Skip to content

Commit

Permalink
Merge branch 'dev/gfdl' into refactor_PressureForce
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallward authored Jun 7, 2024
2 parents 299eab4 + 09774d4 commit 66f329d
Show file tree
Hide file tree
Showing 84 changed files with 2,827 additions and 1,474 deletions.
1 change: 1 addition & 0 deletions .github/workflows/macos-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
env:
CC: gcc
FC: gfortran
FMS_COMMIT: 2019.01.03

defaults:
run:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos-stencil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
env:
CC: gcc
FC: gfortran
FMS_COMMIT: 2019.01.03

defaults:
run:
Expand Down
3 changes: 3 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ p:clone:
tags:
- ncrc5
script:
# NOTE: We could sweep any builds older than 3 days here if needed
#- find $HOME/ci/[0-9]* -mtime +3 -delete 2> /dev/null || true
- .gitlab/pipeline-ci-tool.sh create-job-dir
#.gitlab/pipeline-ci-tool.sh clean-job-dir

Expand Down Expand Up @@ -353,4 +355,5 @@ cleanup:
before_script:
- echo Skipping usual preamble
script:
- rm -rf $HOME/ci/$CI_PIPELINE_ID
- rm -rf $JOB_DIR
7 changes: 7 additions & 0 deletions .gitlab/pipeline-ci-tool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ create-job-dir () {
make -f tools/MRS/Makefile.clone clone_gfdl -j # Extras and link to datasets
bash tools/MRS/generate_manifest.sh . tools/MRS/excluded-expts.txt > manifest.mk
mkdir -p results
# Temporarily move build directory to $HOME to circumvent poor F5 performance
mkdir -p $HOME/ci/$CI_PIPELINE_ID/build
ln -s $HOME/ci/$CI_PIPELINE_ID/build build
# Builds need non-mangled access to src/.
ln -s "$(pwd)"/src $HOME/ci/$CI_PIPELINE_ID/src
# Static builds need access to ocean_only/
ln -s "$(pwd)"/ocean_only $HOME/ci/$CI_PIPELINE_ID/ocean_only
fi
section-end create-job-dir
}
Expand Down
69 changes: 17 additions & 52 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#
# General test configuration:
# MPIRUN MPI job launcher (mpirun, srun, etc)
# FRAMEWORK Model framework (fms1 or fms2)
# DO_REPRO_TESTS Enable production ("repro") testing equivalence
# DO_REGRESSION_TESTS Enable regression tests (usually dev/gfdl)
# DO_COVERAGE Enable code coverage and generate .gcov reports
Expand Down Expand Up @@ -74,8 +73,11 @@ AC_SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))../ac
# User-defined configuration
-include config.mk

# Set the infra framework
FRAMEWORK ?= fms2
# Set the FMS library
FMS_COMMIT ?= 2023.03
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
export FMS_COMMIT
export FMS_URL

# Set the MPI launcher here
# TODO: This needs more automated configuration
Expand Down Expand Up @@ -133,9 +135,6 @@ TIME ?= time
WORKSPACE ?= .

# Set directories for build/ and work/
#BUILD ?= $(WORKSPACE)build
#DEPS ?= $(BUILD)/deps
#WORK ?= $(WORKSPACE)work
BUILD ?= $(WORKSPACE)/build
DEPS ?= $(BUILD)/deps
WORK ?= $(WORKSPACE)/work
Expand Down Expand Up @@ -207,34 +206,6 @@ else
endif


