By default, the script is applied to the current fortran unit. An experimental functionnality is being developped to go through all the tests.
SCRIPT test () // Initialize the list of units foo:=$forlib.INITALLUNITS($cunit) // Get the number of units nbunit := $forlib.NBUNIT cpt:=0 WHILE(cpt<nbunit) // Get the unit AST of rank 'cpt' unit := $forlib.FINDUNIT(cpt) IF (unit) THEN // ### Insert your code here. // ### Example: PRINT "FILE="+unit.FILENAME ENDIF cpt:=cpt+1 ENDWHILE) ENDSCRIPT
You must follow the following rules so that your script works:
// Get the name of the unit (i.e. a string) unit_name := unit.SYMBOL // Get the corresponding entry in the table // of declarations of the unit unit_entry := unit.SYMBOL(unit_name) // Get the declared nature of the unit unit_type := unit_entry.TYPEOFSYMBOL // Restrict the actions to some kinds of units IF ( (unit_type=="subroutine") OR (unit_type=="function")) THEN ... ENDIF
- Do not use a simple string such as "X" to describe a fortran object X. By default, the declaration is taken in the current unit (i.e. $cunit). The structure that associate the object X to the unit is given by unit.SYMBOL("X").