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

merge #23

Merged
merged 3 commits into from
Apr 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions cmake/FindESMF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

if (DEFINED ENV{ESMFMKFILE})
message("ESMFMKFILE: $ENV{ESMFMKFILE}")
else()
message(FATAL_ERROR "ESMFMKFILE env variable is not defined")
endif()

set(ESMFMKFILE $ENV{ESMFMKFILE})

# convert esmf.mk makefile variables to cmake variables until ESMF
# provides proper cmake package
file(STRINGS ${ESMFMKFILE} esmf_mk_text)
foreach(line ${esmf_mk_text})
string(REGEX REPLACE "^[ ]+" "" line ${line}) # strip leading spaces
if (line MATCHES "^ESMF_*") # process only line starting with ESMF_
string(REGEX MATCH "^ESMF_[^=]+" esmf_name ${line})
string(REPLACE "${esmf_name}=" "" emsf_value ${line})
set(${esmf_name} "${emsf_value}")
endif()
endforeach()
string(REPLACE "-I" "" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})
string(REPLACE " " ";" ESMF_F90COMPILEPATHS ${ESMF_F90COMPILEPATHS})

# We use only these 4 variables in our build system. Make sure they are all set
if(ESMF_VERSION_MAJOR AND
ESMF_F90COMPILEPATHS AND
ESMF_F90ESMFLINKRPATHS AND
ESMF_F90ESMFLINKLIBS)
message(" Found ESMF:")
message("ESMF_VERSION_MAJOR: ${ESMF_VERSION_MAJOR}")
message("ESMF_F90COMPILEPATHS: ${ESMF_F90COMPILEPATHS}")
message("ESMF_F90ESMFLINKRPATHS: ${ESMF_F90ESMFLINKRPATHS}")
message("ESMF_F90ESMFLINKLIBS: ${ESMF_F90ESMFLINKLIBS}")
else()
message("One of the ESMF_ variables is not defined")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ESMF
FOUND_VAR
ESMF_FOUND
REQUIRED_VARS
ESMF_F90COMPILEPATHS
ESMF_F90ESMFLINKRPATHS
ESMF_F90ESMFLINKLIBS
VERSION_VAR
ESMF_VERSION_STRING)
63 changes: 63 additions & 0 deletions cmake/GNU.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fcray-pointer -ffree-line-length-none -fno-range-check -fbacktrace")

if(DEBUG)
message("DEBUG is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -O0 -ggdb -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans -ffpe-trap=invalid,zero,overflow -fbounds-check")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O0 -ggdb")
else()
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")
if(APPLE)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0 -ggdb")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -ggdb")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
endif()
else()
message("REPRO is disabled")
endif()


if(32BIT)
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")
endif()


if(OPENMP)
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")
endif()

if(AVX2)
message("AVX2 is ENABLED")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
message("AVX2 is disabled")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()

if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
92 changes: 92 additions & 0 deletions cmake/Intel.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fpp -fno-alias -auto -safe-cray-ptr -ftz -assume byterecl -nowarn -sox -align array64byte")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qno-opt-dynamic-align")


if(32BIT)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -real-size 32")
add_definitions(-DOVERLOAD_R4)
add_definitions(-DOVERLOAD_R8)
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -real-size 64")
if(NOT REPRO)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -no-prec-div -no-prec-sqrt")
endif()
endif()

if(REPRO)
add_definitions(-DREPRO)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qno-opt-dynamic-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qno-opt-dynamic-align")
else()
if(AVX2)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -xCORE-AVX2 -qno-opt-dynamic-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xCORE-AVX2 -qno-opt-dynamic-align")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -xHOST -qno-opt-dynamic-align")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xHOST -qno-opt-dynamic-align")
endif()
endif()

if(REPRO)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -debug minimal -fp-model consistent -qoverride-limits -g -traceback")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -debug minimal")
else()
if(DEBUG)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -O0 -check -check noarg_temp_created -check nopointer -warn -warn noerrors -fp-stack-check -fstack-protector-all -fpe0 -debug -traceback -ftrapuv")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g -ftrapuv -traceback")
add_definitions(-DDEBUG)
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O2 -debug minimal -fp-model source -qoverride-limits -qopt-prefetch=3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -debug minimal")
set(FAST "-fast-transcendentals")
endif()
endif()

if(OPENMP)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qopenmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -qopenmp")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -qopenmp")
add_definitions(-DOPENMP)
endif()


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

# print build options

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

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

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

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

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

if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
62 changes: 62 additions & 0 deletions cmake/PGI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mpreprocess")

if(DEBUG)
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)")
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")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O1 -g -traceback")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
else()
message("REPRO is disabled")
endif()


if(32BIT)
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")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -i4 -r8 -Mfprelaxed=div -Mfprelaxed=sqrt")
endif()


if(OPENMP)
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")
endif()


if(AVX2)
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")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -tp=x64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -tp=x64")
endif()


if(INLINE_POST)
message("INLINE_POST is ENABLED")
else()
message("INLINE_POST is disabled")
endif()
35 changes: 35 additions & 0 deletions cmake/configure_cheyenne.gnu.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("")
35 changes: 35 additions & 0 deletions cmake/configure_cheyenne.intel-impi.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" ON)

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("")
35 changes: 35 additions & 0 deletions cmake/configure_cheyenne.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" ON)

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("")
Loading