Reputation: 554
I'm very new to Fortran. Currently I'm writing (or trying to write) a fortran application which calls a C-library.
I've got a few things working so far but I'm stuck with the init-function from the library which expects argc and argv just to get the program name which is calling the function.
The C-library expects pointers to argc and argv:
void init(gint argc, gchar ***argv);
I have no idea how to express that ***argv in fortran. The other functions only need integers so I had no trouble using this skeleton for them:
interface
subroutine init( argc, argv)
??
end subroutine ee_init
end interface
call init( , )
Upvotes: 2
Views: 998
Reputation: 60008
I would suggest using module ISO_C_BINDING and pass a pointer to an array of pointers, if i understand it correctly.
Upvotes: 4
Reputation: 3102
You will probably need to write your own wrapper function in C, init_fortran, or similar which you call from Fortran and takes arguments in a way you can express in Fortran, then converts them to what the C init function expects.
Upvotes: 5