Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
f2cl
f2cl
Commits
362bfc02
Commit
362bfc02
authored
Dec 18, 2018
by
Raymond Toy
Browse files
Use markdown section markup
Clean up section headings and other text.
parent
91f93078
Changes
1
Show whitespace changes
Inline
Side-by-side
README.md
View file @
362bfc02
Welcome to f2cl - a Fortran to Common Lisp Translator
#
Welcome to f2cl - a Fortran to Common Lisp Translator
Contained in this directory are source code files and some documentation.
Contained in this directory are source code files and some documentation.
The translator is written in Common Lisp making installation simple.
The translator is written in Common Lisp making installation simple.
Installation
#
Installation
------------
If this has been extracted as a part of CLOCC, the way to build f2cl
If this has been extracted as a part of CLOCC, the way to build f2cl
is to simply run "make system" from a shell, as is usual with CLOCC
is to simply run "make system" from a shell, as is usual with CLOCC
...
@@ -47,11 +47,11 @@ manually run everything as follows:
...
@@ -47,11 +47,11 @@ manually run everything as follows:
to load all the compiled files.
to load all the compiled files.
Usage
# Usage
-----
## Converting Fortran Code
Converting Fortran Code
-----------------------
To use f2cl:
To use f2cl:
```
```
(f2cl:f2cl "<path>/fortran.f")
(f2cl:f2cl "<path>/fortran.f")
...
@@ -79,8 +79,7 @@ here is a short list of restrictions that may result in obscure errors:
...
@@ -79,8 +79,7 @@ here is a short list of restrictions that may result in obscure errors:
Note also that an intermediate file called "prep.tmp" is produced by the
Note also that an intermediate file called "prep.tmp" is produced by the
preprocessing stage of the translation.
preprocessing stage of the translation.
Options
### Options
-------
These are the options available to
`f2cl:f2cl`
and
`f2cl:f2cl-compile`
These are the options available to
`f2cl:f2cl`
and
`f2cl:f2cl-compile`
...
@@ -165,8 +164,7 @@ These are the options available to `f2cl:f2cl` and `f2cl:f2cl-compile`
...
@@ -165,8 +164,7 @@ These are the options available to `f2cl:f2cl` and `f2cl:f2cl-compile`
information see below. This mimics the memory layout of how
information see below. This mimics the memory layout of how
Fortran treats common blocks. Default =
`NIL`
.
Fortran treats common blocks. Default =
`NIL`
.
Using Converted Code
# Using Converted Code
--------------------
Once you've converted the code, you do not need to load up all of f2cl
Once you've converted the code, you do not need to load up all of f2cl
to use the converted code. In fact, you only need f2cl0.l and
to use the converted code. In fact, you only need f2cl0.l and
...
@@ -174,64 +172,64 @@ macros.l to define the necessary packages and functions used by the
...
@@ -174,64 +172,64 @@ macros.l to define the necessary packages and functions used by the
converted code. Actually, you really only need the defpackage for
converted code. Actually, you really only need the defpackage for
f2cl-lib in f2cl0.l.
f2cl-lib in f2cl0.l.
Issues
# Issues
------
For a more detailed list of issues and notes, see src/NOTES.
For a more detailed list of issues and notes, see src/NOTES.
We highlight just a few issues here.
We highlight just a few issues here.
*
Block data statements.
## Block data statements.
In Fortran, block data statments are used to initialize common
blocks. Since Fortran executables are loaded and run just once,
In Fortran, block data statments are used to initialize common
this is not a problem. However, in Lisp, this might not be true,
blocks. Since Fortran executables are loaded and run just once,
and you may want to run the main program many times. Thus, it is
this is not a problem. However, in Lisp, this might not be true,
up to you to run the block data initializer at the right time, as
and you may want to run the main program many times. Thus, it is
needed. f2cl cannot know when and where to call the initializer.
up to you to run the block data initializer at the right time, as
needed. f2cl cannot know when and where to call the initializer.
*
Common blocks.
F2cl converts common blocks to structures. However, common blocks
## Common blocks.
may be referenced in several different files, so the user must
F2cl converts common blocks to structures. However, common blocks
tell f2cl when to define the structure. Use the :declare-common
may be referenced in several different files, so the user must
parameter to tell f2cl to define the structure. This should be
tell f2cl when to define the structure. Use the :declare-common
done exactly once for each common block that is defined. This
parameter to tell f2cl to define the structure. This should be
should also be done for the first file that is compiled and
done exactly once for each common block that is defined. This
loaded, so that subsequent files know about the definition.
should also be done for the first file that is compiled and
loaded, so that subsequent files know about the definition.
In addition, there is another option, :common-as-array. This
changes how f2cl handles common blocks. A rather common use of
In addition, there is another option, :common-as-array. This
common blocks has the same common block using different variable
changes how f2cl handles common blocks. A rather common use of
names. For example, one routine might have
common blocks has the same common block using different variable
names. For example, one routine might have
```
```
COMMON /foo/ a(10), b, i(4)
COMMON /foo/ a(10), b, i(4)
```
```
and another might say
and another might say
```
```
COMMON /foo/ b(9), c, d, j(2), k(2)
COMMON /foo/ b(9), c, d, j(2), k(2)
```
```
In Fortran, this is perfectly acceptable. Normally, f2cl expects
In Fortran, this is perfectly acceptable. Normally, f2cl expects
all common blocks to use the same variable names, and then f2cl
all common blocks to use the same variable names, and then f2cl
creates a structure for the common block using the variable names
creates a structure for the common block using the variable names
as the names of the slots. However, for a case like the above,
as the names of the slots. However, for a case like the above,
f2cl gets confused. Hence, :common-as-array. We treat the common
f2cl gets confused. Hence, :common-as-array. We treat the common
block as an array of memory. So this gets converted into a
block as an array of memory. So this gets converted into a
structure somewhat like
structure somewhat like
```
```
(defstruct foo
(defstruct foo
(part-0 (make-array 11 :element-type 'real))
(part-0 (make-array 11 :element-type 'real))
(part-1 (make-array 4 :element-type 'integer4)))
(part-1 (make-array 4 :element-type 'integer4)))
```
```
(In a more general case, we group all contiguous variables of the
(In a more general case, we group all contiguous variables of the
same type into one array. f2cl and Lisp cannot handle the case
same type into one array. f2cl and Lisp cannot handle the case
where a real and integer value are allocated to the same piece of
where a real and integer value are allocated to the same piece of
memory.)
memory.)
Then in the individual routines, symbol-macrolets are used to
Then in the individual routines, symbol-macrolets are used to
create accessors for the various definitions. Hence, for the
create accessors for the various definitions. Hence, for the
second version, we would do something like
second version, we would do something like
```
```
(symbol-macrolet
(symbol-macrolet
(b (make-array 9 :displaced-to
(b (make-array 9 :displaced-to
...
@@ -247,36 +245,36 @@ We highlight just a few issues here.
...
@@ -247,36 +245,36 @@ We highlight just a few issues here.
:displaced-offset 2))
:displaced-offset 2))
...)
...)
```
```
Thus, we access the right parts of the common block, independent
Thus, we access the right parts of the common block, independent
of the name. Note that this has a performance impact since we
of the name. Note that this has a performance impact since we
used displaced arrays.
used displaced arrays.
*
Conversion order.
##
Conversion order.
While not necessary, f2cl can do a significantly better job in
While not necessary, f2cl can do a significantly better job in
generating code if the functions are compiled in the correct
generating code if the functions are compiled in the correct
order. This means any function, F, that is called by another
order. This means any function, F, that is called by another
function, G, should compiled first. In this way, f2cl can
function, G, should compiled first. In this way, f2cl can
determine the calling conventions for F, and generate the
determine the calling conventions for F, and generate the
appropriate call for F in G. This is important if F takes an
appropriate call for F in G. This is important if F takes an
array argument and G passes a slice of an array to F, or
array argument and G passes a slice of an array to F, or
conversely if F takes a simple variable, and G calls F with an
conversely if F takes a simple variable, and G calls F with an
array reference.
array reference.
If this is not done, the user may have to modify either the
If this is not done, the user may have to modify either the
Fortran code or the resulting Lisp code to pass arguments
Fortran code or the resulting Lisp code to pass arguments
correctly.
correctly.
F2cl cannot always determine whether a slice of an array should be
F2cl cannot always determine whether a slice of an array should be
used or just the single element.
used or just the single element.
See also the file src/NOTES which contains a change log. But there
See also the file src/NOTES which contains a change log. But there
are also various notes about about restrictions and enhancements on
are also various notes about about restrictions and enhancements on
various features supported by f2cl.
various features supported by f2cl.
Acknowledgments
:
#
Acknowledgments
The translator was written by Kevin Broughan and Diane Koorey Willcock
The translator was written by Kevin Broughan and Diane Koorey Willcock
at the University of Waikato. Reports should be sent to
at the University of Waikato. Reports should be sent to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment