[3] | 1 | MODULE daymod |
---|
| 2 | !!====================================================================== |
---|
| 3 | !! *** MODULE daymod *** |
---|
| 4 | !! Ocean : calendar |
---|
| 5 | !!===================================================================== |
---|
[703] | 6 | !! History : ! 94-09 (M. Pontaud M. Imbard) Original code |
---|
| 7 | !! ! 97-03 (O. Marti) |
---|
| 8 | !! ! 97-05 (G. Madec) |
---|
| 9 | !! ! 97-08 (M. Imbard) |
---|
| 10 | !! 9.0 ! 03-09 (G. Madec) F90 + nyear, nmonth, nday |
---|
| 11 | !! ! 04-01 (A.M. Treguier) new calculation based on adatrj |
---|
| 12 | !! ! 06-08 (G. Madec) surface module major update |
---|
| 13 | !!---------------------------------------------------------------------- |
---|
[3] | 14 | |
---|
| 15 | !!---------------------------------------------------------------------- |
---|
| 16 | !! day : calendar |
---|
| 17 | !!---------------------------------------------------------------------- |
---|
| 18 | USE dom_oce ! ocean space and time domain |
---|
| 19 | USE phycst ! physical constants |
---|
| 20 | USE in_out_manager ! I/O manager |
---|
[258] | 21 | USE prtctl ! Print control |
---|
[3] | 22 | |
---|
| 23 | IMPLICIT NONE |
---|
| 24 | PRIVATE |
---|
| 25 | |
---|
| 26 | PUBLIC day ! called by step.F90 |
---|
| 27 | |
---|
[703] | 28 | INTEGER , PUBLIC :: nyear !: current year |
---|
| 29 | INTEGER , PUBLIC :: nmonth !: current month |
---|
| 30 | INTEGER , PUBLIC :: nday !: current day of the month |
---|
| 31 | INTEGER , PUBLIC :: nday_year !: current day counted from jan 1st of the current year |
---|
| 32 | REAL(wp), PUBLIC :: rsec_year !: current time step counted in second since 00h jan 1st of the current year |
---|
| 33 | REAL(wp), PUBLIC :: rsec_month !: current time step counted in second since 00h 1st day of the current month |
---|
| 34 | REAL(wp), PUBLIC :: rsec_day !: current time step counted in second since 00h of the current day |
---|
| 35 | INTEGER , PUBLIC :: ndastp !: time step date in year/month/day aammjj |
---|
| 36 | |
---|
| 37 | !!gm supprimer adatrj et adatrj0 ==> remplacer par rsecday..... |
---|
| 38 | REAL(wp), PUBLIC :: adatrj !: number of elapsed days since the begining of the run |
---|
| 39 | REAL(wp), PUBLIC :: adatrj0 !: value of adatrj at nit000-1 (before the present run). |
---|
| 40 | ! ! it is the accumulated duration of previous runs |
---|
| 41 | ! ! that may have been run with different time steps. |
---|
| 42 | INTEGER , PUBLIC, DIMENSION(0:13) :: nmonth_len !: length of the current year |
---|
| 43 | |
---|
| 44 | INTEGER, PUBLIC, DIMENSION(12) :: nbiss = (/ 31, 29, 31, 30, 31, 30, & !: number of days per month |
---|
| 45 | & 31, 31, 30, 31, 30, 31 /) !: (leap-year) |
---|
| 46 | INTEGER, PUBLIC, DIMENSION(12) :: nobis = (/ 31, 28, 31, 30, 31, 30, & !: number of days per month |
---|
| 47 | & 31, 31, 30, 31, 30, 31 /) !: (365 days a year) |
---|
| 48 | |
---|
| 49 | REAL(wp), PUBLIC, DIMENSION(0:14) :: rmonth_half(0:14) |
---|
| 50 | |
---|
[3] | 51 | !!---------------------------------------------------------------------- |
---|
[703] | 52 | !! OPA 9.0 , LOCEAN-IPSL (2006) |
---|
[699] | 53 | !! $Id$ |
---|
[703] | 54 | !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt) |
---|
[15] | 55 | !!---------------------------------------------------------------------- |
---|
[3] | 56 | |
---|
| 57 | CONTAINS |
---|
| 58 | |
---|
[15] | 59 | SUBROUTINE day( kt ) |
---|
[3] | 60 | !!---------------------------------------------------------------------- |
---|
[15] | 61 | !! *** ROUTINE day *** |
---|
[3] | 62 | !! |
---|
| 63 | !! ** Purpose : Compute the date with a day iteration IF necessary. |
---|
| 64 | !! |
---|
| 65 | !! ** Method : - ??? |
---|
| 66 | !! |
---|
| 67 | !! ** Action : - nyear : current year |
---|
| 68 | !! - nmonth : current month of the year nyear |
---|
| 69 | !! - nday : current day of the month nmonth |
---|
| 70 | !! - nday_year : current day of the year nyear |
---|
| 71 | !! - ndastp : =nyear*10000+nmonth*100+nday |
---|
[15] | 72 | !! - adatrj : date in days since the beginning of the run |
---|
[703] | 73 | !! - rsec_year : current time of the year (in second since 00h, jan 1st) |
---|
[3] | 74 | !!---------------------------------------------------------------------- |
---|
[703] | 75 | INTEGER, INTENT(in) :: kt ! ocean time-step indices |
---|
| 76 | ! |
---|
| 77 | INTEGER :: js, jm ! dummy loop indice |
---|
| 78 | CHARACTER (len=25) :: charout |
---|
[3] | 79 | !!---------------------------------------------------------------------- |
---|
| 80 | |
---|
| 81 | ! 0. initialization of adatrj0 and nday, nmonth,nyear, nday_year. |
---|
| 82 | ! ndastp has been initialized in domain.F90 or restart.F90 |
---|
| 83 | !----------------------------------------------------------------- |
---|
| 84 | |
---|
[703] | 85 | ! ! ---------------- ! |
---|
| 86 | IF( kt == -1 ) THEN ! Initialisation ! |
---|
| 87 | ! ! ---------------- ! |
---|
| 88 | ! |
---|
[15] | 89 | IF( .NOT.ln_rstart ) adatrj0 = 0.e0 ! adatrj0 initialized in rst_read when restart |
---|
[3] | 90 | |
---|
[703] | 91 | ! set the calandar from adatrj0 and ndastp (read in restart file and namelist) |
---|
| 92 | adatrj = adatrj0 !???? bug.... toujours rest !!gm |
---|
[3] | 93 | nyear = ndastp / 10000 |
---|
| 94 | nmonth = ( ndastp - (nyear * 10000) ) / 100 |
---|
| 95 | nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) |
---|
| 96 | |
---|
[703] | 97 | ! length of the month of the current year (from nleapy, read in namelist) |
---|
| 98 | nmonth_len(0) = nbiss(12) ; nmonth_len(13) = nbiss(1) |
---|
| 99 | SELECT CASE( nleapy ) |
---|
| 100 | CASE( 1 ) |
---|
| 101 | IF( MOD( nyear, 4 ) == 0 ) THEN |
---|
| 102 | ; nmonth_len(1:12) = nbiss(:) ! 366 days per year (leap year) |
---|
[3] | 103 | ELSE |
---|
[703] | 104 | ; nmonth_len(1:12) = nobis(:) ! 365 days per year |
---|
[3] | 105 | ENDIF |
---|
[703] | 106 | CASE( 0 ) ; nmonth_len(1:12) = nobis(:) ! 365 days per year |
---|
| 107 | CASE( 2: ) ; nmonth_len(1:13) = nleapy ! 12*nleapy days per year |
---|
| 108 | END SELECT |
---|
| 109 | |
---|
| 110 | ! half month in second since the bigining of the year |
---|
| 111 | rmonth_half(0) = - 0.5 * rday * REAL( nmonth_len( 0 ) ) |
---|
| 112 | DO jm = 1, 12 |
---|
| 113 | rmonth_half(jm) = rmonth_half(jm-1) + 0.5 * rday * REAL( nmonth_len(jm-1) + nmonth_len(jm) ) |
---|
[3] | 114 | END DO |
---|
[703] | 115 | rmonth_half(13) = rmonth_half( 1 ) + 365. * rday |
---|
| 116 | rmonth_half(14) = rmonth_half( 2 ) + 365. * rday |
---|
[3] | 117 | |
---|
[703] | 118 | ! day since january 1st (useful to read daily forcing fields) |
---|
| 119 | nday_year = nday |
---|
| 120 | DO js = 1, nmonth - 1 ! accumulates days of previous months of this year |
---|
| 121 | nday_year = nday_year + nmonth_len(js) |
---|
| 122 | END DO |
---|
[3] | 123 | |
---|
[703] | 124 | ! number of seconds since... |
---|
| 125 | rsec_year = REAL( nday_year - 1 ) * rday - rdttra(1) ! 00h 1st day of the current year |
---|
| 126 | rsec_day = REAL( nday - 1 ) * rday - rdttra(1) ! 00h 1st day of the current month |
---|
| 127 | rsec_month = - rdttra(1) ! 00h of the current day |
---|
[3] | 128 | |
---|
[703] | 129 | ! control print |
---|
| 130 | IF(lwp) WRITE(numout,*)' ==============>> time-step =', kt, ' Initial DATE= ', & |
---|
| 131 | & nyear, '/', nmonth, '/', nday, ' rsec_day:', rsec_day |
---|
[3] | 132 | |
---|
[703] | 133 | ! |
---|
| 134 | ! ! -------------------------------- ! |
---|
| 135 | ELSE ! Model calendar at time-step kt ! |
---|
| 136 | ! ! -------------------------------- ! |
---|
[3] | 137 | |
---|
[703] | 138 | rsec_year = rsec_year + rdttra(1) ! New time-step |
---|
| 139 | rsec_month = rsec_month + rdttra(1) ! New time-step |
---|
| 140 | rsec_day = rsec_day + rdttra(1) ! New time-step |
---|
[3] | 141 | |
---|
[703] | 142 | adatrj = adatrj0 + ( kt - nit000 + 1 ) * rdttra(1) / rday |
---|
[3] | 143 | |
---|
[703] | 144 | IF( rsec_day >= rday ) THEN |
---|
| 145 | ! |
---|
| 146 | rsec_day = 0.e0 ! NEW day |
---|
| 147 | nday = nday + 1 |
---|
| 148 | nday_year = nday_year + 1 |
---|
| 149 | ! |
---|
| 150 | IF( nday == nmonth_len(nmonth) + 1 ) THEN ! NEW month |
---|
| 151 | nday = 1 |
---|
| 152 | rsec_month = 0.e0 |
---|
| 153 | nmonth = nmonth + 1 |
---|
| 154 | IF( nmonth == 13 ) THEN ! NEW year |
---|
| 155 | nyear = nyear + 1 |
---|
| 156 | nmonth = 1 |
---|
| 157 | nday_year = 1 |
---|
| 158 | rsec_year = 0.e0 |
---|
| 159 | ! ! update the length of the month |
---|
| 160 | IF( nleapy == 1 ) THEN ! of the current year (if necessary) |
---|
| 161 | IF( MOD( nyear, 4 ) == 0 ) THEN |
---|
| 162 | nmonth_len(1:12) = nbiss(:) ! 366 days per year (leap year) |
---|
| 163 | ELSE |
---|
| 164 | nmonth_len(1:12) = nobis(:) ! 365 days per year |
---|
| 165 | ENDIF |
---|
| 166 | ! half month in second since the bigining of the year |
---|
| 167 | rmonth_half(0) = - 0.5 * rday * REAL( nmonth_len( 0 ) ) |
---|
| 168 | DO jm = 1, 12 |
---|
| 169 | rmonth_half(jm) = rmonth_half(jm-1) + 0.5 * rday * REAL( nmonth_len(jm-1) + nmonth_len(jm) ) |
---|
| 170 | END DO |
---|
| 171 | rmonth_half(13) = rmonth_half( 1 ) + 365. * rday |
---|
| 172 | rmonth_half(14) = rmonth_half( 2 ) + 365. * rday |
---|
| 173 | ENDIF |
---|
| 174 | ENDIF |
---|
| 175 | ENDIF |
---|
[3] | 176 | |
---|
[703] | 177 | ! |
---|
| 178 | ndastp = nyear * 10000 + nmonth * 100 + nday ! NEW date |
---|
| 179 | ! |
---|
| 180 | ! IF(lwp) WRITE(numout,'(a,i8,a,i4,a,i2,a,i2,a,i3)') '======>> time-step =', kt, & |
---|
| 181 | ! & ' New day, DATE= ', nyear, '/', nmonth, '/', nday, ' nday_year = ', nday_year |
---|
| 182 | ! IF(lwp) WRITE(numout,'(a,F9.0,a,F9.0,a,F9.0)') ' rsec_year = ', rsec_year, & |
---|
| 183 | ! & ' rsec_month = ', rsec_month, ' rsec_day = ', rsec_day |
---|
[3] | 184 | ENDIF |
---|
[703] | 185 | |
---|
| 186 | IF(ln_ctl) THEN |
---|
| 187 | WRITE(charout,FMT="('kt =', I4,' d/m/y =',I2,I2,I4)") kt, nday, nmonth, nyear |
---|
| 188 | CALL prt_ctl_info(charout) |
---|
[3] | 189 | ENDIF |
---|
[703] | 190 | ! |
---|
[3] | 191 | ENDIF |
---|
| 192 | |
---|
| 193 | END SUBROUTINE day |
---|
| 194 | |
---|
| 195 | !!====================================================================== |
---|
| 196 | END MODULE daymod |
---|