Skip to content

Instantly share code, notes, and snippets.

@baptistelabat
Last active June 16, 2016 13:44
Show Gist options
  • Save baptistelabat/ab8c5cb37b5303b55c7239df5c1ee81b to your computer and use it in GitHub Desktop.
Save baptistelabat/ab8c5cb37b5303b55c7239df5c1ee81b to your computer and use it in GitHub Desktop.
Basic example of how to call c++ code from fortran
gcc -c test.cpp -o test.o
gfortran main.f90 test.o
a
program toto
integer::a,b,c
!external ADD
a=10
b=15
call ADD(a,b,c)
print*, a,b,c
end program
extern "C"
{
extern void add_(int* a, int* b, int* c);
}
void add_(int* a, int* b, int* c)
{
*c=*a+*b+0;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment