6
$\begingroup$

I tried to build wannier90 for parallel execution in a fedora system. However, I encounter with the following issue repetitively.

...
...
...
Error: Type mismatch between actual argument at (1) and actual argument at (2) (CHARACTER(*)/COMPLEX(8)).

../comms.F90:289:19:

  289 |     call MPI_bcast(array, size, MPI_logical, root_id, mpi_comm_world, error)

      |                   1

......
  332 |     call MPI_bcast(array, size, MPI_double_complex, root_id, mpi_comm_world, error)

      |                   2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (LOGICAL(4)/COMPLEX(8)).
../comms.F90:268:19:


  268 |     call MPI_bcast(array, size, MPI_double_precision, root_id, mpi_comm_world, error)

      |                   1
......
  332 |     call MPI_bcast(array, size, MPI_double_complex, root_id, mpi_comm_world, error)

      |                   2

Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(8)/COMPLEX(8)).
../comms.F90:247:19:
...
...
...

Any idea or a suggestion for build the code and mitigate this error is highly appreciated.

In the make.inc file, following two lines were added,

COMMS  = mpi
MPIF90 = /usr/lib64/openmpi/bin/mpifort #mpif90
$\endgroup$
4
  • 2
    $\begingroup$ Are you using gfortran? If so it is almost certainly a duplicate of fortran: Error: Type mismatch between actual argument at (1) and actual argument at (2) (INTEGER(8)/INTEGER(2)) over on Stackoverflow . Short version of the story, your program is not standard Fortran and you have to either fix it or add a flag to make the compiler ignore the error. $\endgroup$
    – Ian Bush
    Apr 23 at 9:06
  • $\begingroup$ Thanks for the reply, yes I am using gfortran and then modify the make.inc file as fallows FCOPTS = -O3 -fallow-argument-mismatch LDOPTS = then I issue the make command. build it finally I issued the command "mpirun -np 4 wannier90.x -pp si" it create nnkp file and mentioned as " Running in parallel on 4 CPUs" in the .wout file. however after running the pw2wannnier90.x and run with "mpirun -np 4 wannier90.x si" result a (Segmentation fault) $\endgroup$ Apr 23 at 10:32
  • $\begingroup$ Please use a proper code block. $\endgroup$ Apr 23 at 10:54
  • $\begingroup$ @wenu that is a separate issue. Please use a different question to ask about it. You will need to supply more details than you have to get an answer $\endgroup$
    – Ian Bush
    Apr 23 at 16:38

1 Answer 1

4
$\begingroup$

This problem is per see, not a bug in the code.

The problem is that fortran does not, implicitly, enforce data-type similarity between arguments (much like C).
However, this is not standard compliant (read the F90 standard section 12.4.1.2). Yet, since most codes are legacy codes and this way of doing things has been common for decades, it is still allowed via compilation extensions.

I.e. a method could be defined like this:

subroutine program(arr)
  complex :: arr(10, 10)
  ...
end subroutine

subroutine caller()
  complex :: zarr(10, 10)
  real :: rarr(2, 10, 10)
  call program(zarr)
  call program(rarr)
end subroutine

Both would work, since the memory layout is equivalent.

NOTE: You should never do this. It is typically something you'll see across older codes.

Since GNU compiler version 10 the standard is now enforced, and hence the argument types must match.

To allow backwards compatibility, one should add this flag:

#  Generic flag name:
FFLAGS = -fallow-argument-mismatch
# Fortran flag options name in wannier90
FCOPTS = -fallow-argument-mismatch

as also mentioned in the comments.

So simply add the above to the make.inc and you should be able to compile Wannier90.

The reason you see this is not because of Wannier90, but rather because of the MPI module they are using. If Wannier90 was using the mpi_f08 module, then these errors would go away.

$\endgroup$
6
  • 1
    $\begingroup$ Gfortran 10 and later are simply enforcing the Fortran standard as it has been for over half a century. As such it is diagnosing a problem in the code. Whatever the C equivalent is and how that behaves is irrelevant. In a simple case like this for a code to conform to the Fortran standard the type, kind and rank of the actual and dummy arguments must match. $\endgroup$
    – Ian Bush
    Apr 23 at 16:35
  • $\begingroup$ @IanBush and nickpapior thank you very much for your reply and comments $\endgroup$ Apr 23 at 17:51
  • $\begingroup$ @IanBush you are correct, it has just been so common in the language that it was never understood as a standard. Thanks. $\endgroup$
    – nickpapior
    Apr 24 at 7:57
  • 1
    $\begingroup$ @IanBush I have amended the answer, please have a look $\endgroup$
    – nickpapior
    Apr 24 at 8:07
  • $\begingroup$ @nickpapior I hear where you are coming from, but it is still a bug in the code, at least to my eyes. Just because many people think it is correct doesn't make it correct. But apart from the very first sentence I mostly agree. My only other complaint is that I would say it is because of Wannier90, but the way mpi has been defined in the past makes it difficult to do it properly - and the reference to mpi_08, which is what people should be using nowadays, is great. $\endgroup$
    – Ian Bush
    Apr 24 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .