scafacos / scafacos

ScaFaCoS library for Fast Coulomb Solvers
http://www.scafacos.de
GNU General Public License v3.0
26 stars 26 forks source link

ScaFaCoS v1.0.1 lib does not build on Fedora 32 / gfortran 10.x #29

Closed akohlmey closed 4 years ago

akohlmey commented 4 years ago

Hi when trying to build LAMMPS with the USER-SCAFACOS package (current git master) on a Fedora 32 installation, compilation fails to compile lib/fmm/src/mp_wrapper.f90 with the errors listed below. The code looks valid to me, so I am confused what may be the cause and what could be a possible workaround. To reproduce:

git clone --depth 1 https://github.com/lammps/lammps.git -b master lammps
singularity pull fedora.sif library://lammps/default/lammps_development:fedora32_mingw
singularity shell fedora.sif
cd lammps
mkdir build-scafacos
cd build-scafacos
cmake -D PKG_USER-SCFACOS=yes -D DOWNLOAD_SCAFACOS=yes ../cmake
make

Here are the error messages:

build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:696:53:

  696 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_REAL4,dst,elem_tmp,MPI_REAL4,comm,ierr)
      |                                                     1
......
  734 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_INTEGER8,dst,elem_tmp,MPI_INTEGER8,comm,ierr)
      |                                                        2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/INTEGER(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:678:52:

  678 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_BYTE,dst,elem_tmp,MPI_BYTE,comm,ierr)
      |                                                    1
......
  734 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_INTEGER8,dst,elem_tmp,MPI_INTEGER8,comm,ierr)
      |                                                        2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(1)/INTEGER(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:656:52:

  656 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_BYTE,dst,elem_tmp,MPI_BYTE,comm,ierr)
      |                                                    1
......
  734 |   call mpi_allgather(MPI_IN_PLACE,elem_tmp,MPI_INTEGER8,dst,elem_tmp,MPI_INTEGER8,comm,ierr)
      |                                                        2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(1)/INTEGER(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:592:34:

  592 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:574:48:

  574 |                 call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL4,op,comm,ierr)
      |                                                1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2              
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/REAL(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:553:34:

  553 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL4,op,comm,ierr)
      |                                  1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/REAL(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:534:34:

  534 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL4,op,comm,ierr)
      |                                  1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/REAL(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:516:34:

  516 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_INTEGER8,op,comm,ierr)
      |                                  1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/REAL(8)).
build-scafacos/scafacos_build-prefix/src/scafacos_build/lib/fmm/src/mp_wrapper.f90:497:34:

  497 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_INTEGER8,op,comm,ierr)
      |                                  1
......
  632 |   call mpi_allreduce(MPI_IN_PLACE,dst,elem_tmp,MPI_REAL8,op,comm,ierr)
      |                                  2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/REAL(8)).
rhalver commented 4 years ago

Hi Axel,

which compilers are used by Fedora when compiling the package, I assume gfortran? If yes, which version?

akohlmey commented 4 years ago

Hi Axel,

which compilers are used by Fedora when compiling the package, I assume gfortran? If yes, which version?

as the subject line of the issue says, it is gfortran 10.

build-scafacos> gfortran --version
GNU Fortran (GCC) 10.1.1 20200507 (Red Hat 10.1.1-1)
akohlmey commented 4 years ago

FWIW, there are no issues with Fedora 31 and gfortran 9.x

rhalver commented 4 years ago

It seems that gfortran changed its default behavior when dealing with Fortran interfacing. Now it checks if, when calling an external function, e.g. mpi_allreduce, if the function is always called with the same arguments. Since it is not called with the same arguments here, it fails. There is a way to revert this change by passing the -fallow-argument-mismatch flag. I will check if this resolves the issue by reverting the errors to warnings and will let you know once the compilation finished.

rhalver commented 4 years ago

@akohlmey: The flag seems to fix the issue for me, I will talk to Christoph Junghans, how to pass the flag with cmake, only if gfortran 10+ is used, if that is fine with you. . Then I will open a pull-request on Lammps to fix it.

akohlmey commented 4 years ago

On Mon, Jun 15, 2020 at 10:44 AM rhalver notifications@github.com wrote:

@akohlmey https://github.com/akohlmey: The flag seems to fix the issue for me, I will talk to Christoph Junghans, how to pass the flag with cmake, only if gfortran 10+ is used, if that is fine with you. . Then I will open a pull-request on Lammps to fix it.

already working on it. just noticed some other, related issues and am working on those, too.

axel.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/scafacos/scafacos/issues/29#issuecomment-644178535, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACGTY64UHNISJMI54SLXO3RWYXTJANCNFSM4N5XCEOA .

-- Dr. Axel Kohlmeyer akohlmey@gmail.com http://goo.gl/1wk0 College of Science & Technology, Temple University, Philadelphia PA, USA International Centre for Theoretical Physics, Trieste. Italy.

rhalver commented 4 years ago

Ok, let me know, if there is anything I need to do. For the time being, I close this issue now.

akohlmey commented 4 years ago

One more followup to this. While the compiler flag works around the compilation issue, it should be considered to address this through changes in the source code. After some reading of bug reports and discussions on the gcc bugzilla pages, the origin of the compiler issue is that mpi_allreduce and mpi_allgather are called with an implicit interface. However modern revisions of the Fortran standard require explicit interfaces for subroutines and functions that can take multiple types or ranks of arguments. Thus one way to make the library compile without switching the compiler to "legacy mode" would require either converting the whole thing to use the MPI (or MPI_F08?) module instead of the (legacy) mpif.h include file, or adding explicit interfaces, e.g. in each of the wrapper functions calling mpi_allreduce one would add something like following after the variable declarations:

interface
     subroutine mpi_allgather(send,scount,stype,recv,rcount,rtype,comm,err)
     ! declare data types of the interface here as they are called in this wrapper
     end subroutine mpi_allgather
end interface

This is a bit tedious and requires some careful debugging, but would help to future-proof the library and avoid problems compiling it for less "technical" people.