Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into user_module_units
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Nov 25, 2022
2 parents 524ab32 + 571ddd9 commit b8c044d
Show file tree
Hide file tree
Showing 40 changed files with 1,071 additions and 436 deletions.
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
14 changes: 7 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ p:merge:

# Setup the persistent JOB_DIR for all subsequent stages
#
# This basically setups up a complete tree much as a user would in their workflow
# This basically setups up a complete tree much as a user would in their workflow
p:clone:
stage: setup
tags:
Expand Down Expand Up @@ -181,11 +181,11 @@ actions:gnu:
- echo -e "\e[0Ksection_start:`date +%s`:compile[collapsed=true]\r\e[0KCompiling executables"
- cd .testing
- module unload PrgEnv-pgi PrgEnv-intel PrgEnv-gnu darshan ; module load PrgEnv-gnu ; module unload netcdf gcc ; module load gcc/7.3.0 cray-hdf5 cray-netcdf
- make work/local-env
- make -s -j
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
- (echo '#!/bin/bash';echo '. ./work/local-env/bin/activate';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c3,c4 --nodes=5 --time=0:05:00 --account=gfdl_o --qos=debug --job-name=MOM6.gnu.testing --output=log.$CI_JOB_ID --wait job.sh && make test || ( cat log.$CI_JOB_ID ; exit 911 )
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c3,c4 --nodes=5 --time=0:05:00 --account=gfdl_o --qos=debug --job-name=MOM6.gnu.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 )
- make test.summary

actions:intel:
stage: tests
Expand All @@ -200,11 +200,11 @@ actions:intel:
- echo -e "\e[0Ksection_start:`date +%s`:compile[collapsed=true]\r\e[0KCompiling executables"
- cd .testing
- module unload PrgEnv-pgi PrgEnv-intel PrgEnv-gnu darshan; module load PrgEnv-intel; module unload netcdf intel; module load intel/18.0.6.288 cray-hdf5 cray-netcdf
- make work/local-env
- make -s -j
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
- (echo '#!/bin/bash';echo '. ./work/local-env/bin/activate';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c3,c4 --nodes=5 --time=0:05:00 --account=gfdl_o --qos=debug --job-name=MOM6.intel.testing --output=log.$CI_JOB_ID --wait job.sh && make test || ( cat log.$CI_JOB_ID ; exit 911 )
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c3,c4 --nodes=5 --time=0:05:00 --account=gfdl_o --qos=debug --job-name=MOM6.intel.testing --output=log.$CI_JOB_ID --wait job.sh || ( cat log.$CI_JOB_ID ; exit 911 )
- make test.summary

# Tests
#
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) LAUNCHER="$(MPIRUN)"

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.

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

LAUNCHER ?=

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

# Since each program generates two outputs, we can only use one to track the
# creation. The second rule is used to indirectly re-invoke the first rule.
#
# Reference:
# https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html

# Program output
all: ocean_hgrid.nc temp_salt_ic.nc

ocean_hgrid.nc: gen_grid
$(LAUNCHER) ./gen_grid
topog.nc: ocean_hgrid.nc
@test -f $@ || rm -f $^
@test -f $@ || $(MAKE) $^

temp_salt_ic.nc: gen_data ocean_hgrid.nc
$(LAUNCHER) ./gen_data
sponge.nc: temp_salt_ic.nc
@test -f $@ || rm -f $^
@test -f $@ || $(MAKE) $^


# Programs

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

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


# Support

.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~
Loading

0 comments on commit b8c044d

Please sign in to comment.