my main fortran code, main.f90:
program main
implicit none
write(*,*) "abcdefghijklmnopqrstuvwxyz"
call cprint(" Hello world!")
call cprint(" Hello hell!")
end program main
“cprint” is a c subroutine here, foo.c
#include <stdio.h>
void cprint_(char* string){
printf("%s", string);
}
The result output is
abcdefghijklmnopqrstuvwxyz
Hello world!abcdefghijklmnopqrstuvwxyz Hello hell! Hello world!abcdefghijklmnopqrstuvwxyz
I use the debug tool “pgdbg” to check the variable passing, I found that
the fortran trans “Hello world!abcdefghijklmnopqrstuvwxyz” to string in cprint.
I can’t understand this. How to solve it.
Thank you.
btw: my compile command is
gcc -g -c foo.c
pgf90 -g -c main.f90
pgf90 -g -o bar.out main.o foo.o
My pgf90 version is 5.2-1, gcc version is 3.4.3