Problems of mpirun for OpenMPI - fortran

I installed openmpi-4.0.0 (https://www.open-mpi.org/software/ompi/v4.0/) as follow
./configure --prefix="/usr/local/openmpi"
make
sudo make install
export PATH=$PATH:/usr/local/openmpi/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openmpi/lib/
source ~/.bashrc
sudo ldconfig
then enter the examples folder in the package, and use command:
make
mpirun -n 4 ./hello_usempi
it shows:
Hello, world, I am 0 of 1: Open MPI v2.1.1, package: Open MPI buildd#lcy01-amd64-009 Distribution, ident: 2.1.1, repo rev: v2.1.0-100-ga2fdb5b, May 10, 2017
Hello, world, I am 0 of 1: Open MPI v2.1.1, package: Open MPI buildd#lcy01-amd64-009 Distribution, ident: 2.1.1, repo rev: v2.1.0-100-ga2fdb5b, May 10, 2017
Hello, world, I am 0 of 1: Open MPI v2.1.1, package: Open MPI buildd#lcy01-amd64-009 Distribution, ident: 2.1.1, repo rev: v2.1.0-100-ga2fdb5b, May 10, 2017
Hello, world, I am 0 of 1: Open MPI v2.1.1, package: Open MPI buildd#lcy01-amd64-009 Distribution, ident: 2.1.1, repo rev: v2.1.0-100-ga2fdb5b, May 10, 2017
The problem seems to be only one processor is activated. Note, both openmpi-4.0.0 and Ifort were installed on my computer. Could anyone please give me a hand, thanks very much.
I add the messages of the command mpif90 -v and mpirun -v here
mpif90 -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
mpirun -v
[mpiexec#tony-ThinkPad-P50] set_default_values (../../ui/mpich/utils.c:3178): no executable provided
[mpiexec#tony-ThinkPad-P50] HYD_uii_mpx_get_parameters (../../ui/mpich/utils.c:3620): setting default values failed
[mpiexec#tony-ThinkPad-P50] main (../../ui/mpich/mpiexec.c:438): error parsing parameters
The code is here (Copyright of Open MPI https://www.open-mpi.org/software/ompi/v4.0/)
! Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
! University Research and Technology
! Corporation. All rights reserved.
! Copyright (c) 2004-2005 The Regents of the University of California.
! All rights reserved.
! Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved.
! $COPYRIGHT$
!
! Sample MPI "hello world" application using the Fortran mpi module
! bindings.
program main
use mpi
implicit none
integer :: ierr, rank, size, len
character(len=MPI_MAX_LIBRARY_VERSION_STRING) :: version
call MPI_INIT(ierr)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
call MPI_GET_LIBRARY_VERSION(version, len, ierr)
write(*, '("Hello, world, I am ", i2, " of ", i2, ": ", a)') &
rank, size, version
call MPI_FINALIZE(ierr)
end
The contents of the makefile are quite long, I think it is not convenient to post here, it is still in the install package of OpenMPI-4.0.0. Thank you once more.

Related

Fortran/MPI Compilation Error IMPLICIT NONE statement cannot follow attribute declaration

I am in the process of learning MPI in fortran, and so I've been writing a bunch of small functions that do simple tasks in MPI to get a good handle on it. However, halfway through, i began getting this error when trying to compile
$ mpif90 example.f90 -o example.out
example.f90:108:17:
108 | implicit none
| 1
Error: IMPLICIT NONE statement at (1) cannot follow attribute declaration statement at (2)
which doesn't even show me where (2) is so I don't know whats causing the error. But when I commented out implicit none, it compiled fine and ran correctly. Any ideas as to what is happening here?
Code:
program send_vec
include 'mpif.h'
implicit none
integer :: process_rank, cluster_size, ierror, message_item
integer :: i
integer, dimension(:), allocatable :: buffer_vector
allocate(buffer_vector(1:10))
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, cluster_size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, process_rank, ierror)
if ( process_rank == 0 ) then
do i = 1, 10
buffer_vector(i) = i
end do
write (*,*) "sent:", buffer_vector
call MPI_SEND(buffer_vector, 10, MPI_INT, 1, 1, MPI_COMM_WORLD, ierror)
else if (process_rank == 1) then
call MPI_RECV(buffer_vector, 10, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierror)
write (*,*) "recieved:", buffer_vector
end if
call MPI_FINALIZE(ierror)
end program send_vec
Also this is mpif90 -v
mpifort for MPICH version 3.4.1
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-7ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)
implicit none must appear before include 'mpif.h'
That being said, this is very error prone, and you should at least use
program send_vec
use mpi
implicit none
...
(note the implicit none is after the use mpi line)
Ideally, you would
program send_vec
use mpi_f08
implicit none
...
but that will likely require you to modernize your code
(for example, a datatype has its own type (e.g. Type(MPI_Datatype) instead of INTEGER)

Why gdb complain to me that No Source Available (with g++ -ggdb3)

For some reason I reinstalled my OS(manjaro linux) yesterday, and installed gcc and gdb by pacman, then I write a very small example program to make sure my environment is correct, because I am a beginner in linux and gdb. After compile,it went according to my expectations. Then I wanted to take a look at the STL source code through gdb, so I opened my gdb with tui mode. Everything seemed normal at first, but my gdb can't step into ss.insert() that I want to see, with [ No Source Available ] on the top side of the screen. And I've found the directory of the source file of operator<< is different to the version that before reinstall OS, and /usr/shared/c++/ doesn't exist anymore!
This is the version information of GCC(g++) and gdb
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++,d --with-isl --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-install-libiberty --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-libunwind-exceptions --disable-werror gdc_include_dir=/usr/include/dlang/gdc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (GCC)
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Why gdb complain to me that No Source Available (with g++ -ggdb3)
Because you are stopped inside libstdc++, which was built in a temporary directory (here /build/gcc/src/gcc-build/...) and that directory is not present on your machine.
It is exceedingly unlikely that you actually need to look at the source of operator<<(), but if you really do want to do that, install GCC sources, and use (gdb) directory to point GDB to the relevant sources.

openmpi and gfortran error : no specific subroutine for the generic ‘mpi_waitall’

Fortran code using MPI_Waitall will not compile on my system with gfortran and the openmpi library, but the same code does compile with intel fortran compilers (and the intel mpi implementation). I can't figure out how or why this is happening. Here is a minimal/trivial example of code that fails to compile:
test.f90
program TEST_WAITALL
use MPI
implicit none
integer :: ierr
integer :: N
integer, allocatable :: reqs(:)
integer :: to, tag, count
double precision :: data(100)
N = 5
reqs = 1
call MPI_INIT( ierr )
call MPI_Waitall(N, reqs, MPI_STATUS_IGNORE, ierr)
call MPI_SEND( data, count, MPI_DOUBLE_PRECISION, to, tag, MPI_COMM_WORLD, ierr )
call MPI_FINALIZE ( ierr )
end program TEST_WAITALL
Note this is not intended to run, and is clearly "nonsense" code.
When I compile with the intel toolchain, there are no issues:
mpiifort test.f90
When I compile with the gfortran/openmpi toolchain I get an error:
mpifort test.f90
test.f90:17:54:
call MPI_Waitall(N, reqs, MPI_STATUS_IGNORE, ierr)
1
Error: There is no specific subroutine for the generic ‘mpi_waitall’ at (1)
If I comment out just the call to MPI_Waitall, then the code compiles with both gfortran/openmpi and intel. So MPI is being found and linked against.
My first guess would be that somehow I've used the wrong interface to MPI_Waitall, and that I'm trying to pass arguments of the wrong type, but as far as I can see from online documentation, I can't see any problems with types.
I've also changed the third argument from an array of statuses to MPI_STATUS_IGNORE to see if this fixes the problem, but it did not.
I have openmpi-bin installed through the package manager (apt) on ubuntu, and compiler info is as follows:
mpifort -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.3.0-27ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
You have to use MPI_STATUSES_IGNORE and not MPI_STATUS_IGNORE because it is multiple statuses, each for each request.

Fortran runtime error: I/O past end of record on unformatted file

I am having a problem with a Fortran 90 code. The code reads a huge amount of data using the read statement. The error message points to the last line of this piece of code:
open(1,file=trim(filename),action='read',form='unformatted',status='old')
read(1) np ! np is a 6 element array of integers*4
npart = np(species)
if (sum(np(1:species-1))>0) then
read(1) (xempty,yempty,zempty,i=1,sum(np(1:species-1)))
end if
allocate(x(npart),y(npart),z(npart),mass(npart))
write(*,*) "number of particles: ", npart
read(1) (x(i),y(i),z(i),i=1,npart
The error message appears while running the code. It is:
Fortran runtime error: I/O past end of record on unformatted file
I think this problem is related with the record length limit in Fortran 90, but I am not sure how to solve this problem, and how to find or modify the record limit in gfortran. The error message does not show up if I use a smaller filename. In other words, when npart is smaller.
I am using the following gfortran compiler:
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-
6ubuntu1~16.04.4' --with-bugurl=file:///usr/share/doc/gcc-
5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-
c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-
build-id --libexecdir=/usr/lib --without-included-gettext --enable-
threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --
enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-
time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object -
-disable-vtable-verify --enable-libmpx --enable-plugin --with-system-
zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-
java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --
with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-
arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --
enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --
with-tune=generic --enable-checking=release --build=x86_64-linux-gnu -
-host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
The input file is in binary format, and it was created using a C code. It is not possible for me to know the compiler used to create the file. The last line of the code : read(1) (x(i),y(i),z(i),i=1,npart) reads positions of particles which are on real( 4 bytes) format.
Additionally, the error does not appear when I used an input file with smaller number of particles, in other words, when npart is smaller.

Gfortran does not have module Funits while ifort does

Once O tried to compile Fortran code that relies on funits. while it is not available in gfortran 4.9.3.
use FUNITS
1
Fatal Error: Can't open module file 'funits.mod' for reading at (1): No such file or directory
here is gfortran information
gfortran -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3/gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.9.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.9.3/work/gcc-4.9.3/configure --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/include/g++-v4 --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.9.3/python --enable-languages=c,c++,java,fortran --enable-obsolete --enable-secureplt --disable-werror --with-system-zlib --enable-nls --without-included-gettext --enable-checking=release --with-bugurl=https://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.9.3 p1.5, pie-0.6.4' --enable-libstdcxx-time --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-multilib --with-multilib-list=m32,m64 --disable-altivec --disable-fixed-point --enable-targets=all --enable-libgomp --disable-libmudflap --disable-libssp --disable-libcilkrts --enable-vtable-verify --enable-libvtv --enable-lto --without-cloog --enable-libsanitizer
Thread model: posix
gcc version 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)
Instead ifort version 14.0.3 has it pre-installed.
How can I install funits with gfortran as we need to rely on the free software?
FUNITS is a module. There is no such module in standard Fortran. It must be some external library, not an intrinsic module.
It is also not part of Intel Fortran although you claim it to be. It is not part of my Intel Fortran installation and it is not mentioned anywhere in the manual.
You have to find where does it come from, who supplies this library and compile it for gfortran yourself.
Or find out what it does and implement that functionality yourself.
A simple web search found 2 modules called FUNITS on the internet. Both just declare some file unit number constants. I have no idea whether you need one of them or not https://mfix.netl.doe.gov/develop/STI/source_profile_2015-2/mfix_und/MFIX_html/9899.html http://home.chpc.utah.edu/~u0703457/STILT_tutorial/WRF_STILT_code/STILT_updated/funits.f Probably it will be better to search your hard drive.