Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
703ea8c
Add gablsdyn with dynamic profiling of T
karimali5 Sep 18, 2025
85a2862
use local fftw3 on Stampede3
karimali5 Sep 18, 2025
9100acd
add stable_pbl_concurrent from Kirby's branch
karimali5 Sep 18, 2025
2eb3f7a
add dummy controller so conc. follows prec. actions
karimali5 Sep 19, 2025
10ba539
changes to make code compile on AMD machine with GNU
karimali5 Oct 27, 2025
4fb9720
fix release run on AMD using GNU
karimali5 Nov 10, 2025
125d084
add O3 in GNU make flags
karimali5 Dec 3, 2025
2aef2c0
only do checks for xy-budget flags if xy-budgets are on
karimali5 Dec 3, 2025
9e2aef1
comment out start_io and xy-budgets in gablsdyn
karimali5 Dec 3, 2025
69ee728
initialize domain in gablsdyn from 1D vertical profiles
karimali5 Dec 3, 2025
b3d1180
put def of namelist in tile prog before keys def - to work with GNU
karimali5 Dec 10, 2025
d54bcac
roll back to original initialize.F90 in gablsdyn
karimali5 Dec 10, 2025
50df81f
Merge pull request #15 from Howland-Lab/gnu_amd_KA
karimali5 Dec 10, 2025
b7e7627
fix fringe association for w
karimali5 Dec 27, 2025
7dfc51a
Add compact set of deficit budgets
karimali5 Jan 29, 2026
d5fa510
Fix the sign of the mean buoyancy term
karimali5 Jan 29, 2026
ce6e0fa
comment out unnesscary checks in actuator disk
karimali5 Jan 29, 2026
e2a6314
move delta_tauij to updateBudget
karimali5 Jan 30, 2026
460e041
remove time-weighted sum because time-averaged budget are not summed …
karimali5 Jan 30, 2026
0ce6c07
Update AssembleBudget2 to use already computed flow gradients in igrid
karimali5 Feb 1, 2026
c735fb8
intermediate save
karimali5 Feb 2, 2026
9e5389f
push to Anvil to test Budget 2
Feb 2, 2026
80059d8
add MCG- add parity for ddz & E2C- expand budget 2
karimali5 Feb 3, 2026
495d00a
fix size of budget 3
karimali5 Feb 4, 2026
0b42c7a
comment out the turbine forcing covariance (small and very local)
karimali5 Feb 4, 2026
02291f5
comment out turbine forcing from TKE budget
karimali5 Feb 10, 2026
04cd7ab
update temperature initialization
karimali5 Feb 10, 2026
7b5e8ca
Fatal error when any pencil thickness = 1 and turbines are used
karimali5 Feb 15, 2026
4e78d08
some cleanup
karimali5 Feb 15, 2026
bd90b96
A program to compute derivatives offline
karimali5 Feb 16, 2026
4f1c312
Adding dx, dy, dz to turbine init in case the processor grid only has…
kirbyh Nov 3, 2025
8320ed3
small bug fix to read_2d_ascii
kirbyh Aug 12, 2025
22716f7
Added read arbitrary inflow to get_u
kirbyh Aug 12, 2025
8187f62
new, fast implementation for ADM type 5 (TESTED)
kirbyh Aug 13, 2025
52e1f14
Revert extraneous commits from other features not part of the ADM imp…
kirbyh Aug 18, 2025
e9ba023
Revert "small bug fix to read_2d_ascii"
kirbyh Aug 18, 2025
35b3fa0
Increasing ADM sampling resolution parameter to fix kernel bug
kirbyh Feb 8, 2026
a111f38
Attempt at fixing double power output
skygering Jan 8, 2026
fb5e5b1
Remove repreated turbine values written to .pow and .vel files with b…
skygering Jan 8, 2026
c6de9ab
Reorganize dump_visualization_files block
skygering Jan 8, 2026
2752495
Reset setup file
skygering Jan 9, 2026
768ac12
Decrease allocations for time budgets
skygering Oct 8, 2025
3846155
Update cmake version
skygering Oct 8, 2025
f9dbad2
Further memory cleanup in budgets
skygering Oct 8, 2025
4fa823a
Update destroy code
skygering Oct 18, 2025
ea4417c
Update destroy budget call
skygering Oct 18, 2025
1aebac6
Update destroy methods
skygering Oct 19, 2025
0b5d165
Restoring local FFTW path and updating cmake to 3.31.9 on Stampede3
kirbyh Feb 8, 2026
507e860
small updates in destroy to release correct allocated memory
kirbyh Feb 8, 2026
df8b938
use local fftw3 on Stampede3
karimali5 Sep 18, 2025
0119297
changes to make code compile on AMD machine with GNU
karimali5 Oct 27, 2025
30b3b40
fix release run on AMD using GNU
karimali5 Nov 10, 2025
23da9d2
missing endif() from merging during rebase
karimali5 Feb 19, 2026
e708588
make deficit budgets not dependent on time-avg budgets of full flow
karimali5 Feb 22, 2026
1202ce1
add option to squeeze time-avg budget 0when it runs with deficit bud…
karimali5 Feb 22, 2026
a51b85a
add option to skip box averaging of budgets in ConstructDeficitBudgets
karimali5 Feb 22, 2026
5ababb2
include squeez option for restart of time-averaged budget 0
karimali5 Feb 24, 2026
525ca72
Used ChatGPT to replace MPI_SEND & MPI_REC with MPI_GATHER in io_star…
karimali5 Feb 24, 2026
86f45b2
Add MPI_GATHER in the list of 'external' rouines in igrid.F90
karimali5 Feb 24, 2026
55cc561
Add external statement for MPI_ALLREDUCE
karimali5 Feb 24, 2026
47639ed
Cleanup MPI stuff in actuator disk module
karimali5 Mar 2, 2026
b1dd2c5
add deallocation of extra arrays in destroy
karimali5 Mar 2, 2026
d9435a2
Add y and z momentum budgets
karimali5 Mar 2, 2026
f56788f
add iostat to reading namelists in constructdeficitbudgets
karimali5 Mar 3, 2026
3089da5
fix typo in refine_fields
karimali5 Mar 3, 2026
7f553a6
add some error messages to constrcutDeficitBudget
karimali5 Mar 5, 2026
5bb4ce8
Fix zero-padding + move decomp_inter to module level
karimali5 Mar 5, 2026
ff5d0bd
deallocate ktmp at end of fft init
karimali5 Mar 11, 2026
aa03265
fix build on PadeOps
Mar 16, 2026
fc4393a
Add specific height to pertub T below instead of using xdim in case R…
karimali5 Mar 26, 2026
7800703
add hpert to pre_conc_compact_budget
karimali5 Mar 26, 2026
9bb2046
Add a fringe method to damp advection of vertical momentum
karimali5 Mar 26, 2026
15df319
fix inputfile length in declaration
karimali5 Apr 3, 2026
39a1612
safeguard actuatordisk_filtered aganst single-cell slabs
karimali5 Apr 7, 2026
218f6e2
Use correct decomp_info object for edge transpose in buoyancy term
karimali5 Apr 8, 2026
d833d7a
Add setup file for Anvil
karimali5 Apr 15, 2026
006b4de
specify versions of loaded modules
karimali5 Apr 17, 2026
2ed5165
Refactor min/max calculations in doTemporalStuff
karimali5 May 4, 2026
01d6762
Fringe: Compute reduced min/max outside function/subroutine arguments
karimali5 May 4, 2026
5b57391
fix typo in latest commit of temporalHook
karimali5 May 4, 2026
0886d52
Derivative of multiple files in the same call
karimali5 May 4, 2026
686c0af
Safeguards in destroy of compact deficit budgets
karimali5 May 5, 2026
bb01d54
Add program to clip 3D field
karimali5 May 21, 2026
fd01bad
Add y taper in AD Fringe
karimali5 May 21, 2026
823d3f7
Add Spectrum Program
karimali5 May 22, 2026
b9bfd85
Add some fixes to Spectrum.F90
karimali5 May 23, 2026
004b2e9
change AD Fringe namelist name to avoid collision with &Fringe namelist
karimali5 May 25, 2026
6c2e385
Add 1D options to Spectrum
karimali5 May 25, 2026
51d6948
Add yz spectra per x
karimali5 May 25, 2026
9dbe1b4
add lateral spectrum and vertical stats
karimali5 May 29, 2026
de544dc
Make PadeOps compatible with AMD compiler on Archer2
karimali5 Jun 2, 2026
0012964
GNU compiler does not accept using a real as size indicator
karimali5 Jun 4, 2026
b2af243
Switch Archer2 compilation to GNU
karimali5 Jun 4, 2026
539538f
Example of input file for refine_fields
karimali5 Jun 5, 2026
54f5d7c
fix staggOps
karimali5 Jun 5, 2026
b5eec11
Preserve existing computeFbody state during SGS initialization unless…
karimali5 Jun 5, 2026
937c30b
Fix periodic fd02 cleanup and complex-pencil indexing in PadeDerOps.
karimali5 Jun 5, 2026
ca04aa1
avoid using a REAL in a do size with GNU
karimali5 Jun 5, 2026
3f19d54
Update GNU build options
karimali5 Jun 5, 2026
879c5ee
Initialize WriteTurbineForce
karimali5 Jun 5, 2026
2ac2697
Fix order of restarting MCG
karimali5 Jun 8, 2026
bdf9c26
AI sweep and cleanup
karimali5 Jun 8, 2026
5b80952
GNU compiler works well now
karimali5 Jun 8, 2026
463d0bb
remove vtk from intel CMake
karimali5 Jun 8, 2026
4be5775
Rename parameters p_row and p_col to prow and pool in refine_fields
karimali5 Jun 10, 2026
47201fd
overload budget0 in time_avg_budget with fields from budget1 when squ…
karimali5 Jun 18, 2026
fd04d7a
Add MKE budget
karimali5 Jun 18, 2026
55a85ba
Safeguard initialzing unallocated budgets
karimali5 Jun 19, 2026
e8f29af
Build GNU+mvapich on Stampede3
karimali5 Jun 20, 2026
7bec5f2
fix precursor budget 1 path when squeeze is on.
karimali5 Jun 21, 2026
62d86da
some fixes for deficit budget2 + safe guards
karimali5 Jun 23, 2026
427e5ec
push the streamtube program
karimali5 Jun 23, 2026
bafe6d3
Add a TMP type in CosntructDeficitBudgets
karimali5 Jun 24, 2026
6fe9e3c
Refactor CMake dependency discovery for portable platform stacks
karimali5 Jun 24, 2026
3b47703
Add option to recognize implicit sci libs coming with loaded modules,…
karimali5 Jun 24, 2026
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
89 changes: 5 additions & 84 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,94 +1,15 @@
cmake_minimum_required(VERSION 2.8)
project(PadeOps)
cmake_minimum_required(VERSION 3.16)
project(PadeOps LANGUAGES Fortran)

