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

.testing: Use Fortran to generate tc inputs #250

Merged
Merged
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
12 changes: 0 additions & 12 deletions .github/actions/testing-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ inputs:
description: 'If true, will build the symmetric MOM6 executable'
required: false
default: 'true'
install_python:
description: 'If true, will install the local python env needed for .testing'
required: false
default: 'true'
runs:
using: 'composite'
steps:
Expand Down Expand Up @@ -54,14 +50,6 @@ runs:
test ${{ inputs.build_symmetric }} == true && make build/symmetric/MOM6 -j
echo "::endgroup::"

- name: Install local python venv for generating input data
shell: bash
run: |
echo "::group::Create local python env for input data generation"
cd .testing
test ${{ inputs.install_python }} == true && make work/local-env
echo "::endgroup::"

- name: Set flags
shell: bash
run: |
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/coupled-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- uses: ./.github/actions/testing-setup
with:
build_symmetric: 'false'
install_python: 'false'

- name: Compile MOM6 for the GFDL coupled driver
shell: bash
Expand Down
91 changes: 30 additions & 61 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Delete the MOM6 test executables and dependency builds (FMS)
#
# make clean.build
# Delete only the MOM6 test executables
# Delete only the MOM6 test executables
#
#
# Configuration:
Expand Down Expand Up @@ -204,34 +204,11 @@ endif
FMS_SOURCE = $(call SOURCE,deps/fms/src)


#---
# Python preprocessing environment configuration

HAS_NUMPY = $(shell python -c "import numpy" 2> /dev/null && echo "yes")
HAS_NETCDF4 = $(shell python -c "import netCDF4" 2> /dev/null && echo "yes")

USE_VENV =
ifneq ($(HAS_NUMPY), yes)
USE_VENV = yes
endif
ifneq ($(HAS_NETCDF4), yes)
USE_VENV = yes
endif

# When disabled, activation is a null operation (`true`)
VENV_PATH =
VENV_ACTIVATE = true
ifeq ($(USE_VENV), yes)
VENV_PATH = work/local-env
VENV_ACTIVATE = . $(VENV_PATH)/bin/activate
endif


#---
# Rules

.PHONY: all build.regressions build.prof
all: $(foreach b,$(BUILDS),build/$(b)) $(VENV_PATH)
all: $(foreach b,$(BUILDS),build/$(b))
build.regressions: $(foreach b,symmetric target,build/$(b)/MOM6)
build.prof: $(foreach b,opt opt_target,build/$(b)/MOM6)

Expand Down Expand Up @@ -382,8 +359,8 @@ deps/Makefile: ../ac/deps/Makefile
# broken the ability to compile. This is not a means to build a complete
# coupled executable.
# TODO:
# - Avoid re-building FMS and MOM6 src by re-using existing object/mod files
# - Use autoconf rather than mkmf templates
# - Avoid re-building FMS and MOM6 src by re-using existing object/mod files
# - Use autoconf rather than mkmf templates
MK_TEMPLATE ?= ../../deps/mkmf/templates/ncrc-gnu.mk

# NUOPC driver
Expand All @@ -402,21 +379,6 @@ build/mct/mom_ocean_model_mct.o: build/mct/Makefile
check_mom6_api_mct: build/mct/mom_ocean_model_mct.o


#---
# Python preprocessing

# NOTE: Some less mature environments (e.g. Arm64 Ubuntu) require explicit
# installation of numpy before netCDF4, as well as wheel and cython support.
work/local-env:
python3 -m venv $@
. $@/bin/activate \
&& python3 -m pip install --upgrade pip \
&& pip3 install wheel \
&& pip3 install cython \
&& pip3 install numpy \
&& pip3 install netCDF4


#---
# Testing

Expand Down Expand Up @@ -555,6 +517,20 @@ $(foreach c,$(CONFIGS),$(eval $(call CONFIG_DIM_RULE,$(c))))
@echo -e "$(PASS): Diagnostics $*.regression.diag agree."


#---
# Preprocessing
# NOTE: This only support tc4, but can be generalized over all tests.
.PHONY: preproc
preproc: tc4/Makefile
cd tc4 && make

