Skip to content

Commit

Permalink
Merge pull request #340 from bitterbark/mdtf_weblink
Browse files Browse the repository at this point in the history
fix MDTF implementation
  • Loading branch information
justin-richling authored Nov 11, 2024
2 parents 904028e + c85e002 commit 7365311
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config_amwg_default_plots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ diag_mdtf_info:
# Intermediate/output file settings
make_variab_tar: false # tar up MDTF results
save_ps : false # save postscript figures in addition to bitmaps
save_nc : true # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results saved under a unique name
save_nc : false # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results will be saved under a unique name

# Settings used in debugging:
verbose : 3 # Log verbosity level.
Expand Down
4 changes: 2 additions & 2 deletions config_cam_baseline_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@ diag_mdtf_info:
# Intermediate/output file settings
make_variab_tar: false # tar up MDTF results
save_ps : false # save postscript figures in addition to bitmaps
save_nc : true # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results saved under a unique name
save_nc : false # save netCDF files of processed data (recommend true when starting with new model data)
overwrite: true # overwrite results in OUTPUT_DIR; otherwise results will be saved under a unique name

# Settings used in debugging:
verbose : 3 # Log verbosity level.
Expand Down
5 changes: 4 additions & 1 deletion lib/adf_diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,7 @@ def setup_run_mdtf(self):
"""
Create MDTF directory tree, generate input settings jsonc file
Submit MDTF diagnostics.
Returns mdtf_proc for sub-process control (waits for it to finish in run_adf_diag)
"""

Expand Down Expand Up @@ -1343,19 +1344,21 @@ def setup_run_mdtf(self):
if copy_files_only:
print("\t ...Copy files only. NOT Running MDTF")
print(f"\t Command: {mdtf_exe} Log: {mdtf_log}")
return 0
else:
print(
f"\t ...Running MDTF in background. Command: {mdtf_exe} Log: {mdtf_log}"
)
print(f"Running MDTF in background. Command: {mdtf_exe} Log: {mdtf_log}")
with open(mdtf_log, "w", encoding="utf-8") as subout:
_ = subprocess.Popen(
mdtf_proc_var = subprocess.Popen(
[mdtf_exe],
shell=True,
stdout=subout,
stderr=subout,
close_fds=True,
)
return mdtf_proc_var

def move_tsfiles_for_mdtf(self, verbose):
"""
Expand Down
9 changes: 8 additions & 1 deletion run_adf_diag
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ if __name__ == "__main__":

#Call the MDTF:
if diag.get_mdtf_info('mdtf_run'):
diag.setup_run_mdtf()
mdtf_proc = diag.setup_run_mdtf() #returns mdtf_proc for subprocess control

#Create model climatology (climo) files.
#This call uses the "time_averaging_scripts" specified
Expand Down Expand Up @@ -193,6 +193,13 @@ if __name__ == "__main__":
if diag.create_html:
diag.create_website()

# Check if sub-processes are still running (CVDP, MDTF)
mdtf_status = mdtf_proc.wait(timeout=None)
if (mdtf_status != 0):
print(f"ERROR: MDTF finished with code {mdtf_status}")
else:
print("MDTF finished successfully")

#+++++++++++++++
#End diag script
#+++++++++++++++
Expand Down

0 comments on commit 7365311

Please sign in to comment.