enable_language(Fortran)

set( CMAKE_MODULE_PATH ${PadeOps_SOURCE_DIR} )
list(PREPEND CMAKE_MODULE_PATH "${PadeOps_SOURCE_DIR}/cmake")

if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()

# Where to look for FFTW
set(FFTW_PATH $ENV{FFTW_PATH})
set(FFTW_LIBRARY_PATH "${FFTW_PATH}/lib")
set(FFTW_INCLUDE_PATH "${FFTW_PATH}/include")

# Where to look for DECOMP&FFT
set(DECOMP_PATH $ENV{DECOMP_PATH})
set(DECOMP_LIBRARY_PATH "${DECOMP_PATH}/lib")
set(DECOMP_INCLUDE_PATH "${DECOMP_PATH}/include")

# Where to look for Lib_VTK_IO
set(VTK_IO_PATH $ENV{VTK_IO_PATH})
set(VTK_IO_LIBRARY_PATH "${VTK_IO_PATH}/lib")
set(VTK_IO_INCLUDE_PATH "${VTK_IO_PATH}/modules")

# Where to look for HDF5
set(HDF5_PATH $ENV{HDF5_PATH})
set(HDF5_LIBRARY_PATH "${HDF5_PATH}/lib")
set(HDF5_INCLUDE_PATH "${HDF5_PATH}/include")

