I have a bunch of fortran code that I am adapting with some c++ code. The problem area essentially boils down to this:
The C++ function that calls the fortran function:
extern "C"
{
void CALX(float* w, int* nw, double* dw, int* idmx, int* lo);
}
void calcPort(float* w, int* nw, double* dw, int *idmx)
{
int lo[250]; //>100 used for internal stuff
//stuff
CALX(w, nw, dw, idmx, lo);
for(int i=0; i<100; ++i)
{
cout<<lo[i]<<", ";
if(i%50 == 49)
{
cout<<endl;
}
}
//more stuff
}
The important parts of the fortran function:
SUBROUTINE CALX(W,NW,DW,LO) bind(C, name="CALX") CALX-001
use iso_c_binding
C Lots o' comments
LOGICAL LO(250) CALX-160
DOUBLE PRECISION DW(1) CALX-161
C Bunch o' common blocks
1 READ (5,1000) TITLE CALX-175
C some miscellaneous stuff dealing with a couple special title strings
DO 4 I=1,100 CALX-184
4 LO(I)=.FALSE. CALX-185
READ (5,1001) (LO(I),I=1,50) CALX-186
WRITE (6,*) SIZEOF(LO(1))
WRITE (6,1001) (LO(I),I=1,50)
C IF LO(36)=.TRUE. RETURN TO RESTART A SEARCH SAVED ON TAPE 8 CALX-187
IF (LO(36)) RETURN CALX-188
READ (5,1001) (LO(I),I=51,100) CALX-189
WRITE (6,1001) (LO(I),I=51,100)
C More stuff
To my eye this should work. After the function is called the c++ code should read 0 or non zero in the same pattern that the fortran does. Instead what I get is this:
This bit from the fortran write statements (which matches the input I redirect into it):
FFFFFFTTFFTTFFFTFFFFFFFFFFFTFFTTFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFTTTFTTTFFFFFFFFFFFFFFFFFTTFFFFFFFF
This bit from my loop.
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Clearly there is some failure to communicate. Why? How do I fix it?
WandNWon the Fortran side.?Is aLOGICALreally represented the same way as anint?