Here is a template to write a user defined function:
C+
C.NAME
C USER0i
C
C.DESCRIPTION
C ...
C
C.INPUT ARGUMENTS:
C NIND INTEGER Number of independent variables
C X (NIND) REAL Array of NIND elements with the
C independent variable
C NPAR INTEGER Number of parameters
C PARAM (NPAR) DOUBLE PRECISION Array of NPAR elements with the
C values of the parameters
C
C.OUTPUT ARGUMENTS:
C Y DOUBLE PRECISION Value of the function
C DERIV (NPAR) DOUBLE PRECISION Array of NPAR elements with the
C partial derivatives of the
C function for each parameter
C-
SUBROUTINE USER0i(NIND,X,NPAR,PARAM,Y,DERIV)
IMPLICIT NONE
C ..
C .. Scalar Arguments ..
INTEGER NIND,NPAR
DOUBLE PRECISION Y
C ..
C .. Array Arguments ..
REAL X(NIND)
DOUBLE PRECISION DERIV(NPAR),PARAM(NPAR)
C ..
C .. Local Scalars ..
C ..
C .. Local Arrays ..
C ..
C .. Executable Statements
RETURN
END
The variable Y must contain the value of the basic function at the
parameter value PARAM and the array DERIV has to receive the value
of the partial derivatives, except if the method used is CGNND
(the abbreviation of Corrected Gauss-Newton No Derivative).
In the user functions, it is recommended to scale the parameters in
such a way that their absolute values lies in a small scale range
let us say in [0.1 +10.].
It is advised to use this scheme to test and debug new functions
that can later on be included in the system supported set.