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

can compile specfem2D but failed during execute #1162

Closed
rzhouaf opened this issue Nov 7, 2022 · 7 comments
Closed

can compile specfem2D but failed during execute #1162

rzhouaf opened this issue Nov 7, 2022 · 7 comments

Comments

@rzhouaf
Copy link

rzhouaf commented Nov 7, 2022

Hi, there,

I was able to compile specfem2d on my MacBook Pro (M1). However, when I tried to run "run_this example.sh" for EXAMPLES/Tromp2005, I got below error, and no output. Any ideas? Thanks!

Program received signal SIGILL: Illegal instruction.
Backtrace for this error:
Could not print backtrace: executable file is not an executable
#0 0x10295f187
#1 0x10295e163
#2 0x1aa1e74a3
#3 0x20c0b319b
#4 0x20c0b612b
#5 0x1b2ae4aeb
#6 0x1b2ae4923
#7 0x1aa00c1b3
#8 0x1aa01b413
#9 0x1b2bb2927
#10 0x1b2ae4743
#11 0x1b2b0ee13
#12 0x1aa00c1b3
#13 0x1aa00da33
#14 0x1b2ae4513
#15 0x10402c3a3
#16 0x104032533
#17 0x20b961147

./run_this_example.sh: line 47: 50186 Illegal instruction: 4 ./xmeshfem2D

@danielpeter
Copy link
Contributor

:) the backtrace is not very helpful... that's always tricky on Macs to get some readable backtrace outputs.

did you get any console output when running the script? the beginning should looks like:

SPECFEM2D/EXAMPLES/Tromp2005$ ./run_this_example.sh 
running example: Mon Nov  7 17:15:15 CET 2022

setting up example...


running mesher...


 **********************************************
 *** Specfem 2-D Mesher - serial version    ***
 **********************************************

 Running Git version of the code corresponding to undefined in the case of old tar ball builds
 dating undefined in the case of old tar ball builds

 Reading the parameter file...

 Title of the simulation: Tromp-Tape-Liu (GJI 2005)


also, can you attach your config.log file to see how you compiled the code? please also make sure first that you can run a simple fortran code on your Mac installation.

@rzhouaf
Copy link
Author

rzhouaf commented Nov 8, 2022

Thanks, Daniel, for your response. Yes, I can compile and run simple fortran code on my Macbook
hello.f90
program hello
! This is a comment line; it is ignored by the compiler
print *, 'Hello, World!'
end program hello

