I have some legacy Fortran 77 code that uses a lot of global data (COMMON blocks, etc.) and which I need to package into a Windows DLL for use in various environments including Microsoft Excel, webservices, etc. That is, different types of programs will be calling the exported subroutines in this DLL for various calculations. The subroutines are currently structured such that the arguments are limited to only those variables that makes sense for callers to modify and to those calculation results that callers actually need. Also, significant amount of data are held in COMMON blocks that get the appropriate values when an initialization subroutine is invoked. These data are then reused repeatedly during the actual calculations.
I need to ensure the DLL is multi-threaded as well as thread-safe. How do I go about creating and fully validating such a DLL? What are the basic elements? Will I need to restructure the code so that calculations do not depend on any global data? What is the best approach to learn about threading and thread-safety? I couldn't find much in Intel Fortran 2013 Help. I see Intel advertises its Math Kernel Library as multi-threaded and thread-safe; so is IMSL. I'd like my library to be in the same state.
I'm currently using Compaq Visual Fortran 6.6C with Microsoft Visual Studio 6.0 but I plan to switch to Intel Fortran Composer 2013 with Visual Studio 2010. Using Compaq Fortran and Visual Studio 6.0, I've created a "single-threaded DLL" that works well with a single-threaded executable such as a Fortran or C main program. But as expected, the DLL fails when used in a multi-threaded environment such as a C# executable (a .NET application calling the DLL via PInvoke) that deliberately spawns different threads. Next I'll try using Intel Fortran Composer 2013 with Visual Studio 2010, but it will be good to be knowledgeable about this instead of going in blindly.