Module()

Manage the dynamic loading and execution of user written C or FORTRAN code.

MODULE/COMPILE
[/C]
file=String [comp_flags=String] [link_flags=String] [symbols=String] Compile a user written module
MODULE/LOAD file=String [desc=String] (Re-) load the routine into memory
MODULE/EXECUTE
[/C]
func=String pars=Workspace Run a loaded module
MODULE/LIST   Show loaded modules

example:

	# Compile a convolution module, load then run it on a 2-D workspace
	>> Module/Compile "conv.for" comp_flags="/check=all" symbols="conv_sub"
	>> Module/Load "conv.so"
	>> w1 = get(1:30)
	>> w2 = Module:Execute("conv_sub", w1)

Note: A compiled module only needs loading once per Open GENIE session.

Module/Compile

Open GENIE looks after the details of compiling a dynamically loadable program module whatever system it is running on. This greatly simplifies what on some systems is quite a complex process. The end result of the compilation of either a C or FORTRAN program is a dynamically loadable library which can contain one or more subroutines callable by Open GENIE once the module has been loaded.

The Compiled module may be written in FORTRAN or C and needs to adhere to a simple set of conventions to ensure its correct communication with the running Open GENIE. The structure of a module and the facilities available to it are described in the FORTRAN Module Interface and the C Module Interface sections of this manual.

Parameters:

/C

Invoke the C compiler instead of the FORTRAN compiler (the default).

File (String)

The name of the FORTRAN or C source file (including the .f, .c, or .for part of the filename). The compilation will produce a shareable library of the same file name but with the file extension of ".so" for the dynamic library. Once created, this can be kept and used with the Module/Load command.

Comp_flags (String) [ default = "" ]

This string takes any compiler flags or switches which may be needed by your program. Open GENIE already will have already added anything that is needed for compiling modules.

Link_flags (String) [ default = "" ]

This string takes any linking flags or switches which may be needed to link the compiled code. Open GENIE will have already added all the flags needed to build a shareable library.

Symbols (String) [ default = "" ]

This is a comma separated list of the subroutine or C function names which you want open GENIE to be able to call from your module when you run a loaded module. This parameter supplies all the names you can use when specifying the "func" parameter in the Module/Execute command.

Note that if you do not list a name here, on most operating systems, the Module/Execute command will not be able to find your subroutine in the dynamic library and you will get an error.

Module/Load

The Module/Load command takes an existing compiled shareable module library and activates it into Open GENIE so that the routines in the module may be called. This only needs to be done once for any module file in an Open GENIE session. From then on it is possible to call routines within the module using the Module/Execute command. It is possible to check which modules are loaded with the Module/List command.

Parameters:

File (String)

The full filename of the shareable library module to be loaded (it will always be a file ending in ".so").

Desc (String) [ default = "<no description>" ]

An optional description string. This is useful when several different modules are being used to identify their function. The description is show when using the Module/List command.

Module/Execute

This command runs a subroutine or C function from within a user written module. Open GENIE's advanced data access mechanism means that complex data can easily be transferred to and from a user written program without complex programming on the part of the user. The Module/Execute command can be called either as a function ( x = Module:Execute(...) ) or as a keyword command ( Module/Execute ... ). When called as a function a workspace is returned which may contain complex multi-dimensional data and/or simple strings and individual parameters.

Parameters:

Func (String)

The name of the subroutine or C function in the compiled module to call.

Pars (Workspace)

A workspace containing all the information for the external routine to process. This may be a workspace assembled just to package a few parameters and a data array needed by the external routine or it can be a complete n-dimensional workspace as read in by Open GENIE from data file (see the example above). See the sections on C Module Interface or FORTRAN Module Interface for details about the method of communicating parameters with the shareable library.

RESULT = (Workspace)

Contains the workspace given in the "Pars" parameter but as modified by the external subroutine.

Module/List

Lists all the currently loaded user written modules.