From 272a2e8ee66dba5e1f6717040eaef1ff83ce2b05 Mon Sep 17 00:00:00 2001 From: Marshall Ward Date: Wed, 8 Mar 2023 17:11:40 -0500 Subject: [PATCH] Autoconf-based builds for MOM6-examples models This patch includes Makefiles for building each of the models and supporting libraries in MOM6-examples. Each build now uses autoconf to configure its essential compiler flags, rather than relying on an external mkmf template. Each Makefile is usable on its own; for example the FMS Makefile will build FMS, the ocean_only Makefile will build the ocean-only MOM6, etc. When a Makefile requires a component from another part (such as ocean_only requiring FMS), it now invokes the Makefile of the depedency, rather than trying to orchestrate the entire build on its own. There are still instances of "reaching" into other components. For example, many of the builds use autoconf files in the MOM6 repository. Others use configure scripts from a common directory. And any Makefile dependencies are freely referenced from within the directory tree. But in principle, each of these "externals" can be indepdendently configured and each Makefile can be used as a standalone build. There is a top-level Makefile which builds both symmetric and nonsymmetric versions of each model, as well as supporting libraries. These are placed in a user-defined BUILD directory (default to `build`) which is external to the individual default build directories within the Makefiles of individual components. This top-level Makefile does its best to emulate the output of the existing MRS build system. Assuming we are satisfied with this new approach, we can start to change some of these conventions. There are still many smaller issues which ought to be addressed: - The default MRS build system creates libMOM and libSIS libraries for the coupled builds (ice-ocean and AM2-based). We do not create equivalent libraries. - There are perhaps too many local `configure.XXX.ac` configure script templates floating around. Many are nearly identical. - Reaching into MOM6 for much of the content is not sustainable, and this content should perhaps be moved into MOM6-examples itself. - These Makefiles include some rules for running the models, but this is not yet feature-complete and we are still quite far from replacing MRS for running the tests. (Regression testing would not happen at this level, and would be handled by an even higher Makefile, such as from Gaea-stats). --- Makefile | 194 ++++++++++++++++ ac/configure.mom6sis2.ac | 317 ++++++++++++++++++++++++++ coupled_AM2_LM3_SIS2/Makefile | 215 +++++++++++++++++ ice_ocean_SIS2/.gitignore | 1 + ice_ocean_SIS2/Makefile | 215 +++++++++++++++++ ocean_only/Makefile | 228 ++++++++++++++++++ shared/AM2/Makefile | 39 ++++ shared/LM3/Makefile | 32 +++ shared/atmos_null/Makefile | 12 + shared/config/Libs.mk | 63 +++++ shared/config/Makefile.in | 35 +++ shared/config/configure.AM2.ac | 163 +++++++++++++ shared/config/configure.LM3.ac | 163 +++++++++++++ shared/config/configure.atmos_null.ac | 149 ++++++++++++ shared/config/configure.ice_param.ac | 149 ++++++++++++ shared/config/configure.icebergs.ac | 157 +++++++++++++ shared/config/configure.land_null.ac | 149 ++++++++++++ shared/fms/Makefile | 14 ++ shared/ice_param/Makefile | 12 + shared/icebergs/Makefile | 12 + shared/land_null/Makefile | 12 + shared/tools/get_nprocs.sh | 15 ++ 22 files changed, 2346 insertions(+) create mode 100644 Makefile create mode 100644 ac/configure.mom6sis2.ac create mode 100644 coupled_AM2_LM3_SIS2/Makefile create mode 100644 ice_ocean_SIS2/.gitignore create mode 100644 ice_ocean_SIS2/Makefile create mode 100644 ocean_only/Makefile create mode 100644 shared/AM2/Makefile create mode 100644 shared/LM3/Makefile create mode 100644 shared/atmos_null/Makefile create mode 100644 shared/config/Libs.mk create mode 100644 shared/config/Makefile.in create mode 100644 shared/config/configure.AM2.ac create mode 100644 shared/config/configure.LM3.ac create mode 100644 shared/config/configure.atmos_null.ac create mode 100644 shared/config/configure.ice_param.ac create mode 100644 shared/config/configure.icebergs.ac create mode 100644 shared/config/configure.land_null.ac create mode 100644 shared/fms/Makefile create mode 100644 shared/ice_param/Makefile create mode 100644 shared/icebergs/Makefile create mode 100644 shared/land_null/Makefile create mode 100755 shared/tools/get_nprocs.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..0da8b64b2a --- /dev/null +++ b/Makefile @@ -0,0 +1,194 @@ +# Test build +BUILD ?= build + +# Models +MODELS=ocean_only ice_ocean_SIS2 coupled_AM2_LM3_SIS2 +LIBS=AM2 atmos_null LM3 land_null icebergs ice_param fms + +.PHONY: all +all: $(MODELS) + +# ocean_only + +.PHONY: ocean_only +ocean_only: ocean_only.symmetric ocean_only.asymmetric + +.PHONY: ocean_only.symmetric +ocean_only.symmetric: fms + $(MAKE) -C ocean_only \ + BUILD=../$(BUILD)/dynamic_symmetric/ocean_only \ + FMS_BUILD=../$(BUILD)/fms + +.PHONY: ocean_only.asymmetric +ocean_only.asymmetric: fms + $(MAKE) -C ocean_only \ + BUILD=../$(BUILD)/dynamic_nonsymmetric/ocean_only \ + FMS_BUILD=../$(BUILD)/fms \ + MOM_MEMORY=../src/MOM6/config_src/memory/dynamic_nonsymmetric/MOM_memory.h + + +# ice_ocean_SIS2 + +.PHONY: ice_ocean_SIS2 +ice_ocean_SIS2: ice_ocean_SIS2.symmetric ice_ocean_SIS2.asymmetric + +.PHONY: ice_ocean_SIS2.symmetric +ice_ocean_SIS2.symmetric: fms atmos_null land_null ice_param icebergs + $(MAKE) -C ice_ocean_SIS2 \ + BUILD=../$(BUILD)/dynamic_symmetric/ice_ocean_SIS2 \ + FMS_BUILD=../$(BUILD)/fms \ + ATMOS_BUILD=../$(BUILD)/atmos_null \ + ICEBERGS_BUILD=../$(BUILD)/icebergs \ + ICE_PARAM_BUILD=../$(BUILD)/ice_param \ + LAND_BUILD=../$(BUILD)/land_null + +.PHONY: ice_ocean_SIS2.asymmetric +ice_ocean_SIS2.asymmetric: fms atmos_null land_null ice_param icebergs + $(MAKE) -C ice_ocean_SIS2 \ + BUILD=../$(BUILD)/dynamic_nonsymmetric/ice_ocean_SIS2 \ + FMS_BUILD=../$(BUILD)/fms \ + ATMOS_BUILD=../$(BUILD)/atmos_null \ + ICEBERGS_BUILD=../$(BUILD)/icebergs \ + ICE_PARAM_BUILD=../$(BUILD)/ice_param \ + LAND_BUILD=../$(BUILD)/land_null \ + MOM_MEMORY=../src/MOM6/config_src/memory/dynamic_nonsymmetric/MOM_memory.h \ + SIS_MEMORY=../src/SIS2/config_src/dynamic/SIS2_memory.h + + +# Full coupled model + +.PHONY: coupled_AM2_LM3_SIS2 +coupled_AM2_LM3_SIS2: coupled_AM2_LM3_SIS2.symmetric coupled_AM2_LM3_SIS2.asymmetric + +.PHONY: coupled_AM2_LM3_SIS2.symmetric +coupled_AM2_LM3_SIS2.symmetric: fms AM2 LM3 ice_param icebergs + $(MAKE) -C coupled_AM2_LM3_SIS2 \ + BUILD=../$(BUILD)/dynamic_symmetric/coupled_AM2_LM3_SIS2 \ + FMS_BUILD=../$(BUILD)/fms \ + AM2_BUILD=../$(BUILD)/AM2 \ + ICEBERGS_BUILD=../$(BUILD)/icebergs \ + ICE_PARAM_BUILD=../$(BUILD)/ice_param \ + LM3_BUILD=../$(BUILD)/LM3 + +.PHONY: coupled_AM2_LM3_SIS2.asymmetric +coupled_AM2_LM3_SIS2.asymmetric: fms AM2 LM3 ice_param icebergs + $(MAKE) -C coupled_AM2_LM3_SIS2 \ + BUILD=../$(BUILD)/dynamic_nonsymmetric/coupled_AM2_LM3_SIS2 \ + FMS_BUILD=../$(BUILD)/fms \ + AM2_BUILD=../$(BUILD)/AM2 \ + ICEBERGS_BUILD=../$(BUILD)/icebergs \ + ICE_PARAM_BUILD=../$(BUILD)/ice_param \ + LM3_BUILD=../$(BUILD)/LM3 \ + MOM_MEMORY=../src/MOM6/config_src/memory/dynamic_nonsymmetric/MOM_memory.h \ + SIS_MEMORY=../src/SIS2/config_src/dynamic/SIS2_memory.h + +# TODO: Coupled asymmetric? + +# Libraries + +.PHONY: fms +fms: + $(MAKE) -C shared/fms \ + BUILD=../../$(BUILD)/fms + +.PHONY: atmos_null +atmos_null: fms + $(MAKE) -C shared/atmos_null \ + BUILD=../../$(BUILD)/atmos_null \ + FMS_BUILD=../../$(BUILD)/fms + +.PHONY: AM2 +AM2: fms + $(MAKE) -C shared/AM2 \ + BUILD=../../$(BUILD)/AM2 \ + FMS_BUILD=../../$(BUILD)/fms + +.PHONY: land_null +land_null: fms + $(MAKE) -C shared/land_null \ + BUILD=../../$(BUILD)/land_null \ + FMS_BUILD=../../$(BUILD)/fms + +.PHONY: LM3 +LM3: fms + $(MAKE) -C shared/LM3 \ + BUILD=../../$(BUILD)/LM3 \ + FMS_BUILD=../../$(BUILD)/fms + +.PHONY: ice_param +ice_param: fms + $(MAKE) -C shared/ice_param \ + BUILD=../../$(BUILD)/ice_param \ + FMS_BUILD=../../$(BUILD)/fms + +.PHONY: icebergs +icebergs: fms + $(MAKE) -C shared/icebergs \ + BUILD=../../$(BUILD)/icebergs \ + FMS_BUILD=../../$(BUILD)/fms + + +# Runs +# NOTE: This is not yet implemented, and is only an example of how this could +# look in a future version. + +RUNDIR ?= runs + +# unused +rwildcard=$(foreach d,$(wildcard $(1:=/*)),\ + $(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d)) + +# Build manifest +# TODO: recursive wildcard +PARAM_LIST=$(shell find $1 -name MOM_parameter_doc.all) +EXPT_DIRS=$(patsubst $1/%/MOM_parameter_doc.all,%,$(call PARAM_LIST,$1)) + +# 1: rundir +# 2: build dir +# 3: expt dir +define EXPT_RULE +$(1)/ocean.stats: ocean_only ; + $(MAKE) -C ocean_only ../$(1)/ocean.stats \ + BUILD=../$(2) \ + OUTPUT=../$(1) \ + EXPT=$(3) +endef +$(foreach e,$(call EXPT_DIRS,ocean_only),\ + $(eval $(call EXPT_RULE,$(RUNDIR)/ocean_only/symmetric/$e,$(BUILD)/ocean_only/symmetric,$e))) + + +run.ocean_only: $(foreach e,$(call EXPT_DIRS,ocean_only),\ + $(RUNDIR)/ocean_only/symmetric/$(e)/ocean.stats) + + +# Cleanup + +clean: $(foreach model,$(MODELS),$(model).clean) + rm -rf build + +define MODEL_CLEAN_RULE +.PHONY: $(1).clean +$(1).clean: $(1).symmetric.clean $(1).asymmetric.clean + +.PHONY: $(1).symmetric.clean +$(1).symmetric.clean: + $(MAKE) -C $(1) \ + BUILD=../$(BUILD)/dynamic_symmetric/$(1) \ + clean + +.PHONY: $(1).asymmetric.clean +$(1).asymmetric.clean: + $(MAKE) -C $(1) \ + BUILD=../$(BUILD)/dynamic_nonsymmetric/$(1) \ + clean +endef +$(foreach model,$(MODELS),$(eval $(call MODEL_CLEAN_RULE,$(model)))) + +define CLEAN_RULE +.PHONY: $(1).clean +$(1).clean: + $(MAKE) -C shared/$(1) \ + BUILD=../../$(BUILD)/$(1) \ + clean +endef +$(foreach lib,$(LIBS),$(eval $(call CLEAN_RULE,$(lib)))) diff --git a/ac/configure.mom6sis2.ac b/ac/configure.mom6sis2.ac new file mode 100644 index 0000000000..06ef495f7f --- /dev/null +++ b/ac/configure.mom6sis2.ac @@ -0,0 +1,317 @@ +# Autoconf configuration +AC_PREREQ([2.63]) + +AC_INIT( + [MOM6], + [], + [https://github.com/NOAA-GFDL/MOM6/issues], + [], + [https://github.com/NOAA-GFDL/MOM6] +) + + +# Validate srdcir and configure input +AC_CONFIG_SRCDIR([src/core/MOM.F90]) +AC_CONFIG_MACRO_DIR([m4]) + + +# MOM6 memory layout configuration + +AC_ARG_VAR([MOM_MEMORY], + [Path to MOM_memory.h header, describing the field memory layout: dynamic + symmetric (default), dynamic asymmetric, or static.] +) + +AS_VAR_IF([MOM_MEMORY], [], + [MOM_MEMORY=${srcdir}/config_src/memory/dynamic_symmetric/MOM_memory.h] +) + +# Confirm that MOM_MEMORY is named 'MOM_memory.h' +AS_IF([test $(basename "${MOM_MEMORY}") == "MOM_memory.h"], [], + [AC_MSG_ERROR([MOM_MEMORY header ${MOM_MEMORY} must be named 'MOM_memory.h'])] +) + +# Confirm that the file exists +AC_CHECK_FILE(["$MOM_MEMORY"], [], + [AC_MSG_ERROR([MOM_MEMORY header ${MOM_MEMORY} not found.])] +) + +MOM_MEMORY_DIR=$(AS_DIRNAME(["${MOM_MEMORY}"])) +AC_SUBST([MOM_MEMORY_DIR]) + + +# SIS2 memory layout configuration + +AC_ARG_VAR([SIS_MEMORY], + [Path to SIS2_memory.h header, describing the field memory layout: dynamic + symmetric (default), dynamic asymmetric, or static.] +) + +# For now, we assume that SIS2 source is in the same directory as MOM6 +AS_VAR_IF([SIS_MEMORY], [], + [SIS_MEMORY=${srcdir}/../SIS2/config_src/dynamic_symmetric/SIS2_memory.h] +) + +# Confirm that SIS_MEMORY is named 'SIS2_memory.h' +AS_IF([test $(basename "${SIS_MEMORY}") == "SIS2_memory.h"], [], + [AC_MSG_ERROR([SIS_MEMORY header ${SIS_MEMORY} must be named 'SIS2_memory.h'])] +) + +# Confirm that the file exists +AC_CHECK_FILE(["$SIS_MEMORY"], [], + [AC_MSG_ERROR([SIS_MEMORY header ${SIS_MEMORY} not found.])] +) + +SIS_MEMORY_DIR=$(AS_DIRNAME(["${SIS_MEMORY}"])) +AC_SUBST([SIS_MEMORY_DIR]) + + +# Driver configuration +DRIVER_DIR=${srcdir}/config_src/drivers/solo_driver +AC_ARG_WITH([driver], + AS_HELP_STRING( + [--with-driver=FMS_cap|solo_driver|unit_tests], + [Select directory for driver source code] + ) +) +AS_IF([test "x$with_driver" != "x"], + [DRIVER_DIR=${srcdir}/config_src/drivers/${with_driver}]) + + +# 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/FMS1 +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/FMS1] +) + + +# Explicitly assume free-form Fortran +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) + + +# Determine MPI compiler wrappers +# NOTE: +# - AX_MPI invokes AC_PROG_FC, often with gfortran, even if the MPI launcher +# does not use gfortran. +# - This can cause standard AC_PROG_FC tests to fail if FCFLAGS is configured +# with flags from another compiler. +# - I do not yet know how to resolve this possible issue. +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) + + +# Explicitly replace FC and LD with MPI wrappers +# NOTE: This is yet another attempt to manage the potential mismatches between +# FC and MPIFC. Without this step, the tests below would not use MPIFC. +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + +# Confirm that FC can see the Fortran 90 MPI module. +AX_FC_CHECK_MODULE([mpi], + [], [AC_MSG_ERROR([Could not find MPI Fortran module.])]) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# Unlimited line length (2.67) +# AC_FC_LINE_LENGTH was added in 2.67. +m4_version_prereq([2.67], + [AC_FC_LINE_LENGTH([unlimited])], + [AX_FC_LINE_LENGTH([unlimited])] +) + + +# OpenMP configuration + +# NOTE: AC_OPENMP fails on `Fortran` for Autoconf <2.69 due to a m4 bug. +# For older versions, we test against CC and use the result for FC. +m4_version_prereq([2.69], [AC_OPENMP], [ + AC_LANG_PUSH([C]) + AC_OPENMP + AC_LANG_POP([C]) + OPENMP_FCFLAGS="$OPENMP_CFLAGS" +]) + +# NOTE: Only apply OpenMP flags if explicitly enabled. +AS_IF( + [test "$enable_openmp" = yes], [ + FCFLAGS="$FCFLAGS $OPENMP_FCFLAGS" + LDFLAGS="$LDFLAGS $OPENMP_FCFLAGS" +]) + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROG([MAKEDEP], [makedep], [${srcdir}/ac/makedep]) +AC_SUBST([MAKEDEP]) + + +# Generate source list and configure dependency command +AC_SUBST([SRC_DIRS], ["\\ + ${srcdir}/src \\ + ${MODEL_FRAMEWORK} \\ + ${srcdir}/config_src/external \\ + ${DRIVER_DIR} \\ + ${MOM_MEMORY_DIR} \\ + ${SIS_MEMORY_DIR}" +]) +AC_CONFIG_COMMANDS(Makefile.dep, [make depend]) + + +# Append user-defined source directories +AC_ARG_VAR([EXTRA_SRC_DIRS], [Additional source code to include in build]) +AS_IF([test -n "${EXTRA_SRC_DIRS}"], [ + SRC_DIRS="${SRC_DIRS} ${EXTRA_SRC_DIRS}" +]) + + +# POSIX verification tests + +# These symbols may be defined as macros, making them inaccessible by Fortran. +# These three exist in modern BSD and Linux libc, so we just confirm them. +# But one day, we many need to handle them more carefully. +AX_FC_CHECK_BIND_C([setjmp], [], [AC_MSG_ERROR([Could not find setjmp.])]) +AX_FC_CHECK_BIND_C([longjmp], [], [AC_MSG_ERROR([Could not find longjmp.])]) +AX_FC_CHECK_BIND_C([siglongjmp], [], [AC_MSG_ERROR([Could not find siglongjmp.])]) + +# Determine the sigsetjmp symbol. If missing, then point to sigsetjmp_missing. +# +# Supported symbols: +# sigsetjmp POSIX, BSD libc (MacOS) +# __sigsetjmp glibc (Linux) +SIGSETJMP="sigsetjmp_missing" +for sigsetjmp_fn in sigsetjmp __sigsetjmp; do + AX_FC_CHECK_BIND_C([${sigsetjmp_fn}], [ + SIGSETJMP=${sigsetjmp_fn} + break + ]) +done +AC_DEFINE_UNQUOTED([SIGSETJMP_NAME], ["${SIGSETJMP}"]) + +# Verify the size of nonlocal jump buffer structs +# NOTE: This requires C compiler, but can it be done with a Fortran compiler? +AC_LANG_PUSH([C]) + +AX_MPI([], [AC_MSG_ERROR([Could not find MPI launcher.])]) +AC_SUBST([CC], [$MPICC]) + +AC_CHECK_SIZEOF([jmp_buf], [], [#include ]) +AC_CHECK_SIZEOF([sigjmp_buf], [], [#include ]) + +AC_LANG_POP([C]) + + +# Prepare output +AC_SUBST([CPPFLAGS]) +AC_CONFIG_FILES([Makefile:Makefile.in]) +AC_OUTPUT diff --git a/coupled_AM2_LM3_SIS2/Makefile b/coupled_AM2_LM3_SIS2/Makefile new file mode 100644 index 0000000000..2364d3b6aa --- /dev/null +++ b/coupled_AM2_LM3_SIS2/Makefile @@ -0,0 +1,215 @@ +# Configuration +BUILD ?= build +MOM_MEMORY ?= +SIS_MEMORY ?= + +# Dependencies +FMS_BUILD ?= ../shared/fms/$(BUILD) +AM2_BUILD ?= ../shared/AM2/$(BUILD) +ICEBERGS_BUILD ?= ../shared/icebergs/$(BUILD) +ICE_PARAM_BUILD ?= ../shared/ice_param/$(BUILD) +LM3_BUILD ?= ../shared/LM3/$(BUILD) + +# Autoconf configuration +MOM_CODEBASE ?= ../src/MOM6 +MAKEFILE_IN ?= $(MOM_CODEBASE)/ac/Makefile.in +CONFIGURE_AC ?= ../ac/configure.mom6sis2.ac +M4DIR ?= $(MOM_CODEBASE)/ac/m4 +MAKEDEP ?= $(MOM_CODEBASE)/ac/makedep + +# Run configuration +EXPT ?= +OUTPUT ?= ./$(EXPT) +LAUNCHER ?= mpirun +EXCLUDE ?= + +# Autoconf setup +EXTRA_SRC_DIRS = \ + $(abspath ../src/SIS2/src) \ + $(abspath ../src/SIS2/config_src/dynamic_symmetric) \ + $(abspath ../src/SIS2/config_src/external) \ + $(abspath ../src/coupler) + +CONFIG_FLAGS := --config-cache +CONFIG_FLAGS += --srcdir=$(abspath $(MOM_CODEBASE)) +CONFIG_FLAGS += --with-driver=FMS_cap +ifdef MOM_MEMORY + CONFIG_FLAGS += MOM_MEMORY=$(abspath $(MOM_MEMORY)) +endif +ifdef SIS_MEMORY + CONFIG_FLAGS += SIS_MEMORY=$(abspath $(SIS_MEMORY)) +endif + +# Preprocessor directives +CPPFLAGS += -Duse_AM3_physics -D_USE_LEGACY_LAND_ + +# NOTE: MOM_FCFLAGS overwrites default; we restore it here +FCFLAGS ?= -g -O2 + +# Path to fms_platform.h +FCFLAGS += -I$(abspath ../src/FMS/include) + +# These autoconf flags are passed only to ./configure +MOM_FCFLAGS = $(FCFLAGS) \ + -I$(abspath $(FMS_BUILD)) \ + -I$(abspath $(AM2_BUILD)) \ + -I$(abspath $(ICEBERGS_BUILD)) \ + -I$(abspath $(ICE_PARAM_BUILD)) \ + -I$(abspath $(LM3_BUILD)) + +MOM_LDFLAGS += $(LDFLAGS) \ + -L$(abspath $(FMS_BUILD)) \ + -L$(abspath $(AM2_BUILD)) \ + -L$(abspath $(ICEBERGS_BUILD)) \ + -L$(abspath $(ICE_PARAM_BUILD)) \ + -L$(abspath $(LM3_BUILD)) + +# TODO: Should be autodetected, but we'll get there... +# Also, appending -lFMS is a duplication but it needs to follow the others +MOM_LIBS += -licebergs -lice_param -lLM3 -lAM2 -lFMS + + +# Makefile configuration + +# Verify that BUILD is not set to the current directory +# (which would clobber this Makefile) +MAKEPATH = $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +ifeq ($(MAKEPATH), $(realpath $(BUILD))) + $(error BUILD cannot be set to the current directory) +endif + +# Disable builtin rules and variables +MAKEFLAGS += -rR + +# Export autoconf variables to dependent Makefiles +export CPPFLAGS +export CC +export MPICC +export CFLAGS +export FC +export MPIFC +export FCFLAGS +export LDFLAGS +export LIBS +export PYTHON +export EXTRA_SRC_DIRS + + +#---- + +TARGET = MOM6 + +all: $(BUILD)/$(TARGET) + +$(BUILD)/$(TARGET): $(BUILD)/Makefile + FCFLAGS="${MOM_FCFLAGS}" \ + LDFLAGS="${MOM_LDFLAGS}" \ + $(MAKE) -C $(BUILD) coupler_main + @# Rename to MOM6 for MRS compatibility + @# This can be dropped when MRS is updated (or replaced) + mv $(BUILD)/coupler_main $(BUILD)/$(TARGET) + +$(BUILD)/Makefile: $(FMS_BUILD)/libFMS.a +$(BUILD)/Makefile: $(AM2_BUILD)/libAM2.a +$(BUILD)/Makefile: $(LM3_BUILD)/libLM3.a +$(BUILD)/Makefile: $(ICE_PARAM_BUILD)/libice_param.a +$(BUILD)/Makefile: $(ICEBERGS_BUILD)/libicebergs.a +$(BUILD)/Makefile: $(BUILD)/Makefile.in $(BUILD)/configure + cd $(BUILD) && \ + PATH=${PATH}:$(dir $(abspath $(MAKEDEP))) \ + FCFLAGS="${MOM_FCFLAGS}" \ + LDFLAGS="${MOM_LDFLAGS}" \ + LIBS="${MOM_LIBS}" \ + ./configure ${CONFIG_FLAGS} + +$(BUILD)/Makefile.in: $(MAKEFILE_IN) | $(BUILD) + cp $(MAKEFILE_IN) $(BUILD)/Makefile.in + +$(BUILD)/configure: $(BUILD)/configure.ac + autoreconf $(BUILD) + +$(BUILD)/configure.ac: $(CONFIGURE_AC) | $(BUILD) + cp $(CONFIGURE_AC) $(BUILD)/configure.ac + cp -r $(M4DIR) $(BUILD) + +$(BUILD): + mkdir -p $@ + + +#---- +# Dependencies + +$(FMS_BUILD)/libFMS.a: + $(MAKE) -C ../shared/fms BUILD=$(BUILD) + +$(AM2_BUILD)/libAM2.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/AM2 BUILD=$(BUILD) + +$(LM3_BUILD)/libLM3.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/LM3 BUILD=$(BUILD) + +$(ICE_PARAM_BUILD)/libice_param.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/ice_param BUILD=$(BUILD) + +$(ICEBERGS_BUILD)/libicebergs.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/icebergs BUILD=$(BUILD) + + +#---- +# Experiments + +EXPTS = $(patsubst ./%/,%,$(dir $(shell find . -name MOM_parameter_doc.all))) +GET_NPROCS = $(abspath ../shared/tools/get_nprocs.sh) + +REG_EXPTS = $(filter-out $(EXCLUDE),$(EXPTS)) + +RUNDIR = $(if $(OUTPUT),$(OUTPUT)/$(1),$(1)) + +.PHONY: run.all +run.all: $(foreach e,$(REG_EXPTS),run.$(e)) + +define EXPT_RULE +.PHONY: run.$(1) +run.$(1): $(RUNDIR)/ocean.stats | $(RUNDIR) + +$(RUNDIR)/ocean.stats: $(BUILD)/$(TARGET) $(RUNDIR)/input.nml + mkdir -p $(RUNDIR)/RESTART + cd $(RUNDIR) && srun -mblock --exclusive -n $$$$($(GET_NPROCS) .) \ + $(abspath $(BUILD)/$(TARGET)) + +# TODO: Whitelist the files/dirs to copy? +# TODO: What about symbolic links? +$(RUNDIR)/input.nml: | $(RUNDIR) + cp -r $(1)/* $(RUNDIR)/ + +$(RUNDIR): + mkdir -p $(RUNDIR) + +clean.$(1): + rm -f $(RUNDIR)/CPU_stats + rm -f $(RUNDIR)/Depth_list.nc + rm -rf $(RUNDIR)/RESTART + rm -f $(RUNDIR)/Vertical_coordinate.nc + rm -f $(RUNDIR)/available_diags.?????? + rm -f $(RUNDIR)/ave_prog__*.nc + rm -f $(RUNDIR)/cont__*.nc + rm -f $(RUNDIR)/exitcode + rm -f $(RUNDIR)/logfile.??????.out + rm -f $(RUNDIR)/ocean.stats + rm -f $(RUNDIR)/ocean.stats.nc + rm -f $(RUNDIR)/ocean_geometry.nc + rm -f $(RUNDIR)/prog__*.nc + rm -f $(RUNDIR)/time_stamp.out +endef +$(foreach expt,$(EXPTS),$(eval $(call EXPT_RULE,$(expt)))) + + +#---- +# Cleanup + +.PHONY: clean +clean: + rm -rf $(BUILD) + +.PHONY: clean.runs +clean.runs: $(foreach e,$(EXPTS),clean.$(e)) diff --git a/ice_ocean_SIS2/.gitignore b/ice_ocean_SIS2/.gitignore new file mode 100644 index 0000000000..567609b123 --- /dev/null +++ b/ice_ocean_SIS2/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/ice_ocean_SIS2/Makefile b/ice_ocean_SIS2/Makefile new file mode 100644 index 0000000000..de6f8bdbac --- /dev/null +++ b/ice_ocean_SIS2/Makefile @@ -0,0 +1,215 @@ +# Build configuration +BUILD ?= build +MOM_MEMORY ?= +SIS_MEMORY ?= + +# Dependencies +FMS_BUILD ?= ../shared/fms/$(BUILD) +ICEBERGS_BUILD ?= ../shared/icebergs/$(BUILD) +ICE_PARAM_BUILD ?= ../shared/ice_param/$(BUILD) +ATMOS_BUILD ?= ../shared/atmos_null/$(BUILD) +LAND_BUILD ?= ../shared/land_null/$(BUILD) + +# Autoconf configuration +MOM_CODEBASE ?= ../src/MOM6 +MAKEFILE_IN ?= $(MOM_CODEBASE)/ac/Makefile.in +CONFIGURE_AC ?= ../ac/configure.mom6sis2.ac +M4DIR ?= $(MOM_CODEBASE)/ac/m4 +MAKEDEP ?= $(MOM_CODEBASE)/ac/makedep + +# Run configuration +EXPT ?= +OUTPUT ?= ./$(EXPT) +LAUNCHER ?= mpirun +# The following runs do not appear to work +EXCLUDE ?= \ + OM4_025.JRA \ + SIS2_icebergs \ + SIS2_bergs_cgrid + + +# Autoconf setup +EXTRA_SRC_DIRS := \ + $(abspath ../src/SIS2/src) \ + $(abspath ../src/SIS2/config_src/external) \ + $(abspath ../src/coupler) + +CONFIG_FLAGS := --config-cache +CONFIG_FLAGS += --srcdir=$(abspath $(MOM_CODEBASE)) +CONFIG_FLAGS += --with-driver=FMS_cap +ifdef MOM_MEMORY + CONFIG_FLAGS += MOM_MEMORY=$(abspath $(MOM_MEMORY)) +endif +ifdef SIS_MEMORY + CONFIG_FLAGS += SIS_MEMORY=$(abspath $(SIS_MEMORY)) +endif + +# NOTE: MOM_FCFLAGS overwrites default; we restore it here +FCFLAGS ?= -g -O2 + +# Apply coupler preprocessing +CPPFLAGS += \ + -Duse_AM3_physics \ + -D_USE_LEGACY_LAND_ + +MOM_FCFLAGS := $(FCFLAGS) \ + -I$(abspath $(FMS_BUILD)) \ + -I$(abspath $(ICEBERGS_BUILD)) \ + -I$(abspath $(ICE_PARAM_BUILD)) \ + -I$(abspath $(ATMOS_BUILD)) \ + -I$(abspath $(LAND_BUILD)) +MOM_LDFLAGS := $(LDFLAGS) \ + -L$(abspath $(FMS_BUILD)) \ + -L$(abspath $(ICEBERGS_BUILD)) \ + -L$(abspath $(ICE_PARAM_BUILD)) \ + -L$(abspath $(ATMOS_BUILD)) \ + -L$(abspath $(LAND_BUILD)) + +# TODO: Should be autodetected, but we'll get there... +# Also, appending -lFMS is a duplication but it needs to follow the others +MOM_LIBS += -licebergs -lice_param -latmos_null -lland_null -lFMS + +# Autoconf variables +export CPPFLAGS +export CC +export MPICC +export CFLAGS +export FC +export MPIFC +export FCFLAGS +export LDFLAGS +export LIBS +export PYTHON +export EXTRA_SRC_DIRS + + +# Makefile setup + +# Verify that BUILD is not set to the current directory +# (which would clobber this Makefile) +MAKEPATH = $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +ifeq ($(MAKEPATH), $(realpath $(BUILD))) + $(error BUILD cannot be set to the current directory) +endif + +# Disable builtin rules and variables +MAKEFLAGS += -rR + +#--- + +TARGET := MOM6 + +all: $(BUILD)/$(TARGET) + +$(BUILD)/$(TARGET): $(BUILD)/Makefile + FCFLAGS="${MOM_FCFLAGS}" \ + LDFLAGS="${MOM_LDFLAGS}" \ + $(MAKE) -C $(BUILD) coupler_main + @# Rename to MOM6 for MRS compatibility + @# This can be dropped when MRS is updated (or replaced) + mv $(BUILD)/coupler_main $(BUILD)/MOM6 + +$(BUILD)/Makefile: $(FMS_BUILD)/libFMS.a +$(BUILD)/Makefile: $(ATMOS_BUILD)/libatmos_null.a +$(BUILD)/Makefile: $(LAND_BUILD)/libland_null.a +$(BUILD)/Makefile: $(ICE_PARAM_BUILD)/libice_param.a +$(BUILD)/Makefile: $(ICEBERGS_BUILD)/libicebergs.a +$(BUILD)/Makefile: $(BUILD)/Makefile.in $(BUILD)/configure + cd $(BUILD) && \ + PATH="${PATH}:$(dir $(abspath $(MAKEDEP)))" \ + FCFLAGS="${MOM_FCFLAGS}" \ + LDFLAGS="${MOM_LDFLAGS}" \ + LIBS="${MOM_LIBS}" \ + ./configure $(CONFIG_FLAGS) + +$(BUILD)/Makefile.in: $(MAKEFILE_IN) | $(BUILD) + cp $(MAKEFILE_IN) $(BUILD)/Makefile.in + +$(BUILD)/configure: $(BUILD)/configure.ac $(BUILD)/m4 + autoreconf $(BUILD) + +$(BUILD)/configure.ac: $(CONFIGURE_AC) | $(BUILD) + cp $(CONFIGURE_AC) $(BUILD)/configure.ac + +$(BUILD)/m4: $(M4DIR) | $(BUILD) + cp -r $(M4DIR) $(BUILD) + +$(BUILD): + mkdir -p $@ + +#---- + +# Dependencies + +$(FMS_BUILD)/libFMS.a: + $(MAKE) -C ../shared/fms BUILD=$(BUILD) + +$(ATMOS_BUILD)/libatmos_null.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/atmos_null BUILD=$(BUILD) + +$(LAND_BUILD)/libland_null.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/land_null BUILD=$(BUILD) + +$(ICE_PARAM_BUILD)/libice_param.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/ice_param BUILD=$(BUILD) + +$(ICEBERGS_BUILD)/libicebergs.a: $(FMS_BUILD)/libFMS.a + $(MAKE) -C ../shared/icebergs BUILD=$(BUILD) + +#---- + +# Experiments + +EXPTS = $(patsubst ./%/,%,$(dir $(shell find . -name MOM_parameter_doc.all))) +GET_NPROCS = $(abspath ../shared/tools/get_nprocs.sh) + +REG_EXPTS = $(filter-out $(EXCLUDE),$(EXPTS)) + +RUNDIR = $(if $(OUTPUT),$(OUTPUT)/$(1),$(1)) + +.PHONY: run.all +run.all: $(foreach e,$(REG_EXPTS),run.$(e)) + +define EXPT_RULE +.PHONY: run.$(1) +run.$(1): $(RUNDIR)/ocean.stats | $(RUNDIR) + +$(RUNDIR)/ocean.stats: $(BUILD)/$(TARGET) $(RUNDIR)/input.nml + mkdir -p $(RUNDIR)/RESTART + cd $(RUNDIR) && srun -mblock --exclusive -n $$$$($(GET_NPROCS) .) \ + $(abspath $(BUILD)/$(TARGET)) + +# TODO: Whitelist the files/dirs to copy? +# TODO: What about symbolic links? +$(RUNDIR)/input.nml: | $(RUNDIR) + cp -r $(1)/* $(RUNDIR)/ + +$(RUNDIR): + mkdir -p $(RUNDIR) + +clean.$(1): + rm -f $(RUNDIR)/CPU_stats + rm -f $(RUNDIR)/Depth_list.nc + rm -rf $(RUNDIR)/RESTART + rm -f $(RUNDIR)/Vertical_coordinate.nc + rm -f $(RUNDIR)/available_diags.?????? + rm -f $(RUNDIR)/ave_prog__*.nc + rm -f $(RUNDIR)/cont__*.nc + rm -f $(RUNDIR)/exitcode + rm -f $(RUNDIR)/logfile.??????.out + rm -f $(RUNDIR)/ocean.stats + rm -f $(RUNDIR)/ocean.stats.nc + rm -f $(RUNDIR)/ocean_geometry.nc + rm -f $(RUNDIR)/prog__*.nc + rm -f $(RUNDIR)/time_stamp.out +endef +$(foreach expt,$(EXPTS),$(eval $(call EXPT_RULE,$(expt)))) + +#---- + +.PHONY: clean +clean: + rm -rf $(BUILD) + +.PHONY: clean.runs +clean.runs: $(foreach e,$(EXPTS),clean.$(e)) diff --git a/ocean_only/Makefile b/ocean_only/Makefile new file mode 100644 index 0000000000..d5745fa060 --- /dev/null +++ b/ocean_only/Makefile @@ -0,0 +1,228 @@ +# Build configuration +BUILD ?= build +MOM_MEMORY ?= + +# Dependencies +FMS_BUILD ?= ../shared/fms/$(BUILD) + +# Autoconf configuration +CODEBASE ?= ../src/MOM6 +MAKEFILE_IN ?= $(CODEBASE)/ac/Makefile.in +CONFIGURE_AC ?= $(CODEBASE)/ac/configure.ac +M4DIR ?= $(CODEBASE)/ac/m4 +MAKEDEP ?= $(CODEBASE)/ac/makedep + +# Run configuration +EXPT ?= +OUTPUT ?= ./$(EXPT) +LAUNCHER ?= mpirun +# The following are either too large or appear to be broken. +EXCLUDE ?= \ + tides_025 \ + ISOMIP/% \ + MESO_025_% \ + rotating_gravity_current/% \ + buoy_forced_basin + + +# Autoconf setup +CONFIG_FLAGS := --config-cache +CONFIG_FLAGS += --srcdir=$(abspath $(CODEBASE))/ac +ifdef MOM_MEMORY + CONFIG_FLAGS += MOM_MEMORY=$(abspath $(MOM_MEMORY)) +endif + +# NOTE: `export FCFLAGS` overwrites the autoconf default. We restore it here. +FCFLAGS ?= -g -O2 + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +# Autoconf variables +export CPPFLAGS +export CC +export MPICC +export CFLAGS +export FC +export MPIFC +export FCFLAGS +export LDFLAGS +export LIBS +export PYTHON + + +# Makefile setup + +# Verify that BUILD is not set to the current directory +# (which would clobber this Makefile) +MAKEPATH = $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +ifeq ($(MAKEPATH), $(realpath $(BUILD))) + $(error BUILD cannot be set to the current directory) +endif + +# Disable builtin rules and variables +MAKEFLAGS += -rR + +#---- + +TARGET := MOM6 + +all: $(BUILD)/$(TARGET) + +$(BUILD)/$(TARGET): $(BUILD)/Makefile + $(MAKE) -C $(BUILD) $(TARGET) + +$(BUILD)/Makefile: $(FMS_BUILD)/libFMS.a +$(BUILD)/Makefile: $(BUILD)/Makefile.in $(BUILD)/configure + cd $(BUILD) && \ + PATH="${PATH}:$(dir $(abspath $(MAKEDEP)))" \ + ./configure $(CONFIG_FLAGS) + +$(BUILD)/Makefile.in: $(MAKEFILE_IN) | $(BUILD) + cp $(MAKEFILE_IN) $(BUILD)/Makefile.in + +$(BUILD)/configure: $(BUILD)/configure.ac $(BUILD)/m4 + autoreconf $(BUILD) + +$(BUILD)/configure.ac: $(CONFIGURE_AC) | $(BUILD) + cp $(CONFIGURE_AC) $(BUILD)/configure.ac + +$(BUILD)/m4: $(M4DIR) | $(BUILD) + cp -r $(M4DIR) $(BUILD) + +$(BUILD): + mkdir -p $(BUILD) + + +#---- +# Dependencies + +$(FMS_BUILD)/libFMS.a: + $(MAKE) -C ../shared/fms BUILD=$(BUILD) + + +#---- +# Experiments +# +# Experiment configuration +# (NOTE: This is probably going away) + +# NOTE: Static output may be produced alongside the configurations, so we +# assume the *.static format and exclude them from the manifests. +EXPT_MANIFEST := $(patsubst ./%/,%,\ + $(dir $(shell find . -name MOM_parameter_doc.all -not -path "*/*.static/*"))) +STATIC_EXPTS := $(patsubst ./%/,%,\ + $(dir $(shell find . -name MOM_memory.h -not -path "*/*.static/*"))) + +# Filter out the undesired experiments +EXPTS := $(filter-out $(EXCLUDE),$(EXPT_MANIFEST)) + +GET_NPROCS := $(abspath ../shared/tools/get_nprocs.sh) + +# List of potential input files +# TODO: Generate this from input.nml +INPUT_FILESET = \ + input.nml \ + MOM_input \ + MOM_override \ + diag_table \ + data_table \ + field_table \ + INPUT + +MANIFEST=$(notdir $(wildcard $(foreach f,$(INPUT_FILESET),$(EXPT)/$f))) + +.PHONY: run +run: $(OUTPUT)/ocean.stats + +.PHONY: ./ocean.stats +./ocean.stats: + @echo "Please specify the experiment to run. For example:" + @echo " make run EXPT=double_gyre" + @echo " make run.double_gyre" + +run.%: + $(MAKE) EXPT=$* run + +%/ocean.stats: $(BUILD)/$(TARGET) $(foreach f,$(MANIFEST),%/$f) | % + mkdir -p $(@D)/RESTART + cd $(@D) && $(LAUNCHER) -np $$($(GET_NPROCS) $(abspath $(@D))) $(abspath $(BUILD)/$(TARGET)) + +ifneq ($(realpath $(EXPT)), $(realpath $(OUTPUT))) +define copy +$(OUTPUT)/$(1): $(EXPT)/$(1) | $(OUTPUT) + cp -p $$^ $$@ +endef +$(foreach f,$(MANIFEST),$(eval $(call copy,$f))) +endif + +# TODO: Symlink will cause issues with restart runs +$(OUTPUT)/INPUT: $(EXPT)/INPUT | $(OUTPUT) + if [ -e $< ]; then ln -s $(abspath $^) $@ ; fi + +$(OUTPUT): + mkdir -p $@ + + +#.PHONY: run.all +#run.all: $(foreach e,$(EXPTS),run.$(e)) + +## Support macros +#RUNDIR = $(if $(OUTPUT),$(OUTPUT),.) +# +## MOM6 output +#MOM_OUTPUT = \ +# available_diags.?????? \ +# CPU_stats \ +# Depth_list.nc \ +# exitcode \ +# Vertical_coordinate.nc \ +# logfile.??????.out \ +# ocean.stats \ +# ocean.stats.nc \ +# ocean_geometry.nc \ +# time_stamp.out +# +## TODO: generate the diagnostic output files. For now we just guess. +#MOM_OUTPUT += \ +# ave_prog__*.nc \ +# cont__*.nc \ +# prog__*.nc + +## $(1): Experiment directory / name +#define EXPT_RULE +# +#.PHONY: run.$(1) +#run.$(1): $(RUNDIR)/$(1)/ocean.stats | $(RUNDIR)/$(1) +# +#$(RUNDIR)/$(1)/ocean.stats: $(BUILD)/$(TARGET) $(RUNDIR)/$(1)/input.nml +# mkdir -p $(RUNDIR)/$(1)/RESTART +# cd $(RUNDIR)/$(1) && $(LAUNCHER) -n $(NPROCS) $(abspath $(BUILD)/$(TARGET)) +# +#$(RUNDIR)/$(1)/input.nml: | $(RUNDIR)/$(1) +# cp -r $(1)/* $(RUNDIR)/$(1)/ +# +#$(RUNDIR)/$(1): +# mkdir -p $(RUNDIR)/$(1) +# +#.PHONY: clean.$(1) +#clean.$(1): +# if [ $(realpath $(RUNDIR)/$(1)) != $(realpath ./$(1)) ]; then \ +# rm -rf $(RUNDIR)/$(1); \ +# else \ +# rm -f $(addprefix $(1)/,${MOM_OUTPUT}); \ +# rm -rf $(1)/RESTART; \ +# fi +#endef +#$(foreach e,$(EXPTS),$(eval $(call EXPT_RULE,$(e)))) + + +#---- +# Cleanup + +.PHONY: clean +clean: + rm -rf $(BUILD) + +.PHONY: clean.runs +clean.runs: $(foreach e,$(EXPTS),clean.$(e)) diff --git a/shared/AM2/Makefile b/shared/AM2/Makefile new file mode 100644 index 0000000000..82841e0d31 --- /dev/null +++ b/shared/AM2/Makefile @@ -0,0 +1,39 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +TARGET = libAM2.a +CODEBASE = ../../src/AM2 +CONFIGURE_AC = ../config/configure.AM2.ac +M4DIR = ../../src/MOM6/ac/deps/m4 +SRCDIRS = $(addprefix $(abspath $(CODEBASE))/, \ + $(addprefix atmos_fv_dynamics/,driver/coupled model tools) \ + atmos_drivers/coupled \ + atmos_shared_am3 \ + atmos_param_am3) + +CPPFLAGS += -Duse_AM3_physics -DSPMD + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +FCFLAGS += -I$(abspath ../../src/FMS/include) + +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk + +#---- +# External Codebase +# NOTE: These are only visible within the GFDL firewall + +$(BUILD)/configure: | $(CODEBASE) + +$(CODEBASE): + mkdir -p $@ + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/atmos_shared_am3.git + git -C $@/atmos_shared_am3 checkout warsaw_201803 + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/atmos_drivers.git + git -C $@/atmos_drivers checkout warsaw_201803 + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/atmos_fv_dynamics.git + git -C $@/atmos_fv_dynamics checkout warsaw_201803 + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/atmos_param_am3.git + git -C $@/atmos_param_am3 checkout warsaw_201803 diff --git a/shared/LM3/Makefile b/shared/LM3/Makefile new file mode 100644 index 0000000000..3b485ef283 --- /dev/null +++ b/shared/LM3/Makefile @@ -0,0 +1,32 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +LM3_SRC ?= ../../src/LM3 + +TARGET = libLM3.a +CODEBASE = ../../src/LM3 +CONFIGURE_AC = ../config/configure.LM3.ac +M4DIR = ../../src/MOM6/ac/deps/m4 + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk + +#---- +# External Codebase +# NOTE: These are only visible within the GFDL firewall + +$(BUILD)/configure: | $(LM3_SRC) + +$(LM3_SRC): + mkdir -p $@ + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/land_param.git + git -C $@/land_param checkout xanadu + git -C $@ clone http://gitlab.gfdl.noaa.gov/fms/land_lad2.git + git -C $@/land_lad2 checkout verona_201701 + find $@/land_lad2 -type f -name \*.F90 \ + -exec cpp -Duse_libMPI -Duse_netCDF -DSPMD -Duse_LARGEFILE -C -nostdinc -v -I ../../src/FMS/include -o '{}'.cpp {} \; + find $@/land_lad2 -type f -name \*.F90.cpp -exec rename .F90.cpp .f90 {} \; + find $@/land_lad2 -type f -name \*.F90 -exec rename .F90 .F90_preCPP {} \; diff --git a/shared/atmos_null/Makefile b/shared/atmos_null/Makefile new file mode 100644 index 0000000000..d6ee9e9749 --- /dev/null +++ b/shared/atmos_null/Makefile @@ -0,0 +1,12 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +TARGET = libatmos_null.a +CODEBASE = ../../src/atmos_null +CONFIGURE_AC = ../config/configure.atmos_null.ac + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk diff --git a/shared/config/Libs.mk b/shared/config/Libs.mk new file mode 100644 index 0000000000..194c5b84ba --- /dev/null +++ b/shared/config/Libs.mk @@ -0,0 +1,63 @@ +# Configuration +BUILD ?= +TARGET ?= +CODEBASE ?= +MAKEFILE_IN ?= ../config/Makefile.in +CONFIGURE_AC ?= + +# Potentially configurabe, but not yet sure if we want to allow this. +MAKEPATH = $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))) +M4DIR ?= $(MAKEPATH)/../../src/MOM6/ac/m4 +MAKEDEP = $(MAKEPATH)/../../src/MOM6/ac/makedep + +# Autoconf configuration +export CPPFLAGS +export CC +export MPICC +export CFLAGS +export FC +export MPIFC +export FCFLAGS +export LDFLAGS +export LIBS +export PYTHON +export SRCDIRS + +# Verify that BUILD is not set to the current directory (which would clobber this Makefile) +ifeq ($(MAKEPATH), $(realpath $(BUILD))) + $(error BUILD cannot be set to the current directory) +endif + +# Disable builtin rules and variables +MAKEFLAGS += -rR + +#---- + +all: $(BUILD)/$(TARGET) + +$(BUILD)/$(TARGET): $(BUILD)/Makefile + $(MAKE) -C $(BUILD) $(TARGET) + +$(BUILD)/Makefile: $(BUILD)/Makefile.in $(BUILD)/configure + cd $(BUILD) && \ + PATH="${PATH}:$(dir $(abspath $(MAKEDEP)))" \ + ./configure \ + --srcdir=$(abspath $(CODEBASE)) \ + --config-cache + +$(BUILD)/Makefile.in: $(MAKEFILE_IN) | $(BUILD) + cp $(MAKEFILE_IN) $(BUILD)/Makefile.in + +$(BUILD)/configure: $(BUILD)/configure.ac + autoreconf $(BUILD) + +$(BUILD)/configure.ac: $(CONFIGURE_AC) | $(BUILD) + cp $(CONFIGURE_AC) $(BUILD)/configure.ac + cp -r $(M4DIR) $(BUILD) + +$(BUILD): + mkdir -p $@ + +.PHONY: clean +clean: + rm -rf $(BUILD) diff --git a/shared/config/Makefile.in b/shared/config/Makefile.in new file mode 100644 index 0000000000..db81684528 --- /dev/null +++ b/shared/config/Makefile.in @@ -0,0 +1,35 @@ +# Makefile template for FMS +# +# Compiler flags are configured by autoconf's configure script. +# +# Source code dependencies are configured by makedep and saved to Makefile.dep. + +# Autoconf / Makedep configuration +DEFS = @DEFS@ +CPPFLAGS = @CPPFLAGS@ +CC = @CC@ +CFLAGS = @CFLAGS@ +FC = @FC@ +FCFLAGS = @FCFLAGS@ +LD = @FC@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +AR = @AR@ +ARFLAGS = @ARFLAGS@ + +# Makedep support +PYTHON = @PYTHON@ +MAKEDEP = @MAKEDEP@ + +# Target library, to be configured by the user +LIBTARGET = @LIBTARGET@ + +# Directories used to generate Makefile.dep +SRCDIRS = @SRCDIRS@ + +-include Makefile.dep + +.PHONY: depend +depend: Makefile.dep +Makefile.dep: + $(PYTHON) $(MAKEDEP) -o Makefile.dep -e -x $(LIBTARGET) $(SRCDIRS) diff --git a/shared/config/configure.AM2.ac b/shared/config/configure.AM2.ac new file mode 100644 index 0000000000..8da53f1d13 --- /dev/null +++ b/shared/config/configure.AM2.ac @@ -0,0 +1,163 @@ +AC_INIT([AM2], []) + +AC_CONFIG_SRCDIR([atmos_drivers/coupled/atmos_model.F90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + +# Unlimited line length +# NOTE: AC_FC_LINE_LENGTH was added in 2.67. +m4_version_prereq([2.67], + [AC_FC_LINE_LENGTH([unlimited])], + [AX_FC_LINE_LENGTH([unlimited])] +) + +# Allow argument mismatch (for functions lacking interfaces) +AX_FC_ALLOW_ARG_MISMATCH +FCFLAGS="$FCFLAGS $ALLOW_ARG_MISMATCH_FCFLAGS" + +# Enable Cray pointers +AX_FC_CRAY_POINTER + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libAM2.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/config/configure.LM3.ac b/shared/config/configure.LM3.ac new file mode 100644 index 0000000000..ad2af3e681 --- /dev/null +++ b/shared/config/configure.LM3.ac @@ -0,0 +1,163 @@ +AC_INIT([LM3], []) + +AC_CONFIG_SRCDIR([land_lad2/land_model.f90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) + +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# Unlimited line length (2.67) +# AC_FC_LINE_LENGTH was added in 2.67. +m4_version_prereq([2.67], + [AC_FC_LINE_LENGTH([unlimited])], + [AX_FC_LINE_LENGTH([unlimited])] +) + + +# Allow argument mismatch (for functions lacking interfaces) +AX_FC_ALLOW_ARG_MISMATCH +FCFLAGS="$FCFLAGS $ALLOW_ARG_MISMATCH_FCFLAGS" + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libLM3.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/config/configure.atmos_null.ac b/shared/config/configure.atmos_null.ac new file mode 100644 index 0000000000..94bafef14c --- /dev/null +++ b/shared/config/configure.atmos_null.ac @@ -0,0 +1,149 @@ +AC_INIT([atmos_null], []) + +AC_CONFIG_SRCDIR([atmos_model.F90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libatmos_null.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/config/configure.ice_param.ac b/shared/config/configure.ice_param.ac new file mode 100644 index 0000000000..1fcb665072 --- /dev/null +++ b/shared/config/configure.ice_param.ac @@ -0,0 +1,149 @@ +AC_INIT([ice_param], []) + +AC_CONFIG_SRCDIR([ice_albedo.F90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libice_param.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/config/configure.icebergs.ac b/shared/config/configure.icebergs.ac new file mode 100644 index 0000000000..9d929ebbca --- /dev/null +++ b/shared/config/configure.icebergs.ac @@ -0,0 +1,157 @@ +AC_INIT([icebergs], []) + +AC_CONFIG_SRCDIR([icebergs.F90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# Unlimited line length (2.67) +# AC_FC_LINE_LENGTH was added in 2.67. +m4_version_prereq([2.67], + [AC_FC_LINE_LENGTH([unlimited])], + [AX_FC_LINE_LENGTH([unlimited])] +) + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libicebergs.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/config/configure.land_null.ac b/shared/config/configure.land_null.ac new file mode 100644 index 0000000000..2e5e2ba49d --- /dev/null +++ b/shared/config/configure.land_null.ac @@ -0,0 +1,149 @@ +AC_INIT([land_null], []) + +AC_CONFIG_SRCDIR([land_model.F90]) +AC_CONFIG_MACRO_DIR([m4]) + +AC_LANG([Fortran]) +AC_FC_SRCEXT([f90]) +AX_MPI([], [ + AC_MSG_ERROR([Could not find MPI launcher.]) +]) +AC_SUBST(FC, $MPIFC) +AC_SUBST(LD, $MPIFC) + + +# netCDF configuration + +# Search for the Fortran netCDF module. +AX_FC_CHECK_MODULE([netcdf], [], [ + AS_UNSET([ax_fc_cv_mod_netcdf]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([FCFLAGS], ["$FCFLAGS -I$($NF_CONFIG --includedir)"]) + ], [AC_MSG_ERROR([Could not find nf-config.])] + ) + AX_FC_CHECK_MODULE([netcdf], [], [ + AC_MSG_ERROR([Could not find netcdf module.]) + ]) +]) + +# Confirm that the Fortran compiler can link the netCDF C library +AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AS_UNSET([ax_fc_cv_c_lib_netcdf_nc_create]) + AC_PATH_PROG([NC_CONFIG], [nc-config]) + AS_IF([test -n "$NC_CONFIG"], [ + AC_SUBST([LDFLAGS], ["$LDFLAGS -L$($NC_CONFIG --libdir)"]) + ], [ + AC_MSG_ERROR([Could not find nc-config.]) + ]) + AX_FC_CHECK_C_LIB([netcdf], [nc_create], [], [ + AC_MSG_ERROR([Could not find netCDF C library.]) + ]) +]) + +# Confirm that the Fortran compiler can link to the netCDF Fortran library. +# NOTE: +# - We test nf_create, rather than nf90_create, since AX_FC_CHECK_LIB can +# not currently probe the Fortran 90 interfaces. +# - nf-config does not have --libdir, so we parse the --flibs output. +AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AS_UNSET([ax_fc_cv_lib_netcdff_nf_create]) + AC_PATH_PROG([NF_CONFIG], [nf-config]) + AS_IF([test -n "$NF_CONFIG"], [ + AC_SUBST([LDFLAGS], + ["$LDFLAGS $($NF_CONFIG --flibs | xargs -n1 | grep "^-L" | sort -u | xargs)"] + ) + ], [ + AC_MSG_ERROR([Could not find nf-config.]) + ]) + AX_FC_CHECK_LIB([netcdff], [nf_create], [], [], [ + AC_MSG_ERROR([Could not find netCDF Fortran library.]) + ]) +]) + + +# Force 8-byte reals +AX_FC_REAL8 +AS_IF( + [test "$enable_real8" != no], + [FCFLAGS="$FCFLAGS $REAL8_FCFLAGS"]) + + +# FMS support + +# Test for fms_mod to verify FMS module access +AX_FC_CHECK_MODULE([fms_mod], [], [ + AS_UNSET([ax_fc_cv_mod_fms_mod]) + AX_FC_CHECK_MODULE([fms_mod], + [AC_SUBST([FCFLAGS], ["-I${srcdir}/ac/deps/include $FCFLAGS"])], + [AC_MSG_ERROR([Could not find fms_mod Fortran module.])], + [-I${srcdir}/ac/deps/include]) +]) + +# Test for fms_init to verify FMS library linking +AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], + [], [ + AS_UNSET([ax_fc_cv_lib_FMS_fms_init]) + AX_FC_CHECK_LIB([FMS], [fms_init], [fms_mod], [ + AC_SUBST([LDFLAGS], ["-L${srcdir}/ac/deps/lib $LDFLAGS"]) + AC_SUBST([LIBS], ["-lFMS $LIBS"]) + ], + [AC_MSG_ERROR([Could not find FMS library.])], + [-L${srcdir}/ac/deps/lib]) + ] +) + +# 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 +# - position values NORTH, EAST, CENTER were added to diag_axis_mod +# For our versioning test, we check the second feature. +AC_MSG_CHECKING([if diag_axis_mod supports domain positions]) +AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], [use diag_axis_mod, only: NORTH, EAST, CENTER])], + [AC_MSG_RESULT([yes])], + [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([diag_axis_mod in MOM6 requires FMS 2019.01.02 or newer.]) + ] +) + + +# Verify that Python is available +AC_PATH_PROGS([PYTHON], [python python3 python2], [ + AC_MSG_ERROR([Could not find python.]) +]) +AC_ARG_VAR([PYTHON], [Python interpreter command]) + + +# Verify that makedep is available +AC_PATH_PROGS([MAKEDEP], [makedep], [], ["${PATH}:${srcdir}/../MOM6/ac"]) +AS_IF([test -n "${MAKEDEP}"], [ + AC_SUBST([MAKEDEP]) +], [ + AC_MSG_ERROR(["Could not find makedep."]) +]) + +# Autoconf does not configure the archiver (ar), as it is handled by Automake. +# TODO: Properly configure this tool. For now, we hard-set this to `ar`. +AR=ar +ARFLAGS=rv +AC_SUBST([AR]) +AC_SUBST([ARFLAGS]) + +# Generate source list and configure dependency command +SRCDIRS="${SRCDIRS:-${srcdir}}" +AC_SUBST([SRCDIRS]) +AC_CONFIG_COMMANDS([Makefile.dep], [make depend]) + +# Populate the unused config parameters +AC_SUBST([CPPFLAGS]) +AC_SUBST([CC]) +AC_SUBST([CFLAGS]) + +LIBTARGET=libland_null.a +AC_SUBST([LIBTARGET]) + +# Prepare output +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/shared/fms/Makefile b/shared/fms/Makefile new file mode 100644 index 0000000000..e626737fd0 --- /dev/null +++ b/shared/fms/Makefile @@ -0,0 +1,14 @@ +# Configuration +BUILD ?= build + +CODEBASE = ../../src/FMS +TARGET = libFMS.a +MAKEFILE_IN = ../../src/MOM6/ac/deps/Makefile.fms.in +CONFIGURE_AC = ../../src/MOM6/ac/deps/configure.fms.ac +M4DIR = ../../src/MOM6/ac/deps/m4 + +# These are required by the FMS2 test suite +CPPFLAGS += -DAU_TEST_KIND_=r8_kind +CPPFLAGS += -DTEST_SVP_KIND_=8 + +include ../config/Libs.mk diff --git a/shared/ice_param/Makefile b/shared/ice_param/Makefile new file mode 100644 index 0000000000..67cc847fef --- /dev/null +++ b/shared/ice_param/Makefile @@ -0,0 +1,12 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +CODEBASE = ../../src/ice_param +TARGET = libice_param.a +CONFIGURE_AC = ../config/configure.ice_param.ac + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk diff --git a/shared/icebergs/Makefile b/shared/icebergs/Makefile new file mode 100644 index 0000000000..2e29cd8bc7 --- /dev/null +++ b/shared/icebergs/Makefile @@ -0,0 +1,12 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +CODEBASE = ../../src/icebergs/src +TARGET = libicebergs.a +CONFIGURE_AC = ../config/configure.icebergs.ac + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk diff --git a/shared/land_null/Makefile b/shared/land_null/Makefile new file mode 100644 index 0000000000..1966eea06b --- /dev/null +++ b/shared/land_null/Makefile @@ -0,0 +1,12 @@ +# Configuration +BUILD ?= build +FMS_BUILD ?= ../fms/$(BUILD) + +TARGET = libland_null.a +CODEBASE = ../../src/land_null +CONFIGURE_AC = ../config/configure.land_null.ac + +FCFLAGS += -I$(abspath $(FMS_BUILD)) +LDFLAGS += -L$(abspath $(FMS_BUILD)) + +include ../config/Libs.mk diff --git a/shared/tools/get_nprocs.sh b/shared/tools/get_nprocs.sh new file mode 100755 index 0000000000..2935395097 --- /dev/null +++ b/shared/tools/get_nprocs.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +nx=$(grep -oP "(?<=^NIPROC = )[0-9]*" $1/MOM_parameter_doc.layout) +ny=$(grep -oP "(?<=^NJPROC = )[0-9]*" $1/MOM_parameter_doc.layout) + +masktable=INPUT/$(grep -oP "(?<=^MASKTABLE = \")[^\"]*" $1/MOM_parameter_doc.layout) +if [ -f ${masktable} ]; then + read -r nmask < ${masktable} +else + nmask=0 +fi + +np=$(( nx * ny - nmask )) + +echo $np