From 0f9c026a5dbcbd8d1def0cfbaa10495fb7d9cb06 Mon Sep 17 00:00:00 2001 From: David A Minton Date: Tue, 25 Oct 2022 13:56:09 -0400 Subject: [PATCH] Fixed cmake to allow for NetCDF libraries to be found --- Makefile.Defines | 84 ------------------------------ Makefile.Defines_example | 90 --------------------------------- bin/.gitignore | 2 - build/.gitignore | 1 - cmake/Modules/FindNETCDF.cmake | 9 ++++ cmake/Modules/SetUpNetCDF.cmake | 6 +-- src/CMakeLists.txt | 34 +++++++------ src/modules/symba_classes.f90 | 2 +- src/symba/symba_step.f90 | 2 +- 9 files changed, 30 insertions(+), 200 deletions(-) delete mode 100644 Makefile.Defines delete mode 100644 Makefile.Defines_example delete mode 100644 bin/.gitignore create mode 100644 cmake/Modules/FindNETCDF.cmake diff --git a/Makefile.Defines b/Makefile.Defines deleted file mode 100644 index c73eb3910..000000000 --- a/Makefile.Defines +++ /dev/null @@ -1,84 +0,0 @@ -#****************************************************************************** -# -# Unit Name : Makefile.Defines -# Unit Type : makefile -# Project : SWIFTEST -# Package : N/A -# Language : GNU makefile syntax -# -# Description : Contains user-modifiable macro definitions used in the build -# process for the Swifter library, drivers and tools, as well as -# the FXDR library -# -# Input -# Arguments : none -# Terminal : none -# File : none -# -# Output -# Arguments : none -# Terminal : none -# File : none -# -# Invocation : include Makefile.Defines (from within another makefile) -# -# Notes : -# -#****************************************************************************** - -# System utilities - -SHELL = /bin/sh -AR = ar -RANLIB = ranlib -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -m 755 -INSTALL_DATA = $(INSTALL) -m 644 -ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) -# Swifter definitions - -SWIFTEST_HOME = $(ROOT_DIR) -USER_MODULES = -COLLRESOLVE_HOME = $(ROOT_DIR)/collresolve/ - -# Compiler definitions - -# DO NOT include in FFLAGS the "-c" option to compile object only -# this is done explicitly as needed in the Makefile -IDEBUG = -O0 -init=snan,arrays -nogen-interfaces -no-pie -no-ftz -fpe-all=0 -g -traceback -mp1 -qopt-matmul -fp-model strict -fpe0 -debug all -align all -pad -ip -prec-div -prec-sqrt -assume protect-parens -CB -no-wrap-margin -STRICTREAL = -fp-model=precise -prec-div -prec-sqrt -assume protect-parens -SIMDVEC = -simd -xhost -align all -assume contiguous_assumed_shape -vecabi=cmdtarget -fp-model no-except -fma -PAR = -qopenmp -HEAPARR = -heap-arrays 4194304 -OPTREPORT = -qopt-report=5 -IPRODUCTION = -no-wrap-margin -O3 -qopt-prefetch=0 -qopt-matmul -sox $(PAR) $(SIMDVEC) #$(HEAPARR) - -#gfortran flags -GDEBUG = -g -Og -fbacktrace -fbounds-check -ffree-line-length-none -GPAR = -fopenmp -ftree-parallelize-loops=4 -GMEM = -fsanitize-address-use-after-scope -fstack-check -fsanitize=bounds-strict -fsanitize=undefined -fsanitize=signed-integer-overflow -fsanitize=object-size -fstack-protector-all -GWARNINGS = -Wall -Warray-bounds -Wimplicit-interface -Wextra -Warray-temporaries -GPRODUCTION = -O3 -ffree-line-length-none $(GPAR) - -INCLUDES = -I$(SWIFTEST_HOME)/include -I$(NETCDF_FORTRAN_HOME)/include -I$(MKLROOT)/include -LINKS = -L$(MKLROOT)/lib/intel64 -L$(NETCDF_FORTRAN_HOME)/lib -lswiftest -lnetcdf -lnetcdff -qopt-matmul $(PAR) - -FSTRICTFLAGS = $(IPRODUCTION) $(STRICTREAL) -FFLAGS = $(IPRODUCTION) -fp-model=fast - -FORTRAN = ifort -AR = xiar -CC = icc - -#FORTRAN = gfortran -#FFLAGS = $(GDEBUG) $(GMEM) #$(GPAR) -#FSTRICTFLAGS = $(GDEBUG) $(GMEM) #$(GPAR) -#AR = ar -#CC = cc - -# DO NOT include in CFLAGS the "-c" option to compile object only -# this is done explicitly as needed in the Makefile - -CFLAGS = -O3 -w -m64 -std=c99 - -64_BIT_REALS = -r8 diff --git a/Makefile.Defines_example b/Makefile.Defines_example deleted file mode 100644 index b21710254..000000000 --- a/Makefile.Defines_example +++ /dev/null @@ -1,90 +0,0 @@ -#****************************************************************************** -# -# Unit Name : Makefile.Defines -# Unit Type : makefile -# Project : SWIFTER -# Package : N/A -# Language : GNU makefile syntax -# -# Description : Contains user-modifiable macro definitions used in the build -# process for the Swifter library, drivers and tools, as well as -# the FXDR library -# -# Input -# Arguments : none -# Terminal : none -# File : none -# -# Output -# Arguments : none -# Terminal : none -# File : none -# -# Invocation : include Makefile.Defines (from within another makefile) -# -# Notes : -# -#****************************************************************************** - -# System utilities - -SHELL = /bin/sh -AR = ar -RANLIB = ranlib -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -m 755 -INSTALL_DATA = $(INSTALL) -m 644 - -# Swifter definitions - -SWIFTER_HOME = # Full path to your Swifter directory goes here -USER_MODULES = - -# Compiler definitions - -# DO NOT include in FFLAGS the "-c" option to compile object only -# this is done explicitly as needed in the Makefile - -#FORTRAN = ifort -#FFLAGS = -O3 -openmp -132 -align all -pad -ip -fp-model strict -prec-div -prec-sqrt -ftz -assume protect-parens - -FORTRAN = gfortran -FFLAGS = -O3 - -# DO NOT include in CFLAGS the "-c" option to compile object only -# this is done explicitly as needed in the Makefile - -CC = cc -CFLAGS = -O - -64_BIT_REALS = -r8 - -# FXDR Makefile compatibility - DO NOT ALTER - -F77CMD = $(FORTRAN) -F77OPTS = $(FFLAGS) -CCCMD = $(CC) -CCOPTS = $(CFLAGS) - -#****************************************************************************** -# -# Author(s) : David E. Kaufmann -# -# Revision Control System (RCS) Information -# -# Source File : $RCSfile: Makefile.Defines,v $ -# Full Path : $Source: /d1/kaufmann/development/RCS/Makefile.Defines,v $ -# Revision : $Revision: 0.1 $ -# Date : $Date: 2003/04/15 22:56:57 $ -# Programmer : $Author: kaufmann $ -# Locked By : $Locker: $ -# State : $State: Exp $ -# -# Modification History: -# -# $Log: Makefile.Defines,v $ -# Revision 0.1 2003/04/15 22:56:57 kaufmann -# Initial implementation -# -# -#****************************************************************************** diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/bin/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/build/.gitignore b/build/.gitignore index d6b7ef32c..72e8ffc0d 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1,2 +1 @@ * -!.gitignore diff --git a/cmake/Modules/FindNETCDF.cmake b/cmake/Modules/FindNETCDF.cmake new file mode 100644 index 000000000..f8e97dbca --- /dev/null +++ b/cmake/Modules/FindNETCDF.cmake @@ -0,0 +1,9 @@ +# - Finds the NetCDF libraries +find_path(NETCDF_INCLUDE_DIR NAMES netcdf.mod HINTS ENV NETCDF_FORTRAN_HOME) +find_library(NETCDF_LIBRARY NAMES netcdf HINTS ENV NETCDF_FORTRAN_HOME) +find_library(NETCDF_FORTRAN_LIBRARY NAMES netcdff HINTS ENV NETCDF_FORTRAN_HOME) + +set(NETCDF_FOUND TRUE) +set(NETCDF_INCLUDE_DIRS ${NETCDF_INCLUDE_DIR}) +set(NETCDF_LIBRARIES ${NETCDF_LIBRARY} ${NETCDF_FORTRAN_LIBRARY}) +mark_as_advanced(NETCDF_LIBRARY NETCDF_FORTRAN_LIBRARY NETCDF_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/SetUpNetCDF.cmake b/cmake/Modules/SetUpNetCDF.cmake index d4ee7d43c..dbfe44c4b 100644 --- a/cmake/Modules/SetUpNetCDF.cmake +++ b/cmake/Modules/SetUpNetCDF.cmake @@ -1,9 +1,5 @@ # Find NetCDF if not already found IF(NOT NETCDF_FOUND) ENABLE_LANGUAGE(C) # Some libraries need a C compiler to find - FIND_PACKAGE(netcdf REQUIRED) - SET(NETCDF_FOUND TRUE CACHE INTERNAL "NETCDF was found" FORCE) - SET(NETCDF_LIBRARIES ${NETCDF_LIBRARIES} CACHE INTERNAL "NETCDF LIBS" FORCE) - #SET(NETCDFFORTRAN_FOUND TRUE CACHE INTERNAL "NETCDF-FORTRAN was found" FORCE) - #SET(NETCDFFORTRAN_LIBRARIES ${NETCDFFORTRAN_LIBRARIES} CACHE INTERNAL "NETCDFFORTRAN LIBS" FORCE) + FIND_PACKAGE(NETCDF REQUIRED) ENDIF(NOT NETCDF_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8af404c73..5ea24cc0d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,20 @@ ######################################## # Add the source files -SET(FOO_src ${SRC}/discard/discard.f90 +SET(FOO_src + ${SRC}/modules/encounter_classes.f90 + ${SRC}/modules/fraggle_classes.f90 + ${SRC}/modules/helio_classes.f90 + ${SRC}/modules/lambda_function.f90 + ${SRC}/modules/rmvs_classes.f90 + ${SRC}/modules/swiftest_classes.f90 + ${SRC}/modules/swiftest_globals.f90 + ${SRC}/modules/swiftest_operators.f90 + ${SRC}/modules/swiftest.f90 + ${SRC}/modules/symba_classes.f90 + ${SRC}/modules/walltime_classes.f90 + ${SRC}/modules/whm_classes.f90 + ${SRC}/discard/discard.f90 ${SRC}/drift/drift.f90 ${SRC}/encounter/encounter_check.f90 ${SRC}/encounter/encounter_io.f90 @@ -25,19 +38,6 @@ SET(FOO_src ${SRC}/discard/discard.f90 ${SRC}/helio/helio_util.f90 ${SRC}/io/io.f90 ${SRC}/kick/kick.f90 - ${SRC}/main/swiftest_driver.f90 - ${SRC}/modules/encounter_classes.f90 - ${SRC}/modules/fraggle_classes.f90 - ${SRC}/modules/helio_classes.f90 - ${SRC}/modules/lambda_function.f90 - ${SRC}/modules/rmvs_classes.f90 - ${SRC}/modules/swiftest_classes.f90 - ${SRC}/modules/swiftest_globals.f90 - ${SRC}/modules/swiftest_operators.f90 - ${SRC}/modules/swiftest.f90 - ${SRC}/modules/symba_classes.f90 - ${SRC}/modules/walltime_classes.f90 - ${SRC}/modules/whm_classes.f90 ${SRC}/netcdf/netcdf.f90 ${SRC}/obl/obl.f90 ${SRC}/operators/operator_cross.f90 @@ -61,6 +61,8 @@ SET(FOO_src ${SRC}/discard/discard.f90 ${SRC}/symba/symba_setup.f90 ${SRC}/symba/symba_step.f90 ${SRC}/symba/symba_util.f90 + ${SRC}/tides/tides_getacch_pl.f90 + ${SRC}/tides/tides_spin_step.f90 ${SRC}/user/user_getacch.f90 ${SRC}/util/util_append.f90 ${SRC}/util/util_coord.f90 @@ -89,6 +91,7 @@ SET(FOO_src ${SRC}/discard/discard.f90 ${SRC}/whm/whm_setup.f90 ${SRC}/whm/whm_step.f90 ${SRC}/whm/whm_util.f90 + ${SRC}/main/swiftest_driver.f90 ) # Define the executable in terms of the source files @@ -99,8 +102,7 @@ ADD_EXECUTABLE(${FOOEXE} ${FOO_src}) ##################################################### # Uncomment if you need to link to BLAS and LAPACK -TARGET_LINK_LIBRARIES(${FOOEXE} ${NETCDF_LIBRARIES}) - #${NETCDFFORTRAN_LIBRARIES}) +TARGET_LINK_LIBRARIES(${FOOEXE} ${NETCDF_LIBRARIES} ${NETCDF_FORTRAN_LIBRARIES}) # Uncomment if you have parallization IF(USE_OPENMP) diff --git a/src/modules/symba_classes.f90 b/src/modules/symba_classes.f90 index f501c1f4f..525013500 100644 --- a/src/modules/symba_classes.f90 +++ b/src/modules/symba_classes.f90 @@ -485,7 +485,7 @@ module subroutine symba_step_set_recur_levels_system(self, ireci) integer(I4B), intent(in) :: ireci !! Input recursion level end subroutine symba_step_set_recur_levels_system - module recursive subroutine symba_step_recur_system(self, param, t, ireci) + recursive module subroutine symba_step_recur_system(self, param, t, ireci) use swiftest_classes, only : swiftest_parameters implicit none class(symba_nbody_system), intent(inout) :: self !! SyMBA nbody system object diff --git a/src/symba/symba_step.f90 b/src/symba/symba_step.f90 index c5e37c576..99c324286 100644 --- a/src/symba/symba_step.f90 +++ b/src/symba/symba_step.f90 @@ -150,7 +150,7 @@ module subroutine symba_step_set_recur_levels_system(self, ireci) end subroutine symba_step_set_recur_levels_system - module recursive subroutine symba_step_recur_system(self, param, t, ireci) + recursive module subroutine symba_step_recur_system(self, param, t, ireci) !! author: David A. Minton !! !! Step interacting planets and active test particles ahead in democratic heliocentric coordinates at the current