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 11993 for NEMO/trunk/src/OCE/DIA/diaar5.F90 – NEMO

Ignore:
Timestamp:
2019-11-28T11:20:53+01:00 (5 years ago)
Author:
cetlod
Message:

trunk : undo bad commit. Oups

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/OCE/DIA/diaar5.F90

    r11989 r11993  
    7171      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index 
    7272      ! 
    73       INTEGER  ::   ji, jj, jk, iks, ikb                      ! dummy loop arguments 
    74       REAL(wp) ::   zvolssh, zvol, zssh_steric, zztmp, zarho, ztemp, zsal, zmass, zsst 
     73      INTEGER  ::   ji, jj, jk                      ! dummy loop arguments 
     74      REAL(wp) ::   zvolssh, zvol, zssh_steric, zztmp, zarho, ztemp, zsal, zmass 
    7575      REAL(wp) ::   zaw, zbw, zrw 
    7676      ! 
    7777      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: zarea_ssh , zbotpres       ! 2D workspace  
    78       REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: zpe, z2d                   ! 2D workspace  
    79       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   :: zrhd , zrhop, ztpot   ! 3D workspace 
     78      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: zpe                         ! 2D workspace  
     79      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   :: zrhd , zrhop               ! 3D workspace 
    8080      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: ztsn                       ! 4D workspace 
    8181 
     
    8686 
    8787      IF( l_ar5 ) THEN  
    88          ALLOCATE( zarea_ssh(jpi,jpj), zbotpres(jpi,jpj), z2d(jpi,jpj) ) 
     88         ALLOCATE( zarea_ssh(jpi,jpj) , zbotpres(jpi,jpj) ) 
    8989         ALLOCATE( zrhd(jpi,jpj,jpk) , zrhop(jpi,jpj,jpk) ) 
    9090         ALLOCATE( ztsn(jpi,jpj,jpk,jpts) ) 
     
    9292      ENDIF 
    9393      ! 
    94       CALL iom_put( 'e2u'      , e2u (:,:) ) 
    95       CALL iom_put( 'e1v'      , e1v (:,:) ) 
    96       CALL iom_put( 'areacello', area(:,:) ) 
    97       ! 
    98       IF( iom_use( 'volcello' ) .OR. iom_use( 'masscello' )  ) THEN   
    99          zrhd(:,:,jpk) = 0._wp        ! ocean volume ; rhd is used as workspace 
    100          DO jk = 1, jpkm1 
    101             zrhd(:,:,jk) = area(:,:) * e3t_n(:,:,jk) * tmask(:,:,jk) 
    102          END DO 
    103          CALL iom_put( 'volcello'  , zrhd(:,:,:)  )  ! WARNING not consistent with CMIP DR where volcello is at ca. 2000 
    104          CALL iom_put( 'masscello' , rau0 * e3t_n(:,:,:) * tmask(:,:,:) )  ! ocean mass 
    105       ENDIF  
    106       ! 
    107       IF( iom_use( 'e3tb' ) )  THEN    ! bottom layer thickness 
    108          DO jj = 1, jpj 
    109             DO ji = 1, jpi 
    110                ikb = mbkt(ji,jj) 
    111                z2d(ji,jj) = e3t_n(ji,jj,ikb) 
    112             END DO 
    113          END DO 
    114          CALL iom_put( 'e3tb', z2d ) 
    115       ENDIF  
    116       ! 
    11794      IF( iom_use( 'voltot' ) .OR. iom_use( 'sshtot' )  .OR. iom_use( 'sshdyn' )  ) THEN     
    11895         !                                         ! total volume of liquid seawater 
    119          zvolssh = glob_sum( 'diaar5', zarea_ssh(:,:) )  
    120          zvol    = vol0 + zvolssh 
     96         zvolssh = SUM( zarea_ssh(:,:) )  
     97         CALL mpp_sum( 'diaar5', zvolssh ) 
     98         zvol = vol0 + zvolssh 
    12199       
    122100         CALL iom_put( 'voltot', zvol               ) 
     
    140118               DO ji = 1, jpi 
    141119                  DO jj = 1, jpj 
    142                      iks = mikt(ji,jj) 
    143                      zbotpres(ji,jj) = zbotpres(ji,jj) + sshn(ji,jj) * zrhd(ji,jj,iks) + riceload(ji,jj) 
     120                     zbotpres(ji,jj) = zbotpres(ji,jj) + sshn(ji,jj) * zrhd(ji,jj,mikt(ji,jj)) + riceload(ji,jj) 
    144121                  END DO 
    145122               END DO 
     
    152129         END IF 
    153130         !                                          
    154          zarho = glob_sum( 'diaar5', area(:,:) * zbotpres(:,:) )  
     131         zarho = SUM( area(:,:) * zbotpres(:,:) )  
     132         CALL mpp_sum( 'diaar5', zarho ) 
    155133         zssh_steric = - zarho / area_tot 
    156134         CALL iom_put( 'sshthster', zssh_steric ) 
     
    169147               DO ji = 1,jpi 
    170148                  DO jj = 1,jpj 
    171                      iks = mikt(ji,jj) 
    172                      zbotpres(ji,jj) = zbotpres(ji,jj) + sshn(ji,jj) * zrhd(ji,jj,iks) + riceload(ji,jj) 
     149                     zbotpres(ji,jj) = zbotpres(ji,jj) + sshn(ji,jj) * zrhd(ji,jj,mikt(ji,jj)) + riceload(ji,jj) 
    173150                  END DO 
    174151               END DO 
     
    178155         END IF 
    179156         !     
    180          zarho = glob_sum( 'diaar5', area(:,:) * zbotpres(:,:) )  
     157         zarho = SUM( area(:,:) * zbotpres(:,:) )  
     158         CALL mpp_sum( 'diaar5', zarho ) 
    181159         zssh_steric = - zarho / area_tot 
    182160         CALL iom_put( 'sshsteric', zssh_steric ) 
     161       
    183162         !                                         ! ocean bottom pressure 
    184163         zztmp = rau0 * grav * 1.e-4_wp               ! recover pressure from pressure anomaly and cover to dbar = 1.e4 Pa 
     
    189168 
    190169      IF( iom_use( 'masstot' ) .OR. iom_use( 'temptot' )  .OR. iom_use( 'saltot' )  ) THEN     
    191           !                                         ! Mean density anomalie, temperature and salinity 
    192           ztsn(:,:,:,:) = 0._wp                    ! ztsn(:,:,1,jp_tem/sal) is used here as 2D Workspace for temperature & salinity 
    193           DO jk = 1, jpkm1 
    194              DO jj = 1, jpj 
    195                 DO ji = 1, jpi 
    196                    zztmp = area(ji,jj) * e3t_n(ji,jj,jk) 
    197                    ztsn(ji,jj,1,jp_tem) = ztsn(ji,jj,1,jp_tem) + zztmp * tsn(ji,jj,jk,jp_tem) 
    198                    ztsn(ji,jj,1,jp_sal) = ztsn(ji,jj,1,jp_sal) + zztmp * tsn(ji,jj,jk,jp_sal) 
    199                 ENDDO 
    200              ENDDO 
    201           ENDDO 
    202  
    203           IF( ln_linssh ) THEN 
     170         !                                         ! Mean density anomalie, temperature and salinity 
     171         ztemp = 0._wp 
     172         zsal  = 0._wp 
     173         DO jk = 1, jpkm1 
     174            DO jj = 1, jpj 
     175               DO ji = 1, jpi 
     176                  zztmp = area(ji,jj) * e3t_n(ji,jj,jk) 
     177                  ztemp = ztemp + zztmp * tsn(ji,jj,jk,jp_tem) 
     178                  zsal  = zsal  + zztmp * tsn(ji,jj,jk,jp_sal) 
     179               END DO 
     180            END DO 
     181         END DO 
     182         IF( ln_linssh ) THEN 
    204183            IF( ln_isfcav ) THEN 
    205184               DO ji = 1, jpi 
    206185                  DO jj = 1, jpj 
    207                      iks = mikt(ji,jj) 
    208                      ztsn(ji,jj,1,jp_tem) = ztsn(ji,jj,1,jp_tem) + zarea_ssh(ji,jj) * tsn(ji,jj,iks,jp_tem)  
    209                      ztsn(ji,jj,1,jp_sal) = ztsn(ji,jj,1,jp_sal) + zarea_ssh(ji,jj) * tsn(ji,jj,iks,jp_sal)  
     186                     ztemp = ztemp + zarea_ssh(ji,jj) * tsn(ji,jj,mikt(ji,jj),jp_tem)  
     187                     zsal  = zsal  + zarea_ssh(ji,jj) * tsn(ji,jj,mikt(ji,jj),jp_sal)  
    210188                  END DO 
    211189               END DO 
    212190            ELSE 
    213                ztsn(:,:,1,jp_tem) = ztsn(:,:,1,jp_tem) + zarea_ssh(:,:) * tsn(:,:,1,jp_tem)  
    214                ztsn(:,:,1,jp_sal) = ztsn(:,:,1,jp_sal) + zarea_ssh(:,:) * tsn(:,:,1,jp_sal)  
     191               ztemp = ztemp + SUM( zarea_ssh(:,:) * tsn(:,:,1,jp_tem) ) 
     192               zsal  = zsal  + SUM( zarea_ssh(:,:) * tsn(:,:,1,jp_sal) ) 
    215193            END IF 
    216194         ENDIF 
    217          ! 
    218          ztemp = glob_sum( 'diaar5', ztsn(:,:,1,jp_tem) ) 
    219          zsal  = glob_sum( 'diaar5', ztsn(:,:,1,jp_sal) ) 
    220          zmass = rau0 * ( zarho + zvol )       
     195         IF( lk_mpp ) THEN   
     196            CALL mpp_sum( 'diaar5', ztemp ) 
     197            CALL mpp_sum( 'diaar5', zsal  ) 
     198         END IF 
     199         ! 
     200         zmass = rau0 * ( zarho + zvol )                 ! total mass of liquid seawater 
     201         ztemp = ztemp / zvol                            ! potential temperature in liquid seawater 
     202         zsal  = zsal  / zvol                            ! Salinity of liquid seawater 
    221203         ! 
    222204         CALL iom_put( 'masstot', zmass ) 
    223          CALL iom_put( 'temptot', ztemp / zvol ) 
    224          CALL iom_put( 'saltot' , zsal  / zvol ) 
    225          ! 
    226       ENDIF      
    227  
    228       IF( ln_teos10 ) THEN        ! ! potential temperature (TEOS-10 case) 
    229          IF( iom_use( 'toce_pot') .OR. iom_use( 'temptot_pot' ) .OR. iom_use( 'sst_pot' )  & 
    230                                   .OR. iom_use( 'ssttot' ) .OR.  iom_use( 'tosmint_pot' ) ) THEN 
    231             ! 
    232             ALLOCATE( ztpot(jpi,jpj,jpk) ) 
    233             ztpot(:,:,jpk) = 0._wp 
    234             ztpot(:,:,:)   = eos_pt_from_ct( tsn(:,:,:,jp_tem), tsn(:,:,:,jp_sal) ) 
    235             ! 
    236             CALL iom_put( 'toce_pot', ztpot(:,:,:) )  ! potential temperature (TEOS-10 case) 
    237             CALL iom_put( 'sst_pot' , ztpot(:,:,1) )  ! surface temperature 
    238             ! 
    239             IF( iom_use( 'temptot_pot' ) ) THEN   ! Output potential temperature in case we use TEOS-10 
    240                z2d(:,:) = 0._wp 
    241                DO jk = 1, jpkm1 
    242                  z2d(:,:) = z2d(:,:) + area(:,:) * e3t_n(:,:,jk) * ztpot(:,:,jk) 
    243                END DO 
    244                ztemp = glob_sum( 'diaar5', z2d(:,:)  )  
    245                CALL iom_put( 'temptot_pot', ztemp / zvol ) 
    246              ENDIF 
    247              ! 
    248              IF( iom_use( 'ssttot' ) ) THEN   ! Output potential temperature in case we use TEOS-10 
    249                zsst = glob_sum( 'diaar5',  area(:,:) * ztpot(:,:,1)  )  
    250                CALL iom_put( 'ssttot', zsst / area_tot ) 
    251              ENDIF 
    252              ! Vertical integral of temperature 
    253              IF( iom_use( 'tosmint_pot') ) THEN 
    254                z2d(:,:) = 0._wp 
    255                DO jk = 1, jpkm1 
    256                   DO jj = 1, jpj 
    257                      DO ji = 1, jpi   ! vector opt. 
    258                         z2d(ji,jj) = z2d(ji,jj) + rau0 * e3t_n(ji,jj,jk) *  ztpot(ji,jj,jk) 
    259                      END DO 
    260                   END DO 
    261                END DO 
    262                CALL iom_put( 'tosmint_pot', z2d )  
    263             ENDIF 
    264             DEALLOCATE( ztpot ) 
    265         ENDIF 
    266       ELSE        
    267          IF( iom_use('ssttot') ) THEN   ! Output sst in case we use EOS-80 
    268             zsst  = glob_sum( 'diaar5', area(:,:) * tsn(:,:,1,jp_tem) ) 
    269             CALL iom_put('ssttot', zsst / area_tot ) 
    270          ENDIF 
     205         CALL iom_put( 'temptot', ztemp ) 
     206         CALL iom_put( 'saltot' , zsal  ) 
     207         ! 
    271208      ENDIF 
    272209 
    273210      IF( iom_use( 'tnpeo' )) THEN     
    274         ! Work done against stratification by vertical mixing 
    275         ! Exclude points where rn2 is negative as convection kicks in here and 
    276         ! work is not being done against stratification 
     211      ! Work done against stratification by vertical mixing 
     212      ! Exclude points where rn2 is negative as convection kicks in here and 
     213      ! work is not being done against stratification 
    277214         ALLOCATE( zpe(jpi,jpj) ) 
    278215         zpe(:,:) = 0._wp 
     
    282219                  DO ji = 1, jpi 
    283220                     IF( rn2(ji,jj,jk) > 0._wp ) THEN 
    284                         zrw = ( gdept_n(ji,jj,jk) - gdepw_n(ji,jj,jk) ) / e3w_n(ji,jj,jk) 
     221                        zrw =   ( gdepw_n(ji,jj,jk  ) - gdept_n(ji,jj,jk) )   & 
     222                           &  / ( gdept_n(ji,jj,jk-1) - gdept_n(ji,jj,jk) ) 
     223!!gm  this can be reduced to :  (depw-dept) / e3w   (NB idem dans bn2 !) 
     224!                        zrw =   ( gdept_n(ji,jj,jk) - gdepw_n(ji,jj,jk) ) / e3w_n(ji,jj,jk) 
     225!!gm end 
    285226                        ! 
    286227                        zaw = rab_n(ji,jj,jk,jp_tem) * (1. - zrw) + rab_n(ji,jj,jk-1,jp_tem)* zrw 
    287228                        zbw = rab_n(ji,jj,jk,jp_sal) * (1. - zrw) + rab_n(ji,jj,jk-1,jp_sal)* zrw 
    288229                        ! 
    289                         zpe(ji, jj) = zpe(ji,jj)   & 
     230                        zpe(ji, jj) = zpe(ji, jj)            & 
    290231                           &        -  grav * (  avt(ji,jj,jk) * zaw * (tsn(ji,jj,jk-1,jp_tem) - tsn(ji,jj,jk,jp_tem) )  & 
    291232                           &                   - avs(ji,jj,jk) * zbw * (tsn(ji,jj,jk-1,jp_sal) - tsn(ji,jj,jk,jp_sal) ) ) 
     
    298239               DO ji = 1, jpi 
    299240                  DO jj = 1, jpj 
    300                      zpe(ji,jj) = zpe(ji,jj) + avt(ji,jj,jk) * MIN(0._wp,rn2(ji,jj,jk)) * rau0 * e3w_n(ji,jj,jk) 
     241                     zpe(ji,jj) = zpe(ji,jj) + avt(ji, jj, jk) * MIN(0._wp,rn2(ji, jj, jk)) * rau0 * e3w_n(ji, jj, jk) 
    301242                  END DO 
    302243               END DO 
    303244            END DO 
    304245         ENDIF 
     246!!gm useless lbc_lnk since the computation above is performed over 1:jpi & 1:jpj 
     247!!gm           CALL lbc_lnk( 'diaar5', zpe, 'T', 1._wp)          
    305248          CALL iom_put( 'tnpeo', zpe ) 
    306249          DEALLOCATE( zpe ) 
     
    308251 
    309252      IF( l_ar5 ) THEN 
    310         DEALLOCATE( zarea_ssh , zbotpres, z2d ) 
     253        DEALLOCATE( zarea_ssh , zbotpres ) 
    311254        DEALLOCATE( zrhd      , zrhop    ) 
    312255        DEALLOCATE( ztsn                 ) 
     
    344287       CALL lbc_lnk( 'diaar5', z2d, 'U', -1. ) 
    345288       IF( cptr == 'adv' ) THEN 
    346           IF( ktra == jp_tem ) CALL iom_put( 'uadv_heattr' , rau0_rcp * z2d )  ! advective heat transport in i-direction 
    347           IF( ktra == jp_sal ) CALL iom_put( 'uadv_salttr' , rau0     * z2d )  ! advective salt transport in i-direction 
     289          IF( ktra == jp_tem ) CALL iom_put( "uadv_heattr" , rau0_rcp * z2d )  ! advective heat transport in i-direction 
     290          IF( ktra == jp_sal ) CALL iom_put( "uadv_salttr" , rau0     * z2d )  ! advective salt transport in i-direction 
    348291       ENDIF 
    349292       IF( cptr == 'ldf' ) THEN 
    350           IF( ktra == jp_tem ) CALL iom_put( 'udiff_heattr' , rau0_rcp * z2d ) ! diffusive heat transport in i-direction 
    351           IF( ktra == jp_sal ) CALL iom_put( 'udiff_salttr' , rau0     * z2d ) ! diffusive salt transport in i-direction 
     293          IF( ktra == jp_tem ) CALL iom_put( "udiff_heattr" , rau0_rcp * z2d ) ! diffusive heat transport in i-direction 
     294          IF( ktra == jp_sal ) CALL iom_put( "udiff_salttr" , rau0     * z2d ) ! diffusive salt transport in i-direction 
    352295       ENDIF 
    353296       ! 
     
    362305       CALL lbc_lnk( 'diaar5', z2d, 'V', -1. ) 
    363306       IF( cptr == 'adv' ) THEN 
    364           IF( ktra == jp_tem ) CALL iom_put( 'vadv_heattr' , rau0_rcp * z2d )  ! advective heat transport in j-direction 
    365           IF( ktra == jp_sal ) CALL iom_put( 'vadv_salttr' , rau0     * z2d )  ! advective salt transport in j-direction 
     307          IF( ktra == jp_tem ) CALL iom_put( "vadv_heattr" , rau0_rcp * z2d )  ! advective heat transport in j-direction 
     308          IF( ktra == jp_sal ) CALL iom_put( "vadv_salttr" , rau0     * z2d )  ! advective salt transport in j-direction 
    366309       ENDIF 
    367310       IF( cptr == 'ldf' ) THEN 
    368           IF( ktra == jp_tem ) CALL iom_put( 'vdiff_heattr' , rau0_rcp * z2d ) ! diffusive heat transport in j-direction 
    369           IF( ktra == jp_sal ) CALL iom_put( 'vdiff_salttr' , rau0     * z2d ) ! diffusive salt transport in j-direction 
     311          IF( ktra == jp_tem ) CALL iom_put( "vdiff_heattr" , rau0_rcp * z2d ) ! diffusive heat transport in j-direction 
     312          IF( ktra == jp_sal ) CALL iom_put( "vdiff_salttr" , rau0     * z2d ) ! diffusive salt transport in j-direction 
    370313       ENDIF 
    371314           
     
    380323      !!---------------------------------------------------------------------- 
    381324      INTEGER  ::   inum 
    382       INTEGER  ::   ik, idep 
     325      INTEGER  ::   ik 
    383326      INTEGER  ::   ji, jj, jk  ! dummy loop indices 
    384327      REAL(wp) ::   zztmp   
    385328      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) ::   zsaldta   ! Jan/Dec levitus salinity 
    386       REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   zvol0      
    387329      ! 
    388330      !!---------------------------------------------------------------------- 
     
    398340         IF( dia_ar5_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dia_ar5_init : unable to allocate arrays' ) 
    399341 
    400          area(:,:) = e1e2t(:,:) 
    401          area_tot  = glob_sum( 'diaar5', area(:,:) ) 
    402  
    403          ALLOCATE( zvol0(jpi,jpj) ) 
    404          zvol0 (:,:) = 0._wp 
     342         area(:,:) = e1e2t(:,:) * tmask_i(:,:) 
     343 
     344         area_tot = SUM( area(:,:) )   ;   CALL mpp_sum( 'diaar5', area_tot ) 
     345 
     346         vol0        = 0._wp 
    405347         thick0(:,:) = 0._wp 
    406348         DO jk = 1, jpkm1 
    407             DO jj = 1, jpj               ! interpolation of salinity at the last ocean level (i.e. the partial step) 
    408                DO ji = 1, jpi 
    409                   idep = tmask(ji,jj,jk) * e3t_0(ji,jj,jk) 
    410                   zvol0 (ji,jj) = zvol0 (ji,jj) +  idep * area(ji,jj) 
    411                   thick0(ji,jj) = thick0(ji,jj) +  idep     
    412                END DO 
    413             END DO 
    414          END DO 
    415          vol0 = glob_sum( 'diaar5', zvol0 ) 
    416          DEALLOCATE( zvol0 ) 
     349            vol0        = vol0        + SUM( area (:,:) * tmask(:,:,jk) * e3t_0(:,:,jk) ) 
     350            thick0(:,:) = thick0(:,:) +    tmask_i(:,:) * tmask(:,:,jk) * e3t_0(:,:,jk) 
     351         END DO 
     352         CALL mpp_sum( 'diaar5', vol0 ) 
    417353 
    418354         IF( iom_use( 'sshthster' ) ) THEN 
    419             ALLOCATE( zsaldta(jpi,jpj,jpk,jpts) ) 
     355            ALLOCATE( zsaldta(jpi,jpj,jpj,jpts) ) 
    420356            CALL iom_open ( 'sali_ref_clim_monthly', inum ) 
    421357            CALL iom_get  ( inum, jpdom_data, 'vosaline' , zsaldta(:,:,:,1), 1  ) 
Note: See TracChangeset for help on using the changeset viewer.