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 1438 for trunk/NEMO/OPA_SRC/DYN/dynspg_exp.F90 – NEMO

Ignore:
Timestamp:
2009-05-11T16:34:47+02:00 (15 years ago)
Author:
rblod
Message:

Merge VVL branch with the trunk (act II), see ticket #429

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/DYN/dynspg_exp.F90

    r1146 r1438  
    44   !! Ocean dynamics:  surface pressure gradient trend 
    55   !!====================================================================== 
     6   !! History :  9.0  !  2005-11  (V. Garnier, G. Madec, L. Bessieres) Original code 
     7   !!---------------------------------------------------------------------- 
    68#if defined key_dynspg_exp   ||   defined key_esopa 
    79   !!---------------------------------------------------------------------- 
     
    1113   !!                      pressure gradient in the free surface constant   
    1214   !!                      volume case with vector optimization 
    13    !!   exp_rst      : read/write the explicit restart fields in the ocean restart file 
    1415   !!---------------------------------------------------------------------- 
    15    !! * Modules used 
    1616   USE oce             ! ocean dynamics and tracers  
    1717   USE dom_oce         ! ocean space and time domain  
     
    3131   PRIVATE 
    3232 
    33    !! * Accessibility 
    34    PUBLIC dyn_spg_exp  ! routine called by step.F90 
    35    PUBLIC exp_rst      ! routine called by istate.F90 
     33   PUBLIC   dyn_spg_exp   ! routine called by step.F90 
    3634 
    3735   !! * Substitutions 
     
    3937#  include "vectopt_loop_substitute.h90" 
    4038   !!---------------------------------------------------------------------- 
    41    !!  OPA 9.0 , LOCEAN-IPSL (2005)  
     39   !! NEMO/OPA 3.2 , LOCEAN-IPSL (2009)  
    4240   !! $Id$ 
    43    !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt  
     41   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)  
    4442   !!---------------------------------------------------------------------- 
    45  
    4643 
    4744CONTAINS 
     
    6259      !!      -1- Compute the now surface pressure gradient 
    6360      !!      -2- Add it to the general trend 
    64       !!      -3- Compute the horizontal divergence of velocities 
    65       !!      - the now divergence is given by : 
    66       !!         zhdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] ) 
    67       !!      - integrate the horizontal divergence from the bottom  
    68       !!         to the surface 
    69       !!      - apply lateral boundary conditions on zhdivn 
    70       !!      -4- Estimate the after sea surface elevation from the kinematic 
    71       !!         surface boundary condition: 
    72       !!         zssha = sshb - 2 rdt ( zhdiv + emp ) 
    73       !!      - Time filter applied on now sea surface elevation to avoid 
    74       !!         the divergence of two consecutive time-steps and swap of free 
    75       !!         surface arrays to start the next time step: 
    76       !!         sshb = sshn + atfp * [ sshb + zssha - 2 sshn ] 
    77       !!         sshn = zssha 
    78       !!      - apply lateral boundary conditions on sshn 
    7961      !! 
    8062      !! ** Action : - Update (ua,va) with the surf. pressure gradient trend 
     63      !!--------------------------------------------------------------------- 
     64      INTEGER, INTENT( in )  ::   kt         ! ocean time-step index 
    8165      !! 
    82       !! References : 
    83       !! 
    84       !! History : 
    85       !!   9.0  !  05-11  (V. Garnier, G. Madec, L. Bessieres) Original code 
    86       !! 
    87       !!--------------------------------------------------------------------- 
    88       !! * Arguments 
    89       INTEGER, INTENT( in )  ::   kt         ! ocean time-step index 
    90  
    91       !! * Local declarations 
    9266      INTEGER  ::   ji, jj, jk               ! dummy loop indices 
    93       REAL(wp) ::   z2dt, zraur, zssha       ! temporary scalars  
    94       REAL(wp), DIMENSION(jpi,jpj)    ::  &  ! temporary arrays 
    95          &         zhdiv 
    9667      !!---------------------------------------------------------------------- 
    9768 
     
    10475         spgu(:,:) = 0.e0                     ! surface pressure gradient (i-direction) 
    10576         spgv(:,:) = 0.e0                     ! surface pressure gradient (j-direction) 
    106  
    107          CALL exp_rst( nit000, 'READ' )       ! read or initialize the following fields: 
    108          !                                    ! sshb, sshn 
    109  
    11077      ENDIF 
    11178 
    112       IF( .NOT. lk_vvl ) THEN 
     79      ! read or estimate sea surface height and vertically integrated velocities 
     80      IF( lk_obc )   CALL obc_dta_bt( kt, 0 ) 
    11381 
    114          ! 0. Initialization 
    115          ! ----------------- 
    116          ! read or estimate sea surface height and vertically integrated velocities 
    117          IF( lk_obc )   CALL obc_dta_bt( kt, 0 ) 
    118          z2dt = 2. * rdt                                       ! time step: leap-frog 
    119          IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt       ! time step: Euler if restart from rest 
    120          zraur = 1.e0 / rauw 
     82      ! Surface pressure gradient (now) 
     83      DO jj = 2, jpjm1 
     84         DO ji = fs_2, fs_jpim1   ! vector opt. 
     85            spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj) 
     86            spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj) 
     87         END DO 
     88      END DO 
    12189 
    122          ! 1. Surface pressure gradient (now) 
    123          ! ---------------------------- 
     90      ! Add the surface pressure trend to the general trend 
     91      DO jk = 1, jpkm1 
    12492         DO jj = 2, jpjm1 
    12593            DO ji = fs_2, fs_jpim1   ! vector opt. 
    126                spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj) 
    127                spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj) 
     94               ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) 
     95               va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) 
    12896            END DO 
    12997         END DO 
     98      END DO 
    13099 
    131          ! 2. Add the surface pressure trend to the general trend 
    132          ! ------------------------------------------------------ 
    133          DO jk = 1, jpkm1 
    134             DO jj = 2, jpjm1 
    135                DO ji = fs_2, fs_jpim1   ! vector opt. 
    136                   ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj) 
    137                   va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj) 
    138                END DO 
    139             END DO 
    140          END DO 
    141       
    142          ! 3. Vertical integration of horizontal divergence of velocities 
    143          ! -------------------------------- 
    144          zhdiv(:,:) = 0.e0 
    145          DO jk = jpkm1, 1, -1 
    146             DO jj = 2, jpjm1 
    147                DO ji = fs_2, fs_jpim1   ! vector opt. 
    148                   zhdiv(ji,jj) = zhdiv(ji,jj) + (  e2u(ji  ,jj  ) * fse3u(ji  ,jj  ,jk) * un(ji  ,jj  ,jk)      & 
    149                      &                           - e2u(ji-1,jj  ) * fse3u(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)      & 
    150                      &                           + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * vn(ji  ,jj  ,jk)      & 
    151                      &                           - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  )   & 
    152                      &                        / ( e1t(ji,jj) * e2t(ji,jj) ) 
    153                END DO 
    154             END DO 
    155          END DO 
    156  
    157 #if defined key_obc 
    158          ! open boundaries (div must be zero behind the open boundary) 
    159          !  mpp remark: The zeroing of zhdiv can probably be extended to 1->jpi/jpj for the correct row/column 
    160          IF( lp_obc_east  )   zhdiv(nie0p1:nie1p1,nje0  :nje1  ) = 0.e0      ! east 
    161          IF( lp_obc_west  )   zhdiv(niw0  :niw1  ,njw0  :njw1  ) = 0.e0      ! west 
    162          IF( lp_obc_north )   zhdiv(nin0  :nin1  ,njn0p1:njn1p1) = 0.e0      ! north 
    163          IF( lp_obc_south )   zhdiv(nis0  :nis1  ,njs0  :njs1  ) = 0.e0      ! south 
    164 #endif 
    165  
    166          ! 4. Sea surface elevation time stepping 
    167          ! -------------------------------------- 
    168          ! Euler (forward) time stepping, no time filter 
    169          IF( neuler == 0 .AND. kt == nit000 ) THEN 
    170             DO jj = 1, jpj 
    171                DO ji = 1, jpi 
    172                   ! after free surface elevation 
    173                   zssha = sshb(ji,jj) - rdt * ( zraur * emp(ji,jj) + zhdiv(ji,jj) ) * tmask(ji,jj,1) 
    174                   ! swap of arrays 
    175                   sshb(ji,jj) = sshn(ji,jj) 
    176                   sshn(ji,jj) = zssha 
    177                END DO 
    178             END DO 
    179          ELSE 
    180             ! Leap-frog time stepping and time filter 
    181             DO jj = 1, jpj 
    182                DO ji = 1, jpi 
    183                   ! after free surface elevation 
    184                   zssha = sshb(ji,jj) - z2dt * ( zraur * emp(ji,jj) + zhdiv(ji,jj) ) * tmask(ji,jj,1) 
    185                   ! time filter and array swap 
    186                   sshb(ji,jj) = atfp * ( sshb(ji,jj) + zssha ) + atfp1 * sshn(ji,jj) 
    187                   sshn(ji,jj) = zssha 
    188                END DO 
    189             END DO 
    190          ENDIF 
    191  
    192       ELSE !! Variable volume, ssh time-stepping already done 
    193  
    194          ! read or estimate sea surface height and vertically integrated velocities 
    195          IF( lk_obc )   CALL obc_dta_bt( kt, 0 ) 
    196  
    197          ! Sea surface elevation swap 
    198          ! ----------------------------- 
    199          ! 
    200          sshbb(:,:) = sshb(:,:) ! Needed for the dynamics time-stepping 
    201          ! 
    202          IF( neuler == 0 .AND. kt == nit000 ) THEN 
    203             ! No time filter 
    204             sshb(:,:) = sshn(:,:) 
    205             sshn(:,:) = ssha(:,:) 
    206          ELSE 
    207             ! Time filter 
    208             sshb(:,:) = atfp * ( sshb(:,:) + ssha(:,:) ) + atfp1 * sshn(:,:) 
    209             sshn(:,:) = ssha(:,:) 
    210          ENDIF 
    211  
    212       ENDIF 
    213  
    214       ! Boundary conditions on sshn 
    215       IF( .NOT. lk_obc ) CALL lbc_lnk( sshn, 'T', 1. ) 
    216  
    217       ! write filtered free surface arrays in restart file 
    218       ! -------------------------------------------------- 
    219       IF( lrst_oce )   CALL exp_rst( kt, 'WRITE' ) 
    220   
    221       IF(ln_ctl) THEN         ! print sum trends (used for debugging) 
    222          CALL prt_ctl(tab2d_1=sshn, clinfo1=' ssh      : ', mask1=tmask) 
    223       ENDIF 
    224        
    225100   END SUBROUTINE dyn_spg_exp 
    226101 
    227    SUBROUTINE exp_rst( kt, cdrw ) 
    228       !!--------------------------------------------------------------------- 
    229       !!                   ***  ROUTINE exp_rst  *** 
    230       !! 
    231       !! ** Purpose : Read or write explicit arrays in restart file 
    232       !!---------------------------------------------------------------------- 
    233       INTEGER         , INTENT(in) ::   kt         ! ocean time-step 
    234       CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag 
    235       ! 
    236       !!---------------------------------------------------------------------- 
    237       ! 
    238       IF( TRIM(cdrw) == 'READ' ) THEN 
    239          IF( iom_varid( numror, 'sshn', ldstop = .FALSE. ) > 0 ) THEN 
    240             CALL iom_get( numror, jpdom_autoglo, 'sshb'  , sshb(:,:)   ) 
    241             CALL iom_get( numror, jpdom_autoglo, 'sshn'  , sshn(:,:)   ) 
    242             IF( neuler == 0 ) sshb(:,:) = sshn(:,:) 
    243          ELSE 
    244             IF( nn_rstssh == 1 ) THEN   
    245                sshb(:,:) = 0.e0 
    246                sshn(:,:) = 0.e0 
    247             ENDIF 
    248          ENDIF 
    249       ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN 
    250          CALL iom_rstput( kt, nitrst, numrow, 'sshb'  , sshb  (:,:) ) 
    251          CALL iom_rstput( kt, nitrst, numrow, 'sshn'  , sshn  (:,:) ) 
    252       ENDIF 
    253       ! 
    254    END SUBROUTINE exp_rst 
    255102#else 
    256103   !!---------------------------------------------------------------------- 
     
    261108      WRITE(*,*) 'dyn_spg_exp: You should not have seen this print! error?', kt 
    262109   END SUBROUTINE dyn_spg_exp 
    263    SUBROUTINE exp_rst( kt, cdrw )     ! Empty routine 
    264       INTEGER         , INTENT(in) ::   kt         ! ocean time-step 
    265       CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag 
    266       WRITE(*,*) 'exp_rst: You should not have seen this print! error?', kt, cdrw 
    267    END SUBROUTINE exp_rst 
    268110#endif 
    269     
     111 
    270112   !!====================================================================== 
    271113END MODULE dynspg_exp 
Note: See TracChangeset for help on using the changeset viewer.