Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Added the NetCDF libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
cwishard committed Oct 14, 2022
1 parent 94a0e10 commit a65eed8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ INCLUDE(${CMAKE_MODULE_PATH}/SetFortranFlags.cmake)
# about Fortran.
INCLUDE(${CMAKE_MODULE_PATH}/SetParallelizationLibrary.cmake)

INCLUDE(${CMAKE_MODULE_PATH}/SetUpNetCDF.cmake)

# There is an error in CMAKE with this flag for pgf90. Unset it
GET_FILENAME_COMPONENT(FCNAME ${CMAKE_Fortran_COMPILER} NAME)
IF(FCNAME STREQUAL "pgf90")
Expand Down
9 changes: 9 additions & 0 deletions cmake/Modules/SetUpNetCDF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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(NETCDFFORTRAN_FOUND TRUE CACHE INTERNAL "NETCDFFORTRAN was found" FORCE)
SET(NETCDF_LIBRARIES ${NETCDF_LIBRARIES} CACHE INTERNAL "NETCDF LIBS" FORCE)
SET(NETCDFFORTRAN_LIBRARIES ${NETCDFFORTRAN_LIBRARIES} CACHE INTERNAL "NETCDFFORTRAN LIBS" FORCE)
ENDIF(NOT NETCDF_FOUND)
8 changes: 8 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ SET(FOO_src ${SRC}/discard/discard.f90
# Define the executable in terms of the source files
ADD_EXECUTABLE(${FOOEXE} ${FOO_src})

#####################################################
# Add the needed libraries and special compiler flags
#####################################################

# Uncomment if you need to link to BLAS and LAPACK
TARGET_LINK_LIBRARIES(${FOOEXE} ${NETCDF_LIBRARIES}
${NETCDFFORTRAN_LIBRARIES})

#####################################
# Tell how to install this executable
#####################################
Expand Down

0 comments on commit a65eed8

Please sign in to comment.