Skip to content

Commit

Permalink
Merge pull request #6 from NOAA-GFDL/dev-gfdl-main-candidate-2021-02-19
Browse files Browse the repository at this point in the history
Dev gfdl main candidate 2021 02 19
  • Loading branch information
adcroft authored Feb 22, 2021
2 parents 5cdc0b7 + 45b3366 commit 27cd2ed
Show file tree
Hide file tree
Showing 195 changed files with 15,960 additions and 12,348 deletions.
13 changes: 11 additions & 2 deletions .github/actions/testing-setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
name: 'Build-.testing-prerequisites'
description: 'Build pre-requisites for .testing including FMS and a symmetric MOM6 executable'
inputs:
build_symmetric:
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 @@ -51,15 +60,15 @@ runs:
run: |
echo "::group::Compile MOM6 in symmetric memory mode"
cd .testing
make build/symmetric/MOM6 -j
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
make work/local-env
test ${{ inputs.install_python }} == true && make work/local-env
echo "::endgroup::"
- name: Set flags
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/coupled-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: API for coupled drivers

on: [push, pull_request]

jobs:
test-top-api:

runs-on: ubuntu-latest
defaults:
run:
working-directory: .testing

steps:
- uses: actions/checkout@v2
with:
submodules: recursive

- uses: ./.github/actions/testing-setup
with:
build_symmetric: 'false'
install_python: 'false'

- name: Compile MOM6 for the GFDL coupled driver
shell: bash
run: make check_mom6_api_coupled -j

- 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
3 changes: 2 additions & 1 deletion .github/workflows/documentation-and-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Check white space (non-blocking)
run: |
./.testing/trailer.py -e TEOS10 -l 120 src config_src | tee style_errors
./.testing/trailer.py -e TEOS10 -l 120 src config_src 2>&1 | tee style_errors
continue-on-error: true

- name: Install packages used when generating documentation
Expand All @@ -35,4 +35,5 @@ jobs:
run: |
grep "warning:" docs/_build/doxygen_warn_nortd_log.txt | grep -v "as part of a" | tee doxy_errors
cat style_errors doxy_errors > all_errors
cat all_errors
test ! -s all_errors
3 changes: 2 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ run:
- time tar zxf $CACHE_DIR/build-pgi-repro-$CI_PIPELINE_ID.tgz
# time tar zxf $CACHE_DIR/build-gnu-debug-$CI_PIPELINE_ID.tgz
- (echo '#!/bin/tcsh';echo 'make -f MRS/Makefile.tests all') > job.sh
- sbatch --clusters=c3,c4 --nodes=29 --time=0:34:00 --account=gfdl_o --qos=debug --job-name=mom6_regressions --output=log.$CI_PIPELINE_ID --wait job.sh
- sbatch --clusters=c3,c4 --nodes=29 --time=0:34:00 --account=gfdl_o --qos=debug --job-name=mom6_regressions --output=log.$CI_PIPELINE_ID --wait job.sh || MJOB_RETURN_STATE=Fail
- cat log.$CI_PIPELINE_ID
- test -z "$MJOB_RETURN_STATE"
- test -f restart_results_gnu.tar.gz
- time tar zvcf $CACHE_DIR/results-$CI_PIPELINE_ID.tgz *.tar.gz

