From 3f75a6c66a7c65db4ccc51e9cc687b1f7d75cfc8 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 12:24:32 +0200 Subject: [PATCH 1/5] remove deprecated findFFTW that fails on runners --- CMakeLists.txt | 63 ++++++++++++++++++++++++++-------------------- src/CMakeLists.txt | 4 +-- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98dc87d9..12b0cd08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,36 +80,45 @@ find_package (LAPACK REQUIRED) # Find FFTW3. # Intel oneAPI has FFT3 available as part of MKL. Just linking against MKL gives FFTW functionality. if (NOT ${BLA_VENDOR} MATCHES "^Intel") - # For standard FFTW library - # We are using findfftw module from github/egpbos. - # PPPL provides fftwconfig.cmake. We could try that first in future - - # To guide cmake to the location of FFT, set FFTW_ROOT to the path of FFTW - # Ex: For PPPL gcc suite of compilers, - # We are using FFTW find module from github.com/egpbos - # - configure_file(downloadFindFFTW.cmake.in findFFTW-download/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download ) - if(result) - message(FATAL_ERROR "CMake step for findFFTW failed: ${result}") - else() - message("CMake step for findFFTW completed (${result}).") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-download ) - if(result) - message(FATAL_ERROR "Build step for findFFTW failed: ${result}") - endif() + find_package(FFTW3 REQUIRED) + + # will find it, but FFTW_LIBRARIES is set to 'fftw3' simple string, which F2py does not like + + # Hack to find the proper .so looking first in conda, then in other + set(FFTW3_LIBRARY_PATHS) # Initialize empty list + + if(DEFINED CONDA_PREFIX) + list(APPEND FFTW3_LIBRARY_PATHS "${CONDA_PREFIX}/lib") # Add Conda first + endif() + + list(APPEND FFTW3_LIBRARY_PATHS + /usr/lib + /usr/local/lib + ${FFTW3_ROOT_DIR}/lib + ) + # also add a path relative to the found include dirs, which is a true path + if(FFTW3_INCLUDE_DIRS) + string(REPLACE "/include" "/lib" FFTW3_LIBRARY_DIR_FROM_INCLUDE "${FFTW3_INCLUDE_DIRS}") + list(APPEND FFTW3_LIBRARY_PATHS ${FFTW3_LIBRARY_DIR_FROM_INCLUDE}) + endif() + + # Find the library using the constructed list of paths. Should find the path to the .so + find_library(FFTW3_LIBRARY_TRUE + NAMES fftw3 + PATHS ${FFTW3_LIBRARY_PATHS} + NO_DEFAULT_PATH + ) + + if(FFTW3_LIBRARY_TRUE) + message(STATUS "FFTW3 Library with full path found: ${FFTW3_LIBRARY_TRUE}") + set(FFTW3_FULL_PATH ${FFTW3_LIBRARY}) + else() + message(FATAL_ERROR "Could not find FFTW3 library with find_library.") + endif() - set(findFFTW_DIR ${CMAKE_CURRENT_BINARY_DIR}/findFFTW-src) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${findFFTW_DIR}") - find_package(FFTW REQUIRED) else() # Not required for OneAPI, but for older versions - set(FFTW_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) + set(FFTW3_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) endif() # Find HDF5 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fcc9bfb3..387457d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -262,11 +262,11 @@ target_include_directories(spec PUBLIC ${HDF5_C_INCLUDE_DIRS} ${HDF5_Fortran_INC # MKL could be used for all the three target_link_libraries(spec PUBLIC - ${FFTW_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} + ${FFTW3_LIBRARY_TRUE} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ) target_include_directories(spec PUBLIC - ${FFTW_INCLUDE_DIRS} ${LAPACK_INCLUDE_DIRS} ${BLAS_INCLUDE_DIRS} + ${FFTW3_INCLUDE_DIRS} ${LAPACK_INCLUDE_DIRS} ${BLAS_INCLUDE_DIRS} ) #if(SKBUILD) From 8656934c65c7a102e62b40f61798c0025ea25064 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 13:16:42 +0200 Subject: [PATCH 2/5] find fftw in specific folders --- CMakeLists.txt | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12b0cd08..d8ef131e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,42 +80,46 @@ find_package (LAPACK REQUIRED) # Find FFTW3. # Intel oneAPI has FFT3 available as part of MKL. Just linking against MKL gives FFTW functionality. if (NOT ${BLA_VENDOR} MATCHES "^Intel") - find_package(FFTW3 REQUIRED) - - # will find it, but FFTW_LIBRARIES is set to 'fftw3' simple string, which F2py does not like - # Hack to find the proper .so looking first in conda, then in other - set(FFTW3_LIBRARY_PATHS) # Initialize empty list + set(FFTW3_TEST_PATHS) # Initialize empty list if(DEFINED CONDA_PREFIX) - list(APPEND FFTW3_LIBRARY_PATHS "${CONDA_PREFIX}/lib") # Add Conda first + list(APPEND FFTW3_TEST_PATHS "${CONDA_PREFIX}/lib") # Add Conda first endif() - list(APPEND FFTW3_LIBRARY_PATHS + list(APPEND FFTW3_TEST_PATHS /usr/lib /usr/local/lib ${FFTW3_ROOT_DIR}/lib ) - # also add a path relative to the found include dirs, which is a true path - if(FFTW3_INCLUDE_DIRS) - string(REPLACE "/include" "/lib" FFTW3_LIBRARY_DIR_FROM_INCLUDE "${FFTW3_INCLUDE_DIRS}") - list(APPEND FFTW3_LIBRARY_PATHS ${FFTW3_LIBRARY_DIR_FROM_INCLUDE}) - endif() # Find the library using the constructed list of paths. Should find the path to the .so find_library(FFTW3_LIBRARY_TRUE NAMES fftw3 - PATHS ${FFTW3_LIBRARY_PATHS} - NO_DEFAULT_PATH + PATHS ${FFTW3_TEST_PATHS} + ) + + + set(FFTW_INC_TEST_PATHS) # Initialize an empty list for include paths + + foreach(path ${FFTW3_TEST_PATHS}) + string(REGEX REPLACE "/lib$" "/include" INCLUDE_PATH "${path}") + list(APPEND FFTW_INC_TEST_PATHS "${INCLUDE_PATH}") + endforeach() + + find_path(FFTW3_INCLUDE_DIRS # Use FFTW3_INCLUDE_DIRS as in the normal find_package call. + NAMES fftw3.f90 fftw3.h # Check for both Fortran and C headers + PATHS ${FFTW_INC_TEST_PATHS} + REQUIRED ) - if(FFTW3_LIBRARY_TRUE) - message(STATUS "FFTW3 Library with full path found: ${FFTW3_LIBRARY_TRUE}") - set(FFTW3_FULL_PATH ${FFTW3_LIBRARY}) - else() - message(FATAL_ERROR "Could not find FFTW3 library with find_library.") + if(NOT FFTW3_LIBRARY_TRUE) + message(FATAL_ERROR "Could not find FFTW3 library with find_library.") endif() + message(STATUS "found fftw3 library with path: ${FFTW3_LIBRARY_TRUE}") + message(STATUS "found fftw3 include dir with path: ${FFTW3_INCLUDE_DIRS}") + else() # Not required for OneAPI, but for older versions set(FFTW3_INCLUDE_DIRS $ENV{MKLROOT}/include/fftw) From 86c9a9ef3f968f4dcbe1dbe37dbd3d79a13b886d Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 13:41:05 +0200 Subject: [PATCH 3/5] Remove specific hdf5 install in workflow --- .github/workflows/build.yml | 2 +- .github/workflows/build_cmake.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2dd748a1..1e2cd829 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib cd ${{ github.workspace }}/Utilities/pythontools pip3 install -v . diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 60496cd5..39d52a37 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -15,7 +15,7 @@ jobs: - name: Install prereqs run: | sudo apt-get update - sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-103 libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev + sudo apt-get install gfortran mpi-default-bin mpi-default-dev libhdf5-dev libfftw3-bin libfftw3-dev libopenblas0-openmp libopenblas-dev pip3 install --upgrade pip pip3 install --user ninja cmake scipy pip3 install --user numpy f90nml scikit-build scipy h5py matplotlib From 24f45ba90ce33ab57eed1bac40c59f996226ecca Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 2 Apr 2025 14:07:01 +0200 Subject: [PATCH 4/5] downgrade to python3.11 as install fails for 3.12 (numpy/f2py/meson issue?) --- .github/workflows/python_wrapper.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/python_wrapper.yml b/.github/workflows/python_wrapper.yml index 8977807c..bae90752 100644 --- a/.github/workflows/python_wrapper.yml +++ b/.github/workflows/python_wrapper.yml @@ -8,6 +8,11 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: "3.11" + # Python3 should be pre-installed on 'ubuntu-latest' - name: Python version info run: | From 0c02ae2e4b2a7cad4a55ae97f995bde70ada7543 Mon Sep 17 00:00:00 2001 From: ErolBa Date: Thu, 3 Apr 2025 16:29:33 +0200 Subject: [PATCH 5/5] Added force printing to output, Lcheck=7 --- src/global.f90 | 2 ++ src/inputlist.f90 | 1 + src/sphdf5.f90 | 8 +++++++- src/xspech.f90 | 39 ++++++++++++++++++++++++++++++--------- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/global.f90 b/src/global.f90 index 902cd112..cdc1dff1 100644 --- a/src/global.f90 +++ b/src/global.f90 @@ -741,6 +741,8 @@ module allglobal LOGICAL :: Lhessian3Dallocated !< flag to indicate that 2D Hessian matrix is allocated (?) REAL, allocatable :: hessian3D(:,:) !< Hessian 3D REAL, allocatable :: dessian3D(:,:) !< derivative Hessian 3D + + REAL, allocatable :: force_final(:) !< Final force on the interfaces [inface*mode] !> @} !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! diff --git a/src/inputlist.f90 b/src/inputlist.f90 index 30c0b04b..74cf25df 100644 --- a/src/inputlist.f90 +++ b/src/inputlist.f90 @@ -535,6 +535,7 @@ module inputlist !<
  • must set \c Freebound=1, \c Lfindzero>0, \c mfreeits!=0
  • !<
  • \c xdiagno must be executed manually
  • !< + !<
  • if \c Lcheck = 7, calculates the force and force_grad, outputs them to the .h5 file
  • !< LOGICAL :: Ltiming = .false. !< to check timing LOGICAL :: Ltransform = .false. !< to evaluate iota and straight field line coordinates diff --git a/src/sphdf5.f90 b/src/sphdf5.f90 index f6c833bf..c54e3779 100644 --- a/src/sphdf5.f90 +++ b/src/sphdf5.f90 @@ -1038,7 +1038,8 @@ subroutine hdfint lmns, & TT, & beltramierror, & - IPDt, dlambdaout, lmns + IPDt, dlambdaout, lmns, & + force_final, hessian, NGdof LOCALS @@ -1165,6 +1166,11 @@ subroutine hdfint !>
  • All quantities marked as real should be treated as double precision.
  • !> + if( Lcheck.eq.7 ) then + HWRITERV(grpOutput, NGdof+1, force_final, force_final(0:NGdof)) + HWRITERA( grpOutput, NGdof, NGdof, force_final_grad, hessian(1:NGdof,1:NGdof) ) + end if + HCLOSEGRP( grpOutput ) endif ! myid.eq.0 diff --git a/src/xspech.f90 b/src/xspech.f90 index 1389b232..5d251301 100644 --- a/src/xspech.f90 +++ b/src/xspech.f90 @@ -317,7 +317,9 @@ subroutine spec first_free_bound, & dMA, dMB, dMD, dMG, MBpsi, solution, IPDt, & version, & - MPI_COMM_SPEC + MPI_COMM_SPEC, & + force_final, Lhessianallocated, LocalConstraint, hessian, dBBdmp, dFFdRZ, dmupfdx, & + dRodR, dRodZ, dZodR, dZodZ, dessian, LGdof !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! @@ -483,18 +485,37 @@ subroutine spec !-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-!-! - SALLOCATE( gradient, (0:NGdof), zero ) + if(Lcheck.eq.7) then + SALLOCATE( force_final, (0:NGdof), zero ) + SALLOCATE( hessian, (1:NGdof,1:NGdof), zero ) + SALLOCATE( dessian, (1:NGdof,1:LGdof), zero ) + SALLOCATE( dFFdRZ, (1:LGdof,0:1,1:LGdof,0:1,1:Mvol), zero ) + SALLOCATE( dBBdmp, (1:LGdof,1:Mvol,0:1,1:2), zero ) + if( LocalConstraint ) then + SALLOCATE( dmupfdx, (1:Mvol, 1:1,1:2,1:LGdof,0:1), zero ) + else + SALLOCATE( dmupfdx, (1:Mvol, 1:Mvol-1,1:2,1:LGdof,1), zero ) ! TODO change the format to put vvol in last index position... + endif + Lhessianallocated = .true. + SALLOCATE( dRodR, (1:Ntz,0:3,1:mn), zero ) ! calculated in rzaxis; 19 Sep 16; + SALLOCATE( dRodZ, (1:Ntz,0:3,1:mn), zero ) + SALLOCATE( dZodR, (1:Ntz,0:3,1:mn), zero ) + SALLOCATE( dZodZ, (1:Ntz,0:3,1:mn), zero ) + + LComputeDerivatives = .true. - lastcpu = GETTIME + LComputeAxis = .true. + WCALL( xspech, dforce, ( NGdof, position(0:NGdof), force_final(0:NGdof), LComputeDerivatives, LComputeAxis) ) - LComputeDerivatives = .false. - LComputeAxis = .true. -! vvol = Mvol ; ideriv = 0 ; ii = 1 -! write(ounit,'("xspech : ", 10x ," : sum(Ate(",i3,",",i2,",",i2,")%s) =",99es23.15)') vvol, ideriv, ii, sum(Ate(vvol,ideriv,ii)%s(0:Lrad(vvol))) + else + SALLOCATE( force_final, (0:NGdof), zero ) - WCALL( xspech, dforce, ( NGdof, position(0:NGdof), gradient(0:NGdof), LComputeDerivatives, LComputeAxis) ) ! (re-)calculate Beltrami fields; + LComputeDerivatives = .false. + LComputeAxis = .true. - DALLOCATE(gradient) + WCALL( xspech, dforce, ( NGdof, position(0:NGdof), force_final(0:NGdof), LComputeDerivatives, LComputeAxis) ) + end if + #ifdef DEBUG do vvol = 1, Mvol-1