From 373d6f210177a9989c3b14405c50ee4ea36c72a8 Mon Sep 17 00:00:00 2001 From: stafusa Date: Thu, 31 Mar 2022 05:08:04 +0200 Subject: [PATCH 1/7] Test Lin. Alg. libraries presence for GNU and serial Intel. --- check_libs.f90 | 10 ++++++++++ configure.sh | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 check_libs.f90 diff --git a/check_libs.f90 b/check_libs.f90 new file mode 100644 index 00000000..508f3984 --- /dev/null +++ b/check_libs.f90 @@ -0,0 +1,10 @@ +program check_libs + use iso_fortran_env + integer :: n,ix=1,iy=1 + real(kind=8) :: A(1),B(1) + real(kind=8) :: z + real(kind=8), external :: ddot + A(1)=1; B(1)=1 + z=ddot(n,A,ix,B,iy) + !write(*,*) "Linear algebra libraries found." +end program check_libs diff --git a/configure.sh b/configure.sh index 9283b386..4503d2f6 100755 --- a/configure.sh +++ b/configure.sh @@ -64,6 +64,25 @@ set_hdf5_flags() LIB_HDF5="$LIB_HDF5 $HDF5_DIR/lib/libhdf5_fortran.a $HDF5_DIR/lib/libhdf5.a -lz -ldl -lm -Wl,-rpath -Wl,$HDF5_DIR/lib" } +check_libs() +{ + FC="$1" LIBS="$2" + COMPILE="$FC check_libs.f90 $LIBS -o check_libs.out" + ERROR_MSG1="\033[0;31mError: Compiler $FC not found.\033[0m\n" + ERROR_MSG2="\033[0;31mError: Linear algebra libraries not found.\033[0m\n" + if $FC --version 2>&1 >/dev/null; then + if $COMPILE; then + ./check_libs.out + else + printf "${ERROR_MSG2}" + return 1 + fi + else + printf "${ERROR_MSG1}" + return 1 + fi +} + # default optimization flags for Intel compiler INTELOPTFLAGS="-cpp -O3 -fp-model fast=2 -xHost -unroll -finline-functions -ipo -ip -heap-arrays 1024 -no-wrap-margin" # INTELOPTFLAGS="-cpp -O3 " @@ -302,6 +321,8 @@ case $MACHINE in ;; esac +check_libs "$ALF_FC" "${LIB_BLAS_LAPACK}" || return 1 + PROGRAMMCONFIGURATION="$STABCONFIGURATION $PROGRAMMCONFIGURATION" Libs="$ALF_DIR/Libraries" -- GitLab From c1408d242f6d35861404e3bd20773320b0af76cc Mon Sep 17 00:00:00 2001 From: Jefferson Stafusa Elias Portela Date: Thu, 31 Mar 2022 12:10:46 +0200 Subject: [PATCH 2/7] Support PGI; minor bug fix. --- check_libs.f90 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check_libs.f90 b/check_libs.f90 index 508f3984..520dc434 100644 --- a/check_libs.f90 +++ b/check_libs.f90 @@ -1,9 +1,9 @@ program check_libs use iso_fortran_env - integer :: n,ix=1,iy=1 - real(kind=8) :: A(1),B(1) + integer :: n=1, ix=1, iy=1 + real(kind=8) :: A(1), B(1) real(kind=8) :: z - real(kind=8), external :: ddot + real(kind=8), external :: ddot A(1)=1; B(1)=1 z=ddot(n,A,ix,B,iy) !write(*,*) "Linear algebra libraries found." -- GitLab From 92387a03b2f02ed9c0bbfc334b187a1f88e7b894 Mon Sep 17 00:00:00 2001 From: Jefferson Stafusa Elias Portela Date: Mon, 4 Apr 2022 10:49:26 +0200 Subject: [PATCH 3/7] Improve printing. --- configure.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/configure.sh b/configure.sh index 4503d2f6..721fda1e 100755 --- a/configure.sh +++ b/configure.sh @@ -50,7 +50,7 @@ set_hdf5_flags() fi case "$yn" in y|Y|"") - printf "\e[31mDownloading and installing HDF5 in %s.\e[0m\n" "$HDF5_DIR" + printf "${RED}Downloading and installing HDF5 in %s.${NC}\n" "$HDF5_DIR" CC="$CC" FC="$FC" CXX="$CXX" HDF5_DIR="$HDF5_DIR" "$ALF_DIR/HDF5/install_hdf5.sh" || return 1 ;; *) @@ -68,17 +68,15 @@ check_libs() { FC="$1" LIBS="$2" COMPILE="$FC check_libs.f90 $LIBS -o check_libs.out" - ERROR_MSG1="\033[0;31mError: Compiler $FC not found.\033[0m\n" - ERROR_MSG2="\033[0;31mError: Linear algebra libraries not found.\033[0m\n" - if $FC --version 2>&1 >/dev/null; then - if $COMPILE; then + if $FC --version 2>&1 >/dev/null; then # Calling the compiler is successful + if $COMPILE; then # Compiling with $LIBS is successful ./check_libs.out else - printf "${ERROR_MSG2}" + printf "${RED}Error: Linear algebra libraries not found.${NC}\n" return 1 fi else - printf "${ERROR_MSG1}" + printf "${RED}Error: Compiler %s not found.${NC}\n" "$FC" return 1 fi } -- GitLab From d067a6827aaea6abc98865b905d4219ed9a78ee7 Mon Sep 17 00:00:00 2001 From: stafusa Date: Tue, 5 Apr 2022 20:14:41 +0200 Subject: [PATCH 4/7] Add test for python3 and for lapack function call in configure.sh; +minor. --- check_libs.f90 | 18 +++++++++++------- configure.sh | 18 ++++++++++++++---- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/check_libs.f90 b/check_libs.f90 index 520dc434..f89b81bf 100644 --- a/check_libs.f90 +++ b/check_libs.f90 @@ -1,10 +1,14 @@ program check_libs + use iso_fortran_env - integer :: n=1, ix=1, iy=1 - real(kind=8) :: A(1), B(1) - real(kind=8) :: z - real(kind=8), external :: ddot - A(1)=1; B(1)=1 - z=ddot(n,A,ix,B,iy) - !write(*,*) "Linear algebra libraries found." + integer :: N=2, ix=1, iy=1, LDA=2, LWMAX=1000, INFO, LWORK=-1 + real (kind=kind(0.d0)) :: C(2), D(2), dot, W(2), RWORK(4) + complex (kind=kind(0.d0)) :: A(2,2), WORK(1000) + real (kind=kind(0.d0)), external :: ddot + data A /(1,0),(0,0),(0,0),(2,0)/, C /3,1415/, D /42,0/ + external ZHEEV + + dot = ddot(n,C,ix,D,iy) + call ZHEEV( 'V', 'U', N, A, LDA, W, WORK, LWORK, RWORK, INFO ) + end program check_libs diff --git a/configure.sh b/configure.sh index 721fda1e..19f56c02 100755 --- a/configure.sh +++ b/configure.sh @@ -68,15 +68,23 @@ check_libs() { FC="$1" LIBS="$2" COMPILE="$FC check_libs.f90 $LIBS -o check_libs.out" - if $FC --version 2>&1 >/dev/null; then # Calling the compiler is successful - if $COMPILE; then # Compiling with $LIBS is successful + if command -v "$FC" > /dev/null; then # Calling the compiler is successful + if $COMPILE; then # Compiling with $LIBS is successful ./check_libs.out else - printf "${RED}Error: Linear algebra libraries not found.${NC}\n" + printf "${RED}\n==== Error: Linear algebra libraries <%s> not found. ====${NC}\n\n" "$LIBS" return 1 fi else - printf "${RED}Error: Compiler %s not found.${NC}\n" "$FC" + printf "${RED}\n==== Error: Compiler <%s> not found. ====${NC}\n\n" "$FC" + return 1 + fi +} + +check_python() +{ + if ! command -v python3 > /dev/null; then + printf "${RED}\n==== Error: Python 3 not found. =====${NC}\n\n" return 1 fi } @@ -321,6 +329,8 @@ esac check_libs "$ALF_FC" "${LIB_BLAS_LAPACK}" || return 1 +check_python || return 1 + PROGRAMMCONFIGURATION="$STABCONFIGURATION $PROGRAMMCONFIGURATION" Libs="$ALF_DIR/Libraries" -- GitLab From 6a5ec2ed53cd972e5ef4a14d0c2b3014822c5582 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Wed, 6 Apr 2022 00:03:58 +0200 Subject: [PATCH 5/7] check_libs.f90: Test output of calls --- check_libs.f90 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/check_libs.f90 b/check_libs.f90 index f89b81bf..65172140 100644 --- a/check_libs.f90 +++ b/check_libs.f90 @@ -1,14 +1,25 @@ +! Small check if BLAS and LAPACK libraries are present and working. program check_libs use iso_fortran_env - integer :: N=2, ix=1, iy=1, LDA=2, LWMAX=1000, INFO, LWORK=-1 - real (kind=kind(0.d0)) :: C(2), D(2), dot, W(2), RWORK(4) - complex (kind=kind(0.d0)) :: A(2,2), WORK(1000) + integer, parameter :: N=2, ix=1, iy=1, LDA=2, LWORK=100 + integer :: INFO + real (kind=kind(0.d0)) :: C(2), D(2), dot, W(2), RWORK(4) + complex (kind=kind(0.d0)) :: A(2,2), WORK(LWORK) real (kind=kind(0.d0)), external :: ddot - data A /(1,0),(0,0),(0,0),(2,0)/, C /3,1415/, D /42,0/ + data A /(0,0),(0,1),(0,-1),(0,0)/, C /3,1415/, D /42,0/ external ZHEEV dot = ddot(n,C,ix,D,iy) + if (.not. abs(dot-126d0) < 1d-10) then + write(error_unit, *) "Problem with BLAS" + error stop + endif + call ZHEEV( 'V', 'U', N, A, LDA, W, WORK, LWORK, RWORK, INFO ) + if ( .not. (abs(W(1)+1d0) < 1d-10 .and. abs(W(1)+1d0) < 1d-10) ) then + write(error_unit, *) "Problem with LAPACK" + error stop + endif end program check_libs -- GitLab From b39bee90a759567776b6738a40880f752aeb3243 Mon Sep 17 00:00:00 2001 From: Jefferson Stafusa Elias Portela Date: Mon, 30 May 2022 11:22:49 +0200 Subject: [PATCH 6/7] Trying to debug pgi (nv) compiler error. --- check_libs.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_libs.f90 b/check_libs.f90 index 65172140..325eda2c 100644 --- a/check_libs.f90 +++ b/check_libs.f90 @@ -13,13 +13,13 @@ program check_libs dot = ddot(n,C,ix,D,iy) if (.not. abs(dot-126d0) < 1d-10) then write(error_unit, *) "Problem with BLAS" - error stop + stop 5 endif call ZHEEV( 'V', 'U', N, A, LDA, W, WORK, LWORK, RWORK, INFO ) if ( .not. (abs(W(1)+1d0) < 1d-10 .and. abs(W(1)+1d0) < 1d-10) ) then write(error_unit, *) "Problem with LAPACK" - error stop + stop 5 endif end program check_libs -- GitLab From 519e2f1fa4e8535564483ec07ab90e4fab34a0a3 Mon Sep 17 00:00:00 2001 From: Jonas Schwab Date: Mon, 30 May 2022 12:46:48 +0200 Subject: [PATCH 7/7] check_libs.f90: revert to 'error stop' --- check_libs.f90 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_libs.f90 b/check_libs.f90 index 325eda2c..65172140 100644 --- a/check_libs.f90 +++ b/check_libs.f90 @@ -13,13 +13,13 @@ program check_libs dot = ddot(n,C,ix,D,iy) if (.not. abs(dot-126d0) < 1d-10) then write(error_unit, *) "Problem with BLAS" - stop 5 + error stop endif call ZHEEV( 'V', 'U', N, A, LDA, W, WORK, LWORK, RWORK, INFO ) if ( .not. (abs(W(1)+1d0) < 1d-10 .and. abs(W(1)+1d0) < 1d-10) ) then write(error_unit, *) "Problem with LAPACK" - stop 5 + error stop endif end program check_libs -- GitLab