From 8b609d071fbe8505399960f2e93405ca9f182506 Mon Sep 17 00:00:00 2001 From: Alistair Adcroft Date: Mon, 25 Jul 2022 15:38:46 -0400 Subject: [PATCH] Facilitate multiple execs in .testing/Makefile Updates .testing/Makefile to allow for alternative executable names and multiple executables in one build directory. Until now, the .testing/Makefile assumes all executables are called "MOM6". With the introduction of makedep, executables are called by the name indicated by the Fortran program statement. Changes: - BUILDS used to be a list of directories under build/ . Now is a list of /. - UNIT_EXECS lists possible executables within build/unit . This list allows us to override targets at the command-line. - Replaces many $(foreach b,$(BUILDS), ...) constructs in favor of build/%/... rules. i.e. reduces use of $(BUILDS) in general - Corrected name of executable in build/unit Co-authored-by: Marshall Ward --- .github/workflows/coverage.yml | 5 +---- .testing/Makefile | 40 ++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index e285b18c72..358d48a7a7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -10,9 +10,6 @@ jobs: run: working-directory: .testing - #env: - # REQUIRE_COVERAGE_UPLOAD: true - steps: - uses: actions/checkout@v2 with: @@ -23,7 +20,7 @@ jobs: - uses: ./.github/actions/testing-setup - name: Compile unit testing - run: make -j build/unit/MOM6 + run: make -j build/unit/MOM_unit_tests - name: Run unit tests run: make run.cov.unit diff --git a/.testing/Makefile b/.testing/Makefile index 6879b04f84..150a365692 100644 --- a/.testing/Makefile +++ b/.testing/Makefile @@ -121,7 +121,7 @@ TIME ?= time # Experiment configuration -BUILDS ?= symmetric asymmetric openmp +BUILDS ?= symmetric/MOM6 asymmetric/MOM6 openmp/MOM6 CONFIGS ?= $(wildcard tc*) TESTS ?= grid layout rotate restart openmp nan $(foreach d,$(DIMS),dim.$(d)) DIMS ?= t l h z q r @@ -134,26 +134,29 @@ DIMS ?= t l h z q r # the DEBUG results in older GCCs and vendor compilers, so we can optionally # disable them. ifeq ($(DO_REPRO_TESTS), true) - BUILDS += repro + BUILDS += repro/MOM6 TESTS += repro endif # Profiling ifeq ($(DO_PROFILE), true) - BUILDS += opt opt_target + BUILDS += opt/MOM6 opt_target/MOM6 endif # Unit testing +UNIT_EXECS ?= MOM_unit_tests ifeq ($(DO_COVERAGE), true) - BUILDS += cov unit + BUILDS += cov/MOM6 $(foreach e, $(UNIT_EXECS), unit/$(e)) +endif + +ifeq ($(DO_PROFILE), false) + BUILDS += opt/MOM6 opt_target/MOM6 endif -CODECOV_UPLOADER_URL ?= https://uploader.codecov.io/latest/linux/codecov DO_REGRESSION_TESTS ?= - ifeq ($(DO_REGRESSION_TESTS), true) - BUILDS += target + BUILDS += target/MOM6 TESTS += regression MOM_TARGET_SLUG ?= NOAA-GFDL/MOM6 @@ -214,13 +217,12 @@ endif # Rules .PHONY: all build.regressions build.prof -all: $(foreach b,$(BUILDS),build/$(b)/MOM6) $(VENV_PATH) +all: $(foreach b,$(BUILDS),build/$(b)) $(VENV_PATH) build.regressions: $(foreach b,symmetric target,build/$(b)/MOM6) build.prof: $(foreach b,opt opt_target,build/$(b)/MOM6) # Executable -BUILD_TARGETS = MOM6 Makefile path_names -.PRECIOUS: $(foreach b,$(BUILDS),$(foreach f,$(BUILD_TARGETS),build/$(b)/$(f))) +.PRECIOUS: $(foreach b,$(BUILDS),build/$(b)) # Compiler flags @@ -283,18 +285,18 @@ build/opt_target/Makefile: | $(TARGET_CODEBASE) # 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. -$(foreach b,$(filter-out target,$(BUILDS)),build/$(b)/Makefile): $(MOM_SOURCE) build/target_codebase/configure: $(TARGET_SOURCE) -# Build MOM6 -.PRECIOUS: $(foreach b,$(BUILDS),build/$(b)/MOM6) -build/%/MOM6: build/%/Makefile +# 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 # Use autoconf to construct the Makefile for each target -.PRECIOUS: $(foreach b,$(BUILDS),build/$(b)/Makefile) +.PRECIOUS: build/%/Makefile build/%/Makefile: ../ac/configure ../ac/Makefile.in deps/lib/libFMS.a mkdir -p $(@D) cd $(@D) \ @@ -577,12 +579,12 @@ work/%/$(1)/ocean.stats work/%/$(1)/chksum_diag: build/$(2)/MOM6 $(VENV_PATH) cd build/$(2) ; \ gcov -b *.gcda > gcov.$$*.$(1).out ; \ find -name "*.gcov" -exec sed -i -r 's/^( *[0-9]*)\*:/ \1:/g' {} \; ; \ - curl -s $(CODECOV_UPLOADER_URL) -o codecov ; \ fi endef # Upload coverage reports +CODECOV_UPLOADER_URL ?= https://uploader.codecov.io/latest/linux/codecov codecov: curl -s $(CODECOV_UPLOADER_URL) -o $@ chmod +x codecov @@ -693,7 +695,7 @@ test.summary: #--- -# unit test +# Unit test # NOTE: Using file parser gcov report as a proxy for test completion .PHONY: run.cov.unit @@ -718,8 +720,8 @@ work/unit/std.out: build/unit/MOM_unit_tests cat p2.std.err | tail -n 100 ; \ ) -# Use driver coverage file as a proxy for the run # NOTE: .gcov actually depends on .gcda, but .gcda is produced with std.out +# TODO: Replace work/unit/std.out with *.gcda? build/unit/MOM_file_parser_tests.F90.gcov: work/unit/std.out cd $(@D) \ && gcov -b *.gcda > gcov.unit.out @@ -733,7 +735,7 @@ report.cov.unit: build/unit/MOM_file_parser_tests.F90.gcov codecov && echo -e "${MAGENTA}Report uploaded to codecov.${RESET}" \ || { \ echo -e "${RED}Failed to upload report.${RESET}" ; \ - if [ $(REQUIRE_COVERAGE_UPLOAD) = "true" ] ; then false ; fi ; \ + if [ "$(REQUIRE_COVERAGE_UPLOAD)" = true ] ; then false ; fi ; \ }