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 Sep 22, 2023
2 parents e9d1cb5 + 25b57f4 commit b47de7f
Show file tree
Hide file tree
Showing 107 changed files with 6,425 additions and 3,956 deletions.
13 changes: 6 additions & 7 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ stages:
# We use the "fetch" strategy to speed up the startup of stages
variables:
JOB_DIR: "/lustre/f2/scratch/oar.gfdl.ogrp-account/runner/builds/$CI_PIPELINE_ID"
WORKSPACE: "/lustre/f2/scratch/oar.gfdl.ogrp-account/runner/$CI_RUNNER_ID"
GIT_STRATEGY: fetch

# Always eport value of $JOB_DIR
Expand Down Expand Up @@ -185,9 +184,9 @@ actions:gnu:
- make -s -j
- MPIRUN= make preproc -s -j
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" WORKSPACE=$WORKSPACE test -s -j') > job.sh
- sbatch --clusters=c5 --nodes=2 --time=0:10: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 WORKSPACE=$WORKSPACE test -s
- make WORKSPACE=$WORKSPACE test.summary
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c5 --nodes=2 --time=0:10: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 -s
- make test.summary

actions:intel:
stage: tests
Expand All @@ -205,9 +204,9 @@ actions:intel:
- make -s -j
- MPIRUN= make preproc -s -j
- echo -e "\e[0Ksection_end:`date +%s`:compile\r\e[0K"
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" WORKSPACE=$WORKSPACE test -s -j') > job.sh
- sbatch --clusters=c5 --nodes=2 --time=0:10: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 WORKSPACE=$WORKSPACE test -s
- make WORKSPACE=$WORKSPACE test.summary
- (echo '#!/bin/bash';echo 'make MPIRUN="srun -mblock --exclusive" test -s -j') > job.sh
- sbatch --clusters=c5 --nodes=2 --time=0:10: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 -s
- make test.summary

# Tests
#
Expand Down
33 changes: 7 additions & 26 deletions .testing/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ $(WORKSPACE)/work/%/$(1)/ocean.stats $(WORKSPACE)/work/%/$(1)/chksum_diag: build
&& $(TIME) $(5) $(MPIRUN) -n $(6) $(abspath $$<) 2> std.err > std.out \
|| !( \
mkdir -p ../../../results/$$*/ ; \
cat std.out | tee ../../../results/$$*/std.$(1).out | tail -n 20 ; \
cat std.err | tee ../../../results/$$*/std.$(1).err | tail -n 20 ; \
cat std.out | tee ../../../results/$$*/std.$(1).out | tail -n 40 ; \
cat std.err | tee ../../../results/$$*/std.$(1).err | tail -n 40 ; \
rm ocean.stats chksum_diag ; \
echo -e "$(FAIL): $$*.$(1) failed at runtime." \
)
Expand Down Expand Up @@ -630,8 +630,8 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
# Run the first half-period
cd $(@D) && $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> std1.err > std1.out \
|| !( \
cat std1.out | tee ../../../results/$*/std.restart1.out | tail -n 20 ; \
cat std1.err | tee ../../../results/$*/std.restart1.err | tail -n 20 ; \
cat std1.out | tee ../../../results/$*/std.restart1.out | tail -n 40 ; \
cat std1.err | tee ../../../results/$*/std.restart1.err | tail -n 40 ; \
echo -e "$(FAIL): $*.restart failed at runtime." \
)
# Setup the next inputs
Expand All @@ -641,8 +641,8 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
# Run the second half-period
cd $(@D) && $(TIME) $(MPIRUN) -n 1 $(abspath $<) 2> std2.err > std2.out \
|| !( \
cat std2.out | tee ../../../results/$*/std.restart2.out | tail -n 20 ; \
cat std2.err | tee ../../../results/$*/std.restart2.err | tail -n 20 ; \
cat std2.out | tee ../../../results/$*/std.restart2.out | tail -n 40 ; \
cat std2.err | tee ../../../results/$*/std.restart2.err | tail -n 40 ; \
echo -e "$(FAIL): $*.restart failed at runtime." \
)

