Code - Aster: Process Control Supervisor and Language
Code - Aster: Process Control Supervisor and Language
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 1/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
Summary:
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 2/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
Contents
1 Introduction........................................................................................................................................... 3
2 Mechanism general of operation of the supervisor..............................................................................3
2.1 General architecture...................................................................................................................... 3
2.2 Total execution or step by step....................................................................................................... 4
2.3 The construction of the stages....................................................................................................... 4
2.4 Treatment of the macro-orders ..................................................................................................... 5
2.5 Procedures of starting.................................................................................................................... 5
2.6 Links with EFICAS......................................................................................................................... 6
3 The process control language............................................................................................................... 6
3.1 Python and the language process control......................................................................................6
3.2 Concept of concept........................................................................................................................ 7
3.3 Possible operations........................................................................................................................ 7
3.4 Rules on the concept produced by an operator.............................................................................8
3.4.1 Basic principle...................................................................................................................... 8
3.4.2 Concept produces and re-used concept...............................................................................8
3.4.3 Checks carried out by the supervisor on the concepts produced.........................................8
3.5 Body of an order............................................................................................................................ 9
3.5.1 Introduction........................................................................................................................... 9
3.5.2 Keyword................................................................................................................................ 9
3.5.3 Argument of a simple keyword............................................................................................. 9
3.5.3.1 The type of the arguments........................................................................................ 9
3.5.3.2 Concept of list......................................................................................................... 10
3.5.4 Keyword factor.................................................................................................................... 10
4 Definition of values and evaluations of expressions...........................................................................11
5 Use of python in the command files................................................................................................... 12
5.1 personalized Macro-orders.......................................................................................................... 12
5.2 General instructions PYTHON and useful modules.....................................................................12
5.3 Exceptions PYTHON of the module aster...................................................................................12
5.3.1 Interception of the <S> errors............................................................................................. 13
5.3.2 Interception of the <F>atales errors...................................................................................13
5.3.3 Validity of the concepts in the event of lifting of exception.................................................14
5.3.4 Precautions for use of the exceptions................................................................................14
5.4 Recovery of computed values in variables PYTHON..................................................................14
5.5 Dynamic example of construction of keywords factors................................................................16
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 3/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
1 Introduction
The role of the supervisor is to ensure the command of the course of operations in the course 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 owner, it is it process control
language.
The language Python is employed to write the catalogue of orders, the supervisor and the command
files 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 (orders), defined in the catalogue of orders.
These functions have arguments of entry: keywords and their contents, and of the arguments of exit:
produced concepts. The user who composes his command file must thus subject himself to the
general syntax of Python (parenthesizing, indentation…) and with the rules imposed by the catalogue
of orders (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.
Object JDC (name for Command set) is a python object created by the SUPERVISORY object starting
from the text of the command file and of the module catalogues orders. It contains the STAGE
objects. Object JDC is representative of the command file user.
The STAGE objects are representative of each call to orders Aster in the command file. Each STAGE
object is called after the order that it reference, the list of the active keywords and their values, the
type and the name of the produced concept.
Construction then the execution of object JDC start the following actions:
• syntactic analysis of the command file user: it is on this level that syntax python is checked
(brackets, commas between keywords, indentation…). The detection of an error
(SyntaxError Python) cause the stop of the execution of Aster. The first error is fatal: one
does not search the following errors,
• construction of the stages: that consists in creating a STAGE object for each call to an order
Aster in the command file. This object is recorded at JDC which manages the list of the
stages and the related concepts,
• checking of each STAGE: if the call to an order in the file user is incoherent with the
catalogue of orders, a report is displayed and the execution is stopped on this level. It is the
semantic checking,
• execution itself of the orders: for each stage taken in the order, call to high level routine
FORTRAN (op0nnn.f) corresponding.
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 4/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
• 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 keyword 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 the keyword PAR_LOT=' NON' in the order BEGINNING.
If the user does not specify anything in the order starting, total mode ( PAR_LOT=' OUI') is retained.
These two modes present each one their advantages and disadvantages.
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 indeed a shame to stop in fatal error after a
long resolution because of a keyword forgotten in an order of postprocessing.
That also means that all the stages of the command set are built and stored. If several thousands of
stages are reached, that can become very consuming memory and this mode is not then advised any
more.
The mode step by step builds a stage only after having carried out the preceding one. It thus detects
only the semantic errors of the pending order and presents the disadvantage described above. It
however makes it possible to exploit a result calculated (in a concept) in the command file for, for
example, to place conditional instructions there.
In this mode, the stage carried out is released at once from the memory. The memory used is then
independent amongst stage to carry out.
Here an example of loop with a criterion of stop on the value of a calculated size, stored in the
concept of the type table : RELV [K]. If for example an obligatory keyword 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 the variable SYY
since the concept RELV [K] was completely calculated at the time when the supervisor carries out
this line.
BEGINNING (PAR_LOT=' NON')
END ()
It should be noted that the choice of a procedure conditions the order 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 orders
ASTER, without other instructions python; this independently of the mode PAR_LOT chosen.
During the construction of each STAGE object, one checks his semantic coherence with the catalogue
of the order to which it refers. Any detected error is consigned in a report which, in total procedure, is
delivered after the analysis of all the command file.
It is important to note that the phase of construction of the macro-orders proceeds right before 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-order itself, but not that of its under - orders.
• One can on the other hand exploit, in the programming of the macros, the data previously
calculated and repatriated within the space of names python, without having to impose the mode
PAR_LOT=' NON' with the user the macro one.
The first task consists in putting in correspondence numbers of logical units of standard files of
input/output (message, error, result).
The second task consists to define and open the databases (file of direct access 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] the Manager of memory, JEVEUX).
The sequence of the orders to be carried out ends obligatorily in the order END. The text which follows
END must be commentarized (i.e. begin with #). For a file included, it is the order RETURN who marks
the end of the instructions that ASTER must take into account.
Note:
In interactive mode, seizure of the manual controls, not to put of order END and to pass the
argument – interact on the command line of tender of the job.
A command file can contain instructions python of two natures: orders Aster and… any other
instruction python. Indeed, a command file is a program python except for whole and one can place in
particular there structures of control (loops), tests (yew), digital calculations, calls to functions the pre
one and postprocessing.
Within the framework of a “classical” use of the code where the command file contains orders Aster
exclusively, the two rules specific to Python to be retained are:
• Arguments of the functions, in other words the keywords of the orders, are separated by
commas; they are composed of a keyword, sign “=”, contents of the keyword.
Important:
Editor EFICAS allows to produce only command files of this type: containing exclusively orders
ASTER, without another instruction Python. To use EFICAS guarantees primarily three things:
The user having composed his command file will thus be safe from a stop with the execution with the
reason for a problem of syntax.
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 7/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
The concept of concept thus makes it possible to the user to handle objects symbolically and
independently of their internal representation (which it can not know). Moreover, the python object
indicated by the name of the concept does not contain any other information but its type, its class with
the direction python (cf Doc. D). Its name, transmitted by the supervisor to FORTRAN, makes it
possible Aster to find the corresponding structure of data in the total base. But it is not possible to
have visibility of the structure of data since the command file. For example, the following instructions
do not make it possible to print the structure of data of the type grid and of name e-mail :
mail=LIRE_MAILLAGE ()
print e-mail
There is an exception to this rule: tables. Indeed, an artifice of programming makes it possible to
simply recover contained information in structure of data TABLE by handling this one like a table
at two entries:
That supposes of course that the structure of data resu, of type TABLE, was already calculated at the
time when this instruction is met: thus in procedure step by step (PAR_LOT=' NON').
Notice lexical:
The names of concepts should not exceed 8 characters. The alphanumerics are licit (small letters and
capital and figures not placed in first position) as well as the underscore ‘_’. Breakage is important: the
concepts “E-MAIL” and “E-mail” could be used in the same command file and will be regarded as
different… it however is disadvised for the legibility of the file!
• 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-order which generates a sequence of instructions of the two preceding types and
which can produce zero, one or more concepts.
From the syntactic point of view an operator presents himself in the form:
nomconcept = operator (arguments…)
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 8/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
The concepts appearing in argument of entry of the orders, are not modified.
• authorization given, by the catalogue and the programming of the order, to use reusable
concepts for the operator: the attribute reentrant catalogue 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 orders which allow it.
BEGINNING ()
concept=operator () # (1) is correct: one definite the concept,
concept=operator () # (2) is incorrect: one tries to redefine it
# concept but without saying it,
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 ()
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 9/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
In fact a concept can be created only once: what means to appear sign on the left = (equal) without
reuse that is to say employed in the arguments of the order.
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.2 Keyword
A keyword is a formal identifier, it is the name of the attribute receiving the argument.
Example: MATRIX =…
Syntactic remarks:
• the order of appearance of the keywords is free, it is not imposed by the order of declaration
in the catalogues,
• the keywords cannot exceed 16 characters (but only the first 10 characters are meaning).
There exist two types of keywords: simple keywords and the keywords factors which differ by nature
from their arguments.
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 10/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
The representation of the complex type is a “tuple” python containing a character string indicating the
mode of representation of the complex number (left real and imaginary or module-phase) then the
digital values.
The two notations are strictly equivalent. In notation ‘MP’, the phase is in degrees.
The standard text is declared between simple dimensions. Breakage is respected. However, when a
keyword must take a value in a preset list in the catalogue, the use wants that this value is today
always in capitals.
Breakage is important and, in the context above, the following command line will fail:
The concept is declared simply by its name, without dimensions nor quotation marks.
Caution :
The word “list” is an abuse language here. It is not 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. Any basic type can
be used in list.
Examples of list:
list of entireties (1, 2,3,4),
list of text (‘this’, ‘is’, ‘one’, ‘list’, ‘of’, ‘text’),
list of concepts (resu1, resu2, resu3),
User friendliness:
It is allowed that a list reduced to an element can be described without bracket.
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 11/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
Contrary to the simple keyword, the keyword factor can receive one type of object: the supervisory
object “ _F ”, or a list of this one.
That is to say the keyword 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 keyword factor IMPRESSION receives an object _F, in the other, it receives a
singleton. Attention with the comma; in python, a tuple with an element is written: (element,)
That is to say the keyword 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) expected of a keyword factor is defined in the
catalogue of orders.
Concept of value by default
It is possible to make affect by the supervisor of the values by default. These values are defined in the
catalogue of orders and not in FORTRAN.
There is no distinction from the point of view of the routine associated with the order between a value
provided by the user and a value by default introduced by the supervisor. This appears during the
impression of the orders user by the supervisor in the file of messages: all the values by default
appear in the text of order, if they were not provided by the user
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 saved 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.
Pisur2 = pi/2.
chechmate = MA_COMMANDE (VALE = Pisur2)
or:
VAr = ‘world’
chechmate = MA_COMMANDE ( VALE = pi/2. ,
VALE2 = Pisur2+cos (30.),
TEXT = ‘hello’ +var )
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 12/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
However, the advanced user will be able to use cheaply the power of the language PYTHON in his
command file, since this one is already written in this language.
The four principal uses can be: the writing of personalized macro-orders, the use of general
instructions python, the importation of useful modules python, the recovery of information of the
structures of data Code_Aster in variables PYTHON.
Note:
If one wants to use French characters accentuated in the command file or the modules
imported, it is necessary to place the following instruction in first or second-row forward of
the file:
# – * – coding: Iso-8859-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.
Other various features of python interesting for the user of Code_Aster can be:
• the read-write on file,
• digital 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)
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 13/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
The mechanism of the exceptions Python is very interesting, it authorizes for example “to try” an order
then to take again the hand if this one “plants” while raising a particular exception:
try:
block of instructions
except ErreurIdentifiée, message:
block of instructions carried out if ErreurIdentifiée occurs…
In the command file, one can use this mechanism with any exception of the modules Python
standards.
One also has exceptions suitable for Code_Aster (with the module aster), divided into two
categories, the exceptions associated with the errors <S>, and that associated with the errors <F>.
All these exceptions derive from the exception <S> general which is aster.error. What means that
except aster.error intercept all the exceptions quoted below. It is nevertheless always preferable
to specify with what a error one expects!
Example of use:
try:
resu = STAT_NON_LINE (...)
except aster.NonConvergenceError, message:
print ‘Stop for this reason: %s’ % str (message)
# One knows that one needs much more iterations to converge
print “One continues by increasing the iteration count.”
resu = STAT_NON_LINE (reuse = resu,
…,
CONVERGENCE=_F (ITER_GLOB_MAXI=400,),)
except aster.error, message:
print “Another error occurred: %s” % str (message)
print “Stop”
from Utilitai.Utmess importation UTMESS
UTMESS (‘F’, ‘Example’, ‘unexpected <S> Error’)
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 14/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
The latter called without argument turns over the current behavior in the event of fatal error:
comport = aster.onFatalError ()
print “Behavior running in the event of fatal error: %s” % comport
and allows to define the behavior which one wishes:
aster.onFatalError (‘EXCEPTION’) # one raises the exception FatalError
or
aster.onFatalError (‘ABORT’) # one stops with increase of error.
In the event of error <S> liftings in STAT/DYNA_NON_LINE, the concept is generally valid, and can be
re-used (keyword reuse) to continue calculation with another strategy (as in the example quoted
previously).
Lastly, before returning the hand to the user, the objects of the volatile base are removed by a call to
JEDETV, and Jeveux marks it is repositioned to 1 (with JEDEMA) to release the objects brought back in
memory.
• it is necessary to activate the lifting of exception in the event of <F> error with
aster.FatalError (‘EXCEPTION’) or in BEGINNING/CONTINUATION.
• the two exceptions should be intercepted:
except (aster.FatalError, aster.error), message: …
It is disadvised using “ except: ” without specifying with which exception one expects (it is a general
rule in Python independently of the exceptions Aster). Indeed, treatment carried out underexcept little
chance has to be valid in all the cases of error.
In the same way, as in the example set higher, it is preferable to use the particularized exceptions
NonConvergenceError, ArretCPUError,… that exception moreover high level aster.error ;
always in the idea of knowing exactly what occurred.
Certain footbridges 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 future
developments are expected.
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' (keyword of the order BEGINNING). Indeed, in this case, there is no total
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 15/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
analysis of the command file, but each instruction is carried out sequentially. When one arrives on an
instruction, all the concepts it preceding were thus already calculated.
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)
Version
Code_Aster default
Titre : Superviseur et langage de commande Date : 08/05/2012 Page : 16/16
Responsable : COURTOIS Mathieu Clé : U1.03.01 Révision :
54d5d0ce0986
Here some access methods to the structures of data. The list is nonexhaustive, to refer to
documentation [U1.03.02].
li1=DEFI_LISTE_REEL ( DEBUT=0.,
INTERVALLE=ooo
/ or
INTERVALLE=ppp
/ or
INTERVALLE=rrr
)
END ()
Warning : The translation process used on this website is a "Machine Translation". It may be imprecise and inaccurate in whole or in part and is
provided as a convenience.
Copyright 2017 EDF R&D - Licensed under the terms of the GNU FDL (http://www.gnu.org/copyleft/fdl.html)