-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.txt
89 lines (63 loc) · 2.53 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Forpedo (v0.1) -- a Fortran preprocessor for generics
-----------------------------------------------------
Author: Drew McCormack
Created: 26 Nov 2004
Last Modified: 26 Nov 2004
'Forpedo' is a preprocessor for Fortran 90 code, written in python.
(The name is inspired by the flipper feet himself.) It can handle
some typical preprocessing tasks, like including code from one file in
another, but it is mostly designed to provide C++ like generics (templates).
The output of Forpedo is pure Fortran code, which should work with any
standard compiler.
To use Forpedo, you will need access to a recent version of Python (2.3 or later).
Python is commonly available these days, on almost all platforms (see http://www.python.org)
Forpedo is very new software, and may contain bugs. Please report them
to [email protected]. The Forpedo web site is http://www.maniacalextent.com/forpedo
New functionality should be added to Forpedo in good time. Suggestions and offers
of support are always welcome.
Using forpedo
-------------
To run forpedo, simply pipe your source code into forpedo.py. Generated code will
be written to standard output.
Eg.
forpedo.py < myFile.f90t > myFile.f90
f90 myFile.f90
Directives Reference
--------------------
import
------
Include the source of one file in another (like C's include directive).
Example:
#import "OtherFile.fh"
definetype
----------
Used to define generic types, and type definitions (like C's typedef's).
Example of simple type definition:
#definetype RealParamType none real(8), parameter
Example of using this defined type:
@RealParamType :: r = 10
print *, r
Example of generic type definition:
#definetype T Int integer
#definetype T Real real
Example of using this generic type:
@T var<T>
var<T> = 10
print *, var<T>
A definetype directive has a type name, a tag, and a concrete fortran type.
The typename should be used, after an @ symbol, anywhere in the code that
the type is required.
The tag can be accessed in the code by putting the
type name between triangular parentheses (ie <typename>). The tag is often
required to avoid name clashes, particularly for variables with global scope.
So, for example, you would generally need to use the tag for a module name,
otherwise multiple modules may get the same name.
Eg.
module MyModule<T>
this will be replaced with
module MyModuleInt
and
module MyModuleReal
When you are using definetype for a type definition, rather than generic
types, the tag is not really needed, and you can simply set it to some
string like 'none'.