pyccel.codegen.printing.fcode module#
Print to F90 standard. Trying to follow the information provided at www.fortran90.org as much as possible.
- class pyccel.codegen.printing.fcode.FCodePrinter(filename, *, verbose, prefix_module=None)[source]#
Bases:
CodePrinter
A printer for printing code in Fortran.
A printer to convert Pyccel’s AST to strings of Fortran code. As for all printers the navigation of this file is done via _print_X functions.
- Parameters:
filename (str) – The name of the file being pyccelised.
verbose (int) – The level of verbosity.
prefix_module (str) – A prefix to be added to the name of the module.
- function_signature(expr, name)[source]#
Get the different parts of the signature of the function expr.
A helper function to print just the signature of the function including the declarations of the arguments and results.
- Parameters:
expr (FunctionDef) – The function whose signature should be printed.
name (str) – The name which should be printed as the name of the function. (May be different from expr.name in the case of interfaces).
- Returns:
- A dictionary with the keys :
sig - The declaration of the function/subroutine with any necessary keywords. arg_code - A string containing a list of the arguments. func_end - Any code to be added to the signature after the arguments (ie result). arg_decs - The code necessary to declare the arguments of the function/subroutine. func_type - Subroutine or function.
- Return type:
dict
- indent_code(code)[source]#
Add the correct indentation to the code.
Analyse the code to calculate when indentation is needed. Add the necessary spaces at the start of each line.
- Parameters:
code (str | iterable[str]) – A string of code or a list of code lines.
- Returns:
A list of indented code lines.
- Return type:
list[str]
- language = 'Fortran'#
- print_constant_imports()[source]#
Print the import of constant intrinsics.
Print the import of constants such as C_INT from an intrinsic module (i.e. a module provided by Fortran) such as iso_c_binding.
- Returns:
The code describing the import of the intrinsics.
- Return type:
str
- print_kind(expr)[source]#
Print the kind(precision) of a literal value or its shortcut if possible.
Print the kind(precision) of a literal value or its shortcut if possible.
- Parameters:
expr (TypedAstNode | PyccelType) – The object whose precision should be investigated.
- Returns:
The code for the kind parameter.
- Return type:
str
- printmethod = '_fcode'#