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

Upgrade pyPDAF to be compatible with PDAF V2.2.1 #4

Merged
merged 6 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add missed subroutine interface c__pdafomi_localize_covar_noniso
work out build process and CI for Linux and Mac; cleaned compile pyPDAF on windows; hopefully improved stability using intel-fortran-rt and mpi when new conda version is published; cannot workout a windows build CI as it seems very difficult to set up Intel Fortran with Visual studio in github runner but it is useful to keep the compiler environment variable options.
  • Loading branch information
yumengch committed Jul 22, 2024
commit ba439f9da6d447bfa471715196ba1705c71d704e
52 changes: 0 additions & 52 deletions .github/workflows/test_build.yaml

This file was deleted.

28 changes: 28 additions & 0 deletions .github/workflows/test_linux_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test_linux_build
on: [workflow_dispatch]

jobs:
test_ubuntu_build:
runs-on: ubuntu-latest
steps:
- name: check out code
uses: actions/checkout@v4
with:
submodules: 'true'
ref: upgrade2.2.1

- name: installing dependent libraries
run: sudo apt install -y liblapack-dev libblas-dev libopenmpi-dev

- name: Set up Python 3.x
uses: actions/setup-python@v5

- name: install pyPDAF
run: pip install -v .

- name: run example
run: mpiexec --oversubscribe -n 4 python -u example/main.py

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
40 changes: 40 additions & 0 deletions .github/workflows/test_mac_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: test_mac_build
on: [workflow_dispatch]

jobs:
test_mac_build:
runs-on: macos-latest
steps:
- name: check out code
uses: actions/checkout@v4
with:
submodules: 'true'
ref: upgrade2.2.1

- name: Setup Fortran compiler
uses: fortran-lang/[email protected]
id: setup-fortran
with:
compiler: gcc
version: 13

- name: install dependent Libaries
run: brew install openblas lapack open-mpi

- name: Set up Python 3.x
uses: actions/setup-python@v5

- name: install pyPDAF
run: |
mv setup_mac.cfg setup.cfg
pip install -v .

- name: run example
run: |
mv example/config_mac.py example/config.py
mv example/config_obsA_mac.py example/config_obsA.py
mpiexec --oversubscribe -n 4 python -u example/main.py

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
81 changes: 81 additions & 0 deletions .github/workflows/test_win_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: test_win_build
on: [workflow_dispatch]

env:
WINDOWS_BASEKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/e83a8e64-04fc-45df-85c6-c2208d03bdb5/w_BaseKit_p_2024.2.0.635_offline.exe
WINDOWS_HPCKIT_URL: https://registrationcenter-download.intel.com/akdlm/IRC_NAS/0d500705-397e-41b3-8b2b-2a3da1753fc2/w_HPCKit_p_2024.2.0.633_offline.exe
WINDOWS_FORTRAN_COMPONENTS: intel.oneapi.win.ifort-compiler
WINDOWS_DPCPP_COMPONENTS: intel.oneapi.win.mkl.devel:intel.oneapi.win.tbb.devel
CACHE_NUMBER: 5
COMPILER_VERSION: 2024.2.0
TBB_VERSION: 2021.13.0
VS_VER: vs2022

jobs:
test_windows_build:
runs-on: windows-latest
steps:
- name: check out oneAPI code
uses: actions/checkout@v4
with:
repository: oneapi-src/oneapi-ci

- name: cache install fortran
id: cache-install-fortran
uses: actions/cache@v2
with:
path: |
C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat
C:\Program Files (x86)\Intel\oneAPI\compiler
key: install-${{ env.CACHE_NUMBER }}-${{ env.WINDOWS_HPCKIT_URL }}-${{ env.WINDOWS_FORTRAN_COMPONENTS }}-compiler-${{ hashFiles('**/scripts/cache_exclude_windows.sh') }}

- name: install fortran
if: steps.cache-install.outputs.cache-hit != 'true'
shell: bash
run: scripts/install_windows.bat $WINDOWS_HPCKIT_URL $WINDOWS_FORTRAN_COMPONENTS

