Skip to content

Commit

Permalink
Consistency among ncar make templates
Browse files Browse the repository at this point in the history
General formatting is the same, the only differences are the actual flags and
whatnot used by the different compilers
  • Loading branch information
mnlevy1981 committed Sep 27, 2024
1 parent 28e1f75 commit 845436d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 91 deletions.
34 changes: 15 additions & 19 deletions standalone/templates/ncar-gnu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
26 changes: 12 additions & 14 deletions standalone/templates/ncar-intel.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
############
# commands #
############

FC = mpif90
CC = mpicc
CXX = icpc
Expand All @@ -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.
Expand Down
84 changes: 26 additions & 58 deletions standalone/templates/ncar-nvhpc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
############
# commands #
############

FC = ftn
CC = cc
CXX = cc
Expand All @@ -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.
Expand All @@ -90,13 +58,13 @@ LDFLAGS += $(LIBS) -time -Wl,--allow-multiple-definition
# .f, .f90, .F, .F90. Given a sourcefile <file>.<ext>, where <ext> is one of
# the above, this provides a number of default actions:

# make <file>.opt create an optimization report
# make <file>.o create an object file
# make <file>.s create an assembly listing
# make <file>.x create an executable file, assuming standalone
# source
# make <file>.i create a preprocessed file (for .F)
# make <file>.i90 create a preprocessed file (for .F90)
# make <file>.opt create an optimization report
# make <file>.o create an object file
# make <file>.s create an assembly listing
# make <file>.x create an executable file, assuming standalone
# source
# make <file>.i create a preprocessed file (for .F)
# make <file>.i90 create a preprocessed file (for .F90)

# The macro TMPFILES is provided to slate files like the above for removal.

Expand Down

0 comments on commit 845436d

Please sign in to comment.