- Timestamp:
- 2018-09-12T15:59:13+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/branches/2018/dev_r5003_MERCATOR6_CRS/NEMOGCM/NEMO/SAS_SRC/daymod.F90
r7256 r10115 2 2 !!====================================================================== 3 3 !! *** MODULE daymod *** 4 !! Ocean : calendar 4 !! Ocean : calendar 5 5 !!===================================================================== 6 6 !! History : OPA ! 1994-09 (M. Pontaud M. Imbard) Original code 7 7 !! ! 1997-03 (O. Marti) 8 !! ! 1997-05 (G. Madec) 8 !! ! 1997-05 (G. Madec) 9 9 !! ! 1997-08 (M. Imbard) 10 10 !! NEMO 1.0 ! 2003-09 (G. Madec) F90 + nyear, nmonth, nday 11 11 !! ! 2004-01 (A.M. Treguier) new calculation based on adatrj 12 12 !! ! 2006-08 (G. Madec) surface module major update 13 !!---------------------------------------------------------------------- 13 !!---------------------------------------------------------------------- 14 14 15 15 !!---------------------------------------------------------------------- 16 16 !! day : calendar 17 !! 17 !! 18 18 !! ------------------------------- 19 19 !! ----------- WARNING ----------- … … 24 24 !! ----------- WARNING ----------- 25 25 !! ------------------------------- 26 !! 26 !! 27 27 !!---------------------------------------------------------------------- 28 28 USE dom_oce ! ocean space and time domain 29 29 USE phycst ! physical constants 30 30 USE in_out_manager ! I/O manager 31 USE iom ! 31 USE iom ! 32 32 USE ioipsl, ONLY : ymds2ju ! for calendar 33 33 USE prtctl ! Print control 34 USE restart !34 USE trc_oce, ONLY : lk_offline ! offline flag 35 35 USE timing ! Timing 36 USE restart ! restart 36 37 37 38 IMPLICIT NONE … … 40 41 PUBLIC day ! called by step.F90 41 42 PUBLIC day_init ! called by istate.F90 42 43 INTEGER :: nsecd, nsecd05, ndt, ndt05 43 PUBLIC day_mth ! Needed by TAM 44 45 INTEGER, PUBLIC :: nsecd, nsecd05, ndt, ndt05 ! (PUBLIC for TAM) 44 46 45 47 !!---------------------------------------------------------------------- … … 53 55 !!---------------------------------------------------------------------- 54 56 !! *** ROUTINE day_init *** 55 !! 56 !! ** Purpose : Initialization of the calendar values to their values 1 time step before nit000 57 !! 58 !! ** Purpose : Initialization of the calendar values to their values 1 time step before nit000 57 59 !! because day will be called at the beginning of step 58 60 !! … … 85 87 ndt05 = NINT(0.5 * rdttra(1)) 86 88 87 ! ==> clem: here we read the ocean restart for the date (only if it exists) 88 ! It is not clean and another solution should be found 89 CALL day_rst( nit000, 'READ' ) 90 ! ==> 91 92 ! set the calendar from ndastp (read in restart file and namelist) 89 IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' ) 90 91 ! set the calandar from ndastp (read in restart file and namelist) 93 92 94 93 nyear = ndastp / 10000 95 94 nmonth = ( ndastp - (nyear * 10000) ) / 100 96 nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) 95 nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) 97 96 98 97 CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday ) ! we assume that we start run at 00:00 … … 102 101 nsec1jan000 = 0 103 102 CALL day_mth 104 103 105 104 IF ( nday == 0 ) THEN ! for ex if ndastp = ndate0 - 1 106 nmonth = nmonth - 1 105 nmonth = nmonth - 1 107 106 nday = nmonth_len(nmonth) 108 107 ENDIF … … 113 112 IF( nleapy == 1 ) CALL day_mth 114 113 ENDIF 115 114 116 115 ! day since january 1st 117 116 nday_year = nday + SUM( nmonth_len(1:nmonth - 1) ) 118 117 119 !compute number of days between last monday and today 118 !compute number of days between last monday and today 120 119 CALL ymds2ju( 1900, 01, 01, 0.0, zjul ) ! compute julian day value of 01.01.1900 (our reference that was a Monday) 121 inbday = NINT(fjulday - zjul) ! compute nb day between 01.01.1900 and current day 122 idweek = MOD(inbday, 7) ! compute nb day between last monday and current day 120 inbday = NINT(fjulday - zjul) ! compute nb day between 01.01.1900 and current day 121 idweek = MOD(inbday, 7) ! compute nb day between last monday and current day 123 122 124 123 ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step … … 142 141 !!---------------------------------------------------------------------- 143 142 !! *** ROUTINE day_init *** 144 !! 143 !! 145 144 !! ** Purpose : calendar values related to the months 146 145 !! … … 154 153 155 154 ! length of the month of the current year (from nleapy, read in namelist) 156 IF ( nleapy < 2 ) THEN 155 IF ( nleapy < 2 ) THEN 157 156 nmonth_len(:) = (/ 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31 /) 158 157 nyear_len(:) = 365 … … 177 176 ! time since Jan 1st 0 1 2 ... 11 12 13 178 177 ! ---------*--|--*--|--*--| ... |--*--|--*--|--*--|-------------------------------------- 179 ! <---> <---> <---> ... <---> <---> <---> 178 ! <---> <---> <---> ... <---> <---> <---> 180 179 ! month number 0 1 2 ... 11 12 13 181 180 ! … … 190 189 nmonth_end(jm) = nmonth_end(jm-1) + nsecd * nmonth_len(jm) 191 190 END DO 192 ! 193 END SUBROUTINE 191 ! 192 END SUBROUTINE 194 193 195 194 … … 197 196 !!---------------------------------------------------------------------- 198 197 !! *** ROUTINE day *** 199 !! 198 !! 200 199 !! ** Purpose : Compute the date with a day iteration IF necessary. 201 200 !! … … 209 208 !! - adatrj : date in days since the beginning of the run 210 209 !! - nsec_year : current time of the year (in second since 00h, jan 1st) 211 !!---------------------------------------------------------------------- 210 !!---------------------------------------------------------------------- 212 211 INTEGER, INTENT(in) :: kt ! ocean time-step indices 213 212 ! … … 220 219 zprec = 0.1 / rday 221 220 ! ! New time-step 222 nsec_year = nsec_year + ndt 223 nsec_month = nsec_month + ndt 221 nsec_year = nsec_year + ndt 222 nsec_month = nsec_month + ndt 224 223 nsec_week = nsec_week + ndt 225 nsec_day = nsec_day + ndt 224 nsec_day = nsec_day + ndt 226 225 adatrj = adatrj + rdttra(1) / rday 227 226 fjulday = fjulday + rdttra(1) / rday 228 227 IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec ) fjulday = REAL(NINT(fjulday),wp) ! avoid truncation error 229 228 IF( ABS(adatrj - REAL(NINT(adatrj ),wp)) < zprec ) adatrj = REAL(NINT(adatrj ),wp) ! avoid truncation error 230 229 231 230 IF( nsec_day > nsecd ) THEN ! New day 232 231 ! … … 261 260 262 261 IF( nsec_week > 7*nsecd ) nsec_week = ndt05 ! New week 263 262 264 263 IF(ln_ctl) THEN 265 264 WRITE(charout,FMT="('kt =', I4,' d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear … … 267 266 ENDIF 268 267 269 ! since we no longer call rst_opn, need to define nitrst here, used by ice restart routine 270 IF( kt == nit000 ) nitrst = nitend 271 IF( MOD( kt - 1, nstock ) == 0 ) THEN 272 ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment 273 nitrst = kt + nstock - 1 ! define the next value of nitrst for restart writing 274 IF( nitrst > nitend ) nitrst = nitend ! make sure we write a restart at the end of the run 275 ENDIF 276 268 IF( .NOT. lk_offline ) CALL rst_opn( kt ) ! Open the restart file if needed and control lrst_oce 269 IF( lrst_oce ) CALL day_rst( kt, 'WRITE' ) ! write day restart information 270 ! 277 271 IF( nn_timing == 1 ) CALL timing_stop('day') 278 272 ! … … 372 366 ! 373 367 END SUBROUTINE day_rst 368 374 369 !!====================================================================== 375 370 END MODULE daymod
Note: See TracChangeset
for help on using the changeset viewer.