Skip to content

Commit

Permalink
GitHub Issue NOAA-EMC/GSI#112. A refactor of CMake build framework. (…
Browse files Browse the repository at this point in the history
…#327)
  • Loading branch information
aerorahul authored and MichaelLueken committed May 18, 2022
1 parent 62a9059 commit d5f91df
Show file tree
Hide file tree
Showing 85 changed files with 825 additions and 1,086 deletions.
107 changes: 2 additions & 105 deletions util/Conventional_Monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,105 +1,2 @@
cmake_minimum_required(VERSION 2.8)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# I am top-level project.
if( NOT DEFINED ENV{CC} )
find_path( crayComp "ftn" )
find_path( wcossIntel "mpfort" )
find_path( intelComp "ifort" )
find_path( pgiComp "pgf90" )
if( crayComp )
message("Setting CrayLinuxEnvironment")
set(CMAKE_SYSTEM_NAME "CrayLinuxEnvironment")
set(CMAKE_C_COMPILER "${crayComp}/cc")
set(CMAKE_CXX_COMPILER "${crayComp}/CC")
set(CMAKE_Fortran_COMPILER "${crayComp}/ftn")
endif()
if( intelComp )
set(ENV{CC} "icc")
set(ENV{CXX} "icpc")
set(ENV{FC} "ifort")
endif()
if( wcossIntel )
message("Setting env for wcoss intel")
set(ENV{CC} "mpcc")
set(ENV{CXX} "mpCC")
set(ENV{FC} "mpfort")
endif()
if( pgiComp )
set(ENV{CC} "pgcc")
set(ENV{CXX} "pgCC")
set(ENV{FC} "pgf90")
endif()
endif()
project(COV_Calc)
enable_language (Fortran)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../../cmake/Modules/")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPlatformVariables.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setIntelFlags.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setGNUFlags.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setPGIFlags.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/setHOST.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Cheyenne.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Discover.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Generic.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Gaea.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Jet.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/S4.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/Hera.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-C.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS-D.cmake)
include(${CMAKE_SOURCE_DIR}/../../cmake/Modules/platforms/WCOSS.cmake)
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: PRODUCTION Debug Release."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU*")
message("Setting GNU flags")
setGNU()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
message("Setting Intel flags")
setIntel()
elseif(CMAKE_C_COMPILER MATCHES "pgc*")
message("Setting PGI flags")
setPGI()
endif()

cmake_policy(SET CMP0009 NEW)
cmake_policy(SET CMP0054 NEW)
find_package(OpenMP)
message("found openmp with flag ${OPENMP_Fortran_FLAGS}")

# Set Host specific flags and options
setHOST()

find_package( NetCDF COMPONENTS C Fortran REQUIRED)
find_package(MPI REQUIRED)
message("MPI version is ${MPI_Fortran_VERSION}")
message("MPI f90 version is ${MPI_Fortran_HAVE_F90_MODULE}")
message("MPI f08 version is ${MPI_Fortran_HAVE_F08_MODULE}")

add_definitions(${MPI_Fortran_COMPILE_FLAGS})
include_directories(${MPI_Fortran_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} "./" ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
link_directories(${MPI_Fortran_LIBRARIES} ${ARCHIVE_OUTPUT_PATH} )
find_package( W3NCO )

set (CMAKE_Fortran_INC_FLAGS "-I ./ -I ${CORE_INCS} -I ${NETCDF_INCLUDE_DIRS} ")
set(BUILD_NCDIAG ON)
set(NCDIAG_INCS "${PROJECT_BINARY_DIR}/src/ncdiag/include")
add_subdirectory(src/ncdiag)
set(NCDIAG_LIBRARIES ncdiag )
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()

add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_lev.fd)
add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_mandlev.fd)
add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfc.fd)
add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sfctime.fd)
add_subdirectory(nwprod/conmon_shared/sorc/conmon_grads_sig.fd)
add_subdirectory(nwprod/conmon_shared/sorc/conmon_time.fd)
add_subdirectory(image_gen/sorc/conmon_read_ps_IG.fd)
add_subdirectory(image_gen/sorc/conmon_read_pw_IG.fd)
add_subdirectory(image_gen/sorc/conmon_read_q_IG.fd)
add_subdirectory(image_gen/sorc/conmon_read_t_IG.fd)
add_subdirectory(image_gen/sorc/conmon_read_uv_IG.fd)
add_subdirectory(image_gen)
add_subdirectory(nwprod)
1 change: 1 addition & 0 deletions util/Conventional_Monitor/image_gen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(sorc)
2 changes: 0 additions & 2 deletions util/Conventional_Monitor/image_gen/exec/.gitignore

This file was deleted.

