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

Fix issue with topo linking, pass in stretched grid options #14

Merged
merged 12 commits into from
May 17, 2023
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Deprecated

## [1.2.0] - 2023-04-25

### Fixed

- Fixed issue with `remap_upper.py` where nc4 files were being linked instead of binary files which FV routines require

### Changed

- Moved to pass in stretched grid factors to `interp_restarts.x` rather than using a namelist file

## [1.1.1] - 2023-03-29

### Fixed
Expand Down
1 change: 1 addition & 0 deletions pre/remap_restart/remap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def get_grid_kind(this, grid):
hgrd['C720'] = 'e'
hgrd['C1080'] = 'e'
hgrd['C1440'] = 'e'
hgrd['C1536'] = 'e'
hgrd['C2160'] = 'e'
hgrd['C2880'] = 'e'
hgrd['C5760'] = 'e'
Expand Down
4 changes: 2 additions & 2 deletions pre/remap_restart/remap_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def ask_questions():
{
"type": "text",
"name": "input:shared:agrid",
"message": "Enter input atmospheric grid: \n C12 C180 C1000 C270\n C24 C360 C1440 C540\n C48 C500 C2880 C1080\n C90 C720 C5760 C2160\n ",
"message": "Enter input atmospheric grid: \n C12 C180 C1000 C270\n C24 C360 C1440 C540\n C48 C500 C2880 C1080\n C90 C720 C5760 C2160 C1536\n ",
"default": 'C360',
# if it is merra-2 or has_fvcore, agrid is deduced
"when": lambda x: not x['input:shared:MERRA-2'] and not fvcore_name(x),
Expand All @@ -121,7 +121,7 @@ def ask_questions():
{
"type": "text",
"name": "output:shared:agrid",
"message": "Enter new atmospheric grid: \n C12 C180 C1000 C270\n C24 C360 C1440 C540\n C48 C500 C2880 C1080\n C90 C720 C5760 C2160\n ",
"message": "Enter new atmospheric grid: \n C12 C180 C1000 C270\n C24 C360 C1440 C540\n C48 C500 C2880 C1080\n C90 C720 C5760 C2160 C1536\n ",
"default": 'C360',
},

Expand Down
43 changes: 25 additions & 18 deletions pre/remap_restart/remap_upper.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ def remap(self):
subprocess.call(shlex.split(cmd))

# link topo file
topoin = glob.glob(in_bcsdir+'/topo_DYN_ave*')[0]
topoin = glob.glob(in_bcsdir+'/topo_DYN_ave*.data')[0]
cmd = '/bin/ln -s ' + topoin + ' .'
print('\n'+cmd)
subprocess.call(shlex.split(cmd))

topoout = glob.glob(out_bcsdir+'/topo_DYN_ave*')[0]
topoout = glob.glob(out_bcsdir+'/topo_DYN_ave*.data')[0]
cmd = '/bin/ln -s ' + topoout + ' topo_dynave.data'
print('\n'+cmd)
subprocess.call(shlex.split(cmd))
Expand Down Expand Up @@ -124,10 +124,28 @@ def remap(self):

# We need to create an input.nml file which is different if we are running stretched grid
# First, let's define a boolean for whether we are running stretched grid
# If we are running with imout of 270, 540, 1080, or 2160, then we are running stretched grid
stretched_grid = False
# If we are running with imout of 270, 540, 1080, 1536 or 2160, then we are running stretched grid
if imout in [270, 540, 1080, 2160]:
stretched_grid = True
target_lat = 39.5
target_lon = -98.35
stretch_fac = 2.5
elif imout in [1536]:
stretched_grid = True
target_lat = 39.5
target_lon = -98.35
stretch_fac = 3.0
else:
stretched_grid = False

# If we are running stretched grid, we need to pass in the target lat, lon, and stretch factor
# to interp_restarts.x. Per the code we use:
# -stretched_grid target_lon target_lat stretch_fac
# If we are not running stretched grid, we should pass in a blank string
if stretched_grid:
stretch_str = "-stretched_grid " + str(target_lon) + " " + str(target_lat) + " " + str(stretch_fac)
else:
stretch_str = ""

# Now, let's create the input.nml file
# We need to create a namelist for the upper air remapping
Expand All @@ -138,18 +156,6 @@ def remap(self):
domains_stack_size = 24000000
/
"""

# If we are running stretched grid, we need to add an &fv_core_nml namelist as well
if stretched_grid:
nml_file += """
&fv_core_nml
do_schmidt = .true.
stretch_fac = 2.5
target_lat = 39.5
target_lon = -98.35
/
"""

# Now, let's write the input.nml file
with open('input.nml', 'w') as f:
f.write(nml_file)
Expand Down Expand Up @@ -214,7 +220,7 @@ def remap(self):
endif

{Bin}/esma_mpirun -np {NPE} $interp_restartsX -im {imout} -lm {nlevel} \\
-do_hydro {hydrostatic} $ioflag $dmflag -nwriter {nwrit}
-do_hydro {hydrostatic} $ioflag $dmflag -nwriter {nwrit} {stretch_str}

"""
account = config['slurm']['account']
Expand All @@ -225,7 +231,8 @@ def remap(self):
remap_upper_script = remap_template.format(Bin=bindir, account = account, \
out_dir = out_dir, log_name = log_name, drymassFLG = drymassFLG, \
imout = imout, nwrit = nwrit, NPE = NPE, \
QOS = QOS,CONSTR = CONSTR, nlevel = nlevel, hydrostatic = hydrostatic)
QOS = QOS,CONSTR = CONSTR, nlevel = nlevel, hydrostatic = hydrostatic,
stretch_str = stretch_str)

script_name = './remap_upper.j'

Expand Down