61 TYPE(NCFILE),
POINTER :: NCF
62 TYPE(NCVAR),
POINTER :: VAR
65 TYPE(TIME) :: INTERVAL_TIME, NEXT_TIME,PREV_TIME
66 INTEGER :: STKLEN, STKMAX,PREVSTK,NEXTSTK
68 INTEGER(itime) :: Dummy
70 CHARACTER(LEN=4) :: BFLAG,EFLAG,FLAG
74 CALL set_model_timestep
83 WRITE(
ipt,*)
'! SET TIME FOR HOTSTART !' 87 & (
'STARUP FILE IS NOT ASSOCIATED IN SETUP_TIME!')
100 EndTime = READ_DATETIME(END_DATE,DATE_FORMAT,TIMEZONE,status)
102 &
Call fatal_error(
"Could not read the date string END_DATE: "&
106 &
Call fatal_error(
"Runfile Start_Date exceeds or equal to End_Date")
137 (
'IDEALIZED MODEL TIME SPECIFICATION IS INCORRENT',&
138 &
'BEGIN AND END CAN BE IN EITHER CYCLES OR TIME BUT NOT MIXED',&
141 IF (bflag ==
'time')
THEN 157 ELSE IF(bflag ==
'step')
THEN 164 &(
'Number of steps can not be less than zero')
172 EndTime = StartTime + IMDTI *
nsteps 180 CALL fatal_error(
'IDEAL_TIME_STRING2TIME returned invalid flag')
196 CALL report_time_setup
213 CALL set_output_file_time(
nc_avg,interval_time,next_time&
214 &,nextstk,prev_time,prevstk,stklen,stkmax)
218 &
Call fatal_error(
"The time of the first averaged output & 219 &must be greater than or equal to the start time")
222 &
Call fatal_error(
"The time of the first averaged output & 223 &must be less than or equal to the end time")
229 CALL get_first_output_time(trim(
nc_first_out),next_time)
241 CALL set_output_file_time(
nc_dat,interval_time,next_time&
242 &,nextstk,prev_time,prevstk,stklen,stkmax)
247 &
Call fatal_error(
"The time of the first file output & 248 &must be greater than or equal to the start time")
251 &
Call fatal_error(
"The time of the first file output & 252 &must be less than or equal to the end time")
272 CALL set_output_file_time(
nc_rst,interval_time,next_time&
273 &,nextstk,prev_time,prevstk,stklen,stkmax)
278 &
Call fatal_error(
"The time of the first restart output & 279 &must be greater than or equal to the start time")
282 &
Call fatal_error(
"The time of the first restart output & 283 &must be less than or equal to the end time")
293 WRITE(
ipt,*)
'! SET TIME FOR CRASHRESTART !' 298 & (
'STARUP FILE IS NOT ASSOCIATED IN SETUP_TIME!')
322 EndTime = READ_DATETIME(END_DATE,DATE_FORMAT,TIMEZONE,status)
324 &
Call fatal_error(
"Could not read the date string END_DATE: "&
329 &
Call fatal_error(
"Runfile Start_Date exceeds or equal to End_Date")
359 (
'IDEALIZED MODEL TIME SPECIFICATION IS INCORRENT',&
360 &
'BEGIN AND END CAN BE IN EITHER CYCLES OR TIME BUT NOT MIXED',&
363 IF (eflag ==
'time')
THEN 376 ELSE IF(eflag ==
'step')
THEN 386 &(
'Number of steps can not be less than zero')
389 &(
'Starting time step can not be less than zero')
392 EndTime = StartTime + IMDTI *
nsteps 399 CALL fatal_error(
'IDEAL_TIME_STRING2TIME returned invalid flag')
413 CALL report_time_setup
429 stklen = ncf%FTIME%stk_len
434 IF (stklen .GT. 1)
THEN 436 CALL update_file_bracket(ncf,
starttime,status)
456 nextstk = ncf%FTIME%NEXT_STKCNT + 1
458 prev_time = ncf%FTIME%PREV_IO
459 prevstk = ncf%FTIME%PREV_STKCNT + 1
461 else if (ncf%FTIME%PREV_IO ==
starttime)
then 463 nextstk = ncf%FTIME%NEXT_STKCNT
466 prevstk = ncf%FTIME%PREV_STKCNT
469 call fatal_error(
'Something is very wrong with update_file_bracket!')
475 call fatal_error(
'Start time is before or after average output ???')
490 ELSE IF(stklen .eq. 1)
THEN 506 next_time = get_file_time_ncf(ncf,stklen)
516 call fatal_error(
'Cant crash restart when the restart time is not an average output time!')
538 & (
"CAN NOT CONNECT TO EXISTING FILE - THERE IS A TIME GAP",&
539 "BETWEEN THE EXISTING OUTPUT AND THE START TIME?")
545 &
Call fatal_error(
"The time of the first averaged output & 546 &must be less than or equal to the end time")
558 CALL set_output_file_time(
nc_avg,interval_time,next_time&
559 &,nextstk,prev_time,prevstk,stklen,stkmax)
578 stklen = ncf%FTIME%stk_len
581 IF (stklen .GT. 1)
THEN 583 CALL update_file_bracket(ncf,
starttime,status)
585 prev_time = ncf%FTIME%PREV_IO
586 prevstk= ncf%FTIME%PREV_STKCNT
589 nextstk = ncf%FTIME%NEXT_STKCNT
590 next_time = ncf%FTIME%NEXT_IO
595 prev_time = get_file_time_ncf(ncf,stklen)
599 next_time = prev_time + interval_time
602 &(
"COULD NOT FIND VALID BRACKET FOR START TIME IN THE DATA FILE",&
603 &
"Try comparing the time in the restart and the data file?")
607 ELSE IF(stklen .eq. 1)
THEN 609 prev_time = get_file_time_ncf(ncf,stklen)
615 next_time = prev_time + interval_time
627 CALL get_first_output_time(trim(
nc_first_out),next_time)
635 & (
"CAN NOT CONNECT TO EXISTING FILE - THERE IS A TIME GAP",&
636 "BETWEEN THE EXISTING OUTPUT AND THE START TIME?")
641 &
Call fatal_error(
"The time of the first file output & 642 &must be less than or equal to the end time")
649 CALL set_output_file_time(
nc_dat,interval_time,next_time&
650 &,nextstk,prev_time,prevstk,stklen,stkmax)
667 IF (stklen .GT. 1)
THEN 671 ncf%FTIME%prev_stkcnt = 0
672 CALL update_file_bracket(ncf,
starttime,status)
674 &(
" COULD NOT FIND VALID BRACKET FOR START TIME IN THE DATA FILE")
681 prev_time = ncf%FTIME%PREV_IO
682 prevstk= ncf%FTIME%PREV_STKCNT
685 nextstk = ncf%FTIME%NEXT_STKCNT
686 next_time = ncf%FTIME%NEXT_IO
687 ELSE IF (ncf%FTIME%NEXT_IO ==
starttime)
THEN 689 prev_time= ncf%FTIME%NEXT_IO
690 prevstk= ncf%FTIME%NEXT_STKCNT
692 next_time= prev_time + interval_time
693 nextstk = prevstk + 1
696 CALL fatal_error(
"DID NOT MATCH START TIME TO RESTART FILE")
700 ELSE IF(stklen .eq. 1)
THEN 702 prev_time = get_file_time_ncf(ncf,stklen)
707 next_time = prev_time + interval_time
713 &
"I suggest a strong cocktail before you try and figure this one out!")
719 ncf%FTIME%PREV_IO= prev_time
720 ncf%FTIME%PREV_STKCNT=prevstk
722 ncf%FTIME%NEXT_IO = next_time
723 ncf%FTIME%NEXT_STKCNT = nextstk
726 &
Call fatal_error(
"The time of the first file output & 727 &must be less than or equal to the end time")
733 CALL set_output_file_time(
nc_rst,interval_time,next_time&
734 &,nextstk,prev_time,prevstk,stklen,stkmax)
744 WRITE(
ipt,*)
'! SET TIME FOR COLDSTART !' 758 EndTime = READ_DATETIME(END_DATE,DATE_FORMAT,TIMEZONE,status)
760 &
Call fatal_error(
"Could not read the date string END_DATE: "&
765 &
Call fatal_error(
"Runfile Start_Date exceeds or equal to End_Date")
785 &
"! SETTING PREV_STCKNT FOR NETCDF COLD START FILE 1" 791 &
"! NO NETCDF COLD START FILE" 805 (
'IDEALIZED MODEL TIME SPECIFICATION IS INCORRENT',&
806 &
'BEGIN AND END CAN BE IN EITHER CYCLES OR TIME BUT NOT MIXED',&
809 IF (bflag ==
'time')
THEN 819 &
"! SETTING PREV_STCKNT FOR NETCDF COLD START FI& 826 &
"! NO NETCDF COLD START FILE" 831 ELSE IF(bflag ==
'step')
THEN 838 &(
'Number of steps can not be less than zero')
844 EndTime = IMDTI *
iend 853 &
"! SETTING PREV_STCKNT FOR NETCDF COLD START FI& 860 &
"! NO NETCDF COLD START FILE" 865 CALL fatal_error(
'IDEAL_TIME_STRING2TIME returned invalid flag')
884 CALL report_time_setup
901 CALL set_output_file_time(
nc_avg,interval_time,next_time&
902 &,nextstk,prev_time,prevstk,stklen,stkmax)
906 &
Call fatal_error(
"The time of the first averaged output & 907 &must be greater than or equal to the start time")
910 &
Call fatal_error(
"The time of the first averaged output & 911 &must be less than or equal to the end time")
917 CALL get_first_output_time(trim(
nc_first_out),next_time)
929 CALL set_output_file_time(
nc_dat,interval_time,next_time&
930 &,nextstk,prev_time,prevstk,stklen,stkmax)
935 &
Call fatal_error(
"The time of the first file output & 936 &must be greater than or equal to the start time")
939 &
Call fatal_error(
"The time of the first file output & 940 &must be less than or equal to the end time")
960 CALL set_output_file_time(
nc_rst,interval_time,next_time&
961 &,nextstk,prev_time,prevstk,stklen,stkmax)
966 &
Call fatal_error(
"The time of the first restart output & 967 &must be greater than or equal to the start time")
970 &
Call fatal_error(
"The time of the first restart output & 971 &must be less than or equal to the end time")
994 interval_time =
nc_rst%FTIME%INTERVAL
995 next_time =
nc_rst%FTIME%NEXT_IO
998 CALL fatal_error(
"RST_OUT_INTERVAL must be an integer number of int& 1002 CALL fatal_error(
"RST_FIRST_OUT must be an integer number of int& 1003 &ernal time steps from the StartTime!")
1009 interval_time =
nc_dat%FTIME%INTERVAL
1010 next_time =
nc_dat%FTIME%NEXT_IO
1012 CALL fatal_error(
"NC_OUT_INTERVAL must be an integer number of int& 1013 &ernal time steps!")
1016 CALL fatal_error(
"NC_FIRST_OUT must be an integer number of int& 1017 &ernal time steps from the StartTime!")
1024 interval_time =
nc_avg%FTIME%INTERVAL
1025 next_time =
nc_avg%FTIME%NEXT_IO
1028 CALL fatal_error(
"NCAV_OUT_INTERVAL must be an integer number of int& 1029 &ernal time steps!")
1032 CALL fatal_error(
"NCAV_FIRST_OUT must be an integer number of int& 1033 &ernal time steps from the StartTime!")
1041 CALL fatal_error(
"NCAV_OUT_INTERVAL: The restart file int& 1042 &erval must be an integer number of Average intervals!")
1048 &(
"NCAV_FIRST_OUT: Any Restart dump time must also be a average output time!",&
1049 &
"MOD(RST_FIRST_OUT - NCAV_FIRST_OUT,NCAV_OUT_INTERVAL)/=0 IS AN ERROR")
1070 IF(flag ==
'step')
THEN 1074 &(
'Number of steps for INTERVAL_RHO_MEAN can not be less than zero')
1079 ELSE IF(flag ==
'time')
THEN 1083 &(
'INTERVAL_RHO_MEAN can not be LE zero seconds!')
1089 interval_time =
nc_rst%FTIME%INTERVAL
1090 next_time =
nc_rst%FTIME%NEXT_IO
1093 CALL warning(
"MODEL RESTART IS NOT PERFECT WHEN USING RHO MEAN RECALCULATION,",&
1094 "TO FIX: SET MOD(RST_OUT_INTERVAL,INTERVAL_RHO_MEAN)==0!")
1099 CALL warning(
"MODEL RESTART IS NOT PERFECT WHEN USING RHO MEAN RECALCULATION,",&
1100 "TO FIX: SET MOD(RST_FIRST_OUT-StartTime,INTERVAL_RHO_MEAN)==0!")
character(len=80) date_format
subroutine get_output_file_interval(STRING, INTERVAL)
logical function dbg_set(vrb)
character(len=80) startup_type
character(len=80) rst_out_interval
character(len=80) ncav_out_interval
character(len=80) interval_rho_mean
character(len=80) date_reference
character(len=80) rst_first_out
type(time) function read_datetime(timestr, frmt, TZONE, status)
character(len=80) timezone
type(time) runfile_starttime
subroutine warning(ER1, ER2, ER3, ER4)
character(len=80) nc_first_out
logical use_real_world_time
character(len=80) end_date
logical recalculate_rho_mean
subroutine fatal_error(ER1, ER2, ER3, ER4)
character(len=80) ncav_first_out
integer ncav_output_stack
character(len=80) start_date
type(time) recalc_rho_mean
subroutine print_time(mjd, IPT, char)
integer, parameter dbg_log
character(len=80) nc_out_interval