background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
1/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
Organization (S):
EDF-R & D/AMA















Instruction manual
U1.0- booklet: Introduction to Code_Aster
Document: U1.03.01



Process control supervisor and language


Summary:

This document describes the role and operation:
·
of the supervisor who ensures the piloting of an execution of Code_Aster;
·
and of the process control language which ensures the communication between the user and the Code.

background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
2/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
Count
matters
1
Introduction ............................................................................................................................................ 3
2
General mechanism of operation of the supervisor ........................................................................ 4
2.1
General architecture ....................................................................................................................... 4
2.2
Total execution or step by step .................................................................................................... 4
2.3
The construction of the stages .............................................................................................................. 5
2.4
Processing of the macro-controls ............................................................................................. 6
2.5
Procedures of starting ........................................................................................................ 6
2.6
Links with EFICAS .......................................................................................................................... 7
3
The process control language ..................................................................................................................... 7
3.1
Python and the language process control ................................................................................................ 7
3.2
Concept of concept ............................................................................................................................ 8
3.3
Possible operations ....................................................................................................................... 8
3.4
Rules on the concept produced by an operator .............................................................................. 9
3.4.1
Guiding principle ..................................................................................................................... 9
3.4.2
Produced concept and concept re-used ....................................................................................... 9
3.4.3
Checks carried out by the supervisor on the concepts produced ..................................... 9
3.5
Body of a control ................................................................................................................. 10
3.5.1
Introduction ........................................................................................................................... 10
3.5.2
Key word 10
3.5.3
Argument of a single-ended spanner word .............................................................................................. 10
3.5.3.1
The type of the arguments ............................................................................................. 10
3.5.3.2
Concept of list .......................................................................................................... 11
3.5.4
Key word factor ...................................................................................................................... 11
4
Definition of values and evaluations of expressions .............................................................................. 12
5
Use of python in the command files ............................................................................... 13
5.1
personalized Macro-controls .............................................................................................. 13
5.2
General instructions PYTHON and useful modules ....................................................................... 13
5.3
Recovery of computed values in variables PYTHON ................................................ 14
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
3/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
1 Introduction
The role of the supervisor is to ensure the command of the course of operations in progress
of execution of a program. The instructions of execution are generally provided by the user.
This requires a formalization of the communications between the code and its operator, it is the language
of control.
The Python language is employed to write the catalog of controls, the supervisor and the files
controls user. For the command files, that makes it possible to discharge the supervisor from
the task of syntactic analysis, reserved for Python itself.
A command file is a succession of call to functions Python (controls),
defined in the catalog of controls. These functions have arguments of input: words
keys and their contents, and of the arguments of exit: produced concepts. The user who composes sound
command file must thus be subjected to the general syntax of Python (parenthesizing,
indentation…) and with the rules imposed by the catalog of controls (the provided arguments are
coherent with until the function waits).
For a first making of contact with the code, the reader will be able not to approach chapter 2.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
4/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
2
General mechanism of operation of the supervisor
2.1 Structure
general
The basic elements brought into play during an execution of an Aster calculation are:
·
the command file, provided by the user,
·
the catalog of controls: it is a module python of name cata placed in the package
Cata,
·
the SUPERVISORY high level object,
·
object JDC created by this last and which is finally carried out.
The SUPERVISORY object is a python object which analyzes the options transmitted on the line of
order, imports the catalog of controls, created object JDC starting from the command file and
carry out the aforementioned.
Object JDC (name for Command set) is a python object created by the SUPERVISORY object with
to leave the text of the command file and the module catalogs controls. It contains the objects
STAGE. Object JDC is representative of the command file user.
The STAGE objects are representative of each call to Aster controls in the file of
order. Each STAGE object bears the name of the control that it reference, the list of the key words
credits and their values, the type and the name of the produced concept.
Construction then the execution of object JDC start the following actions:
·
analyze syntactic command file user: it is on this level that syntax
python is checked (brackets, commas between key words, indentation…). The detection of one
error (Syntax Error Python) causes the stop of the execution of Aster. The first error
is fatal: the following errors are not sought,
·
construction of the stages: that consists in creating a STAGE object for each call to one
order Aster in the command file. This object is recorded at JDC which
manage the list of the stages and related concepts,
·
checking of each STAGE: if the call to a control in the file user is
incoherent with the catalog of controls, a report is displayed and the execution is
stopped on this level. It is the semantic checking,
·
execution itself of the controls: for each stage taken in the order, call to
high level routine FORTRAN (op0nnn.f) corresponding.
2.2
Total execution or step by step
A command set can be built and carried out according to two modes:
·
the total mode for which all the stages of the command set are initially built
then carried out in their order of appearance. This mode is chosen by the key word
PAR_LOT=' OUI' in the ordering of starting BEGINNING,
·
the mode step by step for which each stage is immediately carried out after its
construction. This mode is chosen by key word PAR_LOT=' NON' in the control BEGINNING.
If the user does not specify anything in the control starting, the total mode (PAR_LOT=' OUI') is
retained. These two modes present each one their advantages and disadvantages.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
5/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
The total procedure guarantees to the user that all its file is semantically correct
before starting calculations which could fail or not converging. It would be a pity indeed
to stop in fatal error after a long resolution because of a key word forgotten in one
order postprocessing.
The mode step by step builds a stage only after having carried out the preceding one. It thus does not detect
that the semantic errors of the pending order and presents the disadvantage described above. It
however allows to exploit a result calculated (in a concept) in the command file for,
for example, to place conditional instructions there.
Here an example of loop with a criterion of stop on the value of a calculated size, stored in
the concept of the type counts: RELV [K]. If for example an obligatory key word misses in the call to
POST_RELEVE_T, that will be detected only after the complete execution of the first MECA_STATIQUE.
On the other hand, the mode step by step makes here possible the assignment of variable SYY since the concept
RELV [K] was completely calculated at the time when the supervisor carries out this line.
BEGINNING (PAR_LOT=' NON')
RESU= [Nun] * 10
RELV= [Nun] * 10
for K in arranges (1,10):
RESU [K] =MECA_STATIQUE (…)
RELV [K] =POST_RELEVE_T (…)
SYY=RELV [K] [“VMIS”, 4]
yew SYY < criterion:
station-wagon
END ()
It should be noted that the choice of a procedure conditions the command in which the analysis will proceed
semantics (STAGE by STAGE or overall for all the JDC). But, in both cases, the analysis
syntactic python is always made as a preliminary for all the command file.
Note:
EFICAS can exclusively generate and read again only command sets containing
controls ASTER, without other instructions python; this independently of the mode
Selected PAR_LOT.
2.3
The construction of the stages
During the construction of each STAGE object, one checks his semantic coherence with the catalog
control to which it refers. Any detected error is consigned in a report
who, in total procedure, is delivered after the analysis of all the command file.
Semantic examples of checks:
·
respect of the number of arguments of the key words,
·
respect of the type of argument,
·
membership of an argument to a list of possible values,
·
exactitude of the orthography of a key word or a key word factor,
·
compliance with the rules of exclusion or implication between key words,
·
presence of the obligatory key words.
This stage, if the control is an operator and produces a concept, the aforementioned is typified. The supervisor
check that a of the same concept name was not already defined, or if it is employed again, that the control
authorizes.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
6/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
2.4
Processing of the macro-controls
A macro-control, considering the user, is an ordinary control. In fact, it does not call
directly a high level routine FORTRAN but generates other controls.
Two types of macro-controls exist:
·
macros in Python,
·
macros supervisory: they are the controls special (BEGINNING, FORMULA, INCLUDE,
INCLUDE_MATERIAU, CONTINUATION) which require a treatment the level of their
construction.
As well as the JDC itself, the call to a macro-control produces a father object (of type
MACRO-ETAPE) which contains wire objects: the stages which the macro one generates, even others macros.
A macro-control of the JDC is first of all treated like the other controls (checking
syntactic, construction of the macro stage). Then it “is built” by application of the method
Build python on object JDC. After its construction, stages of the controls produced by
macro are substituted at the stage of macro itself, for later execution.
It is important to note that the phase of construction of the macro-controls proceeds right front
their execution, and not at the time the total master key on the command file in mode PAR_LOT=' OUI'.
That has two consequences:
· EFICAS analyzes the syntax of the macro-control itself, but not that of its
subcommands.
· One can on the other hand exploit, in the programming of the macros, the data
previously calculated and repatriated in the space of names python, without having to impose it
mode PAR_LOT=' NON' with the user the macro one.
2.5
Procedures of starting
The procedures of starting available are:
BEGINNING
(cf [U4.11.01] and
CONTINUATION
[U4.11.03])
At least one of these two procedures must be obligatorily present in the file of
order. No other Aster control must precede them. If it is the case or if none is
present, the execution will be stopped as of the creation of the JDC. These are the procedures which contain
information on the procedure (PAR_LOT=' OUI' or “NOT”) which conditions the mode
of execution of the controls which follow.
In fact macro-controls supervisor, with their construction, call routines FORTRAN
allowing to initialize calculation by the following tasks:
·
“connection” of the logical units of the standard files,
·
opening of the data bases,
·
reading of the catalog of elements.
The first task consists in putting in correspondence numbers of logical units of files
of input/output standards (message, error, result).
The second task consists to define and open the data bases (file of random accesses used by
the manager of memory) in accordance with the instructions of the user, who can redefine
parameters of these files (see documents [U4.11.01] and [U4.11.03] on the procedures of
starting). One calls for that the routines of initialization
JEVEUX
(see document [D6.02.01] it
Manager of memory,
JEVEUX
).
The sequence of the controls to be carried out ends obligatorily in the control END. The text
who follows FINE must be commentarisé (i.e. begin with #). For a file included, it is
order RETURN which marks the end of the instructions that ASTER must take into account.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
7/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
Note:
In interactive mode, seized of the manual controls, not to put of control END and to pass
the argument ­ interact on the line of ordering of tender of the job.
2.6
Links with EFICAS
The core of the supervisor is common with Eficas, the editor of command files Aster. At the time of
the edition of a command file, the aforementioned carries out the syntactic analysis and the checks of
coherence of the concepts by construction of the JDC and its STAGE objects. Eficas does not realize of course
not the task of construction of the macro-controls which would require the source code of Aster.

3
The process control language
3.1
Python and the language process control
A command file for Code_Aster is exclusively made up of Python instructions.
first of the stresses is thus to conform to the rules of this language. One will be able to read the tutoriel
Python (www.python.org) or many books of introduction to Python for more detail, but it
is not necessary for the use of Aster.
A command file can contain instructions python of two natures: controls
Aster and… any other instruction python. Indeed, a command file is one
program python with whole share and one can place in particular there structures of control (loops),
numerical tests (yew), calculations, calls to functions the pre one and postprocessing.
Within the framework of a “conventional” use of the code where the command file contains
exclusively controls Aster, the two rules specific to Python to be retained are:
·
No the indentation on the first line of statement of an instruction.
mall = LIRE_MAILLAGE ()
One should place neither white, nor tabulation before the character string mall.
·
Arguments of the functions, in other words the key words of the controls, are separated by
commas; they are composed of a key word, sign “=”, contents of the key word.
Important:
Editor EFICAS allows to produce only command files of this type: container
exclusively controls ASTER, without another instruction Python. Utiliser EFICAS guarantees
primarily three things:
·
the produced file will have a correct syntax python,
·
the produced controls will be coherent with the catalog of controls,
·
the produced concepts being correctly connected (not of use of a concept without it
was created by a preceding control).
The user having composed his command file thus will be safe from one stop to the execution with the reason
of a problem of syntax.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
8/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
3.2
Concept of concept
Definition: one calls concept the structures of Aster data, that the user can handle and
to name. These concepts are typified at the time of their creation and could be used only like
argument of input of the type corresponding in a further order.
The concept of concept thus makes it possible the user symbolically to handle objects and
independently of their internal representation (which it can not know). Moreover, the python object
indicated by the name of the concept any other information but its type, its class with the direction does not contain
python (cf Doc. D). Its name, transmitted by the supervisor to FORTRAN, makes it possible Aster to find
corresponding structure of data in the total base. But it is not possible to have visibility
structure of data since the command file. For example, following instructions
do not allow to print the structure of data of the mesh type and name mall:
mail=LIRE_MAILLAGE ()
print mall
but generate the following message:
SD mesh name: mall
There is an exception to this rule: tables. Indeed, an artifice of programming allows
to simply recover information contained in a structure of data COUNTS while handling
the aforementioned like a table at two entries:
to print all the table:
print
resu
to print a value:
print
resu [“DX”, 1]
to assign it to a variable:
value = resu [“DX”, 1]
That supposes of course that the structure of data resu, type COUNTS, was already calculated with
moment when this instruction is met: thus in procedure step by step (PAR_LOT=' NON').
Lexical remark:
The names of concepts should not exceed 8 characters. Alphanumerics
are licit (small letters and capital and figures not placed in first position) like
the underscore “_”. Breakage is important: the concepts “MALL” and “Mall” could be used
in the same command file and will be regarded as different… it is however
disadvised for the legibility of the file!

3.3 Operations
possible
The structure of the process control language is appeared as a linear succession of instructions.
In addition to the instructions python other than of the Aster controls, of which it is not question for
moment, three natures of instructions (or controls) are available:
·
the operator who carries out an action and who provides one
concept
product
of a preset type
exploitable by the following instructions in the command set,
·
the procedure which carries out an action but does not provide a concept,
·
the macro-control which generates a sequence of instructions of the two preceding types and
who can produce zero, one or more concepts.
Typically, an operator will be an ordering of assignment or of resolution, a procedure will be
an ordering of impression (in a file).
From the syntactic point of view an operator presents himself in the form:
nomconcept = operator (arguments…)
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
9/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
Whereas a procedure arises in the form:
procedure (arguments…)
The syntax of an operator or a procedure is described in the following paragraph.

3.4
Rules on the concept produced by an operator
3.4.1 Guiding principle
With each execution of an operator, the aforementioned provides a new produced concept of the preset type in
the catalog of control.
The concepts appearing in argument of input of the controls, are not modified.

3.4.2 Produced concept and re-used concept
One calls re-used concept, a concept which being produced by an operator, is modified by one
new occurrence of this operator or by another operator.
The use of a re-used concept is not possible, like exemption of the guiding Principle that from two
conditions:
·
authorization given, by the catalog and the programming of the control, to use
reusable concepts for the operator: the reentrant attribute of the catalog is worth “O” or “F”,
·
request clarifies of the user of the re-use of a concept produced by the attribute
reuse=nom_du_concept in the arguments of the controls which allow it.

3.4.3 Checks carried out by the supervisor on the concepts produced
·
Produced concept respecting the guiding principle:
The supervisor checks that the name of the produced concept is not already allotted by one of
preceding controls, in particular by an ordering of a preceding execution in
the case of one
CONTINUATION
or of a INCLUDE.
·
Concept used in re-use:
The supervisor checks that:
-
the name of the produced concept is already well allotted.
-
the operator is well entitled to accept re-used concepts,
-
the type of the concept is in conformity with the type of
concept
product
by the operator.
Examples with accompanying notes:
BEGINNING ()
concept=operator
(
)
#
(1)
is correct: one definite the concept,
concept=operator
(
)
#
(2)
is incorrect: one tries to redefine it
#
concept but without the statement,
concept=operator (reuse = concept) # (3)
is correct, if the operator accepts
#
existing concepts and if the type is
#
coherent; it is incorrect if the operator
#
does not accept them.
END ()
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
10/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
In fact a concept can be created only only once: what means to appear sign on the left
= (equal) without reuse is employed in the arguments of the control.
In the case of a re-use, to again specify the name of the concept behind the attribute
reuse
is
redundant; more especially as the supervisor checks that the two names of concept are identical.
Note:
One can destroy a concept, and thus re-use his name then.
3.5
Body of a control
3.5.1 Introduction
The body of a control contains the “variable” part of the control. The statements are
separated by commas and separately the attribute
reuse
mentioned above, they all are of the form:
[mot_clé]
=
[argument]
The key word is necessarily a key word of the pending order, declared in the catalog of
the aforementioned.
3.5.2 Word
key
A key word is a formal identifier, it is the name of the attribute receiving the argument.
Example:
STAMP
=…
Syntactic remarks:
·
the order of appearance of the key words is free, it is not imposed by the command of statement in
catalogs,
·
the key words cannot exceed 16 characters (but only the first 10 characters are
meaning).
There are two types of key words: single-ended spanner words and the key words factors which differ by
nature of their arguments.
3.5.3 Argument of a single-ended spanner word

3.5.3.1 The type of the arguments
The basic types recognized by the supervisor are:
· entireties,
· realities,
· complexes,
· texts,
· logics,
· concepts,
· as well as the lists of these types of bases.
The entireties and realities correspond exactly to the equivalent types in python.
·
Optional single-ended spanner word awaiting a reality:
Catalog
:
VALE
= SIMP (statut=' f', typ = “R”),
Command file
:
VALE = 10.
,
·
Optional single-ended spanner word awaiting an entirety:
Catalog
:
INFORMATION
= SIMP (statut=' f', typ = “I”),
Command file
:
INFORMATION = 1
,
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
11/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
The representation of the complex type is a “tuple” python containing a character string
indicating the mode of representation of the complex number (parts real and imaginary or modulates
phase) then numerical values.
Catalog
:
VALE_C = SIMP (statut=' f', typ = “It),
Command file
:
VALE_C = (“IH”, 0.732, - 0.732),
Command file
:
VALE_C = (“MP”, 1. , - 45. ),
The two notations are strictly equivalent. In notation
“MP”
, the phase is in degrees.
The text type is declared between simple dimensions. Breakage is respected. However, when a key word
must take a value in a preset list in the catalog, the use wants that this value is
today always in capitals.
Catalog
:
ALL
=SIMP (typ= `TXM', into= (“YES”, “NOT”)) ,
Command file
:
ALL
= “YES”,
Breakage is important and, in the context above, the line of following control will fail:
Command file
:
ALL
= “yes”,
The logical type is not used today in the catalog of controls.
The concept is declared simply by its name, without dimensions nor quotation marks.

3.5.3.2 Concept of list
Caution:
the word “list” is an abuse language here. It is not a question of the type “lists” python but rather
of tuples, within the meaning of python: different the items is declared between an opening bracket and
a closing bracket; they are separated by commas.
The lists are homogeneous lists, i.e. whose elements are of the same basic type. All
basic type can be used in list.
Examples of list:
list entireties
(1, 2, 3, 4),
list text
(“this”, “is”, “one”, “list”, “of”, “text”),
list concepts
(resu1, resu2, resu3),
Facility of employment:
It is allowed that a list reduced to an element can be described without bracket.
Example of erroneous list:
Heterogeneous list of entirety and reality
(1,
3,
4.)
3.5.4 Key word factor
Certain information cannot be given overall (in once in the control), it is
thus important to envisage the repetition of certain key words, to be able to affect arguments to them
different. The key word factor offers this possibility; under a key word factor, one will thus find one
together of key words (simple), which could be used with each occurrence of the key word factor.
That makes it possible moreover to improve the legibility of the command file by gathering key words which
shares a common direction: for example various parameters of the same material.
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
12/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
Contrary to the single-ended spanner word, the key word factor can receive one type of object: the object
supervisor “_F”, or a list of the aforementioned.
That is to say the key word factor has only one occurrence and one can write for example, with the choice:
IMPRESSION =
_F (
RESULT =
resu, UNIT = 6),
or
IMPRESSION = (_F (
RESULT =
resu, UNIT = 6),),
In the first case, the key word factor IMPRESSION receives a _F object, in the other, it receives one
singleton. Attention with the comma; in python, a tuple with an element is written: (element,)
That is to say the key word factor has several occurrences, two in this example:
IMPRESSION = (_F (
RESULT =
resu1, UNIT = 6),
_F (
RESULT =
resu2, UNIT = 7)
),
The number of occurrence (minimum and/or maximum) waited of a key word factor is defined in
catalog controls.
Concept of default value
It is possible to make affect by the supervisor of the default values. These values are defined
in the catalog of controls and not in
FORTRAN
.
There is no distinction from the point of view of the routine associated with the control between a value
provided by the user and a default value introduced by the supervisor. This appears at the time of
impression of the controls user by the supervisor in the file of messages: all them
default values appear in the text of control, if they were not provided by
the user
Recall: one cannot give default value to a concept.

4
Definition of values and evaluations of expressions
It is possible to assign values to variables python in order to use those like arguments
simple key words: these variables are called parameters in EFICAS. They can contain
values whole, real, complex, texts or lists of these types.
Example:
Young = 2.E+11
chechmate =
DEFI_MATERIAU
(ELAS = _F (E = Young, NAKED = 0.3))
At the end of the execution, the context python is backed up with the base. Thus, in the continuation which will follow,
the parameters will be always present, with their preset values, just like the concepts
ASTER.

It is possible to carry out operations in python on the simple arguments of key words:
Pisur2 =
pi/2.
chechmate
= MA_COMMANDE (VALE = Pisur2)
or:

VAr =
'
world'
chechmate = MA_COMMANDE (VALE =
pi/2.
,
VALE2
=
Pisur2+cos (30.)
,
TEXT = `hello'+var
)
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
13/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
5
Use of python in the command files
It is not necessary to know the language python to use Code_Aster. Indeed, realizing
some basic rules to respect on the indentation and parenthesizing, only the knowledge of
process control language describes in the catalogs of control is necessary. And still, EFICAS
allows to exempt itself to resort to the catalog or the paragraph “syntax” of the controls in
proposing the key words graphically to inform.
However, the advanced user will be able to use cheaply the power of the language PYTHON in sound
command file, since the aforementioned is already written in this language.
The four main uses can be: the writing of personalized macro-controls, the use
general instructions python, the importation of useful modules python, the recovery of information of
structures of Code_Aster data in variables PYTHON.
Note:
If one wants to use French characters accentuated in the command file or them
imported modules, it is necessary to place the following instruction in first or second line of
file:
# ­ * ­ coding: iso8859­1 ­ * ­
In python 2.3, the absence of this line causes a warning which will become an error in
python 2.4; in ASTER, it is systematically an error.

5.1 Macro-controls
personalized
See the document [D5.01.02]: To introduce a new macro-control
The personalized macro-controls are very easy to program. They can be used for
to capitalize recurring diagrams of calculation and thus to constitute a tool-trade. It is strongly
advised to take example on the existing macro-controls: macro package in bibpyt.

5.2
General instructions PYTHON and useful modules
The advanced users can benefit great from the use of loops (for), of tests (yew), of
exceptions (try, except) and in a general way of all the power of the language PYTHON
directly in their command file. The list of the uses is impossible to establish
exhaustively. Many examples are present in the cases tests of the base of tests. One can
for example to make adaptation of mesh while placing the sequence calculation/mending of meshes in one
loop, to establish a criterion of stop of the iterations by a test on a computed value.
Concerning the exceptions, only the errors of the <S> type are recoverable as an exception
in the command set. That authorizes for example “to try” a control then to begin again
hand if the aforementioned “plants” while raising this exception.
In a loop, if an already existing concept is recreated, it is necessary to think of destroying it as a preliminary by
order TO DESTROY.
The other various functionalities of python interesting for the user of Code_Aster can
to be:
·
the read-write on file,
·
numerical calculation (for example by using Numerical Python),
·
the call via the module bone with the language of script, and in particular the launching of a third code
(os.system)
·
the handling of character strings
·
the call to graphic modules (grace, gnuplot)
background image
Code_Aster
®
Version
7.4
Titrate:
Process control supervisor and language
Date:
07/04/05
Author (S):
C. DURAND
Key
:
U1.03.01-E
Page
:
14/14
Instruction manual
U1.0- booklet: Introduction to Code_Aster
HT-66/05/004/A
5.3
Recovery of computed values in variables PYTHON
To exploit the language PYTHON in its command file is not interesting that if one can
conditionally to launch actions according to what the code calculated.
Certain links exist between python and the structures of data calculated by the code and
present in memory JEVEUX. Others remain to be programmed; this is a field in
evolution and of future developments are awaited.
It is essential to understand that to recover calculated data requires that the instructions
involving their obtaining were indeed carried out as a preliminary. In other words, it is essential
to carry out the code in mode PAR_LOT=' NON' (key word of the control BEGINNING). Indeed, in it
case, it does not have there total analysis of the command file, but each instruction is carried out
sequentially. When one arrives on an instruction, all the concepts preceding thus have it already
summer calculated.
Here some access methods to the structures of data. The list is nonexhaustive, to refer to
documentation [U1.03.02].

Structure of data Method
Python type turned over turned over Information
listr8
LIST_VALEURS
list
List values
mesh
LIST_GROUP_NO
list
List groups of nodes
LIST_GROUP_MA
list
List groups of meshs
count
[...]
reality
Contents of the table
function
LISTE_VALEURS
list
List values
result
LIST_CHAMPS
list
List computed fields
LIST_NOM_CMP
list
List components
LIST_VARI_ACCES lists
List variables of access
LIST_PARA
list
List parameters
cham_no
EXTR_COMP
post_comp_cham_no
Contents of the field in a table
cham_elem
EXTR_COMP
post_comp_cham_el
Contents of the field in a table
Any object JEVEUX
getvectjev
list
List objects of the jeveux vector