I'm working on some legacy software and we have a DLL with one external function: doSomeMath( Data ). Where Data is really multiple arguments with several different large derived types. Internally in doSomeMath the Data is manipulated, memory is allocated and intialization routines are called and there is finally a function computeValues( manipluatedData ). doSomeMath is called several times from a C++ program and each time Data is remanipulated in a non-unique way. What would be the best way to make a function initializeData( Data ) so that I can call computeValues( ) from the C++? I'd laso think this would be more flexible because I can call computeDifferentValues( ) without any re-initialization.
I can think of returning manipulatedData to the C++ and passing it each time or possibly storing manipulatedData as global variables. If I use the globals approach I'd declare manipulated data with the COMMON attribute, right? The first way seems inefficient, the second way seems unsafe. I'm still new to Fortran and programming in general so any advice is greatly appreciated. Thanks.