From 89a48d81e734384af31aa22c518b56cc8f566d60 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 14:12:04 -0700 Subject: [PATCH 1/7] minimal example. working? --- CMakeLists.txt | 10 +++- toolchain/cmake/regular/FindLAPACK.cmake | 70 ++++++++++++++++++++++++ toolchain/dependencies/CMakeLists.txt | 27 +++++++++ toolchain/mfc/build.py | 5 +- 4 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 toolchain/cmake/regular/FindLAPACK.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d486d43981..4bbab344de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -391,9 +391,10 @@ HANDLE_SOURCES(syscheck OFF) # * FFTW (optional) Should be linked with an FFTW-like library (fftw/cufftw), # depending on whether OpenACC is enabled and which compiler is # being used. +# * LAPACK (optional) Should be linked with LAPACK. function(MFC_SETUP_TARGET) - cmake_parse_arguments(ARGS "OpenACC;MPI;SILO;HDF5;FFTW" "TARGET" "SOURCES" ${ARGN}) + cmake_parse_arguments(ARGS "OpenACC;MPI;SILO;HDF5;FFTW;LAPACK" "TARGET" "SOURCES" ${ARGN}) add_executable(${ARGS_TARGET} ${ARGS_SOURCES}) set(IPO_TARGETS ${ARGS_TARGET}) @@ -461,6 +462,11 @@ function(MFC_SETUP_TARGET) endif() endif() + if (ARGS_LAPACK) + find_package(LAPACK REQUIRED) + target_link_libraries(${a_target} PRIVATE LAPACK::LAPACK) + endif() + if (MFC_OpenACC AND ARGS_OpenACC) find_package(OpenACC) @@ -552,7 +558,7 @@ endif() if (MFC_POST_PROCESS) MFC_SETUP_TARGET(TARGET post_process SOURCES "${post_process_SRCs}" - MPI SILO HDF5 FFTW) + MPI SILO HDF5 FFTW LAPACK) # -O0 is in response to https://github.com/MFlowCode/MFC-develop/issues/95 target_compile_options(post_process PRIVATE -O0) diff --git a/toolchain/cmake/regular/FindLAPACK.cmake b/toolchain/cmake/regular/FindLAPACK.cmake new file mode 100644 index 0000000000..acb895a5d4 --- /dev/null +++ b/toolchain/cmake/regular/FindLAPACK.cmake @@ -0,0 +1,70 @@ +# Attempt to find LAPACK (Linear Algebra PACKage) +# URL: https://www.netlib.org/lapack/ +# DOCS: https://cmake.org/cmake/help/latest/command/find_library.html +# https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html + +include(FindPackageHandleStandardArgs) + +# Special handling for Cray systems which have optimized math libraries +if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") + # On Cray systems, LAPACK is typically provided by the cray-libsci package + find_library(LAPACK_LIBRARY + NAMES sci_cray sci_gnu sci_intel sci_pgi sci + NAMES_PER_DIR + ) + set(BLAS_LIBRARY "") # BLAS is included in the sci library +else() + # Find LAPACK library for other compilers + find_library(LAPACK_LIBRARY + NAMES lapack + PATH_SUFFIXES lapack + NAMES_PER_DIR + ) + + # Find BLAS library (required by LAPACK) + find_library(BLAS_LIBRARY + NAMES blas openblas + PATH_SUFFIXES blas + NAMES_PER_DIR + ) + + # Some LAPACK implementations include BLAS + if (NOT BLAS_LIBRARY) + set(BLAS_LIBRARY "") + endif() +endif() + +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LAPACK + REQUIRED_VARS + LAPACK_LIBRARY +) + +if (LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) + set(LAPACK_LIBRARIES "${LAPACK_LIBRARY}") + if (BLAS_LIBRARY) + list(APPEND LAPACK_LIBRARIES "${BLAS_LIBRARY}") + endif() + + add_library(LAPACK::LAPACK INTERFACE IMPORTED) + + set_target_properties(LAPACK::LAPACK PROPERTIES + INTERFACE_LINK_LIBRARIES "${LAPACK_LIBRARIES}" + ) + + # Add math library for linking (commonly needed) + if (UNIX AND NOT APPLE) + set_property(TARGET LAPACK::LAPACK APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "m") + endif() + + # Add compiler-specific libraries + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + set_property(TARGET LAPACK::LAPACK APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "gfortran") + elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" OR CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") + # NVHPC/PGI may need additional libraries + set_property(TARGET LAPACK::LAPACK APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "pgf90rtl") + endif() +endif() \ No newline at end of file diff --git a/toolchain/dependencies/CMakeLists.txt b/toolchain/dependencies/CMakeLists.txt index 116e288711..428bcb7204 100644 --- a/toolchain/dependencies/CMakeLists.txt +++ b/toolchain/dependencies/CMakeLists.txt @@ -21,6 +21,7 @@ include(ExternalProject) option(MFC_FFTW "Build the FFTW3 dependency" OFF) option(MFC_HDF5 "Build the HDF5 dependency" OFF) option(MFC_SILO "Build the SILO dependency" OFF) +option(MFC_LAPACK "Build the LAPACK dependency" OFF) option(MFC_HIPFORT "Build the HIPFORT dependency" OFF) @@ -98,6 +99,32 @@ if (MFC_SILO) endif() endif() +# LAPACK +if (MFC_LAPACK) + find_package(LAPACK QUIET) + if (LAPACK_FOUND) + message(STATUS "LAPACK found.") + add_custom_target(lapack) + else() + # Use reference LAPACK from netlib + find_package(Git REQUIRED) + + ExternalProject_Add(lapack + GIT_REPOSITORY "https://github.com/Reference-LAPACK/lapack" + GIT_TAG v3.12.0 + GIT_SHALLOW ON + GIT_PROGRESS ON + CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + -DCBLAS=OFF + -DLAPACKE=OFF + -DBUILD_DEPRECATED=OFF + "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + ) + endif() +endif() + # HIPFORT if (MFC_HIPFORT) if (CMAKE_Fortran_COMPILER_ID STREQUAL "Cray") diff --git a/toolchain/mfc/build.py b/toolchain/mfc/build.py index 2de738986d..b28be82821 100644 --- a/toolchain/mfc/build.py +++ b/toolchain/mfc/build.py @@ -184,14 +184,15 @@ def install(self, case: input.MFCInputFile): FFTW = MFCTarget('fftw', ['-DMFC_FFTW=ON'], True, False, False, MFCTarget.Dependencies([], [], []), -1) HDF5 = MFCTarget('hdf5', ['-DMFC_HDF5=ON'], True, False, False, MFCTarget.Dependencies([], [], []), -1) SILO = MFCTarget('silo', ['-DMFC_SILO=ON'], True, False, False, MFCTarget.Dependencies([HDF5], [], []), -1) +LAPACK = MFCTarget('lapack', ['-DMFC_LAPACK=ON'], True, False, False, MFCTarget.Dependencies([], [], []), -1) HIPFORT = MFCTarget('hipfort', ['-DMFC_HIPFORT=ON'], True, False, False, MFCTarget.Dependencies([], [], []), -1) PRE_PROCESS = MFCTarget('pre_process', ['-DMFC_PRE_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([], [], []), 0) SIMULATION = MFCTarget('simulation', ['-DMFC_SIMULATION=ON'], False, True, False, MFCTarget.Dependencies([], [FFTW], [HIPFORT]), 1) -POST_PROCESS = MFCTarget('post_process', ['-DMFC_POST_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([FFTW, HDF5, SILO], [], []), 2) +POST_PROCESS = MFCTarget('post_process', ['-DMFC_POST_PROCESS=ON'], False, True, False, MFCTarget.Dependencies([FFTW, HDF5, SILO, LAPACK], [], []), 2) SYSCHECK = MFCTarget('syscheck', ['-DMFC_SYSCHECK=ON'], False, False, True, MFCTarget.Dependencies([], [], [HIPFORT]), -1) DOCUMENTATION = MFCTarget('documentation', ['-DMFC_DOCUMENTATION=ON'], False, False, False, MFCTarget.Dependencies([], [], []), -1) -TARGETS = { FFTW, HDF5, SILO, HIPFORT, PRE_PROCESS, SIMULATION, POST_PROCESS, SYSCHECK, DOCUMENTATION } +TARGETS = { FFTW, HDF5, SILO, LAPACK, HIPFORT, PRE_PROCESS, SIMULATION, POST_PROCESS, SYSCHECK, DOCUMENTATION } DEFAULT_TARGETS = { target for target in TARGETS if target.isDefault } REQUIRED_TARGETS = { target for target in TARGETS if target.isRequired } From b05af20a178a1f957f03cdfc03e61cefc24e1c05 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 15:36:39 -0700 Subject: [PATCH 2/7] fix nvhpc --- src/post_process/m_lapack_example.f90 | 136 +++++++++++++++++++++++ src/post_process/m_start_up.f90 | 7 ++ toolchain/cmake/regular/FindLAPACK.cmake | 10 -- 3 files changed, 143 insertions(+), 10 deletions(-) create mode 100644 src/post_process/m_lapack_example.f90 diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 new file mode 100644 index 0000000000..a86c30c1c3 --- /dev/null +++ b/src/post_process/m_lapack_example.f90 @@ -0,0 +1,136 @@ +!> +!! @file m_lapack_example.f90 +!! @brief Contains module m_lapack_example + +!> @brief This module demonstrates the use of LAPACK in MFC post_process. +!! It provides example routines that show how to use LAPACK for +!! common linear algebra operations like solving linear systems. +module m_lapack_example + + use m_global_parameters !< Global parameters for the code + use m_mpi_proxy !< Message passing interface (MPI) module proxy + + implicit none + + private; public :: s_lapack_example_solve_linear_system, & + s_lapack_example_eigenvalues + +contains + + !> @brief Example subroutine demonstrating LAPACK usage for solving + !! a linear system Ax = b using DGESV/SGESV + !! This routine shows how to use LAPACK with MFC's precision system + impure subroutine s_lapack_example_solve_linear_system() + + ! Local variables for the linear system + integer, parameter :: n = 3 ! Size of the system + real(wp), dimension(n, n) :: A ! Coefficient matrix + real(wp), dimension(n) :: b ! Right-hand side vector + real(wp), dimension(n) :: x ! Solution vector + + ! LAPACK variables + integer, dimension(n) :: ipiv ! Pivot indices + integer :: info ! Return status + integer :: nrhs = 1 ! Number of right-hand sides + + ! Only run on the root process to avoid duplicate output + if (proc_rank /= 0) return + + ! Set up a simple 3x3 linear system: Ax = b + ! Example: + ! 2x + y + z = 8 + ! x + 3y + z = 10 + ! x + y + 4z = 16 + A(1, :) = [2.0_wp, 1.0_wp, 1.0_wp] + A(2, :) = [1.0_wp, 3.0_wp, 1.0_wp] + A(3, :) = [1.0_wp, 1.0_wp, 4.0_wp] + + b = [8.0_wp, 10.0_wp, 16.0_wp] + + print *, "=== LAPACK Linear System Solver Example ===" + print *, "Solving the system Ax = b where:" + print *, "A = [2 1 1; 1 3 1; 1 1 4]" + print *, "b = [8; 10; 16]" + print *, "" + + ! Copy b to x (LAPACK will overwrite the right-hand side with solution) + x = b + + ! Call appropriate LAPACK routine based on precision +#ifdef MFC_SINGLE_PRECISION + call sgesv(n, nrhs, A, n, ipiv, x, n, info) + print *, "Using single precision LAPACK (SGESV)" +#else + call dgesv(n, nrhs, A, n, ipiv, x, n, info) + print *, "Using double precision LAPACK (DGESV)" +#endif + + ! Check for success + if (info == 0) then + print *, "Linear system solved successfully!" + print *, "Solution: x = [", x(1), ", ", x(2), ", ", x(3), "]" + print *, "Expected: x = [1, 2, 3]" + else if (info < 0) then + print *, "LAPACK error: argument ", -info, " had an illegal value" + else + print *, "LAPACK error: matrix is singular, solution could not be computed" + end if + + print *, "=== End LAPACK Example ===" + print *, "" + + end subroutine s_lapack_example_solve_linear_system + + !> @brief Example subroutine demonstrating LAPACK usage for computing + !! eigenvalues of a symmetric matrix using DSYEV/SSYEV + impure subroutine s_lapack_example_eigenvalues() + + ! Local variables for eigenvalue computation + integer, parameter :: n = 3 ! Size of the matrix + real(wp), dimension(n, n) :: A ! Symmetric matrix + real(wp), dimension(n) :: w ! Eigenvalues + real(wp), dimension(3*n) :: work ! Work array + integer :: lwork = 3*n ! Size of work array + integer :: info ! Return status + character :: jobz = 'N' ! Compute eigenvalues only + character :: uplo = 'U' ! Upper triangular part of A + + ! Only run on the root process to avoid duplicate output + if (proc_rank /= 0) return + + ! Set up a simple symmetric 3x3 matrix + A(1, :) = [4.0_wp, 1.0_wp, 1.0_wp] + A(2, :) = [1.0_wp, 4.0_wp, 1.0_wp] + A(3, :) = [1.0_wp, 1.0_wp, 4.0_wp] + + print *, "=== LAPACK Eigenvalue Example ===" + print *, "Computing eigenvalues of symmetric matrix:" + print *, "A = [4 1 1; 1 4 1; 1 1 4]" + print *, "" + + ! Call appropriate LAPACK routine based on precision +#ifdef MFC_SINGLE_PRECISION + call ssyev(jobz, uplo, n, A, n, w, work, lwork, info) + print *, "Using single precision LAPACK (SSYEV)" +#else + call dsyev(jobz, uplo, n, A, n, w, work, lwork, info) + print *, "Using double precision LAPACK (DSYEV)" +#endif + + ! Check for success + if (info == 0) then + print *, "Eigenvalues computed successfully!" + print *, "Eigenvalues: [", w(1), ", ", w(2), ", ", w(3), "]" + print *, "Expected: [2, 5, 5] (approximately)" + else if (info < 0) then + print *, "LAPACK error: argument ", -info, " had an illegal value" + else + print *, "LAPACK error: algorithm failed to converge" + end if + + print *, "=== End LAPACK Eigenvalue Example ===" + print *, "" + + end subroutine s_lapack_example_eigenvalues + +end module m_lapack_example \ No newline at end of file diff --git a/src/post_process/m_start_up.f90 b/src/post_process/m_start_up.f90 index b733f43dd9..b3ea3bf036 100644 --- a/src/post_process/m_start_up.f90 +++ b/src/post_process/m_start_up.f90 @@ -45,6 +45,8 @@ module m_start_up use m_chemistry + use m_lapack_example + implicit none contains @@ -714,6 +716,11 @@ impure subroutine s_initialize_mpi_domain ! leads to the termination of the post-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() + + ! Run LAPACK examples before reading input file + call s_lapack_example_solve_linear_system() + call s_lapack_example_eigenvalues() + call s_read_input_file() call s_check_input_file() diff --git a/toolchain/cmake/regular/FindLAPACK.cmake b/toolchain/cmake/regular/FindLAPACK.cmake index acb895a5d4..6691eb40bb 100644 --- a/toolchain/cmake/regular/FindLAPACK.cmake +++ b/toolchain/cmake/regular/FindLAPACK.cmake @@ -57,14 +57,4 @@ if (LAPACK_FOUND AND NOT TARGET LAPACK::LAPACK) set_property(TARGET LAPACK::LAPACK APPEND PROPERTY INTERFACE_LINK_LIBRARIES "m") endif() - - # Add compiler-specific libraries - if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - set_property(TARGET LAPACK::LAPACK APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "gfortran") - elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" OR CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") - # NVHPC/PGI may need additional libraries - set_property(TARGET LAPACK::LAPACK APPEND PROPERTY - INTERFACE_LINK_LIBRARIES "pgf90rtl") - endif() endif() \ No newline at end of file From 5a84b05af56e5f601fe23b26a5dc66dfe6564ce1 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 15:46:24 -0700 Subject: [PATCH 3/7] format and fix linter --- src/post_process/m_lapack_example.f90 | 54 +++++++++++++-------------- src/post_process/m_start_up.f90 | 4 +- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 index a86c30c1c3..e404ab13ec 100644 --- a/src/post_process/m_lapack_example.f90 +++ b/src/post_process/m_lapack_example.f90 @@ -13,11 +13,11 @@ module m_lapack_example implicit none private; public :: s_lapack_example_solve_linear_system, & - s_lapack_example_eigenvalues + s_lapack_example_eigenvalues contains - !> @brief Example subroutine demonstrating LAPACK usage for solving + !> @brief Example subroutine demonstrating LAPACK usage for solving !! a linear system Ax = b using DGESV/SGESV !! This routine shows how to use LAPACK with MFC's precision system impure subroutine s_lapack_example_solve_linear_system() @@ -27,35 +27,35 @@ impure subroutine s_lapack_example_solve_linear_system() real(wp), dimension(n, n) :: A ! Coefficient matrix real(wp), dimension(n) :: b ! Right-hand side vector real(wp), dimension(n) :: x ! Solution vector - + ! LAPACK variables integer, dimension(n) :: ipiv ! Pivot indices integer :: info ! Return status - integer :: nrhs = 1 ! Number of right-hand sides - + integer, parameter :: nrhs = 1 ! Number of right-hand sides + ! Only run on the root process to avoid duplicate output if (proc_rank /= 0) return - + ! Set up a simple 3x3 linear system: Ax = b - ! Example: + ! Example: ! 2x + y + z = 8 - ! x + 3y + z = 10 + ! x + 3y + z = 10 ! x + y + 4z = 16 A(1, :) = [2.0_wp, 1.0_wp, 1.0_wp] A(2, :) = [1.0_wp, 3.0_wp, 1.0_wp] A(3, :) = [1.0_wp, 1.0_wp, 4.0_wp] - + b = [8.0_wp, 10.0_wp, 16.0_wp] - + print *, "=== LAPACK Linear System Solver Example ===" print *, "Solving the system Ax = b where:" print *, "A = [2 1 1; 1 3 1; 1 1 4]" print *, "b = [8; 10; 16]" print *, "" - + ! Copy b to x (LAPACK will overwrite the right-hand side with solution) x = b - + ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call sgesv(n, nrhs, A, n, ipiv, x, n, info) @@ -64,7 +64,7 @@ impure subroutine s_lapack_example_solve_linear_system() call dgesv(n, nrhs, A, n, ipiv, x, n, info) print *, "Using double precision LAPACK (DGESV)" #endif - + ! Check for success if (info == 0) then print *, "Linear system solved successfully!" @@ -75,13 +75,13 @@ impure subroutine s_lapack_example_solve_linear_system() else print *, "LAPACK error: matrix is singular, solution could not be computed" end if - + print *, "=== End LAPACK Example ===" print *, "" - + end subroutine s_lapack_example_solve_linear_system - !> @brief Example subroutine demonstrating LAPACK usage for computing + !> @brief Example subroutine demonstrating LAPACK usage for computing !! eigenvalues of a symmetric matrix using DSYEV/SSYEV impure subroutine s_lapack_example_eigenvalues() @@ -90,24 +90,24 @@ impure subroutine s_lapack_example_eigenvalues() real(wp), dimension(n, n) :: A ! Symmetric matrix real(wp), dimension(n) :: w ! Eigenvalues real(wp), dimension(3*n) :: work ! Work array - integer :: lwork = 3*n ! Size of work array + integer, parameter :: lwork = 3*n ! Size of work array integer :: info ! Return status - character :: jobz = 'N' ! Compute eigenvalues only - character :: uplo = 'U' ! Upper triangular part of A - + character, parameter :: jobz = 'N' ! Compute eigenvalues only + character, parameter :: uplo = 'U' ! Upper triangular part of A + ! Only run on the root process to avoid duplicate output if (proc_rank /= 0) return - + ! Set up a simple symmetric 3x3 matrix A(1, :) = [4.0_wp, 1.0_wp, 1.0_wp] A(2, :) = [1.0_wp, 4.0_wp, 1.0_wp] A(3, :) = [1.0_wp, 1.0_wp, 4.0_wp] - + print *, "=== LAPACK Eigenvalue Example ===" print *, "Computing eigenvalues of symmetric matrix:" print *, "A = [4 1 1; 1 4 1; 1 1 4]" print *, "" - + ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call ssyev(jobz, uplo, n, A, n, w, work, lwork, info) @@ -116,7 +116,7 @@ impure subroutine s_lapack_example_eigenvalues() call dsyev(jobz, uplo, n, A, n, w, work, lwork, info) print *, "Using double precision LAPACK (DSYEV)" #endif - + ! Check for success if (info == 0) then print *, "Eigenvalues computed successfully!" @@ -127,10 +127,10 @@ impure subroutine s_lapack_example_eigenvalues() else print *, "LAPACK error: algorithm failed to converge" end if - + print *, "=== End LAPACK Eigenvalue Example ===" print *, "" - + end subroutine s_lapack_example_eigenvalues -end module m_lapack_example \ No newline at end of file +end module m_lapack_example diff --git a/src/post_process/m_start_up.f90 b/src/post_process/m_start_up.f90 index b3ea3bf036..12162d1516 100644 --- a/src/post_process/m_start_up.f90 +++ b/src/post_process/m_start_up.f90 @@ -716,11 +716,11 @@ impure subroutine s_initialize_mpi_domain ! leads to the termination of the post-process. if (proc_rank == 0) then call s_assign_default_values_to_user_inputs() - + ! Run LAPACK examples before reading input file call s_lapack_example_solve_linear_system() call s_lapack_example_eigenvalues() - + call s_read_input_file() call s_check_input_file() From debf82802d389ae36be1c96504f51b5fd98b675c Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 15:54:11 -0700 Subject: [PATCH 4/7] satiate the linter (why am i doing this?) --- src/post_process/m_lapack_example.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 index e404ab13ec..602ee802f2 100644 --- a/src/post_process/m_lapack_example.f90 +++ b/src/post_process/m_lapack_example.f90 @@ -59,10 +59,10 @@ impure subroutine s_lapack_example_solve_linear_system() ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call sgesv(n, nrhs, A, n, ipiv, x, n, info) - print *, "Using single precision LAPACK (SGESV)" + print *, "Using sing. prec. LAPACK (SGESV)" #else call dgesv(n, nrhs, A, n, ipiv, x, n, info) - print *, "Using double precision LAPACK (DGESV)" + print *, "Using doub. prec. LAPACK (DGESV)" #endif ! Check for success From 57bc5ec5a677afa6c01b661687b6ee27150cc57c Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 16:02:03 -0700 Subject: [PATCH 5/7] fix --- src/post_process/m_lapack_example.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 index 602ee802f2..acbfeef687 100644 --- a/src/post_process/m_lapack_example.f90 +++ b/src/post_process/m_lapack_example.f90 @@ -59,10 +59,10 @@ impure subroutine s_lapack_example_solve_linear_system() ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call sgesv(n, nrhs, A, n, ipiv, x, n, info) - print *, "Using sing. prec. LAPACK (SGESV)" + print *, "Using LAPACK (SGESV)" #else call dgesv(n, nrhs, A, n, ipiv, x, n, info) - print *, "Using doub. prec. LAPACK (DGESV)" + print *, "Using LAPACK (DGESV)" #endif ! Check for success From 36259b8321934bcccb4b462134269a85927e57a9 Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Sun, 13 Jul 2025 21:33:21 -0400 Subject: [PATCH 6/7] Update m_lapack_example.f90 --- src/post_process/m_lapack_example.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 index acbfeef687..9372e2f9d5 100644 --- a/src/post_process/m_lapack_example.f90 +++ b/src/post_process/m_lapack_example.f90 @@ -111,10 +111,10 @@ impure subroutine s_lapack_example_eigenvalues() ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION call ssyev(jobz, uplo, n, A, n, w, work, lwork, info) - print *, "Using single precision LAPACK (SSYEV)" + print *, "Using LAPACK (SSYEV)" #else call dsyev(jobz, uplo, n, A, n, w, work, lwork, info) - print *, "Using double precision LAPACK (DSYEV)" + print *, "Using LAPACK (DSYEV)" #endif ! Check for success From a1e90920d0d49a648f5d13139ad7fbdad99319be Mon Sep 17 00:00:00 2001 From: Spencer Bryngelson Date: Mon, 14 Jul 2025 02:29:30 -0400 Subject: [PATCH 7/7] Update m_lapack_example.f90 --- src/post_process/m_lapack_example.f90 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/post_process/m_lapack_example.f90 b/src/post_process/m_lapack_example.f90 index 9372e2f9d5..83aa37867b 100644 --- a/src/post_process/m_lapack_example.f90 +++ b/src/post_process/m_lapack_example.f90 @@ -47,11 +47,10 @@ impure subroutine s_lapack_example_solve_linear_system() b = [8.0_wp, 10.0_wp, 16.0_wp] - print *, "=== LAPACK Linear System Solver Example ===" + print *, "LAPACK Linear System Solver Example" print *, "Solving the system Ax = b where:" print *, "A = [2 1 1; 1 3 1; 1 1 4]" print *, "b = [8; 10; 16]" - print *, "" ! Copy b to x (LAPACK will overwrite the right-hand side with solution) x = b @@ -76,8 +75,7 @@ impure subroutine s_lapack_example_solve_linear_system() print *, "LAPACK error: matrix is singular, solution could not be computed" end if - print *, "=== End LAPACK Example ===" - print *, "" + print *, "End LAPACK Example" end subroutine s_lapack_example_solve_linear_system @@ -103,10 +101,9 @@ impure subroutine s_lapack_example_eigenvalues() A(2, :) = [1.0_wp, 4.0_wp, 1.0_wp] A(3, :) = [1.0_wp, 1.0_wp, 4.0_wp] - print *, "=== LAPACK Eigenvalue Example ===" + print *, "LAPACK Eigenvalue Example" print *, "Computing eigenvalues of symmetric matrix:" print *, "A = [4 1 1; 1 4 1; 1 1 4]" - print *, "" ! Call appropriate LAPACK routine based on precision #ifdef MFC_SINGLE_PRECISION @@ -128,8 +125,7 @@ impure subroutine s_lapack_example_eigenvalues() print *, "LAPACK error: algorithm failed to converge" end if - print *, "=== End LAPACK Eigenvalue Example ===" - print *, "" + print *, "End LAPACK Eigenvalue Example" end subroutine s_lapack_example_eigenvalues