- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have C++ code that calls a few Fortran routines. (Legacy software that can not be rewritten into C++.) I am getting the following runtime error:
The value of ESP was not properly saved across a function call. ...
I am assuming that this is coming from one of my Fortran subroutine calls. I get the message when I return from the subroutine. I see nothing wrong with the declarations and definitions. I've gotten other Fortran subroutines to function with no warnings or errors. The code functions correctly when I stepped into it and examined variable values.
The C declaration is:
extern "C"
{
void XFERCONS_C_SCISIM( double J1[],
double C1[],
double C2[],
double L1[],
double M2[],
double U1[],
double U2[] );
}
The C call is:
void TCII_SCISIM_Interface::CALL_XFERCONS(
double J1[],
double C1[],
double C2[],
double L1[],
double M2[],
double U1[],
double U2[] )
{
// note that arguments are addresses of parameters
XFERCONS_C_SCISIM( J1, C1, C2, L1, M2, U1, U2 );
}
The Fortran subroutine is:
SUBROUTINE XFERCONS_C_SCISIM ( J1,
. C1,
. C2,
. L1,
. M2,
. U1,
. U2)
REAL*8 J1(MAX_NUM_CONSTANTS)
REAL*8 C1(MAX_NUM_CONSTANTS)
REAL*8 C2(MAX_NUM_CONSTANTS)
REAL*8 L1(MAX_NUM_CONSTANTS)
REAL*8 M2(MAX_NUM_CONSTANTS)
REAL*8 U1(MAX_NUM_CONSTANTS)
REAL*8 U2(MAX_NUM_CONSTANTS)
INTEGER*4 I
DO I = 1,MAX_NUM_CONSTANTS
J1CON(I) = J1(I)
C1CON(I) = C1(I)
C2CON(I) = C2(I)
L1CON(I) = L1(I)
M2CON(I) = M2(I)
U1CON(I) = U1(I)
U2CON(I) = U2(I)
ENDDO
END
Any help with solving this issue will be greatly appreciated.
Thanks,
George
The value of ESP was not properly saved across a function call. ...
I am assuming that this is coming from one of my Fortran subroutine calls. I get the message when I return from the subroutine. I see nothing wrong with the declarations and definitions. I've gotten other Fortran subroutines to function with no warnings or errors. The code functions correctly when I stepped into it and examined variable values.
The C declaration is:
extern "C"
{
void XFERCONS_C_SCISIM( double J1[],
double C1[],
double C2[],
double L1[],
double M2[],
double U1[],
double U2[] );
}
The C call is:
void TCII_SCISIM_Interface::CALL_XFERCONS(
double J1[],
double C1[],
double C2[],
double L1[],
double M2[],
double U1[],
double U2[] )
{
// note that arguments are addresses of parameters
XFERCONS_C_SCISIM( J1, C1, C2, L1, M2, U1, U2 );
}
The Fortran subroutine is:
SUBROUTINE XFERCONS_C_SCISIM ( J1,
. C1,
. C2,
. L1,
. M2,
. U1,
. U2)
REAL*8 J1(MAX_NUM_CONSTANTS)
REAL*8 C1(MAX_NUM_CONSTANTS)
REAL*8 C2(MAX_NUM_CONSTANTS)
REAL*8 L1(MAX_NUM_CONSTANTS)
REAL*8 M2(MAX_NUM_CONSTANTS)
REAL*8 U1(MAX_NUM_CONSTANTS)
REAL*8 U2(MAX_NUM_CONSTANTS)
INTEGER*4 I
DO I = 1,MAX_NUM_CONSTANTS
J1CON(I) = J1(I)
C1CON(I) = C1(I)
C2CON(I) = C2(I)
L1CON(I) = L1(I)
M2CON(I) = M2(I)
U1CON(I) = U1(I)
U2CON(I) = U2(I)
ENDDO
END
Any help with solving this issue will be greatly appreciated.
Thanks,
George
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Add __stdcall after the "C" in your C (actually C++) declaration.
Steve
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page