New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 5034 for branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90 – NEMO

Ignore:
Timestamp:
2015-01-15T14:48:42+01:00 (9 years ago)
Author:
andrewryan
Message:

merge with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4650_UKMO14.12_STAND_ALONE_OBSOPER/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90

    r4499 r5034  
    44   !! Ocean  tracers:  horizontal & vertical advective trend 
    55   !!====================================================================== 
    6    !! History :  8.2  ! 2001-08  (G. Madec, E. Durand) trahad+trazad=traadv  
    7    !!            1.0  ! 2002-06  (G. Madec)  F90: Free form and module 
    8    !!            9.0  ! 2004-08  (C. Talandier) New trends organization 
     6   !! History :  OPA  ! 2001-08  (G. Madec, E. Durand) v8.2 trahad+trazad=traadv  
     7   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module 
     8   !!             -   ! 2004-08  (C. Talandier) New trends organization 
    99   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization 
    1010   !!            2.0  ! 2006-04  (R. Benshila, G. Madec) Step reorganization 
     
    2121   USE dom_oce         ! ocean space and time domain 
    2222   USE eosbn2          ! equation of state 
    23    USE trdmod_oce      ! tracers trends 
    24    USE trdtra          ! tracers trends 
     23   USE trd_oce         ! trends: ocean variables 
     24   USE trdtra          ! trends manager: tracers  
    2525   USE closea          ! closed sea 
    2626   USE sbcrnf          ! river runoffs 
     
    3333   USE wrk_nemo        ! Memory Allocation 
    3434   USE timing          ! Timing 
     35   USE phycst 
    3536 
    3637   IMPLICIT NONE 
    3738   PRIVATE 
    3839 
    39    PUBLIC   tra_adv_cen2       ! routine called by step.F90 
    40    PUBLIC   ups_orca_set       ! routine used by traadv_cen2_jki.F90 
    41  
    42    LOGICAL  :: l_trd       ! flag to compute trends 
     40   PUBLIC   tra_adv_cen2   ! routine called by traadv.F90 
    4341 
    4442   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: upsmsk !: mixed upstream/centered scheme near some straits  
     
    5553 
    5654   SUBROUTINE tra_adv_cen2( kt, kit000, cdtype, pun, pvn, pwn,     & 
    57       &                                 ptb, ptn, pta, kjpt   )  
     55      &                                         ptb, ptn, pta, kjpt   )  
    5856      !!---------------------------------------------------------------------- 
    5957      !!                  ***  ROUTINE tra_adv_cen2  *** 
     
    8583      !!       * Add this trend now to the general trend of tracer (ta,sa): 
    8684      !!               pta = pta + ztra 
    87       !!       * trend diagnostic ('key_trdtra' defined): the trend is 
     85      !!       * trend diagnostic (l_trdtra=T or l_trctra=T): the trend is 
    8886      !!      saved for diagnostics. The trends saved is expressed as 
    89       !!      Uh.gradh(T), i.e. 
    90       !!                     save trend = ztra + ptn divn 
     87      !!      Uh.gradh(T), i.e.  save trend = ztra + ptn divn 
    9188      !! 
    9289      !!         Part II : vertical advection 
     
    104101      !!         Add this trend now to the general trend of tracer (ta,sa): 
    105102      !!             pta = pta + ztra 
    106       !!         Trend diagnostic ('key_trdtra' defined): the trend is 
     103      !!         Trend diagnostic (l_trdtra=T or l_trctra=T): the trend is 
    107104      !!      saved for diagnostics. The trends saved is expressed as : 
    108105      !!             save trend =  w.gradz(T) = ztra - ptn divn. 
     
    111108      !!              - save trends if needed 
    112109      !!---------------------------------------------------------------------- 
    113       USE oce     , ONLY:   zwx => ua        , zwy  => va          ! (ua,va) used as 3D workspace 
    114       ! 
    115110      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index 
    116111      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index 
     
    121116      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend  
    122117      ! 
    123       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices 
    124       INTEGER  ::   ierr             ! local integer 
     118      INTEGER  ::   ji, jj, jk, jn, ikt   ! dummy loop indices 
     119      INTEGER  ::   ierr                 ! local integer 
    125120      REAL(wp) ::   zbtr, ztra                            ! local scalars 
    126121      REAL(wp) ::   zfp_ui, zfp_vj, zfp_w, zcofi          !   -      - 
     
    128123      REAL(wp) ::   zupsut, zcenut, zupst                 !   -      - 
    129124      REAL(wp) ::   zupsvt, zcenvt, zcent, zice           !   -      - 
    130       REAL(wp), POINTER, DIMENSION(:,:  ) :: ztfreez  
    131       REAL(wp), POINTER, DIMENSION(:,:,:) :: zwz, zind 
     125      REAL(wp), POINTER, DIMENSION(:,:)   :: zfzp, zpres   ! 2D workspace 
     126      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwx, zwy     ! 3D     - 
     127      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwz, zind    !  -     - 
    132128      !!---------------------------------------------------------------------- 
    133129      ! 
    134130      IF( nn_timing == 1 )  CALL timing_start('tra_adv_cen2') 
    135131      ! 
    136       CALL wrk_alloc( jpi, jpj, ztfreez ) 
    137       CALL wrk_alloc( jpi, jpj, jpk, zwz, zind ) 
     132      CALL wrk_alloc( jpi, jpj, zpres, zfzp ) 
     133      CALL wrk_alloc( jpi, jpj, jpk, zwx, zwy, zwz, zind ) 
    138134      ! 
    139135 
     
    144140         IF(lwp) WRITE(numout,*) 
    145141         ! 
    146          IF ( .NOT. ALLOCATED( upsmsk ) )  THEN 
     142         IF( .NOT. ALLOCATED( upsmsk ) )  THEN 
    147143             ALLOCATE( upsmsk(jpi,jpj), STAT=ierr ) 
    148144             IF( ierr /= 0 )   CALL ctl_stop('STOP', 'tra_adv_cen2: unable to allocate array') 
     
    162158      ENDIF 
    163159      ! 
    164       l_trd = .FALSE. 
    165       IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) )   l_trd = .TRUE. 
    166       ! 
    167160      ! Upstream / centered scheme indicator 
    168161      ! ------------------------------------ 
    169162!!gm  not strickly exact : the freezing point should be computed at each ocean levels... 
    170163!!gm  not a big deal since cen2 is no more used in global ice-ocean simulations 
    171       ztfreez(:,:) = tfreez( tsn(:,:,1,jp_sal) ) 
     164!!ch  changes for ice shelf to retain standard behaviour elsewhere, even if not optimal  
     165      DO jj = 1, jpj  
     166         DO ji = 1, jpi  
     167            ikt = mikt(ji,jj)  
     168            IF (ikt > 1 ) THEN  
     169               zpres(ji,jj) = grav * rau0 * fsdept(ji,jj,ikt) * 1.e-04   
     170            ELSE  
     171               zpres(ji,jj) = 0.0  
     172            ENDIF   
     173         END DO  
     174      END DO  
     175      zfzp(:,:) = eos_fzp( tsn(:,:,1,jp_sal), zpres(:,:) ) 
    172176      DO jk = 1, jpk 
    173177         DO jj = 1, jpj 
    174178            DO ji = 1, jpi 
    175179               !                                        ! below ice covered area (if tn < "freezing"+0.1 ) 
    176                IF( tsn(ji,jj,jk,jp_tem) <= ztfreez(ji,jj) + 0.1 ) THEN   ;   zice = 1.e0 
    177                ELSE                                                      ;   zice = 0.e0 
     180               IF( tsn(ji,jj,jk,jp_tem) <= zfzp(ji,jj) + 0.1 ) THEN   ;   zice = 1._wp 
     181               ELSE                                                   ;   zice = 0._wp 
    178182               ENDIF 
    179183               zind(ji,jj,jk) = MAX (   & 
     
    224228         !                                                     ! Surface value :  
    225229         IF( lk_vvl ) THEN   ;   zwz(:,:, 1 ) = 0.e0                         ! volume variable 
    226          ELSE                ;   zwz(:,:, 1 ) = pwn(:,:,1) * ptn(:,:,1,jn)   ! linear free surface  
     230         ELSE 
     231            DO jj = 1, jpj   ! vector opt. 
     232               DO ji = 1, jpi   ! vector opt. 
     233                  ikt = mikt(ji,jj)                 
     234                  zwz(ji,jj,ikt ) = pwn(ji,jj,ikt) * ptn(ji,jj,ikt,jn)   ! linear free surface  
     235                  zwz(ji,jj,1:ikt-1) = 0.e0 
     236               END DO 
     237            END DO 
    227238         ENDIF 
    228239         ! 
     
    260271         END DO 
    261272 
    262          !                                 ! trend diagnostics (contribution of upstream fluxes) 
    263          IF( l_trd ) THEN 
    264             CALL trd_tra( kt, cdtype, jn, jptra_trd_xad, zwx, pun, ptn(:,:,:,jn) ) 
    265             CALL trd_tra( kt, cdtype, jn, jptra_trd_yad, zwy, pvn, ptn(:,:,:,jn) ) 
    266             CALL trd_tra( kt, cdtype, jn, jptra_trd_zad, zwz, pwn, ptn(:,:,:,jn) ) 
     273         !                                 ! trend diagnostics 
     274         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.    & 
     275            &( cdtype == 'TRC' .AND. l_trdtrc ) )   THEN 
     276            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptn(:,:,:,jn) ) 
     277            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptn(:,:,:,jn) ) 
     278            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwz, pwn, ptn(:,:,:,jn) ) 
    267279         END IF 
    268280         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes) 
    269281         IF( cdtype == 'TRA' .AND. ln_diaptr .AND. ( MOD( kt, nn_fptr ) == 0 ) ) THEN   
    270            IF( jn == jp_tem )  htr_adv(:) = ptr_vj( zwy(:,:,:) ) 
    271            IF( jn == jp_sal )  str_adv(:) = ptr_vj( zwy(:,:,:) ) 
     282           IF( jn == jp_tem )   htr_adv(:) = ptr_vj( zwy(:,:,:) ) 
     283           IF( jn == jp_sal )   str_adv(:) = ptr_vj( zwy(:,:,:) ) 
    272284         ENDIF 
    273285         ! 
    274       ENDDO 
     286      END DO 
    275287 
    276288      ! ---------------------------  required in restart file to ensure restartability) 
     
    281293      ENDIF 
    282294      ! 
    283       CALL wrk_dealloc( jpi, jpj, ztfreez ) 
    284       CALL wrk_dealloc( jpi, jpj, jpk, zwz, zind ) 
     295      CALL wrk_dealloc( jpi, jpj, zpres, zfzp ) 
     296      CALL wrk_dealloc( jpi, jpj, jpk, zwx, zwy, zwz, zind ) 
    285297      ! 
    286298      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_cen2') 
     
    303315      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers 
    304316      !!---------------------------------------------------------------------- 
    305        
    306317      ! 
    307318      IF( nn_timing == 1 )  CALL timing_start('ups_orca_set') 
Note: See TracChangeset for help on using the changeset viewer.