Skip to content

Commit

Permalink
pynorms
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumevernieres committed Jul 1, 2024
1 parent 58115a6 commit 5438a47
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions ush/python/pygfs/task/marine_bmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ def __init__(self, config):
# Extend task_config with local_dict
self.task_config = AttrDict(**self.task_config, **local_dict)


@logit(logger)
def _run(self, exec_cmd):
"""Run the executable command
TODO: Move this method somewhere else
"""
logger.info(f"Executing {exec_cmd}")

try:
logger.debug(f"Executing {exec_cmd}")
exec_cmd()
Expand All @@ -75,7 +73,6 @@ def _run(self, exec_cmd):

pass


@logit(logger)
def _link_executable(self, exe_name: str) -> None:
"""Link the executable to the DATA directory
Expand All @@ -89,7 +86,6 @@ def _link_executable(self, exe_name: str) -> None:
os.remove(exe_dest)
os.symlink(exe_src, exe_dest)


@logit(logger)
def _prep_input_nml(self) -> None:
"""Prepare the input.nml file
Expand All @@ -109,7 +105,6 @@ def _prep_input_nml(self) -> None:
nml['fms_nml']['domains_stack_size'] = int(domain_stack_size)
nml.write('mom_input.nml')


@logit(logger)
def _cice_hist2fms(self, input_filename, output_filename) -> None:
""" Reformat the CICE history file to be read by SOCA/FMS
Expand All @@ -132,7 +127,6 @@ def _cice_hist2fms(self, input_filename, output_filename) -> None:
# Save the new netCDF file
ds.to_netcdf(output_filename, mode='w')


@logit(logger)
def initialize(self: Task) -> None:
"""Initialize a global B-matrix
Expand All @@ -150,7 +144,7 @@ def initialize(self: Task) -> None:

# stage fix files
logger.info(f"Staging SOCA fix files from {self.task_config.SOCA_INPUT_FIX_DIR}")
newdirs = [ os.path.join(self.task_config.DATA, 'INPUT') ]
newdirs = [os.path.join(self.task_config.DATA, 'INPUT')]
FileHandler({'mkdir': newdirs}).sync()
soca_fix_list = parse_j2yaml(self.task_config.SOCA_FIX_YAML_TMPL, self.task_config)
FileHandler(soca_fix_list).sync()
Expand Down Expand Up @@ -205,9 +199,8 @@ def initialize(self: Task) -> None:
data=self.task_config)
diffvz_config.save(os.path.join(self.task_config.DATA, 'soca_parameters_diffusion_vt.yaml'))


# generate the horizontal diffusion YAML files
if True: #task_config.COMPUTE_HORIZ_DIFF:
if True: # TODO(G): Missing logic to skip this section
# stage the correlation scale configuration
logger.debug("Generate correlation scale YAML file")
FileHandler({'copy': [[os.path.join(self.task_config.BERROR_YAML_DIR, 'soca_setcorscales.yaml'),
Expand All @@ -220,7 +213,9 @@ def initialize(self: Task) -> None:
diffhz_config.save(os.path.join(self.task_config.DATA, 'soca_parameters_diffusion_hz.yaml'))

# hybrid EnVAR case
if True: #self.task_config.DOHYBVAR:
if True:
# TODO(G): copy logic/steps from old script in the block below
# ensemble DA is temporarily off, check self.task_config.DOHYBVAR.
# stage ensemble membersfiles for use in hybrid background error
logger.debug("Stage ensemble files for DOHYBVAR {self.task_config.DOHYBVAR}")

Expand All @@ -238,10 +233,8 @@ def initialize(self: Task) -> None:
]
FileHandler({'mkdir': newdirs}).sync()


@logit(logger)
def gridgen(self: Task) -> None:

# link gdas_soca_gridgen.x
self._link_executable('gdas_soca_gridgen.x')
exec_cmd = Executable(self.task_config.APRUN_MARINEBMAT)
Expand All @@ -253,7 +246,6 @@ def gridgen(self: Task) -> None:

@logit(logger)
def variance_partitioning(self: Task) -> None:

# link the variance partitioning executable, gdas_soca_diagb.x
self._link_executable('gdas_soca_diagb.x')
exec_cmd = Executable(self.task_config.APRUN_MARINEBMAT)
Expand Down Expand Up @@ -307,7 +299,6 @@ def vertical_diffusion(self: Task) -> None:
# compute the coefficients of the diffusion operator
self._run(exec_cmd)


@logit(logger)
def ensemble_perturbations(self: Task) -> None:
"""Generate the 3D ensemble of perturbation for the 3DEnVAR
Expand Down

0 comments on commit 5438a47

Please sign in to comment.