Hi,
Here is a really strange behavior of function call
on a sun4m sparc
I must precise that this problem does not appear
on our i386 PC or Alpha (running linux too)
I have a main programme written in C
It calls a Fortran function
The programme must simply calculate the exponantial of a complex
value.
The strange behavior is in the argument "pass"
The call is :
b = f77exp_(&a)
In the Fortran function I have :
complex*16 function F77EXP(ARGUMENT)
where ARGUMENT should be the address of 'a'
unfortunately, ARGUMENT got 'b' address and return 'a' address !!
STRANGE !
here is the code, an the compilation lign :
/* appelc.c */
#include <stdio.h>
#include <stdlib.h>
typedef double real8;
typedef struct complexe16
{
real8 partie_reelle;
real8 partie_imaginaire;
} struct_complexe16;
typedef struct_complexe16 complex16;
complex16 f77exp_(complex16 *argument);
int
main()
{
complex16 a;
complex16 b;
a.partie_reelle = 1;
a.partie_imaginaire = 1;
a = f77exp_(&b);
printf("%d %d\n", b.partie_reelle, b.partie_imaginaire);
return(0);
}
/* exp.f */
complex*16 function F77EXP(ARGUMENT)
implicit none
complex*16 ARGUMENT
write(*,*) ARGUMENT
F77EXP = exp(ARGUMENT)
return
end function
/* compilation ligns */
g77 -g -c appelc.c
g77 -g -c exp.f
g77 -g -o crashtest exp.o appelc.o
If someone can explain this to me....
--
Baudin Maxime - Laboratoire électronique et communication - CNAM, Paris
Le paradis c'est rempli de gens qui pendant l'éternité entière, vont se
raconter des souvenirs de leurs vies. L'enfer c'est pareil...
sauf qu'en plus chacun apporte ses diapos.