background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
1/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
Organization (S):
EDF/IMA/MN
Data-processing manual of Description
D2.02 booklet: Rules of development
D2.02.01 document
Rules of programming FORTRAN
Summary:
This document presents the rules retained by the Team of Development of
Aster (EDA) for the writing of
routines of the code in FORTRAN 77.
One can distinguish two kinds of rules:
·
the rules resulting from book “FORTRAN 77 Guides for the writing of portable programs”
(F. FICHEUX-VAPNE and coll). For these rules, we sometimes modified the statement in
transforming a consulting into rule,
·
rules resulting from the experience gained during the first years of the project. These
last rules are sometimes dictated by strategic technical choices: for example,
management of the memory (
JEVEUX
) exemption often of the use of
COMMON
. These last rules
thus have a range less general than the first.
The compliance with these rules has two main objectives:
·
to ensure a good portability of the code,
·
to ensure a good legibility (and thus maintainability) of the source text.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
2/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
1
Contents
1 Contents .......................................................................................................................... 2
2 Introduction ...................................................................................................................................... 3
3 Rules selected ............................................................................................................................... 4
3.1 Presentation .............................................................................................................................. 4
3.2 ANSI .............................................................................................................................. normalizes 4
3.3 Exceptions to the standard ............................................................................................................... 5
3.4 Lexical elements ..................................................................................................................... 5
3.5 Objects of the language ..................................................................................................................... 6
3.6 Initialization - assignment .......................................................................................................... 6
3.7 Structures of control ............................................................................................................... 7
3.8 Units of program ................................................................................................................ 8
3.9 Input-outputs ........................................................................................................................ 9
3.10 Problems of inter-compilation ................................................................................................. 9
4 Some explanations .................................................................................................................... 11
4.1 Alphabet .................................................................................................................................. 11
4.2 Statement of the floating types ................................................................................................. 11
4.3 Intrinsic functions ............................................................................................................. 12
4.4 COMMON ............................................................................................................................... 13
4.5 Input-outputs ...................................................................................................................... 15
5 “Errors” detected by the compiler of the CRAY ............................................................................ 16
6 “external” Calls .......................................................................................................................... 17
6.1 BLAS: SAXPY, SCOPY, SDOT, SNRM2, SSCAL, SPDOT * ................................................... 17
6.2 Specific routines CRAY ..................................................................................................... 17
6.3 BIBC ....................................................................................................................................... 17
6.4 BIBCAL ................................................................................................................................... 17
7 Bibliography .................................................................................................................................. 18
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
3/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
2 Introduction
The goal of this document is to present the whole of the rules retained by the Team of Development
of
Aster (EDA) for the writing of routines FORTRAN of the code.
The compliance with these rules has two objectives:
·
to ensure a good portability of the code,
·
to ensure a good legibility (and thus maintainability) of the sources.
It is obvious that it is not enough to comply with these rules to achieve the second goal. The aforementioned requires
also rules of presentation [D9.03.01] and especially of the efforts on behalf of each programmer for
to render comprehensible itself.
It is quite as clear that these rules relate to only the aspects of the language used and that
other rules must be applied concerning the programming (emission of the messages
of error, use of JEVEUX, use of the structures of data, etc) or the development
(presentation, documentation, validation, etc). These rules are presented in the Manual of
Data-processing description and the Manual of Administration.
Immediately let us note the imperative character of these rules. It is not a question of virtuous consultings. Each rule
is written so that one can say without ambiguity if it is respected or not: there is nothing of
qualitative. Developers of the code
Aster must respect them. We will see that the first stated rule
(most important) is the respect of standard ANSI. The current tool for compilation of
Aster (
cft77
on CRAY)
allows to check its application easily. Other rules are checked by the AGLA [D2.01.02] us
will systematically indicate between brackets the emitted code-return when it is nonnull (2 or 4). The code
return (2) allows the administrator sources of
Aster (ASA) to control the departures from the rules. The code
return (4) prohibited restitution of the sources (cf [§5]). For the rules whose automatic checking is less
easy, the “sanction” will be done
a posteriori: the procedure of evolution of the sources indeed makes it possible to find
easily identity of a possible negligent developer.
One cannot speak about rules of programming FORTRAN at DER without speaking about book “FORTRAN77 Guide
for the writing of portable programs " [bib1] carried out under the direction of F. FICHEUX-VAPNE. This book us
was used as a basis for this document: practically, for the presentation of the rules, we preserved it
plan: lexical elements,…, input-outputs. We retained:
·
18 consultings of portability,
·
22 methodological consultings.
The respect of the standard, which we instituted in rule n° 1 replaces 33 consultings of the book.
The consultings of the book were set up in rules, sometimes by modifying their statement: “to use… with prudence” -->
“not to use…”.
With these rules, we added some rules which are clean for us and which result from the gained experience
by the Team of Development during the first five years of the Project.
In this document, we tried to explain (at least partially) the reasons of the choice of these rules.
This is not always easy to make. For that, we return to [bib1] for the rules coming from this book,
and we make references in certain paragraphs of explanation for the rules which are clean for us.
Let us finish this introduction by saying that, contrary to a spread idea, FORTRAN is not one
“obvious” language. Certain elements of the language are “survivals” of old versions of the language. These
elements are not included/understood often any more “young” programmers. The curious reader will be able to read with profit it
deliver “FORTRAN 77” of H. KATZAN [bib3] for including/understanding well what is the FORTRAN77 of standard ANSI.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
4/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
3 Rules
reserves
3.1 Presentation
The rules are numbered. For the rules resulting from [bib1] we preserved same classification as
that of the book, which makes it possible to refer to it more easily, in particular to include/understand it why of this
regulate. The additional rules that we were given are noted Have.
Have:
I
ème
regulate
Aster,
Pi:
I
ème
consulting of portability of [bib1],
Semi:
I
ème
consulting of methodological of [bib1].
In general, each rule is followed clarification of the exceptions to this rule (when they exist).
recall:
the code return of the AGLA (
asverif
) is written between brackets when it is nonnull: (2) or
(4).
Some terms of
Code_Aster
JEVEUX:
manager of memory of
Code_Aster,
SUPERVISOR:
“main program” which connects (and supervises) the different ones
controls of the software,
UTILICRA:
library containing the nonportable routines (in their version
“CRAY”),
BIBC:
library containing some utilities writes out of C,
BIBCAL:
library containing some routines written in “assembler” CRAY
(CAL): optimization of the combined gradient.
3.2 Normalizes
ANSI
A-1
To respect standard FORTRAN77 ANSI. (4)
[bib2]
It is obviously the most important rule.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
5/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
3.3
Exceptions to the standard
The exceptions to the respect of standard ANSI are:
A-2
To use the statements
REAL * 8
and
COMPLEX * 16
(cf [§4.2]).
A-3
It is allowed to make
ZK8 (I)
=
ZK8 (J)
if
ZK8
is a table of character strings.
A-4
It is allowed to use the functions except standard:
·
IAND
,
IOR
on the type
INTEGER
,
·
DIMAG
and
DCONJG
and
DCMPLX
for the type
COMPLEX * 16
(cf [§4.3]).
A-5
The tiny ones and certain special characters are allowed only for certain units
of program (cf [§4.1]) (2).
A-6
It is interdict to use the FORMAT of impression of the binary variables except standard Z, B,
O, etc… except for the routine
JJIMPO
(2) to make the “dump” memory.
A-7
It is allowed JEVEUX to put in equivalence variables of the character type and of
type not-character (2). (cf also A-13)
A-40
It is allowed to pass in argument an expression of the character type of the style
“channel”//arg (1:N)
where
arg
is an argument unknown length.
Example:
SUBROUTINE AAAAAA (C)
CHARACTER * (*) C
CAL UTMESS (…, “LOUSE”//C (1:4),….)
A-41
It is interdict to not use the constant data in binary format for the types
floating. Exception routine
DEFVEM
(2).
A-44
It is safe interdict with JEVEUX (2) to put in equivalence a vector length 1
with a variable declared in
COMMON
.
3.4 Elements
lexical
P.I.6
To register the comments in lines comments comprising in first
column C other than any other character (4).
A-49
The white lines are accepted.
P.I.8
Not to insert comments between lines continuations (0), nor before the headings
FUNCTION
,
SUBROUTINE
, nor afterwards
END
(4).
Mr. I.2
Not to use key words as identifiers:
IF, END, CAL, GOTO,…
Mr. I.3
Not to put white inside the identifiers, of the key words (except for
GO
TO
,
END
IF
, and
ELSE
IF
) and of the constants except those of character type.
Mr. I.5
Not to cut at the end of the line the key words, the identifiers and the constants.
A-29
To use it & as character of continuation of the cards continuations.
A-30
To cut the lines to be continued so that the instruction is syntactically
incorrect without the cards continuations. For example by finishing the lines to be followed by: '
,
'
'
//
''
+
''
-
''
/
'etc…
A-39
To give to each unit of program a name having between 5 and 6 characters.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
6/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
3.5
Objects of the language
P. II.3
Not to put white inside a literal constant of arithmetic type or
logic.
P. II.6
To compare only arithmetic expressions in the same way standard.
P. II.8
Not to use the operators of comparison
.LT.
,
.LE.
,
.GT.
and
.GE.
on channels of
characters that to compare between them channels only made up of
figures or of the channels only made up of letters.
P. II.9
To use only the intrinsic functions
LGE
,
LGT
,
and
LLT
to compare according to
the command of the ASCII code of the channels made up at the same time of letters, figures and of
special characters.
A-2
(Recall) To use the statements
REAL * 8
and
COMPLEX * 16
.
A-8
Not to use the statements
REAL
,
COMPLEX
and
DOUBLE
PRECISION
(4).
A-31
All the routines must comprise the instruction (4):
IMPLICIT REAL * 8 [A-H] [OZ]
or
IMPLICIT NUN
Those which will restore FORTRAN with
IMPLICIT NUN
will be considered better
that others.
A-32
The local variables not used must be destroyed.
A-33
The instructions put in comments must be destroyed.
A-35
The labels should appear only in front of the instruction
CONTINUOUS
or
FORMAT
(4).
A-36
To use: To ** 2 in the place of A * A or A ** 2.
3.6
Initialization - assignment
P. III.1
To use only whole expressions as values initial, final and like
not loop
C
implicit.
Mr. III.6
Not to use the instruction
ASSIGN
.
A-45
All numerical constants (smaller floating number, etc…) and mathematics
(
, 2
, etc…) must be initialized by call to a function ENVIMA [D6.01.01]. If
the aforementioned seems insufficient to emit an anomaly report.
A-46
It is useless and not very readable to use variables to handle constants
numerical simple. For example, which should not be done:
REAL * 8 ZEROS, ONE
DATED ZERO, ONE/0.D0,1.D0/
X = ZERO
MU2 = E/(UN+NU)
What it is necessary to do:
X = 0.D0
MU2 = E/(1.D0+NU)
A-47
All the floating constants must comprise it
.
and it
D
(4) (cf [§4.2]).
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
7/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
3.7
Structures of control
P. IV.1
To use only expressions of the whole type as parameters and counter of
loop.
P. IV.2
Not to modify the counter of loop in the body of the loop.
P. IV.7
Not to use the instruction
PAUSES
.
Mr. IV.1
To finish each loop
C
by an instruction
CONTINUOUS
.
P. IV.4
To use the instruction systematically
CONTINUOUS
, in particular like last
instruction of the structures of control by having care, when these structures are
imbricated, to allot one
CONTINUOUS
with each one.
A-9
Not to use it
GO
TO
calculated.
Exceptions: routines
TE0000
,
EX0000
,
EX0100
,
OPSEXE
.
A-9
Not to use it
GO
TO
assigned.
A-10
Not to use it
IF
arithmetic.
A-11
Not to use the instruction
STOP
except for the routines
JEFINI
,
JVFINM
,
JVVTAM
(2).
A-34
Blocks
IF
vacuum are prohibited.
A-38
Blocks
IF
and them loops
C
must be indentés of two characters.
Example:
C 100 I=1, NR
X (I) = 0.D0
100 CONTINUOUS
C
IF (Y. LT.0.D0) THEN
Z=1.D0
ELSE
Z=2.D0
ENDIF
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
8/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
3.8
Units of program
P.V.4
Not to use the intrinsic functions
TANK
and
ICHAR
(4) (cf A-15).
Exceptions:
·
routines of reading of the supervisor:
LXSCAN
,
LXCAPS
,
LXINIT
(2),
·
JEVEUX: JEDEBU, JJVERN (2).
P.V.9
To use one type for the variables of one
COMMON
given. (cf [§4.4]).
P.V.12
To use the instruction
SAVE
with each time remanence is wished.
Mr. V.3
Not to use the intrinsic functions as arguments of subroutine.
Mr. V.8
To finish an external function by
END
without coding
RETURN
. Thus not to use
RETURN
(4). It is not prohibited however to use:
GOTO 9999
9999 CONTINUOUS
END
Mr. V.9
Not to define external functions having the same name as functions
intrinsic.
Mr. V.12
Not to use in a subroutine the optional returns of subroutines.
Mr. V.13
Not to use the instruction
ENTRY
(4) except
ENVIMA
,
GETVAL
and
VALXEM
(2).
Mr. V.16
Not to use arguments of the form
* étiq
(cf Mr. V.12).
Mr. V.17
Not to use
BLOCK
DATED
(4).
Mr. V.20
Not to use the command
DIMENSION
: it is simpler to declare dimension with
type (4).
Mr. V.21
To define only one commun run for each instruction
COMMON
and to use only one
instruction
COMMON
by commun run.
Mr. V.22
For objects belonging to a commun run, to use the same names in all them
units of program where the aforementioned appears.
Mr. V.23
Not to use the common white (common without name).
Mr. V.27
To use the notation
*
to code the upper limit of the last dimension of one
table used as formal argument when this terminal is unknown under
program.
Mr. V.28
To note
*
the length of a character string used as formal argument (4).
A-12
Not to use the instruction
PROGRAM
. Exception: routine
aster
.
A-13
Not to use the instruction
EQUIVALENCE
(except for the routines
JEVEUX
of
UTILICRA
)
(4) (cf also A-7).
A-14
Not to use the instruction
INTRINSIC
(4).
A-15
To use only the authorized intrinsic functions (cf [§4.3]) (4).
A-21
The use of
COMMON
is reserved for very particular uses (cf [§4.4])
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
9/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
A-26
To limit to 300 the number of lines of a routine (2).
A-27
To limit to 15 the number of arguments of a routine (2).
A-28
To preserve if possible the identifier of the arguments of the routine called in
appealing routine.
A-42
Not to use the instruction
External
that in the event of need: when the “external” routine
passed in argument.
A-43
Not to call upon external libraries:
NAG, GENERAL, LINPACK
… (4).
A-48
To make external calls only in
UTILICRA
and
BIBC
(cf [§6]) ((2): for
UTILICRA
and
BIBC
) ((4): for the others).
A-50
Not to use them
BLAS
(4) but their “caps” which are in the library
UTILICRA
[§6.1]. Exception:
UTILICRA
(2).
3.9
Input-outputs
P. VI.4
At the time of one
READ
or of one
WRITE
, to specify the selected logical unit, by parameterizing sound
number (variable integer). Not to use the asterisk.
P. VI.6
The value of the code return
IOSTAT
depends on the computer. The standard indicates
only that it will be null if very happened well, positive if there were error,
negative if an end of file were met. To use only this property.
P. VI.7
To use only expressions of the whole type for the values initial, final and
for the step value of the loops
C
implicit in the lists of input-output.
P. VI.8
To always give a list of input-output in the writing and reading orders and
not to use the empty format.
P. VI.18
In an instruction
FORMAT
, not to use the specifications of edition,
T
,
TL
and
TR
.
Mr. VI.2
Not to use the instruction
PRINT
.
Mr. VI.5
Not to use the descriptor
nHh1
hn
but
“h1h2… hn”
.
A-16
Not to use the instruction
OPEN
Exceptions: routines,
jxlir1
,
jxouvr
,
spycod
,
spyerr
.
A-17
Not to use the instruction
BACKSPACE
.
A-18
Not to use the instruction
INQUIRE
.
A-19
Not to use the instruction
CLOSED
.
Exceptions: routines
spycod
,
spyerr
.
A-20
Not to use the instruction
ENDFILE
.
3.10 Problems
of inter-compilation
A-22
To use the same type and the same length for a variable put in
COMMON
in
all the routines which use it (4).
A-23
To call the routines with the good number of arguments (4).
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
10/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
A-24
Not to call a routine with an argument of the type
CHARACTER
of length
different that that awaited by the program called (4).
Regulate for the routines having a formal argument of type
CHARACTER
·
to use the statement
CHARACTER * (*)
(M-V-28),
·
to recopy if necessary the arguments
CHARACTER * (*)
in variables
local.
A-25
Not to call a routine with arguments of a type different from that which it
waits. In particular not to call a routine with a complex argument if that
Ci awaits two real arguments and conversely (4).
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
11/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
4 Some
explanations
4.1 Alphabet
Certain routines use “illegal” characters (by the standard).
·
The supervisor must be able to read the characters authorized in the process control language
of
Aster:
- tiny
-
%, &!, _.
·
JEVEUX uses: $ and &.
·
The routines printing of the lines of “UNIX controls” use: $, I (“pipe” UNIX), \.
Summary of the exceptions concerning the alphabet:
That is to say: NR
= {characters authorized by the standard}
= {AB… Z01… 9 " white " =+- */().':$}
·
authorized characters: NR
- {$}
+ {&}
all them
routines
·
authorized characters: NR
+ {&}
JEVEUX
·
authorized characters: NR
- {$}
+ {tiny, %, &!, _}
SUPERVISOR
·
authorized characters: NR
+ {I,
\}
impressions
UNIX
The comments use only the characters authorized by the standard.
4.2
Statement of the floating types
This problem is related to the double following requirement:
·
to allow calculations with a precision considered to be reasonable: 13 significant digits on
CRAY,
·
to be portable on machines of which it
REAL
is length 32 bits.
Unfortunately these requirements are not compatible with the standard.
The “solution” chosen for this problem is detailed in note HI-75/94/068/A “the problem of the numbers
floating in FORTRAN77 ".
Adopted solution:
·
The only authorized commands of statement are:
IMPLICIT NUN
) with
IMPLICIT REAL * 8 [A-H] [OZ]
) choice
LOGICAL
INTEGER
REAL * 8
COMPLEX * 16
CHARACTER *…
If not codes return (4)
·
To write the constants in double precision.
If not codes return (4)
REAL * 8 R1, R2
COMPLEX * 16 C1, C2
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
12/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
R1 = 1.D0/3.D0
C1 = (3.D0, 4.D0)
It is thus interdict to write:
R1 = 1./3.
R1 = 1.E3/3.E3
C1 = (0., 1.)
C1 = (0.E0,1.E2)
4.3 Functions
intrinsic
Intrinsic functions of the language: sines, cosine, racine_carrée, valeur_absolue,… have for the majority
of them a generic form (i.e independent of the type of their arguments). They are these functions
credits which should be used to ensure the portability.
Example: racine_carrée function
REAL
specific name:
SQRT
DOUBLE PRECISION
specific name:
DSQRT
COMPLEX
specific name:
CSQRT
Generic name:
SQRT
In the same way, the conversion of the type must be done in a generic way. For example, conversion into
entirety (truncation):
Specific:
INT
:
REAL
- >
INTEGER
IFIX
:
REAL
- >
INTEGER
IDINT
:
DOUBLE PRECISION
- >
INTEGER
Generic name:
INT
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
13/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
The intrinsic functions selected (cf notes HI-75/94/068/A) are:
·
Functions of standard FORTRAN
Conversions of the type:
INT
DBLE
Generic arithmetic functions
AINT
ANINT
NINT
ABS
MOD
SIGN
DIM
MAX
MIN
SQRT
EXP
LOG
LOG10
Generic goniometrical functions
SIN
COS
TAN
ASIN
ACOS
ATAN
ATAN2
SINH
COSH
TANH
Functions particular to the character type
TANK
ICHAR
LEN
INDEX
·
Functions except standard to be used
Conversions of the type:
DCMPLX
Functions particular to the complex type
DBLE
DIMAG
DCONJG
Functions particular to the integer type
IOR
IAND
4.4
COMMON
The manager of memory JEVEUX allows the routines of the code to exchange data structured in
minimizing the number of the arguments: one transmits the name of the structure of data.
The use of
COMMON
is thus not recommended in
Aster. It is not interdict to however use them.
This use must however remain limited to “parcellings” of routines identified well. The use of
COMMON
is not to limit the number of the arguments passed to the routines. The use is justified:
·
for reasons of performances and only for the routines of general use
(
CALCULATION
,
JEVEUX
,
SUPERVISOR
, reading of
CATALOGS
),
·
for the passage of the parameters to the routines used in
External
.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
14/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
The use even of JEVEUX is impossible without “
COMMON
JEVEUX " [D6.02.01]. For those, one
will always use the same sequence of statements (recopied routine in routine):
C
C ---
BEGINNING STATEMENTS NORMALISEES JEVEUX ---------------------------
----
C
CHARACTER * 32
JEXNUM,
JEXNOM,
JEXR8, JEXATR
INTEGER
ZI
COMMON/IVARJE/
ZI (1)
REAL * 8
ZR
COMMON/RVARJE/
ZR (1)
COMPLEX * 16
ZC
COMMON/CVARJE/
ZC (1)
LOGICAL ZL
COMMON/LVARJE/
ZL (1)
CHARACTER * 8
ZK8
CHARACTER * 16
ZK16
CHARACTER * 24
ZK24
CHARACTER * 32
ZK32
CHARACTER * 80
ZK80
COMMON/KVARJE/
ZK8 (1),
ZK16 (1),
ZK24 (1),
ZK32 (1),
ZK80 (1)
C
C ---
FINE STATEMENTS NORMALISEES JEVEUX -----------------------------
----
For the others
COMMON
we will adopt the rule of following denomination:
COMMON TxyzPP
where:
T
is a character which indicates the type of the variables of the COMMON:
I
INTEGER
R
REAL * 8
L
LOGICAL
C
COMPLEX * 16
L
LOGICAL
K
CHARACTER
PP
is a pair of characters which identifies at the same time a “package” of commun runs and parcelling
routines which use this package.
xyz
are three free characters allowing to differentiate the commun runs from the same package.
Examples of what could be made:
PP = “I”: COMMON
necessary to
JEVEUX
PP = “CA”: COMMON
necessary to the routine
CALCULATION
,
PP = “LLC”: COMMON
necessary to the routine
NMCOMP
,
PP = “GC”: COMMON
necessary to the routines of the supervisor.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
15/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
4.5
Input-outputs
The inputs/outputs of the code are made in theory by a restricted number of routines:
·
read/write on the data bases
Aster (files of random access): JEVEUX.
·
formatted reading:
-
the supervisor is in charge of the reading of the command file,
- only controls
(
=
MESH
,
FUNCTION
,…) and them
controls of interfacing
(
=
GIBI
,
IDEAS
,…) are authorized with reading
on external files. For that, the only authorized instruction is it
READ
formatted.
The opening (
OPEN
) and closing (
CLOSED
) of the files are made by the supervisor.
·
formatted writing:
-
emissions of messages on the files
ERROR
,
MESSAGE
,
RESULT
: parcelling of
routines
UTMESS
,
UTDEBM
,… [D6.04.01],
-
writing of results: controls
(
=
RESU
,
FUNCTION
,…),
-
writing of information in the files
RESULT
or
MESSAGE
(key word
IMPR
of
certain controls).
Summary of the authorized instructions:
UTMESS (...)
all routines.
READ (nfic, fmt)
Controls
WRITE (nfic, fmt)
Controls
and key word
IMPR
OPEN/CLOSED,…
SUPERVIS, JEVEUX
random access
JEVEUX
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
16/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
5
“Errors” detected by the compiler of the CRAY
The compiler of the CRAY cft77 [bib4] emits a certain number of messages classified in various categories:
·
How
·
Note
·
Monetary bond
·
Warning
·
Error
·
ANSI
·
These messages have a heading standardized:
cft77-i
where
I
is a number which can belong to [
1-9999
],
(all the numbers are not allotted!). Only the “Error” are “fatal” for the compiler, but the others
messages (which we will call “errors” with quotation marks) can be revealing problems of
programming.
The explanation of each one of these “errors” is given in the document [D2.02.02].
We thus decided to treat in “error” some of these messages (in other messages ANSI).
During a compilation (for example with the restitution of source), it is easy “to catch” the messages
agent with a given number. One gives then a code return to compilation according to the level
maximum of the detected “errors”.
The value of the code return is that of the restitution (cf.
asrest
[D1.02.01]):
0
All is well
the restitution is accepted.
2
Alarm
the restitution is subjected to the visa of the ASA.
4
Error
the restitution is refused.
All messages of
cft77
lead to a code return 4 except:
·
code return 2:
720 - Regulate A-7
726 - Regulate A-44
890 - Regulate A-5
·
code return 0:
118 - Regulate A-4 and A-15
408 - Regulate A-2
881 - Regulate A-3
895 - Regulate A-40
·
code return 4:
342 except for
DEFVEM
- A-41 Rule
753 except for
JEIMPO
- A-6 Rule
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
17/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
6 Calls
“external”
We call “external” call, one
cal
towards an entrance point which is not:
·
nor a routine (or
ENTRY
) FORTRAN nor a function C of
Aster.
·
nor an intrinsic function
Only libraries
UTILICRA
and
BIBC
can carry out “external” calls.
Let us recall that the call to a routine of an external library (
NAG
,
GENERAL
,
LINPACK
,…) is prohibited (A
43).
Ultimately an “external” call can be only the call to:
/
a routine BLAS
/
a specific function CRAY
/
a routine of
BIBCAL
6.1 BLAS
:
SAXPY
,
SCOPY
,
SDOT
,
SNRM2
,
SSCAL
,
SPDOT *
These routines change names on the machines “32 bits”:
DAXPY
,…
Regulate:
To use the “caps” with these routines which are in
UTILICRA
:
R8AXPY, R8COPY, R8DOT, R8NRM2, R8SCAL, R8PDOT
*
SPDOT
is not an official BLAS.
6.2
Specific routines CRAY
·
Random access:
OPENDR, CLOSDR, READDR, WRITDR
·
“conventional”:
AND, XOR, SHIFT1, SHIFTR, INTMAX, LOC, STRMOV
·
Time:
CLOCK, DATE, TREMAIN, SECOND
·
UNIX environment:
GETCWD
,
GETENV
,
GETPID
·
Dynamic storage:
HPALLOC
,
HPDEALLC
,
HPCHECK
6.3
BIBC
All the routines can call upon the routines of the library
BIBC
. But the aforementioned does not have
to contain that utilities which cannot be carried out in FORTRAN.
6.4
BIBCAL
Only
BIBC
can appeal there.
background image
Code_Aster
®
Version
3.0
Titrate:
Rules of programming FORTRAN
Date:
28/04/98
Author (S):
J. PELLET, P. MIALON
Key:
D2.02.01-A
Page:
18/18
Data-processing manual of Description
D2.02 booklet: Rules of development
HI-75/95/009 Ind A
7 Bibliography
[1]
FORTRAN77 - Guide for the writing of portable programs under the direction of F.
Ficheux-Vapné - Editions Eyrolles Collection of the Management of the Studies and Search
of Electricity of France
[2]
FORTRAN77 normalizes - ANSI
X3.9-1978
[3]
FORTRAN77 - Harry Katzan - Van Nostrand Reinhold Company 1978
[4]
CF77 Compiling System, Volume 2: To compile Manual Message - SR-3072 4.0 1990 - CRAY
research, Inc.