From d45f06b42d5b853435cb3f2e1f8f4a3ca31b6e13 Mon Sep 17 00:00:00 2001 From: "guoqing.ge" Date: Wed, 25 Oct 2023 22:31:30 -0600 Subject: [PATCH 1/2] a working CMake system for the blending code --- blending/chgres_winds/CMakeLists.txt | 43 +++---------------------- blending/chgres_winds/installSO.CMake | 2 ++ blending/raymond/CMakeLists.txt | 45 +++------------------------ blending/raymond/installSO.CMake | 2 ++ blending/remap_dwinds/CMakeLists.txt | 43 +++---------------------- blending/remap_dwinds/installSO.CMake | 2 ++ blending/remap_scalar/CMakeLists.txt | 43 +++---------------------- blending/remap_scalar/installSO.CMake | 2 ++ 8 files changed, 28 insertions(+), 154 deletions(-) create mode 100644 blending/chgres_winds/installSO.CMake create mode 100644 blending/raymond/installSO.CMake create mode 100644 blending/remap_dwinds/installSO.CMake create mode 100644 blending/remap_scalar/installSO.CMake diff --git a/blending/chgres_winds/CMakeLists.txt b/blending/chgres_winds/CMakeLists.txt index 6770ba1..e7d8827 100644 --- a/blending/chgres_winds/CMakeLists.txt +++ b/blending/chgres_winds/CMakeLists.txt @@ -1,49 +1,16 @@ 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) - +#set(CFLAGS "-std=c99") # 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(SCRIPT "installSO.CMake") diff --git a/blending/chgres_winds/installSO.CMake b/blending/chgres_winds/installSO.CMake new file mode 100644 index 0000000..14c9b26 --- /dev/null +++ b/blending/chgres_winds/installSO.CMake @@ -0,0 +1,2 @@ +file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*chgres_winds*.so") +file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/raymond/CMakeLists.txt b/blending/raymond/CMakeLists.txt index cddf66a..a586955 100644 --- a/blending/raymond/CMakeLists.txt +++ b/blending/raymond/CMakeLists.txt @@ -1,49 +1,14 @@ 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(CFLAGS "-std=c99") +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(SCRIPT "installSO.CMake") diff --git a/blending/raymond/installSO.CMake b/blending/raymond/installSO.CMake new file mode 100644 index 0000000..1c720fb --- /dev/null +++ b/blending/raymond/installSO.CMake @@ -0,0 +1,2 @@ +file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*raymond*.so") +file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/remap_dwinds/CMakeLists.txt b/blending/remap_dwinds/CMakeLists.txt index 2515dff..36eba32 100644 --- a/blending/remap_dwinds/CMakeLists.txt +++ b/blending/remap_dwinds/CMakeLists.txt @@ -1,49 +1,16 @@ 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) - +#set(CFLAGS "-std=c99") # 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(SCRIPT "installSO.CMake") diff --git a/blending/remap_dwinds/installSO.CMake b/blending/remap_dwinds/installSO.CMake new file mode 100644 index 0000000..a250810 --- /dev/null +++ b/blending/remap_dwinds/installSO.CMake @@ -0,0 +1,2 @@ +file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_dwinds*.so") +file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/remap_scalar/CMakeLists.txt b/blending/remap_scalar/CMakeLists.txt index 320ed69..1f10964 100644 --- a/blending/remap_scalar/CMakeLists.txt +++ b/blending/remap_scalar/CMakeLists.txt @@ -1,49 +1,16 @@ 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) - +#set(CFLAGS "-std=c99") # 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(SCRIPT "installSO.CMake") diff --git a/blending/remap_scalar/installSO.CMake b/blending/remap_scalar/installSO.CMake new file mode 100644 index 0000000..e1916e2 --- /dev/null +++ b/blending/remap_scalar/installSO.CMake @@ -0,0 +1,2 @@ +file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_scalar*.so") +file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") From 955566553c0dc6aa03e9668379952bcdf006a95f Mon Sep 17 00:00:00 2001 From: "guoqing.ge" Date: Thu, 26 Oct 2023 07:33:30 -0600 Subject: [PATCH 2/2] simplification and cleaning --- blending/chgres_winds/CMakeLists.txt | 5 +++-- blending/chgres_winds/installSO.CMake | 2 -- blending/raymond/CMakeLists.txt | 5 +++-- blending/raymond/installSO.CMake | 2 -- blending/remap_dwinds/CMakeLists.txt | 5 +++-- blending/remap_dwinds/installSO.CMake | 2 -- blending/remap_scalar/CMakeLists.txt | 5 +++-- blending/remap_scalar/installSO.CMake | 2 -- 8 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 blending/chgres_winds/installSO.CMake delete mode 100644 blending/raymond/installSO.CMake delete mode 100644 blending/remap_dwinds/installSO.CMake delete mode 100644 blending/remap_scalar/installSO.CMake diff --git a/blending/chgres_winds/CMakeLists.txt b/blending/chgres_winds/CMakeLists.txt index e7d8827..b4eb2f6 100644 --- a/blending/chgres_winds/CMakeLists.txt +++ b/blending/chgres_winds/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(chgres_winds) -#set(CFLAGS "-std=c99") # Find the path to libiomp5.so find_library(LIBIOMP5_PATH NAMES libiomp5.so) set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/chgres_winds.f90) @@ -13,4 +12,6 @@ execute_process( RESULT_VARIABLE F2PY_RESULT ) -install(SCRIPT "installSO.CMake") +#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) diff --git a/blending/chgres_winds/installSO.CMake b/blending/chgres_winds/installSO.CMake deleted file mode 100644 index 14c9b26..0000000 --- a/blending/chgres_winds/installSO.CMake +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*chgres_winds*.so") -file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/raymond/CMakeLists.txt b/blending/raymond/CMakeLists.txt index a586955..dcd604c 100644 --- a/blending/raymond/CMakeLists.txt +++ b/blending/raymond/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(raymond) -#set(CFLAGS "-std=c99") set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/raymond.f) # Compile the Fortran code using f2py @@ -11,4 +10,6 @@ execute_process( RESULT_VARIABLE F2PY_RESULT ) -install(SCRIPT "installSO.CMake") +#install raymond.so +file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*raymond*.so") +install(FILES ${SOFILE} DESTINATION ${CMAKE_INSTALL_LIBDIR} RENAME raymond.so) diff --git a/blending/raymond/installSO.CMake b/blending/raymond/installSO.CMake deleted file mode 100644 index 1c720fb..0000000 --- a/blending/raymond/installSO.CMake +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*raymond*.so") -file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/remap_dwinds/CMakeLists.txt b/blending/remap_dwinds/CMakeLists.txt index 36eba32..945ab3f 100644 --- a/blending/remap_dwinds/CMakeLists.txt +++ b/blending/remap_dwinds/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(remap_dwinds) -#set(CFLAGS "-std=c99") # Find the path to libiomp5.so find_library(LIBIOMP5_PATH NAMES libiomp5.so) set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/remap_dwinds.f90) @@ -13,4 +12,6 @@ execute_process( RESULT_VARIABLE F2PY_RESULT ) -install(SCRIPT "installSO.CMake") +#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) diff --git a/blending/remap_dwinds/installSO.CMake b/blending/remap_dwinds/installSO.CMake deleted file mode 100644 index a250810..0000000 --- a/blending/remap_dwinds/installSO.CMake +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_dwinds*.so") -file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/blending/remap_scalar/CMakeLists.txt b/blending/remap_scalar/CMakeLists.txt index 1f10964..09c156a 100644 --- a/blending/remap_scalar/CMakeLists.txt +++ b/blending/remap_scalar/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.0) project(remap_scalar) -#set(CFLAGS "-std=c99") # Find the path to libiomp5.so find_library(LIBIOMP5_PATH NAMES libiomp5.so) set(FCODE ${CMAKE_CURRENT_SOURCE_DIR}/remap_scalar.f90) @@ -13,4 +12,6 @@ execute_process( RESULT_VARIABLE F2PY_RESULT ) -install(SCRIPT "installSO.CMake") +#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) diff --git a/blending/remap_scalar/installSO.CMake b/blending/remap_scalar/installSO.CMake deleted file mode 100644 index e1916e2..0000000 --- a/blending/remap_scalar/installSO.CMake +++ /dev/null @@ -1,2 +0,0 @@ -file(GLOB_RECURSE SOFILE "${CMAKE_CURRENT_BINARY_DIR}/*remap_scalar*.so") -file(INSTALL "${SOFILE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")