Skip to content

Commit

Permalink
move runtime_mult inside of SCM Fortran code rather than run script f…
Browse files Browse the repository at this point in the history
…unction
  • Loading branch information
grantfirl committed Aug 15, 2024
1 parent cfe6354 commit 3e796b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
10 changes: 4 additions & 6 deletions scm/src/run_scm.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def __init__(self, case, suite, runtime, runtime_mult, levels, npz_type, vert_co

if runtime_mult:
self._runtime_mult = runtime_mult
message = 'Existing case namelist runtime multiplied by {0}'.format(self._runtime_mult)
message = 'Existing case namelist or DEPHY runtime multiplied by {0}'.format(self._runtime_mult)
logging.debug(message)
else:
self._runtime_mult = None
Expand Down Expand Up @@ -460,11 +460,9 @@ def setup_rundir(self):
message = 'The --runtime_mult argument must be greater than 0 ({0} was entered)'.format(self._runtime_mult)
logging.critical(message)
raise Exception(message)
try:
old_runtime = case_nml['case_config']['runtime']
case_nml['case_config']['runtime'] = old_runtime*self._runtime_mult
except KeyError:
logging.info('The runtime multiplier argument was set, but the runtime is not set in {0} '.format(self._namelist))
else:
case_nml['case_config']['runtime_mult'] = self._runtime_mult

# If the number of levels is specified, set the namelist value
if self._levels:
case_nml['case_config']['n_levels'] = self._levels
Expand Down
21 changes: 17 additions & 4 deletions scm/src/scm_input.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ subroutine get_config_nml(scm_state)
character(len=character_length) :: case_name !< name of case initialization and forcing dataset
real(kind=dp) :: dt !< time step in seconds
real(kind=dp) :: runtime !< total runtime in seconds
real(kind=dp) :: runtime_mult !< runtime multiplier
integer :: n_itt_out !< multiple of timestep for writing output
integer :: n_itt_diag !< multiple of timestep for resetting diagnostics (overwrites fhzero from physics namelist if present)
integer :: n_levels !< number of model levels (currently only 64 supported)
Expand Down Expand Up @@ -77,7 +78,7 @@ subroutine get_config_nml(scm_state)

CHARACTER(LEN=*), parameter :: experiment_namelist = 'input_experiment.nml'

NAMELIST /case_config/ npz_type, vert_coord_file, case_name, dt, runtime, n_itt_out, n_itt_diag, &
NAMELIST /case_config/ npz_type, vert_coord_file, case_name, dt, runtime, runtime_mult, n_itt_out, n_itt_diag, &
n_levels, output_dir, thermo_forcing_type, model_ics, &
lsm_ics, do_spinup, C_RES, spinup_timesteps, mom_forcing_type, relax_time, sfc_type, sfc_flux_spec, &
sfc_roughness_length_cm, reference_profile_choice, year, month, day, hour, min, &
Expand All @@ -95,7 +96,8 @@ subroutine get_config_nml(scm_state)
case_name = 'twpice'
dt = 600.0
time_scheme = 1
runtime = 2138400.0
runtime = 0.0
runtime_mult = 1.0
n_itt_out = 1
n_itt_diag = -999
n_levels = 127
Expand Down Expand Up @@ -179,6 +181,7 @@ subroutine get_config_nml(scm_state)
scm_state%n_itt_out = n_itt_out
scm_state%n_itt_diag = n_itt_diag
scm_state%runtime = runtime
scm_state%runtime_mult = runtime_mult
scm_state%time_scheme = time_scheme
scm_state%init_year = year
scm_state%init_month = month
Expand Down Expand Up @@ -211,7 +214,7 @@ end subroutine get_config_nml
subroutine get_case_init(scm_state, scm_input)
use scm_type_defs, only : scm_state_type, scm_input_type
use NetCDF_read, only: NetCDF_read_var, check, missing_value
type(scm_state_type), intent(in) :: scm_state
type(scm_state_type), intent(inout) :: scm_state
type(scm_input_type), target, intent(inout) :: scm_input

integer :: input_nlev !< number of levels in the input file
Expand Down Expand Up @@ -932,6 +935,9 @@ subroutine get_case_init(scm_state, scm_input)
scm_input%input_emis_ice = input_emis_ice
scm_input%input_lai = input_lai

if (scm_state%runtime_mult /= 1.0) then
scm_state%runtime = scm_state%runtime*scm_state%runtime_mult
end if
!> @}
end subroutine get_case_init

Expand Down Expand Up @@ -1867,7 +1873,14 @@ subroutine get_case_init_DEPHY(scm_state, scm_input)
scm_state%init_day = init_day
scm_state%init_hour = init_hour
scm_state%init_min = init_min
scm_state%runtime = elapsed_sec
if (scm_state%runtime > 0.0) then
!runtime is provided in the case configuration namelist - should override what is in the DEPHY file
if (scm_state%runtime_mult /= 1.0) then
scm_state%runtime = scm_state%runtime*scm_state%runtime_mult
end if
else
scm_state%runtime = elapsed_sec*scm_state%runtime_mult
end if

scm_input%input_time = input_time
scm_input%input_pres_surf(1) = input_pres_surf(active_init_time) !perhaps input_pres_surf should only be equal to input_force_pres_surf?
Expand Down
2 changes: 2 additions & 0 deletions scm/src/scm_type_defs.F90
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ module scm_type_defs
real(kind=dp) :: dt !< physics time step (s)
real(kind=dp) :: dt_now !< time step currently being used (if it changes due to time-stepping scheme)
real(kind=dp) :: runtime !< total runtime (s)
real(kind=dp) :: runtime_mult !< runtime multiplier
real(kind=dp) :: output_period !< how often output is written (s)
real(kind=dp) :: relax_time !< time scale for hor. wind nudging (s)
real(kind=dp) :: deg_to_rad_const !< conversion constant from degrees to radians
Expand Down Expand Up @@ -561,6 +562,7 @@ subroutine scm_state_create(scm_state, n_columns, n_levels, n_soil, n_snow, n_ti
scm_state%dt = real_zero
scm_state%dt_now = real_zero
scm_state%runtime = real_zero
scm_state%runtime_mult = 1.0
scm_state%output_period = real_zero
scm_state%relax_time = real_zero
scm_state%deg_to_rad_const = real_zero
Expand Down

0 comments on commit 3e796b9

Please sign in to comment.