- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C part **********
typedef long(__stdcall * tDll_Ptr_TEST0) (double **, int, int);
..
int rows=10, columns=10;
double ** matrix;
matrix = new double *[rows];
for(i=0; i
}
...
for( i=0; i
}
}
myTEST0(matrix, rows, columns);
..
Fortran Part (Fotran DLL) *************
SUBROUTINE TEST0(TEMP, ROW, COLUMN )
! Expose subroutine TransportDll to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::TEST0
! Variables
!DEC$ ATTRIBUTES REFERENCE :: TEMP! This argument is passed by REFERENCE
!DEC$ ATTRIBUTES VALUE :: ROW! This argument is passed by VALUE
!DEC$ ATTRIBUTES VALUE :: COLUMN! This argument is passed by VALUE
!
! UFComServerTY.f90 - This module contains user-defined class
! definitions and methods
INTEGER ROW, COLUMN
REAL*8 TEMP(COLUMN, ROW)
!!================================================!!
do i=1, row
do j=1, COLUMN
write(*,*) TEMP(i,j)
enddo
write(*,*)
enddo
WRITE(*,*) ' leaving TESTTTTTTTTTTT0 '
READ(*,*)
RETURN
END SUBROUTINE TEST0
When I execute the C main programme I get garbage.ANY HELPPPPPP ????????
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you didn't fall prey to the complications you introduced in linking, you still must understand that a Fortran 2d array corresponds to a C 1d array. For example, you could make your C code look a lot like Fortran with a macro
#define MATRIX(i,j) matrix((j-1)*10 + i -1)
with matrix being a 1d array of size 100.
Your C++ code defines something which would look on the Fortran side like a 1d array of type c_ptr, each element of which points to the first element of a 1d array of type c_double. I haven't seen any fully working examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, I am using C++ complierbut the point is that if I define matrix as:
typedef long(__stdcall * tDll_Ptr_TEST0) (double (*)[10], int, int);
...
int rows=10, columns=10;
double matrix [rows][colums];
for( i=0; i
}
}
myTEST0(matrix, rows, columns);
the everything goes OK.
I think the problem is the way pointers are passed. No problems with vectors (I have already done it). However, the problem is that I havethe main C++ that declares a dynamic two dimensional martrix and I want pass it to the fotran subroutine (in a fortran Dll) efficiently and easily.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There no longer are good reasons to recommend non-portable syntax for situations which are covered in standards.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page