We now understand that the user has to write a Fortran subroutine or a C function to call a problem that requires a user-supplied function. For now, the prototype of this subroutine/function can be found in the description of the problem, available from Matlab or the CGI scripts of the NetSolve homepage (see the section called Problems that can be solved with NetSolve in Chapter 4). Following the usual philosophy of NetSolve, the prototype of the user-supplied function is exactly the same as if the user were using the numerical software directly. Some softwares require the user to provide more than one function. When that is the case, the description of the problem mentions it and gives all the prototypes for all the functions to supply.
A UPF is passed to NetSolve as a string that contains the path to the file that contains the source code of the function.
Users of the NetSolve API may specify a UPF input item as they would any other input item, using the pushArg() method. However, an extra argument is required when pushing a UPF item: the language that the UPF is written in. For example:
n.pushArg(new String(upf0,0),GlobalDefs.LANG_FORTRAN); n.pushArg(new String(upf1,0),GlobalDefs.LANG_C); |
Entering a user-supplied function via the Java interface is very much similar to entering any other kind of data. If the problem requires a user-supplied function, there will be an entry in the Input List called ``User Provided Function'' for which data must be specified, just like any other input object. The user may choose to enter the user-supplied function manually into the Data Input Box or from a file specified in the Filename Selection Box. If the user enters the function manually, the language must also be specified by choosing either C or FORTRAN from an ``option menu'' that appears just above the Data Input Box. If the user-supplied function comes from a file, the file must end with either ``.c'' or ``.f'' (with names ending in ``.c'' interpreted as C functions and names ending in ``.f'' interpreted as FORTRAN functions).