- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to pass the program arguments from a C program to a Fortran DLL. On the C side I have:
Code:extern void __stdcall aSimplexDriver_FTN(int argc, char *argv[]); main(int argc, char *argv[]) { ASIMPLEXDRIVER_FTN(&argc, argv[0]); }
and on the Fortran side:
subroutine aSimplexDriver_FTN(argc, argv) !DEC$ ATTRIBUTES DLLEXPORT::aSimplexDriver_FTN implicit none integer argc character*(*) argv(0:1) ... return end subroutine aSimplexDriver_FTN
I know that the character array passing syntax is incorrect: I know I need the char lengths in the calls somewhere. How do I correctly pass the char*[] array to Fortran?
Adrian
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's no good solution for direct passing of char* argv[]. A semi-correct (VF-specific) Fortran translation of it would be:
An IMO better solution would be to "unwind" argv into several separate arguments in C and pass those to Fortran.
Finally, in the special case of argc/argv, I think you don't have to pass them at all you should be able to retrieve them using NARGS and GETARG routines (but you should verify whether they work in a dll).
Jugoslav
TYPE CharArgSince you don't know the length (marked ?) in advance, you could use a "maximal" length and only access the string up to the first trailing .
CHARACTER(LEN=?), POINTER:: pChar
END TYPE CharArg
SUBROUTINE aSimplexDriver_FTN(argc, argv)
TYPE(CharArg):: argv(argc)
An IMO better solution would be to "unwind" argv into several separate arguments in C and pass those to Fortran.
Finally, in the special case of argc/argv, I think you don't have to pass them at all you should be able to retrieve them using NARGS and GETARG routines (but you should verify whether they work in a dll).
Jugoslav
Message Edited by JugoslavDujic on 01-09-2006 02:59 PM

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