Skip to content

Commit

Permalink
Merge remote-tracking branch 'gfdl/dev/gfdl' into iOM4_is_dev2
Browse files Browse the repository at this point in the history
  • Loading branch information
MJHarrison-GFDL committed Nov 13, 2023
2 parents b47de7f + cce4b3d commit 19bdbd1
Show file tree
Hide file tree
Showing 96 changed files with 8,149 additions and 4,050 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/coupled-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ jobs:
- name: Compile MOM6 for the NUOPC driver
shell: bash
run: make check_mom6_api_nuopc -j

- name: Compile MOM6 for the MCT driver
shell: bash
run: make check_mom6_api_mct -j
20 changes: 17 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,29 @@ jobs:

- uses: ./.github/actions/testing-setup

- name: Compile unit testing
run: make -j build/unit/MOM_unit_tests
- name: Compile file parser unit tests
run: make -j build/unit/test_MOM_file_parser

- name: Run unit tests
- name: Run file parser unit tests
run: make run.cov.unit

- name: Compile unit testing
run: make -j build.unit

- name: Run (single processor) unit tests
run: make run.unit

- name: Report unit test coverage to CI (PR)
if: github.event_name == 'pull_request'
run: make report.cov.unit REQUIRE_COVERAGE_UPLOAD=true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Report unit test coverage to CI (Push)
if: github.event_name != 'pull_request'
run: make report.cov.unit
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Compile ocean-only MOM6 with code coverage
run: make -j build/cov/MOM6
Expand All @@ -42,7 +52,11 @@ jobs:
- name: Report coverage to CI (PR)
if: github.event_name == 'pull_request'
run: make report.cov REQUIRE_COVERAGE_UPLOAD=true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

- name: Report coverage to CI (Push)
if: github.event_name != 'pull_request'
run: make report.cov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
17 changes: 16 additions & 1 deletion .github/workflows/perfmon.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Performance Monitor

on: [pull_request]
on: [push, pull_request]

jobs:
build-test-perfmon:
Expand All @@ -20,19 +20,34 @@ jobs:
- uses: ./.github/actions/testing-setup

- name: Compile optimized models
if: ${{ github.event_name == 'pull_request' }}
run: >-
make -j build.prof
MOM_TARGET_SLUG=$GITHUB_REPOSITORY
MOM_TARGET_LOCAL_BRANCH=$GITHUB_BASE_REF
DO_REGRESSION_TESTS=true
- name: Generate profile data
if: ${{ github.event_name == 'pull_request' }}
run: >-
pip install f90nml &&
make profile
DO_REGRESSION_TESTS=true
- name: Generate perf data
if: ${{ github.event_name == 'pull_request' }}
run: |
sudo sysctl -w kernel.perf_event_paranoid=2
make perf DO_REGRESSION_TESTS=true
- name: Compile timing tests
run: |
make -j build.timing
- name: Run timing tests
run: |
make -j run.timing
- name: Display timing results
run: |
make -j show.timing
11 changes: 9 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

# Extra formats
# PDF generation is failing for now; disabled on 2020-12-02
#formats:
Expand All @@ -10,7 +19,5 @@ sphinx:
configuration: docs/conf.py

python:
# make sure we're using Python 3
version: 3
install:
- requirements: docs/requirements.txt
142 changes: 87 additions & 55 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ MAKEFLAGS += -R
-include config.mk

# Set the infra framework
FRAMEWORK ?= fms1
FRAMEWORK ?= fms2

# Set the MPI launcher here
# TODO: This needs more automated configuration
Expand Down Expand Up @@ -116,6 +116,9 @@ DO_PROFILE ?=
# Enable code coverage runs
DO_COVERAGE ?=

# Enable code coverage runs
DO_UNIT_TESTS ?=

# Report failure if coverage report is not uploaded
REQUIRE_COVERAGE_UPLOAD ?=

Expand Down Expand Up @@ -151,10 +154,16 @@ ifeq ($(DO_PROFILE), true)
BUILDS += opt/MOM6 opt_target/MOM6
endif

# Unit testing
UNIT_EXECS ?= MOM_unit_tests
# Coverage
ifeq ($(DO_COVERAGE), true)
BUILDS += cov/MOM6 $(foreach e, $(UNIT_EXECS), unit/$(e))
BUILDS += cov/MOM6
endif

