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

cleanup lenkf.j.template #16

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

### Changed

### Fixed

### Removed

### Deprecated

-----------------------------

## [v1.0.2] - 2024-04-11
Expand All @@ -17,12 +27,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Bugfix for state increment array referencing in update_type=13.
- Bugfix for state increment array referencing in update_type=13 ([PR #26](https://github.com/GEOS-ESM/GEOSldas_GridComp/pull/26)).

### Changed

- Moved external `GEOSgcm_GridComp` repository to under `GEOSldas/src/Components` for
consistency with directory structure of GEOSgcm and GEOSadas.
consistency with directory structure of GEOSgcm and GEOSadas ([PR #27](https://github.com/GEOS-ESM/GEOSldas_GridComp/pull/27), [PR #30](https://github.com/GEOS-ESM/GEOSldas_GridComp/pull/30)).
- Changed lenkf.j.template to python string ([PR #16](https://github.com/GEOS-ESM/GEOSldas_GridComp/pull/16)).


-----------------------------

Expand All @@ -32,7 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- ldas_setup: Changed entry 'slurm' to 'slurm_pbs' to match remap_params.tpl
- ldas_setup: Changed entry 'slurm' to 'slurm_pbs' to match remap_params.tpl ([PR #17](https://github.com/GEOS-ESM/GEOSldas_GridComp/pull/17)).

-----------------------------

Expand All @@ -42,13 +54,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-----------------------------

### Added

### Changed

### Fixed

### Removed

### Deprecated

3 changes: 2 additions & 1 deletion GEOSldas_App/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set (scripts
ens_forcing/regrid_forc.csh
ens_forcing/enpert_forc.csh
util/config/rewind_GEOSldas.csh
lenkf_j_template.py
)

install (
Expand All @@ -42,7 +43,7 @@ file(GLOB rc_files GEOSldas_*rc)
file(GLOB nml_files LDASsa_DEFAULT*nml)

install(
FILES ${rc_files} ${nml_files} lenkf.j.template
FILES ${rc_files} ${nml_files}
DESTINATION etc
)

Expand Down
109 changes: 41 additions & 68 deletions GEOSldas_App/ldas_setup
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ from dateutil.relativedelta import relativedelta
from remap_utils import *
from remap_catchANDcn import *
from remap_config_ldas import *

from lenkf_j_template import *
"""
This script is intended to be run from any installed directory with GEOSldas.x and ldas_setup
(The default setup is ../install/bin)
Expand Down Expand Up @@ -166,9 +166,10 @@ class LDASsetup:
assert not os.path.isdir(_mydir), 'Dir [%s] already exists!' % _mydir
_mydir = None
self.ladas_coupling = int(self.rqdExeInp.get('LADAS_COUPLING',0))
self.adas_expdir =''
if self.ladas_coupling > 0:
assert 'ADAS_EXPDIR' in self.rqdExeInp, " need ADAS_EXPDIR in the input file %s" %(self.exeinpfile)

self.adas_expdir = self.rqdExeInp['ADAS_EXPDIR']
self.first_ens_id = int(self.rqdExeInp.get('FIRST_ENS_ID',0))
self.perturb = int(self.rqdExeInp.get('PERTURBATIONS',0))
if self.nens > 1:
Expand Down Expand Up @@ -1294,8 +1295,6 @@ class LDASsetup:
status = False

os.chdir(self.rundir)
lenkf=self.blddir+'/etc/lenkf.j.template'
shutil.copy(lenkf,'lenkf.j')

my_qos='allnccs'
if self.GEOS_SITE == 'NAS': my_qos = 'normal'
Expand Down Expand Up @@ -1330,71 +1329,45 @@ class LDASsetup:
'.'.join([expid, 'ldas_err', myDateTime, 'txt']),
]),
self.rundir)
with open(lenkf,'rt') as fin:
with open('lenkf.j','wt') as fout :
for line in fin :
if self.GEOS_SITE == 'NAS':
if '#SBATCH' in line:
continue
if 'sbatch $HOMDIR/lenkf.j' in line:
continue

if self.GEOS_SITE == 'NCCS':
if '#PBS' in line:
continue
if 'qsub $HOMDIR/lenkf.j' in line:
continue

if 'MY_ACCOUNT' in line :
fout.write(line.replace('MY_ACCOUNT',self.rqdRmInp['account']))
elif 'MY_WALLTIME' in line :
fout.write(line.replace('MY_WALLTIME',self.rqdRmInp['walltime']))
elif 'MY_NODES' in line :
line_ = line.replace('MY_NODES',str(self.optRmInp['nodes']))
line_ = line_.replace('MY_NTASKS_PER_NODE',str(self.rqdRmInp['ntasks-per-node']))
line_ = line_.replace('MY_CONSTRAINT', 'cas_ait')
fout.write(line_)
if self.GEOS_SITE == "NCCS" :
if self.BUILT_ON_SLES15 :
fout.write("#SBATCH --constraint=mil\n")
else:
assert int(self.rqdRmInp['ntasks-per-node']) <= 46, 'ntasks-per-node should be <=46 for cas'
fout.write("#SBATCH --constraint=cas\n")

elif 'MY_OSERVER_NODES' in line :
fout.write(line.replace('MY_OSERVER_NODES',str(self.optRmInp['oserver_nodes'])))
elif 'MY_WRITERS_NPES' in line :
fout.write(line.replace('MY_WRITERS_NPES', str(self.optRmInp['writers-per-node'])))
elif 'MY_QOS' in line :
if 'allnccs' not in my_qos or 'normal' not in my_qos:
fout.write(line.replace('MY_QOS',my_qos))
elif 'MY_JOB' in line :
fout.write(line.replace('MY_JOB',my_job))
elif 'MY_EXPID' in line :
fout.write(line.replace('MY_EXPID',self.rqdExeInp['EXP_ID']))
elif 'MY_EXPDOMAIN' in line :
fout.write(line.replace('MY_EXPDOMAIN',self.rqdExeInp['EXP_DOMAIN']))
elif 'MY_LOGFILE' in line :
fout.write(line.replace('MY_LOGFILE',my_logfile))
elif 'MY_ERRFILE' in line :
fout.write(line.replace('MY_ERRFILE',my_errfile))
elif 'MY_MODEL' in line :
fout.write(line.replace('MY_MODEL',self.catch))
elif 'MY_POSTPROC_HIST' in line :
fout.write(line.replace('MY_POSTPROC_HIST',str(self.rqdExeInp['POSTPROC_HIST'])))
elif 'MY_FIRST_ENS_ID' in line :
fout.write(line.replace('MY_FIRST_ENS_ID',str(self.first_ens_id)))
elif 'MY_LADAS_COUPLING' in line :
fout.write(line.replace('MY_LADAS_COUPLING',str(self.ladas_coupling)))
elif 'MY_ENSEMBLE_FORCING' in line :
fout.write(line.replace('MY_ENSEMBLE_FORCING',self.rqdExeInp.get('ENSEMBLE_FORCING', 'NO').upper()))
elif 'MY_ADAS_EXPDIR' in line :
if self.ladas_coupling > 0:
fout.write(line.replace('MY_ADAS_EXPDIR', self.rqdExeInp['ADAS_EXPDIR']))
else :
my_expdir = self.exphome + '/' + self.rqdExeInp['EXP_ID']
fout.write(line.replace('MY_EXPDIR',my_expdir))
constraint='cas'
if self.GEOS_SITE == "NAS":
constraint = 'cas_ait'
elif self.BUILT_ON_SLES15:
constraint = 'mil'
else:
assert int(self.rqdRmInp['ntasks-per-node']) <= 46, 'ntasks-per-node should be <=46 for cas'

SBATCHQSUB = 'sbatch'
if self.GEOS_SITE == 'NAS':
SBATCHQSUB = 'qsub'

job_head = job_directive[self.GEOS_SITE]
lenkf_str= (job_head+job_body).format(
SBATCHQSUB = SBATCHQSUB,
MY_ACCOUNT = self.rqdRmInp['account'],
MY_WALLTIME = self.rqdRmInp['walltime'],
MY_NODES = str(self.optRmInp['nodes']),
MY_NTASKS_PER_NODE = str(self.rqdRmInp['ntasks-per-node']),
MY_CONSTRAINT = constraint,
MY_OSERVER_NODES = str(self.optRmInp['oserver_nodes']),
MY_WRITERS_NPES = str(self.optRmInp['writers-per-node']),
MY_QOS = my_qos,
MY_JOB = my_job,
MY_EXPID = self.rqdExeInp['EXP_ID'],
MY_EXPDOMAIN = self.rqdExeInp['EXP_DOMAIN'],
MY_LOGFILE = my_logfile,
MY_ERRFILE = my_errfile,
MY_MODEL = self.catch,
MY_POSTPROC_HIST = str(self.rqdExeInp['POSTPROC_HIST']),
MY_FIRST_ENS_ID = str(self.first_ens_id),
MY_LADAS_COUPLING = str(self.ladas_coupling),
MY_ENSEMBLE_FORCING= self.rqdExeInp.get('ENSEMBLE_FORCING', 'NO').upper(),
MY_ADAS_EXPDIR = self.adas_expdir,
MY_EXPDIR = self.exphome + '/' + self.rqdExeInp['EXP_ID']
)

with open('lenkf.j','wt') as fout :
fout.write(lenkf_str)
sp.call(['chmod', '755', 'lenkf.j'])

expdir = '/'.join(self.rundir.rstrip('/').split('/')[:-1])
Expand Down
Loading