Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

Passing string from Visual CPP to Visual Fortran

mch7918
Beginner
838 Views
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


0 Kudos
1 Reply
TimP
Honored Contributor III
838 Views
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.
0 Kudos
Reply