Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hd-model/hd-couple
1 result
Show changes
Commits on Source (2)
......@@ -29,9 +29,12 @@
! nstep INTEGER Number of time steps within the run if date_start & date_end are not provided
! delta_time REAL(dp) Model time step length in seconds
! time_start CHARACTER Start time of the run, format HHMMSS or HH:MM:SS (Def.: none)
! If you set time_start, you must also set date_start.
! time_end CHARACTER End time of the run, HHMMSS or HH:MM:SS (Def.: none)
! If you set time_end, you must also set date_end.
! date_rest CHARACTER Date of the first restart file writing, format YYYYMMDD or YYYY-MM-DD (Def.: none)
! time_rest CHARACTER Time of the first restart file writing, format HHMMSS or HH:MM:SS (Def.: none)
! irest_regular INTEGER Switch for regular writing of restart files (0=none, 1=annual)
!
! ufakru REAL(dp) unit factor for runoff and drainage input data
! runoff_file CHARACTER file with input runoff data
......@@ -65,7 +68,7 @@
NAMELIST /HD_CTL/ &
OUT_EXPNAME, OUT_DATAPATH, YEAR1, MONTH1, DATE_START, DATE_END, NSTEP, DELTA_TIME, &
TIME_START, TIME_END, DATE_REST, TIME_REST, &
TIME_START, TIME_END, DATE_REST, TIME_REST, IREST_REGULAR, &
UFAKRU, RUNOFF_FILE, DRAINAGE_FILE, FORCING_FREQ, IOUT, &
COUPLING_TYPE, LCOUPLING_ATM, LCOUPLING_OCE, ICPL_SINKS, ICPL_MASK_TOHD, &
COUPLING_FILE, LCOUPLING_OUT, IFORM_INPUT, LTRANSPORT, IBC_TYPE, DN_BCPARA, LBC_WRITE
......
......@@ -81,7 +81,7 @@ PROGRAM hd_driver
USE mo_time_control, ONLY: l_trigfiles, dt_start, init_manager, delta_time, &
init_times, ec_manager_init, time_reset, &
no_steps, time_set, current_date, &
write_date, day_difference, calc_nstep
write_date, day_difference, calc_nstep, update_regular_restart
USE mo_exception, ONLY: finish, message, message_text
!OSBJSB USE mo_jsbach_interface, ONLY: get_dates
USE mo_control, ONLY: nlon, ngl, nproca, nprocb, nprocio
......@@ -124,6 +124,7 @@ PROGRAM hd_driver
CHARACTER(LEN=10) :: date_start, date_end, date_rest
CHARACTER(LEN=8) :: time_start, time_end, time_rest
INTEGER :: nstep_rest ! Number of time steps until a dedicated writing of restart file
INTEGER :: irest_regular ! Switch for regular writing of restart files (0=none, 1=annual, 2=monthly)
INTEGER :: forcing_freq
INTEGER :: iout
LOGICAL :: lcoupling_out ! Write output for coupling_type 2 (no/yes)
......@@ -359,10 +360,11 @@ write(nout,*) 'OTBhd_init_io'
CALL hd_write_output
! write restart file
IF (step == istep+nstep) THEN
IF (step == istep+nstep) THEN ! End of simulation restart
CALL hydrology_restart
ELSE IF (step == istep+nstep_rest) THEN
ELSE IF (step == istep+nstep_rest) THEN ! Dedicated or regular restart
CALL hydrology_restart(date_rest, time_rest)
IF (irest_regular.GT.0) CALL update_regular_restart(irest_regular, nstep_rest, date_rest)
ENDIF
! update model time step
......@@ -591,7 +593,8 @@ CONTAINS
! time_start Start time of the run, format HHMMSS or HH:MM:SS (Def.: none)
! time_end End time of the run, HHMMSS or HH:MM:SS (Def.: none)
! date_rest Date of the first restart file writing, format YYYYMMDD or YYYY-MM-DD (Def.: none)
! time_rest Time of the first restart file writing, format HHMMSS or HH:MM:SS (Def.: none)
! time_rest Time of the first restart file writing, format HHMMSS or HH:MM:SS (Def.: none)
! irest_regular Switch for regular writing of restart files (0=none, 1=annual, 2=monthly)
!
! runoff_file file with input runoff data
! drainage_file file with input drainage data
......@@ -622,6 +625,7 @@ CONTAINS
INTEGER :: read_status, inml, iunit, ndays
INTEGER :: coupling_type
INTEGER :: month_next
INCLUDE 'hd_ctl.inc'
......@@ -639,6 +643,7 @@ CONTAINS
time_end = ''
date_rest = ''
time_rest = ''
irest_regular = 0
ufakru = 1._dp
runoff_file = "runoff.nc"
drainage_file = "drainage.nc"
......@@ -700,6 +705,7 @@ CONTAINS
ELSE
WRITE (message_text,*) 'No. of time steps taken from namelist (Def.: 365): ', nstep
CALL message('config_hd', message_text)
day1 = 0 ; hour1 = 0 ; minute1 = 0 ; second1 = 0
ENDIF
! Check whether the writing of a restart file at a speficied point in time is requested.
......@@ -716,13 +722,50 @@ CONTAINS
ENDIF
nstep_rest = nstep_rest - 1 ! time_rest is exact time, not begin time of a timestep.
ELSE ! It is assumed that restart file shall be written after date_rest is calculated.
CALL calc_nstep(date_start, '00:00:00', date_rest, '00:00:00', nstep_rest)
time_rest = '00:00:00'
CALL calc_nstep(date_start, '00:00:00', date_rest, time_rest, nstep_rest)
nstep_rest = nstep_rest + NINT(86400._dp / delta_time) ! --> add no. of timesteps of one day.
WRITE (message_text,*) 'time_rest is not set --> Restart will be written after date_rest is calculated'
CALL message('config_hd', message_text)
ENDIF
ENDIF
! Check whether the regular writing of a restart file is requested.
IF (irest_regular.GT.0) THEN
IF (LEN_TRIM(date_rest).GT.0) THEN
WRITE (message_text,*) 'A dedicated and regular restart file writings are both set -> Inconsistent -> Please correct!'
CALL finish ('config_hd', message_text)
ENDIF
SELECT CASE(irest_regular)
CASE(1) ! Annual
date_rest = 'yyyy-01-01'
WRITE(date_rest(1:4), '(I4.4)') year1+1
CASE(2) ! monthly
month_next = month1 + 1
IF (month_next.EQ.13) THEN
date_rest = 'yyyy-01-01'
WRITE(date_rest(1:4), '(I4.4)') year1+1
ELSE
date_rest = 'yyyy-mm-01'
WRITE(date_rest(1:4), '(I4.4)') year1
WRITE(date_rest(6:7), '(I2.2)') month_next
ENDIF
CASE default
WRITE (message_text,*) 'irest_regular = ', irest_regular, ' is not defined -> Program terminated'
CALL finish ('config_hd', message_text)
END SELECT
IF (LEN_TRIM(date_start).LE.0) THEN
date_start = 'yyyy-mm-01'
WRITE(date_start(1:4), '(I4.4)') year1
WRITE(date_start(6:7), '(I2.2)') month1
ENDIF
time_rest = '00:00:00'
CALL calc_nstep(date_start, '00:00:00', date_rest, time_rest, nstep_rest)
nstep_rest = nstep_rest - 1 ! time_rest is exact time, not begin time of a timestep.
ENDIF
! Check coupling information
CALL set_coupling_type(coupling_type)
......
......@@ -610,8 +610,8 @@ CONTAINS
! finfl = Inflow data array for each gridbox for time step nstep
!
CHARACTER(LEN=*), OPTIONAL :: date_rest ! Date of dedicated restart file writing
CHARACTER(LEN=*), OPTIONAL :: time_rest ! Time of dedicated restart file writing
CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: date_rest ! Date of dedicated restart file writing
CHARACTER(LEN=*), OPTIONAL, INTENT(in) :: time_rest ! Time of dedicated restart file writing
TYPE (FILE_INFO) :: restartfile
......
......@@ -403,6 +403,8 @@ MODULE mo_time_control
PUBLIC :: day_difference ! Calculate the difference in days for two ISO dates
PUBLIC :: calc_nstep ! Calculate the number of time steps between two ISO dates & times
PUBLIC :: update_regular_restart ! Updates the time step number nstep_rest
! when the next regular restart file shall be written
CONTAINS
!+
......@@ -2421,6 +2423,56 @@ CONTAINS
END SUBROUTINE ctime2hms
!*****************************************************************************
SUBROUTINE update_regular_restart(irest_regular, nstep_rest, date_rest)
!*****************************************************************************
! Updates the time step number nstep_rest when the next regular restart file shall be written
! if irest_regular ist set > 0.
INTEGER, INTENT(in) :: irest_regular ! Switch for regular writing of restart files
! (0=none, 1=annual, 2=monthly)
INTEGER, INTENT(inout) :: nstep_rest ! Number of time steps until next writing of restart file
CHARACTER(LEN=*), INTENT(inout) :: date_rest ! Date of next regular restart file writing
INTEGER :: ymd, year_rest, month_rest, day_rest, month_next, ndum
INTEGER :: zero = 0
TYPE(time_days) :: date1
TYPE(time_native) :: date_nat
CHARACTER(LEN=10) :: date_old
date_old = date_rest
CALL cdate2ymd(date_rest, ymd)
! Determine day, month and year of previous restart date
CALL inp_convert_date (ymd, zero, date1)
CALL TC_convert(date1, date_nat)
CALL TC_get (date_nat, year_rest, month_rest, day_rest)
SELECT CASE(irest_regular)
CASE(1) ! Annual
WRITE(date_rest(1:4), '(I4.4)') year_rest+1
CASE(2) ! monthly
month_next = month_rest + 1
IF (month_next.EQ.13) THEN
date_rest = 'yyyy-01-01'
WRITE(date_rest(1:4), '(I4.4)') year_rest+1
ELSE
date_rest = 'yyyy-mm-01'
WRITE(date_rest(1:4), '(I4.4)') year_rest
WRITE(date_rest(6:7), '(I2.2)') month_next
ENDIF
CASE default
WRITE (message_text,*) 'irest_regular = ', irest_regular, ' is not defined -> Program terminated'
CALL finish ('update_regular_restart', message_text)
END SELECT
CALL calc_nstep(date_old, '00:00:00', date_rest, '00:00:00', ndum)
ndum = ndum - 1 ! time_rest is exact time, not begin time of a timestep --> -1 step for previous step.
nstep_rest = nstep_rest + ndum
END SUBROUTINE update_regular_restart
!+
! ------------------------------------------------------------------------------
!
......
......@@ -42,14 +42,14 @@ CFORM=nc # Format of forcing files: 'srv' = Service Format (Default), 'nc
ICOUPLE=0 # Coupling type: 0=no, 1=no interpolation, 2=interpolation in HD
DNCOUPLE=${HDFILE}/nemo/hdcouple_hd_vs5_1_to_nemo_imode2.nc
IWORK=5 # Run time: 1=1 year, 2=1 month, 3=year with 30 day months
IWORK=1 # Run time: 1=1 year, 2=1 month, 3=year with 30 day months
# 4=as 1 but final year with nday_final days
# 5=Manually steered by settings in hd_subdaily_settings
nday_final=212 # Jan-July: 90+91+31
ndate_end=20210731 # end date of run for IWORK=4
irest_regular=2 # Regular writing of restart file (0=no, 1=annual, 2=monthly)
MM=01 # Start month
# BIAS CORRECTION
......@@ -65,7 +65,6 @@ esac
DNREMAP="${EXPINP}_to_${RES_INP}" # Remap file name
#
# Time steering of run using date_start and date_end - maybe edited for sub-annual simulations
time_start=0 ; time_end=240000
case $IWORK in
2 ) date_start=${YYYY}${MM}01 ; date_end=${YYYY}${MM}31 ;; # Editing of last day required
3 ) date_start=${YYYY}${MM}01 ; date_end=${YYYY}1230 ;;
......
......@@ -392,9 +392,15 @@ cat >> namelist.hd << end_hdalone_ctl3
end_hdalone_ctl3
fi
#
if [ "$irest_regular" != "" ] ; then
cat >> namelist.hd << end_hdalone_ctl4
/
irest_regular = $irest_regular
end_hdalone_ctl4
fi
#
cat >> namelist.hd << end_hdalone_ctlz
/
end_hdalone_ctlz
#.................... NOTE for IOUT of HD ..................................
#! *** IOUT = Mittelungsartvariable, d.h. ueber wieviel Zeitschritte
......