diff --git a/.dev/utils/DEBUGGING_FLAGS.patch b/.dev/utils/DEBUGGING_FLAGS.patch deleted file mode 100644 index e02c6f5..0000000 --- a/.dev/utils/DEBUGGING_FLAGS.patch +++ /dev/null @@ -1,77 +0,0 @@ -diff --git a/config/compiler.gfortran.mk b/config/compiler.gfortran.mk -index 007a335..3fdf8e4 100644 ---- a/config/compiler.gfortran.mk -+++ b/config/compiler.gfortran.mk -@@ -24,7 +24,7 @@ endif - - FMAKEDEP = $(SCRIPTS_DIR)/sfmakedepend - CPPFLAGS += -DCOMPILER_G95 --FFLAGS = -g -cpp -fconvert=big-endian -O2 -fno-range-check -fallow-argument-mismatch -+FFLAGS = -g -cpp -fconvert=big-endian -O0 -Wall -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion -fbacktrace -fallow-argument-mismatch - F90FLAGS = $(FFLAGS) -ffree-line-length-none - LFLAGS = - ifeq ($(MP),YES) -diff --git a/config/compiler.intel.mk b/config/compiler.intel.mk -index a73a4fe..68839af 100644 ---- a/config/compiler.intel.mk -+++ b/config/compiler.intel.mk -@@ -4,9 +4,9 @@ IFORT_RELEASE := $(shell ifort --version | perl -e \ - 'while(<>){ if(/ifort.* (\d+\.\d+)/) { print "$$1"; } }') - FMAKEDEP = $(SCRIPTS_DIR)/sfmakedepend - CMP_MOD = $(SCRIPTS_DIR)/compare_module_file.pl -compiler INTEL-ifort-9-0-on-LINUX --FFLAGS = -fpp -O2 -ftz -convert big_endian -+FFLAGS = -fpp -O0 -warn all -check bounds -check uninit -check pointers -traceback -assume byterecl -ftz -convert big_endian - F90FLAGS = $(FFLAGS) -free --LFLAGS = -O2 -ftz -+LFLAGS = -O0 -ftz - CPPFLAGS += -DCOMPILER_Intel8 -DCONVERT_BIGENDIAN - F90_VERSION = $(shell $(F90) --version 2>&1) - ifeq ($(MP),YES) -diff --git a/config/rules.mk b/config/rules.mk -index d981c80..87ef4f2 100644 ---- a/config/rules.mk -+++ b/config/rules.mk -@@ -62,7 +62,7 @@ I = I - # by default assume that fortran compiler can do cpp - EXTERNAL_CPP = NO - # assume that C compiler understands basic gcc flags --CFLAGS = -O2 -+CFLAGS = -O0 - # check if ABI was specified - ifneq ($(ABI),) - CFLAGS += -m$(ABI) -@@ -430,7 +430,7 @@ endif - $(CPP) $(CPPFLAGS) $< > $@ - - %.o: %.c -- $(CC) -c -O2 -m64 $< -+ $(CC) -c -O0 -Wall -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion -g -fbacktrace -fallow-argument-mismatch -m64 $< - - %.f: %.m4f - -rm -f $@ -diff --git a/decks/Makefile b/decks/Makefile -index 4d2791a..c167dc6 100644 ---- a/decks/Makefile -+++ b/decks/Makefile -@@ -140,7 +140,7 @@ ifeq ($(GC),YES) - -DCMAKE_Fortran_COMPILER="$(F90)" \ - -DCMAKE_Fortran_FLAGS="$(F90FLAGS)" \ - -DCMAKE_EXE_LINKER_FLAGS="$(CTM_LFLAGS)" -- cd $(GC_BUILD_DIR) && make -j install -+ cd $(GC_BUILD_DIR) && make VERBOSE=1 -j install - cp $(GC_BUILD_DIR)/mod/*.mod $(MODEL_DIR)/mod/ - cp $(GC_BUILD_DIR)/src/HEMCO/mod/*.mod $(MODEL_DIR)/mod/ - cp $(GC_BUILD_DIR)/src/Cloud-J/mod/*.mod $(MODEL_DIR)/mod/ -diff --git a/modele-control.pyar b/modele-control.pyar -index cf10239..1d78b27 100644 ---- a/modele-control.pyar -+++ b/modele-control.pyar -@@ -3447,7 +3447,7 @@ macro(modele_set_flags) - add_definitions(-DCOMPILER_G95) - # This breaks if you try to wrap the long line in the obvious way. - set (CMAKE_Fortran_FLAGS_RELEASE "${CPPFLAGS} -O2 -g -fconvert=big-endian -fno-range-check -ffree-line-length-none") -- set (CMAKE_Fortran_FLAGS_DEBUG "${CPPFLAGS} -O -g -fbacktrace -fconvert=big-endian -fno-range-check -ffree-line-length-none -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion") -+ set (CMAKE_Fortran_FLAGS_DEBUG "${CPPFLAGS} -O0 -g -fbacktrace -fconvert=big-endian -fno-range-check -ffree-line-length-none -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion") - - - if (CMAKE_BUILD_TYPE MATCHES Release) diff --git a/.dev/utils/build.sh b/.dev/utils/build.sh index fa095be..21b0bff 100755 --- a/.dev/utils/build.sh +++ b/.dev/utils/build.sh @@ -9,18 +9,20 @@ set -e FRESH=false OPENMP=false GISS_ONLY=false +MECH=fullchem DEBUG=false # Function to display help text show_help() { - echo "Usage: $0 [MP=YES|NO] [--openmp] [--giss-only] [-f] [--debug]" + echo "Usage: $0 [MECH=fullchem|carbon|Hg|custom] [--openmp] [--giss-only] [-f] [--debug]" echo echo "Options:" - echo " --help Show this help message and exit." - echo " --openmp Compile with OpenMP enabled." - echo " --giss-only Build without GEOS-Chem coupling." - echo " -f Fresh rebuild of the model." - echo " --debug Run with debugging turned on." + echo " MECH= Set the chemical mechanism (defaults to fullchem)." + echo " --openmp Compile with OpenMP enabled." + echo " --giss-only Build without GEOS-Chem coupling." + echo " --debug Run with debugging turned on." + echo " -f Fresh rebuild of the model." + echo " --help Show this help message and exit." } # Check for --help option @@ -32,8 +34,8 @@ fi # Parse arguments for arg in "$@"; do case $arg in - NP=*) - NP="${arg#*=}" + MECH=*) + MECH="${arg#*=}" ;; --openmp) OPENMP=true @@ -68,7 +70,7 @@ else fi # Print the values for verification -echo "NP=${NP}" +echo "MECH=${MECH}" echo "OPENMP=${OPENMP}" echo "GC=${GC}" echo "FRESH=${FRESH}" @@ -85,13 +87,11 @@ fi if [ "${DEBUG}" = true ]; then ln -s -f ${GISS_HOME}/.github/rundecks/${RUNID}.R $(pwd)/${RUNID}_DEBUG.R RUNID="${RUNID}_DEBUG" - git apply ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch - make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \ + make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=${MECH} \ TYPE=Debug DEBUG=YES COMPILE_WITH_TRAPS=YES TRACEBACK=YES OVERWRITE=YES - git apply -R ${GISS_HOME}/.dev/utils/DEBUGGING_FLAGS.patch else ln -s -f ${GISS_HOME}/.github/rundecks/${RUNID}.R $(pwd)/${RUNID}.R - make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=carbon \ + make -j setup RUN=${RUNID} F90=mpif90 GC=${GC} MP=${OPENMP} MPI=YES MECH=${MECH} \ TYPE=Release OVERWRITE=YES fi diff --git a/config/compiler.gfortran.mk b/config/compiler.gfortran.mk index 007a335..d471069 100644 --- a/config/compiler.gfortran.mk +++ b/config/compiler.gfortran.mk @@ -24,7 +24,11 @@ endif FMAKEDEP = $(SCRIPTS_DIR)/sfmakedepend CPPFLAGS += -DCOMPILER_G95 +ifeq ($(TYPE),Debug) +FFLAGS = -g -cpp -fconvert=big-endian -O0 -Wall -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion -fbacktrace -fallow-argument-mismatch +else FFLAGS = -g -cpp -fconvert=big-endian -O2 -fno-range-check -fallow-argument-mismatch +endif F90FLAGS = $(FFLAGS) -ffree-line-length-none LFLAGS = ifeq ($(MP),YES) @@ -34,7 +38,7 @@ LFLAGS += -fopenmp endif CTM_LFLAGS = $(LFLAGS) ifeq ($(GC),YES) -CTM_LFLAGS += -nostartfiles -Wno-main +CTM_LFLAGS += -nostartfiles endif F90_VERSION = $(shell $(F90) --version | head -1) diff --git a/config/compiler.intel.mk b/config/compiler.intel.mk index a73a4fe..f92b644 100644 --- a/config/compiler.intel.mk +++ b/config/compiler.intel.mk @@ -4,9 +4,14 @@ IFORT_RELEASE := $(shell ifort --version | perl -e \ 'while(<>){ if(/ifort.* (\d+\.\d+)/) { print "$$1"; } }') FMAKEDEP = $(SCRIPTS_DIR)/sfmakedepend CMP_MOD = $(SCRIPTS_DIR)/compare_module_file.pl -compiler INTEL-ifort-9-0-on-LINUX +ifeq ($(TYPE),Debug) +FFLAGS = -fpp -O0 -warn all -check bounds -check uninit -check pointers -traceback -assume byterecl -ftz -convert big_endian +LFLAGS = -O0 -ftz +else FFLAGS = -fpp -O2 -ftz -convert big_endian -F90FLAGS = $(FFLAGS) -free LFLAGS = -O2 -ftz +endif +F90FLAGS = $(FFLAGS) -free CPPFLAGS += -DCOMPILER_Intel8 -DCONVERT_BIGENDIAN F90_VERSION = $(shell $(F90) --version 2>&1) ifeq ($(MP),YES) @@ -16,7 +21,7 @@ LFLAGS += -qopenmp endif CTM_LFLAGS = $(LFLAGS) ifeq ($(GC),YES) -CTM_LFLAGS += -nostartfiles -nofor-main +CTM_LFLAGS += -nostartfiles endif R8 = -r8 EXTENDED_SOURCE = -extend_source diff --git a/config/rules.mk b/config/rules.mk index d981c80..b9855f1 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -62,7 +62,11 @@ I = I # by default assume that fortran compiler can do cpp EXTERNAL_CPP = NO # assume that C compiler understands basic gcc flags +ifeq ($(TYPE),Debug) +CFLAGS = -O0 +else CFLAGS = -O2 +endif # check if ABI was specified ifneq ($(ABI),) CFLAGS += -m$(ABI) @@ -430,7 +434,7 @@ endif $(CPP) $(CPPFLAGS) $< > $@ %.o: %.c - $(CC) -c -O2 -m64 $< + $(CC) -c $(CFLAGS) -m64 $< %.f: %.m4f -rm -f $@ diff --git a/decks/Makefile b/decks/Makefile index 4d2791a..ba8ef06 100644 --- a/decks/Makefile +++ b/decks/Makefile @@ -123,6 +123,11 @@ $(MODEL_DIR)/Makefile: $(MODEL_E_ROOT)/model/Makefile cp $(MODEL_E_ROOT)/model/Makefile $(MODEL_DIR)/Makefile endif +ifeq ($(TYPE),Debug) + DEBUG=1 +else + DEBUG=0 +endif gcm $(BIN_DIR)/$(RUN).exe: $(RUN).mk $(BIN_DIR) depend check_vars ifeq ($(GC),YES) @@ -135,12 +140,10 @@ ifeq ($(GC),YES) # If MECH is not specified, it defaults to "fullchem". May also be "carbon". cd $(GC_BUILD_DIR) && cmake ../ -DINSTALLCOPY=.. \ -DCMAKE_BUILD_TYPE="$(TYPE)" -DOMP="$(MP)" -DMECH="$(MECH)" \ - -DCMAKE_C_COMPILER="$(CC)" \ - -DCMAKE_CXX_COMPILER="$(CXX)" \ -DCMAKE_Fortran_COMPILER="$(F90)" \ -DCMAKE_Fortran_FLAGS="$(F90FLAGS)" \ -DCMAKE_EXE_LINKER_FLAGS="$(CTM_LFLAGS)" - cd $(GC_BUILD_DIR) && make -j install + cd $(GC_BUILD_DIR) && make VERBOSE=$(DEBUG) -j install cp $(GC_BUILD_DIR)/mod/*.mod $(MODEL_DIR)/mod/ cp $(GC_BUILD_DIR)/src/HEMCO/mod/*.mod $(MODEL_DIR)/mod/ cp $(GC_BUILD_DIR)/src/Cloud-J/mod/*.mod $(MODEL_DIR)/mod/ diff --git a/modele-control.pyar b/modele-control.pyar index cf10239..1d78b27 100644 --- a/modele-control.pyar +++ b/modele-control.pyar @@ -3447,7 +3447,7 @@ macro(modele_set_flags) add_definitions(-DCOMPILER_G95) # This breaks if you try to wrap the long line in the obvious way. set (CMAKE_Fortran_FLAGS_RELEASE "${CPPFLAGS} -O2 -g -fconvert=big-endian -fno-range-check -ffree-line-length-none") - set (CMAKE_Fortran_FLAGS_DEBUG "${CPPFLAGS} -O -g -fbacktrace -fconvert=big-endian -fno-range-check -ffree-line-length-none -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion") + set (CMAKE_Fortran_FLAGS_DEBUG "${CPPFLAGS} -O0 -g -fbacktrace -fconvert=big-endian -fno-range-check -ffree-line-length-none -fcheck=bounds -fcheck=do -fcheck=mem -fcheck=recursion") if (CMAKE_BUILD_TYPE MATCHES Release)