Skip to content

Commit c770b9d

Browse files
authored
Merge branch 'main' into bugfix/movestat-fix
2 parents 9377ddd + 69cba9c commit c770b9d

File tree

5 files changed

+63
-54
lines changed

5 files changed

+63
-54
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
- Remapping seaicetherom_import_rst and saltwater_import_rst if they are in the restart directory
15+
1416
### Fixed
1517

1618
- Fixed issue with `movestat` which only allowed single-month seasons
1719

1820
### Removed
1921

22+
- Removed detection of OS at NCCS as it is all SLES15 now
23+
2024
### Deprecated
2125

2226
## [2.1.6] - 2025-01-23

pre/remap_restart/remap_catchANDcn.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def remap(self):
4444
in_rstfiles = glob.glob(rst_dir+'/*'+model+'_*')
4545
if len(in_rstfiles) == 0:
4646
return
47-
in_rstfile = in_rstfiles[0]
48-
47+
in_rstfile = in_rstfiles[0]
48+
4949

5050
cwdir = os.getcwd()
5151
bindir = os.path.dirname(os.path.realpath(__file__))
@@ -60,8 +60,8 @@ def remap(self):
6060
surflay = config['output']['surface']['surflay']
6161
in_tilefile = config['input']['surface']['catch_tilefile']
6262

63-
if "gmao_SIteam/ModelData" in out_bc_base:
64-
assert GEOS_SITE == "NAS", "wrong site to run the package"
63+
if "gmao_SIteam/ModelData" in out_bc_base:
64+
assert GEOS_SITE == "NAS", "wrong site to run the package"
6565

6666
if not in_tilefile :
6767
agrid = config['input']['shared']['agrid']
@@ -86,7 +86,7 @@ def remap(self):
8686

8787
out_bc_landdir = get_landdir(out_bc_base, out_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch, grid=EASE_grid)
8888

89-
label = get_label(config)
89+
label = get_label(config)
9090

9191
suffix = time+'z.nc4' + label
9292

@@ -100,22 +100,22 @@ def remap(self):
100100

101101
print("\nRemapping " + model + ".....\n")
102102
# determine NPE based on *approximate* number of input and output tile
103-
103+
104104
in_Ntile = 0
105105
mime = mimetypes.guess_type(in_rstfile)
106106
if mime[0] and 'stream' in mime[0]: # binary
107107
in_Ntile = 1684725 # if it is binary, it is safe to assume the maximum is M09
108108
else : # nc4 file
109109
ds = nc.Dataset(in_rstfile)
110110
in_Ntile = ds.dimensions['tile'].size
111-
111+
112112
out_Ntile = 0
113113
with open( out_bc_landdir+'/clsm/catchment.def') as f:
114114
out_Ntile = int(next(f))
115115
max_Ntile = max(in_Ntile, out_Ntile)
116116
NPE = 0
117117
if (max_Ntile <= 112573) : # no more than EASEv2_M36
118-
NPE = 40
118+
NPE = 40
119119
elif (max_Ntile <= 1684725) : # no more than EASEv2_M09
120120
NPE = 80
121121
elif (max_Ntile <= 2496756) : # no more than C720
@@ -140,9 +140,7 @@ def remap(self):
140140
if (partition != ''):
141141
PARTITION = "#SBATCH --partition=" + partition
142142

143-
CONSTRAINT = '"[cas|sky]"'
144-
if BUILT_ON_SLES15:
145-
CONSTRAINT = 'mil'
143+
CONSTRAINT = '"[cas|mil]"'
146144

