Skip to content

Commit

Permalink
Update run-allsky-example.py
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPincus committed Jun 28, 2023
1 parent 039f6c8 commit 905a1fe
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions examples/all-sky/run-allsky-example.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,34 @@

# In the local directory
all_sky_exe_name = os.path.join(all_sky_dir, "rrtmgp_allsky")
input_file = os.path.join(os.environ["RRTMGP_DATA"], "examples", "all-sky", "inputs", "garand-atmos-1.nc")
atmos_file = os.path.join(all_sky_dir, "rrtmgp-allsky.nc")

if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Runs all-sky examples, resetting output.")
parser.add_argument("--run_command", type=str, default="",
help="Prefix ('jsrun' etc.) for running commands. "
"Use quote marks to enclose multi-part commands.")
parser.add_argument("--ncol", type=int, default=128,
help="Number of cloudy columns to compute "
parser.add_argument("--ncol", type=int, default=24,
help="Number of columns to compute")
parser.add_argument("--nlay", type=int, default=72,
help="Number of layers "
"(every one will have the same clouds)")
parser.add_argument("--nloops", type=int, default=1,
help="Number of times to compute 'nloops' "
"cloudy columns")

args = parser.parse_args()
ncol_str = '{0:5d}'.format(args.ncol)
ncol_str = '{0:5d}'.format(args.ncol)
nlay_str = '{0:5d}'.format(args.nlay)
nloops_str = '{0:5d}'.format(args.nloops)
if args.run_command:
print("using the run command")
all_sky_exe_name = args.run_command + " " + all_sky_exe_name

os.chdir(all_sky_dir)
# Remove cloudy-sky fluxes from the file containing the atmospheric profiles
shutil.copyfile(input_file, atmos_file)
subprocess.run(
[all_sky_exe_name, atmos_file, lw_gas_coeffs_file, lw_clouds_coeff_file,
ncol_str, nloops_str])
[all_sky_exe_name, ncol_str, nlay_str, nloops_str, "rrtmgp-allsky-lw-no-aerosols.nc", lw_gas_coeffs_file, lw_clouds_coeff_file])
subprocess.run(
[all_sky_exe_name, atmos_file, sw_gas_coeffs_file, sw_clouds_coeff_file,
ncol_str, nloops_str])
[all_sky_exe_name, ncol_str, nlay_str, nloops_str, "rrtmgp-allsky-sw-no-aerosols.nc", sw_gas_coeffs_file, sw_clouds_coeff_file])

# end main

0 comments on commit 905a1fe

Please sign in to comment.