I need to integrate a few C subroutines within a f77 program. I've tested on many occasions passing 2D arrays back and forth between C and f77 before, so that's ok. However, in this instance, there's a lot more data to be handled by the C code (data that the f77 code doesn't really need to 'see') and the data really lends itself well to using C structs (would make my life easier if I could store and manipulate the data in C struct arrays, instead of using f77 common blocks and/or arrays). However, the only way I've managed to use the benefits of C here (structs, malloc, pointers, etc.), is to declare a static struct within a C subroutine. That works as long as the same C subroutine is called by f77 main program. If I want the subroutine to do something different within the f77 main program, all I've managed to do is send an integer 'flag' as an argument: depending on the value of the flag, the subroutine will do different stuff. My question is the following: is there anyway to have the struct become 'global' once it's declared in the first C subroutine encountered? That would give me the opportunity to use several different C subroutines within the f77 main program and still use the same C structs ... (I'm testing this out under gcc by the way).
If required, I can type out a C file and f77 main program for you to test ...
If required, I can type out a C file and f77 main program for you to test ...