147145
account = config['slurm_pbs']['account']
148146
# even if the (MERRA-2) input restarts are binary, the output restarts will always be nc4 (remap_bin2nc.py)
@@ -156,7 +154,7 @@ def remap(self):
156154
InData_dir = out_dir+'/InData/'
157155
print ("mkdir -p " + InData_dir)
158156
os.makedirs(InData_dir, exist_ok = True)
159-
157+
160158
f = os.path.basename(in_rstfile)
161159
dest = InData_dir+'/'+f
162160
# file got copy because the computing node cannot access archive
@@ -176,8 +174,8 @@ def remap(self):
176174
177175
set params = ( -model {model} -time {time} -in_tilefile {in_tilefile} )
178176
set params = ( $params -out_bcs {out_bcs} -out_tilefile {out_tilefile} -out_dir {out_dir} )
179-
set params = ( $params -surflay {surflay} -in_wemin {in_wemin} -out_wemin {out_wemin} )
180-
set params = ( $params -in_rst {in_rstfile} -out_rst {out_rstfile} )
177+
set params = ( $params -surflay {surflay} -in_wemin {in_wemin} -out_wemin {out_wemin} )
178+
set params = ( $params -in_rst {in_rstfile} -out_rst {out_rstfile} )
181179
$esma_mpirun_X $mk_catchANDcnRestarts_X $params
182180
183181
"""
@@ -256,7 +254,7 @@ def ask_catch_questions():
256254
catch_input_shared_rst_dir = ''
257255
def has_rs_rc_out(path):
258256
if os.path.exists(path):
259-
dirs = os.listdir(path)
257+
dirs = os.listdir(path)
260258
if 'rs' in dirs and 'rc_out' in dirs:
261259
nonlocal catch_input_shared_rst_dir
262260
catch_input_shared_rst_dir = path
@@ -273,7 +271,7 @@ def has_catch_rst(text):
273271
rst_dir = catch_input_shared_rst_dir + '/rs/ens0000/Y'+yyyy +'/M'+mm+'/'
274272
rst_files = glob.glob(rst_dir+'*catch*_internal_rst.'+yyyy+mm+dd+'_'+hh+'00')
275273
if len(rst_files) !=1 :
276-
return False
274+
return False
277275
return True
278276

279277
questions =[
@@ -290,19 +288,19 @@ def has_catch_rst(text):
290288
"message": (message_datetime + " and rst file must exist.)\n"),
291289
"validate": lambda text: has_catch_rst(text)
292290
},
293-
291+
294292
{
295293
"type": "path",
296294
"name": "output:shared:out_dir",
297-
"message": message_out_dir,
295+
"message": message_out_dir,
298296
},
299297

300298
{
301299
"type": "text",
302300
"name": "output:shared:expid",
303301
"message": message_expid,
304302
"default": "",
305-
},
303+
},
306304

307305
{
308306
"type": "select",
@@ -319,15 +317,15 @@ def has_catch_rst(text):
319317
"choices": choices_bc_ops,
320318
"default": "NL3",
321319
},
322-
{
320+
{
323321
"type": "select",
324322
"name": "output:shared:bc_version",
325323
"message": message_bc_other_new,
326324
"choices": choices_bc_other,
327325
"when": lambda x: x["output:shared:bc_version"] == 'Other',
328326
},
329327

330-
{
328+
{
331329
"type": "select",
332330
"name": "output:surface:EASE_grid",
333331
"message": "Select grid for new restart:\n",
@@ -380,29 +378,29 @@ def has_catch_rst(text):
380378
"name": "slurm_pbs:partition",
381379
"message": message_partition,
382380
"default": '',
383-
},
381+
},
384382

385383
]
386384

387-
answers = questionary.prompt(questions)
385+
answers = questionary.prompt(questions)
388386
yyyy = answers['input:shared:yyyymmddhh'][0:4]
389387
mm = answers['input:shared:yyyymmddhh'][4:6]
390388
dd = answers['input:shared:yyyymmddhh'][6:8]
391389
hh = answers['input:shared:yyyymmddhh'][8:10]
392-
390+
393391
rst_dir = answers['input:shared:rst_dir']+'/rs/ens0000/Y'+yyyy +'/M'+mm+'/'
394392
rst_file = glob.glob(rst_dir+'*catch*_internal_rst.'+yyyy+mm+dd+'_'+hh+'00')[0]
395393
idx1 = rst_file.find('catch')
396394
idx2 = rst_file.find('_internal_rst')
397395
catch_model = rst_file[idx1:idx2]
398-
396+
399397
tile_dir = answers['input:shared:rst_dir']+'/rc_out/'
400398
in_tilefiles = glob.glob(tile_dir+'*.til')
401399
for file in in_tilefiles:
402400
answers['input:surface:catch_tilefile'] = file
403401
if 'MAPL_' in file:
404402
answers['input:surface:catch_tilefile'] = file
405-
403+
406404
answers['input:shared:rst_dir'] = rst_dir
407405
answers['input:surface:catch_model'] = catch_model
408406
answers['input:surface:wemin'] = "13"

pre/remap_restart/remap_lake_landice_saltwater.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,10 @@ def remap(self):
9696
os.makedirs(OutData_dir)
9797

9898

99-
saltwater = ''
100-
seaice = ''
99+
saltwater_internal = ''
100+
saltwater_import = ''
101+
seaicethermo_internal = ''
102+
seaicethermo_import = ''
101103
landice = ''
102104
lake = ''
103105
route = ''
@@ -108,12 +110,14 @@ def remap(self):
108110
if os.path.exists(dest) : shutil.remove(dest)
109111
print('\nCopy ' + rst + ' to ' +dest)
110112
shutil.copy(rst,dest)
111-
if 'saltwater' in f : saltwater = f
112-
if 'seaice' in f : seaice = f
113-
if 'landice' in f : landice = f
114-
if 'lake' in f : lake = f
115-
if 'roue' in f : route = f
116-
if 'openwater' in f : openwater = f
113+
if 'saltwater_internal' in f : saltwater_internal = f
114+
if 'saltwater_import' in f : saltwater_import = f
115+
if 'seaicethermo_internal' in f : seaicethermo_internal = f
116+
if 'seaicethermo_import' in f : seaicethermo_import = f
117+
if 'landice' in f : landice = f
118+
if 'lake' in f : lake = f
119+
if 'roue' in f : route = f
120+
if 'openwater' in f : openwater = f
117121

118122
in_til = InData_dir+'/' + os.path.basename(in_tile_file)
119123
out_til = OutData_dir+'/'+ os.path.basename(out_tile_file)
@@ -131,8 +135,8 @@ def remap(self):
131135
if os.path.exists(log_name):
132136
os.remove(log_name)
133137

134-
if (saltwater):
135-
cmd = exe + out_til + ' ' + in_til + ' InData/'+ saltwater + ' 0 ' + str(zoom)
138+
if (saltwater_internal):
139+
cmd = exe + out_til + ' ' + in_til + ' InData/'+ saltwater_internal + ' 0 ' + str(zoom)
136140
self.run_and_log(cmd, log_name)
137141

138142
# split Saltwater
@@ -144,12 +148,21 @@ def remap(self):
144148
seaice = ''
145149
self.run_and_log(cmd, log_name)
146150

151+
if (saltwater_import):
152+
cmd = exe + out_til + ' ' + in_til + ' InData/'+ saltwater_import + ' 0 ' + str(zoom)
153+
self.run_and_log(cmd, log_name)
154+
147155
if (openwater):
148156
cmd = exe + out_til + ' ' + in_til + ' InData/' + openwater + ' 0 ' + str(zoom)
149157
self.run_and_log(cmd, log_name)
150158

151-
if (seaice):
152-
cmd = exe + out_til + ' ' + in_til + ' InData/' + seaice + ' 0 ' + str(zoom)
159+
if (seaicethermo_internal):
160+
cmd = exe + out_til + ' ' + in_til + ' InData/' + seaicethermo_internal + ' 0 ' + str(zoom)
161+
print('\n'+cmd)
162+
self.run_and_log(cmd, log_name)
163+
164+
if (seaicethermo_import):
165+
cmd = exe + out_til + ' ' + in_til + ' InData/' + seaicethermo_import + ' 0 ' + str(zoom)
153166
print('\n'+cmd)
154167
self.run_and_log(cmd, log_name)
155168

@@ -197,7 +210,9 @@ def find_rst(self):
197210
"landice_internal_rst" ,
198211
"openwater_internal_rst" ,
199212
"saltwater_internal_rst" ,
200-
"seaicethermo_internal_rst"]
213+
"saltwater_import_rst" ,
214+
"seaicethermo_internal_rst",
215+
"seaicethermo_import_rst"]
201216

202217
rst_dir = self.config['input']['shared']['rst_dir']
203218
yyyymmddhh_ = str(self.config['input']['shared']['yyyymmddhh'])

pre/remap_restart/remap_upper.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def remap(self):
7878
label = get_label(config)
7979
suffix = yyyymmddhh_[0:8]+'_'+yyyymmddhh_[8:10] +'z' + types + label
8080

81-
in_bc_base = config['input']['shared']['bc_base']
81+
in_bc_base = config['input']['shared']['bc_base']
8282
if "gmao_SIteam/ModelData" in in_bc_base:
83-
assert GEOS_SITE == "NAS", "wrong site to run the package"
83+
assert GEOS_SITE == "NAS", "wrong site to run the package"
8484

8585
in_bc_version = config['input']['shared']['bc_version']
8686
agrid = config['input']['shared']['agrid']
@@ -90,7 +90,7 @@ def remap(self):
9090
topo_bcsdir = get_topodir(in_bc_base, in_bc_version, agrid=agrid, ogrid=ogrid, omodel=omodel, stretch=stretch)
9191
topoin = glob.glob(topo_bcsdir+'/topo_DYN_ave*.data')[0]
9292

93-
out_bc_base = config['output']['shared']['bc_base']
93+
out_bc_base = config['output']['shared']['bc_base']
9494
out_bc_version = config['output']['shared']['bc_version']
9595
agrid = config['output']['shared']['agrid']
9696
ogrid = config['output']['shared']['ogrid']
@@ -125,7 +125,7 @@ def remap(self):
125125
cmd = '/bin/ln -s ' + rst + ' ' + f
126126
print('\n'+cmd)
127127
subprocess.call(shlex.split(cmd))
128-
128+
129129
# link topo file
130130

131131
cmd = '/bin/ln -s ' + topoin + ' .'
@@ -162,7 +162,7 @@ def remap(self):
162162
PARTITION =''
163163
QOS = config['slurm_pbs']['qos']
164164
TIME = "1:00:00"
165-
if NPE > 532:
165+
if NPE > 532:
166166
assert config['slurm_pbs']['qos'] != 'debug', "qos should be 'allnccs' for NCCS or 'normal' for NAS"
167167
TIME = "12:00:00"
168168
NNODE = ''
@@ -177,9 +177,7 @@ def remap(self):
177177
if (partition != ''):
178178
PARTITION = "#SBATCH --partition=" + partition
179179

180-
CONSTRAINT = '"[cas|sky]"'
181-
if BUILT_ON_SLES15:
182-
CONSTRAINT = 'mil'
180+
CONSTRAINT = '"[cas|mil]"'
183181

184182
# We need to create an input.nml file which is different if we are running stretched grid
185183
# If we are running stretched grid, we need to pass in the target lon+lat and stretch factor
@@ -200,7 +198,7 @@ def remap(self):
200198
else:
201199
exit("This stretched grid option is not supported " + str(stretch))
202200

203-
# note "reversed" order of args (relative to order in definition of STRETCH_GRID)
201+
# note "reversed" order of args (relative to order in definition of STRETCH_GRID)
204202

205203
stretch_str = "-stretched_grid " + str(target_lon) + " " + str(target_lat) + " " + str(stretch_fac)
206204

pre/remap_restart/remap_utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,8 @@
1717

1818
#During cmake step, the string will be changed according to the system
1919

20-
BUILT_ON_SLES15 = "@BUILT_ON_SLES15@"
2120
GEOS_SITE = "@GEOS_SITE@"
2221

23-
if BUILT_ON_SLES15 == "TRUE":
24-
BUILT_ON_SLES15 = True
25-
else:
26-
BUILT_ON_SLES15 = False
27-
2822
# top-level directory for BCs (machine-dependent)
2923

3024
choices_bc_base =[ "NCCS/Discover : /discover/nobackup/projects/gmao/bcs_shared/fvInput/ExtData/esm/tiles",

0 commit comments

Comments
 (0)