S
Santosh
Hello all,
I am trying to interface c++ and fortran, the fortran code is already
there and I was successful
in calling the subroutines and functions, but was not able to send the
fortran module data into my C++ code and viceversa. I used gcc 3.3 and
g95 for c++ and fortran resp. Here is a little made up sample code so
that u could understand my problem.
$cat fort.f90
MODULE foo
real*8 a, b, c
INTEGER d
END MODULE foo
subroutine just ()
use foo
......
! some code which manipulates with the variables in the module just
! Now after manipulation i want them to be sent to my c++ code
......
end subroutine
$cat main.cpp
#include <iostream.h>
#include <math.h>
extern "C" { int just_ ( );}
// is there any structure for the module as well so that i could
//use its variables in c++
int main()
{
just_( );
// I actually wanted to access variables a,b of the module manipulate
them
// and pass it to the fortran like below
// can i do something like just_(&a,&b)
// do some manipulation in fortran and access the latest data in c++
return 0;
}
It wud be great if anyone could explain me how to do this,
Thanx in advance
Regards
Santosh
I am trying to interface c++ and fortran, the fortran code is already
there and I was successful
in calling the subroutines and functions, but was not able to send the
fortran module data into my C++ code and viceversa. I used gcc 3.3 and
g95 for c++ and fortran resp. Here is a little made up sample code so
that u could understand my problem.
$cat fort.f90
MODULE foo
real*8 a, b, c
INTEGER d
END MODULE foo
subroutine just ()
use foo
......
! some code which manipulates with the variables in the module just
! Now after manipulation i want them to be sent to my c++ code
......
end subroutine
$cat main.cpp
#include <iostream.h>
#include <math.h>
extern "C" { int just_ ( );}
// is there any structure for the module as well so that i could
//use its variables in c++
int main()
{
just_( );
// I actually wanted to access variables a,b of the module manipulate
them
// and pass it to the fortran like below
// can i do something like just_(&a,&b)
// do some manipulation in fortran and access the latest data in c++
return 0;
}
It wud be great if anyone could explain me how to do this,
Thanx in advance
Regards
Santosh