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 783 for trunk/NEMO/OPA_SRC/restart.F90 – NEMO

Ignore:
Timestamp:
2008-01-07T15:29:41+01:00 (16 years ago)
Author:
smasson
Message:

write multiple restarts, see ticket:44

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/restart.F90

    r746 r783  
    6565      !!---------------------------------------------------------------------- 
    6666      ! 
    67       IF( kt == nit000 ) THEN   ! default initialization, to do: should be read in the namelist... 
    68          nitrst = nitend        ! to do: should be read in the namelist in a cleaver way... 
    69          lrst_oce = .FALSE. 
    70       ENDIF 
    71  
    72       IF    ( kt == nitrst-1 .AND. lrst_oce         ) THEN 
    73          CALL ctl_stop( 'rst_opn: we cannot create an ocean restart at every time step',    & 
    74             &           'if the run has more than one time step!!!' ) 
    75          numrow = 0 
    76       ELSEIF( kt == nitrst-1 .OR.  nitend == nit000 ) THEN   ! beware if model runs only one time step 
    77          ! beware of the format used to write kt (default is i8.8, that should be large enough) 
    78          IF( nitrst > 1.0e9 ) THEN    
    79             WRITE(clkt,*) nitrst 
    80          ELSE 
    81             WRITE(clkt,'(i8.8)') nitrst 
     67      IF( kt == nit000 ) THEN   ! default definitions 
     68         lrst_oce = .FALSE.    
     69         nitrst = nitend 
     70      ENDIF 
     71      IF( MOD( kt - 1, nstock ) == 0 ) THEN    
     72         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment 
     73         nitrst = kt + nstock - 1                  ! define the next value of nitrst for restart writing 
     74         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run 
     75      ENDIF 
     76 
     77      ! to get better performances with NetCDF format: 
     78      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1) 
     79      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1 
     80      IF( kt == nitrst - 1 .OR. nstock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN 
     81         ! beware of the format used to write kt (default is i8.8, that should be large enough...) 
     82         IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst 
     83         ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst 
    8284         ENDIF 
    8385         ! create the file 
     
    8688            WRITE(numout,*) 
    8789            SELECT CASE ( jprstlib ) 
    88             CASE ( jpnf90 ) 
    89                WRITE(numout,*) '             open ocean restart.output NetCDF file: '//clname 
    90             CASE ( jprstdimg ) 
    91                WRITE(numout,*) '             open ocean restart.output binary file: '//clname 
     90            CASE ( jprstdimg )   ;   WRITE(numout,*) '             open ocean restart binary file: '//clname 
     91            CASE DEFAULT         ;   WRITE(numout,*) '             open ocean restart NetCDF file: '//clname 
    9292            END SELECT 
    93             IF( kt == nitrst-1 ) THEN 
    94                WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp 
    95             ELSE 
    96                WRITE(numout,*) '             kt = ', kt,' date= ', ndastp 
     93            IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt,' date= ', ndastp 
     94            ELSE                          ;   WRITE(numout,*) '             kt = '             , kt,' date= ', ndastp 
    9795            ENDIF 
    9896         ENDIF 
     
    116114      INTEGER, INTENT(in) ::   kt   ! ocean time-step 
    117115      !!---------------------------------------------------------------------- 
     116 
     117      IF( kt == nitrst ) THEN 
     118         IF(lwp) WRITE(numout,*) 
     119         IF(lwp) WRITE(numout,*) 'rst_write : write oce restart file  kt =', kt 
     120         IF(lwp) WRITE(numout,*) '~~~~~~~'          
     121      ENDIF 
    118122 
    119123      ! calendar control 
Note: See TracChangeset for help on using the changeset viewer.