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.
ticket/0664_TRA_TRP (diff) – NEMO

Changes between Version 11 and Version 12 of ticket/0664_TRA_TRP


Ignore:
Timestamp:
2010-07-29T11:53:40+02:00 (14 years ago)
Author:
cetlod
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ticket/0664_TRA_TRP

    v11 v12  
    3030   for example, for CEN2 advection the routine start as follows: 
    3131{{{ 
    32    SUBROUTINE tra_adv_cen2( kt, cdtype, pun, pvn, pwn, ptrab, ptran, ptraa ) 
     32   SUBROUTINE tra_adv_cen2( kt, cdtype, pun, pvn, pwn, ptrab, ptran, ptraa, kjpt ) 
    3333      !!---------------------------------------------------------------------- 
    3434      !!                  ***  ROUTINE tra_adv_cen2  *** 
     
    3838      !! ** Method  :  
    3939      !!---------------------------------------------------------------------- 
    40       INTEGER         , INTENT(in   )                         ::   kt              ! ocean time-step index 
    41       CHARACTER(len=3), INTENT(in   )                         ::   cdtype          ! =TRA or TRC (tracer indicator) 
    42       REAL(wp)        , INTENT(in   ), DIMENSION(:,:,:  )     ::   pun, pvn, pwn   ! 3 ocean transport components 
    43       REAL(wp)        , INTENT(in   ), DIMENSION(:,:,:,:)     ::   ptrab, ptran    ! before and now tracer fields 
    44       REAL(wp)        , INTENT(inout), DIMENSION(:,:,:,:)     ::   ptraa           ! tracer trend 
    45 }}} 
    46 [[BR]] 
    47  
    48 '''(2)''' Test for T & S 3D arrays by using the fortran '''''RESHAPE''''' function [[BR]][[BR]] 
    49  
    50    In order to test the new tra... modules without changing the temperature and salinity field every where in the code, we use the RESHAPE function in the call of the new routine. For example the call in tra_adv becomes : 
     40      INTEGER         , INTENT(in   )                               ::   kt              ! ocean time-step index 
     41      CHARACTER(len=3), INTENT(in   )                               ::   cdtype          ! =TRA or TRC (tracer indicator) 
     42      INTEGER         , INTENT(in   )                               ::   kjpt            ! number of tracers 
     43      REAL(wp)        , INTENT(in   ), DIMENSION(jpi,jpj,jpk     )  ::   pun, pvn, pwn   ! 3 ocean transport components 
     44      REAL(wp)        , INTENT(in   ), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptrab, ptran    ! before and now tracer fields 
     45      REAL(wp)        , INTENT(inout), DIMENSION(jpi,jpj,jpk,kjpt)  ::   ptraa           ! tracer trend 
     46 
     47}}} 
     48[[BR]] 
     49 
     50'''(2)''' Test for T & S 3D arrays  [[BR]][[BR]] 
     51 
     52   In order to test the new tra... modules without changing the temperature and salinity field every where in the code, we replace T and S 3D arrays by 4D array just within the TRA modules in the call of the new routine. For example, in the step rotuin 
     53 
     54{{{ 
     55   SUBROUTINE stp( kstp ) 
     56      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index 
     57 
     58       bla bla bla bla bla bla 
     59       bla bla bla bla bla bla 
     60 
     61      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
     62      ! Active tracers                              (ua, va used as workspace) 
     63      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
     64                             ta(:,:,:) = 0.e0               ! set tracer trends to zero 
     65                             sa(:,:,:) = 0.e0 
     66 
     67                             CALL tra_swap 
     68                             CALL tra_sbc    ( kstp )       ! surface boundary condition 
     69      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr 
     70      IF( lk_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux 
     71      IF( lk_trabbl      )   CALL tra_bbl    ( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme 
     72      IF( lk_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends 
     73                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection 
     74      IF( n_cla == 1     )   CALL tra_cla    ( kstp )       ! Cross Land Advection (Update Hor. advection) 
     75      IF( lk_zdfkpp )        CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes 
     76                             CALL tra_ldf    ( kstp )       ! lateral mixing 
     77#if defined key_agrif 
     78                             CALL tra_unswap 
     79      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge 
     80                             CALL tra_swap 
     81#endif 
     82                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields 
     83 
     84      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos) 
     85         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )            ! update after fields by non-penetrative convection 
     86                             CALL tra_nxt    ( kstp )            ! tracer fields at next time step 
     87                             CALL tra_unswap 
     88                             CALL eos( ta, sa, rhd, rhop )       ! Time-filtered in situ density for hpg computation 
     89         IF( ln_zps      )   CALL zps_hde( kstp, ta, sa, rhd,   &   ! Partial steps: time filtered hor. derivative 
     90            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level 
     91            &                                   gtv, gsv, grv ) 
     92 
     93      ELSE                                                  ! centered hpg  (eos then time stepping) 
     94                             CALL tra_unswap 
     95                             CALL eos( tn, sn, rhd, rhop )       ! now in situ density for hpg computation 
     96         IF( ln_zps      )   CALL zps_hde( kstp, tn, sn, rhd,   &   ! Partial steps: now horizontal derivative 
     97            &                                   gtu, gsu, gru,  &   ! of t, s, rd at the bottom ocean level 
     98            &                                   gtv, gsv, grv ) 
     99                             CALL tra_swap 
     100         IF( ln_zdfnpc   )   CALL tra_npc    ( kstp )       ! update after fields by non-penetrative convection 
     101                             CALL tra_nxt    ( kstp )       ! tracer fields at next time step 
     102                             CALL tra_unswap 
     103      ENDIF 
     104 
     105       bla bla bla bla bla bla 
     106       bla bla bla bla bla bla 
     107}}} 
     108 
     109{{{ 
     110MODULE traswp 
     111   !!============================================================================== 
     112   !!                       ***  MODULE  traswp  *** 
     113   !! Ocean active tracers: swapping array  
     114   !!============================================================================== 
     115   USE par_oce 
     116   USE oce             ! ocean dynamics and active tracers 
     117 
     118   IMPLICIT NONE 
     119   PRIVATE 
     120 
     121   PUBLIC   tra_swap    ! routine called by step.F90 
     122   PUBLIC   tra_unswap    ! routine called by step.F90 
     123 
     124 
     125CONTAINS 
     126 
     127   SUBROUTINE tra_swap 
     128      !!---------------------------------------------------------------------- 
     129      !!                  ***  ROUTINE tra_swp  *** 
     130      !!                    
     131      !! ** Purpose : Store temperature and salinity aaray into a 4D array  
     132      !! 
     133      !!---------------------------------------------------------------------- 
     134 
     135      tsn(:,:,:,jp_tem) = tn(:,:,:)      ;      tsn(:,:,:,jp_sal) = sn(:,:,:) 
     136      tsb(:,:,:,jp_tem) = tb(:,:,:)      ;      tsb(:,:,:,jp_sal) = sb(:,:,:) 
     137      tsa(:,:,:,jp_tem) = ta(:,:,:)      ;      tsa(:,:,:,jp_sal) = sa(:,:,:) 
     138 
     139   END SUBROUTINE tra_swap 
     140 
     141   SUBROUTINE tra_unswap 
     142      !!---------------------------------------------------------------------- 
     143      !!                  ***  ROUTINE tra_unswap  *** 
     144      !!                    
     145      !! ** Purpose : Store temperature and salinity aaray into a 4D array  
     146      !! 
     147      !!---------------------------------------------------------------------- 
     148 
     149      tn(:,:,:) = tsn(:,:,:,jp_tem)      ;      sn(:,:,:) = tsn(:,:,:,jp_sal) 
     150      tb(:,:,:) = tsb(:,:,:,jp_tem)      ;      sb(:,:,:) = tsb(:,:,:,jp_sal) 
     151      ta(:,:,:) = tsa(:,:,:,jp_tem)      ;      sa(:,:,:) = tsa(:,:,:,jp_sal) 
     152 
     153   END SUBROUTINE tra_unswap 
     154 
     155   !!====================================================================== 
     156END MODULE traswp 
     157}}} 
     158 
     159 
     160For example the call in tra_adv becomes : 
    51161 
    52162{{{ 
     
    65175      !!---------------------------------------------------------------------- 
    66176 
    67       !                                              ! effective transport 
    68177      DO jk = 1, jpkm1 
    69 #if defined key_trabbl_adv                                       
    70          !                                                ! eulerian + bbl transport 
    71          zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * ( un(:,:,jk) - u_bbl(:,:,jk) ) 
    72          zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * ( vn(:,:,jk) - v_bbl(:,:,jk) ) 
    73          zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * ( wn(:,:,jk) + w_bbl(:,:,jk) ) 
    74 #else 
    75178         !                                                ! eulerian transport only 
    76          zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) *   un(:,:,jk) 
    77          zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) *   vn(:,:,jk) 
    78          zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      *   wn(:,:,jk) 
    79 #endif 
     179         zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk) 
     180         zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk) 
     181         zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * wn(:,:,jk) 
     182         ! 
    80183      END DO 
    81184      zwn(:,:,jpk) = 0.e0                                 ! no transport trough the bottom 
    82185 
    83186      !                                                   ! add the eiv transport (if necessary) 
    84       IF( lk_traldf_eiv )   CALL tra_adv_eiv( kt, zun, zvn, zwn ) 
    85  
    86       CALL tra_adv_cen2( kt, 'TRA', zun, zvn, zwn                        ,  & 
    87          &                          RESHAPE( tb, (/jpi,jpj,jpk,2/), sb ) ,  & 
    88          &                          RESHAPE( tn, (/jpi,jpj,jpk,2/), sn ) ,  & 
    89          &                          RESHAPE( ta, (/jpi,jpj,jpk,2/), sa )      )    ! 2nd order centered 
     187      IF( lk_traldf_eiv )   CALL tra_adv_eiv( kt, zun, zvn, zwn, 'TRA' ) 
     188 
     189      CALL tra_adv_cen2( kt, 'TRA', zun, zvn, zwn, tsb, tsn, tsa, jpts )    ! 2nd order centered 
    90190}}} 
    91191 
    92192   N.B. the transport given in argument is now the effective transport, i.e. including the one associated with eddy induced velocity, or bbl. 
    93  
     193[[BR]] 
     194   N.B : We've first planned to use the fortran '''''RESHAPE''''' function for tests on T & S tracers. This function allowed to create a 4D array by  merging two 3D arrays : RESHAPE( tb, (/jpi,jpj,jpk,2/), sb ).  But, the performances of vectorisation when using the '''''RESHAPE''''' function are very poor - tests have been done on CCRT NEC-SX8 computer 
     195    
    94196[[BR]] 
    95197 
     
    113215      !!---------------------------------------------------------------------- 
    114216 
    115       !                                              ! effective transport 
    116217      DO jk = 1, jpkm1 
    117 #if defined key_trcbbl_adv                                       
    118          !                                                ! eulerian + bbl transport 
    119          zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * ( un(:,:,jk) - u_trc_bbl(:,:,jk) ) 
    120          zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * ( vn(:,:,jk) - v_trc_bbl(:,:,jk) ) 
    121          zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * ( wn(:,:,jk) + w_trc_bbl(:,:,jk) ) 
    122 #else 
    123218         !                                                ! eulerian transport only 
    124          zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) *   un(:,:,jk) 
    125          zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) *   vn(:,:,jk) 
    126          zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      *   wn(:,:,jk) 
    127 #endif 
     219         zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk) 
     220         zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk) 
     221         zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * wn(:,:,jk) 
     222         ! 
    128223      END DO 
    129224      zwn(:,:,jpk) = 0.e0                                 ! no transport trough the bottom 
    130225 
    131226      !                                                   ! add the eiv transport (if necessary) 
    132       IF( lk_trcldf_eiv )   CALL trc_adv_eiv( kt, zun, zvn, zwn ) 
    133  
    134       CALL tra_adv_cen2( kt, 'TRC', zun, zvn, zwn, trb, trn, tra )    ! 2nd order centered 
    135 }}} 
    136  
    137 [[BR]] 
     227      IF( lk_traldf_eiv )   CALL tra_adv_eiv( kt, zun, zvn, zwn, 'TRC' ) 
     228 
     229      CALL tra_adv_cen2( kt, 'TRC', zun, zvn, zwn, trb, trn, tra, jptra )    ! 2nd order centered 
     230}}} 
     231 
     232[[BR]] 
     233 
    138234 
    139235'''(4)''' Final step : replace T and S 3D arrays by 4D arrays TS throughout the code  [[BR]][[BR]] 
     
    141237'''Additional Tasks'''[[BR]] 
    142238[[BR]] 
    143 - TRENDS[[BR]] 
    144    * Split the OPA_SRC/TRD/trmod.F90 module in 2 modules 
    145       * trends_dyn.F90 which manages dynamical trend diagnostics 
    146       * trends_tra.F90 for the tracers trend diagnostics 
    147    * As a starting point, both active & passive tracers trends modules ( trdmld.F90 & trdmld_trc.F90 ) will be encapsulate in one module 
    148 [[BR]] 
    149 - OBC[[BR]] 
    150     * rewrite the radiative OBC with 4D array as input argument. OBC will be then available for passive tracers 
    151 ---- 
     239 - TRENDS : As a starting point, both active & passive tracers trends modules ( trdmld.F90 & trdmld_trc.F90 ) will be encapsulate in one module 
     240 
    152241=== Testing === 
    153242Testing could consider (where appropriate) other configurations in addition to NVTK].