# Where to look for fftpack
set(FFTPACK_PATH $ENV{FFTPACK_PATH})
set(FFTPACK_LIBRARY_PATH "${FFTPACK_PATH}/lib")
set(FFTPACK_INCLUDE_PATH "${FFTPACK_PATH}/include")


set(CMAKE_Fortran_COMPILER_ID $ENV{COMPILER_ID})



# Intel compiler suite
if ( CMAKE_Fortran_COMPILER_ID MATCHES "Intel" )
if ( CMAKE_BUILD_TYPE MATCHES "Release" )
if ($ENV{ARCH_OPT_FLAG})
set(OPTFLAG "-xhost")
else()
set(OPTFLAG $ENV{ARCH_OPT_FLAG})
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O3 -traceback -qmkl -heap-arrays 1024 -warn all ${OPTFLAG} -dynamic -qopt-report=2 -qopt-report-phase=vec -qopenmp")
elseif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -g -qmkl -heap-arrays 1024 -check all,nouninit -check noarg-temp-created -fpe0 -warn -traceback -debug extended -assume realloc_lhs -fstack-protector -assume protect_parens -implicitnone")
endif()

# GNU compiler on OSX
elseif ( CMAKE_Fortran_COMPILER_ID MATCHES "GNU_OSX")
if ( CMAKE_BUILD_TYPE MATCHES "Release" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -Wconversion -Wextra -Waliasing -fopenmp -ffree-form -ffree-line-length-none -ffast-math -funroll-loops -fno-protect-parens -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
elseif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(CMAKE_Fortran_FLAGS "-Og -g -fbacktrace -pg -llapack -ffree-form -ffree-line-length-none -fopenmp -fbounds-check -ffpe-trap=zero,overflow -Wall -Wconversion -Wextra -Waliasing -Wsurprising -fno-unsafe-math-optimizations -frounding-math -fsignaling-nans")
endif()

# Standard GNU compilers
elseif ( CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
if ( CMAKE_BUILD_TYPE MATCHES "Release" )
if ($ENV{ARCH_OPT_FLAG})
set(OPTFLAG "-march=native")
else()
set(OPTFLAG $ENV{ARCH_OPT_FLAG})
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -Wconversion -Wextra -Waliasing -ffree-form -ffree-line-length-none -ffast-math ${OPTFLAG} -funroll-loops -fno-protect-parens -fopenmp")
elseif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(CMAKE_Fortran_FLAGS "-Og -g -fbacktrace -pg -llapack -ffree-form -ffree-line-length-none -fcheck=all -fbounds-check -ffpe-trap=zero,overflow -Wall -Wconversion -Wextra -Waliasing -Wsurprising")
endif()

elseif ( CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
if ( CMAKE_BUILD_TYPE MATCHES "Release" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wall -Wconversion -Wextra -Waliasing -ffree-form -ffree-line-length-none -ffast-math -march=native -funroll-loops -fno-protect-parens -fopenmp")
elseif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(CMAKE_Fortran_FLAGS "-Og -g -fbacktrace -pg -llapack -ffree-form -ffree-line-length-none -fcheck=all -fbounds-check -ffpe-trap=zero,overflow -Wall -Wconversion -Wextra -Waliasing -Wsurprising")
endif()

elseif ( CMAKE_Fortran_COMPILER_ID MATCHES "IBM")
if ( CMAKE_BUILD_TYPE MATCHES "Release" )
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O5 -qsuffix=cpp=f90 -qxlf2003=polymorphic")
elseif ( CMAKE_BUILD_TYPE MATCHES "Debug" )
set(CMAKE_Fortran_FLAGS "-O0 -qsuffix=cpp=f90 -qxlf2003=polymorphic")
endif()

endif()
include(PadeOpsCompiler)
include(PadeOpsDependencies)

# Add source file directories
add_subdirectory(src)
Expand Down
38 changes: 38 additions & 0 deletions cmake/Find2DECOMP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include(FindPackageHandleStandardArgs)

set(_2DECOMP_HINTS)
foreach(_var DECOMP_ROOT DECOMP_PATH DECOMP_HOME)
if(DEFINED ${_var})
list(APPEND _2DECOMP_HINTS "${${_var}}")
endif()
if(DEFINED ENV{${_var}})
list(APPEND _2DECOMP_HINTS "$ENV{${_var}}")
endif()
endforeach()
list(REMOVE_DUPLICATES _2DECOMP_HINTS)

find_path(2DECOMP_INCLUDE_DIR
NAMES decomp_2d.mod decomp_2d_fft.mod
HINTS ${_2DECOMP_HINTS}
PATH_SUFFIXES include modules mod
)

find_library(2DECOMP_LIBRARY
NAMES 2decomp_fft
HINTS ${_2DECOMP_HINTS}
PATH_SUFFIXES lib lib64
)

find_package_handle_standard_args(2DECOMP
REQUIRED_VARS 2DECOMP_LIBRARY 2DECOMP_INCLUDE_DIR
)

if(2DECOMP_FOUND AND NOT TARGET PadeOps::2DECOMP)
add_library(PadeOps::2DECOMP INTERFACE IMPORTED)
set_target_properties(PadeOps::2DECOMP PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${2DECOMP_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${2DECOMP_LIBRARY}"
)
endif()

mark_as_advanced(2DECOMP_INCLUDE_DIR 2DECOMP_LIBRARY)
38 changes: 38 additions & 0 deletions cmake/FindFFTW.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include(FindPackageHandleStandardArgs)

set(_FFTW_HINTS)
foreach(_var FFTW_ROOT FFTW_PATH FFTW_HOME)
if(DEFINED ${_var})
list(APPEND _FFTW_HINTS "${${_var}}")
endif()
if(DEFINED ENV{${_var}})
list(APPEND _FFTW_HINTS "$ENV{${_var}}")
endif()
endforeach()
list(REMOVE_DUPLICATES _FFTW_HINTS)

find_path(FFTW_INCLUDE_DIR
NAMES fftw3.f fftw3.h
HINTS ${_FFTW_HINTS}
PATH_SUFFIXES include
)

find_library(FFTW_LIBRARY
NAMES fftw3
HINTS ${_FFTW_HINTS}
PATH_SUFFIXES lib lib64
)

find_package_handle_standard_args(FFTW
REQUIRED_VARS FFTW_LIBRARY FFTW_INCLUDE_DIR
)

if(FFTW_FOUND AND NOT TARGET PadeOps::FFTW)
add_library(PadeOps::FFTW INTERFACE IMPORTED)
set_target_properties(PadeOps::FFTW PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${FFTW_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${FFTW_LIBRARY}"
)
endif()

mark_as_advanced(FFTW_INCLUDE_DIR FFTW_LIBRARY)
31 changes: 31 additions & 0 deletions cmake/FindSZIP.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
include(FindPackageHandleStandardArgs)

set(_SZIP_HINTS)
foreach(_var SZIP_ROOT SZIP_PATH SZIP_HOME LIBSZIP_ROOT LIBSZIP_PATH LIBSZIP_HOME)
if(DEFINED ${_var})
list(APPEND _SZIP_HINTS "${${_var}}")
endif()
if(DEFINED ENV{${_var}})
list(APPEND _SZIP_HINTS "$ENV{${_var}}")
endif()
endforeach()
list(REMOVE_DUPLICATES _SZIP_HINTS)

find_library(SZIP_LIBRARY
NAMES sz szip aec
HINTS ${_SZIP_HINTS}
PATH_SUFFIXES lib lib64
)

find_package_handle_standard_args(SZIP
REQUIRED_VARS SZIP_LIBRARY
)

if(SZIP_FOUND AND NOT TARGET PadeOps::SZIP)
add_library(PadeOps::SZIP UNKNOWN IMPORTED)
set_target_properties(PadeOps::SZIP PROPERTIES
IMPORTED_LOCATION "${SZIP_LIBRARY}"
)
endif()

mark_as_advanced(SZIP_LIBRARY)
96 changes: 96 additions & 0 deletions cmake/PadeOpsCompiler.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
add_library(PadeOps::FortranOptions INTERFACE IMPORTED)

find_package(OpenMP QUIET COMPONENTS Fortran)

if(DEFINED ENV{ARCH_OPT_FLAG} AND NOT "$ENV{ARCH_OPT_FLAG}" STREQUAL "")
separate_arguments(PADEOPS_ARCH_OPT_FLAGS NATIVE_COMMAND "$ENV{ARCH_OPT_FLAG}")
else()
set(PADEOPS_ARCH_OPT_FLAGS)
endif()

set(_PADEOPS_FORTRAN_COMPILE_OPTIONS)
set(_PADEOPS_FORTRAN_LINK_OPTIONS)

if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
if(NOT PADEOPS_ARCH_OPT_FLAGS)
set(PADEOPS_ARCH_OPT_FLAGS -xhost)
endif()

if(CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-g -traceback -heap-arrays 1024 -check all,nouninit
-check noarg-temp-created -fpe0 -warn -debug extended
-assume realloc_lhs -fstack-protector -assume protect_parens
-implicitnone
)
else()
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-O3 -traceback -heap-arrays 1024 -warn all
${PADEOPS_ARCH_OPT_FLAGS}
-dynamic -qopt-report=2 -qopt-report-phase=vec
)
endif()
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
if(NOT PADEOPS_ARCH_OPT_FLAGS)
set(PADEOPS_ARCH_OPT_FLAGS -march=native)
endif()

if(CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-Og -g -fbacktrace -pg -ffree-form -ffree-line-length-none
-fcheck=all -fbounds-check -ffpe-trap=zero,overflow
-Wall -Wconversion -Wextra -Waliasing -Wsurprising
)
else()
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-O3 -Wall -Wconversion -Wextra -Waliasing
-ffree-form -ffree-line-length-none
${PADEOPS_ARCH_OPT_FLAGS}
-funroll-loops -fallow-argument-mismatch
-finit-integer=0 -finit-real=zero
)
endif()
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Cray")
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS -hlist=a)
endif()
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "IBM")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS -O0 -qsuffix=cpp=f90 -qxlf2003=polymorphic)
else()
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS -O5 -qsuffix=cpp=f90 -qxlf2003=polymorphic)
endif()
elseif(CMAKE_Fortran_COMPILER_ID MATCHES "AOCC|AMD")
if(CMAKE_BUILD_TYPE MATCHES "Debug")
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-O0 -g -ffree-form -fcheck=all
-fbounds-check -ffpe-trap=zero,overflow
)
else()
list(APPEND _PADEOPS_FORTRAN_COMPILE_OPTIONS
-O3 ${PADEOPS_ARCH_OPT_FLAGS}
-ffree-form -ffast-math -funroll-loops
)
endif()
endif()

