Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add parameters to model_configure #19

Open
ghost opened this issue Sep 30, 2020 · 2 comments
Open

add parameters to model_configure #19

ghost opened this issue Sep 30, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Sep 30, 2020

model_configure is currently mostly hardcoded; need to add parameters to the ModelConfiguration object:

class ModelConfigurationFile(ConfigurationFile):
name = 'model_configure'
def __init__(self, start_time: datetime, duration: timedelta, sequence: RunSequence):
self.start_time = start_time
self.duration = duration
super().__init__(sequence)
def write(self, directory: PathLike, overwrite: bool = False):
directory = ensure_directory(directory)
filename = directory / self.name
if filename.exists():
LOGGER.warning(
f'{"overwriting" if overwrite else "skipping"} ' f'existing file "{filename}"'
)
if not filename.exists() or overwrite:
LOGGER.debug(f'writing model configuration to "{filename}"')
with open(filename, 'w') as output_file:
output_file.write(str(self))
symbolic_link_filename = directory / 'atm_namelist.rc'
try:
symbolic_link_filename.symlink_to(filename)
except Exception as error:
LOGGER.warning(f'could not create symbolic link: {error}')
with open(symbolic_link_filename, 'w') as output_file:
output_file.write(str(self))
def __str__(self) -> str:
duration_hours = round(self.duration / timedelta(hours=1))
return '\n'.join(
[
'core: gfs',
'print_esmf: .true.',
'',
'nhours_dfini=0',
'',
'#nam_atm +++++++++++++++++++++++++++',
'nlunit: 35',
'deltim: 900.0',
'fhrot: 0',
'namelist: atm_namelist',
'total_member: 1',
'grib_input: 0',
f'PE_MEMBER01: {self.sequence.processors}',
'PE_MEMBER02',
'PE_MEMBER03',
'PE_MEMBER04',
'PE_MEMBER05',
'PE_MEMBER06',
'PE_MEMBER07',
'PE_MEMBER08',
'PE_MEMBER09',
'PE_MEMBER10',
'PE_MEMBER11',
'PE_MEMBER12',
'PE_MEMBER13',
'PE_MEMBER14',
'PE_MEMBER15',
'PE_MEMBER16',
'PE_MEMBER17',
'PE_MEMBER18',
'PE_MEMBER19:',
'PE_MEMBER20:',
'PE_MEMBER21:',
'',
'# For stochastic perturbed runs - added by Dhou and Wyang',
'--------------------------------------------------------',
'# ENS_SPS, logical control for application of stochastic '
'perturbation scheme',
'# HH_START, start hour of forecast, and modified ' 'ADVANCECOUNT_SETUP',
'# HH_INCREASE and HH_FINAL are fcst hour increment and end '
'hour of forecast',
'# ADVANCECOUNT_SETUP is an integer indicating the number of '
'time steps between integration_start and the time when model '
'state is saved for the _ini of the GEFS_Coupling, currently is '
'0h.',
'',
'HH_INCREASE: 600',
'HH_FINAL: 600',
'HH_START: 0',
'ADVANCECOUNT_SETUP: 0',
'',
'ENS_SPS: .false.',
'HOUTASPS: 10000',
'',
'#ESMF_State_Namelist +++++++++++++++',
'',
'RUN_CONTINUE: .false.',
'',
'#',
'dt_int: 900',
'dt_num: 0',
'dt_den: 1',
f'start_year: {self.start_time.year}',
f'start_month: {self.start_time.month}',
f'start_day: {self.start_time.day}',
f'start_hour: {self.start_time.hour}',
f'start_minute: {self.start_time.minute}',
f'start_second: {self.start_time.second}',
f'nhours_fcst: {duration_hours:.0f}',
'restart: .false.',
f'nhours_fcst1: {duration_hours:.0f}',
'im: 192',
'jm: 94',
'global: .true.',
'nhours_dfini: 0',
'adiabatic: .false.',
'lsoil: 4',
'passive_tracer: .true.',
'dfilevs: 64',
'ldfiflto: .true.',
'num_tracers: 3',
'ldfi_grd: .false.',
'lwrtgrdcmp: .false.',
'nemsio_in: .false.',
'',
'',
'#jwstart added quilt',
'###############################',
'#### Specify the I/O tasks ####',
'###############################',
'',
'',
'quilting: .false. #For asynchronous '
'quilting/history writes',
'read_groups: 0',
'read_tasks_per_group: 0',
'write_groups: 1',
'write_tasks_per_group: 3',
'',
'num_file: 3 #',
"filename_base: 'SIG.F' 'SFC.F' 'FLX.F'",
"file_io_form: 'bin4' 'bin4' 'bin4'",
"file_io: 'DEFERRED' 'DEFERRED' 'DEFERRED' " "'DEFERRED' #",
'write_dopost: .false. # True--> run do on ' 'quilt',
'post_gribversion: grib1 # True--> grib version for '
'post output files',
'gocart_aer2post: .false.',
'write_nemsioflag: .TRUE. # True--> Write nemsio '
'run history files',
'nfhout: 3',
'nfhout_hf: 1',
'nfhmax_hf: 0',
'nsout: 0',
'',
'io_recl: 100',
"io_position: ' '",
"io_action: 'WRITE'",
"io_delim: ' '",
"io_pad: ' '",
'',
'#jwend',
]
)

@ghost ghost added the enhancement New feature or request label Oct 2, 2020
@ghost ghost self-assigned this Oct 2, 2020
@ghost
Copy link
Author

ghost commented Oct 2, 2020

this template might be useful:
https://github.com/NOAA-EMC/DATM-MOM6-CICE5/blob/ca3d21bd89f967e4c25953eaa3349829c739b528/parm/model_configure.IN#L1-L22

total_member:            1 
print_esmf:              .true.
PE_MEMBER01:             @[TASKS]
start_year:              @[SYEAR]
start_month:             @[SMONTH]
start_day:               @[SDAY]
start_hour:              @[SHOUR]
start_minute:            0
start_second:            0
nhours_fcst:             @[FHMAX]
RUN_CONTINUE:            .false.
ENS_SPS:                 .false.

dt_atmos:                   @[DT_ATMOS]
atm_coupling_interval_sec:  @[coupling_interval_fast_sec]

iatm: @[IATM]
jatm: @[JATM]

cdate0: @[CDATE]
nfhout: @[NFHOUT]
filename_base: @[FILENAME_BASE]

@ghost ghost changed the title model_configure is mostly hardcoded currently add parameters to model_configure Oct 2, 2020
@ghost ghost removed their assignment Oct 2, 2020
@ghost
Copy link
Author

ghost commented Oct 2, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

0 participants