# List of source files to link this Makefile's dependencies to model Makefiles
# Assumes a depth of two, and the following extensions: F90 inc c h
# (1): Root directory
# NOTE: extensions could be a second variable
SOURCE = \
$(foreach ext,F90 inc c h,$(wildcard $(1)/*/*.$(ext) $(1)/*/*/*.$(ext)))

MOM_SOURCE = \
$(call SOURCE,../src) \
$(wildcard ../config_src/drivers/solo_driver/*.F90) \
$(wildcard ../config_src/ext*/*/*.F90)

TARGET_SOURCE = \
$(call SOURCE,$(BUILD)/target_codebase/src) \
$(wildcard $(BUILD)/target_codebase/config_src/drivers/solo_driver/*.F90) \
$(wildcard $(BUILD)target_codebase/config_src/ext*/*.F90)

ifeq ($(FRAMEWORK), fms1)
MOM_SOURCE += $(wildcard ../config_src/infra/FMS1/*.F90)
TARGET_SOURCE += $(wildcard $(BUILD)/target_codebase/config_src/infra/FMS1/*.F90)
else
MOM_SOURCE +=$(wildcard ../config_src/infra/FMS2/*.F90)
TARGET_SOURCE += $(wildcard $(BUILD)/target_codebase/config_src/infra/FMS2/*.F90)
endif

FMS_SOURCE = $(call SOURCE,$(DEPS)/fms/src)


## Rules

.PHONY: all build.regressions build.prof
Expand Down Expand Up @@ -286,7 +257,6 @@ $(BUILD)/unit/Makefile: MOM_ENV += $(COV_FCFLAGS) $(COV_LDFLAGS)
$(BUILD)/timing/Makefile: MOM_ENV += $(OPT_FCFLAGS) $(MOM_LDFLAGS)

# Configure script flags
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
Expand All @@ -298,11 +268,21 @@ $(BUILD)/timing/Makefile: MOM_ACFLAGS += --with-driver=timing_tests
$(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

# Target codebase should use its own build system
$(BUILD)/target/MOM6: $(BUILD)/target FORCE | $(TARGET_CODEBASE)
$(MAKE) -C $(TARGET_CODEBASE)/.testing build/symmetric/MOM6

$(BUILD)/target: | $(TARGET_CODEBASE)
ln -s $(abspath $(TARGET_CODEBASE))/.testing/build/symmetric $@

FORCE:


Expand Down Expand Up @@ -334,27 +314,12 @@ $(BUILD)/%/configure.ac: ../ac/configure.ac | $(BUILD)/%/
$(BUILD)/%/m4/: ../ac/m4/ | $(BUILD)/%/
cp -r ../ac/m4 $(@D)

ALL_EXECS = symmetric asymmetric repro openmp target opt opt_target coupled \
nuopc cov unit timing
ALL_EXECS = symmetric asymmetric repro openmp opt opt_target coupled nuopc \
cov unit timing
$(foreach b,$(ALL_EXECS),$(BUILD)/$(b)/):
mkdir -p $@

# Fetch the regression target codebase

$(BUILD)/target/config.status: $(BUILD)/target/configure $(DEPS)/lib/libFMS.a
cd $(@D) && $(MOM_ENV) ./configure -n \
--srcdir=$(abspath $(BUILD))/target_codebase/ac $(MOM_ACFLAGS) \
|| (cat config.log && false)

$(BUILD)/target/Makefile.in: | $(TARGET_CODEBASE) $(BUILD)/target/
cp $(TARGET_CODEBASE)/ac/Makefile.in $(@D)

$(BUILD)/target/configure.ac: | $(TARGET_CODEBASE) $(BUILD)/target/
cp $(TARGET_CODEBASE)/ac/configure.ac $(@D)

$(BUILD)/target/m4/: | $(TARGET_CODEBASE) $(BUILD)/target/
cp -r $(TARGET_CODEBASE)/ac/m4 $(@D)

$(TARGET_CODEBASE):
git clone --recursive $(MOM_TARGET_URL) $@
cd $@ && git checkout --recurse-submodules $(MOM_TARGET_BRANCH)
Expand Down
8 changes: 5 additions & 3 deletions .testing/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ Several of the following may require configuration for particular systems.
Name of the MPI launcher. Often this is ``mpirun`` or ``mpiexec`` but may
all need to run through a scheduler, e.g. ``srun`` if using Slurm.

``FRAMEWORK`` (*default:* ``fms1``)
Select either the legacy FMS framework (``fms1``) or an FMS2 I/O compatible
version (``fms2``).
``FMS_COMMIT`` (*default:* ``2023.03``)
Set the FMS version, either by tag or commit (as defined in ``FMS_URL``).

``FMS_URL`` (*default*: ``https://github.com/NOAA-GFDL/FMS.git``)
Set the URL of the FMS repository.

``DO_REPRO_TESTS`` (*default:* *none*)
Set to ``true`` to test the REPRO build and confirm equivalence of DEBUG and
Expand Down
60 changes: 55 additions & 5 deletions .testing/tools/parse_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@
import collections
import json
import os
import re
import shlex
import subprocess
import sys

perf_scanner = re.Scanner([
(r'<', lambda scanner, token: token),
(r'>', lambda scanner, token: token),
(r'\(', lambda scanner, token: token),
(r'\)', lambda scanner, token: token),
(r'[ \t]+', lambda scanner, token: token),
(r'[^<>() \t]+', lambda scanner, token: token),
])


def main():
desc = 'Parse perf.data and return in JSON format.'
Expand Down Expand Up @@ -58,15 +68,55 @@ def parse_perf_report(perf_data_path):

# get per-symbol count
else:
tokens, remainder = perf_scanner.scan(line)
if remainder:
print('Line could not be tokenized', file=sys.stderr)
print(' line:', repr(line), file=sys.stderr)
print(' tokens:', tokens, file=sys.stderr)
print(' remainder:', remainder, file=sys.stderr)
sys.exit(os.EX_DATAERR)

# Construct record from tokens
# (NOTE: Not a proper grammar, just dumb bracket counting)
record = []
bracks = 0
parens = 0

for tok in tokens:
if tok == '<':
bracks += 1

if tok == '(':
parens += 1

rec = record[-1] if record else None

inside_bracket = rec and (bracks > 0 or parens > 0)
lead_rec = tok in '<(' and rec and not rec.isspace()
tail_rec = not tok.isspace() and rec and rec[-1] in '>)'

if inside_bracket or lead_rec or tail_rec:
record[-1] += tok
else:
record.append(tok)

if tok == '>':
bracks -= 1
if tok == '(':
parens -= 1

# Strip any whitespace tokens
record = [rec for rec in record if not rec.isspace()]

try:
tokens = line.split()
symbol = tokens[2]
period = int(tokens[3])
except ValueError:
symbol = record[2]
period = int(record[3])
except:
print("parse_perf.py: Error extracting symbol count",
file=sys.stderr)
file=sys.stderr)
print("line:", repr(line), file=sys.stderr)
print("tokens:", tokens, file=sys.stderr)
print("record:", record, file=sys.stderr)
raise

profile[event_name]['symbol'][symbol] = period
Expand Down
21 changes: 8 additions & 13 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,6 @@ AS_IF([test "x$with_driver" != "x"],
# used to configure a header based on a template.
#AC_CONFIG_HEADERS(["$MEM_LAYOUT/MOM_memory.h"])

# Select the model framework (default: FMS1)
# NOTE: We can phase this out after the FMS1 I/O has been removed from FMS and
# replace with a detection test. For now, it is a user-defined switch.
MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS2
AC_ARG_WITH([framework],
AS_HELP_STRING([--with-framework=fms1|fms2], [Select the model framework]))
AS_CASE(["$with_framework"],
[fms1], [MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS1],
[fms2], [MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS2],
[MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS2]
)


# Explicitly assume free-form Fortran
AC_LANG(Fortran)
Expand Down Expand Up @@ -220,7 +208,6 @@ AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod],
]
)


# Verify that FMS is at least 2019.01.02
# NOTE: 2019.01.02 introduced two changes:
# - diag_axis_init supports an optional domain_position argument
Expand All @@ -236,6 +223,14 @@ AC_COMPILE_IFELSE(
]
)

# Determine the FMS IO implementation.
AX_FC_CHECK_MODULE([fms2_io_mod], [
MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS2
],[
MODEL_FRAMEWORK=${srcdir}/config_src/infra/FMS1
])


# Python interpreter test

# Declare the Python interpreter variable
Expand Down
Loading

0 comments on commit 66f329d

Please sign in to comment.