common blocks, FORTRAN,and DLLs

1.2k Views Asked by At

I am a modeler who programs...I would never call myself a programmer, yet I program in C# and in FORTRAN. I have a FORTRAN model that I have connected to some C# code through a dll. I have found that I must have a common block in order to keep the variables in memory in the dll. I have also found that I cannot use more than one include statement.... my include file for the common variables are all Unlabeled. Chapman (2008) "FORTRAN 95/2003 for scientists and Engineers" states "The unlabeled COMMON statement should never be used ...".

How can I ensure that I do not have corrupted memory in my common file? I guess I can experiment, but I was hoping to have some sound advice on this. I am using the Lahey-F ver 7.2 within Microsoft Visual Studio 2008

Anyone, any thoughts?

1

There are 1 best solutions below

2
On

As a programmer who models what I'd like to know is exactly why Chapman states that the unlabelled COMMON should not be used. From what I can remember the blank / unnamed common block is global and must be defined in the main program.

The only way to be sure about this is probably to make a simple Fortan DLL and then disassemble it to see what it's done with / where it put the common block.

Also it'd be useful if you could paste examples of errors etc. when you try to use a named common. It may be that there is a better solution once we understand exactly what's not working.