Currently I am working on a project that requires integrating fortran code to c++. In fortran module lots of variables and arrays are declared. I am able to access the integer,float and double types from c by declaring a c variable as extern double common_area_mp_rmax_ when the corresponding fortran declaration is real*8 rmax and the name of the module is common_area. However, when I try to do the same for an array I am getting error.
suppose the code in fortran module is: real*8,allocatable,dimension(:,:,:) :: x
I have cretaed a c double pointer as:
extern "C"
{
double* common_area_mp_x_;
}
Now when I compile the whole project, it says "multiple definition of `variable_area_mp_x_'". I am using CMake to compile the whole project. Can someone shed some light what I am doing wrong? I am new to fortran and it is getting hard for me to fix this. I appreciate your time and help.
Thanks, mindbender
double * common_area_mp_x_from header files if necessary, and then declareextern double * common_area_mp_x_in the C++ file where you reference that variable.