diff --git a/ccpp/CMakeLists.txt b/ccpp/CMakeLists.txt index 76abff272..760e09a8e 100644 --- a/ccpp/CMakeLists.txt +++ b/ccpp/CMakeLists.txt @@ -25,8 +25,6 @@ endif() # Set include directories for make, also set CCPP_... for external projects INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/framework/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/physics) -SET(CCPP_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/framework/src;${CMAKE_CURRENT_BINARY_DIR}/physics") -SET(CCPP_LIB_DIRS "${CMAKE_CURRENT_BINARY_DIR}/framework/src;${CMAKE_CURRENT_BINARY_DIR}/physics") #------------------------------------------------------------------------------ # Generate Compiler flags for C/CXX/Fortran - set to match NEMSfv3gfs flags diff --git a/ccpp/build_ccpp.sh b/ccpp/build_ccpp.sh deleted file mode 100755 index 2e9aa9a11..000000000 --- a/ccpp/build_ccpp.sh +++ /dev/null @@ -1,193 +0,0 @@ -#!/bin/bash - -set +x -set -eu - -# List of valid/tested machines -VALID_MACHINES=( wcoss_cray wcoss_dell_p3 gaea.intel jet.intel \ - hera.intel hera.gnu orion.intel \ - cheyenne.intel cheyenne.gnu \ - endeavor.intel stampede.intel \ - macosx.gnu \ - linux.intel linux.gnu linux.pgi ) - -################################################################################################### - -function usage { - echo "Usage: " - echo "build_ccpp.sh MACHINE_ID CCPP_DIR CCPP_MK [ 'MAKE_OPT' ] [ clean_before ] [ clean_after ]" - echo " Where: MACHINE [required] can be : ${VALID_MACHINES[@]}" - echo " CCPP_DIR [required] is the target installation directory for CCPP" - echo " CCPP_MK [required] is the location/name of the CCPP ESMF makefile fragment" - echo " MAKE_OPT [optional] can be any of the NEMSfv3gfs MAKE_OPT options," - echo " enclosed in a single string; used:" - echo " SION=Y/N (default N)" - echo " DEBUG=Y/N (default N)" - echo " REPRO=Y/N (default N)" - echo " OPENMP=Y/N (default Y)" - echo " 32BIT=Y/N (default N, affects dynamics/fast physics only)" - echo " SUITES=ABC,XYZ (comma-separated list of CCPP suites; " - echo " corresponding filenames: suite_ABC.xml. ...)" - echo " MULTI_GASES=Y/N (default N)" - echo " clean_before [optional] can be 'YES' (default) or 'NO'" - echo " clean_after [optional] can be 'YES' (default) or 'NO'" - exit 1 -} - -function checkvalid { -# Ensure value ($2) of variable ($1) is contained in list of validvalues ($3) - if [ $# -lt 3 ]; then - echo $FUNCNAME requires at least 3 arguments: stopping - exit 1 - fi - - var_name=$1 && shift - input_val=$1 && shift - valid_vars=($@) - - for x in ${valid_vars[@]}; do - if [ "$input_val" == "$x" ]; then - echo "${var_name}=${input_val} is valid." - return - fi - done - echo "ERROR: ${var_name}=${input_val} is invalid." - usage - exit 1 -} - -function trim { - local var="$1" - # remove leading whitespace characters - var="${var#"${var%%[![:space:]]*}"}" - # remove trailing whitespace characters - var="${var%"${var##*[![:space:]]}"}" - echo -n "$var" -} - -################################################################################################### - -# Check and process command line arguments - -if [[ $# -lt 2 ]]; then usage; fi - -readonly MACHINE_ID=$1 -readonly CCPP_DIR=$2 -readonly CCPP_MK=$3 -readonly MAKE_OPT=${4:-} -readonly clean_before=${5:-YES} -readonly clean_after=${6:-YES} - -checkvalid MACHINE_ID $MACHINE_ID ${VALID_MACHINES[@]} - -# Set compilers for cmake -source ./set_compilers.sh - -# Obtain ESMF_LIB from ESMFMKFILE's ESMF_LIBSDIR entry -readonly ESMF_LIB=$(cat $ESMFMKFILE | grep -E '^ESMF_LIBSDIR=.+' | cut -d = -f 2) -echo "Obtained ESMF_LIB=${ESMF_LIB} from ${ESMFMKFILE}" - -# Account for inconsistencies in HPC modules: if environment variable -# NETCDF is undefined, try to set from NETCDF_DIR, NETCDF_ROOT, ... -if [[ "${MACHINE_ID}" == "wcoss_cray" || "${MACHINE_ID}" == "gaea.intel" ]]; then - NETCDF=${NETCDF:-${NETCDF_DIR}} -fi - -# Generate CCPP cmake flags from MAKE_OPT -CCPP_CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=${CCPP_DIR} -DNETCDF_DIR=${NETCDF} -DMPI=ON" -CCPP_MAKE_FLAGS="" -if [[ "${MAKE_OPT}" == *"SION=Y"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DSIONLIB=${SIONLIB}" -fi -if [[ "${MAKE_OPT}" == *"DEBUG=Y"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Debug" - CCPP_MAKE_FLAGS="${CCPP_MAKE_FLAGS} VERBOSE=1" -elif [[ "${MAKE_OPT}" == *"REPRO=Y"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Bitforbit" - CCPP_MAKE_FLAGS="${CCPP_MAKE_FLAGS} VERBOSE=1" -else - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DCMAKE_BUILD_TYPE=Release" - # Don't use the AVX512 flags yet on hera - #if [[ "${MACHINE_ID}" == "jet.intel" || "${MACHINE_ID}" == "hera.intel" ]]; then - if [[ "${MACHINE_ID}" == "jet.intel" ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DSIMDMULTIARCH=ON" - fi - CCPP_MAKE_FLAGS="${CCPP_MAKE_FLAGS} VERBOSE=1" -fi -if [[ "${MAKE_OPT}" == *"OPENMP=N"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DOPENMP=OFF" -else - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DOPENMP=ON" -fi -if [[ "${MAKE_OPT}" == *"32BIT=Y"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DDYN32=ON" -else - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DDYN32=OFF" -fi -if [[ "${MAKE_OPT}" == *"MULTI_GASES=Y"* ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DMULTI_GASES=ON" -else - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DMULTI_GASES=OFF" -fi - -# Flag to cmake that modern Intel compilers are used -CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLEGACY_INTEL=OFF" - -# Generate additional CCPP cmake flags depending on machine / compiler -if [[ "${MACHINE_ID}" == "macosx.gnu" ]]; then - # Intel MKL (for FFTW) - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DMKL_DIR=${MKL_DIR}" - # ESMF (for DGEMM) - replace with MKL version in the future? - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DESMF_LIB_DIR=${ESMF_LIB}" - # netCDF (needed when linking ESMF) - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DNETCDF_DIR=${NETCDF}" -elif [[ "${MACHINE_ID}" == "linux.gnu" ]]; then - # ESMF (for DGEMM) - replace with MKL version in the future? - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DESMF_LIB_DIR=${ESMF_LIB}" - # netCDF (needed when linking ESMF) - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DNETCDF_DIR=${NETCDF}" -elif [[ "${MACHINE_ID}" == "gaea.intel" || "${MACHINE_ID}" == "wcoss_cray" ]]; then - # Fix broken libxml2 installation on gaea by - # using own version (not known to the system) - if [[ "${MACHINE_ID}" == "gaea.intel" ]]; then - CCPP_CMAKE_FLAGS="${CCPP_CMAKE_FLAGS} -DLIBXML2_LIB_DIR=${LIBXML2_LIB_DIR} -DLIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}" - fi -fi - -CCPP_CMAKE_FLAGS=$(trim "${CCPP_CMAKE_FLAGS}") -CCPP_MAKE_FLAGS=$(trim "${CCPP_MAKE_FLAGS}") - -# Build and install CCPP - -echo "Building CCPP with options '${CCPP_CMAKE_FLAGS}' ..." -PATH_CCPP=${PWD} -PATH_CCPP_BUILD=${PWD}/build -PATH_CCPP_INC=${PWD}/include -PATH_CCPP_LIB=${PWD}/lib - -if [ $clean_before = YES ]; then - rm -fr ${PATH_CCPP_BUILD} - rm -fr ${PATH_CCPP_INC} - rm -fr ${PATH_CCPP_LIB} - rm -f ${CCPP_MK} -fi -mkdir -p ${PATH_CCPP_BUILD} -cd ${PATH_CCPP_BUILD} -cmake ${CCPP_CMAKE_FLAGS} ${PATH_CCPP} -make ${CCPP_MAKE_FLAGS} -make ${CCPP_MAKE_FLAGS} install - -# Generate ESMF makefile fragment - -set -u - -# Set linker flags -CCPP_LINK_OBJS="-L${PATH_CCPP_LIB} -lccpp -lccppphys" - -echo "ESMF_DEP_INCPATH=${PATH_CCPP_INC} ${PATH_CCPP_BUILD}/physics" > ${CCPP_MK} -echo "ESMF_DEP_LINK_OBJS=${CCPP_LINK_OBJS}" >> ${CCPP_MK} - -if [ $clean_after = YES ]; then - rm -fr ${PATH_CCPP_BUILD} -fi - diff --git a/ccpp/driver/makefile b/ccpp/driver/makefile deleted file mode 100644 index c64441135..000000000 --- a/ccpp/driver/makefile +++ /dev/null @@ -1,71 +0,0 @@ -SHELL = /bin/sh - -inside_nems := $(wildcard ../../../conf/configure.nems) -ifneq ($(strip $(inside_nems)),) - include ../../../conf/configure.nems -else - exist_configure_fv3 := $(wildcard ../../conf/configure.fv3) - ifneq ($(strip $(exist_configure_fv3)),) - include ../../conf/configure.fv3 - else - $(error "../../conf/configure.fv3 file is missing. Run ./configure") - endif - $(info ) - $(info Build CCPP layer ...) - $(info ) -endif - -CCPP_DRIVER = CCPP_driver.F90 - -LIBRARY = libccppdriver.a - -# Needed for ccpp_data.mod, fv_arrays_mod.mod, ... -FFLAGS += -I$(FMS_DIR) -I../../gfsphysics -I../../atmos_cubed_sphere - -#CPPDEFS += -DNEW_TAUCTMAX -DSMALL_PE -DNEMS_GSM -DINTERNAL_FILE_NML - -# Set flags for 32-bit dynamics build -ifeq ($(DYN32),Y) -CPPDEFS += -DOVERLOAD_R4 -endif - -SRCS_F90 = \ - CCPP_driver.F90 - -SRCS_c = - -DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90) - -OBJS_f = $(SRCS_f:.f=.o) -OBJS_f90 = $(SRCS_f90:.f90=.o) -OBJS_F = $(SRCS_F:.F=.o) -OBJS_F90 = $(SRCS_F90:.F90=.o) -OBJS_c = $(SRCS_c:.c=.o) - -OBJS = $(OBJS_f) $(OBJS_f90) $(OBJS_F) $(OBJS_F90) $(OBJS_c) - -all default: depend $(LIBRARY) - -$(LIBRARY): $(OBJS) - $(AR) $(ARFLAGS) $@ $? - -# Do preprocessing of the CCPP driver in two steps to be -# able to look at the actual .f90 file that gets compiled -./CCPP_driver.o: ./CCPP_driver.F90 - $(CPP) $(CPPDEFS) $(CPPFLAGS) $< > $*.tmp.f90 - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $*.tmp.f90 -o $@ - -.PHONY: clean -clean: - @echo "Cleaning CCPP_layer ... " - @echo - $(RM) -f $(LIBRARY) *__genmod.f90 *.tmp.f90 *.o */*.o *.mod *.i90 *.lst *.i depend - -MKDEPENDS = ../../mkDepends.pl -include ../../conf/make.rules - -# do not include 'depend' file if the target contains string 'clean' -ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) - -include depend -endif - diff --git a/ccpp/set_compilers.sh b/ccpp/set_compilers.sh deleted file mode 100755 index 894017cb0..000000000 --- a/ccpp/set_compilers.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash - -# The list of compilers here must cover all system listed in build_ccpp.sh -> VALID_MACHINES -case "$MACHINE_ID" in - wcoss_cray) - export LD=ftn - export CC=cc - export CXX=CC - export FC=ftn - export F77=ftn - export F90=ftn - ;; - wcoss_dell_p3) - export CC=mpiicc - export CXX=mpiicpc - export FC=mpiifort - export F77=mpiifort - export F90=mpiifort - ;; - gaea.intel) - export LD=ftn - export CC=cc - export CXX=CC - export FC=ftn - export F77=ftn - export F90=ftn - ;; - jet.intel) - export CC=mpiicc - export CXX=mpiicpc - export FC=mpiifort - export F77=mpiifort - export F90=mpiifort - ;; - hera.intel) - export CC=mpiicc - export CXX=mpiicpc - export FC=mpiifort - export F77=mpiifort - export F90=mpiifort - ;; - hera.gnu) - export CC=mpicc - export CXX=mpicxx - export FC=mpif90 - export F77=mpif77 - export F90=mpif90 - ;; - orion.intel) - export CC=mpiicc - export CXX=mpiicpc - export FC=mpiifort - export F77=mpiifort - export F90=mpiifort - ;; - cheyenne.intel) - export CC=mpicc - export CXX=mpicxx - export FC=mpif90 - export F77=mpif77 - export F90=mpif90 - ;; - cheyenne.gnu) - export CC=mpicc - export CXX=mpicxx - export FC=mpif90 - export F77=mpif77 - export F90=mpif90 - ;; - endeavor.intel) - export CC=mpiicc - export CXX=mpiicpc - export FC=mpiifort - export F77=mpiifort - export F90=mpiifort - ;; - stampede.intel) - export CC=mpicc - export CXX=mpicxx - export FC=mpif90 - export F77=mpif77 - export F90=mpif90 - ;; - macosx.gnu) - # set in generic modulefile - ;; - linux.intel) - # set in generic modulefile - ;; - linux.gnu) - # set in generic modulefile - ;; - linux.pgi) - # set in generic modulefile - ;; - *) - echo "ERROR: MACHINE_ID ${MACHINE_ID} not configured in set_compilers.sh" - exit 1 -esac - -echo "Compilers set for ${MACHINE_ID}." diff --git a/ccpp/suites/suite_FV3_GFS_v16beta.xml b/ccpp/suites/suite_FV3_GFS_v16.xml similarity index 98% rename from ccpp/suites/suite_FV3_GFS_v16beta.xml rename to ccpp/suites/suite_FV3_GFS_v16.xml index 2ae5743fb..a7aab3689 100644 --- a/ccpp/suites/suite_FV3_GFS_v16beta.xml +++ b/ccpp/suites/suite_FV3_GFS_v16.xml @@ -1,6 +1,6 @@ - + diff --git a/ccpp/suites/suite_FV3_GFS_v16beta_RRTMGP.xml b/ccpp/suites/suite_FV3_GFS_v16_RRTMGP.xml similarity index 98% rename from ccpp/suites/suite_FV3_GFS_v16beta_RRTMGP.xml rename to ccpp/suites/suite_FV3_GFS_v16_RRTMGP.xml index fab16d294..92d040f6b 100644 --- a/ccpp/suites/suite_FV3_GFS_v16beta_RRTMGP.xml +++ b/ccpp/suites/suite_FV3_GFS_v16_RRTMGP.xml @@ -1,6 +1,6 @@ - + diff --git a/ccpp/suites/suite_FV3_GFS_v16beta_coupled.xml b/ccpp/suites/suite_FV3_GFS_v16_coupled.xml similarity index 98% rename from ccpp/suites/suite_FV3_GFS_v16beta_coupled.xml rename to ccpp/suites/suite_FV3_GFS_v16_coupled.xml index a131fb380..bb0fb859b 100644 --- a/ccpp/suites/suite_FV3_GFS_v16beta_coupled.xml +++ b/ccpp/suites/suite_FV3_GFS_v16_coupled.xml @@ -1,6 +1,6 @@ - + diff --git a/ccpp/suites/suite_FV3_GFS_v16beta_flake.xml b/ccpp/suites/suite_FV3_GFS_v16_flake.xml similarity index 98% rename from ccpp/suites/suite_FV3_GFS_v16beta_flake.xml rename to ccpp/suites/suite_FV3_GFS_v16_flake.xml index b7ac405ee..faf1a3f26 100644 --- a/ccpp/suites/suite_FV3_GFS_v16beta_flake.xml +++ b/ccpp/suites/suite_FV3_GFS_v16_flake.xml @@ -1,6 +1,6 @@ - + diff --git a/ccpp/suites/suite_FV3_GFS_v16beta_no_nsst.xml b/ccpp/suites/suite_FV3_GFS_v16_no_nsst.xml similarity index 98% rename from ccpp/suites/suite_FV3_GFS_v16beta_no_nsst.xml rename to ccpp/suites/suite_FV3_GFS_v16_no_nsst.xml index a73d1b561..52ff83969 100644 --- a/ccpp/suites/suite_FV3_GFS_v16beta_no_nsst.xml +++ b/ccpp/suites/suite_FV3_GFS_v16_no_nsst.xml @@ -1,6 +1,6 @@ - + diff --git a/conf/make.rules b/conf/make.rules deleted file mode 100644 index d01397bf4..000000000 --- a/conf/make.rules +++ /dev/null @@ -1,30 +0,0 @@ -.SUFFIXES: -.SUFFIXES: .F90 .f90 .F .f .o .c - -.F90.f90: - $(CPP) $(CPPFLAGS) $< > $*.f90 - -.F.f: - $(CPP) $(CPPFLAGS) $< > $*.f - -.f.o: - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $< -o $@ - -.f90.o: - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $< -o $@ - -.F.o: - $(FC) $(CPPDEFS) $(FPPFLAGS) $(FFLAGS) $(OTHER_FFLAGS) -c $< -o $@ - -.F90.o: - $(FC) $(CPPDEFS) $(FPPFLAGS) $(FFLAGS) $(OTHER_FFLAGS) -c $< -o $@ - -.c.o: - $(CC) $(CPPDEFS) $(CPPFLAGS) $(CFLAGS) $(OTHERFLAGS) $(OTHER_CFLAGS) -c $< -o $@ - -depend: $(DEPEND_FILES) makefile - @echo "Building dependencies ..." - @ls -1 $(DEPEND_FILES) > Srcfiles - @echo "." > Filepath - @$(MKDEPENDS) -m Filepath Srcfiles > depend - @$(RM) -f Filepath Srcfiles diff --git a/cpl/makefile b/cpl/makefile deleted file mode 100644 index f3aa91562..000000000 --- a/cpl/makefile +++ /dev/null @@ -1,66 +0,0 @@ -SHELL = /bin/sh - -inside_nems := $(wildcard ../../../conf/configure.nems) -ifneq ($(strip $(inside_nems)),) - include ../../../conf/configure.nems -else - exist_configure_fv3 := $(wildcard ../conf/configure.fv3) - ifneq ($(strip $(exist_configure_fv3)),) - include ../conf/configure.fv3 - else - $(error "../conf/configure.fv3 file is missing. Run ./configure") - endif - $(info ) - $(info Build standalone FV3 io ...) - $(info ) -endif - -LIBRARY = libfv3cpl.a - -#FFLAGS += -I$(FMS_DIR) - -SRCS_f = - -SRCS_f90 = - -SRCS_F = - -SRCS_F90 = ./module_cplfields.F90 \ - ./module_cap_cpl.F90 - -SRCS_c = - -DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90) - -OBJS_f = $(SRCS_f:.f=.o) -OBJS_f90 = $(SRCS_f90:.f90=.o) -OBJS_F = $(SRCS_F:.F=.o) -OBJS_F90 = $(SRCS_F90:.F90=.o) -OBJS_c = $(SRCS_c:.c=.o) - -OBJS = $(OBJS_f) $(OBJS_f90) $(OBJS_F) $(OBJS_F90) $(OBJS_c) - -all default: depend $(LIBRARY) - -$(LIBRARY): $(OBJS) - $(AR) $(ARFLAGS) $@ $? - -module_cplfields.o: module_cplfields.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_cplfields.F90 -module_cap_cpl.o: module_cap_cpl.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_cap_cpl.F90 - -.PHONY: clean -clean: - @echo "Cleaning io ... " - @echo - $(RM) -f $(LIBRARY) *.o *.mod *.lst *.i90 depend - -MKDEPENDS = ../mkDepends.pl -include ../conf/make.rules - -# do not include 'depend' file if the target contains string 'clean' -ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) - -include depend -endif - diff --git a/gfsphysics/makefile b/gfsphysics/makefile deleted file mode 100644 index 2ae58e317..000000000 --- a/gfsphysics/makefile +++ /dev/null @@ -1,273 +0,0 @@ -SHELL = /bin/sh - -inside_nems := $(wildcard ../../../conf/configure.nems) -ifneq ($(strip $(inside_nems)),) - include ../../../conf/configure.nems -else - exist_configure_fv3 := $(wildcard ../conf/configure.fv3) - ifneq ($(strip $(exist_configure_fv3)),) - include ../conf/configure.fv3 - else - $(error "../conf/configure.fv3 file is missing. Run ./configure") - endif - $(info ) - $(info Build standalone FV3 gfsphysics ...) - $(info ) -endif - -LIBRARY = libgfsphys.a - -FFLAGS += -I$(FMS_DIR) -I../cpl - -CPPDEFS += -DNEW_TAUCTMAX -DSMALL_PE -DNEMS_GSM -DINTERNAL_FILE_NML - -# CCPP build -ifneq (,$(findstring CCPP,$(CPPDEFS))) -# Set flags for 32-bit dynamics build -ifeq ($(DYN32),Y) -CPPDEFS += -DOVERLOAD_R4 -endif -CCPP_STATIC_API = ../ccpp/physics/ccpp_static_api.F90 - -# Set physics source files -# DH* 20190916 - can remove namelist_soilveg and set_soilveg -# once calculation of snocvr is moved from FV3GFS_io.F90/GFS_driver.F90 -# to CCPP (GFS_phys_time_vary.fv3.F90) *DH -SRCS_f = \ - ./physics/mersenne_twister.f \ - ./physics/namelist_soilveg.f \ - ./physics/physparam.f \ - ./physics/set_soilveg.f -SRCS_f90 = \ - ./physics/noahmp_tables.f90 -SRCS_F = -SRCS_F90 = \ - ./physics/GFDL_parse_tracers.F90 \ - ./physics/physcons.F90 \ - ./CCPP_layer/CCPP_data.F90 \ - $(CCPP_STATIC_API) \ - ./GFS_layer/GFS_abstraction_layer.F90 \ - ./GFS_layer/GFS_diagnostics.F90 \ - ./GFS_layer/GFS_driver.F90 \ - ./GFS_layer/GFS_restart.F90 -# non-CCPP build -else -SRCS_f = \ - ./physics/cnvc90.f \ - ./physics/co2hc.f \ - ./physics/date_def.f \ - ./physics/dcyc2.f \ - ./physics/dcyc2.pre.rad.f \ - ./physics/efield.f \ - ./physics/get_prs.f \ - ./physics/gocart_tracer_config_stub.f \ - ./physics/gscond.f \ - ./physics/gscondp.f \ - ./physics/gwdc.f \ - ./physics/gwdps.f \ - ./physics/ugwp_driver_v0.f \ - ./physics/cires_orowam2017.f \ - ./physics/h2o_def.f \ - ./physics/h2oc.f \ - ./physics/h2ohdc.f \ - ./physics/h2ophys.f \ - ./physics/ideaca.f \ - ./physics/idea_co2.f \ - ./physics/idea_composition.f \ - ./physics/idea_dissipation.f \ - ./physics/idea_h2o.f \ - ./physics/idea_ion.f \ - ./physics/idea_o2_o3.f \ - ./physics/idea_phys.f \ - ./physics/idea_solar_heating.f \ - ./physics/idea_tracer.f \ - ./physics/iounitdef.f \ - ./physics/lrgsclr.f \ - ./physics/mersenne_twister.f \ - ./physics/mfpbl.f \ - ./physics/mfpblt.f \ - ./physics/mfpbltq.f \ - ./physics/mfscu.f \ - ./physics/mfscuq.f \ - ./physics/module_bfmicrophysics.f \ - ./physics/moninedmf.f \ - ./physics/moninedmf_hafs.f \ - ./physics/moninp.f \ - ./physics/moninp1.f \ - ./physics/moninq.f \ - ./physics/moninq1.f \ - ./physics/moninshoc.f \ - ./physics/mstadb.f \ - ./physics/mstadbtn.f \ - ./physics/mstadbtn2.f \ - ./physics/mstcnv.f \ - ./physics/namelist_soilveg.f \ - ./physics/ozne_def.f \ - ./physics/iccn_def.f \ - ./physics/aerclm_def.f \ - ./physics/ozphys.f \ - ./physics/ozphys_2015.f \ - ./physics/physparam.f \ - ./physics/precpd.f \ - ./physics/precpd_shoc.f \ - ./physics/precpdp.f \ - ./physics/precpd_shoc.f \ - ./physics/progt2.f \ - ./physics/progtm_module.f \ - ./physics/rad_initialize.f \ - ./physics/radiation_aerosols.f \ - ./physics/radiation_astronomy.f \ - ./physics/radiation_clouds.f \ - ./physics/radiation_gases.f \ - ./physics/radiation_surface.f \ - ./physics/radlw_datatb.f \ - ./physics/radlw_main.f \ - ./physics/radlw_param.f \ - ./physics/radsw_datatb.f \ - ./physics/radsw_main.f \ - ./physics/radsw_param.f \ - ./physics/rascnvv2.f \ - ./physics/rayleigh_damp.f \ - ./physics/rayleigh_damp_mesopause.f \ - ./physics/samfaerosols.f \ - ./physics/samfdeepcnv.f \ - ./physics/samfshalcnv.f \ - ./physics/sascnv.f \ - ./physics/sascnvn.f \ - ./physics/satmedmfvdif.f \ - ./physics/satmedmfvdifq.f \ - ./physics/set_soilveg.f \ - ./physics/sfc_cice.f \ - ./physics/sfc_diag.f \ - ./physics/sfc_diff.f \ - ./physics/sfc_drv.f \ - ./physics/sfc_noahmp_drv.f \ - ./physics/sfc_nst.f \ - ./physics/sfc_ocean.f \ - ./physics/sfc_sice.f \ - ./physics/sflx.f \ - ./physics/shalcnv.f \ - ./physics/shalcv.f \ - ./physics/shalcv_1lyr.f \ - ./physics/shalcv_fixdp.f \ - ./physics/shalcv_opr.f \ - ./physics/tracer_const_h.f \ - ./physics/tridi2t3.f - -SRCS_f90 = \ - ./physics/calpreciptype.f90 \ - ./physics/funcphys.f90 \ - ./physics/gcm_shoc.f90 \ - ./physics/get_prs_fv3.f90 \ - ./physics/h2ointerp.f90 \ - ./physics/module_nst_model.f90 \ - ./physics/module_nst_parameters.f90 \ - ./physics/module_nst_water_prop.f90 \ - ./physics/ozinterp.f90 \ - ./physics/module_wrf_utl.f90 \ - ./physics/noahmp_tables.f90 \ - ./physics/module_sf_noahmplsm.f90 \ - ./physics/module_sf_noahmp_glacier.f90 \ - ./physics/iccninterp.f90 \ - ./physics/aerinterp.f90 \ - ./physics/wam_f107_kp_mod.f90 - -SRCS_F = \ - ./physics/aer_cloud.F \ - ./physics/cldmacro.F \ - ./physics/cldwat2m_micro.F \ - ./physics/gfs_phy_tracer_config.F \ - ./physics/machine.F \ - ./physics/num_parthds.F \ - ./physics/sfcsub.F \ - ./physics/wv_saturation.F - -SRCS_F90 = \ - ./physics/GFDL_parse_tracers.F90 \ - ./physics/gcycle.F90 \ - ./physics/cires_ugwp_initialize.F90 \ - ./physics/cires_ugwp_module.F90 \ - ./physics/cires_ugwp_utils.F90 \ - ./physics/cires_ugwp_triggers.F90 \ - ./physics/cires_ugwp_solvers.F90 \ - ./physics/cires_vert_lsatdis.F90 \ - ./physics/cires_vert_orodis.F90 \ - ./physics/cires_vert_wmsdis.F90 \ - ./physics/gfdl_cloud_microphys.F90 \ - ./physics/micro_mg_utils.F90 \ - ./physics/micro_mg2_0.F90 \ - ./physics/micro_mg3_0.F90 \ - ./physics/m_micro_driver.F90 \ - ./physics/cs_conv.F90 \ - ./physics/GFS_debug.F90 \ - ./physics/module_mp_radar.F90 \ - ./physics/module_mp_thompson_gfs.F90 \ - ./physics/module_mp_wsm6_fv3.F90 \ - ./physics/physcons.F90 \ - ./physics/surface_perturbation.F90 \ - ./GFS_layer/GFS_abstraction_layer.F90 \ - ./GFS_layer/GFS_diagnostics.F90 \ - ./GFS_layer/GFS_driver.F90 \ - ./GFS_layer/GFS_physics_driver.F90 \ - ./GFS_layer/GFS_radiation_driver.F90 \ - ./GFS_layer/GFS_restart.F90 \ - ./GFS_layer/GFS_typedefs.F90 -endif - -SRCS_c = - -DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90) - -OBJS_f = $(SRCS_f:.f=.o) -OBJS_f90 = $(SRCS_f90:.f90=.o) -OBJS_F = $(SRCS_F:.F=.o) -OBJS_F90 = $(SRCS_F90:.F90=.o) -OBJS_c = $(SRCS_c:.c=.o) - -OBJS = $(OBJS_f) $(OBJS_f90) $(OBJS_F) $(OBJS_F90) $(OBJS_c) - -all default: depend $(LIBRARY) - -$(LIBRARY): $(OBJS) - $(AR) $(ARFLAGS) $@ $? - -# this is the place to override default (implicit) compilation rules -# and create specific (explicit) rules - -# Reduce optimization (substitute (x)CORE-AVX2, (x)CORE-AVX512 or xHOST with (x)CORE-AVX-I) for radiation_aerosols.f -FFLAGS_LOPT1=$(subst CORE-AVX512,CORE-AVX-I,\ - $(subst CORE-AVX2,CORE-AVX-I,\ - $(subst xHOST,xCORE-AVX-I,$(FFLAGS)))) -./physics/radiation_aerosols.o : ./physics/radiation_aerosols.f - $(FC) $(CPPDEFS) $(FFLAGS_LOPT1) $(OTHER_FFLAGS) -c $< -o $@ - -# Reduce optimization (add -O0) for GFS_diagnsostics.F90 -./GFS_layer/GFS_diagnostics.o : ./GFS_layer/GFS_diagnostics.F90 - $(FC) $(CPPDEFS) $(FFLAGS) $(OTHER_FFLAGS) -O0 -c $< -o $@ - -# Do preprocessing of the GFS drivers in two steps to be able -# to look at the actual .f90 file that is compiled -./GFS_layer/GFS_driver.o: ./GFS_layer/GFS_driver.F90 - $(CPP) $(CPPDEFS) $(CPPFLAGS) $< > $*.tmp.f90 - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $*.tmp.f90 -o $@ -./GFS_layer/GFS_physics_driver.o: ./GFS_layer/GFS_physics_driver.F90 - $(CPP) $(CPPDEFS) $(CPPFLAGS) $< > $*.tmp.f90 - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $*.tmp.f90 -o $@ -./GFS_layer/GFS_radiation_driver.o: ./GFS_layer/GFS_radiation_driver.F90 - $(CPP) $(CPPDEFS) $(CPPFLAGS) $< > $*.tmp.f90 - $(FC) $(FFLAGS) $(OTHER_FFLAGS) -c $*.tmp.f90 -o $@ - -.PHONY: clean -clean: - @echo "Cleaning gfsphysics ... " - @echo - $(RM) -f $(LIBRARY) *__genmod.f90 *.o */*.o *.mod *.i90 *.lst *.i depend */*.tmp.f90 - -MKDEPENDS = ../mkDepends.pl -include ../conf/make.rules - -# do not include 'depend' file if the target contains string 'clean' -ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) - -include depend -endif - diff --git a/io/makefile b/io/makefile deleted file mode 100644 index 99a0dbdce..000000000 --- a/io/makefile +++ /dev/null @@ -1,101 +0,0 @@ -SHELL = /bin/sh - -inside_nems := $(wildcard ../../../conf/configure.nems) -ifneq ($(strip $(inside_nems)),) - include ../../../conf/configure.nems -else - exist_configure_fv3 := $(wildcard ../conf/configure.fv3) - ifneq ($(strip $(exist_configure_fv3)),) - include ../conf/configure.fv3 - else - $(error "../conf/configure.fv3 file is missing. Run ./configure") - endif - $(info ) - $(info Build standalone FV3 io ...) - $(info ) -endif -$(info $$ESMF_INC is [${ESMF_INC}]) - -LIBRARY = libfv3io.a - -FFLAGS += -I$(FMS_DIR) -I../gfsphysics -I../ipd - -ifneq (,$(findstring NO_INLINE_POST,$(CPPDEFS))) -POST_SRC = \ - ./post_gfs_stub.F90 -else -POST_SRC = \ - ./post_gfs.F90 \ - ./post_nems_routines.F90 -endif - -SRCS_f = - -SRCS_f90 = - -SRCS_F = - -SRCS_F90 = \ - ./ffsync.F90 \ - ./FV3GFS_io.F90 \ - $(POST_SRC) \ - ./module_write_nemsio.F90 \ - ./module_write_netcdf.F90 \ - ./module_write_netcdf_parallel.F90 \ - ./module_fv3_io_def.F90 \ - ./module_write_internal_state.F90 \ - ./module_wrt_grid_comp.F90 - -SRCS_c = - -DEPEND_FILES = $(SRCS_f) $(SRCS_f90) $(SRCS_F) $(SRCS_F90) - -OBJS_f = $(SRCS_f:.f=.o) -OBJS_f90 = $(SRCS_f90:.f90=.o) -OBJS_F = $(SRCS_F:.F=.o) -OBJS_F90 = $(SRCS_F90:.F90=.o) -OBJS_c = $(SRCS_c:.c=.o) - -OBJS = $(OBJS_f) $(OBJS_f90) $(OBJS_F) $(OBJS_F90) $(OBJS_c) - -all default: depend $(LIBRARY) - -$(LIBRARY): $(OBJS) - $(AR) $(ARFLAGS) $@ $? - -FV3GFS_io.o: FV3GFS_io.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c FV3GFS_io.F90 -post_nems_routines.o: post_nems_routines.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) -I$(UPP_INC) -c post_nems_routines.F90 -module_write_nemsio.o: module_write_nemsio.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) $(NEMSIOINC) -c module_write_nemsio.F90 -module_write_netcdf.o: module_write_netcdf.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_write_netcdf.F90 -module_write_netcdf_parallel.o: module_write_netcdf_parallel.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_write_netcdf_parallel.F90 -module_fv3_io_def.o: module_fv3_io_def.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_fv3_io_def.F90 -module_write_internal_state.o: module_write_internal_state.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_write_internal_state.F90 -module_wrt_grid_comp.o: module_wrt_grid_comp.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_wrt_grid_comp.F90 -post_gfs.o: post_gfs.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -I$(UPP_INC) -c post_gfs.F90 -post_gfs_stub.o: post_gfs_stub.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c post_gfs_stub.F90 - - -.PHONY: clean -clean: - @echo "Cleaning io ... " - @echo - $(RM) -f $(LIBRARY) *__genmod.f90 *.o *.mod *.i90 *.lst *.i depend - -MKDEPENDS = ../mkDepends.pl -include ../conf/make.rules - -# do not include 'depend' file if the target contains string 'clean' -ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) - -include depend -endif - diff --git a/makefile b/makefile deleted file mode 100644 index 4191b4777..000000000 --- a/makefile +++ /dev/null @@ -1,165 +0,0 @@ -SHELL = /bin/sh - -include conf/configure.fv3 - -ifeq ($(strip $(FMS_DIR)),) - FMS_DIR=$(realpath ../FMS/FMS_INSTALL) -endif - -exist=$(wildcard $(FMS_DIR)) -ifeq ($(strip $(exist)),) - $(error ERROR: FMS_DIR variable is unset and FMS_INSTALL is not in ../FMS/FMS_INSTALL ) -endif - - -FFLAGS += -I$(FMS_DIR) -Igfsphysics -Iipd -Icpl -Iio -Iatmos_cubed_sphere -Iccpp/driver -Istochastic_physics -CPPDEFS += -DESMF_VERSION_MAJOR=$(ESMF_VERSION_MAJOR) - -# Flag to CCPP build for 32bit dynamics -ifeq ($(32BIT),Y) - DYN32 = Y -else - DYN32 = N -endif - -FV3_EXE = fv3.exe -FV3CAP_LIB = libfv3cap.a - -all: libs - $(MAKE) $(FV3_EXE) $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - -nems: libs - $(MAKE) $(FV3CAP_LIB) $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) esmf_make_fragment FMS_DIR=$(FMS_DIR) - -ifneq (,$(findstring CCPP,$(CPPDEFS))) -libs: - $(MAKE) -C cpl $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C gfsphysics $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N DYN32=$(DYN32) # force gfs physics to 64bit, flag to CCPP build for 32bit dynamics - $(MAKE) -C ccpp/driver $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N DYN32=$(DYN32) # force gfs physics to 64bit, flag to CCPP build for 32bit dynamics - $(MAKE) -C ipd $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - $(MAKE) -C io $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C atmos_cubed_sphere $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C ../stochastic_physics $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - $(MAKE) -C stochastic_physics $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - -$(FV3_EXE): atmos_model.o coupler_main.o ccpp/driver/libccppdriver.a atmos_cubed_sphere/libfv3core.a io/libfv3io.a ipd/libipd.a gfsphysics/libgfsphys.a stochastic_physics/libstochastic_physics_wrapper.a ../stochastic_physics/libstochastic_physics.a cpl/libfv3cpl.a - $(LD) -o $@ $^ $(NCEPLIBS) $(LDFLAGS) - -else -libs: - $(MAKE) -C cpl $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C gfsphysics $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - $(MAKE) -C ipd $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - $(MAKE) -C io $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C atmos_cubed_sphere $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) - $(MAKE) -C ../stochastic_physics $(MAKE_OPTS) FMS_DIR=$(FMS_DIR) 32BIT=N # force gfs physics to 64bit - -$(FV3_EXE): atmos_model.o coupler_main.o atmos_cubed_sphere/libfv3core.a io/libfv3io.a ipd/libipd.a gfsphysics/libgfsphys.a ../stochastic_physics/libstochastic_physics.a cpl/libfv3cpl.a - $(LD) -o $@ $^ $(NCEPLIBS) $(LDFLAGS) -endif - -$(FV3CAP_LIB): atmos_model.o module_fv3_config.o module_fcst_grid_comp.o time_utils.o fv3_cap.o - ar rv $(FV3CAP_LIB) $? - -atmos_model.o : atmos_model.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c atmos_model.F90 - -module_fv3_config.o: module_fv3_config.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_fv3_config.F90 -module_fcst_grid_comp.o: module_fcst_grid_comp.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c module_fcst_grid_comp.F90 -time_utils.o: time_utils.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c time_utils.F90 -fv3_cap.o: fv3_cap.F90 - $(FC) $(CPPDEFS) $(CPPFLAGS) $(FPPFLAGS) $(FFLAGS) $(OTHERFLAGS) $(OTHER_FFLAGS) $(ESMF_INC) -c fv3_cap.F90 - -DEPEND_FILES = time_utils.F90 module_fv3_config.F90 atmos_model.F90 module_fcst_grid_comp.F90 fv3_cap.F90 coupler_main.F90 - -# For CCPP, check if SIONlib is used and set linker flags accordingly -ifneq (,$(findstring CCPP,$(CPPDEFS))) -ifneq (,$(findstring SION,$(CPPDEFS))) - SIONLIB_LINK_FLAGS = $(SIONLIB_LIB) -else - SIONLIB_LINK_FLAGS = -endif -endif - -ifneq (,$(findstring CCPP,$(CPPDEFS))) -esmf_make_fragment: - @rm -rf nems_dir; mkdir nems_dir - @cp $(FV3CAP_LIB) ccpp/driver/libccppdriver.a atmos_cubed_sphere/libfv3core.a io/libfv3io.a ipd/libipd.a gfsphysics/libgfsphys.a cpl/libfv3cpl.a stochastic_physics/libstochastic_physics_wrapper.a ../stochastic_physics/libstochastic_physics.a nems_dir - @cp fv3gfs_cap_mod.mod nems_dir - @echo "# ESMF self-describing build dependency makefile fragment" > fv3.mk - @echo "# src location $(PWD)" >> fv3.mk - @echo >> fv3.mk - @echo "ESMF_DEP_FRONT = fv3gfs_cap_mod" >> fv3.mk - # additional include files needed for PGI - #@echo "ESMF_DEP_INCPATH = $(PWD)/nems_dir" >> fv3.mk - @echo "ESMF_DEP_INCPATH = $(PWD) $(addprefix $(PWD)/, nems_dir ccpp/driver atmos_cubed_sphere io gfsphysics cpl ipd ../stochastic_physics)" >> fv3.mk - @echo "ESMF_DEP_CMPL_OBJS =" >> fv3.mk - @echo "ESMF_DEP_LINK_OBJS = $(addprefix $(PWD)/nems_dir/, libfv3cap.a libccppdriver.a libfv3core.a libfv3io.a libipd.a libgfsphys.a libfv3cpl.a libstochastic_physics_wrapper.a libstochastic_physics.a) $(SIONLIB_LINK_FLAGS)" >> fv3.mk - @echo "ESMF_DEP_SHRD_PATH =" >> fv3.mk - @echo "ESMF_DEP_SHRD_LIBS =" >> fv3.mk - @echo - @echo "Finished generating ESMF self-describing build dependency makefile fragment:" fv3.mk - @echo -else -esmf_make_fragment: - @rm -rf nems_dir; mkdir nems_dir - @cp $(FV3CAP_LIB) atmos_cubed_sphere/libfv3core.a io/libfv3io.a ipd/libipd.a gfsphysics/libgfsphys.a cpl/libfv3cpl.a ../stochastic_physics/libstochastic_physics.a nems_dir - @cp fv3gfs_cap_mod.mod nems_dir - @echo "# ESMF self-describing build dependency makefile fragment" > fv3.mk - @echo "# src location $(PWD)" >> fv3.mk - @echo >> fv3.mk - @echo "ESMF_DEP_FRONT = fv3gfs_cap_mod" >> fv3.mk - # additional include files needed for PGI - #@echo "ESMF_DEP_INCPATH = $(PWD)/nems_dir" >> fv3.mk - @echo "ESMF_DEP_INCPATH = $(PWD) $(addprefix $(PWD)/, nems_dir atmos_cubed_sphere io gfsphysics cpl ipd ../stochastic_physics)" >> fv3.mk - @echo "ESMF_DEP_CMPL_OBJS =" >> fv3.mk - @echo "ESMF_DEP_LINK_OBJS = $(addprefix $(PWD)/nems_dir/, libfv3cap.a libfv3core.a libfv3io.a libipd.a libgfsphys.a libfv3cpl.a libstochastic_physics.a)" >> fv3.mk - @echo "ESMF_DEP_SHRD_PATH =" >> fv3.mk - @echo "ESMF_DEP_SHRD_LIBS =" >> fv3.mk - @echo - @echo "Finished generating ESMF self-describing build dependency makefile fragment:" fv3.mk - @echo -endif - -# fv3 library installation defaults (for NEMS): -DESTDIR := $(PWD) -INSTDIR := FV3_INSTALL - -nemsinstall: nems - @mkdir -p $(DESTDIR)/$(INSTDIR) - @cp nems_dir/* $(DESTDIR)/$(INSTDIR) - @sed -e 's;'$(PWD)/nems_dir';'$(DESTDIR)/$(INSTDIR)';g' fv3.mk > $(DESTDIR)/$(INSTDIR)/fv3.mk - @echo Installation into \"$(DESTDIR)/$(INSTDIR)\" complete! - @echo - -.PHONY: clean cleanall -clean: - @echo "Cleaning ... " - @echo - (cd gfsphysics && make clean) - (cd ccpp/driver && make clean) - (cd ipd && make clean) - (cd ../stochastic_physics && make clean) - (cd stochastic_physics && make clean) - (cd io && make clean) - (cd atmos_cubed_sphere && make clean) - (cd cpl && make clean) - $(RM) -f $(FV3_EXE) $(FV3CAP_LIB) *.o *.mod *.i90 *.lst depend - -cleanall: clean - $(RM) -rf nems_dir fv3.mk $(INSTDIR) - $(RM) -f conf/modules.fv3 - $(RM) -f conf/configure.fv3 - -MKDEPENDS = ./mkDepends.pl -include conf/make.rules - -# do not include 'depend' file if the target contains string 'clean' -ifneq (clean,$(findstring clean,$(MAKECMDGOALS))) - -include depend -endif - diff --git a/mkDepends.pl b/mkDepends.pl deleted file mode 100755 index 97c992715..000000000 --- a/mkDepends.pl +++ /dev/null @@ -1,357 +0,0 @@ -#!/usr/bin/env perl - -# Modifications to Brian Eaton's original to relax the restrictions on -# source file name matching module name and only one module per source -# file. See the new "-m" and "-d" options for details. -# -# One important limitation remains. If your module is named "procedure", -# this script will quietly ignore it. -# -# Tom Henderson -# Global Systems Division, NOAA/OAR -# Mar 2011 -# -# Brian Eaton's original comments follow: -# -# Generate dependencies in a form suitable for inclusion into a Makefile. -# The source filenames are provided in a file, one per line. Directories -# to be searched for the source files and for their dependencies are provided -# in another file, one per line. Output is written to STDOUT. -# -# For CPP type dependencies (lines beginning with #include) the dependency -# search is recursive. Only dependencies that are found in the specified -# directories are included. So, for example, the standard include file -# stdio.h would not be included as a dependency unless /usr/include were -# one of the specified directories to be searched. -# -# For Fortran module USE dependencies (lines beginning with a case -# insensitive "USE", possibly preceded by whitespace) the Fortran compiler -# must be able to access the .mod file associated with the .o file that -# contains the module. In order to correctly generate these dependencies -# two restrictions must be observed. -# 1) All modules must be contained in files that have the same base name as -# the module, in a case insensitive sense. This restriction implies that -# there can only be one module per file. -# 2) All modules that are to be contained in the dependency list must be -# contained in one of the source files in the list provided on the command -# line. -# The reason for the second restriction is that since the makefile doesn't -# contain rules to build .mod files the dependency takes the form of the .o -# file that contains the module. If a module is being used for which the -# source code is not available (e.g., a module from a library), then adding -# a .o dependency for that module is a mistake because make will attempt to -# build that .o file, and will fail if the source code is not available. -# -# Author: B. Eaton -# Climate Modelling Section, NCAR -# Feb 2001 - -use Getopt::Std; -use File::Basename; - -# Check for usage request. -@ARGV >= 2 or usage(); - -# Process command line. -my %opt = (); -getopts( "t:wmd:", \%opt ) or usage(); -my $filepath_arg = shift() or usage(); -my $srcfile_arg = shift() or usage(); -@ARGV == 0 or usage(); # Check that all args were processed. - -my $obj_dir; -if ( defined $opt{'t'} ) { $obj_dir = $opt{'t'}; } - -my $additional_obj = ""; -if ( defined $opt{'d'} ) { $additional_obj = $opt{'d'}; } - -open(FILEPATH, $filepath_arg) or die "Can't open $filepath_arg: $!\n"; -open(SRCFILES, $srcfile_arg) or die "Can't open $srcfile_arg: $!\n"; - -# Make list of paths to use when looking for files. -# Prepend "." so search starts in current directory. This default is for -# consistency with the way GNU Make searches for dependencies. -my @file_paths = ; -close(FILEPATH); -chomp @file_paths; -unshift(@file_paths,'.'); -foreach $dir (@file_paths) { # (could check that directories exist here) - $dir =~ s!/?\s*$!!; # remove / and any whitespace at end of directory name - ($dir) = glob $dir; # Expand tildes in path names. -} - -# Make list of files containing source code. -my @src = ; -close(SRCFILES); -chomp @src; - -my %module_files = (); - -#TODO: DRY this out -if ( defined $opt{'m'} ) { - # Attempt to parse each file for /^\s*module/ and extract module names - # for each file. - my ($f, $name, $path, $suffix, $mod); - my @suffixes = ('\.[fF]90', '\.[fF]' ); - foreach $f (@src) { - ($name, $path, $suffix) = fileparse($f, @suffixes); - open(FH, $f) or die "Can't open $f: $!\n"; - while ( ) { - # Search for module definitions. - if ( /^\s*MODULE\s+(\w+)/i ) { - ($mod = $1) =~ tr/a-z/A-Z/; - # skip "module procedure foo" statements - if ( $mod ne "PROCEDURE" ) { - if ( defined $module_files{$mod} ) { - die "Duplicate definitions of module $mod in $module_files{$mod} and $name: $!\n"; - } - $module_files{$mod} = $path.$name; - } - } - } - close( FH ); - } -} else { - # For each file that may contain a Fortran module (*.[fF]90 *.[fF]) convert the - # file's basename to uppercase and use it as a hash key whose value is the file's - # basename. This allows fast identification of the files that contain modules. - # The only restriction is that the file's basename and the module name must match - # in a case insensitive way. - my ($f, $name, $path, $suffix, $mod); - my @suffixes = ('\.[fF]90', '\.[fF]' ); - foreach $f (@src) { - ($name, $path, $suffix) = fileparse($f, @suffixes); - ($mod = $name) =~ tr/a-z/A-Z/; - $module_files{$mod} = $path.$name; - } -} - -#print STDERR "\%module_files\n"; -#while ( ($k,$v) = each %module_files ) { -# print STDERR "$k => $v\n"; -#} - -# Find module and include dependencies of the source files. -my ($file_path, $rmods, $rincs); -my %file_modules = (); -my %file_includes = (); -my @check_includes = (); -foreach $f ( @src ) { - - # Find the file in the seach path (@file_paths). - unless ($file_path = find_file($f)) { - if (defined $opt{'w'}) {print STDERR "$f not found\n";} - next; - } - - # Find the module and include dependencies. - ($rmods, $rincs) = find_dependencies( $file_path ); - - # Remove redundancies (a file can contain multiple procedures that have - # the same dependencies). - $file_modules{$f} = rm_duplicates($rmods); - $file_includes{$f} = rm_duplicates($rincs); - - # Make a list of all include files. - push @check_includes, @{$file_includes{$f}}; -} - -#print STDERR "\%file_modules\n"; -#while ( ($k,$v) = each %file_modules ) { -# print STDERR "$k => @$v\n"; -#} -#print STDERR "\%file_includes\n"; -#while ( ($k,$v) = each %file_includes ) { -# print STDERR "$k => @$v\n"; -#} -#print STDERR "\@check_includes\n"; -#print STDERR "@check_includes\n"; - -# Find include file dependencies. -my %include_depends = (); -while (@check_includes) { - $f = shift @check_includes; - if (defined($include_depends{$f})) { next; } - - # Mark files not in path so they can be removed from the dependency list. - unless ($file_path = find_file($f)) { - $include_depends{$f} = -1; - next; - } - - # Find include file dependencies. - ($rmods, $include_depends{$f}) = find_dependencies($file_path); - - # Add included include files to the back of the check_includes list so - # that their dependencies can be found. - push @check_includes, @{$include_depends{$f}}; - - # Add included modules to the include_depends list. - if ( @$rmods ) { push @{$include_depends{$f}}, @$rmods; } -} - -#print STDERR "\%include_depends\n"; -#while ( ($k,$v) = each %include_depends ) { -# print STDERR (ref $v ? "$k => @$v\n" : "$k => $v\n"); -#} - -# Remove include file dependencies that are not in the Filepath. -my $i, $ii; -foreach $f (keys %include_depends) { - - unless (ref $include_depends{$f}) { next; } - $rincs = $include_depends{$f}; - unless (@$rincs) { next; } - $ii = 0; - $num_incs = @$rincs; - for ($i = 0; $i < $num_incs; ++$i) { - if ($include_depends{$$rincs[$ii]} == -1) { - splice @$rincs, $ii, 1; - next; - } - ++$ii; - } -} - -# Substitute the include file dependencies into the %file_includes lists. -foreach $f (keys %file_includes) { - my @expand_incs = (); - - # Initialize the expanded %file_includes list. - my $i; - unless (@{$file_includes{$f}}) { next; } - foreach $i (@{$file_includes{$f}}) { - push @expand_incs, $i unless ($include_depends{$i} == -1); - } - unless (@expand_incs) { - $file_includes{$f} = []; - next; - } - - # Expand - for ($i = 0; $i <= $#expand_incs; ++$i) { - push @expand_incs, @{ $include_depends{$expand_incs[$i]} }; - } - - $file_includes{$f} = rm_duplicates(\@expand_incs); -} - -#print STDERR "expanded \%file_includes\n"; -#while ( ($k,$v) = each %file_includes ) { -# print STDERR "$k => @$v\n"; -#} - -# Print dependencies to STDOUT. -foreach $f (sort keys %file_modules) { - $f =~ /(.+)\./; - $target = "$1.o"; - if ( defined $opt{'t'} ) { $target = "$opt{'t'}/$1.o"; } - push(@{$file_modules{$f}},$additional_obj); - print "$target : $f @{noncircular(@{$file_modules{$f}},$target)} @{noncircular(@{$file_includes{$f}},$target)}\n"; -} - -#-------------------------------------------------------------------------------------- - -sub noncircular -{ - # Return an array identical to that represented by the first argument, except - # for the absence of the element specified by the second argument. - my @a=(); - my $x=pop(@_); - foreach (@_) { unless ($_ eq $x) { push(@a,$_) } }; - return \@a; -} - -sub find_dependencies { - - # Find dependencies of input file. - # Use'd Fortran 90 modules are returned in \@mods. - # Files that are "#include"d by the cpp preprocessor are returned in \@incs. - - my( $file ) = @_; - my( @mods, @incs ); - - open(FH, $file) or die "Can't open $file: $!\n"; - - while ( ) { - # Search for "#include" and strip filename when found. - if ( /^#include\s+[<"](.*)[>"]/ ) { - push @incs, $1; - } - # Search for module dependencies. - elsif ( /^\s*USE\s+(\w+)/i ) { - # Return dependency in the form of a .o version of the file that contains - # the module. - ($module = $1) =~ tr/a-z/A-Z/; - if ( defined $module_files{$module} ) { - if ( defined $obj_dir ) { - push @mods, "$obj_dir/$module_files{$module}.o"; - } else { - push @mods, "$module_files{$module}.o"; - } - } - } - } - close( FH ); - return (\@mods, \@incs); -} - -#-------------------------------------------------------------------------------------- - -sub find_file { - -# Search for the specified file in the list of directories in the global -# array @file_paths. Return the first occurance found, or the null string if -# the file is not found. - - my($file) = @_; - my($dir, $fname); - - foreach $dir (@file_paths) { - $fname = "$dir/$file"; - if ( -f $fname ) { return $fname; } - } - return ''; # file not found -} - -#-------------------------------------------------------------------------------------- - -sub rm_duplicates { - -# Return a list with duplicates removed. - - my ($in) = @_; # input arrary reference - my @out = (); - my $i; - my %h = (); - foreach $i (@$in) { - $h{$i} = ''; - } - @out = keys %h; - return \@out; -} - -#-------------------------------------------------------------------------------------- - -sub usage { - ($ProgName = $0) =~ s!.*/!!; # name of program - die <