- name: cache install mkl
id: cache-install-mkl
uses: actions/cache@v2
with:
path: |
C:\Program Files (x86)\Intel\oneAPI\setvars-vcvarsall.bat
C:\Program Files (x86)\Intel\oneAPI\compiler
C:\Program Files (x86)\Intel\oneAPI\tbb
C:\Windows\System32\OpenCL.dll
key: install-${{ env.CACHE_NUMBER }}-${{ env.WINDOWS_BASEKIT_URL }}-${{ env.WINDOWS_DPCPP_COMPONENTS }}-compiler-tbb-opencl-${{ hashFiles('**/scripts/cache_exclude_windows.sh') }}

- name: install mkl
if: steps.cache-install.outputs.cache-hit != 'true'
shell: bash
run: scripts/install_windows.bat $WINDOWS_BASEKIT_URL $WINDOWS_DPCPP_COMPONENTS

- name: restore registry on cache hit
if: steps.cache-install.outputs.cache-hit == 'true'
shell: bash
run: scripts/restore_registry.bat $COMPILER_VERSION $TBB_VERSION

- name: check out pyPDAF code
uses: actions/checkout@v4
with:
submodules: 'true'
ref: upgrade2.2.1

- name: install pyPDAF
run: |
cmd.exe /k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
cmd.exe /k "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
cmd.exe /k '"C:\Program Files (x86)\Intel\oneAPI\mkl\latest\env\vars.bat" && powershell'
cd D:\a\pyPDAF\pyPDAF
Move-Item -Path setup_win.cfg -Destination setup.cfg -Force
pip install -v .

- name: run example
run: |
Move-Item -Path example/config_win.py -Destination example/config.py -Force
Move-Item -Path example/config_obsA_win.py -Destination example/config_obsA.py -Force
mpiexec --oversubscribe -n 4 python -u example/main.py

- name: Setup tmate session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
29 changes: 15 additions & 14 deletions PDAFBuild/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -399,27 +399,28 @@ if (${PDAF_NAME} STREQUAL "pdaf-var")
set(SRC_FILES ${SRC_FILES} ${OBJ_3DVAR} ${OBJ_OPTIM})
endif()

# Check if the build type is not explicitly set and default to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
if (WIN32)
# This will just compile the MPI library modules
# This is necessary for MS-MPI on windows and cannot be included in the os-dependent config file
add_library(mpimod OBJECT ${MPI_Fortran_MODULE_SRC_FILE})
target_include_directories(mpimod PUBLIC ${MPI_Fortran_MODULE_INCLUDE_PATH})
set_target_properties(mpimod PROPERTIES
Fortran_MODULE_DIRECTORY ${MPI_Fortran_MODULE_DIR})
endif()

# extra option for specific files
# set_source_files_properties (${SRC_FILES} PROPERTIES COMPILE_OPTIONS "${RELEASE_COMPILE_OPTIONS}")

# Define a target for pdaf library
add_library(${PDAF_NAME} STATIC ${SRC_FILES})

