(j3.2006) Units of measurement in Fortran

Rasmussen, Craig E rasmussn
Fri Apr 22 16:01:38 UTC 2011


On Apr 21, 2011, at 3:19 PM, Van Snyder wrote:


On Thu, 2011-04-21 at 08:15 -0700, Rasmussen, Craig E wrote:
I'm hoping to get a proposal funded that will allow users to add units
to Fortran via compiler directives like OpenMP.  We now have the
compiler infrastructure in place with our Open Fortran Parser (OFP)
and ROSE to build a tools that would ensure that units are maintained
in the program.

If you plan to use a Fortran parser, add real syntax instead of
directives.  I recommend using what I propose in Units-TR-7.  You could
even preprocess to provide the conversion units, including during I/O.

Using your proposed syntax is a good idea but it will still have to be hidden behind a !$ so that it can be compiled with a normal compiler.


I don't really see a need to add units to the language (Van may
disagree) because units can be checked with static analysis tools and
have not effect on runtime behavior of a program.

So I/O is not a runtime behavior?  Units conversion is not a runtime
behavior?

Can you explain how you propose to annotate a file so that units can be checked during I/O?  I didn't realize you wanted to standardize this as well.

Are you coming to Garching?  If you are interested, perhaps you could work with me on this.  I have a little bit of funding for the next year and I could use it to start this tool.  I also found out that at least the preliminary work has been done so we could try it out on some of your codes and see what we get.


We don't really need strong typing, either, since it can be checked by
static analysis tools.  Or explicit interfaces.  Or....  Should the
processor actually care that you have the correct number of subscripts?
That could be checked by static analysis tools.

Proprocessors can provide control structures.

Derived types can be faked.

Let's just go back to Fortran 77 + Ratfor.

To me, compiler directives is the correct approach.

I have nothing against compiler directives, but pretending they solve
the whole problem doesn't actually make the problem go away.


I think there is a trade off between static analysis tools and what goes into a language.  If a small minority of Fortran users will use a feature it shouldn't go into the language, just handle it with tools.

I personally like units and think it is appropriate for Fortran.  However, it is not in Fortran at the moment and a static analysis tool can easily do the task as it has exactly the same source information a compiler will have.

-craig







More information about the J3 mailing list