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 6225 for branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90 – NEMO

Ignore:
Timestamp:
2016-01-08T10:35:19+01:00 (8 years ago)
Author:
jamesharle
Message:

Update MPP_BDY_UPDATE branch to be consistent with head of trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4704_NOC5_MPP_BDY_UPDATE/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90

    r4693 r6225  
    99   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA 
    1010   !!            - -  !  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 
    1113   !!---------------------------------------------------------------------- 
    1214 
     
    1820   USE oce             ! ocean dynamics and tracers  
    1921   USE dom_oce         ! ocean space and time domain 
     22   USE sbc_ice         ! only lk_lim3  
    2023   USE phycst          ! physical constants 
     24   USE eosbn2          ! equation of state            (eos bn2 routine) 
     25   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables 
     26   ! 
    2127   USE in_out_manager  ! I/O manager 
    2228   USE iom             ! I/O module 
    23    USE eosbn2          ! equation of state            (eos bn2 routine) 
    24    USE trdmld_oce      ! ocean active mixed layer tracers trends variables 
    25    USE divcur          ! hor. divergence and curl      (div & cur routines) 
    26    USE sbc_ice, ONLY : lk_lim3 
    27  
     29   USE diurnal_bulk 
     30    
    2831   IMPLICIT NONE 
    2932   PRIVATE 
     
    3538 
    3639   !! * Substitutions 
    37 #  include "domzgr_substitute.h90" 
    3840#  include "vectopt_loop_substitute.h90" 
    3941   !!---------------------------------------------------------------------- 
     
    5759      !! 
    5860      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step deine as a character 
    59       CHARACTER(LEN=50)   ::   clname   ! ice output restart file name 
     61      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name 
     62      CHARACTER(lc)       ::   clpath   ! full path to ocean output restart file 
    6063      !!---------------------------------------------------------------------- 
    6164      ! 
    6265      IF( kt == nit000 ) THEN   ! default definitions 
    6366         lrst_oce = .FALSE.    
    64          nitrst = nitend 
    65       ENDIF 
    66       IF( MOD( kt - 1, nstock ) == 0 ) THEN    
     67         IF( ln_rst_list ) THEN 
     68            nrst_lst = 1 
     69            nitrst = nstocklist( nrst_lst ) 
     70         ELSE 
     71            nitrst = nitend 
     72         ENDIF 
     73      ENDIF 
     74 
     75      ! frequency-based restart dumping (nn_stock) 
     76      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nstock ) == 0 ) THEN    
    6777         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment 
    6878         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing 
     
    7383      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1 
    7484      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN 
    75          ! beware of the format used to write kt (default is i8.8, that should be large enough...) 
    76          IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst 
    77          ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst 
    78          ENDIF 
    79          ! create the file 
    80          clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out) 
    81          IF(lwp) THEN 
    82             WRITE(numout,*) 
    83             SELECT CASE ( jprstlib ) 
    84             CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ocean restart binary file: '//clname 
    85             CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart NetCDF file: '//clname 
    86             END SELECT 
    87             IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression' 
    88             IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt 
    89             ELSE                          ;   WRITE(numout,*) '             kt = '             , kt 
     85         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN  
     86            ! beware of the format used to write kt (default is i8.8, that should be large enough...) 
     87            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst 
     88            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst 
    9089            ENDIF 
    91          ENDIF 
    92          ! 
    93          CALL iom_open( clname, numrow, ldwrt = .TRUE., kiolib = jprstlib ) 
    94          lrst_oce = .TRUE. 
     90            ! create the file 
     91            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out) 
     92            clpath = TRIM(cn_ocerst_outdir) 
     93            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' 
     94            IF(lwp) THEN 
     95               WRITE(numout,*) 
     96               SELECT CASE ( jprstlib ) 
     97               CASE DEFAULT         ;   WRITE(numout,*)                            & 
     98                   '             open ocean restart NetCDF file: ',TRIM(clpath)//clname 
     99               END SELECT 
     100               IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression' 
     101               IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt 
     102               ELSE                          ;   WRITE(numout,*) '             kt = '             , kt 
     103               ENDIF 
     104            ENDIF 
     105            ! 
     106            CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib ) 
     107            lrst_oce = .TRUE. 
     108         ENDIF 
    95109      ENDIF 
    96110      ! 
     
    110124      !!---------------------------------------------------------------------- 
    111125 
    112                      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics time step 
    113                      CALL iom_rstput( kt, nitrst, numrow, 'rdttra1', rdttra(1) )   ! surface tracer time step 
    114  
     126                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rdt       )   ! dynamics and tracer time step 
     127 
     128      IF ( .NOT. ln_diurnal_only ) THEN 
    115129                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , ub        )     ! before fields 
    116130                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vb        ) 
    117131                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem) ) 
    118132                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal) ) 
    119                      CALL iom_rstput( kt, nitrst, numrow, 'rotb'   , rotb      ) 
    120                      CALL iom_rstput( kt, nitrst, numrow, 'hdivb'  , hdivb     ) 
    121133                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      ) 
    122       IF( lk_lim3 )  CALL iom_rstput( kt, nitrst, numrow, 'fse3t_b', fse3t_b(:,:,:) ) 
    123134                     ! 
    124135                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un        )     ! now fields 
     
    126137                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem) ) 
    127138                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal) ) 
    128                      CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn      ) 
    129                      CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn     ) 
    130139                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      ) 
    131140                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      ) 
    132 #if defined key_zdfkpp 
    133                      CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       ) 
    134 #endif 
    135                   IF( lk_lim3 ) THEN 
    136                      CALL iom_rstput( kt, nitrst, numrow, 'iatte'  , iatte     ) !clem modif 
    137                      CALL iom_rstput( kt, nitrst, numrow, 'oatte'  , oatte     ) !clem modif 
    138                   ENDIF 
     141 
     142                  ! extra variable needed for the ice sheet coupling 
     143                  IF ( ln_iscpl ) THEN  
     144                     CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask     ) ! need to extrapolate T/S 
     145                     CALL iom_rstput( kt, nitrst, numrow, 'umask'  , umask     ) ! need to correct barotropic velocity 
     146                     CALL iom_rstput( kt, nitrst, numrow, 'vmask'  , vmask     ) ! need to correct barotropic velocity 
     147                     CALL iom_rstput( kt, nitrst, numrow, 'smask'  , ssmask    ) ! need to correct barotropic velocity 
     148                     CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t_n(:,:,:) )   ! need to compute temperature correction 
     149                     CALL iom_rstput( kt, nitrst, numrow, 'e3u_n', e3u_n(:,:,:) )   ! need to compute bt conservation 
     150                     CALL iom_rstput( kt, nitrst, numrow, 'e3v_n', e3v_n(:,:,:) )   ! need to compute bt conservation 
     151                     CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', gdepw_n(:,:,:) ) ! need to compute extrapolation if vvl 
     152                  END IF 
     153      ENDIF 
     154       
     155      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst    )   
     156 
    139157      IF( kt == nitrst ) THEN 
    140158         CALL iom_close( numrow )     ! close the restart file (only at last time step) 
    141          IF( .NOT. lk_trdmld )   lrst_oce = .FALSE. 
     159!!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE. 
     160!!gm  not sure what to do here   ===>>>  ask to Sebastian 
     161         lrst_oce = .FALSE. 
     162            IF( ln_rst_list ) THEN 
     163               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1)) 
     164               nitrst = nstocklist( nrst_lst ) 
     165            ENDIF 
     166            lrst_oce = .FALSE. 
    142167      ENDIF 
    143168      ! 
    144169   END SUBROUTINE rst_write 
     170 
    145171 
    146172   SUBROUTINE rst_read_open 
     
    153179      !!                the file has already been opened 
    154180      !!---------------------------------------------------------------------- 
    155       INTEGER  ::   jlibalt = jprstlib 
    156       LOGICAL  ::   llok 
    157       !!---------------------------------------------------------------------- 
    158  
    159       IF( numror .LE. 0 ) THEN 
     181      INTEGER        ::   jlibalt = jprstlib 
     182      LOGICAL        ::   llok 
     183      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file 
     184      !!---------------------------------------------------------------------- 
     185      ! 
     186      IF( numror <= 0 ) THEN 
    160187         IF(lwp) THEN                                             ! Contol prints 
    161188            WRITE(numout,*) 
    162189            SELECT CASE ( jprstlib ) 
    163190            CASE ( jpnf90    )   ;   WRITE(numout,*) 'rst_read : read oce NetCDF restart file' 
    164             CASE ( jprstdimg )   ;   WRITE(numout,*) 'rst_read : read oce binary restart file' 
    165191            END SELECT 
    166192            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support' 
     
    168194         ENDIF 
    169195 
    170          IF ( jprstlib == jprstdimg ) THEN 
    171            ! eventually read netcdf file (monobloc)  for restarting on different number of processors 
    172            ! if {cn_ocerst_in}.nc exists, then set jlibalt to jpnf90 
    173            INQUIRE( FILE = TRIM(cn_ocerst_in)//'.nc', EXIST = llok ) 
    174            IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF 
    175          ENDIF 
    176          CALL iom_open( cn_ocerst_in, numror, kiolib = jlibalt ) 
     196         clpath = TRIM(cn_ocerst_indir) 
     197         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' 
     198         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt ) 
    177199      ENDIF 
    178200   END SUBROUTINE rst_read_open 
     201 
    179202 
    180203   SUBROUTINE rst_read 
     
    186209      !! ** Method  :   Read in restart.nc file fields which are necessary for restart 
    187210      !!---------------------------------------------------------------------- 
    188       REAL(wp) ::   zrdt, zrdttra1 
     211      REAL(wp) ::   zrdt 
    189212      INTEGER  ::   jk 
    190       LOGICAL  ::   llok 
    191213      !!---------------------------------------------------------------------- 
    192214 
     
    198220         IF( zrdt /= rdt )   neuler = 0 
    199221      ENDIF 
    200       IF( iom_varid( numror, 'rdttra1', ldstop = .FALSE. ) > 0 )   THEN 
    201          CALL iom_get( numror, 'rdttra1', zrdttra1 ) 
    202          IF( zrdttra1 /= rdttra(1) )   neuler = 0 
    203       ENDIF 
    204       !  
     222 
     223      ! Diurnal DSST  
     224      IF( ln_diurnal ) CALL iom_get( numror, jpdom_autoglo, 'Dsst' , x_dsst  )  
     225      IF ( ln_diurnal_only ) THEN  
     226         IF(lwp) WRITE( numout, * ) & 
     227         &   "rst_read:- ln_diurnal_only set, setting rhop=rau0"  
     228         rhop = rau0 
     229         CALL iom_get( numror, jpdom_autoglo, 'tn'     , tsn(:,:,1,jp_tem) )  
     230         RETURN  
     231      ENDIF   
     232       
    205233      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN 
    206234         CALL iom_get( numror, jpdom_autoglo, 'ub'     , ub      )   ! before fields 
     
    208236         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem) ) 
    209237         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal) ) 
    210          CALL iom_get( numror, jpdom_autoglo, 'rotb'   , rotb    ) 
    211          CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb   ) 
    212238         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb    ) 
    213          IF( lk_lim3 )   CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) ) 
    214239      ELSE 
    215240         neuler = 0 
     
    221246      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal) ) 
    222247      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    ) 
    223       IF( iom_varid( numror, 'rotn', ldstop = .FALSE. ) > 0 ) THEN 
    224          CALL iom_get( numror, jpdom_autoglo, 'rotn'   , rotn    ) 
    225          CALL iom_get( numror, jpdom_autoglo, 'hdivn'  , hdivn   ) 
    226       ELSE 
    227          CALL div_cur( 0 )                              ! Horizontal divergence & Relative vorticity 
    228       ENDIF 
    229248      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN 
    230249         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop    )   ! now    potential density 
    231250      ELSE 
    232          CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )    
    233       ENDIF 
    234 #if defined key_zdfkpp 
    235       IF( iom_varid( numror, 'rhd', ldstop = .FALSE. ) > 0 ) THEN 
    236          CALL iom_get( numror, jpdom_autoglo, 'rhd'    , rhd     )   ! now    in situ density anomaly 
    237       ELSE 
    238          CALL eos( tsn, rhd, fsdept_n(:,:,:) )   ! compute rhd 
    239       ENDIF 
    240 #endif 
     251         CALL eos( tsn, rhd, rhop, gdept_n(:,:,:) )    
     252      ENDIF 
    241253      ! 
    242254      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0) 
     
    244256         ub   (:,:,:)   = un   (:,:,:) 
    245257         vb   (:,:,:)   = vn   (:,:,:) 
    246          rotb (:,:,:)   = rotn (:,:,:) 
    247          hdivb(:,:,:)   = hdivn(:,:,:) 
    248258         sshb (:,:)     = sshn (:,:) 
    249          IF( lk_lim3 ) THEN 
     259         ! 
     260         IF( .NOT.ln_linssh ) THEN 
    250261            DO jk = 1, jpk 
    251                fse3t_b(:,:,jk) = fse3t_n(:,:,jk) 
     262               e3t_b(:,:,jk) = e3t_n(:,:,jk) 
    252263            END DO 
    253264         ENDIF 
    254       ENDIF 
    255       ! 
    256       IF( lk_lim3 ) THEN 
    257          CALL iom_get( numror, jpdom_autoglo, 'iatte' , iatte ) ! clem modif 
    258          CALL iom_get( numror, jpdom_autoglo, 'oatte' , oatte ) ! clem modif 
     265         ! 
    259266      ENDIF 
    260267      ! 
Note: See TracChangeset for help on using the changeset viewer.