sic_python.c File Reference

Provide functions to interact with Python interpreter from SIC. More...

Include dependency graph for sic_python.c:

Go to the source code of this file.

Defines

#define pyend   CFC_EXPORT_NAME( pyend )
#define pyexecfile   CFC_EXPORT_NAME( pyexecfile )
#define pyexec   CFC_EXPORT_NAME( pyexec )
#define pyinteract   CFC_EXPORT_NAME( pyinteract )
#define pyfindfunc   CFC_EXPORT_NAME( pyfindfunc )
#define pycallfuncd   CFC_EXPORT_NAME( pycallfuncd )
#define pycallfuncs   CFC_EXPORT_NAME( pycallfuncs )
#define pygetvar   CFC_EXPORT_NAME( pygetvar )
#define pydelvar   CFC_EXPORT_NAME( pydelvar )

Functions

int CFC_API pyend ()
 Finalize Python if it is already initialized.
int CFC_API pyexecfile (CFC_FString name, int *ln, CFC_FString args, int *la)
 Interprets the input Python file.
int CFC_API pyexec (CFC_FString command, int *l)
 Interpret a single Python command line.
int CFC_API pyinteract (int *sic_code_end, int *sic_ocode)
 Jump to Python prompt.
int CFC_API pyfindfunc (CFC_FString fname, int *l)
 Look for a function in Python __main__.
int CFC_API pycallfuncd (int *nargs, int *index, int strides[], int nwords[], double mem[], double *output)
 Call a Python function with double precision.
int CFC_API pycallfuncs (int *nargs, int *index, int strides[], int nwords[], float mem[], float *output)
 Call a Python function with single precision.
int CFC_API pygetvar (CFC_FString varname, int *l)
 Import variable into Python __main__ given the SIC name.
int CFC_API pydelvar (CFC_FString varname, int *l)
 Delete variable in Python given the SIC name.


Detailed Description

Provide functions to interact with Python interpreter from SIC.

Definition in file sic_python.c.


Define Documentation

#define pycallfuncd   CFC_EXPORT_NAME( pycallfuncd )

Definition at line 21 of file sic_python.c.

#define pycallfuncs   CFC_EXPORT_NAME( pycallfuncs )

Definition at line 22 of file sic_python.c.

#define pydelvar   CFC_EXPORT_NAME( pydelvar )

Definition at line 24 of file sic_python.c.

#define pyend   CFC_EXPORT_NAME( pyend )

Definition at line 16 of file sic_python.c.

#define pyexec   CFC_EXPORT_NAME( pyexec )

Definition at line 18 of file sic_python.c.

#define pyexecfile   CFC_EXPORT_NAME( pyexecfile )

Definition at line 17 of file sic_python.c.

#define pyfindfunc   CFC_EXPORT_NAME( pyfindfunc )

Definition at line 20 of file sic_python.c.

#define pygetvar   CFC_EXPORT_NAME( pygetvar )

Definition at line 23 of file sic_python.c.

#define pyinteract   CFC_EXPORT_NAME( pyinteract )

Definition at line 19 of file sic_python.c.


Function Documentation

int CFC_API pycallfuncd ( int *  nargs,
int *  index,
int  strides[],
int  nwords[],
double  mem[],
double *  output 
)

Call a Python function with double precision.

To be callable on any SIC scalar or array, number of elements, strides and size of 'words' are given as input arguments. Output is a scalar as any SIC function.

Parameters:
[in] nargs is the number of operands.
[in] index is the number element of the output array that is computed.
[in] strides is an array of strides to access in memory elements of the input operands.
[in] nwords is the memory location for each operand.
[in] mem is the reference address.
[out] output is the ouput value.
Returns:
0 on success, 1 otherwise.

Definition at line 629 of file sic_python.c.

int CFC_API pycallfuncs ( int *  nargs,
int *  index,
int  strides[],
int  nwords[],
float  mem[],
float *  output 
)

Call a Python function with single precision.

To be callable on any SIC scalar or array, number of elements, strides and size of 'words' are given as input arguments. Output is a scalar as any SIC function.

