File: readme_f95.txt

package info (click to toggle)
plplot 5.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 84,772 kB
  • sloc: ansic: 86,290; xml: 26,754; ada: 17,685; cpp: 15,530; php: 11,938; tcl: 11,125; ml: 6,825; perl: 6,736; f90: 6,709; python: 6,237; java: 6,215; sh: 2,042; makefile: 192; lisp: 75; fortran: 64; sed: 52
file content (192 lines) | stat: -rw-r--r-- 6,505 bytes parent folder | download
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
Fortran 95 bindings for PLplot
------------------------------

dd. 25 november 2005

Introduction
------------
The Fortran 95 bindings for PLplot have been set up with the following
considerations in mind:
- reuse the bindings for FORTRAN 77 if possible
- provide alternative calls for the various routines to take advantage
  of the features of Fortran 95, most notably, to simplify the interface
- provide a module that takes care of all the details

Fortran 90 versus Fortran 95
----------------------------
Because the Fortran 95 standard is supported by most if not all current
Fortran compilers, it seemed logical to target this standard, rather
than Fortran 90. The differences are small enough though not to matter
too much for PLplot.

To stress that Fortran 95 is the target, we use .f95 as the extension
for the examples. Note that the extension is not important for
most compilers: it merely indicates that the freeform source format is
used.

PLplot module
-------------
The PLplot module defines:
- Several parameters for use with the PLplot library
- Interfaces for all the routines that can be used with Fortran 95
  programs
- Several alternative interfaces for various routines

The parameters are:
- PLFLT or PLF for short
  This is the KIND parameter for all floating-point variables and values
  used by the PLplot library. See the example below for its use

- PL_PARSE_FULL
  A parameter used in the call to PLPARSEOPTS

- PL_PI
  The approximation of the number "pi". It is used in many examples
  and because it is often defined in other modules as well, we have
  given it a more specific name.
  Should you prefer "PI" (or "pi") then use the module like this:

     program myprog
        use plplot, pi => pl_pi
        ...

- PL_GRID_CSA, PL_GRID_DTLI, PL_GRID_NNI, PL_GRID_NNIDW, PL_GRID_NNLI,
  PL_GRID_NNAIDW
  Parameters that select the gridding algorithm for PLGRIDDATA

- PL_JUST_NONE, PL_JUST_OPTIMAL, PL_JUST_SAME, PL_JUST_ISOMETRIC:
  The justification of axes in PLENV. The names should be more or
  less self-explanatory.

- PL_AXIS_NOTHING    - no decoration for the axis
  PL_AXIS_BOX_ONLY   - only the axles
  PL_AXIS_NORMAL     = ordinary axes
  PL_AXIS_ATZERO     = include lines through 0-coordinates
  PL_AXIS_MAJORGRID  = include grid for major tickmarks
  PL_AXIS_MINORGRID  = include grid for major and minor tickmarks
  PL_AXIS_LOGX       = use logarithmic X axis
  PL_AXIS_LOGY       = use logarithmic Y axis
  PL_AXIS_LOGXY      = both axes logarithmic

  You can combine the logarithmic options with the others
  (except PL_AXIS_NOTHING and PL_AXIS_BOX_ONLY) by simply
  adding them: PL_AXIS_LOGX+AXIS_MAJORGRID for instance

To illustrate the alternative interfaces for various routines,
here are the possibilities to call PLBIN

The C API reads:

void
plbin(PLINT nbin, PLFLT *x, PLFLT *y, PLINT center);

Because in Fortran 95, the size of the array can be queried via the SIZE
intrinsic function, we can drop the nbin argument. And while C has no
specific logical data type, Fortran has. So there are four ways to call
PLBIN from Fortran 95:

   logical                        :: center
   integer                        :: icenter, nbin
   real(kind=plflt), dimension(:) :: x, y

   !
   ! Fortran 95, method 1 (compatible with FORTRAN 77)
   !
   icenter = 1
   nbin    = size(x)
   call plbin( nbin, x, y, icenter )

   !
   ! Fortran 95, method 2
   !
   center = .true.
   call plbin( x, y, center )  ! Drop the argument nbin, use a logical for center

   !
   ! Fortran 95, method 3
   !
   icenter = 1
   call plbin( x, y, icenter )  ! No nbin, use an integer for center

   !
   ! Fortran 95, method 4
   !
   center = .true.
   call plbin( nbin, x, y, center )  ! Use nbin, use a logical for center

Method 2 is preferred, as it is most "Fortran 95" in character.



Linking DLLs on Windows
-----------------------
On Windows it is necessary to specify which routines and functions in
a DLL should be exported, i.e. made visible to external programs. While
there compiler-specific ways to do that within the source code we prefer
to do it via so-called linker definition files (.def).

Basically, these files contain a list of all the subroutines and functions
that need to be exported, one name per line. The difficulty is, however,
that these names are the names as constructed by the compiler. Each compiler
is free to use its own scheme for turning the name found in the Fortran code
into a "linker" name".

For the Compaq Visual Fortran the scheme is this:

subroutine/function Name( a, b ) ==> _NAME@8

   module plplotp
   contains
   subroutine/function Name( a, b ) ==> _PLPLOTP_mp_NAME@8
   end module

where the @8 represents the number of bytes in the argument list (the
hidden argument representing the length of string arguments must be
included in that count)

For the MinGW gfortran compiler the scheme is somewhat simpler:

   subroutine/function Name( a, b ) ==> name_
   subroutine/function My_Name( a, b ) ==> my_name__

   module plplotp
   contains
   subroutine/function Name( a, b ) ==> __plplotp_MOD_name
   subroutine/function My_Name( a, b ) ==> __plplotp_MOD_my_name
   end module

For the Cygwin gfortran compiler all symbols are automatically exported. There
is no need for a linker definition file.

One way to find out what the internally produced names are is to examine the
object file (.obj) that is produced by the compiler.

Notes:
- The compiler adds the name of the module to the name of the routine
- The MinGW compiler does not append underscores for routines living
  in a module, but it does for routines outside a module
- All routines that are mentioned in an interface block must be exported:

  The four routines in this fragment must all be exported via the
  linker definition file, even though only the interface name is useable
  in the Fortran code (the routines themselves are not visible to a
  Fortran program because of the private clause):

     interface plvect
        module procedure plvectors_0
        module procedure plvectors_1
        module procedure plvectors_2
        module procedure plvectors_tr
     end interface
     private :: plvectors_0, plvectors_1, plvectors_2, plvectors_tr

  So the definition file has these lines:

     __plplotp_MOD_plvectors_0
     __plplotp_MOD_plvectors_1
     __plplotp_MOD_plvectors_2
     __plplotp_MOD_plvectors_tr

  (but no line for the interface name as that is stored in the
  module intermediate file used by the compiler)