There are 2 methods
Environment Variable
Before running the program, set the
decfort_dump_flag environment variable to any of the common TRUE values (Y, y, yes, yEs, TRUE and so forth) to cause severe errors to create a “core” file.
Doing it in Code
When the Intel compiler generates an executable, it seems to attach a bunch of signal handlers to things like segfaults. For instance, try this program...
integer a(1024)
i = 0
write(*,*) "val = ", a(i + 100000000)
end
This can cause a problem when you
want to ge a core dump. Well, you can basically hack around and
force this to happen by setting up new signal handlers yourself to override the override from the Intel tools. Here's some C code that catches a segfault, prints the pid, then forces a coredump. Simply do a
call setup_signals from fortran, link to the C code and away you go. There is one subtlety...using
kill (getpid(), SIGSYS) will not work even though it is supposed to be an exact equivalent to
raise() !
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
void core_dump (int signal)
{ printf("process %d died!\n", getpid());
raise(SIGSYS);
exit (1);
}
void setup_signals_(void)
{ signal (SIGSEGV, core_dump);
signal (SIGSYS, 0);
}
#ifdef TEST
int main(void)
{ int array[10];
int* a;
setup_signals_();
a = 0;
printf("value is %d\n", *a);
}
#endif
-- Main.MattWalsh - 17 Oct 2004