Open Sezoir opened 2 years ago
https://geodynamics.org/cig/software/specfem3d/ https://github.com/geodynamics/specfem3d_globe/tree/master
Minimum version of Fortran required using gfortran: F2003
How to compile with gfortran:
git clone https://github.com/geodynamics/specfem3d_globe.git
cd specfem3d_globe
This project requires an MPI compiler. For this project I used the ompi wrapper compiler around my gfortran/gcc compilers. After that you can compile the project by running:
./configure FC=mpifort CC=gcc MPIFC=mpifort
make
Where the paths to the OMPI wrapper and gcc compilers are correctly substituted in.
In theory the FC compiler can be replaced with gfortran
, however when I did this I was getting a "warning treated as error":
Error: ‘__builtin_memcpy’ reading 128 bytes from a region of size 112 [-Werror=stringop-overflow=]
Which does not occur when compiling with mpifort
. From a quick look the configure
script seems to set quite a lot more flags when using gfortran
(one of them being -wError
which I believe caused the compile error).
Does it compile with flang-new: No
According to documentation you should just be able to replace the FC
And CC
variables when calling configure
. While I could successfully configure the project with ./configure FC=flang-new CC=clang-12 MPIFC=mpifort
, when it came to compiling I ended up getting this error:
$ clang-12 -c -I./setup -g -O2 -o obj/force_ftz.cc.o src/specfem3D/force_ftz.c
src/shared/param_reader.c:92:9: error: function cannot return function type 'void (char *, int *, int *)'
FC_FUNC_(param_open,PARAM_OPEN)(char * filename, int * length, int * ierr)
Whilst the error is a bit confusing, from a quick look I found the configure script does not correctly configure setup/config.h
. The FC_FUNC(name,NAME)
macro definition is not being generated, leading to the clang compiler getting confused when compiling. It results in looking like:
/* Define to a macro mangling the given C identifier (in lower and upper
case), which must not contain underscores, for linking with Fortran. */
/* #undef FC_FUNC */
/* As FC_FUNC, but for C identifiers containing underscores. */
/* #undef FC_FUNC_ */
However, if we configure with either gfortran or mpifort the macro definition is generated such:
/* Define to a macro mangling the given C identifier (in lower and upper
case), which must not contain underscores, for linking with Fortran. */
#define FC_FUNC(name,NAME) name ## _
/* As FC_FUNC, but for C identifiers containing underscores. */
#define FC_FUNC_(name,NAME) name ## _
From looking at the Makefile generating this, and the comment of the macro, I believe this issue is due to not currently including the ExternalNameConversion pass in the pass pipeline definition in the driver. The Makefile should then start generating the macro definition correctly once the pass is included in the default pass pipeline.
Enable building and execution of the specfem3d application with the LLVM Flang compiler.