I tried 2 configures to compile specfem2D
1 ./configure FC=gfortran CC=gcc (can't compile and create executable files, but it works on the Linux machine at the office, and can run successfully for EXAMPLES/Tromp2005/run_this_example.sh)

  1. ./configure FC=gfortran CC=gcc MPIFC=mpif90 --with-mpi -with-scotch-dir=/Users/rongmaozhou/Softwares/specfem3d/external_libs/scotch (work on Mac to create executable files, but can't run the example (Tromp2005). But same configure command and "make all" works for specfem3D on my Macbook and can run_this_example.sh under specfem3D. However, this doesn't work on Linux. It only created 3 programs, xdecompose_mesh, xmeshfem3D and xspecfem3D)

when I run specfem2D on the Macbook, it looks like this:
run_this_example.sh
running example: Mon Nov 7 18:46:20 EST 2022

setting up example...

running mesher...

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:
Could not print backtrace: executable file is not an executable
#0 0x104bbf187
#1 0x104bbe163
#2 0x1aa1e74a3
#3 0x20c0b319b
#4 0x20c0b612b
#5 0x1b2ae4aeb
#6 0x1b2ae4923
#7 0x1aa00c1b3
#8 0x1aa01b413
#9 0x1b2bb2927
#10 0x1b2ae4743
#11 0x1b2b0ee13
#12 0x1aa00c1b3
#13 0x1aa00da33
#14 0x1b2ae4513
#15 0x10628c3a3
#16 0x106292533
#17 0x20b961147
run_this_example.sh: line 47: 61505

Illegal instruction: 4 ./xmeshfem2D

Could not print backtrace: executable file is not an executable

Thanks,

Rongmao

@danielpeter
Copy link
Contributor

hi Rongmao, in the script output it fails immediately after calling the xmeshfem2D binary. that points to a problem with the compilation and libraries loaded. so my guess would be to check 2 things:

(1) the scotch library build: on a M1 Mac, you should use a different Makefile in the scotch/ library than the default one. on my Mac, this works:

cp -v external_libs/scotch/src/Make.inc/Makefile.inc.i686_mac_darwin8 external_libs/scotch/src/Makefile.inc

then compile without the --with-scotch-dir flag to re-compile the bundled scotch lib. that is, make sure to have a clean scotch directory first (it could be that the scotch directory you point to was compiled with a different, i.e. old intel-Mac, compiler).

thus, you would compile the serial version like:

./configure FC=gfortran CC=gcc
cp -v external_libs/scotch/src/Make.inc/Makefile.inc.i686_mac_darwin8 external_libs/scotch/src/Makefile.inc
make all

for the parallel version:

./configure FC=gfortran CC=gcc MPIFC=mpif90 --with-mpi
cp -v external_libs/scotch/src/Make.inc/Makefile.inc.i686_mac_darwin8 external_libs/scotch/src/Makefile.inc
make all

(2) if the above doesn't fix it, make sure that your mpi compiler works with a simple mpi program.

@rzhouaf
Copy link
Author

rzhouaf commented Nov 9, 2022

Thanks, Daniel. Following your suggestion, when I try the serial version: "make all" and get below error, and only have one xmeshfem2D compiled in the bin/ folder. Yes, I can compile mpi program and can execute it no problem. And I can also compiled specfem3D and run the example without issues.

src/specfem2D/write_wavefield_dumps.F90:405:28:
 
  405 |   subroutine mask_duplicates()
      |                            ^
Error: 'mask_duplicates' defined but not used [-Werror=unused-function]
src/specfem2D/write_wavefield_dumps.F90:461:30:
 
  461 |   subroutine mask_write_matrix()
      |                              ^
Error: 'mask_write_matrix' defined but not used [-Werror=unused-function]
f951: all warnings being treated as errors
make: *** [obj/write_wavefield_dumps.spec.o] Error 1

@rzhouaf
Copy link
Author

rzhouaf commented Nov 10, 2022

I added "-Wno-error=format-truncation" to Makefile, now 8 executable files were compiled. But when I ran, it still has same issues.

running example: Thu Nov 10 08:19:18 EST 2022

setting up example...

running mesher...

Program received signal SIGILL: Illegal instruction.

Backtrace for this error:

Could not print backtrace: executable file is not an executable
#0 0x102f53187
#1 0x102f52163
#2 0x1aa1e74a3
#3 0x20c0b319b
#4 0x20c0b612b
#5 0x1b2ae4aeb
#6 0x1b2ae4923
#7 0x1aa00c1b3
#8 0x1aa01b413
#9 0x1b2bb2927
#10 0x1b2ae4743
#11 0x1b2b0ee13
#12 0x1aa00c1b3
#13 0x1aa00da33
#14 0x1b2ae4513
#15 0x1046143a3
#16 0x10461a533
#17 0x20b961147
run_this_example.sh: line 47: 33399 Illegal instruction: 4 ./xmeshfem2D

@rzhouaf
Copy link
Author

rzhouaf commented Nov 10, 2022

Hi, Daniel,

Found similar issue report on sepcfem3d (SPECFEM/specfem3d#1496). Based on the discussion, I change running xmeshfem2D with mpirun, it works now.

Thanks again, Daniel!

@rzhouaf rzhouaf closed this as completed Nov 10, 2022
@rzhouaf rzhouaf reopened this Nov 10, 2022
@danielpeter
Copy link
Contributor

ok, thanks for figuring it out!

regarding the compilation errors with the subroutine mask_duplicates() and mask_write_matrix() defined but not used. this should have been fixed in the more recent devel branch version. you can try to update your version with this:

git clone --recursive --branch devel https://github.com/SPECFEM/specfem2d.git

for using the mpirun command when running a single process example (NPROC = 1), strangely I don't see that behavior on my Mac. I have the GCC compilers and OpenMPI libraries installed (through MacPorts.org). this runs properly also just by running ./bin/xmeshfem2D - there's no need to use mpirun -np 1 ./bin/xmeshfem2D even though I see that the mpi libraries are linked to the executable by:

otool -L ./bin/xmeshfem2D 

if you find out why your compilers and MPI installation bail out with a segmentation fault, it would be great to know.

@rzhouaf rzhouaf closed this as completed Nov 14, 2022
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

2 participants