Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29391 Discussions

severe (174) using fscanf in a .c file

jpprieto
Beginner
848 Views
Hi, I continue with both my work and my problems.
The situation: I'm running two codes in diferent lenguages, one is in f90 and the otherone in c. To do the fusion between these programs I creat all .o to link it. The .f90 program calls a function in the .c program. The link is Ok.
The problem: When I open a file from .c program the aplication is stopped with the following message:
forrtl: severe (174): SIGSEGV, segmentation fault occurred
This is the line of the error:

double IR13RM(double AEXP)
{
FILE *archsigmaLi;
double dfrec,dA,A,frecLi1,sigmaLi1,frecLi2,sigmaLi2;

archsigmaLi=fopen("sigmaLi.dat","r");
A=0.0;
fscanf(archsigmaLi,"%lf %lf\n",&frecLi1,&sigmaLi1);

At the moment of scanf the program is stopped.
Some idea about what is wrong here?
An interesting thing is that when I run the .c program alone, the file is read in a good way and all is Ok.
Thank you.
0 Kudos
3 Replies
TimP
Honored Contributor III
848 Views
Quoting - jpprieto
Hi, I continue with both my work and my problems.
The situation: I'm running two codes in diferent lenguages, one is in f90 and the otherone in c. To do the fusion between these programs I creat all .o to link it. The .f90 program calls a function in the .c program. The link is Ok.
The problem: When I open a file from .c program the aplication is stopped with the following message:
forrtl: severe (174): SIGSEGV, segmentation fault occurred
This is the line of the error:

double IR13RM(double AEXP)
{
FILE *archsigmaLi;
double dfrec,dA,A,frecLi1,sigmaLi1,frecLi2,sigmaLi2;

archsigmaLi=fopen("sigmaLi.dat","r");
A=0.0;
fscanf(archsigmaLi,"%lf %lfn",&frecLi1,&sigmaLi1);

At the moment of scanf the program is stopped.
Some idea about what is wrong here?
An interesting thing is that when I run the .c program alone, the file is read in a good way and all is Ok.
Thank you.
It's tricky, if at all possible, to do file I/O in both C and Fortran in the same program. If that file were open in Fortran, that would explain the problem.
0 Kudos
jpprieto
Beginner
848 Views
Quoting - tim18
Quoting - jpprieto
Hi, I continue with both my work and my problems.
The situation: I'm running two codes in diferent lenguages, one is in f90 and the otherone in c. To do the fusion between these programs I creat all .o to link it. The .f90 program calls a function in the .c program. The link is Ok.
The problem: When I open a file from .c program the aplication is stopped with the following message:
forrtl: severe (174): SIGSEGV, segmentation fault occurred
This is the line of the error:

double IR13RM(double AEXP)
{
FILE *archsigmaLi;
double dfrec,dA,A,frecLi1,sigmaLi1,frecLi2,sigmaLi2;

archsigmaLi=fopen("sigmaLi.dat","r");
A=0.0;
fscanf(archsigmaLi,"%lf %lfn",&frecLi1,&sigmaLi1);

At the moment of scanf the program is stopped.
Some idea about what is wrong here?
An interesting thing is that when I run the .c program alone, the file is read in a good way and all is Ok.
Thank you.
It's tricky, if at all possible, to do file I/O in both C and Fortran in the same program. If that file were open in Fortran, that would explain the problem.
I agree with you but I'm sure that this isn't the problem.
I changed the file name and the result is the same: severe (174).
This mean that there is an error in the file direction *archsigmaLi, I don't know why but the sistem can not get this direction.
I changed the variable type to float and int, but the problem doesn't disappear.
Thank you.
0 Kudos
jpprieto
Beginner
848 Views
Thank you, the file didn't be at the directory were I was.
0 Kudos
Reply