Skip to content
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added remapping for GEOS-IT restarts
- Added new res C1120
- NOTE: If running on SLES15 remap tests will not be zero diff for GOCART RST but are zero diff for all other
- Add support for v13 BCs
- Add support for v14 BCs

### Changed

Expand Down
4 changes: 2 additions & 2 deletions pre/remap_restart/remap_command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ def get_answers_from_command_line(cml):
init_merra2(answers)
elif cml.geosit:
init_geosit(answers)
else:
else:
answers["input:shared:bc_base"] = cml.in_bc_base
answers["input:shared:omodel"] = cml.ocnmdlin
answers["input:shared:bc_version"] = cml.bcvin
answers["input:surface:catch_model"]= cml.catch_model
answers["input:shared:stretch"] = cml.in_stretch
answers["input:shared:rst_dir"] = os.path.abspath(os.path.expanduser(cml.rst_dir))
fvcore_info(answers)
fvcore_info(answers)
ogrid = cml.oceanin
if ogrid == "CS":
ogrid = answers["input:shared:agrid"]
Expand Down
16 changes: 12 additions & 4 deletions pre/remap_restart/remap_lake_landice_saltwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,41 +138,49 @@ def remap(self):
zoom = config['input']['surface']['zoom']
if zoom is None :
zoom = get_zoom(config)

log_name = out_dir+'/remap_lake_landice_saltwater_log'
if os.path.exists(log_name):
os.remove(log_name)

if (saltwater_internal):
cmd = exe + out_til + ' ' + in_til + ' InData/'+ saltwater_internal + ' 0 ' + str(zoom)
self.run_and_log(cmd, log_name)

# split Saltwater Internal
# NOTE: split_saltwater==True means that the input restarts are already split.
# So we do not split them again.
if not config['output']['surface']['split_saltwater']:
if not config['input']['surface']['split_saltwater']:
print("\nSplitting Saltwater Internal...\n")
cmd = bindir+'/SaltIntSplitter.x ' + out_til + ' ' + 'OutData/' + saltwater_internal
# subprocess.call(shlex.split(cmd))
openwater = ''
seaice = ''
self.run_and_log(cmd, log_name)

# We can now *remove* the unsplit saltwater internal restart to avoid confusion
unsplit_file = 'OutData/' + saltwater_internal
if os.path.exists(unsplit_file):
print('\n Removing unsplit saltwater internal restart: ' + unsplit_file + '\n')
os.remove(unsplit_file)


if (saltwater_import):
cmd = exe + out_til + ' ' + in_til + ' InData/'+ saltwater_import + ' 0 ' + str(zoom)
self.run_and_log(cmd, log_name)

# split Saltwater Import
# NOTE: split_saltwater==True means that the input restarts are already split.
# So we do not split them again.
if not config['output']['surface']['split_saltwater']:
if not config['input']['surface']['split_saltwater']:
print("\nSplitting Saltwater Import...\n")
cmd = bindir+'/SaltIntSplitter.x ' + out_til + ' ' + 'OutData/' + saltwater_import
# subprocess.call(shlex.split(cmd))
openwater = ''
seaice = ''
self.run_and_log(cmd, log_name)


if (openwater):
cmd = exe + out_til + ' ' + in_til + ' InData/' + openwater + ' 0 ' + str(zoom)
self.run_and_log(cmd, log_name)
Expand Down
10 changes: 5 additions & 5 deletions pre/remap_restart/remap_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def ask_questions():
"name": "output:shared:bc_version",
"message": message_bc_ops_new,
"choices": choices_bc_ops,
"default": "v13",
"default": "v12",
"when": lambda x: x["input:shared:MERRA-2"] or x["input:shared:GEOS-IT"],
},

Expand All @@ -301,7 +301,7 @@ def ask_questions():
"name": "output:shared:bc_version",
"message": "Select BCs version for new restarts:\n",
"choices": choices_bc_ops,
"default": "v13",
"default": "v12",
"when": lambda x: not x["input:shared:MERRA-2"] and not x["input:shared:GEOS-IT"],
},

Expand All @@ -310,15 +310,15 @@ def ask_questions():
"name": "output:shared:bc_version",
"message": message_bc_other_new,
"choices": choices_bc_other,
"when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] not in ['v06','v11','v12','GM4'],
"when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] not in ['v06','v11','v12','v14','GM4'],
},

{
"type": "select",
"name": "output:shared:bc_version",
"message": "\nSelect BCs version for new restarts:\n",
"choices": choices_bc_other,
"when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] in ['v06','v11','v12','GM4'],
"when": lambda x: x["output:shared:bc_version"] == 'Other' and x["input:shared:bc_version"] in ['v06','v11','v12','v14','GM4'],
},

