- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have reada few related posts and have not found the answer I need.
I am using VS2005 and IVF10. I found an example in directory C:Program FilesIntelCompilerFortran10.0.025samplesMixedLanguageFortran_Calls_C. This example passes integers and strings from Fortran to C. I need to pass real arrays. I tried to modify this example without success. The numbers inside the C++ routine where incorrect.
In the spirit of theexample above, I provide my own test case. The C++ code is:
#include
"stdafx.h"#include
using
namespace std;extern
"C" void argtest_cpp(int ndata, float *mydata){cout <<
"ndata = " << ndata << endl; for (int i = 0; i < ndata; i++)cout << i <<
" " << *(mydata+i) << endl;}
The Fortran code is:
PROGRAM
argtestIMPLICIT NONE
INTERFACE
SUBROUTINE argtest_cpp (ndata, mydata) !DEC$ ATTRIBUTES C :: argtest_cpp !DEC$ ATTRIBUTES REFERENCE :: mydata INTEGER, INTENT(IN) :: ndata REAL, INTENT(IN) :: mydata(:) END SUBROUTINE argtest_cppEND INTERFACE
REAL
mydata(10)INTEGER
i, ndatandata = 10
DO
i = 1, ndatamydata(i) =
log10(float(i+1)) print *, i, mydata(i)ENDDO
CALL
argtest_cpp(ndata, mydata)STOP
END
When I run this code I see that thereal numbers inside the C++ routine are incorrect, but the integer passes properly. I appreciate any help.&n bsp;
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
REAL, INTENT(IN) :: mydata(*)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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