tc4/Makefile: tc4/configure tc4/Makefile.in
cd $(@D) && ./configure || (cat config.log && false)

tc4/configure: tc4/configure.ac
cd $(@D) && autoreconf -if


#---
# Test run output files

Expand All @@ -567,17 +543,10 @@ $(foreach c,$(CONFIGS),$(eval $(call CONFIG_DIM_RULE,$(c))))
# $(6): Number of MPI ranks

define STAT_RULE
work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6 $(VENV_PATH)
work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6 | preproc
@echo "Running test $$*.$(1)..."
mkdir -p $$(@D)
cp -RL $$*/* $$(@D)
if [ -f $$(@D)/Makefile ]; then \
$$(VENV_ACTIVATE) \
&& cd $$(@D) \
&& $(MAKE); \
else \
cd $$(@D); \
fi
mkdir -p $$(@D)/RESTART
echo -e "$(4)" > $$(@D)/MOM_override
rm -f results/$$*/std.$(1).{out,err}
Expand Down Expand Up @@ -615,7 +584,7 @@ report.cov: run.cov codecov
|| { \
cat build/cov/codecov.err ; \
echo -e "${RED}Failed to upload report.${RESET}" ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
}

# Define $(,) as comma escape character
Expand Down Expand Up @@ -643,17 +612,10 @@ $(eval $(call STAT_RULE,cov,cov,true,,,1))
# 2. Convert DAYMAX from TIMEUNIT to seconds
# 3. Apply seconds to `ocean_solo_nml` inside input.nml.
# NOTE: Assumes that runtime set by DAYMAX, will fail if set by input.nml
work/%/restart/ocean.stats: build/symmetric/MOM6 $(VENV_PATH)
work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
rm -rf $(@D)
mkdir -p $(@D)
cp -RL $*/* $(@D)
if [ -f $(@D)/Makefile ]; then \
$(VENV_ACTIVATE) \
&& cd work/$*/restart \
&& $(MAKE); \
else \
cd work/$*/restart; \
fi
mkdir -p $(@D)/RESTART
# Set the half-period
cd $(@D) \
Expand Down Expand Up @@ -754,7 +716,7 @@ report.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov codecov
|| { \
cat build/unit/codecov.err ; \
echo -e "${RED}Failed to upload report.${RESET}" ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
}


Expand Down Expand Up @@ -833,6 +795,13 @@ clean.build:


.PHONY: clean.stats
clean.stats:
clean.stats: clean.preproc
@[ $$(basename $$(pwd)) = .testing ]
rm -rf work results


.PHONY: clean.preproc
clean.preproc:
@if [ -f tc4/Makefile ] ; then \
cd tc4 && make clean ; \
fi
13 changes: 12 additions & 1 deletion .testing/tc4/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Autoconf
aclocal.m4
autom4te.cache/
config.log
config.status
configure~

# Output
gen_grid
ocean_hgrid.nc
topog.nc

gen_data
sponge.nc
temp_salt_ic.nc
topog.nc
8 changes: 0 additions & 8 deletions .testing/tc4/Makefile

This file was deleted.

38 changes: 38 additions & 0 deletions .testing/tc4/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FC = @FC@
LD = @LD@
FCFLAGS = @FCFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@

OUT = topog.nc ocean_hgrid.nc temp_salt_ic.nc sponge.nc

all: $(OUT)

ocean_hgrid.nc topog.nc: gen_grid
./gen_grid

temp_salt_ic.nc sponge.nc: gen_data
./gen_data

gen_grid: gen_grid.F90
$(FC) $(FCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

gen_data: gen_data.F90
$(FC) $(FCFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)

.PHONY: clean
clean:
rm -rf $(OUT) gen_grid gen_data

.PHONY: distclean
distclean: clean
rm -f config.log
rm -f config.status
rm -f Makefile

.PHONY: ac-clean
ac-clean: distclean
rm -f aclocal.m4
rm -rf autom4te.cache
rm -f configure
rm -f configure~
80 changes: 0 additions & 80 deletions .testing/tc4/build_data.py

This file was deleted.

Loading