Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
15 Views

Segmentation Error when switching from linux to mac

I could compile and run a code on linux clusters without a problem. Now I want to run the same code on a brand new iMac, but I receive segmentation error when I run the same code. On linux I had to use the following flag:

FC=ifort
FFLAGS= -mcmodel medium -shared-intel

but because -mcmodel is not supported, I have to comment it out. Can this be the reason of this problem?Is there any alternative for MACs?

I have tried the following flags and non of them works:

FFLAGS= -heap-arrays

or

FFLAGS= -heap-arrays 10

or

FFLAGS= -Wl,-stack_size -Wl,10000000

PS: I just bought the iMac and I've installed the last version of intel fortran parallel studio. 

0 Kudos
3 Replies
Highlighted
15 Views

You may have to make your large static arrays allocatable.

Also, at one point in time, local arrays declared in PROGRAM did not pay attention to the -heap-arrays (subroutines and functions did). I do not know if this still holds true or not. A quick test (for -heap-arrays)

PROGRAM
CALL wasPROGRAM
END PROGRAM

SUBROUTINE wasPROGRAM
... content of former program
END SUBROUTINE wasPROGRAM

Jim Dempsey

0 Kudos
Highlighted
Beginner
15 Views

Thank you for your response. The code is written in Fortran 77 in so many subroutines and the arrays are shared using COMMON. I am not sure if allocation works for fortran 77. As I mentioned -heap-array did not work for me.  I am looking for a quick remedy for this situation. 

0 Kudos
Highlighted
15 Views

I would first suggest adding -traceback to your build so that when the segfault happens you have an idea of where in the program the problem occurs. There are many, many possible reasons for segfaults and just throwing switches on the compile is not likely to be useful. You don't even know that it's the COMMON that's the problem.

Whether or not something worked in Fortran 77 is not relevant as you are using a Fortran 2008 (almost) compiler. 

I suggest running the program under gdb and seeing exactly where the error occurs. When you know that, if you can't figure out the solution write back here and include as much detail as you can regarding the statement that fails, show the declaration of ALL variables mentioned in that statement, and if it is a call to a subroutine or function, the declaration of that subroutine or function and all its dummy arguments.

0 Kudos