Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Type Mismatch and Segmentation Fault in comm.F90 Using include 'mpi.h' in GNU Fortran (GCC) 12.3.0 #521

Open
stefan-wolfsheimer opened this issue Oct 21, 2024 · 0 comments

Comments

@stefan-wolfsheimer
Copy link

Summary:

A segmentation fault occurs in the Fortran file comm.F90 when using include 'mpi.h' with GNU Fortran (GCC) 12.3.0 at optimization level -O2. Additionally, the program does not compile when using the flag -fno-allow-argument-mismatch, indicating a type mismatch in MPI calls involving complex data types. Switching from include 'mpi.h' to use mpi resolves both the segmentation fault and the type mismatch issue.

Description:

When compiling comm.F90 under GNU Fortran (GCC) 12.3.0, the program fails to compile when the flag -fno-allow-argument-mismatch is used, indicating a type mismatch.
When compiling with '-fallow-argument-mismatch' and optimization level -O2, the wannier90.x program encounters a segmentation fault during execution. The issue is resolved by replacing include 'mpi.h' with use mpi, which aligns the MPI interfaces correctly with Fortran types.

Steps to Reproduce

  1. Attempt to compiling with -fno-allow-argument-mismatch
FFLAGS="-O2 -fno-allow-argument-mismatch"
make all FCOPTS="$FFLAGS" LDOPTS="$FFLAGS"

Expected outcome: type mismatch error
2. Compile with -fallow-argument-mismatch

FFLAGS="-O2 -fallow-argument-mismatch"
make all FCOPTS="$FFLAGS" LDOPTS="$FFLAGS"

The program should compile successfully.
3. Run the program

cd examples/example01
mpirun -np 4 ../../wannier90.x gaas.win

Expected outcome: segmentation fault

Expected behaviour

The program should compile and run correctly at all optimization levels (-O0, -O2, etc.) without segmentation faults or type mismatch issues

Actual behaviour

  • When compiling with -fno-allow-argument-mismatch and include 'mpi.h', the program fails to compile due to a type mismatch error.
  • When compiled with -O2 and -fallow-argument-mismatch, the program runs but crashes with a segmentation fault.

Workaround / possible solution

Replace include "mpi.h" with `use mpi'

stefan-wolfsheimer pushed a commit to stefan-wolfsheimer/easybuild-easyconfigs that referenced this issue Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant