[1] | 1 | SUBROUTINE Setup_Timekeeping ( grid ) |
---|
| 2 | USE module_domain |
---|
| 3 | USE module_configure |
---|
| 4 | USE module_utility |
---|
| 5 | IMPLICIT NONE |
---|
| 6 | TYPE(domain), POINTER :: grid |
---|
| 7 | ! Local |
---|
| 8 | TYPE(WRFU_TimeInterval) :: begin_time, end_time, zero_time, one_minute, one_hour, forever, padding_interval |
---|
| 9 | TYPE(WRFU_TimeInterval) :: interval, run_length, dfl_length |
---|
| 10 | TYPE(WRFU_Time) :: startTime, stopTime, initialTime |
---|
| 11 | TYPE(WRFU_TimeInterval) :: stepTime |
---|
| 12 | TYPE(WRFU_TimeInterval) :: tmp_step |
---|
| 13 | INTEGER :: start_year,start_month,start_day,start_hour,start_minute,start_second |
---|
| 14 | INTEGER :: end_year,end_month,end_day,end_hour,end_minute,end_second |
---|
| 15 | INTEGER :: vortex_interval |
---|
| 16 | #ifdef HWRF |
---|
| 17 | !zhang's doing |
---|
| 18 | real (kind=8) :: day_in_sec |
---|
| 19 | REAL :: tstart |
---|
| 20 | !end of zhang's doing |
---|
| 21 | #endif |
---|
| 22 | |
---|
| 23 | ! #if (EM_CORE == 1) |
---|
| 24 | INTEGER :: dfi_fwdstop_year,dfi_fwdstop_month,dfi_fwdstop_day,dfi_fwdstop_hour,dfi_fwdstop_minute,dfi_fwdstop_second |
---|
| 25 | INTEGER :: dfi_bckstop_year,dfi_bckstop_month,dfi_bckstop_day,dfi_bckstop_hour,dfi_bckstop_minute,dfi_bckstop_second |
---|
| 26 | ! #endif |
---|
| 27 | |
---|
| 28 | INTEGER :: restart_interval_d |
---|
| 29 | INTEGER :: inputout_interval_d |
---|
| 30 | INTEGER :: inputout_begin_y |
---|
| 31 | INTEGER :: inputout_end_y |
---|
| 32 | INTEGER :: inputout_begin_m |
---|
| 33 | INTEGER :: inputout_begin_s |
---|
| 34 | INTEGER :: inputout_begin_d |
---|
| 35 | INTEGER :: inputout_begin_h |
---|
| 36 | INTEGER :: inputout_end_m |
---|
| 37 | INTEGER :: inputout_end_s |
---|
| 38 | INTEGER :: inputout_end_d |
---|
| 39 | INTEGER :: inputout_end_h |
---|
| 40 | INTEGER :: restart_interval_m |
---|
| 41 | INTEGER :: restart_interval_s |
---|
| 42 | INTEGER :: restart_interval |
---|
| 43 | INTEGER :: restart_interval_h |
---|
| 44 | INTEGER :: inputout_interval_m |
---|
| 45 | INTEGER :: inputout_interval_s |
---|
| 46 | INTEGER :: inputout_interval |
---|
| 47 | INTEGER :: inputout_interval_h |
---|
| 48 | |
---|
| 49 | # include "set_timekeeping_defs.inc" |
---|
| 50 | |
---|
| 51 | INTEGER :: grid_fdda, grid_sfdda |
---|
| 52 | |
---|
| 53 | INTEGER :: run_days, run_hours, run_minutes, run_seconds |
---|
| 54 | INTEGER :: time_step, time_step_fract_num, time_step_fract_den |
---|
| 55 | INTEGER :: rc |
---|
| 56 | REAL :: dt |
---|
| 57 | |
---|
| 58 | CALL WRFU_TimeIntervalSet ( zero_time, rc=rc ) |
---|
| 59 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 60 | 'WRFU_TimeIntervalSet(zero_time) FAILED', & |
---|
| 61 | __FILE__ , & |
---|
| 62 | __LINE__ ) |
---|
| 63 | CALL WRFU_TimeIntervalSet ( one_minute, M=1, rc=rc ) |
---|
| 64 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 65 | 'WRFU_TimeIntervalSet(one_minute) FAILED', & |
---|
| 66 | __FILE__ , & |
---|
| 67 | __LINE__ ) |
---|
| 68 | CALL WRFU_TimeIntervalSet ( one_hour, H=1, rc=rc ) |
---|
| 69 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 70 | 'WRFU_TimeIntervalSet(one_hour) FAILED', & |
---|
| 71 | __FILE__ , & |
---|
| 72 | __LINE__ ) |
---|
| 73 | CALL WRFU_TimeIntervalSet ( forever, S=1700000000, rc=rc ) ! magic number; indicats an interval that is forever |
---|
| 74 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 75 | 'WRFU_TimeIntervalSet(forever) FAILED', & |
---|
| 76 | __FILE__ , & |
---|
| 77 | __LINE__ ) |
---|
| 78 | |
---|
| 79 | ! #if (EM_CORE == 1) |
---|
| 80 | IF ( (grid%dfi_opt .EQ. DFI_NODFI) .OR. (grid%dfi_stage .EQ. DFI_SETUP) ) THEN |
---|
| 81 | ! #endif |
---|
| 82 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 83 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 84 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 85 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 86 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 87 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 88 | #ifdef HWRF |
---|
| 89 | !zhang's doing - check with zhan before adding this bit |
---|
| 90 | ! CALL nl_get_tstart ( grid%id , tstart ) |
---|
| 91 | ! CALL jdn_sec(day_in_sec,start_year,start_month,start_day,start_hour,start_minute,start_second) |
---|
| 92 | ! day_in_sec = day_in_sec + tstart*3600. |
---|
| 93 | ! CALL jdn_ymd_hms(day_in_sec,start_year,start_month,start_day,start_hour,start_minute,start_second) |
---|
| 94 | !end of zhang's doing |
---|
| 95 | #endif |
---|
| 96 | CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 97 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 98 | rc=rc) |
---|
| 99 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 100 | 'WRFU_TimeSet(startTime) FAILED', & |
---|
| 101 | __FILE__ , & |
---|
| 102 | __LINE__ ) |
---|
| 103 | ! #if (EM_CORE == 1) |
---|
| 104 | ELSE |
---|
| 105 | IF ( grid%dfi_opt .EQ. DFI_DFL ) THEN |
---|
| 106 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 107 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 108 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 109 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 110 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 111 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 112 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 113 | ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN |
---|
| 114 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 115 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 116 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 117 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 118 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 119 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 120 | |
---|
| 121 | run_length = grid%stop_subtime - grid%start_subtime |
---|
| 122 | CALL WRFU_TimeIntervalGet( run_length, S=run_seconds, rc=rc ) |
---|
| 123 | ! What about fractional seconds? |
---|
| 124 | run_seconds = run_seconds / 2 |
---|
| 125 | CALL WRFU_TimeIntervalSet ( run_length, S=run_seconds, rc=rc ) |
---|
| 126 | CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 127 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 128 | rc=rc) |
---|
| 129 | startTime = startTime + run_length |
---|
| 130 | CALL WRFU_TimeGet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 131 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 132 | rc=rc) |
---|
| 133 | END IF |
---|
| 134 | |
---|
| 135 | ELSE IF ( grid%dfi_opt .EQ. DFI_DDFI ) THEN |
---|
| 136 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 137 | CALL nl_get_dfi_bckstop_year(grid%id,start_year) |
---|
| 138 | CALL nl_get_dfi_bckstop_month(grid%id,start_month) |
---|
| 139 | CALL nl_get_dfi_bckstop_day(grid%id,start_day) |
---|
| 140 | CALL nl_get_dfi_bckstop_hour(grid%id,start_hour) |
---|
| 141 | CALL nl_get_dfi_bckstop_minute(grid%id,start_minute) |
---|
| 142 | CALL nl_get_dfi_bckstop_second(grid%id,start_second) |
---|
| 143 | ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN |
---|
| 144 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 145 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 146 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 147 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 148 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 149 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 150 | ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN |
---|
| 151 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 152 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 153 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 154 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 155 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 156 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 157 | END IF |
---|
| 158 | |
---|
| 159 | ELSE IF ( grid%dfi_opt .EQ. DFI_TDFI ) THEN |
---|
| 160 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 161 | CALL nl_get_dfi_bckstop_year(grid%id,start_year) |
---|
| 162 | CALL nl_get_dfi_bckstop_month(grid%id,start_month) |
---|
| 163 | CALL nl_get_dfi_bckstop_day(grid%id,start_day) |
---|
| 164 | CALL nl_get_dfi_bckstop_hour(grid%id,start_hour) |
---|
| 165 | CALL nl_get_dfi_bckstop_minute(grid%id,start_minute) |
---|
| 166 | CALL nl_get_dfi_bckstop_second(grid%id,start_second) |
---|
| 167 | |
---|
| 168 | ! Here, we look at head_grid to determine run_length. |
---|
| 169 | ! Since start_subtime and stop_subtime were |
---|
| 170 | ! updated for nesting, they no longer bound the dfi |
---|
| 171 | ! time window, so, start_subtime and stop_subtime from |
---|
| 172 | ! from the grid structure won't work. However, we can use |
---|
| 173 | ! head_grid since the dfi time window is the same for all |
---|
| 174 | ! domains. |
---|
| 175 | |
---|
| 176 | run_length = head_grid%start_subtime - head_grid%stop_subtime |
---|
| 177 | CALL WRFU_TimeIntervalGet( run_length, S=run_seconds, rc=rc ) |
---|
| 178 | ! What about fractional seconds? |
---|
| 179 | run_seconds = run_seconds / 2 |
---|
| 180 | CALL WRFU_TimeIntervalSet ( run_length, S=run_seconds, rc=rc ) |
---|
| 181 | CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 182 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 183 | rc=rc) |
---|
| 184 | startTime = startTime + run_length |
---|
| 185 | CALL WRFU_TimeGet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 186 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 187 | rc=rc) |
---|
| 188 | ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN |
---|
| 189 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 190 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 191 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 192 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 193 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 194 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 195 | ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN |
---|
| 196 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 197 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 198 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 199 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 200 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 201 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 202 | ELSE IF ( grid%dfi_stage .EQ. DFI_STARTFWD ) THEN |
---|
| 203 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 204 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 205 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 206 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 207 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 208 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 209 | END IF |
---|
| 210 | END IF |
---|
| 211 | |
---|
| 212 | IF ( grid%dfi_stage .EQ. DFI_STARTBCK ) THEN |
---|
| 213 | CALL WRFU_ClockGet( grid%domain_clock, CurrTime=startTime, rc=rc) |
---|
| 214 | ELSE |
---|
| 215 | CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 216 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 217 | rc=rc) |
---|
| 218 | ENDIF |
---|
| 219 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 220 | 'WRFU_TimeSet(startTime) FAILED', & |
---|
| 221 | __FILE__ , & |
---|
| 222 | __LINE__ ) |
---|
| 223 | END IF |
---|
| 224 | ! #endif |
---|
| 225 | |
---|
| 226 | CALL nl_get_run_days(1,run_days) |
---|
| 227 | CALL nl_get_run_hours(1,run_hours) |
---|
| 228 | CALL nl_get_run_minutes(1,run_minutes) |
---|
| 229 | CALL nl_get_run_seconds(1,run_seconds) |
---|
| 230 | |
---|
| 231 | ! #if (EM_CORE == 1) |
---|
| 232 | IF ( (grid%dfi_opt .EQ. DFI_NODFI) .OR. (grid%dfi_stage .EQ. DFI_SETUP) .OR. (grid%dfi_stage .EQ. DFI_FST)) THEN |
---|
| 233 | ! #endif |
---|
| 234 | |
---|
| 235 | IF ( grid%id .EQ. head_grid%id .AND. & |
---|
| 236 | ( run_days .gt. 0 .or. run_hours .gt. 0 .or. run_minutes .gt. 0 .or. run_seconds .gt. 0 )) THEN |
---|
| 237 | CALL WRFU_TimeIntervalSet ( run_length , D=run_days, H=run_hours, M=run_minutes, S=run_seconds, rc=rc ) |
---|
| 238 | ! #if (EM_CORE == 1) |
---|
| 239 | IF ( grid%dfi_stage .EQ. DFI_FST .AND. grid%dfi_opt .EQ. DFI_DFL ) THEN |
---|
| 240 | CALL nl_get_start_year(grid%id,start_year) |
---|
| 241 | CALL nl_get_start_month(grid%id,start_month) |
---|
| 242 | CALL nl_get_start_day(grid%id,start_day) |
---|
| 243 | CALL nl_get_start_hour(grid%id,start_hour) |
---|
| 244 | CALL nl_get_start_minute(grid%id,start_minute) |
---|
| 245 | CALL nl_get_start_second(grid%id,start_second) |
---|
| 246 | CALL WRFU_TimeSet(initialTime, YY=start_year, MM=start_month, DD=start_day, & |
---|
| 247 | H=start_hour, M=start_minute, S=start_second,& |
---|
| 248 | rc=rc) |
---|
| 249 | dfl_length = startTime - initialTime |
---|
| 250 | run_length = run_length - dfl_length |
---|
| 251 | END IF |
---|
| 252 | ! #endif |
---|
| 253 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 254 | 'WRFU_TimeIntervalSet(run_length) FAILED', & |
---|
| 255 | __FILE__ , & |
---|
| 256 | __LINE__ ) |
---|
| 257 | stopTime = startTime + run_length |
---|
| 258 | ELSE |
---|
| 259 | CALL nl_get_end_year(grid%id,end_year) |
---|
| 260 | CALL nl_get_end_month(grid%id,end_month) |
---|
| 261 | CALL nl_get_end_day(grid%id,end_day) |
---|
| 262 | CALL nl_get_end_hour(grid%id,end_hour) |
---|
| 263 | CALL nl_get_end_minute(grid%id,end_minute) |
---|
| 264 | CALL nl_get_end_second(grid%id,end_second) |
---|
| 265 | CALL WRFU_TimeSet(stopTime, YY=end_year, MM=end_month, DD=end_day, & |
---|
| 266 | H=end_hour, M=end_minute, S=end_second,& |
---|
| 267 | rc=rc ) |
---|
| 268 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 269 | 'WRFU_TimeSet(stopTime) FAILED', & |
---|
| 270 | __FILE__ , & |
---|
| 271 | __LINE__ ) |
---|
| 272 | run_length = stopTime - startTime |
---|
| 273 | ENDIF |
---|
| 274 | |
---|
| 275 | ! #if (EM_CORE == 1) |
---|
| 276 | ELSE IF ( grid%dfi_stage .EQ. DFI_STARTFWD ) THEN |
---|
| 277 | CALL nl_get_time_step ( 1, time_step ) |
---|
| 278 | CALL nl_get_time_step_fract_num( 1, time_step_fract_num ) |
---|
| 279 | CALL nl_get_time_step_fract_den( 1, time_step_fract_den ) |
---|
| 280 | CALL WRFU_TimeIntervalSet( run_length, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc) |
---|
| 281 | stopTime = startTime + run_length |
---|
| 282 | ELSE IF ( grid%dfi_stage .EQ. DFI_STARTBCK ) THEN |
---|
| 283 | CALL nl_get_time_step ( 1, time_step ) |
---|
| 284 | CALL nl_get_time_step_fract_num( 1, time_step_fract_num ) |
---|
| 285 | CALL nl_get_time_step_fract_den( 1, time_step_fract_den ) |
---|
| 286 | CALL WRFU_TimeIntervalSet( run_length, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc) |
---|
| 287 | stopTime = startTime + run_length |
---|
| 288 | ELSE |
---|
| 289 | IF ( grid%dfi_opt .EQ. DFI_DFL ) THEN |
---|
| 290 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 291 | CALL nl_get_dfi_fwdstop_year(grid%id,end_year) |
---|
| 292 | CALL nl_get_dfi_fwdstop_month(grid%id,end_month) |
---|
| 293 | CALL nl_get_dfi_fwdstop_day(grid%id,end_day) |
---|
| 294 | CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour) |
---|
| 295 | CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute) |
---|
| 296 | CALL nl_get_dfi_fwdstop_second(grid%id,end_second) |
---|
| 297 | END IF |
---|
| 298 | |
---|
| 299 | ELSE IF ( grid%dfi_opt .EQ. DFI_DDFI ) THEN |
---|
| 300 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 301 | CALL nl_get_dfi_fwdstop_year(grid%id,end_year) |
---|
| 302 | CALL nl_get_dfi_fwdstop_month(grid%id,end_month) |
---|
| 303 | CALL nl_get_dfi_fwdstop_day(grid%id,end_day) |
---|
| 304 | CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour) |
---|
| 305 | CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute) |
---|
| 306 | CALL nl_get_dfi_fwdstop_second(grid%id,end_second) |
---|
| 307 | ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN |
---|
| 308 | CALL nl_get_dfi_bckstop_year(grid%id,end_year) |
---|
| 309 | CALL nl_get_dfi_bckstop_month(grid%id,end_month) |
---|
| 310 | CALL nl_get_dfi_bckstop_day(grid%id,end_day) |
---|
| 311 | CALL nl_get_dfi_bckstop_hour(grid%id,end_hour) |
---|
| 312 | CALL nl_get_dfi_bckstop_minute(grid%id,end_minute) |
---|
| 313 | CALL nl_get_dfi_bckstop_second(grid%id,end_second) |
---|
| 314 | END IF |
---|
| 315 | |
---|
| 316 | ELSE IF ( grid%dfi_opt .EQ. DFI_TDFI ) THEN |
---|
| 317 | IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN |
---|
| 318 | CALL nl_get_dfi_fwdstop_year(grid%id,end_year) |
---|
| 319 | CALL nl_get_dfi_fwdstop_month(grid%id,end_month) |
---|
| 320 | CALL nl_get_dfi_fwdstop_day(grid%id,end_day) |
---|
| 321 | CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour) |
---|
| 322 | CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute) |
---|
| 323 | CALL nl_get_dfi_fwdstop_second(grid%id,end_second) |
---|
| 324 | ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN |
---|
| 325 | CALL nl_get_dfi_bckstop_year(grid%id,end_year) |
---|
| 326 | CALL nl_get_dfi_bckstop_month(grid%id,end_month) |
---|
| 327 | CALL nl_get_dfi_bckstop_day(grid%id,end_day) |
---|
| 328 | CALL nl_get_dfi_bckstop_hour(grid%id,end_hour) |
---|
| 329 | CALL nl_get_dfi_bckstop_minute(grid%id,end_minute) |
---|
| 330 | CALL nl_get_dfi_bckstop_second(grid%id,end_second) |
---|
| 331 | END IF |
---|
| 332 | END IF |
---|
| 333 | CALL WRFU_TimeSet(stopTime, YY=end_year, MM=end_month, DD=end_day, & |
---|
| 334 | H=end_hour, M=end_minute, S=end_second,& |
---|
| 335 | rc=rc) |
---|
| 336 | |
---|
| 337 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 338 | 'WRFU_TimeSet(dfistopfwdTime) FAILED', & |
---|
| 339 | __FILE__ , & |
---|
| 340 | __LINE__ ) |
---|
| 341 | |
---|
| 342 | run_length = stopTime - startTime |
---|
| 343 | |
---|
| 344 | END IF |
---|
| 345 | ! #endif |
---|
| 346 | |
---|
| 347 | IF ( run_length .GT. zero_time ) THEN |
---|
| 348 | padding_interval = forever |
---|
| 349 | ELSE |
---|
| 350 | padding_interval = zero_time - forever |
---|
| 351 | ENDIF |
---|
| 352 | |
---|
| 353 | IF ( grid%id .EQ. head_grid%id ) THEN |
---|
| 354 | CALL nl_get_time_step ( 1, time_step ) |
---|
| 355 | CALL nl_get_time_step_fract_num( 1, time_step_fract_num ) |
---|
| 356 | CALL nl_get_time_step_fract_den( 1, time_step_fract_den ) |
---|
| 357 | dt = real(time_step) + real(time_step_fract_num) / real(time_step_fract_den) |
---|
| 358 | #ifdef PLANET |
---|
| 359 | ! 2004-12-08 ADT notes: |
---|
| 360 | ! We have gotten the timestep from integers in the namelist, and they have just |
---|
| 361 | ! been converted to the timestep, "dt", used by the physics code just above. |
---|
| 362 | ! After this point, the integers are only used to update the clock used for, |
---|
| 363 | ! and we want to leave that on a "24-hour" type schedule, so we don't need to |
---|
| 364 | ! modify those integers. Theoretically they refer to a portion of the planet's |
---|
| 365 | ! solar day. The only thing we have to do is convert the *real* timestep, dt, |
---|
| 366 | ! to useful SI units. This is easily accomplished by multiplying it by the |
---|
| 367 | ! variable P2SI, which was designed for just this purpose. After multiplication, |
---|
| 368 | ! make sure every subsequent part of the model knows what the value is. |
---|
| 369 | dt = dt * P2SI |
---|
| 370 | #endif |
---|
| 371 | CALL nl_set_dt( grid%id, dt ) |
---|
| 372 | grid%dt = dt |
---|
| 373 | CALL WRFU_TimeIntervalSet(stepTime, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc) |
---|
| 374 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 375 | 'WRFU_TimeIntervalSet(stepTime) FAILED', & |
---|
| 376 | __FILE__ , & |
---|
| 377 | __LINE__ ) |
---|
| 378 | ELSE |
---|
| 379 | tmp_step = domain_get_time_step( grid%parents(1)%ptr ) |
---|
| 380 | stepTime = domain_get_time_step( grid%parents(1)%ptr ) / & |
---|
| 381 | grid%parent_time_step_ratio |
---|
| 382 | grid%dt = grid%parents(1)%ptr%dt / grid%parent_time_step_ratio |
---|
| 383 | CALL nl_set_dt( grid%id, grid%dt ) |
---|
| 384 | ENDIF |
---|
| 385 | |
---|
| 386 | ! create grid%domain_clock and associated state |
---|
| 387 | CALL domain_clock_create( grid, TimeStep= stepTime, & |
---|
| 388 | StartTime=startTime, & |
---|
| 389 | StopTime= stopTime ) |
---|
| 390 | CALL domain_clockprint ( 150, grid, & |
---|
| 391 | 'DEBUG setup_timekeeping(): clock after creation,' ) |
---|
| 392 | |
---|
| 393 | ! Set default value for SIMULATION_START_DATE. |
---|
| 394 | ! This is overwritten later in input_wrf(), if needed. |
---|
| 395 | IF ( grid%id .EQ. head_grid%id ) THEN |
---|
| 396 | CALL nl_set_simulation_start_year ( 1 , start_year ) |
---|
| 397 | CALL nl_set_simulation_start_month ( 1 , start_month ) |
---|
| 398 | CALL nl_set_simulation_start_day ( 1 , start_day ) |
---|
| 399 | CALL nl_set_simulation_start_hour ( 1 , start_hour ) |
---|
| 400 | CALL nl_set_simulation_start_minute ( 1 , start_minute ) |
---|
| 401 | CALL nl_set_simulation_start_second ( 1 , start_second ) |
---|
| 402 | ENDIF |
---|
| 403 | |
---|
| 404 | #include "set_timekeeping_alarms.inc" |
---|
| 405 | |
---|
| 406 | ! RESTART INTERVAL |
---|
| 407 | ! restart_interval is left there (and means minutes) for consistency, but |
---|
| 408 | ! restart_interval_m will take precedence if specified |
---|
| 409 | CALL nl_get_restart_interval( 1, restart_interval ) ! same as minutes |
---|
| 410 | CALL nl_get_restart_interval_d( 1, restart_interval_d ) |
---|
| 411 | CALL nl_get_restart_interval_h( 1, restart_interval_h ) |
---|
| 412 | CALL nl_get_restart_interval_m( 1, restart_interval_m ) |
---|
| 413 | CALL nl_get_restart_interval_s( 1, restart_interval_s ) |
---|
| 414 | IF ( restart_interval_m .EQ. 0 ) restart_interval_m = restart_interval |
---|
| 415 | IF ( MAX( restart_interval_d, & |
---|
| 416 | restart_interval_h, restart_interval_m , restart_interval_s ) .GT. 0 ) THEN |
---|
| 417 | CALL WRFU_TimeIntervalSet( interval, D=restart_interval_d, & |
---|
| 418 | H=restart_interval_h, M=restart_interval_m, S=restart_interval_s, rc=rc ) |
---|
| 419 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 420 | 'WRFU_TimeIntervalSet(restart_interval) FAILED', & |
---|
| 421 | __FILE__ , & |
---|
| 422 | __LINE__ ) |
---|
| 423 | ELSE |
---|
| 424 | interval = padding_interval |
---|
| 425 | ENDIF |
---|
| 426 | CALL domain_alarm_create( grid, RESTART_ALARM, interval ) |
---|
| 427 | |
---|
| 428 | ! INPUTOUT INTERVAL |
---|
| 429 | CALL nl_get_inputout_interval( grid%id, inputout_interval ) ! same as minutes |
---|
| 430 | CALL nl_get_inputout_interval_d( grid%id, inputout_interval_d ) |
---|
| 431 | CALL nl_get_inputout_interval_h( grid%id, inputout_interval_h ) |
---|
| 432 | CALL nl_get_inputout_interval_m( grid%id, inputout_interval_m ) |
---|
| 433 | CALL nl_get_inputout_interval_s( grid%id, inputout_interval_s ) |
---|
| 434 | IF ( inputout_interval_m .EQ. 0 ) inputout_interval_m = inputout_interval |
---|
| 435 | |
---|
| 436 | IF ( MAX( inputout_interval_d, & |
---|
| 437 | inputout_interval_h, inputout_interval_m , inputout_interval_s ) .GT. 0 ) THEN |
---|
| 438 | CALL WRFU_TimeIntervalSet( interval, D=inputout_interval_d, & |
---|
| 439 | H=inputout_interval_h, M=inputout_interval_m, S=inputout_interval_s, rc=rc ) |
---|
| 440 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 441 | 'WRFU_TimeIntervalSet(inputout_interval) FAILED', & |
---|
| 442 | __FILE__ , & |
---|
| 443 | __LINE__ ) |
---|
| 444 | ELSE |
---|
| 445 | interval = padding_interval |
---|
| 446 | ENDIF |
---|
| 447 | |
---|
| 448 | CALL nl_get_inputout_begin_y( grid%id, inputout_begin_y ) |
---|
| 449 | CALL nl_get_inputout_begin_d( grid%id, inputout_begin_d ) |
---|
| 450 | CALL nl_get_inputout_begin_h( grid%id, inputout_begin_h ) |
---|
| 451 | CALL nl_get_inputout_begin_m( grid%id, inputout_begin_m ) |
---|
| 452 | CALL nl_get_inputout_begin_s( grid%id, inputout_begin_s ) |
---|
| 453 | IF ( MAX( inputout_begin_y, inputout_begin_d, & |
---|
| 454 | inputout_begin_h, inputout_begin_m , inputout_begin_s ) .GT. 0 ) THEN |
---|
| 455 | CALL WRFU_TimeIntervalSet( begin_time , D=inputout_begin_d, & |
---|
| 456 | H=inputout_begin_h, M=inputout_begin_m, S=inputout_begin_s, rc=rc ) |
---|
| 457 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 458 | 'WRFU_TimeIntervalSet(inputout_begin) FAILED', & |
---|
| 459 | __FILE__ , & |
---|
| 460 | __LINE__ ) |
---|
| 461 | ELSE |
---|
| 462 | begin_time = zero_time |
---|
| 463 | ENDIF |
---|
| 464 | |
---|
| 465 | CALL nl_get_inputout_end_y( grid%id, inputout_end_y ) |
---|
| 466 | CALL nl_get_inputout_end_d( grid%id, inputout_end_d ) |
---|
| 467 | CALL nl_get_inputout_end_h( grid%id, inputout_end_h ) |
---|
| 468 | CALL nl_get_inputout_end_m( grid%id, inputout_end_m ) |
---|
| 469 | CALL nl_get_inputout_end_s( grid%id, inputout_end_s ) |
---|
| 470 | IF ( MAX( inputout_end_y, inputout_end_d, & |
---|
| 471 | inputout_end_h, inputout_end_m , inputout_end_s ) .GT. 0 ) THEN |
---|
| 472 | CALL WRFU_TimeIntervalSet( end_time , D=inputout_end_d, & |
---|
| 473 | H=inputout_end_h, M=inputout_end_m, S=inputout_end_s, rc=rc ) |
---|
| 474 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 475 | 'WRFU_TimeIntervalSet(inputout_end) FAILED', & |
---|
| 476 | __FILE__ , & |
---|
| 477 | __LINE__ ) |
---|
| 478 | ELSE |
---|
| 479 | end_time = padding_interval |
---|
| 480 | ENDIF |
---|
| 481 | |
---|
| 482 | CALL domain_alarm_create( grid, INPUTOUT_ALARM, interval, begin_time, end_time ) |
---|
| 483 | |
---|
| 484 | #ifdef WRF_CHEM |
---|
| 485 | ! AUXINPUT5_ INTERVAL |
---|
| 486 | ! auxinput5_interval is left there (and means minutes) for consistency, but |
---|
| 487 | ! auxinput5_interval_m will take precedence if specified |
---|
| 488 | CALL nl_get_auxinput5_interval( grid%id, auxinput5_interval ) ! same as minutes |
---|
| 489 | CALL nl_get_auxinput5_interval_d( grid%id, auxinput5_interval_d ) |
---|
| 490 | CALL nl_get_auxinput5_interval_h( grid%id, auxinput5_interval_h ) |
---|
| 491 | CALL nl_get_auxinput5_interval_m( grid%id, auxinput5_interval_m ) |
---|
| 492 | CALL nl_get_auxinput5_interval_s( grid%id, auxinput5_interval_s ) |
---|
| 493 | IF ( auxinput5_interval_m .EQ. 0 ) auxinput5_interval_m = auxinput5_interval |
---|
| 494 | |
---|
| 495 | IF ( MAX( auxinput5_interval_d, & |
---|
| 496 | auxinput5_interval_h, auxinput5_interval_m , auxinput5_interval_s ) .GT. 0 ) THEN |
---|
| 497 | CALL WRFU_TimeIntervalSet( interval, D=auxinput5_interval_d, & |
---|
| 498 | H=auxinput5_interval_h, M=auxinput5_interval_m, S=auxinput5_interval_s, rc=rc ) |
---|
| 499 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 500 | 'WRFU_TimeIntervalSet(auxinput5_interval) FAILED', & |
---|
| 501 | __FILE__ , & |
---|
| 502 | __LINE__ ) |
---|
| 503 | ELSE |
---|
| 504 | interval = padding_interval |
---|
| 505 | ENDIF |
---|
| 506 | |
---|
| 507 | CALL nl_get_auxinput5_begin_y( grid%id, auxinput5_begin_y ) |
---|
| 508 | CALL nl_get_auxinput5_begin_d( grid%id, auxinput5_begin_d ) |
---|
| 509 | CALL nl_get_auxinput5_begin_h( grid%id, auxinput5_begin_h ) |
---|
| 510 | CALL nl_get_auxinput5_begin_m( grid%id, auxinput5_begin_m ) |
---|
| 511 | CALL nl_get_auxinput5_begin_s( grid%id, auxinput5_begin_s ) |
---|
| 512 | IF ( MAX( auxinput5_begin_y, auxinput5_begin_d, & |
---|
| 513 | auxinput5_begin_h, auxinput5_begin_m , auxinput5_begin_s ) .GT. 0 ) THEN |
---|
| 514 | CALL WRFU_TimeIntervalSet( begin_time , D=auxinput5_begin_d, & |
---|
| 515 | H=auxinput5_begin_h, M=auxinput5_begin_m, S=auxinput5_begin_s, rc=rc ) |
---|
| 516 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 517 | 'WRFU_TimeIntervalSet(auxinput5_begin) FAILED', & |
---|
| 518 | __FILE__ , & |
---|
| 519 | __LINE__ ) |
---|
| 520 | ELSE |
---|
| 521 | begin_time = zero_time |
---|
| 522 | ENDIF |
---|
| 523 | CALL nl_get_auxinput5_end_y( grid%id, auxinput5_end_y ) |
---|
| 524 | CALL nl_get_auxinput5_end_d( grid%id, auxinput5_end_d ) |
---|
| 525 | CALL nl_get_auxinput5_end_h( grid%id, auxinput5_end_h ) |
---|
| 526 | CALL nl_get_auxinput5_end_m( grid%id, auxinput5_end_m ) |
---|
| 527 | CALL nl_get_auxinput5_end_s( grid%id, auxinput5_end_s ) |
---|
| 528 | IF ( MAX( auxinput5_end_y, auxinput5_end_d, & |
---|
| 529 | auxinput5_end_h, auxinput5_end_m , auxinput5_end_s ) .GT. 0 ) THEN |
---|
| 530 | CALL WRFU_TimeIntervalSet( end_time , D=auxinput5_end_d, & |
---|
| 531 | H=auxinput5_end_h, M=auxinput5_end_m, S=auxinput5_end_s, rc=rc ) |
---|
| 532 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 533 | 'WRFU_TimeIntervalSet(auxinput5_end) FAILED', & |
---|
| 534 | __FILE__ , & |
---|
| 535 | __LINE__ ) |
---|
| 536 | ELSE |
---|
| 537 | end_time = padding_interval |
---|
| 538 | ENDIF |
---|
| 539 | CALL domain_alarm_create( grid, AUXINPUT5_ALARM, interval, begin_time, end_time ) |
---|
| 540 | !TBH: Should be OK to remove the "#else" section and the code it contains |
---|
| 541 | !TBH: because later code overwrites grid%alarms( AUXINPUT5_ALARM )... |
---|
| 542 | !TBH: In fact, by setting namelist values for auxinput5 correctly, it ought |
---|
| 543 | !TBH: to be possible to get rid of all "#ifdef WRF_CHEM" bits in this file... |
---|
| 544 | CALL WRFU_AlarmEnable( grid%alarms( AUXINPUT5_ALARM ), rc=rc ) |
---|
| 545 | CALL WRFU_AlarmRingerOn( grid%alarms( AUXINPUT5_ALARM ), rc=rc ) |
---|
| 546 | ! TBH: NOTE: Proper setting of namelist variables for auxinput5 ought to |
---|
| 547 | ! TBH: make this hard-coded bit unnecessary. |
---|
| 548 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 549 | ! add for wrf_chem emiss input |
---|
| 550 | CALL WRFU_AlarmEnable( grid%alarms( AUXINPUT5_ALARM ), rc=rc ) |
---|
| 551 | CALL WRFU_AlarmRingerOn( grid%alarms( AUXINPUT5_ALARM ), rc=rc ) |
---|
| 552 | ! end for wrf chem emiss input |
---|
| 553 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 554 | #endif |
---|
| 555 | |
---|
| 556 | ! without this test, it's possible for the value of the WRF_ALARM_SECS_TIL_NEXT_RING |
---|
| 557 | ! that is written as metadata to a restart file to be garbage for BOUNDARY_ALARM for |
---|
| 558 | ! the nests. Parallel NetCDF does a header check on all the metadata being written |
---|
| 559 | ! from multiple processors and if it differs, it throws up an error. This avoids that. |
---|
| 560 | IF ( grid%id .EQ. 1 ) THEN ! only moad can have specified boundaries |
---|
| 561 | CALL domain_alarm_create( grid, BOUNDARY_ALARM ) |
---|
| 562 | CALL WRFU_AlarmEnable( grid%alarms( BOUNDARY_ALARM ), rc=rc ) |
---|
| 563 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 564 | 'WRFU_AlarmEnable(BOUNDARY_ALARM) FAILED', & |
---|
| 565 | __FILE__ , & |
---|
| 566 | __LINE__ ) |
---|
| 567 | CALL WRFU_AlarmRingerOn( grid%alarms( BOUNDARY_ALARM ), rc=rc ) |
---|
| 568 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 569 | 'WRFU_AlarmRingerOn(BOUNDARY_ALARM) FAILED', & |
---|
| 570 | __FILE__ , & |
---|
| 571 | __LINE__ ) |
---|
| 572 | ENDIF |
---|
| 573 | |
---|
| 574 | ! This is the interval at which the code in time_for_move in share/mediation_integrate.F |
---|
| 575 | ! will recompute the center of the Vortex. Other times, it will use the last position. |
---|
| 576 | ! |
---|
| 577 | vortex_interval = 0 |
---|
| 578 | #ifdef MOVE_NESTS |
---|
| 579 | CALL nl_get_vortex_interval ( grid%id , vortex_interval ) |
---|
| 580 | #endif |
---|
| 581 | CALL WRFU_TimeIntervalSet( interval, M=vortex_interval, rc=rc ) |
---|
| 582 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 583 | 'WRFU_TimeIntervalSet(interval) for computing vortex center FAILED', & |
---|
| 584 | __FILE__ , & |
---|
| 585 | __LINE__ ) |
---|
| 586 | CALL domain_alarm_create( grid, COMPUTE_VORTEX_CENTER_ALARM, interval ) |
---|
| 587 | #ifdef MOVE_NESTS |
---|
| 588 | CALL WRFU_AlarmEnable( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc ) |
---|
| 589 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 590 | 'WRFU_AlarmEnable(COMPUTE_VORTEX_CENTER_ALARM) FAILED', & |
---|
| 591 | __FILE__ , & |
---|
| 592 | __LINE__ ) |
---|
| 593 | CALL WRFU_AlarmRingerOn( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc ) |
---|
| 594 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 595 | 'WRFU_AlarmRingerOn(COMPUTE_VORTEX_CENTER_ALARM) FAILED', & |
---|
| 596 | __FILE__ , & |
---|
| 597 | __LINE__ ) |
---|
| 598 | #else |
---|
| 599 | ! Go ahead and let the alarm be defined, but disable it, since we are not using moving nests here. |
---|
| 600 | CALL WRFU_AlarmDisable( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc ) |
---|
| 601 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
| 602 | 'WRFU_AlarmDisable(COMPUTE_VORTEX_CENTER_ALARM) FAILED', & |
---|
| 603 | __FILE__ , & |
---|
| 604 | __LINE__ ) |
---|
| 605 | #endif |
---|
| 606 | |
---|
| 607 | grid%time_set = .TRUE. |
---|
| 608 | |
---|
| 609 | ! Initialize derived time quantities in grid state. |
---|
| 610 | ! These are updated in domain_clockadvance(). |
---|
| 611 | CALL domain_clock_get( grid, minutesSinceSimulationStart=grid%xtime ) |
---|
| 612 | CALL domain_clock_get( grid, currentDayOfYearReal=grid%julian ) |
---|
| 613 | WRITE(wrf_err_message,*) 'setup_timekeeping: set xtime to ',grid%xtime |
---|
| 614 | CALL wrf_debug ( 100, TRIM(wrf_err_message) ) |
---|
| 615 | WRITE(wrf_err_message,*) 'setup_timekeeping: set julian to ',grid%julian |
---|
| 616 | CALL wrf_debug ( 100, TRIM(wrf_err_message) ) |
---|
| 617 | |
---|
| 618 | CALL wrf_debug ( 100 , 'setup_timekeeping: returning...' ) |
---|
| 619 | |
---|
| 620 | END SUBROUTINE Setup_Timekeeping |
---|
| 621 | |
---|
| 622 | |
---|