- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can some one tell me how to pass a char array from visual c++ code to a fortran subroutine.
I tried below code, it doesn't work for me..
My CPP code:
extern "C" {void Routine1(char* param1, char* param2);}
Method:
char param1[]="c:/text1.txt";
char param2[]="c:/text2.txt" ;
Routine1(param1,param2);
Fortran Code:
SUBROUTINE Routine1(param1, param2)
!DEC$ ATTRIBUTES DLLEXPORT::Routine1
CHARACTER(100) :: Routine1,Routine2
!Some logic
END
Can some one tell me how to pass a char array from visual c++ code to a fortran subroutine.
I tried below code, it doesn't work for me..
My CPP code:
extern "C" {void Routine1(char* param1, char* param2);}
Method:
char param1[]="c:/text1.txt";
char param2[]="c:/text2.txt" ;
Routine1(param1,param2);
Fortran Code:
SUBROUTINE Routine1(param1, param2)
!DEC$ ATTRIBUTES DLLEXPORT::Routine1
CHARACTER(100) :: Routine1,Routine2
!Some logic
END
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately, you have several options, with more or less system dependence involved. The compiler docs should be your friend. If you don't want to deal with additional hidden length arguments, you can USE iso_c_binding and follow any of the documents about character string/arrays with ISO C interop, even those not specific to Intel Fortran. In this case, the terminating \0 from the C side will appear as a character element ACHAR(0) on the Fortran side.

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