Changeset 6827 for branches/2016/dev_r6409_SIMPLIF_2_usrdef_tools/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
- Timestamp:
- 2016-08-01T15:37:15+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2016/dev_r6409_SIMPLIF_2_usrdef_tools/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
r6140 r6827 33 33 USE ioipsl , ONLY : ymds2ju ! for calendar 34 34 USE prtctl ! Print control 35 USE trc_oce , ONLY : lk_offline ! offline flag36 35 USE timing ! Timing 37 USE restart ! restart38 36 39 37 IMPLICIT NONE … … 88 86 ndt05 = NINT(0.5 * rdt ) 89 87 90 IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' )91 88 92 89 ! set the calandar from ndastp (read in restart file and namelist) … … 281 278 ENDIF 282 279 283 IF( .NOT. lk_offline ) CALL rst_opn( kt ) ! Open the restart file if needed and control lrst_oce284 IF( lrst_oce ) CALL day_rst( kt, 'WRITE' ) ! write day restart information285 280 ! 286 281 IF( nn_timing == 1 ) CALL timing_stop('day') … … 288 283 END SUBROUTINE day 289 284 290 291 SUBROUTINE day_rst( kt, cdrw )292 !!---------------------------------------------------------------------293 !! *** ROUTINE ts_rst ***294 !!295 !! ** Purpose : Read or write calendar in restart file:296 !!297 !! WRITE(READ) mode:298 !! kt : number of time step since the begining of the experiment at the299 !! end of the current(previous) run300 !! adatrj(0) : number of elapsed days since the begining of the experiment at the301 !! end of the current(previous) run (REAL -> keep fractions of day)302 !! ndastp : date at the end of the current(previous) run (coded as yyyymmdd integer)303 !!304 !! According to namelist parameter nrstdt,305 !! nrstdt = 0 no control on the date (nit000 is arbitrary).306 !! nrstdt = 1 we verify that nit000 is equal to the last307 !! time step of previous run + 1.308 !! In both those options, the exact duration of the experiment309 !! since the beginning (cumulated duration of all previous restart runs)310 !! is not stored in the restart and is assumed to be (nit000-1)*rdt.311 !! This is valid is the time step has remained constant.312 !!313 !! nrstdt = 2 the duration of the experiment in days (adatrj)314 !! has been stored in the restart file.315 !!----------------------------------------------------------------------316 INTEGER , INTENT(in) :: kt ! ocean time-step317 CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag318 !319 REAL(wp) :: zkt, zndastp, zdayfrac, ksecs, ktime320 INTEGER :: ihour, iminute321 !!----------------------------------------------------------------------322 323 IF( TRIM(cdrw) == 'READ' ) THEN324 325 IF( iom_varid( numror, 'kt', ldstop = .FALSE. ) > 0 ) THEN326 ! Get Calendar informations327 CALL iom_get( numror, 'kt', zkt ) ! last time-step of previous run328 IF(lwp) THEN329 WRITE(numout,*) ' *** Info read in restart : '330 WRITE(numout,*) ' previous time-step : ', NINT( zkt )331 WRITE(numout,*) ' *** restart option'332 SELECT CASE ( nrstdt )333 CASE ( 0 ) ; WRITE(numout,*) ' nrstdt = 0 : no control of nit000'334 CASE ( 1 ) ; WRITE(numout,*) ' nrstdt = 1 : no control the date at nit000 (use ndate0 read in the namelist)'335 CASE ( 2 ) ; WRITE(numout,*) ' nrstdt = 2 : calendar parameters read in restart'336 END SELECT337 WRITE(numout,*)338 ENDIF339 ! Control of date340 IF( nit000 - NINT( zkt ) /= 1 .AND. nrstdt /= 0 ) &341 & CALL ctl_stop( ' ===>>>> : problem with nit000 for the restart', &342 & ' verify the restart file or rerun with nrstdt = 0 (namelist)' )343 ! define ndastp and adatrj344 IF ( nrstdt == 2 ) THEN345 ! read the parameters corresponding to nit000 - 1 (last time step of previous run)346 CALL iom_get( numror, 'ndastp', zndastp )347 ndastp = NINT( zndastp )348 CALL iom_get( numror, 'adatrj', adatrj )349 CALL iom_get( numror, 'ntime', ktime )350 nn_time0=INT(ktime)351 ! calculate start time in hours and minutes352 zdayfrac=adatrj-INT(adatrj)353 ksecs = NINT(zdayfrac*86400) ! Nearest second to catch rounding errors in adatrj354 ihour = INT(ksecs/3600)355 iminute = ksecs/60-ihour*60356 357 ! Add to nn_time0358 nhour = nn_time0 / 100359 nminute = ( nn_time0 - nhour * 100 )360 nminute=nminute+iminute361 362 IF( nminute >= 60 ) THEN363 nminute=nminute-60364 nhour=nhour+1365 ENDIF366 nhour=nhour+ihour367 IF( nhour >= 24 ) THEN368 nhour=nhour-24369 adatrj=adatrj+1370 ENDIF371 nn_time0 = nhour * 100 + nminute372 adatrj = INT(adatrj) ! adatrj set to integer as nn_time0 updated373 ELSE374 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day)375 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam376 nhour = nn_time0 / 100377 nminute = ( nn_time0 - nhour * 100 )378 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0)379 adatrj = ( REAL( nit000-1, wp ) * rdt ) / rday380 ! note this is wrong if time step has changed during run381 ENDIF382 ELSE383 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day)384 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam385 nhour = nn_time0 / 100386 nminute = ( nn_time0 - nhour * 100 )387 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0)388 adatrj = ( REAL( nit000-1, wp ) * rdt ) / rday389 ENDIF390 IF( ABS(adatrj - REAL(NINT(adatrj),wp)) < 0.1 / rday ) adatrj = REAL(NINT(adatrj),wp) ! avoid truncation error391 !392 IF(lwp) THEN393 WRITE(numout,*) ' *** Info used values : '394 WRITE(numout,*) ' date ndastp : ', ndastp395 WRITE(numout,*) ' number of elapsed days since the begining of run : ', adatrj396 WRITE(numout,*) ' nn_time0 : ',nn_time0397 WRITE(numout,*)398 ENDIF399 !400 ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN401 !402 IF( kt == nitrst ) THEN403 IF(lwp) WRITE(numout,*)404 IF(lwp) WRITE(numout,*) 'rst_write : write oce restart file kt =', kt405 IF(lwp) WRITE(numout,*) '~~~~~~~'406 ENDIF407 ! calendar control408 CALL iom_rstput( kt, nitrst, numrow, 'kt' , REAL( kt , wp) ) ! time-step409 CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp) ) ! date410 CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj ) ! number of elapsed days since411 ! ! the begining of the run [s]412 CALL iom_rstput( kt, nitrst, numrow, 'ntime' , REAL( nn_time0, wp) ) ! time413 ENDIF414 !415 END SUBROUTINE day_rst416 285 417 286 !!======================================================================
Note: See TracChangeset
for help on using the changeset viewer.