For Programmers: Free Programming Magazines  


Home > Archive > Fortran > January 2006 > Re: physical unit/dimension checking and conversion in scientific









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: physical unit/dimension checking and conversion in scientific
N. Shamsundar

2006-01-22, 3:57 am

Grant W. Petty wrote:
>
>
> The latest update of a free F90 package for runtime computation,
> conversion and consistency checking of physical dimensions and units in
> scientific and engineering program is available here:
>
> http://rain.aos.wisc.edu/%7Egpetty/physunits.html
>
> It's available under the Lesser Gnu Public License (LGPL).
>
> ________________________________________

> Prof. Grant W. Petty
> Atmospheric and Oceanic Sciences
> 1225 W. Dayton Street
> University of Wisconsin-Madison
> Madison, WI 53706
>
> gpetty@aos.wisc.edu
> Tel: (608) 263-3265
> Fax: (608) 262-0166
>
>

A utility such as this may be quite useful in avoiding unit-related
errors, some of which have been spectacular in the recent past.

Despite the Fortran 77 style of coding used in your example, this
solution is beyond the reach of standard Fortran 77 compilers (e.g.,
g77) since the solution is based on using program units and USE statements.

There is one class of physical unit-handling that you have not said much
about : units that differ not only by a factor but also by an offset,
such as temperatures, elevations, etc. For example,

type(preal) Tamb
Tamb=77*u_fahrenheit_degree
write(*,*)' Atm Temp = ',(Tamb-c_ice_point)/u_kelvin,' C'

does not work for obvious reasons, but no error message is produced.

Another common source of error is exemplified by the Rayleigh number:

Ra = g\beta\Delta T L^3/(\alpha\nu)

where

g is acceleration due to gravity
\beta is thermal expansion coefficient, units of reciprocal abs.
temperature.
\Delta T is temperature difference, same in kelvin or celsius.
\alph, \nu are diffusivities, units of L^2/time
L is length

How would you handle this formula in your system?

N. Shamsundar
University of Houston



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com