From 845436d1fd246f5f883c431de27cbc4d63d518d2 Mon Sep 17 00:00:00 2001 From: Michael Levy Date: Fri, 27 Sep 2024 15:39:46 -0600 Subject: [PATCH] Consistency among ncar make templates General formatting is the same, the only differences are the actual flags and whatnot used by the different compilers --- standalone/templates/ncar-gnu.mk | 34 ++++++------ standalone/templates/ncar-intel.mk | 26 +++++---- standalone/templates/ncar-nvhpc.mk | 84 +++++++++--------------------- 3 files changed, 53 insertions(+), 91 deletions(-) diff --git a/standalone/templates/ncar-gnu.mk b/standalone/templates/ncar-gnu.mk index e2021b8..2f2bb7f 100644 --- a/standalone/templates/ncar-gnu.mk +++ b/standalone/templates/ncar-gnu.mk @@ -3,53 +3,49 @@ ############ # commands # ############ + FC = mpif90 CC = gcc CXX = g++ LD = mpif90 $(MAIN_PROGRAM) -######### -# flags # -######### +############ +# flags # +############ DEBUG = - MAKEFLAGS += --jobs=$(shell grep '^processor' /proc/cpuinfo | wc -l) +LDFLAGS := -FPPFLAGS := FC_AUTO_R8 := -fdefault-real-8 -fdefault-double-8 -FFLAGS := $(FC_AUTO_R8) -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none -fallow-argument-mismatch -fallow-invalid-boz -fcray-pointer +FPPFLAGS := +FFLAGS := $(FC_AUTO_R8) -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none -fallow-argument-mismatch -fallow-invalid-boz -fcray-pointer FFLAGS_REPRO = -O FFLAGS_DEBUG = -g -Wall -Og -fbacktrace -ffpe-trap=zero,overflow -fcheck=bounds - CFLAGS := -std=gnu99 CFLAGS_REPRO = -O CFLAGS_DEBUG = -g -Wall -Og -fbacktrace -ffpe-trap=invalid,zero,overflow -fcheck=bounds -LDFLAGS := - - ifeq ($(DEBUG),1) -CFLAGS += $(CFLAGS_DEBUG) -FFLAGS += $(FFLAGS_DEBUG) + FFLAGS += $(FFLAGS_DEBUG) + CFLAGS += $(CFLAGS_DEBUG) else -CFLAGS += $(CFLAGS_REPRO) -FFLAGS += $(FFLAGS_REPRO) + FFLAGS += $(FFLAGS_REPRO) + CFLAGS += $(CFLAGS_REPRO) endif - # NetCDF Flags FFLAGS += -I$(shell nc-config --includedir) CFLAGS += -I$(shell nc-config --includedir) - # add the use_LARGEFILE cppdef + ifneq ($(findstring -Duse_netCDF,$(CPPDEFS)),) - CPPDEFS += -Duse_LARGEFILE + # add the use_LARGEFILE cppdef + CPPDEFS += -Duse_LARGEFILE endif # Linking Flags -LIBS := $(shell nf-config --flibs) $(shell pkg-config --libs mpich2-f90) -LDFLAGS += $(LIBS) +LDFLAGS += $(shell nf-config --flibs) $(shell pkg-config --libs mpich2-f90) #--------------------------------------------------------------------------- # you should never need to change any lines below. diff --git a/standalone/templates/ncar-intel.mk b/standalone/templates/ncar-intel.mk index 4e8517c..5beded2 100644 --- a/standalone/templates/ncar-intel.mk +++ b/standalone/templates/ncar-intel.mk @@ -3,6 +3,7 @@ ############ # commands # ############ + FC = mpif90 CC = mpicc CXX = icpc @@ -12,43 +13,40 @@ LD = mpif90 # flags # ############ -DEBUG = -# Default set to REPRODUCIBLE - +DEBUG = MAKEFLAGS += --jobs=8 +LDFLAGS := FC_AUTO_R8 := -r8 FPPFLAGS := -fpp -Wp,-w -FFLAGS := -qno-opt-dynamic-align -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model source -no-fma -qopt-report -march=core-avx2 $(FC_AUTO_R8) +FFLAGS := $(FC_AUTO_R8) -qno-opt-dynamic-align -convert big_endian -assume byterecl -ftz -traceback -assume realloc_lhs -fp-model source -no-fma -qopt-report -march=core-avx2 FFLAGS_DEBUG = -O0 -g -check uninit -check bounds -check nopointer -fpe0 -check noarg_temp_created # CESM uses -check pointers, that throws an error, changed to nopointer FFLAGS_REPRO = -O2 -debug minimal CFLAGS := -qno-opt-dynamic-align -fp-model precise -std=gnu99 -no-fma -qopt-report -march=core-avx2 -CFLAGS += -I$(NETCDF_PATH)/include CFLAGS_REPRO= -O2 -debug minimal CFLAGS_DEBUG = -O0 -g -LDFLAGS := ifeq ($(DEBUG),1) - CFLAGS += $(CFLAGS_DEBUG) FFLAGS += $(FFLAGS_DEBUG) + CFLAGS += $(CFLAGS_DEBUG) else FFLAGS += $(FFLAGS_REPRO) CFLAGS += $(CFLAGS_REPRO) endif -# Add Net CDF Flags +# NetCDF Flags FFLAGS += -I$(shell nf-config --includedir) -# add the use_LARGEFILE cppdef +CFLAGS += -I$(NETCDF_PATH)/include + ifneq ($(findstring -Duse_netCDF,$(CPPDEFS)),) + # add the use_LARGEFILE cppdef CPPDEFS += -Duse_LARGEFILE endif +CPPDEFS += -D__IFC -CPPDEFS := $(CPPDEFS) -D__IFC -# Add netcdf linking -LIBS := $(shell nc-config --libs) $(shell nf-config --flibs) - -LDFLAGS += $(LIBS) +# Linking Flags +LDFLAGS += $(shell nc-config --libs) $(shell nf-config --flibs) #--------------------------------------------------------------------------- # you should never need to change any lines below. diff --git a/standalone/templates/ncar-nvhpc.mk b/standalone/templates/ncar-nvhpc.mk index 95a9f05..6d69464 100644 --- a/standalone/templates/ncar-nvhpc.mk +++ b/standalone/templates/ncar-nvhpc.mk @@ -3,6 +3,7 @@ ############ # commands # ############ + FC = ftn CC = cc CXX = cc @@ -13,73 +14,40 @@ LD = ftn $(MAIN_PROGRAM) ############ DEBUG = - MAKEFLAGS += --jobs=8 +LDFLAGS := -INCLUDES := $(shell pkg-config --cflags yaml-0.1) - -# Need to use at least GNU Make version 3.81 -need := 3.81 -ok := $(filter $(need),$(firstword $(sort $(MAKE_VERSION) $(need)))) -ifneq ($(need),$(ok)) -$(error Need at least make version $(need). Load module gmake/3.81) -endif - -# Macro for Fortran preprocessor -FPPFLAGS := $(INCLUDES) - - -# Base set of Fortran compiler flags FC_AUTO_R8 = -r8 -FFLAGS = $(FC_AUTO_R8) -Mnofma -i4 -gopt -time -Mextend -byteswapio -Mflushz -Kieee - -# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG) -FFLAGS_REPRO = -O2 -tp=zen3 +FPPFLAGS := $(shell pkg-config --cflags yaml-0.1) +FFLAGS = $(FC_AUTO_R8) -Mnofma -i4 -gopt -time -Mextend -byteswapio -Mflushz -Kieee FFLAGS_DEBUG = -O0 -g # -Mbounds fails compilation and -KTrap=fp fails run! seems like there is a floating point exception in netcdf_io_mod -# Macro for C preprocessor -CPPFLAGS := $(INCLUDES) +FFLAGS_REPRO = -O2 -tp=zen3 - -# Base set of C compiler flags CFLAGS = -gopt -time -Mnofma - -# Flags based on perforance target (production (OPT), reproduction (REPRO), or debug (DEBUG) -CFLAGS_REPRO = -O2 -CFLAGS_DEBUG = - -# Linking flags -LDFLAGS := - -# List of -L library directories to be added to the compile and linking commands -LIBS := +CFLAGS_REPRO = -O2 +CFLAGS_DEBUG = +CPPFLAGS := $(shell pkg-config --cflags yaml-0.1) # Get compile flags based on target macros. ifeq ($(DEBUG),1) -CFLAGS += $(CFLAGS_DEBUG) -FFLAGS += $(FFLAGS_DEBUG) + FFLAGS += $(FFLAGS_DEBUG) + CFLAGS += $(CFLAGS_DEBUG) else -CFLAGS += $(CFLAGS_REPRO) -FFLAGS += $(FFLAGS_REPRO) + FFLAGS += $(FFLAGS_REPRO) + CFLAGS += $(CFLAGS_REPRO) endif - # NetCDF Flags -# Fortran Compiler flags for the NetCDF library -FPPFLAGS += $(shell nf-config --fflags) -# C Compiler flags for the NetCDF library -CPPFLAGS += $(shell nc-config --cflags) -# Add Netcdf linking -LIBS += $(shell nc-config --libs) $(shell nf-config --flibs) +FFLAGS += $(shell nf-config --fflags) +CFLAGS += $(shell nc-config --cflags) + ifneq ($(findstring -Duse_netCDF,$(CPPDEFS)),) - CPPDEFS += -Duse_LARGEFILE + # add the use_LARGEFILE cppdef + CPPDEFS += -Duse_LARGEFILE endif - -# These Algebra libraries Add solution to more complex vector matrix model equations -LIBS += -llapack -lblas - -# CESM Linking Flags -LDFLAGS += $(LIBS) -time -Wl,--allow-multiple-definition +# Linking Flags +LDFLAGS += $(shell nc-config --libs) $(shell nf-config --flibs) -llapack -lblas -time -Wl,--allow-multiple-definition #--------------------------------------------------------------------------- # you should never need to change any lines below. @@ -90,13 +58,13 @@ LDFLAGS += $(LIBS) -time -Wl,--allow-multiple-definition # .f, .f90, .F, .F90. Given a sourcefile ., where is one of # the above, this provides a number of default actions: -# make .opt create an optimization report -# make .o create an object file -# make .s create an assembly listing -# make .x create an executable file, assuming standalone -# source -# make .i create a preprocessed file (for .F) -# make .i90 create a preprocessed file (for .F90) +# make .opt create an optimization report +# make .o create an object file +# make .s create an assembly listing +# make .x create an executable file, assuming standalone +# source +# make .i create a preprocessed file (for .F) +# make .i90 create a preprocessed file (for .F90) # The macro TMPFILES is provided to slate files like the above for removal.