Expand Down
27 changes: 25 additions & 2 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,19 @@ build/asymmetric/Makefile: MOM_ENV=$(PATH_FMS) $(ASYMMETRIC_FCFLAGS) $(MOM_LDFLA
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/coupled/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(SYMMETRIC_LDFLAGS)
build/nuopc/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(SYMMETRIC_LDFLAGS)
build/mct/Makefile: MOM_ENV=$(PATH_FMS) $(SYMMETRIC_FCFLAGS) $(SYMMETRIC_LDFLAGS)

# Configure script flags
build/symmetric/Makefile: MOM_ACFLAGS=
build/asymmetric/Makefile: MOM_ACFLAGS=--enable-asymmetric
build/repro/Makefile: MOM_ACFLAGS=
build/openmp/Makefile: MOM_ACFLAGS=--enable-openmp
build/target/Makefile: MOM_ACFLAGS=

build/coupled/Makefile: MOM_ACFLAGS=--with-driver=coupled_driver
build/nuopc/Makefile: MOM_ACFLAGS=--with-driver=nuopc_driver
build/mct/Makefile: MOM_ACFLAGS=--with-driver=mct_driver

# Fetch regression target source code
build/target/Makefile: | $(TARGET_CODEBASE)
Expand Down Expand Up @@ -328,6 +332,25 @@ $(DEPS)/Makefile: ../ac/deps/Makefile
mkdir -p $(@D)
cp $< $@

#---
# The following block does a non-library build of a coupled driver interface to MOM, along with everything below it.
# This simply checks that we have not 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
MK_TEMPLATE ?= ../../$(DEPS)/mkmf/templates/ncrc-gnu.mk
# NUOPC driver
build/nuopc/mom_ocean_model_nuopc.o: build/nuopc/Makefile
cd $(@D) && make $(@F)
check_mom6_api_nuopc: build/nuopc/mom_ocean_model_nuopc.o
# GFDL coupled driver
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

#---
# Python preprocessing
Expand Down
199 changes: 118 additions & 81 deletions .testing/trailer.py
Original file line number Diff line number Diff line change
@@ -1,100 +1,137 @@
#!/usr/bin/env python
"""Subroutines for Validating the whitespace of the source code."""

import argparse
import os
import re
import sys


def parseCommandLine():
"""
Parse the command line positional and optional arguments.
This is the highest level procedure invoked from the very end of the script.
"""
"""Parse the command line positional and optional arguments.
This is the highest level procedure invoked from the very end of the
script.
"""
# Arguments
parser = argparse.ArgumentParser(
description='trailer.py checks Fortran files for trailing white '
'space.',
epilog='Written by A.Adcroft, 2017.'
)
parser.add_argument(
'files_or_dirs', type=str, nargs='+',
metavar='FILE|DIR',
help='Fortran files or director in which to search for Fortran files '
'(with .f, .f90, .F90 suffixes).'''
)
parser.add_argument(
'-e', '--exclude_dir', type=str, action='append',
metavar='DIR',
help='''Exclude directories from search that end in DIR.'''
)
parser.add_argument(
'-l', '--line_length', type=int, default=512,
help='''Maximum allowed length of a line.'''
)
parser.add_argument(
'-s', '--source_line_length', type=int, default=132,
help='''Maximum allowed length of a source line excluding comments.'''
)
parser.add_argument(
'-d', '--debug', action='store_true',
help='turn on debugging information.'
)
args = parser.parse_args()

# Arguments
parser = argparse.ArgumentParser(description='''trailer.py checks Fortran files for trailing white space.''',
epilog='Written by A.Adcroft, 2017.')
parser.add_argument('files_or_dirs', type=str, nargs='+',
metavar='FILE|DIR',
help='''Fortran files or director in which to search for Fortran files (with .f, .f90, .F90 suffixes).''')
parser.add_argument('-e','--exclude_dir', type=str, action='append',
metavar='DIR',
help='''Exclude directories from search that end in DIR.''')
parser.add_argument('-l','--line_length', type=int, default=512,
help='''Maximum allowed length of a line.''')
parser.add_argument('-s','--source_line_length', type=int, default=132,
help='''Maximum allowed length of a source line excluding comments.''')
parser.add_argument('-d','--debug', action='store_true',
help='turn on debugging information.')
args = parser.parse_args()
global debug
debug = args.debug

global debug
debug = args.debug
main(args)

main(args)

def main(args):
'''
Does the actual work
'''
if (debug): print(args)
"""Do the actual work."""
if (debug):
print(args)

# Process files_or_dirs argument into list of files
all_files = []
for a in args.files_or_dirs:
if os.path.isfile(a): all_files.append(a)
elif os.path.isdir(a):
for d,s,files in os.walk(a):
ignore = False
if args.exclude_dir is not None:
for e in args.exclude_dir:
if e+'/' in d+'/': ignore = True
if not ignore:
for f in files:
_,ext = os.path.splitext(f)
if ext in ('.f','.F','.f90','.F90'): all_files.append( os.path.join(d,f) )
else: raise Exception('Argument '+a+' is not a file or directory! Stopping.')
if (debug): print('Found: ',all_files)
# Process files_or_dirs argument into list of files
all_files = []
for a in args.files_or_dirs:
if os.path.isfile(a):
all_files.append(a)
elif os.path.isdir(a):
for d, s, files in os.walk(a):
ignore = False
if args.exclude_dir is not None:
for e in args.exclude_dir:
if e+'/' in d+'/':
ignore = True
if not ignore:
for f in files:
_, ext = os.path.splitext(f)
if ext in ('.f', '.F', '.f90', '.F90'):
all_files.append(os.path.join(d, f))
else:
raise Exception('Argument '+a+' is not a file or directory! '
'Stopping.')
if (debug):
print('Found: ', all_files)

# For each file, check for trailing white space
fail = False
for filename in all_files:
this = scan_file(filename, line_length=args.line_length,
source_line_length=args.source_line_length)
fail = fail or this
if fail:
sys.exit(1)

# For each file, check for trailing white space
fail = False
for filename in all_files:
this = scan_file(filename, line_length=args.line_length, source_line_length=args.source_line_length)
fail = fail or this
if fail: sys.exit(1)

def scan_file(filename, line_length=512, source_line_length=132):
'''Scans file for trailing white space'''
def msg(filename,lineno,mesg,line=None):
if line is None: print('%s, line %i: %s'%(filename,lineno,mesg))
else: print('%s, line %i: %s "%s"'%(filename,lineno,mesg,line))
white_space_detected = False
tabs_space_detected = False
long_line_detected = False
with open(filename) as file:
trailing_space = re.compile(r'.* +$')
tabs = re.compile(r'.*\t.*')
lineno = 0
for line in file.readlines():
lineno += 1
line = line.replace('\n','')
srcline = line.split('!', 1)[0] # Discard comments
if trailing_space.match(line) is not None:
if debug: print(filename,lineno,line,trailing_space.match(line))
if len(line.strip())>0: msg(filename,lineno,'Trailing space detected',line)
else: msg(filename,lineno,'Blank line contains spaces')
white_space_detected = True
if tabs.match(line) is not None:
if len(line.strip())>0: msg(filename,lineno,'Tab detected',line)
else: msg(filename,lineno,'Blank line contains tabs')
tabs_space_detected = True
if len(line)>line_length:
if len(line.strip())>0: msg(filename,lineno,'Line length exceeded',line)
else: msg(filename,lineno,'Blank line exceeds line length limit')
long_line_detected = True
if len(srcline)>source_line_length:
msg(filename,lineno,'Non-comment line length exceeded',line)
return white_space_detected or tabs_space_detected or long_line_detected
"""Scan file for trailing white space."""
def msg(filename, lineno, mesg, line=None):
if line is None:
print('%s, line %i: %s' % (filename, lineno, mesg))
else:
print('%s, line %i: %s "%s"' % (filename, lineno, mesg, line))
white_space_detected = False
tabs_space_detected = False
long_line_detected = False
with open(filename) as file:
trailing_space = re.compile(r'.* +$')
tabs = re.compile(r'.*\t.*')
lineno = 0
for line in file.readlines():
lineno += 1
line = line.replace('\n', '')
srcline = line.split('!', 1)[0] # Discard comments
if trailing_space.match(line) is not None:
if debug:
print(filename, lineno, line, trailing_space.match(line))
if len(line.strip()) > 0:
msg(filename, lineno, 'Trailing space detected', line)
else:
msg(filename, lineno, 'Blank line contains spaces')
white_space_detected = True
if tabs.match(line) is not None:
if len(line.strip()) > 0:
msg(filename, lineno, 'Tab detected', line)
else:
msg(filename, lineno, 'Blank line contains tabs')
tabs_space_detected = True
if len(line) > line_length:
if len(line.strip()) > 0:
msg(filename, lineno, 'Line length exceeded', line)
else:
msg(filename, lineno,
'Blank line exceeds line length limit')
long_line_detected = True
if len(srcline) > source_line_length:
msg(filename, lineno, 'Non-comment line length exceeded', line)
return white_space_detected or tabs_space_detected or long_line_detected


# Invoke parseCommandLine(), the top-level procedure
if __name__ == '__main__': parseCommandLine()
if __name__ == '__main__':
parseCommandLine()
10 changes: 8 additions & 2 deletions ac/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ AC_ARG_ENABLE([asymmetric],
AS_IF([test "$enable_asymmetric" = yes],
[MEM_LAYOUT=${srcdir}/config_src/dynamic])

# Default to solo_driver
DRIVER_DIR=${srcdir}/config_src/solo_driver
AC_ARG_WITH([driver],
AS_HELP_STRING([--with-driver=coupled_driver|solo_driver], [Select directory for driver source code]))
AS_IF([test "x$with_driver" != "x"],
[DRIVER_DIR=${srcdir}/config_src/${with_driver}])

# TODO: Rather than point to a pre-configured header file, autoconf could be
# used to configure a header based on a template.
Expand Down Expand Up @@ -210,10 +216,10 @@ AS_IF([test -z "$MKMF"], [
AC_CONFIG_COMMANDS([path_names],
[list_paths -l \
${srcdir}/src \
${srcdir}/config_src/solo_driver \
${srcdir}/config_src/ext* \
${DRIVER_DIR} \
${MEM_LAYOUT}
], [MEM_LAYOUT=$MEM_LAYOUT])
], [MEM_LAYOUT=$MEM_LAYOUT DRIVER_DIR=$DRIVER_DIR])


AC_CONFIG_COMMANDS([Makefile.mkmf],
Expand Down
2 changes: 1 addition & 1 deletion ac/deps/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MKMF_COMMIT ?= master

# FMS framework
FMS_URL ?= https://github.com/NOAA-GFDL/FMS.git
FMS_COMMIT ?= 2020.04
FMS_COMMIT ?= 2019.01.03


# List of source files to link this Makefile's dependencies to model Makefiles
Expand Down
Loading

0 comments on commit 27cd2ed

Please sign in to comment.