diff --git a/.gitmodules b/.gitmodules index f64487ad56..6ad405b403 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,12 @@ [submodule "src/FMS"] path = src/FMS - url = https://github.com/NOAA-GFDL/FMS.git + url = https://github.com/nicjhan/FMS.git [submodule "src/MOM6"] path = src/MOM6 - url = https://github.com/NOAA-GFDL/MOM6.git + url = git@github.com:nicjhan/MOM6.git [submodule "src/SIS2"] path = src/SIS2 - url = https://github.com/NOAA-GFDL/SIS2.git + url = https://github.com/nicjhan/SIS2.git [submodule "tools/matlab/gtools"] path = tools/matlab/gtools url = https://github.com/Adcroft/gtools.git @@ -27,7 +27,7 @@ url = https://github.com/NOAA-GFDL/land_null.git [submodule "src/mkmf"] path = src/mkmf - url = https://github.com/NOAA-GFDL/mkmf.git + url = https://github.com/NOAA-GFDL/mkmf.git [submodule "tools/analysis/mpl-cmocean"] path = tools/analysis/mpl-cmocean url = https://github.com/matplotlib/cmocean.git diff --git a/src/FMS b/src/FMS index 32a792370d..f97fba758f 160000 --- a/src/FMS +++ b/src/FMS @@ -1 +1 @@ -Subproject commit 32a792370d1ee4254b3cf6ab93c769076c5c447c +Subproject commit f97fba758f656871193e9ca33891f45c536a7e6c diff --git a/src/MOM6 b/src/MOM6 index 07a30e642d..e848ab7ca5 160000 --- a/src/MOM6 +++ b/src/MOM6 @@ -1 +1 @@ -Subproject commit 07a30e642d05b020cdad92c811a89edf13d5a9d6 +Subproject commit e848ab7ca5e668d04610f08a10bbdd02485af95d diff --git a/src/SIS2 b/src/SIS2 index 65b1d23f2f..f4a50ec67e 160000 --- a/src/SIS2 +++ b/src/SIS2 @@ -1 +1 @@ -Subproject commit 65b1d23f2f3e3a25f1e8665a36b970ea84e726ea +Subproject commit f4a50ec67e5f065e7ff488640b1bd3ab92cf98a6 diff --git a/tools/tests/experiment.py b/tools/tests/experiment.py index 5cb5c21794..456742027e 100644 --- a/tools/tests/experiment.py +++ b/tools/tests/experiment.py @@ -8,6 +8,7 @@ import random import subprocess as sp import run_config as rc +import fileinput from model import Model # Only support Python version >= 2.7 @@ -237,6 +238,39 @@ def get_unfinished_diags(self): """ return self.unfinished_diags + def set_mom_input_option(self, option, value): + """ + Set an option in the MOM_input file. + """ + + fname = os.path.join(self.path, 'MOM_input') + self.set_input_option(fname, option, value) + + def set_sis_input_option(self, option, value): + """ + Set an option in the SIS_input file. + """ + + fname = os.path.join(self.path, 'SIS_input') + self.set_input_option(fname, option, value) + + def set_input_option(self, fname, option, value): + + found = False + optstr = option + ' = ' + value + '\n' + + with fileinput.FileInput(fname, inplace=True) as f: + for line in f: + if line.startswith(option): + print(optstr, end='') + found = True + else: + print(line, end='') + + if not found: + with open(fname, 'a') as f: + f.write(optstr) + def create_experiments(platform='raijin'): """ diff --git a/tools/tests/model.py b/tools/tests/model.py index caaa28f105..4fc4430b7d 100644 --- a/tools/tests/model.py +++ b/tools/tests/model.py @@ -21,7 +21,7 @@ _build_ocean_ice_script = """ pwd && -../../../../../mkmf/bin/list_paths ./ ../../../../../src/MOM6/config_src/{{{memory_type},coupled_driver}} ../../../../../src/MOM6/src/{{*,*/*}}/ ../../../../../src/{{atmos_null,coupler,land_null,SIS2,ice_ocean_extras,icebergs,FMS/coupler,FMS/include}} && +../../../../../mkmf/bin/list_paths ./ ../../../../../src/MOM6/config_src/{{{memory_type},coupled_driver}} ../../../../../src/MOM6/src/{{*,*/*}}/ ../../../../../src/SIS2/config_src/{memory_type} ../../../../../src/SIS2/src ../../../../../src/{{atmos_null,coupler,land_null,ice_ocean_extras,icebergs,FMS/coupler,FMS/include}} && ../../../../../mkmf/bin/mkmf -t ../../../../../mkmf/templates/{platform}-{compiler}.mk -o '-I../../../shared/{build}' -p 'MOM6 -L../../../shared/{build} -lfms' -c '-Duse_libMPI -Duse_netCDF -DSPMD -DUSE_LOG_DIAG_FIELD_INFO -Duse_AM3_physics -D_USE_LEGACY_LAND_' path_names && source ../../../../../mkmf/env/{platform}-{compiler}.env && make NETCDF=3 {build}=1 MOM6 -j """ diff --git a/tools/tests/test_domain_transform.py b/tools/tests/test_domain_transform.py new file mode 100644 index 0000000000..0a4a12dcaa --- /dev/null +++ b/tools/tests/test_domain_transform.py @@ -0,0 +1,95 @@ + +from __future__ import print_function + +import pytest +import os +import f90nml +from experiment import Experiment + +def modify_input_nml(exp, set_ensemble_size=True, set_short_runtime=False): + + if set_ensemble_size or set_short_runtime: + nml = f90nml.read(os.path.join(exp.path, 'input.nml')) + if set_ensemble_size: + nml['ensemble_nml'] = f90nml.namelist.Namelist() + nml['ensemble_nml']['ensemble_size'] = 2 + if set_short_runtime: + nml['coupler_nml']['days'] = 1 + + f90nml.write(nml, os.path.join(exp.path, 'input.nml'), force=True) + + +class TestDomainTransform: + """ + This test runs two test MOM6/SIS2 cases side-by-side. These cases are the + same except that one of them has it's domain transformed. The + transformation can be either a transpose or a rotation. As they run the + side-by-side test cases compare key fields. If these fields differ in any + way then the test fails. + + The test catches a large class of indexing errors, as well any differences + in code between the i and j directions. + """ + + def test_baltic_transpose(self): + """ + Test that the Baltic tests case gives identical results with a + transposed domain. + """ + + exp = Experiment('ice_ocean_SIS2/Baltic') + + # Setup MOM_input for the test. + exp.set_mom_input_option('DEBUG', 'True') + exp.set_mom_input_option('TRANSFORM_TEST', 'TRANSPOSE') + exp.set_mom_input_option('DIFFUSE_ML_TO_INTERIOR', 'False') + exp.set_mom_input_option('RESTORE_SALINITY', 'False') + + exp.set_sis_input_option('DEBUG', 'True') + exp.set_sis_input_option('TRANSFORM_TEST', 'TRANSPOSE') + + modify_input_nml(exp, set_short_runtime=True) + + # FIXME: empty the diag_table. + + # Run test. + ret = exp.force_run() + assert ret == 0 + + + @pytest.mark.skip + def test_baltic_rotate90(self): + pass + + @pytest.mark.skip + def test_baltic_rotate180(self): + pass + + def test_double_gyre_transpose(self): + """ + Test that the double gyre case gives identical results with a + transposed domain. + """ + + exp = Experiment('ocean_only/double_gyre') + + # Setup MOM_input for the test. + exp.set_mom_input_option('DEBUG', 'True') + exp.set_mom_input_option('TRANSFORM_TEST', 'TRANSPOSE') + exp.set_mom_input_option('DAYMAX', '1.0') + + modify_input_nml(exp) + + # Run test. + ret = exp.force_run() + assert ret == 0 + + + @pytest.mark.skip + def test_double_gyre_rotate90(self): + pass + + @pytest.mark.skip + def test_double_gyre_rotate180(self): + pass +