Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/FMS
Submodule FMS updated from 32a792 to f97fba
2 changes: 1 addition & 1 deletion src/MOM6
Submodule MOM6 updated from 07a30e to e848ab
2 changes: 1 addition & 1 deletion src/SIS2
Submodule SIS2 updated from 65b1d2 to f4a50e
34 changes: 34 additions & 0 deletions tools/tests/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'):
"""
Expand Down
2 changes: 1 addition & 1 deletion tools/tests/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
95 changes: 95 additions & 0 deletions tools/tests/test_domain_transform.py
Original file line number Diff line number Diff line change
@@ -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