if(OpenMP_Fortran_FOUND)
list(APPEND _PADEOPS_FORTRAN_LINK_OPTIONS OpenMP::OpenMP_Fortran)
message(STATUS "OpenMP Fortran provider: OpenMP::OpenMP_Fortran")
else()
message(STATUS "OpenMP Fortran was not found by CMake; building without CMake-managed OpenMP flags")
endif()

if(_PADEOPS_FORTRAN_COMPILE_OPTIONS)
set_target_properties(PadeOps::FortranOptions PROPERTIES
INTERFACE_COMPILE_OPTIONS "${_PADEOPS_FORTRAN_COMPILE_OPTIONS}"
)
endif()

if(_PADEOPS_FORTRAN_LINK_OPTIONS)
set_target_properties(PadeOps::FortranOptions PROPERTIES
INTERFACE_LINK_LIBRARIES "${_PADEOPS_FORTRAN_LINK_OPTIONS}"
)
endif()

message(STATUS "Fortran compiler: ${CMAKE_Fortran_COMPILER_ID} ${CMAKE_Fortran_COMPILER_VERSION}")
79 changes: 79 additions & 0 deletions cmake/PadeOpsDependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
include(CheckFortranSourceCompiles)
include(PadeOpsModuleEnv)

function(_padeops_append_existing_library out_var)
set(_result "${${out_var}}")
foreach(_lib IN LISTS ARGN)
if(_lib AND NOT _lib MATCHES "-NOTFOUND$")
list(APPEND _result "${_lib}")
endif()
endforeach()
set(${out_var} "${_result}" PARENT_SCOPE)
endfunction()