5 changes: 5 additions & 0 deletions util/Conventional_Monitor/image_gen/sorc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_subdirectory(conmon_read_ps_IG.fd)
add_subdirectory(conmon_read_pw_IG.fd)
add_subdirectory(conmon_read_q_IG.fd)
add_subdirectory(conmon_read_t_IG.fd)
add_subdirectory(conmon_read_uv_IG.fd)
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
cmake_minimum_required(VERSION 2.6)
file(GLOB CONMON_READ_PS_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 )
set(CONMON_READ_PS_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ")
set_source_files_properties( ${CONMON_READ_PS_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} )
add_executable(conmon_read_ps_IG.x ${CONMON_READ_PS_IG_SRC} )
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4")
endif()

set_target_properties( conmon_read_ps_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PS_IG_Fortran_FLAGS} )
include_directories( ${CORE_INCS} ${NCDIAG_INCS} )
list(APPEND SRCS
convinfo.f90
histgram.f90
mainread_ps.f90
read_ps.f90
read_ps_mor.f90
rm_dups.f90
)

target_link_libraries( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} )
if(BUILD_W3NCO)
add_dependencies( conmon_read_ps_IG.x ${W3NCO_4_LIBRARY} )
endif()
add_executable(conmon_read_ps_IG.x ${SRCS})
if(TARGET ncdiag)
add_dependencies(conmon_read_ps_IG.x ncdiag)
endif()

target_compile_definitions(conmon_read_ps_IG.x PRIVATE "_REAL8_")
target_link_libraries(conmon_read_ps_IG.x PRIVATE NetCDF::NetCDF_Fortran)
target_link_libraries(conmon_read_ps_IG.x PRIVATE MPI::MPI_Fortran)
target_link_libraries(conmon_read_ps_IG.x PRIVATE ncdiag::ncdiag)
target_link_libraries(conmon_read_ps_IG.x PRIVATE w3emc::w3emc_4)

# Install executable targets
install(TARGETS conmon_read_ps_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm
!--------------
! interface
!
character(idtype), intent(in) :: dtype
integer, intent(in) :: idtype, insubtype
character(idtype), intent(in) :: dtype
integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype
real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
cmake_minimum_required(VERSION 2.6)
file(GLOB CONMON_READ_PW_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 )
set(CONMON_READ_PW_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ")
set_source_files_properties( ${CONMON_READ_PW_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} )
add_executable(conmon_read_pw_IG.x ${CONMON_READ_PW_IG_SRC} )
set_target_properties( conmon_read_pw_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_PW_IG_Fortran_FLAGS} )
include_directories( ${CORE_INCS} ${NCDIAG_INCS} )
target_link_libraries( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} )
if(BUILD_W3NCO)
add_dependencies( conmon_read_pw_IG.x ${W3NCO_4_LIBRARY} )
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4")
endif()

list(APPEND SRCS
convinfo.f90
histgram.f90
mainread_pw.f90
read_pw.f90
read_pw_mor.f90
rm_dups.f90
)

add_executable(conmon_read_pw_IG.x ${SRCS})
if(TARGET ncdiag)
add_dependencies(conmon_read_pw_IG.x ncdiag)
endif()

target_compile_definitions(conmon_read_pw_IG.x PRIVATE "_REAL8_")
target_link_libraries(conmon_read_pw_IG.x PRIVATE NetCDF::NetCDF_Fortran)
target_link_libraries(conmon_read_pw_IG.x PRIVATE MPI::MPI_Fortran)
target_link_libraries(conmon_read_pw_IG.x PRIVATE ncdiag::ncdiag)
target_link_libraries(conmon_read_pw_IG.x PRIVATE w3emc::w3emc_4)

# Install executable targets
install(TARGETS conmon_read_pw_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm
!--------------
! interface
!
character(idtype), intent(in) :: dtype
integer, intent(in) :: idtype, insubtype
character(idtype), intent(in) :: dtype
integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype
real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
cmake_minimum_required(VERSION 2.6)
file(GLOB CONMON_READ_Q_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 )
set(CONMON_READ_Q_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ")
set_source_files_properties( ${CONMON_READ_Q_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} )
add_executable(conmon_read_q_IG.x ${CONMON_READ_Q_IG_SRC} )
set_target_properties( conmon_read_q_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_Q_IG_Fortran_FLAGS} )
include_directories( ${CORE_INCS} ${NCDIAG_INCS} )
target_link_libraries( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} )
if(BUILD_W3NCO)
add_dependencies( conmon_read_q_IG.x ${W3NCO_4_LIBRARY} )
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4")
endif()

list(APPEND SRCS
convinfo.f90
histgram.f90
mainread_q.f90
read_q.f90
read_q_mor.f90
rm_dups.f90
)

add_executable(conmon_read_q_IG.x ${SRCS})
if(TARGET ncdiag)
add_dependencies(conmon_read_q_IG.x ncdiag)
endif()

target_compile_definitions(conmon_read_q_IG.x PRIVATE "_REAL8_")
target_link_libraries(conmon_read_q_IG.x PRIVATE NetCDF::NetCDF_Fortran)
target_link_libraries(conmon_read_q_IG.x PRIVATE MPI::MPI_Fortran)
target_link_libraries(conmon_read_q_IG.x PRIVATE ncdiag::ncdiag)
target_link_libraries(conmon_read_q_IG.x PRIVATE w3emc::w3emc_4)

