Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cmake build system. #11

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add INLINE_POST cmake option
  • Loading branch information
DusanJovic-NOAA committed Nov 7, 2019
commit 0e7ff414024439b1d17f1396dbbdc0676e643905
28 changes: 16 additions & 12 deletions cmake/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,58 @@
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check -fbacktrace")

if(DEBUG)
message("DEBUG is ENABLED")
message("DEBUG is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -O0 -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check -fbacktrace -fno-range-check")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g")
else()
message("DEBUG is disabled (optimized build)")
message("DEBUG is disabled (optimized build)")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -fno-range-check")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()


if(REPRO)
message("REPRO is ENABLED")
message("REPRO is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -g -fbacktrace -fno-range-check")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
else()
message("REPRO is disabled")
message("REPRO is disabled")
endif()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also add a mechanism to either abort if both REPRO and DEBUG are requested, or make one of the two superior (I suggest DEBUG). In the latter case, issue a warning that both REPRO and DEBUG where requested, and that DEBUG will be used (and REPRO disabled).


if(32BIT)
message("32BIT is ENABLED")
message("32BIT is ENABLED")
add_definitions(-DOVERLOAD_R4)
add_definitions(-DOVERLOAD_R8)
else()
message("32BIT is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8 -fdefault-double-8")
message("32BIT is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fdefault-real-8")
endif()