# Set properties for pdaf library
target_include_directories(${PDAF_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(${PDAF_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

# Set include directory for MPI
target_include_directories(${PDAF_NAME} PUBLIC ${MPI_Fortran_INCLUDE_PATH})
target_include_directories(${PDAF_NAME} PUBLIC ${MPI_Fortran_MODULE_INCLUDE_PATH})
target_include_directories(${PDAF_NAME} PUBLIC ${MPI_Fortran_MODULE_DIR})
set_target_properties(${PDAF_NAME} PROPERTIES
Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../include)

# Move the static library and include files to given directories.
set_target_properties(${PDAF_NAME} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../lib
)
set_target_properties(${PDAF_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../include)
install(TARGETS ${PDAF_NAME}
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../lib
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../lib
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/../bin # For Windows DLLs
)
18 changes: 10 additions & 8 deletions PDAFBuild/linux_gfortran_openmpi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,23 @@ set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -Wextra -g -pedantic -fcheck=all -fback

# set MPI library information
set(MPI_Fortran_INCLUDE_PATH
"/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/include/"
""
CACHE STRING "path to the include directory of MPI_Fortran")
set(MPI_Fortran_MODULE_DIR
"/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/lib/"
""
CACHE STRING "path to the module directory of MPI_Fortran")

# set BLAS information
set(BLAS_NAME "openblas")
set(BLAS_INCLUDE_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openblas-0.3.26-fhoiyp4jbfxtxry3d6skn5he4hqh7ur7/include")
set(BLAS_LIB_PATH "/homeusernamesoftware/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openblas-0.3.26-fhoiyp4jbfxtxry3d6skn5he4hqh7ur7/lib")
set(BLAS_INCLUDE_PATH "")
set(BLAS_LIB_PATH "")

# set LAPACK information
set(LAPACK_NAME "scalapack")
set(LAPACK_INCLUDE_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/netlib-scalapack-2.2.0-izrouv2qyqsuchli4s3jybeksc6m7zdo/include")
set(LAPACK_LIB_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/netlib-scalapack-2.2.0-izrouv2qyqsuchli4s3jybeksc6m7zdo/lib")
set(LAPACK_INCLUDE_PATH "")
set(LAPACK_LIB_PATH "")

# set PDAF information
set(PDAF_INCLUDE_PATH "/home/username/Documents/pyPDAF/PDAF_V2.2.1/include")
# Check if the build type is not explicitly set and default to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
24 changes: 8 additions & 16 deletions PDAFBuild/linux_gfortran_openmpi_pypdaf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,26 @@ set(CMAKE_AR "ar" CACHE FILEPATH "Archiver")
# RANKLIB is used to deal with static libraries
set(CMAKE_RANLIB "ranlib" CACHE FILEPATH "Ranlib")
# Here a linker is specified it can be the compiler used
set(CMAKE_LINKER "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/bin/mpif90" CACHE FILEPATH "Linker")
set(CMAKE_LINKER "mpif90" CACHE FILEPATH "Linker")
# CPP is the C preprocessor
set(CMAKE_CPP "cpp" CACHE FILEPATH "C Preprocessor")

# set compiler executable
set(CMAKE_Fortran_COMPILER "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/bin/mpif90")
set(CMAKE_Fortran_COMPILER "mpif90")
# Set compiler flags for Release/Production configurations
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ffree-line-length-none -fdefault-real-8 -fPIC")
# Set compiler flags for Debug configurations
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -Wextra -g -pedantic -fcheck=all -fbacktrace -ffree-line-length-none -fdefault-real-8 -fPIC")

# set MPI library information
set(MPI_Fortran_INCLUDE_PATH
"/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/include/"
""
CACHE STRING "path to the include directory of MPI_Fortran")
set(MPI_Fortran_MODULE_DIR
"/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openmpi-5.0.3-ummuvvrxsncu6txyqbvehgqkpijndmql/lib/"
""
CACHE STRING "path to the module directory of MPI_Fortran")

# set BLAS information
set(BLAS_NAME "openblas")
set(BLAS_INCLUDE_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openblas-0.3.26-fhoiyp4jbfxtxry3d6skn5he4hqh7ur7/include")
set(BLAS_LIB_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/openblas-0.3.26-fhoiyp4jbfxtxry3d6skn5he4hqh7ur7/lib")

# set LAPACK information
set(LAPACK_NAME "scalapack")
set(LAPACK_INCLUDE_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/netlib-scalapack-2.2.0-izrouv2qyqsuchli4s3jybeksc6m7zdo/include")
set(LAPACK_LIB_PATH "/home/username/software/spack-0.22.1/opt/spack/linux-ubuntu22.04-skylake/gcc-13.2.0/netlib-scalapack-2.2.0-izrouv2qyqsuchli4s3jybeksc6m7zdo/lib")

# set PDAF information
set(PDAF_INCLUDE_PATH "/home/username/Documents/pyPDAF/PDAF_V2.2.1/include")
# Check if the build type is not explicitly set and default to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
32 changes: 32 additions & 0 deletions PDAFBuild/osx_gfortran_openmpi_pypdaf.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Set the PDAF library name, it can be pdaf-var or pdaf-d
set(PDAF_NAME "pdaf-var")

# Set preprocessor and linker for current system
# AR is used to generate static libraries
set(CMAKE_AR "ar" CACHE FILEPATH "Archiver")
# RANKLIB is used to deal with static libraries
set(CMAKE_RANLIB "ranlib" CACHE FILEPATH "Ranlib")
# Here a linker is specified it can be the compiler used
set(CMAKE_LINKER "mpif90" CACHE FILEPATH "Linker")
# CPP is the C preprocessor
set(CMAKE_CPP "cpp" CACHE FILEPATH "C Preprocessor")

# set compiler executable
set(CMAKE_Fortran_COMPILER "mpif90")
# Set compiler flags for Release/Production configurations
set(CMAKE_Fortran_FLAGS_RELEASE "-O3 -ffree-line-length-none -fdefault-real-8 -fPIC -mmacosx-version-min=11.0")
# Set compiler flags for Debug configurations
set(CMAKE_Fortran_FLAGS_DEBUG "-O0 -Wall -Wextra -g -pedantic -fcheck=all -fbacktrace -ffree-line-length-none -fdefault-real-8 -fPIC")

# set MPI library information
set(MPI_Fortran_INCLUDE_PATH
""
CACHE STRING "path to the include directory of MPI_Fortran")
set(MPI_Fortran_MODULE_DIR
""
CACHE STRING "path to the module directory of MPI_Fortran")

# Check if the build type is not explicitly set and default to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
33 changes: 33 additions & 0 deletions PDAFBuild/win_intel_msmpi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Set the PDAF library name, it can be pdaf-var or pdaf-d
set(PDAF_NAME "pdaf-var")

# set MPI library information
set(MPI_NAME "msmpi;msmpifec")
set(MPI_Fortran_INCLUDE_PATH
"C:/Program Files (x86)/Microsoft SDKs/MPI/Include"
CACHE STRING "path to the MPI Fortran mpi.h include directory")
set(MPI_Fortran_MODULE_INCLUDE_PATH
"C:/Program Files (x86)/Microsoft SDKs/MPI/Include/x64"
CACHE STRING "path to the include directory to compile MPI Fortran module")
set(MPI_Fortran_MODULE_DIR
"C:/Users/cymji/Desktop/pyPDAF/PDAF_V2.2.1/mpi_include"
CACHE STRING "path to the installed module directory of MPI_Fortran")
# We have to compile MPI-MPI mod file ourselves in Windows
set(MPI_Fortran_MODULE_SRC_FILE "C:/Program Files (x86)/Microsoft SDKs/MPI/Include/mpi.f90"
CACHE STRING "path to the MPI Fortran module source file" )
# We have to compile MPI-MPI mod file ourselves in Windows
set(MPI_Fortran_LINK_DIR "C:/Program Files (x86)/Microsoft SDKs/MPI/Lib/x64"
CACHE STRING "path to the MPI Fortran libraries" )
# This overrides any language flags and must be given before add_library
set_source_files_properties(${MPI_Fortran_MODULE_SRC_FILE} PROPERTIES COMPILE_FLAGS "/O2 /Qdiag-disable:10448 /Qdiag-disable:10423")

# ideally, we should provide compiler options based on target or source files,
# but this will force us to use multiple config files or encode it in the CMakelist.txt file
set(CMAKE_Fortran_FLAGS_RELEASE "/O2 /4R8 /Qdiag-disable:10448 /Qdiag-disable:10423" CACHE STRING "RELEASE FLAGS" FORCE)
# Set compiler flags for Debug configurations
set(CMAKE_Fortran_FLAGS_DEBUG "/Od /debug:full /traceback /check:all /Qtrapuv /4R8 /Qdiag-disable:10448 /Qdiag-disable:10423" CACHE STRING "DEBUG FLAGS" FORCE)

# set BLAS information
set(BLAS_NAME "mkl_core;mkl_intel_lp64;mkl_sequential")
set(BLAS_INCLUDE_PATH "")
set(BLAS_LIB_PATH "C:/Program Files (x86)/Intel/oneAPI/mkl/2024.2/lib")
Loading