# Install executable targets
install(TARGETS conmon_read_q_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm
!--------------
! interface
!
character(idtype), intent(in) :: dtype
integer, intent(in) :: idtype, insubtype
character(idtype), intent(in) :: dtype
integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype
real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
cmake_minimum_required(VERSION 2.6)
file(GLOB CONMON_READ_T_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 )
set(CONMON_READ_T_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ")
set_source_files_properties( ${CONMON_READ_T_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} )
add_executable(conmon_read_t_IG.x ${CONMON_READ_T_IG_SRC} )
set_target_properties( conmon_read_t_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_T_IG_Fortran_FLAGS} )
include_directories( ${CORE_INCS} ${NCDIAG_INCS} )
target_link_libraries( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} )
if(BUILD_W3NCO)
add_dependencies( conmon_read_t_IG.x ${W3NCO_4_LIBRARY} )
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4")
endif()

list(APPEND SRCS
convinfo.f90
histgram.f90
mainread_t.f90
read_t.f90
read_t_mor.f90
rm_dups.f90
)

add_executable(conmon_read_t_IG.x ${SRCS})
if(TARGET ncdiag)
add_dependencies(conmon_read_t_IG.x ncdiag)
endif()

target_compile_definitions(conmon_read_t_IG.x PRIVATE "_REAL8_")
target_link_libraries(conmon_read_t_IG.x PRIVATE NetCDF::NetCDF_Fortran)
target_link_libraries(conmon_read_t_IG.x PRIVATE MPI::MPI_Fortran)
target_link_libraries(conmon_read_t_IG.x PRIVATE ncdiag::ncdiag)
target_link_libraries(conmon_read_t_IG.x PRIVATE w3emc::w3emc_4)

# Install executable targets
install(TARGETS conmon_read_t_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm
!--------------
! interface
!
character(idtype), intent(in) :: dtype
integer, intent(in) :: idtype, insubtype
character(idtype), intent(in) :: dtype
integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype
real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
cmake_minimum_required(VERSION 2.6)
file(GLOB CONMON_READ_UV_IG_SRC ${CMAKE_CURRENT_SOURCE_DIR}/*90 )
set(CONMON_READ_UV_IG_Fortran_FLAGS "-fp-model strict -assume byterecl -convert big_endian -O3 -traceback -D_REAL8_ ")
set_source_files_properties( ${CONMON_READ_UV_IG_SRC} PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} )
add_executable(conmon_read_uv_IG.x ${CONMON_READ_UV_IG_SRC} )
set_target_properties( conmon_read_uv_IG.x PROPERTIES COMPILE_FLAGS ${CONMON_READ_UV_IG_Fortran_FLAGS} )
include_directories( ${CORE_INCS} ${NCDIAG_INCS} )
target_link_libraries( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} ${NCDIAG_LIBRARIES} ${NETCDF_Fortran_LIBRARIES} )
if(BUILD_W3NCO)
add_dependencies( conmon_read_uv_IG.x ${W3NCO_4_LIBRARY} )
endif()
if(CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fp-model strict -assume byterecl -convert big_endian")
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "^(GNU)$")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fconvert=big-endian -ffree-line-length-0 -ffast-math -fno-second-underscore -frecord-marker=4")
endif()

list(APPEND SRCS
convinfo.f90
histgram.f90
histgramuv.f90
mainread_uv.f90
read_uv.f90
read_uv_mor.f90
rm_dups.f90
)

add_executable(conmon_read_uv_IG.x ${SRCS})
if(TARGET ncdiag)
add_dependencies(conmon_read_uv_IG.x ncdiag)
endif()

target_compile_definitions(conmon_read_uv_IG.x PRIVATE "_REAL8_")
target_link_libraries(conmon_read_uv_IG.x PRIVATE NetCDF::NetCDF_Fortran)
target_link_libraries(conmon_read_uv_IG.x PRIVATE MPI::MPI_Fortran)
target_link_libraries(conmon_read_uv_IG.x PRIVATE ncdiag::ncdiag)
target_link_libraries(conmon_read_uv_IG.x PRIVATE w3emc::w3emc_4)

# Install executable targets
install(TARGETS conmon_read_uv_IG.x RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ subroutine convinfo_read( dtype, idtype, insubtype, ituse, ntumgrp, ntgroup, ntm
!--------------
! interface
!
character(idtype), intent(in) :: dtype
integer, intent(in) :: idtype, insubtype
character(idtype), intent(in) :: dtype
integer(4), intent(out) :: ituse, ntumgrp, ntgroup, ntmiter, isubtype
real(4), intent(out) :: ttwind2, gtross2, etrmax2, etrmin2, vtar_b2, vtar_pg2

Expand Down
1 change: 1 addition & 0 deletions util/Conventional_Monitor/nwprod/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(conmon_shared)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(sorc)

This file was deleted.

Loading

0 comments on commit d5f91df

Please sign in to comment.