function(_padeops_filter_found_libraries out_var)
set(_result)
foreach(_lib IN LISTS ARGN)
if(_lib AND NOT _lib MATCHES "-NOTFOUND$")
list(APPEND _result "${_lib}")
endif()
endforeach()
set(${out_var} "${_result}" PARENT_SCOPE)
endfunction()

padeops_collect_dependency_prefixes(HDF5 PADEOPS_HDF5_PREFIXES)
padeops_collect_dependency_prefixes(FFTW PADEOPS_FFTW_PREFIXES)
padeops_collect_dependency_prefixes(2DECOMP PADEOPS_2DECOMP_PREFIXES)
padeops_collect_dependency_prefixes(SZIP PADEOPS_SZIP_PREFIXES)

foreach(_var HDF5_ROOT HDF5_PATH HDF5_HOME FFTW_ROOT FFTW_PATH FFTW_HOME DECOMP_ROOT DECOMP_PATH DECOMP_HOME SZIP_ROOT SZIP_PATH SZIP_HOME LIBSZIP_ROOT LIBSZIP_PATH LIBSZIP_HOME)
if(DEFINED ${_var} AND NOT "${${_var}}" STREQUAL "")
list(APPEND CMAKE_PREFIX_PATH "${${_var}}")
endif()
if(DEFINED ENV{${_var}} AND NOT "$ENV{${_var}}" STREQUAL "")
list(APPEND CMAKE_PREFIX_PATH "$ENV{${_var}}")
endif()
endforeach()
list(APPEND CMAKE_PREFIX_PATH
${PADEOPS_HDF5_PREFIXES}
${PADEOPS_FFTW_PREFIXES}
${PADEOPS_2DECOMP_PREFIXES}
${PADEOPS_SZIP_PREFIXES}
)
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)