if(OPENMP)
message("OPENMP is ENABLED")
message("OPENMP is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
add_definitions(-DOPENMP)
else()
message("OPENMP is disabled")
message("OPENMP is disabled")
endif()


if(AVX2)
DusanJovic-NOAA marked this conversation as resolved.
Show resolved Hide resolved
message("AVX2 is ENABLED")
message("AVX2 is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
message("AVX2 is disabled")
message("AVX2 is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__IFC")
if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
25 changes: 15 additions & 10 deletions cmake/Intel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,42 @@ if(OPENMP)
endif()



set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__IFC -sox -fp-model source")

# print build options

if(DEBUG)
message("DEBUG is ENABLED")
message("DEBUG is ENABLED")
else()
message("DEBUG is disabled")
message("DEBUG is disabled")
endif()

if(REPRO)
message("REPRO is ENABLED")
message("REPRO is ENABLED")
else()
message("REPRO is disabled")
message("REPRO is disabled")
endif()

if(32BIT)
message("32BIT is ENABLED")
message("32BIT is ENABLED")
else()
message("32BIT is disabled")
message("32BIT is disabled")
endif()

if(OPENMP)
message("OPENMP is ENABLED")
message("OPENMP is ENABLED")
else()
message("OPENMP is disabled")
message("OPENMP is disabled")
endif()


if(AVX2)
message("AVX2 is ENABLED")
message("AVX2 is ENABLED")
endif()


if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
27 changes: 16 additions & 11 deletions cmake/PGI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,61 @@
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mpreprocess")

if(DEBUG)
message("DEBUG is ENABLED")
message("DEBUG is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -O0 -Ktrap=fp -Mbounds -traceback")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -traceback")
else()
message("DEBUG is disabled (optimized build)")
message("DEBUG is disabled (optimized build)")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(FAST "-fast-transcendentals")
endif()


if(REPRO)
message("REPRO is ENABLED")
message("REPRO is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O1 -g -traceback")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
else()
message("REPRO is disabled")
message("REPRO is disabled")
endif()


if(32BIT)
message("32BIT is ENABLED")
message("32BIT is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -r4")
add_definitions(-DOVERLOAD_R4)
add_definitions(-DOVERLOAD_R8)
else()
message("32BIT is disabled")
message("32BIT is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -r8 -Mfprelaxed=div -Mfprelaxed=sqrt")
endif()


if(OPENMP)
message("OPENMP is ENABLED")
message("OPENMP is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mp")
add_definitions(-DOPENMP)
else()
message("OPENMP is disabled")
message("OPENMP is disabled")
endif()


if(AVX2)
message("AVX2 is ENABLED")
message("AVX2 is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -tp=haswell")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -tp=haswell")
else()
message("AVX2 is disabled")
message("AVX2 is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -tp=x64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -tp=x64")
endif()

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__IFC")

if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
34 changes: 34 additions & 0 deletions cmake/configure_linux.gnu.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
message("")
DusanJovic-NOAA marked this conversation as resolved.
Show resolved Hide resolved
message("Setting configuration for $ENV{CMAKE_Platform}")
message("")

get_filename_component (C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
get_filename_component (CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
message("C compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} (${C_COMPILER_NAME})")
message("CXX compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} (${CXX_COMPILER_NAME})")
message("Fortran compiler: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION} (${Fortran_COMPILER_NAME})")
message("")

option(DEBUG "Enable DEBUG mode" OFF)
option(REPRO "Enable REPRO mode" OFF)
option(VERBOSE "Enable VERBOSE mode" OFF)
option(32BIT "Enable 32BIT (single precision arithmetic in dycore)" OFF)
option(OPENMP "Enable OpenMP threading" ON)
option(AVX2 "Enable AVX2 instruction set" ON)

option(INLINE_POST "Enable inline post" OFF)

include( cmake/${CMAKE_Fortran_COMPILER_ID}.cmake )

set(NEMSIO_INC $ENV{NEMSIO_INC})
set(NCEP_LIBS $ENV{NEMSIO_LIB} $ENV{BACIO_LIB4} $ENV{SP_LIBd} $ENV{W3EMC_LIBd} $ENV{W3NCO_LIBd})

set(ESMF_MOD ${ESMF_F90COMPILEPATHS})
set(ESMF_LIBS "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90ESMFLINKLIBS}")

set(NETCDF_INC_DIR $ENV{NETCDF}/include)
set(NETCDF_LIBDIR $ENV{NETCDF}/lib)
set(NETCDF_LIBS -L$ENV{NETCDF}/lib -lnetcdff -lnetcdf)

message("")
35 changes: 35 additions & 0 deletions cmake/configure_linux.intel.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
message("")
message("Setting configuration for $ENV{CMAKE_Platform}")
message("")

get_filename_component (C_COMPILER_NAME ${CMAKE_C_COMPILER} NAME)
get_filename_component (CXX_COMPILER_NAME ${CMAKE_CXX_COMPILER} NAME)
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
message("C compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} (${C_COMPILER_NAME})")
message("CXX compiler: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} (${CXX_COMPILER_NAME})")
message("Fortran compiler: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION} (${Fortran_COMPILER_NAME})")
message("")

option(DEBUG "Enable DEBUG mode" OFF)
option(REPRO "Enable REPRO mode" OFF)
option(VERBOSE "Enable VERBOSE mode" OFF)
option(32BIT "Enable 32BIT (single precision arithmetic in dycore)" OFF)
option(OPENMP "Enable OpenMP threading" ON)
option(AVX2 "Enable AVX2 instruction set" OFF)

option(INLINE_POST "Enable inline post" OFF)

include( cmake/${CMAKE_Fortran_COMPILER_ID}.cmake )

set(NEMSIO_INC $ENV{NEMSIO_INC})
set(POST_INC $ENV{POST_INC})
set(NCEP_LIBS $ENV{POST_LIB} $ENV{NEMSIO_LIB} $ENV{G2_LIB4} $ENV{G2TMPL_LIB} $ENV{BACIO_LIB4} $ENV{SP_LIBd} $ENV{W3EMC_LIBd} $ENV{W3NCO_LIBd} $ENV{CRTM_LIB} $ENV{PNG_LIB} $ENV{JASPER_LIB} $ENV{Z_LIB})

set(ESMF_MOD ${ESMF_F90COMPILEPATHS})
set(ESMF_LIBS "${ESMF_F90ESMFLINKRPATHS} ${ESMF_F90ESMFLINKPATHS} ${ESMF_F90ESMFLINKLIBS}")

set(NETCDF_INC_DIR $ENV{NETCDF}/include)
set(NETCDF_LIBDIR $ENV{NETCDF}/lib)
set(NETCDF_LIBS -L$ENV{NETCDF}/lib -lnetcdff -lnetcdf)

message("")