Parameters:
[in] nargs is the number of operands.
[in] index is the number element of the output array that is computed.
[in] strides is an array of strides to access in memory elements of the input operands.
[in] nwords is the memory location for each operand.
[in] mem is the reference address.
[out] output is the ouput value.
Returns:
0 on success, 1 otherwise.

Definition at line 682 of file sic_python.c.

int CFC_API pydelvar ( CFC_FString  varname,
int *  l 
)

Delete variable in Python given the SIC name.

Given the SIC name, compute references to the PyObject and its parent, and delete the PyObject. Additionaly, check the 'Sic.localspaces' array and move back an upper-level variable which has the same name, if any.

Parameters:
[in] varname is the full name of the variable.
[in] l is the Fortran length of its name.
Returns:
0 on success, 1 otherwise.

Definition at line 770 of file sic_python.c.

References CFC_f2c_strcpy(), and CFC_f2c_string().

Here is the call graph for this function:

int CFC_API pyend (  ) 

Finalize Python if it is already initialized.

If Python is already initialized, it first deactivates the 'atexit' call. Then Python is Py_Finalize'd and a system exit() is done depending on the master or slave status of Python.

Returns:
0 if not exit.

Definition at line 350 of file sic_python.c.

int CFC_API pyexec ( CFC_FString  command,
int *  l 
)

Interpret a single Python command line.

The input command line is interpreted in the __main__ name area (scope). The carriage return is mandatory at the end of the string to be executed by PyRun_SimpleString. Print the command line if the 'sic.verify' ('SICVERIFY') flag is on, and add it to Python prompt history.

Parameters:
[in] command is the Python command line.
[in] l is the Fortran length of the command line.
Returns:
0.

Definition at line 471 of file sic_python.c.

References CFC_f2c_strcpy().

Here is the call graph for this function:

int CFC_API pyexecfile ( CFC_FString  name,
int *  ln,
CFC_FString  args,
int *  la 
)

Interprets the input Python file.

The input file is interpreted in the __main__ name area (scope). Depending on the 'sic.verify' ('SICVERIFY') flag value, PyRun_SimpleFile (no prints) or 'pexecfile' (custom Python 'execfile' with prints) is called.

Parameters:
[in] name is the Python file name with full path.
[in] ln is the Fortran length of this name.
[in] args is a string with file name and its args.
[in] la is the Fortran length of this string.
Returns:
0.

Definition at line 378 of file sic_python.c.

References CFC_f2c_strcpy().

Here is the call graph for this function:

int CFC_API pyfindfunc ( CFC_FString  fname,
int *  l 
)

Look for a function in Python __main__.

Check if the input object exists in Python __main__ and is callable. If yes, adds a reference named 'Sic.pyfunc' to this function/method.

Parameters:
[in] fname is the function name.
[out] l is the Fortran length of the name.
Returns:
0 on success, 1 otherwise.

Definition at line 569 of file sic_python.c.

References CFC_f2c_strcpy().

Here is the call graph for this function:

int CFC_API pygetvar ( CFC_FString  varname,
int *  l 
)

Import variable into Python __main__ given the SIC name.

Parameters:
[in] varname is the name of the variable.
[in] l is the Fortran length of the string.
Returns:
0 on success, 1 otherwise.

Definition at line 725 of file sic_python.c.

References CFC_f2c_strcpy(), and CFC_f2c_string().

Here is the call graph for this function:

int CFC_API pyinteract ( int *  sic_code_end,
int *  sic_ocode 
)

Jump to Python prompt.

Depending on the slave or master status of Python, this function calls the customized local InteractiveLoop to interact with the Python interpreter started in background, or it return's at once after changing the 'ocode' value.

Parameters:
[in] sic_code_end is the CODE_END Fortran value.
[out] sic_ocode is the OCODE Fortran code.
Returns:
0 on success, 1 otherwise.

Definition at line 531 of file sic_python.c.

References sic_push_command_text().

Here is the call graph for this function:


Generated on Tue Mar 13 15:21:30 2007 for SIC by  doxygen 1.5.1