-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #267 from GEOS-ESM/feature/wjiang/add_tests
Create test suite for remap_restarts.py
- Loading branch information
Showing
7 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,3 +168,5 @@ install(PROGRAMS | |
${CMAKE_CURRENT_BINARY_DIR}/3CH.j | ||
DESTINATION post | ||
) | ||
|
||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
file(GLOB test_scripts CONFIGURE_DEPENDS ./*.py ./*.yaml) | ||
install( | ||
PROGRAMS ${test_scripts} | ||
DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# | ||
# This template file can be filled with questionary or manually | ||
# | ||
# | ||
|
||
input: | ||
air: | ||
drymass: 1 | ||
hydrostatic: 0 | ||
shared: | ||
MERRA-2: false | ||
agrid: C24 | ||
bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus-NLv3/Icarus-NLv3_Reynolds//CF0024x6C_DE0360xPE0180/ | ||
expid: '' | ||
ogrid: 360X180 | ||
rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c24Toc12/inputs | ||
yyyymmddhh: '2000041421' | ||
surface: | ||
zoom: '1' | ||
wemin: '13' | ||
# it supports three models: catch, catchcnclm40, catchcnclm45 | ||
catch_model: catch | ||
|
||
output: | ||
shared: | ||
agrid: C12 | ||
bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus-NLv3/Icarus-NLv3_Reynolds//CF0012x6C_DE0360xPE0180/ | ||
expid: hello | ||
ogrid: 360X180 | ||
out_dir: $NOBACKUP/REMAP_TESTS/c24Toc12/ | ||
air: | ||
remap: true | ||
nlevel: '72' | ||
surface: | ||
split_saltwater: true | ||
surflay: 50.0 | ||
wemin: '13' | ||
remap_water: true | ||
remap_catch: true | ||
analysis: | ||
bkg: false | ||
aqua: true | ||
lcv: false | ||
|
||
slurm: | ||
account: g0610 | ||
qos: debug | ||
constraint: hasw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# | ||
# This template file can be filled with questionary or manually | ||
# | ||
# | ||
|
||
input: | ||
air: | ||
drymass: 1 | ||
hydrostatic: 0 | ||
shared: | ||
MERRA-2: false | ||
agrid: C720 | ||
bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus_Updated/Icarus_Ostia//CF0720x6C_CF0720x6C/ | ||
expid: f522_fp | ||
ogrid: C720 | ||
rst_dir: /discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/f522Toc360/inputs/ | ||
yyyymmddhh: '2019061421' | ||
surface: | ||
zoom: '8' | ||
wemin: '26' | ||
catch_model: catch | ||
|
||
output: | ||
shared: | ||
agrid: C360 | ||
bcs_dir: /discover/nobackup/projects/gmao/share/gmao_ops/fvInput/g5gcm/bcs/Icarus-NLv3/Icarus-NLv3_Reynolds//CF0360x6C_DE0360xPE0180/ | ||
expid: remap | ||
ogrid: 360X180 | ||
out_dir: $NOBACKUP/REMAP_TESTS/f522Toc360/ | ||
air: | ||
nlevel: '72' | ||
remap: true | ||
surface: | ||
split_saltwater: true | ||
surflay: 50.0 | ||
wemin: '13' | ||
remap_catch: true | ||
remap_water: true | ||
analysis: | ||
bkg: true | ||
aqua: true | ||
lcv: true | ||
|
||
slurm: | ||
account: g0610 | ||
qos: debug | ||
constraint: hasw |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
c24Toc12: | ||
base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/c24Toc12/baseline/' | ||
config: 'c24Toc12.yaml' | ||
f522Toc360: | ||
base_line: '/discover/nobackup/projects/gmao/SIteam/Remapping_Test_Cases/f522Toc360/baseline/' | ||
config: 'f522Toc360.yaml' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# source install/bin/g5_modules | ||
# | ||
# Newer GEOS code should load a module with GEOSpyD Python3 if not run: | ||
# module load python/GEOSpyD/Min4.10.3_py3.9 | ||
# | ||
|
||
import sys, getopt | ||
import ruamel.yaml | ||
import questionary | ||
import glob | ||
import subprocess as sp | ||
import remap_restarts | ||
from remap_questions import get_config_from_questionary | ||
from remap_params import * | ||
from remap_upper import * | ||
from remap_lake_landice_saltwater import * | ||
from remap_analysis import * | ||
from remap_catchANDcn import * | ||
|
||
def compare(base, result): | ||
#1) comparing nc4 | ||
bases = glob.glob(base + '/*_rst*.nc4*') | ||
results = glob.glob( result + '/*_rst*.nc4*') | ||
if (len(bases) != len(results)) : | ||
print(len(bases), len(results)) | ||
print (" number of restart out should be the same") | ||
return False | ||
bases.sort() | ||
results.sort() | ||
for b, r in zip(bases, results): | ||
cmd = 'nccmp -dmgfs '+ b + ' ' + r | ||
print(cmd) | ||
p = sp.Popen(shlex.split(cmd), stdout=subprocess.PIPE) | ||
(out, err) = p.communicate() | ||
rc = p.wait() | ||
out = out.decode().split() | ||
if "identical." in out : | ||
print('identical') | ||
else: | ||
print ( f + ' is different from ' + r) | ||
return False | ||
return True | ||
|
||
def test_remap(config): | ||
|
||
upper = upperair(config_obj=config) | ||
upper.remap() | ||
lls = lake_landice_saltwater(config_obj=config) | ||
lls.remap() | ||
catch = catchANDcn(config_obj=config) | ||
catch.remap() | ||
ana = analysis(config_obj=config) | ||
ana.remap() | ||
|
||
|
||
if __name__ == '__main__' : | ||
|
||
yaml = ruamel.yaml.YAML() | ||
stream ='' | ||
cases_yaml = 'test_remap_cases.yaml' | ||
with open(cases_yaml, 'r') as f: | ||
stream = f.read() | ||
cases = yaml.load(stream) | ||
|
||
cmd = 'whoami' | ||
p = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) | ||
(user, err) = p.communicate() | ||
p_status = p.wait() | ||
user = user.decode().split()[0] | ||
|
||
for case, values in cases.items(): | ||
base_line = values['base_line'] | ||
config_yaml_file = values['config'] | ||
|
||
stream ='' | ||
with open(config_yaml_file, 'r') as f: | ||
stream = f.read() | ||
config = yaml.load(stream) | ||
|
||
out_dir = '/discover/nobackup/'+user+'/REMAP_TESTS/'+case+'/' | ||
config['output']['shared']['out_dir'] = out_dir | ||
|
||
test_remap(config) | ||
|
||
rc = compare(base_line, out_dir) | ||
if (not rc) : | ||
print ("failed in " + case) | ||
else : | ||
print (case +" test is successful") | ||
|