Skip to content

Commit 2a33374

Browse files
committed
edited handling of nens, mwrtm_path, nml_input_path and special nml input files (CMakeLists.txt, ldas_setup)
1 parent 1f8a0ec commit 2a33374

File tree

2 files changed

+60
-54
lines changed

2 files changed

+60
-54
lines changed

GEOSldas_App/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ configure_file(${file} ${file} @ONLY)
3939
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION bin)
4040

4141
file(GLOB rc_files GEOSldas_*rc)
42-
file(GLOB nml_files LDASsa_DEFAULT*nml)
42+
file(GLOB nml_files LDASsa_DEFAULT*nml LandAtmDAS/LDASsa_SPECIAL*nml )
4343

4444
install(
4545
FILES ${rc_files} ${nml_files}

GEOSldas_App/ldas_setup

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class LDASsetup:
112112
self.bcs_version = cmdLineArgs['bcs_version']
113113
self.rstloc = cmdLineArgs['rstloc']
114114
self.varwindow = cmdLineArgs['varwindow']
115-
self.atm_nens = cmdLineArgs['atm_nens']
115+
self.nens = cmdLineArgs['nens']
116116

117117
# obsolete command line args
118118
self.runmodel = cmdLineArgs['runmodel']
@@ -190,20 +190,20 @@ class LDASsetup:
190190
if self.ladas_cpl > 0 :
191191

192192
# make sure all necessary command line arguments were supplied
193-
assert self.nymdb is not None, "Error. Must have command line arg nymdb for coupled land-atm DAS.\n"
194-
assert self.nhmsb is not None, "Error. Must have command line arg nhmsb for coupled land-atm DAS.\n"
195-
assert self.agcm_res is not None, "Error. Must have command line arg agcm_res for coupled land-atm DAS.\n"
196-
assert self.bcs_version is not None, "Error. Must have command line arg bcs_version for coupled land-atm DAS.\n"
197-
assert self.rstloc is not None, "Error. Must have command line arg rstloc for coupled land-atm DAS.\n"
198-
assert self.varwindow is not None, "Error. Must have command line arg varwindow for coupled land-atm DAS.\n"
199-
assert self.atm_nens is not None, "Error. Must have command line arg atm_nens for coupled land-atm DAS.\n"
193+
assert self.nymdb is not None, "Error. Must have command line arg nymdb for coupled land-atm DAS.\n"
194+
assert self.nhmsb is not None, "Error. Must have command line arg nhmsb for coupled land-atm DAS.\n"
195+
assert self.agcm_res is not None, "Error. Must have command line arg agcm_res for coupled land-atm DAS.\n"
196+
assert self.bcs_version is not None, "Error. Must have command line arg bcs_version for coupled land-atm DAS.\n"
197+
assert self.rstloc is not None, "Error. Must have command line arg rstloc for coupled land-atm DAS.\n"
198+
assert self.varwindow is not None, "Error. Must have command line arg varwindow for coupled land-atm DAS.\n"
199+
assert self.nens is not None, "Error. Must have command line arg nens for coupled land-atm DAS.\n"
200200

201-
self.rqdExeInp['BEG_DATE'] = f"{self.nymdb} {self.nhmsb}"
202-
rstloc_ = self.rstloc.rstrip('/') # remove trailing '/'
203-
assert os.path.isdir(rstloc_) # make sure rstloc_ is a valid directory
204-
self.rstloc = os.path.abspath(rstloc_)
205-
self.rqdExeInp['RESTART_PATH'] = os.path.dirname( self.rstloc)
206-
self.rqdExeInp['RESTART_ID'] = os.path.basename(self.rstloc)
201+
self.rqdExeInp['BEG_DATE'] = f"{self.nymdb} {self.nhmsb}"
202+
rstloc_ = self.rstloc.rstrip('/') # remove trailing '/'
203+
assert os.path.isdir(rstloc_) # make sure rstloc_ is a valid directory
204+
self.rstloc = os.path.abspath(rstloc_)
205+
self.rqdExeInp['RESTART_PATH'] = os.path.dirname( self.rstloc)
206+
self.rqdExeInp['RESTART_ID'] = os.path.basename(self.rstloc)
207207

208208
self.adas_expdir = os.path.dirname( self.exphome)
209209
self.rqdExeInp['ADAS_EXPDIR'] = self.adas_expdir
@@ -215,30 +215,32 @@ class LDASsetup:
215215
self.rqdExeInp['EXP_ID'] = self.adas_expid + '_LDAS'
216216
self.rqdExeInp['MET_PATH'] = self.adas_expdir + '/recycle/holdpredout'
217217
self.rqdExeInp['ENSEMBLE_FORCING'] = 'NO'
218-
self.nens = 24 # for now, hardwire nens for atm det
219218
elif self.ladas_cpl == 2 :
220219
# ldas coupled with ensemble component of adas
221220
self.rqdExeInp['EXP_ID'] = self.adas_expid + '_LDAS4ens'
222221
self.rqdExeInp['MET_PATH'] = self.adas_expdir + '/atmens/mem'
223222
self.rqdExeInp['ENSEMBLE_FORCING'] = 'YES'
224-
self.nens = self.atm_nens
225223
else :
226224
exit("Error. Unknown value of self.ladas_cpl.\n")
225+
227226
self.rqdExeInp['NUM_LDAS_ENSEMBLE'] = self.nens
228227
self.first_ens_id = 1
229-
self.rqdExeInp['FIRST_ENS_ID'] = self.first_ens_id
230-
self.rqdExeInp['EXP_DOMAIN'] = 'CF'+ self.agcm_res +'x6C_GLOBAL'
228+
self.rqdExeInp['FIRST_ENS_ID'] = self.first_ens_id
229+
230+
_agcm_res = 'CF' + self.agcm_res
231+
self.rqdExeInp['EXP_DOMAIN'] = _agcm_res +'x6C_GLOBAL'
231232

232233
# when coupled to ADAS, "BCS_PATH" EXCLUDE bcs version info
233234
# hard-wired BCS_PATH for now
234-
self.rqdExeInp['BCS_PATH'] = "/discover/nobackup/projects/gmao/bcs_shared/fvInput/ExtData/esm/tiles"
235+
self.rqdExeInp['BCS_PATH'] = "/discover/nobackup/projects/gmao/bcs_shared/fvInput/ExtData/esm/tiles"
235236
self.rqdExeInp['BCS_PATH'] = self.rqdExeInp['BCS_PATH'].rstrip('/') + '/' + self.bcs_version
236237
if self.bcs_version == "Icarus-NLv3" :
237238
self.rqdExeInp['BCS_PATH'] = self.rqdExeInp['BCS_PATH'] + '_new_layout'
238-
self.rqdExeInp['BCS_RESOLUTION'] = 'CF'+ self.agcm_res +'x6C_CF' + self.agcm_res +'x6C'
239-
self.rqdExeInp['RESTART_DOMAIN'] = 'CF'+ self.agcm_res +'x6C_GLOBAL'
239+
self.rqdExeInp['BCS_RESOLUTION'] = _agcm_res +'x6C_' + _agcm_res +'x6C'
240+
self.rqdExeInp['RESTART_DOMAIN'] = _agcm_res +'x6C_GLOBAL'
240241

241242
# the following are not in default rqdExeInp list; hardwire for now
243+
self.rqdExeInp['MWRTM_PATH'] = '/discover/nobackup/projects/gmao/smap/SMAP_Nature/bcs/RTM_params/RTMParam_L2DCA_R19/'
242244
self.rqdExeInp['LAND_ASSIM'] = "YES"
243245
self.rqdExeInp['MET_HINTERP'] = 0
244246
self.landassim_dt = 10800 # seconds
@@ -249,29 +251,33 @@ class LDASsetup:
249251
exit("Error. LANDASSIM_DT is inconsistent with ADAS analysis window.\n")
250252
self.rqdExeInp['LANDASSIM_T0'] = "013000" # HHMMSS
251253
jsgmt1 = "00000000"
252-
jsgmt2 = hours_to_hhmmss(int(self.varwindow)/60) # convert minutes to HHMMSS
254+
jsgmt2 = hours_to_hhmmss(int(self.varwindow)/60) # convert minutes to HHMMSS
253255
self.rqdExeInp['JOB_SGMT'] = f"{jsgmt1} {jsgmt2}"
254256
self.rqdExeInp['NUM_SGMT'] = 1
255257
self.rqdExeInp['FORCE_DTSTEP'] = 3600
256258

257259
# determine END_DATE = BEG_DATE + TIME_STEP_OF_ADAS_CYCLE
258-
_beg_date = datetime.strptime( self.rqdExeInp['BEG_DATE'], "%Y%m%d %H%M%S")
259-
_hours = int(self.rqdExeInp['JOB_SGMT'][ 9:11])
260-
_end_date = _beg_date + timedelta(hours=int(self.varwindow)/60)
261-
260+
_beg_date = datetime.strptime( self.rqdExeInp['BEG_DATE'], "%Y%m%d %H%M%S")
261+
_hours = int(self.rqdExeInp['JOB_SGMT'][ 9:11])
262+
_end_date = _beg_date + timedelta(hours=int(self.varwindow)/60)
262263
self.rqdExeInp['END_DATE'] = _end_date.strftime("%Y%m%d %H%M%S")
263264

264-
#default special nml path
265-
current_directory = os.path.dirname(__file__)
266-
geosdir = current_directory.rsplit('/',2)[0]
267-
self.LDAS_nml_path = geosdir +'/src/Components/@GEOSldas_GridComp/GEOSldas_App/SPECnml/'
268-
self.rqdExeInp['NML_INPUT_PATH'] = self.LDAS_nml_path
269-
270-
# default mwrtm path
271-
self.mwrtm_path = '/discover/nobackup/projects/gmao/smap/SMAP_Nature/bcs/RTM_params/RTMParam_L2DCA_R19/'
272-
self.rqdExeInp['MWRTM_PATH'] = self.mwrtm_path
265+
# process LDAS special nml input files
266+
# FOR NOW, DEFINE/CREATE etc AND run DIRECTORIES HERE; NOTE THAT self.rundir IS DEFINED
267+
# IN __init__() BELOW AND etcdir IS DEFINED IN createRCFiles().
268+
current_directory = os.path.dirname(__file__)
269+
_etcdir = current_directory.rsplit('/',2)[0] + '/etc/'
270+
_rundir = self.exphome + '/' + self.rqdExeInp['EXP_ID'] + '/run/'
271+
self._mkdir_p(_rundir)
272+
# copy nml files to run directory
273+
shutil.copy(_etcdir+'/LDASsa_SPECIAL_inputs_ensprop.nml', _rundir)
274+
shutil.copy(_etcdir+'/LDASsa_SPECIAL_inputs_ensupd.nml' , _rundir)
275+
# edit resolution info in ensupd nml file
276+
sp.run(['sed', '-i', 's/<CFnnnn>/'+_agcm_res+'/g', _etcdir+'/LDASsa_SPECIAL_inputs_ensupd.nml'])
277+
self.rqdExeInp['NML_INPUT_PATH'] = _rundir
278+
273279

274-
# end if self.ladas_cpl > 0
280+
# end if self.ladas_cpl > 0 --------------------------------------------------------------------
275281

276282
for key in rqdExeInpKeys :
277283
assert key in self.rqdExeInp,' "%s" is required in the input file %s' % (key,self.exeinpfile)
@@ -639,22 +645,22 @@ class LDASsetup:
639645
# exefyl
640646
# ------
641647

642-
self.bindir = os.path.dirname(os.path.realpath(__file__))
643-
self.blddir = self.bindir.rsplit('/',1)[0]
644-
exefyl = '/bin/GEOSldas.x'
645-
tmp_execfyl= self.blddir+exefyl
648+
self.bindir = os.path.dirname(os.path.realpath(__file__))
649+
self.blddir = self.bindir.rsplit('/',1)[0]
650+
exefyl = '/bin/GEOSldas.x'
651+
tmp_execfyl = self.blddir + exefyl
646652
assert os.path.isfile(tmp_execfyl),\
647653
'Executable [%s] does not exist!' % tmp_execfyl
648-
self.expdir = self.exphome + '/' + self.rqdExeInp['EXP_ID']
649-
self.rundir = self.expdir + '/run'
650-
self.inpdir = self.expdir + '/input'
651-
self.outdir = self.expdir + '/output'
652-
self.scratchdir = self.expdir + '/scratch'
653-
self.blddirLn = self.expdir + '/build'
654-
self.out_path = self.outdir+'/'+self.rqdExeInp['EXP_DOMAIN']
655-
self.bcsdir = self.outdir+'/'+self.rqdExeInp['EXP_DOMAIN']+'/rc_out/'
656-
self.rstdir = self.outdir+'/'+self.rqdExeInp['EXP_DOMAIN']+'/rs/'
657-
self.exefyl = self.blddirLn+exefyl
654+
self.expdir = self.exphome + '/' + self.rqdExeInp['EXP_ID']
655+
self.rundir = self.expdir + '/run'
656+
self.inpdir = self.expdir + '/input'
657+
self.outdir = self.expdir + '/output'
658+
self.scratchdir = self.expdir + '/scratch'
659+
self.blddirLn = self.expdir + '/build'
660+
self.out_path = self.outdir + '/'+self.rqdExeInp['EXP_DOMAIN']
661+
self.bcsdir = self.outdir + '/'+self.rqdExeInp['EXP_DOMAIN']+'/rc_out/'
662+
self.rstdir = self.outdir + '/'+self.rqdExeInp['EXP_DOMAIN']+'/rs/'
663+
self.exefyl = self.blddirLn + exefyl
658664

659665
my_ntasks_per_node = int(self.rqdRmInp['ntasks-per-node'])
660666

@@ -1967,7 +1973,7 @@ def parseCmdLine():
19671973
)
19681974
p_setup.add_argument(
19691975
'--agcm_res',
1970-
help='AGCM resolution associated with boundary conditions: xxxx (4 digits). Required when exeinp is dummy',
1976+
help='AGCM resolution associated with boundary conditions: nnnn (4 digits). Required when exeinp is dummy',
19711977
type=str
19721978
)
19731979
p_setup.add_argument(
@@ -1986,8 +1992,8 @@ def parseCmdLine():
19861992
type=str
19871993
)
19881994
p_setup.add_argument(
1989-
'--atm_nens',
1990-
help='ADAS number of ensemble members (Required when exeinp is dummy',
1995+
'--nens',
1996+
help='number of ensemble members. Required when exeinp is dummy',
19911997
type=str
19921998
)
19931999

0 commit comments

Comments
 (0)