find_package(MPI REQUIRED COMPONENTS Fortran)
find_package(FFTW REQUIRED)
find_package(2DECOMP REQUIRED)

set(_save_required_includes "${CMAKE_REQUIRED_INCLUDES}")
set(CMAKE_REQUIRED_INCLUDES "${2DECOMP_INCLUDE_DIR}")
check_fortran_source_compiles("
program padeops_2decomp_compile_check
use decomp_2d
end
" PADEOPS_2DECOMP_COMPILES)
set(CMAKE_REQUIRED_INCLUDES "${_save_required_includes}")
if(NOT PADEOPS_2DECOMP_COMPILES)
message(FATAL_ERROR
"Found 2DECOMP, but its Fortran module cannot be compiled with the active compiler. Ensure DECOMP_ROOT/DECOMP_PATH points to the 2DECOMP build for this compiler and MPI stack."
)
endif()

include(PadeOpsHDF5)
include(PadeOpsLAPACK)

if(TARGET MPI::MPI_Fortran)
add_library(PadeOps::MPI ALIAS MPI::MPI_Fortran)
elseif(NOT TARGET PadeOps::MPI)
add_library(PadeOps::MPI INTERFACE IMPORTED)
set_target_properties(PadeOps::MPI PROPERTIES
INTERFACE_COMPILE_OPTIONS "${MPI_Fortran_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${MPI_Fortran_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${MPI_Fortran_LIBRARIES}"
INTERFACE_LINK_OPTIONS "${MPI_Fortran_LINK_FLAGS}"
)
endif()

message(STATUS "FFTW library: ${FFTW_LIBRARY}")
message(STATUS "2DECOMP library: ${2DECOMP_LIBRARY}")
Loading