I've a problem with obtaining the tracebackqq information.
I have a (simplified) routine:
subroutine my_trace() use IFCORE implicit none call tracebackqq(user_exit_code=-1) end subroutine
When placing a call to my_trace in my Fortran routine it gives the following stack trace:
Program received signal SIGSEGV, Segmentation fault. 0x0000000000000000 in ?? () Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.192.el6.x86_64 libgcc-4.4.7-17.el6.x86_64 libstdc++-4.4.7-17.el6.x86_64 (gdb) #0 0x0000000000000000 in ?? () #1 0x00002aaaac1fe157 in tbk_stack_trace () from /share/astenv/devtools/compilers/x86_64-unknown-linux_r5i12/intel/composer_xe_2011_sp1.13.367/compiler/lib/intel64/libifcoremt.so.5 #2 0x00002aaaac16e53c in tracebackqq_ () from /share/astenv/devtools/compilers/x86_64-unknown-linux_r5i12/intel/composer_xe_2011_sp1.13.367/compiler/lib/intel64/libifcoremt.so.5 #3 0x0000000005820c26 in my_trace () at traceback.F90:5 #4 0x0000000000781464 in cmain (in_cpu=@0x1, in_iam=@0x0, in_job=@0xffffffff00000000, in_rst=@0x0, in_sol=@0x1ffffffff, in_vb=@0xffffffff00000001, c_bld=..., c_bldid=..., c_dat=..., .tmp.C_BLD.len_V$d80=9, .tmp.C_BLDID.len_V$d82=5, .tmp.C_DAT.len_V$d84=11) at cmain.f:233 #5 0x000000000046d4c2 in main (argc=7, argv=0x7fffffff9448) at cfd_main.cpp:374 It is a MPI program running (for simplicity) with 1 process and it has a C main program.
I can reproduce the error. The error is caused by missing initialization of the fortran runtime environment required by calling fortran runtime subroutine. Normally the initialization will be done by a fortran main program. If the main program is a C code the runtime initialization subroutine "for_rtl_init_" should be called from the C main program.
An example has been given in the compiler reference:
Consider the following C code:
int argc; char **argv; void for_rtl_init_ (int *, char **); for_rtl_init_ (&argc, argv);
Adding such a call in the C main program the error will be resolved. Similarly using call "for_rtl_finish_" to lean up the Fortran run-time environment once all fortran codes finish running.
Intel Customer Support
Thanks for the answer. I tried it with and when calling the my_trace from a Fortran routine it worked without problems.
We now looked only for Linux but how will it look like on Windows. I assume that in that case we need not to call in the main program for_rtl_init_ but FOR_RTL_INIT.
Currently I'm facing some problems with a routine called deep down in my (cpp / C stack) that is calling the traceback routine, but I have to investigate this a bit further.
I was thinking it because normally when calling a Fortran routine from C on Linux one has to use the underscore at the end and the name in lowercase and on Windows the name has to be in capitals without trailing underscore (at least when combining Intel Fortran with Microsoft C).
That would be true if it were a Fortran routine you compiled yourself, but that's not the case here. Just declare it in C/C++ exactly as it is described in the documentation.