OpenCoarrays integration with gfortran

Bernhard Reutner-Fischer rep.dot.nop@gmail.com
Sun Sep 23 20:19:00 GMT 2018


On Sun, 23 Sep 2018 at 21:17, Toon Moene <toon@moene.org> wrote:
>
> [ dropping mailing list gcc-patches, as it is not relevant to *this*
> discussion :-) ]

yea, sorry for that.
>
> On 09/23/2018 06:47 PM, Bernhard Reutner-Fischer wrote:
>
> > On 23 September 2018 11:46:57 CEST, Toon Moene <toon@moene.org> wrote:
>
> >> and recompiled my stuff:
> >>
> >> gfortran -g -fbacktrace -fcoarray=lib random-weather.f90
> >> -L/usr/lib/x86_64-linux-gnu/open-coarrays/openmpi/lib -lcaf_mpi
> >>
> >> [ Yes, the location of the libs is quite experimental, but OK for the
> >> "Testing" variant of Debian ... ]
> >
> > Are you sure you need the -L?
> > For me a simple  -fcoarray=lib -lcaf_mpi
> > links fine.
>
> I get this:
>
> toon@moene:~/src$ gfortran -g -fbacktrace -fcoarray=lib
> random-weather.f90 -lcaf_mpi
> /usr/bin/ld: cannot find -lcaf_mpi
> collect2: error: ld returned 1 exit status
>
> Are you sure the linker isn't finding another libcaf_mpi.so ?

Yes, i'm certain it finds the right libcaf_mpi and openmpi, but then
you're on testing and i'm on sid, maybe that's a difference.
For reference (my compiler built from trunk lives in /opt/$(uname
-m)/gcc-9.0.mine):
$ cat ~/tmp/hello.f08;echo EOF
implicit none
character(len=64) :: str, hi[*]
integer :: i, nprocs
nprocs = num_images()
do i=1, nprocs
  !write(hi[this_image()], '(i0,a,i0,": ",a)') this_image(), '/',
nprocs, 'hello world' ! :) but data-ref :(
  write(str, '(i0,a,i0,": ",a)') this_image(), '/', nprocs, 'hello world' ! :(
  hi[this_image()] = str
end do
sync all
write(*,*) hi[this_image()]
end
EOF
$ gfortran -o hi -fcoarray=lib -lcaf_mpi ~/tmp/hello.f08 && mpirun -np 3 ./hi
 1/3: hello world
 2/3: hello world
 3/3: hello world
$ ldd ./hi
linux-vdso.so.1 (0x00007ffd03986000)
libcaf_mpi.so.3 => /usr/lib/x86_64-linux-gnu/libcaf_mpi.so.3
(0x00007fe9e6a72000)
libgfortran.so.5 => /opt/x86_64/gcc-9.0.mine/lib64/libgfortran.so.5
(0x00007fe9e677a000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe9e65e6000)
libgcc_s.so.1 => /opt/x86_64/gcc-9.0.mine/lib64/libgcc_s.so.1
(0x00007fe9e65c2000)
libquadmath.so.0 => /opt/x86_64/gcc-9.0.mine/lib64/libquadmath.so.0
(0x00007fe9e6576000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe9e63b9000)
libmpi.so.40 => /usr/lib/x86_64-linux-gnu/libmpi.so.40 (0x00007fe9e62af000)
libmpi_usempif08.so.40 =>
/usr/lib/x86_64-linux-gnu/libmpi_usempif08.so.40 (0x00007fe9e6278000)
libmpi_usempi_ignore_tkr.so.40 =>
/usr/lib/x86_64-linux-gnu/libmpi_usempi_ignore_tkr.so.40
(0x00007fe9e626c000)
libmpi_mpifh.so.40 => /usr/lib/x86_64-linux-gnu/libmpi_mpifh.so.40
(0x00007fe9e620f000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe9e6acb000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe9e620a000)
libopen-rte.so.40 => /usr/lib/x86_64-linux-gnu/libopen-rte.so.40
(0x00007fe9e6150000)
libopen-pal.so.40 => /usr/lib/x86_64-linux-gnu/libopen-pal.so.40
(0x00007fe9e60a3000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe9e6099000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fe9e6094000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe9e5e76000)
libhwloc.so.5 => /usr/lib/x86_64-linux-gnu/libhwloc.so.5 (0x00007fe9e5e35000)
libevent-2.1.so.6 => /usr/lib/x86_64-linux-gnu/libevent-2.1.so.6
(0x00007fe9e5bdd000)
libevent_pthreads-2.1.so.6 =>
/usr/lib/x86_64-linux-gnu/libevent_pthreads-2.1.so.6
(0x00007fe9e59da000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe9e59b9000)
libnuma.so.1 => /usr/lib/x86_64-linux-gnu/libnuma.so.1 (0x00007fe9e59ab000)
libltdl.so.7 => /usr/lib/x86_64-linux-gnu/libltdl.so.7 (0x00007fe9e59a0000)
$ dpkg -S /usr/lib/x86_64-linux-gnu/libcaf_mpi.so.3
libcaf-mpi3:amd64: /usr/lib/x86_64-linux-gnu/libcaf_mpi.so.3
$ dpkg -l libcaf-mpi3
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  libcaf-mpi3:amd64     2.2.0-1         amd64           Co-Array
Fortran libraries for gfortran

I'd check if you really got the debian files so you don't run afoul a
manual install or leftovers thereof.
If it's really unpleasant in testing, it will at least ripple down
from sid sometimes and hence should work without hazzle soonish :)

HTH and cheers,
Bernhard



More information about the Fortran mailing list