Download CamFort
- Binaries
- Build from source:
Download the source from GitHub.
Compilation requires ghc (6.3 or above). Then compile to binary via:
runhaskell Setup.hs configure
runhaskell Setup.hs build
ghc --make Main.hs -o camfort -package mtl
CamFort is in development and we would value any feedback! Please e-mail
dominic.orchard AT cl.cam.ac.uk if you have any problems.
Quick guide to using units-of-measure feature of CamFort
More details of this tool can be found in the ICCS'15 publication. We give a quick guide to getting started here.
Consider the following Fortran source file:
example.f90
program example
implicit none
real :: x
real :: t
real :: v
x = 50
t = 1.3
v = x / t
end program
CamFort can report the set of critical variables, that is, a minimal set
of variables which, if given a unit, would provide the most amount of information to
the type checker. This can be done as follows:
$ camfort criticalUnits
For example, if we are in the current directory of example.f90 we can just do:
$ camfort criticalUnits .
CamFort 0.615 - Cambridge Fortran Infrastructure.
Infering critical variables for units inference in directory "."
./iccs.f90
./iccs.f90: Critical variables: t,x
CamFort tells us that t and x are critical variables, so we annotate
those with unit information (m (metres) for x and s (seconds) for t here):
example.f90
program example
implicit none
real, unit(m) :: x
real, unit(s) :: t
real :: v
x = 50
t = 1.3
v = x / t
end program
We can now ask CamFort to infer the rest of the units, which outputs to a file:
$ camfort units
For example, if we are in the current directory of example.f90 and we want to output
to a new directory 'out' then we can do:
$ mkdir out
$ camfort units . out
CamFort 0.615 - Cambridge Fortran Infrastructure.
Inferring units for "."
./iccs.f90
./iccs.f90: Added 1 non-unitless annotation: m / s
./iccs.f90: checked/inferred 3 user variables
Writing refactored files to directory: out/
Writing out/iccs.f90
We see that CamFort has added one annotation:
out/example.f90
program example
implicit none
real, unit(m) :: x
real, unit(s) :: t
real, unit(m / s) :: v
x = 50
t = 1.3
v = x / t
end program
So now we have units for all variables. But when we want to compile using our usual compiler tool chain we need to erase these annotations. CamFort can do this as part of your build process:
$ camfort removeUnits
For example:
$ mkdir src
$ camfort removeUnits out src
Which now give us:
src/example.f90
program example
implicit none
real :: x
real :: t
real :: v
x = 50
t = 1.3
v = x / t
end program
We are currently in the process of allowing unit attributes to be given only as comments,
which simplifies the integration of CamFort with your existing tool chain (no need to
run the 'remove' step).
CamFort is in development and we would value any feedback! Please e-mail
dominic.orchard AT cl.cam.ac.uk if you have any problems.
More details of our project can be found here.
Last modified: Tue Jun 2 13:28:15 GMT 2015