{
Expand Down Expand Up @@ -453,7 +453,7 @@ def ask_questions():
"name": "slurm_pbs:reservation",
"message": message_reservation,
"default": "",
},
},
{
"type": "text",
"name": "slurm_pbs:partition",
Expand Down
64 changes: 45 additions & 19 deletions pre/remap_restart/remap_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import shlex
import netCDF4 as nc
import linecache
import re

# shared global variables

Expand All @@ -29,11 +30,11 @@
# define "choices", "message" strings, and "validate" lists that are used multiple times
# (and related definitions, even if they are used just once).

choices_bc_ops = ['v13', 'NL3', 'ICA', 'Other']
choices_bc_ops = ['v12', 'NL3', 'ICA', 'Other']

choices_bc_other = ['v06','v11','v12','GM4']
choices_bc_other = ['v06','v11','v14','GM4']

choices_bc_cmd = ['NL3', 'ICA', 'GM4', 'v06', 'v11','v12', 'v13']
choices_bc_cmd = ['NL3', 'ICA', 'GM4', 'v06', 'v11','v12', 'v14']

choices_omodel = ['data', 'MOM5', 'MOM6']

Expand Down Expand Up @@ -79,7 +80,7 @@
message_bc_ops = f'''\n
BCs version | ADAS tags | GCM tags typically used with BCs version
-----------------|----------------------|-----------------------------------------
v13: v13 | future | 12.0 ... present
v12: v12 | future | 12.0 ... present
NL3: Icarus-NLv3 | 5_25_1 ... present | Icarus_NL, 10.19 ... 11.7
ICA: Icarus | 5_17_0 ... 5_24_0_p1 | Icarus, Jason ... 10.18
----------------------------------------------------------------------------------
Expand All @@ -88,11 +89,16 @@
message_bc_ops_in = ("Select boundary conditions (BCs) version of input restarts:\n" + message_bc_ops)
message_bc_ops_new = ("Select boundary conditions (BCs) version for new restarts:\n" + message_bc_ops)

# v12 used to be in the "other" section but is now the default, but we preserve this information
# in a comment since v14 will probably soon be the new default and we'll want to move v12 back to "other".
#v12: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2 + Argentina peatland fix \n

message_bc_other = f'''\n
v06: NL3 + JPL veg height + PEATMAP + MODIS snow alb
v11: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2
v12: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2 + Argentina peatland fix
GM4: Ganymed-4_0\n'''\

v06: NL3 + JPL veg height + PEATMAP + MODIS snow alb\n
v11: NL3 + JPL veg height + PEATMAP + MODIS snow alb v2\n
v14: v12 + Coupled MOM6/v2 ocean bathymetry (OM4) and v2 topography for atmosphere \n
GM4: Ganymed-4_0\n\n'''\

message_bc_other_in = ("Select BCs version of input restarts:\n" + message_bc_other)
message_bc_other_new = ("Select BCs version for new restarts:\n" + message_bc_other)
Expand Down Expand Up @@ -345,7 +351,7 @@ def show_wemin_default(x):
return True

def get_zoom(x):
# "zoom" approximates the (integer) number of grid cells per degree lat or lon (min=1, max=8);
# "zoom" approximates the (integer) number of grid cells per degree lat or lon (min=1, max=8);
# for EASEv2 grid and lat/lon grid, always use the default value of 8.
zoom_ = '8'
if x.get('input:shared:MERRA-2') or x.get('input:shared:GEOS-IT'):
Expand Down Expand Up @@ -581,9 +587,16 @@ def get_config_from_answers(answers, config_tpl = False):
if len(keys) == 3:
config[keys[0]][keys[1]][keys[2]] = value

bc_version = config['output']['shared'].get('bc_version')
# Do the inputs have a split saltwater?
input_bc_version = config['input']['shared'].get('bc_version')
config['input']['surface']['split_saltwater'] = True
if 'Ganymed' in input_bc_version or 'GM4' in input_bc_version:
config['input']['surface']['split_saltwater'] = False

# Do the outputs need a split saltwater?
output_bc_version = config['output']['shared'].get('bc_version')
config['output']['surface']['split_saltwater'] = True
if 'Ganymed' in bc_version :
if 'Ganymed' in output_bc_version or 'GM4' in output_bc_version:
config['output']['surface']['split_saltwater'] = False

return config
Expand Down Expand Up @@ -628,16 +641,29 @@ def get_default_bc_base():
return choices_bc_base[0]
return choices_bc_base[1]


def get_topodir(bc_base, bc_version, agrid=None, ogrid=None, omodel=None, stretch=None):
gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel,stretch=stretch)
agrid_name = gridStr.split('_')[0]
bc_topo = ''
if 'GM4' == bc_version:
bc_topo = bc_base + '/' + bc_version + '/TOPO/TOPO_' + agrid_name
else:
bc_topo = bc_base + '/' + bc_version + '/TOPO/TOPO_' + agrid_name + '/smoothed'
gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch)
agrid_name = gridStr.split('_')[0]

v = str(bc_version).strip().upper()

# GM4 stays on legacy tiles tree
if v.startswith('GM4'):
return os.path.join(str(bc_base), 'GM4', 'TOPO', f'TOPO_{agrid_name}')

# v2 from v14+, else v1
m = re.search(r'(\d+)', v)
ver_num = int(m.group(1)) if m else None
stream = 'v2' if (ver_num is not None and ver_num >= 14) else 'v1'

# Derive new topo base from bc_base; fallback to default if pattern not found
bc_base_str = str(bc_base or '')
topo_base = re.sub(r'/fvInput/ExtData/esm/tiles/?$', '/make_bcs_inputs/atmosphere', bc_base_str)
if topo_base == bc_base_str or not topo_base:
topo_base = '/discover/nobackup/projects/gmao/bcs_shared/make_bcs_inputs/atmosphere'

return bc_topo
return os.path.join(topo_base, 'TOPO', stream, agrid_name, 'smoothed')

def get_landdir(bc_base, bc_version, agrid=None, ogrid=None, omodel=None, stretch=None, grid=None):
gridStr = get_resolutions(agrid=agrid, ogrid=ogrid, omodel=omodel,stretch=stretch, grid=grid)
Expand Down