Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cannot build examples/ on Ubuntu with gfortran / fort77 / ifx with current BLAS / LAPACK libraries #19

Open
flor1an42 opened this issue Nov 15, 2024 · 2 comments

Comments

@flor1an42
Copy link

With the following modifications on make_Unix, I got the receip lib for building slicot.a and lpkaug.a sucessfully compiled, but the receipe example failed.

make -f makefile_Unix lib
make -f makefile_Unix example

FORTRAN = gfortran
OPTS = -O3 -shared -fPIC -llapacke -llapack -lrefblas -lgfortran -lopenblas -lopenlapack -lblas
BLASLIB      = /usr/lib/x86_64-linux-gnu/blas/libblas.a
LAPACKLIB    = /usr/lib/x86_64-linux-gnu/lapack/liblapack.a

Without the modified OPTS flags, the compiler gets stuck on ./TAB01ND <AB01ND.dat >AB01ND.exa .

With the gfortran and fort77 I get the following error output:

( cd examples; make -f makefile_Unix )
make[1]: Entering directory '/mnt/c/Workspace/Slycot/slycot/src/SLICOT-Reference/examples'
gfortran  -o TAB01MD TAB01MD.o ../slicot.a ../lpkaux.a /usr/lib/x86_64-linux-gnu/lapack/liblapack.a /usr/lib/x86_64-linux-gnu/blas/libblas.a
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/13/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
/usr/bin/ld: TAB01MD.o: in function `MAIN__':
TAB01MD.f:(.text+0x35): undefined reference to `for_set_fpe_'
/usr/bin/ld: TAB01MD.f:(.text+0x41): undefined reference to `for_set_reentrancy'
/usr/bin/ld: TAB01MD.f:(.text+0x77): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0xa8): undefined reference to `for_read_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0xe5): undefined reference to `for_read_seq_lis'
/usr/bin/ld: TAB01MD.f:(.text+0x112): undefined reference to `for_read_seq_lis_xmit'
/usr/bin/ld: TAB01MD.f:(.text+0x14a): undefined reference to `for_read_seq_lis_xmit'
/usr/bin/ld: TAB01MD.f:(.text+0x213): undefined reference to `for_read_seq_lis'
/usr/bin/ld: TAB01MD.f:(.text+0x28c): undefined reference to `for_read_seq_lis'
/usr/bin/ld: TAB01MD.f:(.text+0x332): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0x3d7): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0x47d): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0x556): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.f:(.text+0x5f0): undefined reference to `for_write_seq_fmt'
/usr/bin/ld: TAB01MD.o:TAB01MD.f:(.text+0x635): more undefined references to `for_write_seq_fmt' follow
/usr/bin/ld: TAB01MD.o: in function `MAIN__':
TAB01MD.f:(.text+0x653): undefined reference to `for_stop_core_quiet'
collect2: error: ld returned 1 exit status
make[1]: *** [makefile_Unix:330: TAB01MD] Error 1
make[1]: Leaving directory '/mnt/c/Workspace/Slycot/slycot/src/SLICOT-Reference/examples'
make: *** [makefile_Unix:51: example] Error 2

and with the ifx fortran compiler the following:

( cd examples; make -f makefile_Unix )
make[1]: Entering directory '/mnt/c/Workspace/Slycot/slycot/src/SLICOT-Reference/examples'
ifx  -o TAB01MD TAB01MD.o ../slicot.a ../lpkaux.a /usr/lib/x86_64-linux-gnu/lapack/liblapack.a /usr/lib/x86_64-linux-gnu/blas/libblas.a
ld: /usr/lib/x86_64-linux-gnu/lapack/liblapack.a(xerbla.o): in function `xerbla_':
(.text+0x76): undefined reference to `_gfortran_st_write'
ld: (.text+0x81): undefined reference to `_gfortran_string_len_trim'
ld: (.text+0x98): undefined reference to `_gfortran_transfer_character_write'
ld: (.text+0xa8): undefined reference to `_gfortran_transfer_integer_write'
ld: (.text+0xb0): undefined reference to `_gfortran_st_write_done'
ld: (.text+0xbb): undefined reference to `_gfortran_stop_string'
make[1]: *** [makefile_Unix:330: TAB01MD] Error 1
make[1]: Leaving directory '/mnt/c/Workspace/Slycot/slycot/src/SLICOT-Reference/examples'
make: *** [makefile_Unix:51: example] Error 2

My conclusion is that ifx has an implementation of for_set_fpe_ which is not available at gfortran and fort77.
Also all three fortran compiles lacks of _gfortran_st_write.

I think long time ago the Fortran compiler got this routines, and (possibly newer?) Fortran compilers lacks of them.
It may be the case that also there is a missing flag in the compiler options.
Another idea is that there is a incompatibility with the newer LAPACK library version.

My apt versions are on Ubuntu 24.04.1 LTS

Package: libblas-dev Version: 3.12.0-3build1.1
Package: liblapack-dev Version: 3.12.0-3build1.1

Is there a compiler known which compiles and runs the example in a clean way? Which Fortran compiler (with version number) and corresponding BLAS and LAPACK version is known to run properly?

@roryyorke
Copy link

For what it's worth, on Ubuntu 22.04, with the diff at the end to use system BLAS & LAPACK, I get TAB01MD to compile, and its output AB01MD.exa is almost identical to AB01MD.res (the only difference is some zeros have negative sign).

The very next example TAB01ND, also compiles, but seems to run forever (been going for a few minutes, still at 100% on 1 CPU).

Versions of gfortran, BLAS, and LAPACK:

$ gfortran --version
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
$ dpkg-query -l libblas-dev liblapack-dev
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version       Architecture Description
+++-===================-=============-============-=====================================================
ii  libblas-dev:amd64   3.9.0-1build1 amd64        Basic Linear Algebra Subroutines 3, static library
ii  liblapack-dev:amd64 3.9.0-1build1 amd64        Library of linear algebra routines 3 - static version

diff to use system libs:

modified   make_Unix.inc
@@ -36,7 +36,7 @@ LOADOPTS = $(SLICOTLIB) $(LPKAUXLIB) $(LAPACKLIB) $(BLASLIB)
 #  machine-specific, optimized BLAS library should be used whenever
 #  possible.)
 #
-BLASLIB      = ../libs/blas.a
-LAPACKLIB    = ../libs/lapack.a
+BLASLIB      = -lblas
+LAPACKLIB    = -llapack
 LPKAUXLIB    = ../lpkaux.a
 SLICOTLIB    = ../slicot.a

@roryyorke
Copy link

the -fdefault-integer-8 was what caused infinite loop, and also some segfaults in toher tests; at a guess, that flag makes sense if you've compiled BLAS and LAPACK yourself also with -fdefault-integer-8.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants