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

Ignore:
Timestamp:
2015-12-03T09:10:32+01:00 (8 years ago)
Author:
deazer
Message:

Merging TMB and 25h diagnostics to head of trunk
added brief documentation

File:
1 edited

Legend:

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

    r5260 r5989  
    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 trdmxl_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 
    2729 
    2830   IMPLICIT NONE 
     
    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 ( jprstdimg )   ;   WRITE(numout,*)                            & 
     98                   '             open ocean restart binary file: ',TRIM(clpath)//clname 
     99               CASE DEFAULT         ;   WRITE(numout,*)                            & 
     100                   '             open ocean restart NetCDF file: ',TRIM(clpath)//clname 
     101               END SELECT 
     102               IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression' 
     103               IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt 
     104               ELSE                          ;   WRITE(numout,*) '             kt = '             , kt 
     105               ENDIF 
     106            ENDIF 
     107            ! 
     108            CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE., kiolib = jprstlib ) 
     109            lrst_oce = .TRUE. 
     110         ENDIF 
    95111      ENDIF 
    96112      ! 
     
    117133                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem) ) 
    118134                     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     ) 
    121135                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      ) 
    122                      ! 
    123       IF( lk_lim3 )  CALL iom_rstput( kt, nitrst, numrow, 'fse3t_b', fse3t_b(:,:,:) ) 
    124136                     ! 
    125137                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , un        )     ! now fields 
     
    127139                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem) ) 
    128140                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal) ) 
    129                      CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn      ) 
    130                      CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn     ) 
    131141                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      ) 
    132142                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      ) 
    133 #if defined key_zdfkpp 
    134                      CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       ) 
    135 #endif 
    136                   IF( lk_lim3 ) THEN 
    137                      CALL iom_rstput( kt, nitrst, numrow, 'fraqsr_1lev'  , fraqsr_1lev     ) !clem modif 
    138                   ENDIF 
    139143      IF( kt == nitrst ) THEN 
    140144         CALL iom_close( numrow )     ! close the restart file (only at last time step) 
     
    142146!!gm  not sure what to do here   ===>>>  ask to Sebastian 
    143147         lrst_oce = .FALSE. 
     148            IF( ln_rst_list ) THEN 
     149               nrst_lst = MIN(nrst_lst + 1, SIZE(nstocklist,1)) 
     150               nitrst = nstocklist( nrst_lst ) 
     151            ENDIF 
     152            lrst_oce = .FALSE. 
    144153      ENDIF 
    145154      ! 
     
    156165      !!                the file has already been opened 
    157166      !!---------------------------------------------------------------------- 
    158       INTEGER  ::   jlibalt = jprstlib 
    159       LOGICAL  ::   llok 
     167      INTEGER        ::   jlibalt = jprstlib 
     168      LOGICAL        ::   llok 
     169      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file 
    160170      !!---------------------------------------------------------------------- 
    161171      ! 
     
    171181         ENDIF 
    172182 
     183         clpath = TRIM(cn_ocerst_indir) 
     184         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/' 
    173185         IF ( jprstlib == jprstdimg ) THEN 
    174186           ! eventually read netcdf file (monobloc)  for restarting on different number of processors 
    175187           ! if {cn_ocerst_in}.nc exists, then set jlibalt to jpnf90 
    176            INQUIRE( FILE = TRIM(cn_ocerst_in)//'.nc', EXIST = llok ) 
     188           INQUIRE( FILE = TRIM(cn_ocerst_indir)//'/'//TRIM(cn_ocerst_in)//'.nc', EXIST = llok ) 
    177189           IF ( llok ) THEN ; jlibalt = jpnf90  ; ELSE ; jlibalt = jprstlib ; ENDIF 
    178190         ENDIF 
    179          CALL iom_open( cn_ocerst_in, numror, kiolib = jlibalt ) 
     191         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror, kiolib = jlibalt ) 
    180192      ENDIF 
    181193   END SUBROUTINE rst_read_open 
     194 
    182195 
    183196   SUBROUTINE rst_read 
     
    211224         CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem) ) 
    212225         CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal) ) 
    213          CALL iom_get( numror, jpdom_autoglo, 'rotb'   , rotb    ) 
    214          CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb   ) 
    215226         CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb    ) 
    216          IF( lk_lim3 )   CALL iom_get( numror, jpdom_autoglo, 'fse3t_b', fse3t_b(:,:,:) ) 
    217227      ELSE 
    218228         neuler = 0 
     
    224234      CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal) ) 
    225235      CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    ) 
    226       IF( iom_varid( numror, 'rotn', ldstop = .FALSE. ) > 0 ) THEN 
    227          CALL iom_get( numror, jpdom_autoglo, 'rotn'   , rotn    ) 
    228          CALL iom_get( numror, jpdom_autoglo, 'hdivn'  , hdivn   ) 
    229       ELSE 
    230          CALL div_cur( 0 )                              ! Horizontal divergence & Relative vorticity 
    231       ENDIF 
    232236      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN 
    233237         CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop    )   ! now    potential density 
     
    235239         CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )    
    236240      ENDIF 
    237 #if defined key_zdfkpp 
    238       IF( iom_varid( numror, 'rhd', ldstop = .FALSE. ) > 0 ) THEN 
    239          CALL iom_get( numror, jpdom_autoglo, 'rhd'    , rhd     )   ! now    in situ density anomaly 
    240       ELSE 
    241          CALL eos( tsn, rhd, fsdept_n(:,:,:) )   ! compute rhd 
    242       ENDIF 
    243 #endif 
    244241      ! 
    245242      IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0) 
     
    247244         ub   (:,:,:)   = un   (:,:,:) 
    248245         vb   (:,:,:)   = vn   (:,:,:) 
    249          rotb (:,:,:)   = rotn (:,:,:) 
    250          hdivb(:,:,:)   = hdivn(:,:,:) 
    251246         sshb (:,:)     = sshn (:,:) 
    252  
     247         ! 
    253248         IF( lk_vvl ) THEN 
    254249            DO jk = 1, jpk 
     
    256251            END DO 
    257252         ENDIF 
    258  
    259          IF( lk_lim3 .AND. .NOT. lk_vvl ) THEN 
    260             DO jk = 1, jpk 
    261                fse3t_b(:,:,jk) = fse3t_n(:,:,jk) 
    262             END DO 
    263          ENDIF 
    264  
    265       ENDIF 
    266       ! 
    267       IF( lk_lim3 ) THEN 
    268          CALL iom_get( numror, jpdom_autoglo, 'fraqsr_1lev' , fraqsr_1lev ) 
     253         ! 
    269254      ENDIF 
    270255      ! 
Note: See TracChangeset for help on using the changeset viewer.