Expand All @@ -652,26 +652,7 @@ $(WORKSPACE)/work/%/restart/ocean.stats: build/symmetric/MOM6 | preproc
# Not a true rule; only call this after `make test` to summarize test results.
.PHONY: test.summary
test.summary:
@if ls $(WORKSPACE)/results/*/* &> /dev/null; then \
if ls $(WORKSPACE)/results/*/std.*.err &> /dev/null; then \
echo "The following tests failed to complete:" ; \
ls $(WORKSPACE)/results/*/std.*.out \
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[2]; if(length(t)>3) v=v"."t[3]; print a[2],":",v}'; \
fi; \
if ls $(WORKSPACE)/results/*/ocean.stats.*.diff &> /dev/null; then \
echo "The following tests report solution regressions:" ; \
ls $(WORKSPACE)/results/*/ocean.stats.*.diff \
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[3]; if(length(t)>4) v=v"."t[4]; print a[2],":",v}'; \
fi; \
if ls $(WORKSPACE)/results/*/chksum_diag.*.diff &> /dev/null; then \
echo "The following tests report diagnostic regressions:" ; \
ls $(WORKSPACE)/results/*/chksum_diag.*.diff \
| awk '{split($$0,a,"/"); split(a[3],t,"."); v=t[2]; if(length(t)>3) v=v"."t[3]; print a[2],":",v}'; \
fi; \
false ; \
else \
echo -e "$(PASS): All tests passed!"; \
fi
@./tools/report_test_results.sh $(WORKSPACE)/results


#---
Expand Down
42 changes: 42 additions & 0 deletions .testing/tools/report_test_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh
RESULTS=${1:-${PWD}/results}

GREEN="\033[0;32m"
RESET="\033[0m"
PASS="${GREEN}PASS${RESET}"

if [ -d ${RESULTS} ]; then
if ls ${RESULTS}/*/std.*.err &> /dev/null; then
echo "The following tests failed to complete:"
ls ${RESULTS}/*/std.*.out \
| awk '{ \
split($$0,a,"/"); \
split(a[length(a)],t,"."); \
v=t[2]; \
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
fi

if ls ${RESULTS}/*/ocean.stats.*.diff &> /dev/null; then
echo "The following tests report solution regressions:"
ls ${RESULTS}/*/ocean.stats.*.diff \
| awk '{ \
split($$0,a,"/"); \
split(a[length(a)],t,"."); \
v=t[3]; \
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
fi

if ls ${RESULTS}/*/chksum_diag.*.diff &> /dev/null; then
echo "The following tests report diagnostic regressions:"
ls ${RESULTS}/*/chksum_diag.*.diff \
| awk '{ \
split($$0,a,"/"); \
split(a[length(a)],t,"."); \
v=t[2]; \
if(length(t)>4) v=v"."t[4]; print a[length(a)-1],":",v}'
fi

exit 1
else
printf "${PASS}: All tests passed!\n"
fi
45 changes: 45 additions & 0 deletions ac/deps/m4/ax_fc_check_c_lib.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
dnl AX_FC_CHECK_C_LIB(LIBRARY, FUNCTION,
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
dnl [OTHER-LDFLAGS], [OTHER-LIBS])
dnl
dnl This macro checks if a C library can be referenced by a Fortran compiler.
dnl
dnl Results are cached in `ax_fc_cv_c_lib_LIBRARY_FUNCTION`.
dnl
dnl NOTE: Might be possible to rewrite this to use `AX_FC_CHECK_BIND_C`.
dnl
AC_DEFUN([AX_FC_CHECK_C_LIB], [
AS_VAR_PUSHDEF([ax_fc_C_Lib], [ax_fc_cv_c_lib_$1_$2])
m4_ifval([$5],
[ax_fc_c_lib_msg_LDFLAGS=" with $5"],
[ax_fc_c_lib_msg_LDFLAGS=""]
)
AC_CACHE_CHECK(
[for $2 in -l$1$ax_fc_c_lib_msg_LDFLAGS], [ax_fc_cv_c_lib_$1_$2], [
ax_fc_check_c_lib_save_LDFLAGS=$LDFLAGS
LDFLAGS="$6 $LDFLAGS"
ax_fc_check_c_lib_save_LIBS=$LIBS
LIBS="-l$1 $7 $LIBS"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([],[dnl
dnl begin code block
interface
subroutine test() bind(c, name="$2")
end subroutine test
end interface
call test])
dnl end code block
],
[AS_VAR_SET([ax_fc_C_Lib], [yes])],
[AS_VAR_SET([ax_fc_C_Lib], [no])]
)
LDFLAGS=$ax_fc_check_c_lib_save_LDFLAGS
LIBS=$ax_fc_check_c_lib_save_LIBS
]
)
AS_VAR_IF([ax_fc_C_Lib], [yes],
[m4_default([$3], [LIBS="-l$1 $LIBS"])],
[$4]
)
AS_VAR_POPDEF([ax_fc_C_Lib])
])
13 changes: 7 additions & 6 deletions ac/deps/m4/ax_fc_check_lib.m4
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dnl library with different -L flags, or perhaps other ld configurations.
dnl
dnl Results are cached in the ax_fc_cv_lib_LIBRARY_FUNCTION variable.
dnl
AC_DEFUN([AX_FC_CHECK_LIB],[dnl
AC_DEFUN([AX_FC_CHECK_LIB],[
AS_VAR_PUSHDEF([ax_fc_Lib], [ax_fc_cv_lib_$1_$2])
m4_ifval([$6],
[ax_fc_lib_msg_LDFLAGS=" with $6"],
Expand All @@ -29,14 +29,15 @@ AC_DEFUN([AX_FC_CHECK_LIB],[dnl
LDFLAGS="$6 $LDFLAGS"
ax_fc_check_lib_save_LIBS=$LIBS
LIBS="-l$1 $7 $LIBS"
AS_IF([test -n $3],
AS_IF([test -n "$3"],
[ax_fc_use_mod="use $3"],
[ax_fc_use_mod=""])
AC_LINK_IFELSE([
AC_LANG_PROGRAM([], [dnl
AC_LINK_IFELSE([dnl
dnl Begin 7-column code block
AC_LANG_PROGRAM([], [dnl
$ax_fc_use_mod
call $2]dnl
)
call $2])dnl
dnl End code block
],
[AS_VAR_SET([ax_fc_Lib], [yes])],
[AS_VAR_SET([ax_fc_Lib], [no])]
Expand Down
45 changes: 39 additions & 6 deletions ac/makedep
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ re_use = re.compile(r"^ *use +([a-z_0-9]+)")
re_cpp_include = re.compile(r"^ *# *include *[<\"']([a-zA-Z_0-9\.]+)[>\"']")
re_f90_include = re.compile(r"^ *include +[\"']([a-zA-Z_0-9\.]+)[\"']")
re_program = re.compile(r"^ *[pP][rR][oO][gG][rR][aA][mM] +([a-zA-Z_0-9]+)")
re_end = re.compile(r"^ *end *(module|procedure) ", re.IGNORECASE)
# NOTE: This excludes comments and tokens with substrings containing `function`
# or `subroutine`, but will fail if the keywords appear in other contexts.
re_procedure = re.compile(
r"^[^!]*(?<![a-z_])(function|subroutine)(?![a-z_])",
re.IGNORECASE
)


def create_deps(src_dirs, makefile, debug, exec_target, fc_rule,
Expand All @@ -30,6 +37,7 @@ def create_deps(src_dirs, makefile, debug, exec_target, fc_rule,
F90_files = [
f for f in all_files
if f.endswith('.f90') or f.endswith('.F90')
or f.endswith('.f') or f.endswith('.F')
]
# ... all C source
c_files = [f for f in all_files if f.endswith('.c')]
Expand Down Expand Up @@ -58,7 +66,7 @@ def create_deps(src_dirs, makefile, debug, exec_target, fc_rule,
o2mods, o2uses, o2h, o2inc, o2prg, prg2o, mod2o = {}, {}, {}, {}, {}, {}, {}
externals, all_modules = [], []
for f in F90_files:
mods, used, cpp, inc, prg = scan_fortran_file(f)
mods, used, cpp, inc, prg, has_externals = scan_fortran_file(f)
# maps object file to modules produced
o2mods[object_file(f)] = mods
# maps module produced to object file
Expand All @@ -85,12 +93,12 @@ def create_deps(src_dirs, makefile, debug, exec_target, fc_rule,
o2prg[o] = ['[ignored %s]' % (p)]
else:
prg2o[p] = object_file(f)
if not mods and not prg:
if has_externals:
externals.append(object_file(f))
all_modules += mods

for f in c_files:
_, _, cpp, inc, _ = scan_fortran_file(f)
_, _, cpp, inc, _, _ = scan_fortran_file(f)
# maps object file to .h files included
o2h[object_file(f)] = cpp
externals.append(object_file(f))
Expand Down Expand Up @@ -238,7 +246,7 @@ def nested_inc(inc_files, f2F):
def recur(hfile):
if hfile not in f2F.keys():
return
_, _, cpp, inc, _ = scan_fortran_file(f2F[hfile])
_, _, cpp, inc, _, _ = scan_fortran_file(f2F[hfile])
if len(cpp) + len(inc) > 0:
for h in cpp+inc:
if h not in hlst and h in f2F.keys():
Expand All @@ -258,25 +266,49 @@ def scan_fortran_file(src_file):
module_decl, used_modules, cpp_includes, f90_includes, programs = [], [], [], [], []
with io.open(src_file, 'r', errors='replace') as file:
lines = file.readlines()

external_namespace = True

file_has_externals = False

for line in lines:
match = re_module.match(line.lower())
if match:
if match.group(1) not in 'procedure': # avoid "module procedure" statements
module_decl.append(match.group(1))
external_namespace = False

match = re_use.match(line.lower())
if match:
used_modules.append(match.group(1))

match = re_cpp_include.match(line)
if match:
cpp_includes.append(match.group(1))

match = re_f90_include.match(line)
if match:
f90_includes.append(match.group(1))

match = re_program.match(line)
if match:
programs.append(match.group(1))
external_namespace = False

match = re_end.match(line)
if match:
external_namespace = True

# Check for any external procedures; if present, flag the file
# as a potential source of
# NOTE: This a very weak test that needs further modification
if external_namespace and not file_has_externals:
match = re_procedure.match(line)
if match:
file_has_externals = True

used_modules = [m for m in sorted(set(used_modules)) if m not in module_decl]
return add_suff(module_decl, '.mod'), add_suff(used_modules, '.mod'), cpp_includes, f90_includes, programs
return add_suff(module_decl, '.mod'), add_suff(used_modules, '.mod'), cpp_includes, f90_includes, programs, file_has_externals
# return add_suff(module_decl, '.mod'), add_suff(sorted(set(used_modules)), '.mod'), cpp_includes, f90_includes, programs


Expand All @@ -297,8 +329,9 @@ def find_files(src_dirs):
for file in f:
# TODO: use any()
if (file.endswith('.F90') or file.endswith('.f90')
or file.endswith('.f') or file.endswith('.F')
or file.endswith('.h') or file.endswith('.inc')
or file.endswith('.c')):
or file.endswith('.c') or file.endswith('.H')):
files.append(p+'/'+file)
return sorted(set(files))

Expand Down
Loading

0 comments on commit b47de7f

Please sign in to comment.