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 9863 for NEMO/branches/2018/dev_r9838_ENHANCE04_MLF/src/OCE/DOM/restart.F90 – NEMO

Ignore:
Timestamp:
2018-06-30T12:51:02+02:00 (6 years ago)
Author:
gm
Message:

#1911 (ENHANCE-04): simplified implementation of the Euler stepping at nit000

File:
1 moved

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2018/dev_r9838_ENHANCE04_MLF/src/OCE/DOM/restart.F90

    r9839 r9863  
    88   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart 
    99   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA 
    10    !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D) 
    11    !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart 
    12    !!             -   !  2014-12  (G. Madec) remove KPP scheme 
    13    !!---------------------------------------------------------------------- 
    14  
    15    !!---------------------------------------------------------------------- 
    16    !!   rst_opn    : open the ocean restart file 
    17    !!   rst_write  : write the ocean restart file 
    18    !!   rst_read   : read the ocean restart file 
    19    !!---------------------------------------------------------------------- 
    20    USE oce             ! ocean dynamics and tracers  
    21    USE dom_oce         ! ocean space and time domain 
    22    USE sbc_ice         ! only lk_si3  
    23    USE phycst          ! physical constants 
    24    USE eosbn2          ! equation of state            (eos bn2 routine) 
    25    USE trdmxl_oce      ! ocean active mixed layer tracers trends variables 
     10   !!            - -  !  2010-10  (C. Ethe, G. Madec)  TRC-TRA merge (T-S in 4D) 
     11   !!            3.7  !  2014-01  (G. Madec)  suppression of curl and hdiv from the restart 
     12   !!             -   !  2014-12  (G. Madec)  remove KPP scheme 
     13   !!            4.0  !  2018-06  (G. Madec)  introduce l_1st_euler 
     14   !!---------------------------------------------------------------------- 
     15 
     16   !!---------------------------------------------------------------------- 
     17   !!   rst_opn       : open the ocean restart file in write mode 
     18   !!   rst_write     : write the ocean restart file 
     19   !!   rst_read_open : open the ocean restart file in read mode 
     20   !!   rst_read      : read the ocean restart file 
     21   !!---------------------------------------------------------------------- 
     22   USE oce            ! ocean dynamics and tracers  
     23   USE dom_oce        ! ocean space and time domain 
     24   USE sbc_ice        ! only lk_si3  
     25   USE phycst         ! physical constants 
     26   USE eosbn2         ! equation of state            (eos bn2 routine) 
     27   USE trdmxl_oce     ! ocean active mixed layer tracers trends variables 
     28   USE diurnal_bulk   !  
    2629   ! 
    27    USE in_out_manager  ! I/O manager 
    28    USE iom             ! I/O module 
    29    USE diurnal_bulk 
     30   USE in_out_manager ! I/O manager 
     31   USE iom            ! I/O module 
    3032 
    3133   IMPLICIT NONE 
     
    3436   PUBLIC   rst_opn         ! routine called by step module 
    3537   PUBLIC   rst_write       ! routine called by step module 
     38   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init 
    3639   PUBLIC   rst_read        ! routine called by istate module 
    37    PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init 
    3840 
    3941   !! * Substitutions 
     
    144146      INTEGER, INTENT(in) ::   kt   ! ocean time-step 
    145147      !!---------------------------------------------------------------------- 
    146                      IF(lwxios) CALL iom_swap(      cwxios_context          ) 
    147                      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       , ldxios = lwxios)   ! dynamics time step 
    148  
    149       IF ( .NOT. ln_diurnal_only ) THEN 
    150                      CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub, ldxios = lwxios        )     ! before fields 
    151                      CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb, ldxios = lwxios        ) 
    152                      CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lwxios ) 
    153                      CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lwxios ) 
    154                      CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb, ldxios = lwxios      ) 
    155                      ! 
    156                      CALL iom_rstput( kt, nitrst, numrow, 'un'     , un, ldxios = lwxios        )     ! now fields 
    157                      CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn, ldxios = lwxios        ) 
    158                      CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lwxios ) 
    159                      CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lwxios ) 
    160                      CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn, ldxios = lwxios      ) 
    161                      CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop, ldxios = lwxios      ) 
    162                   ! extra variable needed for the ice sheet coupling 
    163                   IF ( ln_iscpl ) THEN  
    164                      CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask, ldxios = lwxios ) ! need to extrapolate T/S 
    165                      CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask, ldxios = lwxios ) ! need to correct barotropic velocity 
    166                      CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask, ldxios = lwxios ) ! need to correct barotropic velocity 
    167                      CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask, ldxios = lwxios) ! need to correct barotropic velocity 
    168                      CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:), ldxios = lwxios )   ! need to compute temperature correction 
    169                      CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation 
    170                      CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:), ldxios = lwxios )   ! need to compute bt conservation 
    171                      CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:), ldxios = lwxios ) ! need to compute extrapolation if vvl 
    172                   END IF 
    173       ENDIF 
    174        
    175       IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )   
    176       IF(lwxios) CALL iom_swap(      cxios_context          ) 
     148      IF( lwxios )   CALL iom_swap( cwxios_context ) 
     149          
     150      CALL    iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_rdt           , ldxios = lwxios )   ! dynamics time step 
     151      ! 
     152      IF( .NOT. ln_diurnal_only ) THEN 
     153         CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub               , ldxios = lwxios )   ! before fields 
     154         CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb               , ldxios = lwxios ) 
     155         CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem), ldxios = lwxios ) 
     156         CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal), ldxios = lwxios ) 
     157         CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb             , ldxios = lwxios ) 
     158         ! 
     159         CALL iom_rstput( kt, nitrst, numrow, 'un'     , un               , ldxios = lwxios )     ! now fields 
     160         CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vn               , ldxios = lwxios ) 
     161         CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem), ldxios = lwxios ) 
     162         CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal), ldxios = lwxios ) 
     163         CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn             , ldxios = lwxios ) 
     164         CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop             , ldxios = lwxios ) 
     165         ! 
     166         IF( ln_iscpl ) THEN          ! extra variable needed for the ice sheet coupling 
     167            CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask  , ldxios = lwxios )    ! need to extrapolate T/S 
     168            CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask  , ldxios = lwxios )    ! need to correct barotropic velocity 
     169            CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask  , ldxios = lwxios )    ! need to correct barotropic velocity 
     170            CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask , ldxios = lwxios )    ! need to correct barotropic velocity 
     171            CALL iom_rstput( kt, nitrst, numrow, 'e3t_n'  , e3t_n  , ldxios = lwxios )    ! need to compute temperature correction 
     172            CALL iom_rstput( kt, nitrst, numrow, 'e3u_n'  , e3u_n  , ldxios = lwxios )    ! need to compute bt conservation 
     173            CALL iom_rstput( kt, nitrst, numrow, 'e3v_n'  , e3v_n  , ldxios = lwxios )    ! need to compute bt conservation 
     174            CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n, ldxios = lwxios )    ! need to compute extrapolation if vvl 
     175         ENDIF 
     176      ENDIF 
     177      ! 
     178      IF( ln_diurnal )   CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )   
     179      IF( lwxios     )   CALL iom_swap( cxios_context ) 
    177180      IF( kt == nitrst ) THEN 
    178          IF(.NOT.lwxios) THEN 
    179             CALL iom_close( numrow )     ! close the restart file (only at last time step) 
    180          ELSE 
    181             CALL iom_context_finalize(      cwxios_context          ) 
     181         IF( lwxios ) THEN   ;   CALL iom_context_finalize( cwxios_context ) 
     182         ELSE                ;   CALL iom_close( numrow )     ! close the restart file (only at last time step) 
    182183         ENDIF 
    183184!!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE. 
    184185!!gm  not sure what to do here   ===>>>  ask to Sebastian 
    185186         lrst_oce = .FALSE. 
    186             IF( ln_rst_list ) THEN 
    187                nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1)) 
    188                nitrst = nstocklist( nrst_lst ) 
    189             ENDIF 
     187         IF( ln_rst_list ) THEN 
     188            nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1)) 
     189            nitrst = nstocklist( nrst_lst ) 
     190         ENDIF 
    190191      ENDIF 
    191192      ! 
     
    202203      !!                the file has already been opened 
    203204      !!---------------------------------------------------------------------- 
    204       INTEGER        ::   jlibalt = jprstlib 
    205       LOGICAL        ::   llok 
    206       CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file 
     205      INTEGER       ::   jlibalt = jprstlib 
     206      LOGICAL       ::   llok 
     207      CHARACTER(lc) ::   clpath   ! full path to ocean output restart file 
    207208      !!---------------------------------------------------------------------- 
    208209      ! 
     
    238239         ENDIF  
    239240      ENDIF 
    240  
     241      ! 
    241242   END SUBROUTINE rst_read_open 
    242243 
     
    254255      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d 
    255256      !!---------------------------------------------------------------------- 
    256  
     257      ! 
    257258      CALL rst_read_open           ! open restart for reading (if not already opened) 
    258259 
     
    260261      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN 
    261262         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios ) 
    262          IF( zrdt /= rdt )   neuler = 0 
     263         IF( zrdt /= rn_rdt ) THEN 
     264            IF(lwp) WRITE( numout,*) 
     265            IF(lwp) WRITE( numout,*) 'rst_read:  rdt not equal to the read one' 
     266            IF(lwp) WRITE( numout,*) 
     267            IF(lwp) WRITE( numout,*) '      ==>>>   forced euler first time-step' 
     268            l_1st_euler =  .TRUE. 
     269         ENDIF 
    263270      ENDIF 
    264271 
     
    266273      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst, ldxios = lrxios )  
    267274      IF ( ln_diurnal_only ) THEN  
    268          IF(lwp) WRITE( numout, * ) & 
    269          &   "rst_read:- ln_diurnal_only set, setting rhop=rau0"  
     275         IF(lwp) WRITE( numout,*) 'rst_read: ln_diurnal_only set, setting rhop=rau0' 
    270276         rhop = rau0 
    271277         CALL iom_get( numror, jpdom_autoglo, 'tn'     , w3d, ldxios = lrxios )  
     
    274280      ENDIF   
    275281       
    276       IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN 
     282      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0  .AND. .NOT.l_1st_euler ) THEN 
    277283         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub, ldxios = lrxios                )   ! before fields 
    278284         CALL iom_get( numror, jpdom_autoglo, 'vb'     , vb, ldxios = lrxios                ) 
     
    281287         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb, ldxios = lrxios              ) 
    282288      ELSE 
    283          neuler = 0 
     289         l_1st_euler =  .TRUE.      ! before field not found, forced euler 1st time-step 
    284290      ENDIF 
    285291      ! 
     
    295301      ENDIF 
    296302      ! 
    297       IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0) 
    298          tsb  (:,:,:,:) = tsn  (:,:,:,:)                             ! all before fields set to now values 
    299          ub   (:,:,:)   = un   (:,:,:) 
    300          vb   (:,:,:)   = vn   (:,:,:) 
    301          sshb (:,:)     = sshn (:,:) 
    302          ! 
    303          IF( .NOT.ln_linssh ) THEN 
    304             DO jk = 1, jpk 
    305                e3t_b(:,:,jk) = e3t_n(:,:,jk) 
    306             END DO 
    307          ENDIF 
    308          ! 
     303      IF( l_1st_euler ) THEN              ! Euler restart 
     304         tsb (:,:,:,:) = tsn (:,:,:,:)          ! all before fields set to now values 
     305         ub  (:,:,:)   = un  (:,:,:) 
     306         vb  (:,:,:)   = vn  (:,:,:) 
     307         sshb(:,:)     = sshn(:,:) 
     308         IF( .NOT.ln_linssh )   e3t_b(:,:,:) = e3t_n(:,:,:) 
    309309      ENDIF 
    310310      ! 
Note: See TracChangeset for help on using the changeset viewer.