# Unit testing (or coverage)
UNIT_EXECS ?= $(basename $(notdir $(wildcard ../config_src/drivers/unit_tests/*.F90) ) )
TIMING_EXECS ?= $(basename $(notdir $(wildcard ../config_src/drivers/timing_tests/*.F90) ) )
ifneq (X$(DO_COVERAGE)$(DO_UNIT_TESTS)X, XX)
BUILDS += $(foreach e, $(UNIT_EXECS), unit/$(e))
endif

ifeq ($(DO_PROFILE), false)
Expand Down Expand Up @@ -245,60 +254,57 @@ COV_LDFLAGS := LDFLAGS="$(LDFLAGS_COVERAGE) $(LDFLAGS_DEPS) $(LDFLAGS_USER)"


# Environment variable configuration
build/symmetric/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/asymmetric/Makefile: MOM_ENV=$(PATH_FMS) $(ASYMMETRIC_FCFLAGS) $(MOM_LDFLAGS) \
MOM_ENV := $(PATH_FMS)
build/symmetric/Makefile: MOM_ENV += $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/asymmetric/Makefile: MOM_ENV += $(ASYMMETRIC_FCFLAGS) $(MOM_LDFLAGS) \
MOM_MEMORY=../../../config_src/memory/dynamic_nonsymmetric/MOM_memory.h
build/repro/Makefile: MOM_ENV=$(PATH_FMS) $(REPRO_FCFLAGS) $(MOM_LDFLAGS)
build/openmp/Makefile: MOM_ENV=$(PATH_FMS) $(OPENMP_FCFLAGS) $(MOM_LDFLAGS)
build/target/Makefile: MOM_ENV=$(PATH_FMS) $(TARGET_FCFLAGS) $(MOM_LDFLAGS)
build/opt/Makefile: MOM_ENV=$(PATH_FMS) $(OPT_FCFLAGS) $(MOM_LDFLAGS)
build/opt_target/Makefile: MOM_ENV=$(PATH_FMS) $(OPT_FCFLAGS) $(MOM_LDFLAGS)
build/coupled/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/nuopc/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/mct/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/cov/Makefile: MOM_ENV=$(PATH_FMS) $(COV_FCFLAGS) $(COV_LDFLAGS)
build/unit/Makefile: MOM_ENV=$(PATH_FMS) $(COV_FCFLAGS) $(COV_LDFLAGS)
build/repro/Makefile: MOM_ENV += $(REPRO_FCFLAGS) $(MOM_LDFLAGS)
build/openmp/Makefile: MOM_ENV += $(OPENMP_FCFLAGS) $(MOM_LDFLAGS)
build/target/Makefile: MOM_ENV += $(TARGET_FCFLAGS) $(MOM_LDFLAGS)
build/opt/Makefile: MOM_ENV += $(OPT_FCFLAGS) $(MOM_LDFLAGS)
build/opt_target/Makefile: MOM_ENV += $(OPT_FCFLAGS) $(MOM_LDFLAGS)
build/coupled/Makefile: MOM_ENV += $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/nuopc/Makefile: MOM_ENV += $(SYMMETRIC_FCFLAGS) $(MOM_LDFLAGS)
build/cov/Makefile: MOM_ENV += $(COV_FCFLAGS) $(COV_LDFLAGS)
build/unit/Makefile: MOM_ENV += $(COV_FCFLAGS) $(COV_LDFLAGS)
build/timing/Makefile: MOM_ENV += $(OPT_FCFLAGS) $(MOM_LDFLAGS)

# Configure script flags
build/symmetric/Makefile: MOM_ACFLAGS=
build/asymmetric/Makefile: MOM_ACFLAGS=
build/repro/Makefile: MOM_ACFLAGS=
build/openmp/Makefile: MOM_ACFLAGS=--enable-openmp
build/target/Makefile: MOM_ACFLAGS=
build/opt/Makefile: MOM_ACFLAGS=
build/opt_target/Makefile: MOM_ACFLAGS=
build/coupled/Makefile: MOM_ACFLAGS=--with-driver=FMS_cap
build/nuopc/Makefile: MOM_ACFLAGS=--with-driver=nuopc_cap
build/mct/Makefile: MOM_ACFLAGS=--with-driver=mct_cap
build/cov/Makefile: MOM_ACFLAGS=
build/unit/Makefile: MOM_ACFLAGS=--with-driver=unit_tests
MOM_ACFLAGS := --with-framework=$(FRAMEWORK)
build/openmp/Makefile: MOM_ACFLAGS += --enable-openmp
build/coupled/Makefile: MOM_ACFLAGS += --with-driver=FMS_cap
build/nuopc/Makefile: MOM_ACFLAGS += --with-driver=nuopc_cap
build/unit/Makefile: MOM_ACFLAGS += --with-driver=unit_tests
build/timing/Makefile: MOM_ACFLAGS += --with-driver=timing_tests

# Fetch regression target source code
build/target/Makefile: | $(TARGET_CODEBASE)
build/opt_target/Makefile: | $(TARGET_CODEBASE)


# Define source code dependencies
# NOTE: ./configure is too much, but Makefile is not enough!
# Ideally we only want to re-run both Makefile and mkmf, but the mkmf call
# is inside ./configure, so we must re-run ./configure as well.
build/target_codebase/configure: $(TARGET_SOURCE)


# Build executables
$(foreach e,$(UNIT_EXECS),build/unit/$(e)): build/unit/Makefile $(MOM_SOURCE)
cd $(@D) && $(TIME) $(MAKE) -j
build/%/MOM6: build/%/Makefile $(MOM_SOURCE)
cd $(@D) && $(TIME) $(MAKE) -j
build/unit/test_%: build/unit/Makefile FORCE
cd $(@D) && $(TIME) $(MAKE) $(@F) -j
build/unit/Makefile: $(foreach e,$(UNIT_EXECS),../config_src/drivers/unit_tests/$(e).F90)
build/timing/time_%: build/timing/Makefile FORCE
cd $(@D) && $(TIME) $(MAKE) $(@F) -j
build/timing/Makefile: $(foreach e,$(TIMING_EXECS),../config_src/drivers/timing_tests/$(e).F90)
build/%/MOM6: build/%/Makefile FORCE
cd $(@D) && $(TIME) $(MAKE) $(@F) -j
FORCE: ;


# Use autoconf to construct the Makefile for each target
.PRECIOUS: build/%/Makefile
build/%/Makefile: ../ac/configure ../ac/Makefile.in deps/lib/libFMS.a
mkdir -p $(@D)
cd $(@D) \
&& $(MOM_ENV) ../../../ac/configure $(MOM_ACFLAGS) --with-framework=$(FRAMEWORK) \
|| (cat config.log && false)
&& $(MOM_ENV) ../../../ac/configure $(MOM_ACFLAGS) \
|| (cat config.log && false)


../ac/configure: ../ac/configure.ac ../ac/m4
Expand All @@ -310,8 +316,8 @@ build/target/Makefile build/opt_target/Makefile: \
$(TARGET_CODEBASE)/ac/configure deps/lib/libFMS.a
mkdir -p $(@D)
cd $(@D) \
&& $(MOM_ENV) ../../$(TARGET_CODEBASE)/ac/configure $(MOM_ACFLAGS) \
|| (cat config.log && false)
&& $(MOM_ENV) ../../$(TARGET_CODEBASE)/ac/configure $(MOM_ACFLAGS) \
|| (cat config.log && false)


$(TARGET_CODEBASE)/ac/configure: $(TARGET_CODEBASE)
Expand Down Expand Up @@ -370,11 +376,6 @@ build/coupled/ocean_model_MOM.o: build/coupled/Makefile
cd $(@D) && make $(@F)
check_mom6_api_coupled: build/coupled/ocean_model_MOM.o

# MCT driver
build/mct/mom_ocean_model_mct.o: build/mct/Makefile
cd $(@D) && make $(@F)
check_mom6_api_mct: build/mct/mom_ocean_model_mct.o


#---
# Testing
Expand Down Expand Up @@ -571,13 +572,21 @@ endef

# Upload coverage reports
CODECOV_UPLOADER_URL ?= https://uploader.codecov.io/latest/linux/codecov
CODECOV_TOKEN ?=

ifdef CODECOV_TOKEN
CODECOV_TOKEN_ARG = -t $(CODECOV_TOKEN)
else
CODECOV_TOKEN_ARG =
endif

codecov:
curl -s $(CODECOV_UPLOADER_URL) -o $@
chmod +x codecov

.PHONY: report.cov
report.cov: run.cov codecov
./codecov -R build/cov -Z -f "*.gcov" \
./codecov $(CODECOV_TOKEN_ARG) -R build/cov -Z -f "*.gcov" \
> build/cov/codecov.out \
2> build/cov/codecov.err \
&& echo -e "${MAGENTA}Report uploaded to codecov.${RESET}" \
Expand Down Expand Up @@ -662,35 +671,54 @@ test.summary:
.PHONY: run.cov.unit
run.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov

$(WORKSPACE)/work/unit/std.out: build/unit/MOM_unit_tests
.PHONY: build.unit
build.unit: $(foreach f, $(UNIT_EXECS), build/unit/$(f))
.PHONY: run.unit
run.unit: $(foreach f, $(UNIT_EXECS), work/unit/$(f).out)
.PHONY: build.timing
build.timing: $(foreach f, $(TIMING_EXECS), build/timing/$(f))
.PHONY: run.timing
run.timing: $(foreach f, $(TIMING_EXECS), work/timing/$(f).out)
.PHONY: show.timing
show.timing: $(foreach f, $(TIMING_EXECS), work/timing/$(f).show)
$(WORKSPACE)/work/timing/%.show:
./tools/disp_timing.py $(@:.show=.out)

# General rule to run a unit test executable
# Pattern is to run build/unit/executable and direct output to executable.out
$(WORKSPACE)/work/unit/%.out: build/unit/%
@mkdir -p $(@D)
cd $(@D) ; $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> >(tee $*.err) > $*.out

$(WORKSPACE)/work/unit/test_MOM_file_parser.out: build/unit/test_MOM_file_parser
if [ $(REPORT_COVERAGE) ]; then \
find build/unit -name *.gcda -exec rm -f '{}' \; ; \
fi
rm -rf $(@D)
mkdir -p $(@D)
cd $(@D) \
&& $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> std.err > std.out \
&& rm -f input.nml logfile.0000*.out *_input MOM_parameter_doc.* \
&& $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> test_MOM_file_parser.err > test_MOM_file_parser.out \
|| !( \
cat std.out | tail -n 100 ; \
cat std.err | tail -n 100 ; \
cat test_MOM_file_parser.out | tail -n 100 ; \
cat test_MOM_file_parser.err | tail -n 100 ; \
)
cd $(@D) \
&& $(TIME) $(MPIRUN) -n 2 $(abspath $<) 2> p2.std.err > p2.std.out \
&& $(TIME) $(MPIRUN) -n 2 $(abspath $<) 2> p2.test_MOM_file_parser.err > p2.test_MOM_file_parser.out \
|| !( \
cat p2.std.out | tail -n 100 ; \
cat p2.std.err | tail -n 100 ; \
cat p2.test_MOM_file_parser.out | tail -n 100 ; \
cat p2.test_MOM_file_parser.err | tail -n 100 ; \
)

# NOTE: .gcov actually depends on .gcda, but .gcda is produced with std.out
# TODO: Replace $(WORKSPACE)/work/unit/std.out with *.gcda?
build/unit/MOM_file_parser_tests.F90.gcov: $(WORKSPACE)/work/unit/std.out
build/unit/MOM_file_parser_tests.F90.gcov: $(WORKSPACE)/work/unit/test_MOM_file_parser.out
cd $(@D) \
&& gcov -b *.gcda > gcov.unit.out
find $(@D) -name "*.gcov" -exec sed -i -r 's/^( *[0-9]*)\*:/ \1:/g' {} \;

.PHONY: report.cov.unit
report.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov codecov
./codecov -R build/unit -f "*.gcov" -Z -n "Unit tests" \
./codecov $(CODECOV_TOKEN_ARG) -R build/unit -f "*.gcov" -Z -n "Unit tests" \
> build/unit/codecov.out \
2> build/unit/codecov.err \
&& echo -e "${MAGENTA}Report uploaded to codecov.${RESET}" \
Expand All @@ -700,6 +728,10 @@ report.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov codecov
if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \
}

$(WORKSPACE)/work/timing/%.out: build/timing/% FORCE
@mkdir -p $(@D)
@echo Running $< in $(@D)
@cd $(@D) ; $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> $*.err > $*.out

#---
# Profiling based on FMS clocks
Expand Down
11 changes: 11 additions & 0 deletions .testing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ Usage
``make clean``
Delete the MOM6 test executables and dependency builds (FMS).

``make -j build.unit``
Build the unit test programs in config_src/drivers/unit_tests

``make -j run.unit``
Run the unit test programs from config_src/drivers/unit_tests in $(WORKSPACE)/work/unit

``make -j build.timing``
Build the timing test programs in config_src/drivers/timing_tests

``make -j run.timing``
Run the timing test programs from config_src/drivers/timing_tests in $(WORKSPACE)/work/timing

Configuration
=============
Expand Down
Loading

0 comments on commit 19bdbd1

Please sign in to comment.