-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from guoqing-noaa/dev_forDonnie
a working CMake system for the blending code
- Loading branch information
Showing
4 changed files
with
24 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(chgres_winds) | ||
|
||
enable_language(Fortran) | ||
set(CMAKE_Fortran_COMPILER ifort) | ||
|
||
# Set compiler flags | ||
set(FFLAGS "-fopenmp") | ||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS}") | ||
set(CFLAGS "-std=c99") | ||
|
||
# Add the source file | ||
add_library(chgres_winds MODULE chgres_winds.f90) | ||
|
||
# Set the output name of the module | ||
set_target_properties(chgres_winds PROPERTIES OUTPUT_NAME chgres_winds) | ||
|
||
# Find the path to libiomp5.so | ||
find_library(LIBIOMP5_PATH NAMES libiomp5.so) | ||
|
||
# Specify the build directory for f2py | ||
set(F2PY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# Get the Python executable path - to generalize the f2py3.x command | ||
execute_process( | ||
COMMAND python3 -c "import sys; print(sys.executable)" | ||
OUTPUT_VARIABLE PYTHON_EXECUTABLE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/chgres_winds.f90) | ||
|
||
# Compile the Fortran code using f2py | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -m numpy.f2py -DF2PY_REPORT_ATEXIT --build-dir ${F2PY_BUILD_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m chgres_winds chgres_winds.f90 | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
COMMAND $ENV{BLENDINGPYTHON} -m numpy.f2py -DF2PY_REPORT_ATEXIT --fcompiler=intelem --build-dir ${CMAKE_CURRENT_BINARY_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m chgres_winds ${FCODE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
RESULT_VARIABLE F2PY_RESULT | ||
) | ||
|
||
# Generate a list of files matching the pattern | ||
file(GLOB CHGRES_WINDS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*cpython*.so") | ||
|
||
# Install each file individually | ||
foreach(FILE ${CHGRES_WINDS_FILES}) | ||
get_filename_component(FILENAME ${FILE} NAME) | ||
install( | ||
FILES ${FILE} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RENAME ${FILENAME} | ||
) | ||
endforeach() | ||
#install chgres_winds.so | ||
file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*chgres_winds*.so") | ||
install(FILES ${SOFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME chgres_winds.so) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(raymond) | ||
|
||
enable_language(Fortran) | ||
set(CMAKE_Fortran_COMPILER ifort) | ||
|
||
# Set compiler flags | ||
set(FFLAGS "-fopenmp") | ||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS}") | ||
set(CFLAGS "-std=c99") | ||
|
||
# Add the source file | ||
add_library(raymond MODULE raymond.f) | ||
|
||
# Set the output name of the module | ||
set_target_properties(raymond PROPERTIES OUTPUT_NAME remap) | ||
|
||
# Link any necessary libraries | ||
target_link_libraries(raymond PRIVATE iomp5) | ||
|
||
# Specify the build directory for f2py | ||
set(F2PY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# Get the Python executable path - to generalize the f2py3.x command | ||
execute_process( | ||
COMMAND python3 -c "import sys; print(sys.executable)" | ||
OUTPUT_VARIABLE PYTHON_EXECUTABLE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/raymond.f) | ||
|
||
# Compile the Fortran code using f2py | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -m numpy.f2py -DF2PY_REPORT_ATEXIT --build-dir ${F2PY_BUILD_DIR} -c -m raymond raymond.f | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
COMMAND $ENV{BLENDINGPYTHON} -m numpy.f2py -DF2PY_REPORT_ATEXIT --fcompiler=intelem --build-dir ${CMAKE_CURRENT_BINARY_DIR} -c -m raymond ${FCODE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
RESULT_VARIABLE F2PY_RESULT | ||
) | ||
|
||
# Generate a list of files matching the pattern | ||
file(GLOB RAYMOND_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*cpython*.so") | ||
|
||
# Install each file individually | ||
foreach(FILE ${RAYMOND_FILES}) | ||
get_filename_component(FILENAME ${FILE} NAME) | ||
install( | ||
FILES ${FILE} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RENAME ${FILENAME} | ||
) | ||
endforeach() | ||
#install raymond.so | ||
file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*raymond*.so") | ||
install(FILES ${SOFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME raymond.so) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(remap_dwinds) | ||
|
||
enable_language(Fortran) | ||
set(CMAKE_Fortran_COMPILER ifort) | ||
|
||
# Set compiler flags | ||
set(FFLAGS "-fopenmp") | ||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS}") | ||
set(CFLAGS "-std=c99") | ||
|
||
# Add the source file | ||
add_library(remap_dwinds MODULE remap_dwinds.f90) | ||
|
||
# Set the output name of the module | ||
set_target_properties(remap_dwinds PROPERTIES OUTPUT_NAME remap_dwinds) | ||
|
||
# Find the path to libiomp5.so | ||
find_library(LIBIOMP5_PATH NAMES libiomp5.so) | ||
|
||
# Specify the build directory for f2py | ||
set(F2PY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# Get the Python executable path - to generalize the f2py3.x command | ||
execute_process( | ||
COMMAND python3 -c "import sys; print(sys.executable)" | ||
OUTPUT_VARIABLE PYTHON_EXECUTABLE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/remap_dwinds.f90) | ||
|
||
# Compile the Fortran code using f2py | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -m numpy.f2py -DF2PY_REPORT_ATEXIT --build-dir ${F2PY_BUILD_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m remap_dwinds remap_dwinds.f90 | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
COMMAND $ENV{BLENDINGPYTHON} -m numpy.f2py -DF2PY_REPORT_ATEXIT --fcompiler=intelem --build-dir ${CMAKE_CURRENT_BINARY_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m remap_dwinds ${FCODE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
RESULT_VARIABLE F2PY_RESULT | ||
) | ||
|
||
# Generate a list of files matching the pattern | ||
file(GLOB REMAP_DWINDS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*cpython*.so") | ||
|
||
# Install each file individually | ||
foreach(FILE ${REMAP_DWINDS_FILES}) | ||
get_filename_component(FILENAME ${FILE} NAME) | ||
install( | ||
FILES ${FILE} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RENAME ${FILENAME} | ||
) | ||
endforeach() | ||
#install remap_dwinds.so | ||
file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_dwinds*.so") | ||
install(FILES ${SOFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME remap_dwinds.so) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,17 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(remap_scalar) | ||
|
||
enable_language(Fortran) | ||
set(CMAKE_Fortran_COMPILER ifort) | ||
|
||
# Set compiler flags | ||
set(FFLAGS "-fopenmp") | ||
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${FFLAGS}") | ||
set(CFLAGS "-std=c99") | ||
|
||
# Add the source file | ||
add_library(remap_scalar MODULE remap_scalar.f90) | ||
|
||
# Set the output name of the module | ||
set_target_properties(remap_scalar PROPERTIES OUTPUT_NAME remap_scalar) | ||
|
||
# Find the path to libiomp5.so | ||
find_library(LIBIOMP5_PATH NAMES libiomp5.so) | ||
|
||
# Specify the build directory for f2py | ||
set(F2PY_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
# Get the Python executable path - to generalize the f2py3.x command | ||
execute_process( | ||
COMMAND python3 -c "import sys; print(sys.executable)" | ||
OUTPUT_VARIABLE PYTHON_EXECUTABLE | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/remap_scalar.f90) | ||
|
||
# Compile the Fortran code using f2py | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -m numpy.f2py -DF2PY_REPORT_ATEXIT --build-dir ${F2PY_BUILD_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m remap_scalar remap_scalar.f90 | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
COMMAND $ENV{BLENDINGPYTHON} -m numpy.f2py -DF2PY_REPORT_ATEXIT --fcompiler=intelem --build-dir ${CMAKE_CURRENT_BINARY_DIR} -c --f90flags='-fopenmp' -L${LIBIOMP5_PATH} -liomp5 -m remap_scalar ${FCODE} | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
RESULT_VARIABLE F2PY_RESULT | ||
) | ||
|
||
# Generate a list of files matching the pattern | ||
file(GLOB REMAP_SCALAR_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*cpython*.so") | ||
|
||
# Install each file individually | ||
foreach(FILE ${REMAP_SCALAR_FILES}) | ||
get_filename_component(FILENAME ${FILE} NAME) | ||
install( | ||
FILES ${FILE} | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RENAME ${FILENAME} | ||
) | ||
endforeach() | ||
#install remap_scalar.so | ||
file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_scalar*.so") | ||
install(FILES ${SOFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME remap_scalar.so) |