Hi all,

I do not know if this forum is the most appropriate, but as it based 
using gfortran I will try to start here. 

I usually build the ATLAS library in some beta version without any 
numerical problem that I remember. In a circumstantial way, I have to 
use the system ATLAS library and, today, I am getting some incorrect 
numerical results with the DGBSV lapack fortran subroutine, which is 
described below with a simple test. 

Perhaps, I am not using the correct sintaxis in the interface, maybe 
in the compiler flags or the link ones? Please, any ideas? 
Thanks in advance.

Regards.
Jorge.
--
A simple test: it is built for the General Band Matrix Factorization
and Multiple Right-Hand Side Solver DGBSV lapack fortran subroutine,
and it is based from:
  IBM Documentation
  SGBSV, DGBSV, CGBSV, and ZGBSV
  (General Band Matrix Factorization and Multiple Right-Hand Side Solve)
  
https://www.ibm.com/docs/en/essl/6.2?topic=blaes-sgbsv-dgbsv-cgbsv-zgbsv-general-band-matrix-factorization-multiple-right-hand-side-solve

$ cat /proc/version
Linux version 5.13.19-200.fc34.x86_64 
(mockbu...@bkernel01.iad2.fedoraproject.org) (gcc (GCC) 11.2.1 20210728 (Red 
Hat 11.2.1-1), GNU ld version 2.35.2-5.fc34) #1 SMP Sat Sep 18 16:32:24 UTC 2021

$ sudo dnf --best reinstall atlas*

$ which gfortran
/usr/beta/gcc-trunk/bin/gfortran

$ gfortran --version
GNU Fortran (GCC) 12.0.0 20210914 (experimental)

$ gfortran -march=native -mtune=native -fall-intrinsics -fcheck=all 
-fimplicit-none -fmax-errors=4 -fPIC -std=f2018 -Wall -Waliasing 
-Warray-temporaries -Wcharacter-truncation -Werror -Wextra -Wimplicit-interface 
-Wimplicit-procedure -Wintrinsic-shadow -Wline-truncation -Wuse-without-only 
-Wrealloc-lhs-all -Wsurprising -Wtabs -Wuninitialized -Wunused-parameter -Og -o 
trouble.exe trouble.f90  -L/usr/lib64/atlas -llapack -lf77blas -lcblas -ltatlas

(Note: the same results either -ltatlas, -lsatlas, -flto=auto flags).

$ ./trouble.exe

(snip)

info =  1   # <-- i.e. the solution has not been computed.

$ cat trouble.f90

module m_interfase
  implicit none
  private
  public :: idp, iin, dgbsv
  integer, parameter :: idp = kind (1.0d0)
  integer, parameter :: iin = kind (1)    
  interface
    subroutine dgbsv (n, kl, ku, nrhs, ab, ldab, ipiv, b, ldb, info)
      integer           info, kl, ku, ldab, ldb, n, nrhs
      integer           ipiv (*)
      double precision  ab (ldab,*), b (ldb,*)
      external          dgbtrf, dgbtrs, xerbla
      intrinsic         max
    end subroutine dgbsv
  end interface
end module m_interfase
!
program trouble
  use  m_interfase, only: iin, idp, dgbsv
  implicit none
  real (idp), parameter :: cero = 0.0_idp
  real (idp), parameter :: uno  = 1.0_idp
  real (idp), parameter :: dos  = 2.0_idp
  real (idp), parameter :: tres = 3.0_idp
  real (idp), parameter :: cuat = 4.0_idp
  real (idp), parameter :: cinc = 5.0_idp
  real (idp), parameter :: seis = 6.0_idp
  real (idp), parameter :: siet = 7.0_idp
  real (idp), parameter :: ocho = 8.0_idp
  real (idp), parameter :: nuev = 9.0_idp
  real (idp), dimension (9,9), parameter :: &
    ccc = reshape ( [ &
      uno,  dos, tres, cero, cero, cero, cero, cero, cero, & ! 1
      dos,  uno,  dos, tres, cero, cero, cero, cero, cero, & ! 2
     tres,  dos,  uno,  dos, tres, cero, cero, cero, cero, & ! 3
     cuat, tres,  dos,  uno,  dos, tres, cero, cero, cero, & ! 4
     cero, cuat, tres,  dos,  uno,  dos, tres, cero, cero, & ! 5
     cero, cero, cuat, tres,  dos,  uno,  dos, tres, cero, & ! 6
     cero, cero, cero, cuat, tres,  dos,  uno,  dos, tres, & ! 7
     cero, cero, cero, cero, cuat, tres,  dos,  uno,  dos, & ! 8
     cero, cero, cero, cero, cero, cuat, tres,  dos,  uno  & ! 9
     ], [9,9])
  real (idp), dimension (9,3), parameter :: &
    vvv = reshape ( [ &
      uno,  uno,  uno,  uno,  uno,  uno,  uno,  uno,  uno, & ! 1
      uno, -uno,  uno, -uno,  uno, -uno,  uno, -uno,  uno, & ! 2
      uno,  dos, tres, cuat, cinc, seis, siet, ocho, nuev  & ! 3
      ], [9,3])
  real    (idp), dimension (9,9) :: aaa
  real    (idp), dimension (9,3) :: bbb
  integer (iin), dimension (9)   :: ipiv
  integer (iin) :: nn, klo, kup, nrhs, lda, ldb, info
  integer (iin) :: i
  !
  nn   = size (aaa,1)
  klo  = 2
  kup  = 3
  nrhs = size (bbb,2)
  lda  = 2 * klo + kup + 1
  ldb  = nn
  aaa  = ccc
  bbb  = vvv
  ipiv = 0
  !
  write (*,*)
  write (*,*)" dgbsv (General Band Side) test "
  write (*,*)
  write (*,*)" system matrix: aaa  "
  do  i = 1, nn
  write (*,*) real (aaa (i,:))
  end do
  write (*,*)
  write (*,*)" source: bbb  "
  do  i = 1, nn
  write (*,*) real (bbb (i,:))
  end do
  write (*,*)" nn   = ", nn
  write (*,*)" klo  = ", klo
  write (*,*)" kup  = ", kup
  write (*,*)" nrhs = ", nrhs
  write (*,*)" lda  = ", lda
  write (*,*)" ldb  = ", ldb
  !           N  KL   KU   NRHS   A   LDA   IPIV  B    LDB  INFO)
  !           |   |    |    |     |    |    |     |      |     |
 !call dgbsv (9 , 2  , 3  , 3   , aaa, 8  , ipiv, bbb,   9, info)
  call dgbsv (nn, klo, kup, nrhs, aaa, lda, ipiv, bbb, ldb, info)
  !
  write (*,*)
  write (*,*)" output aaa: "
  do  i = 1, nn
  write (*,*) real (aaa (i,:))
  end do
  write (*,*)
  write (*,*)" output bbb: "
  do  i = 1, nn
  write (*,*) real (bbb (i,:))
  end do 
  write (*,*)
  write (*,*)" output ipiv: ", ipiv
  write (*,*)
  write (*,*)" info = ", info
end program trouble
--

Reply via email to