c-----------------------------------------------------------------------
c
c.....(c) Victor Luana Cabal, Nov. 8, 1991, 1992, 1993.
c Grupo de Quimica Cuantica
c Departamento de Quimica Fisica y Analitica
c Universidad de Oviedo, 33007-Oviedo, Spain.
c
c-----------------------------------------------------------------------
c
c HISTORY:
c
c First version (1.0): (Nov. 8, 1991) VLC
c
c Rel. 1.1: (Sep. 4, 1992) VLC
c Dater routine added.
c Optional parities of the function incorporated to the 2nd order
c derivatives.
c
c Rel. 1.2: (Apr. 5, 1993) VLC
c hinic values are specific fot each variable. The input file is
c slightly modified.
c
c-----------------------------------------------------------------------
c
c.....derive - Numerical computation of second derivatives of an
c arbitrary analytical function computed by means of an external
c procedure. Derive has been designed as a driver program working
c in unix environments. The programs performs system calls to run
c the external procedure, mechanism that adds some time to the
c computation, but represents a very flexible method easily adapted
c to many different tasks.
c
c.....Mechanism for using derive:
c
c (derive data) ----> DERIVE ----> EXTERNAL_PROCEDURE
c ^ |
c | |
c | v
c (file with the function value)
c
c Derive transmits the variable values as parameters to the
c external procedure. This procedure returns the final function
c value as the only result contained in a file. The internal design
c of the external procedure is arbitrary from the derive viewpoint.
c
c-----------------------------------------------------------------------
c
c.....How to use derive: derive [input [output]]
c
c Input is read from stdin when a file name is not given as the
c first parameter. Output is send to the stdout when a file name
c is not given as the second parameter.
c
c-----------------------------------------------------------------------
c
c.....Input data:
c
c Rec #1 (*) : Function_name
c Name of the external procedure that evaluates the function to
c derive.
c
c Rec #2 (*) : File_name
c File where the external procedure prints the function value.
c
c Rec #3 (*) : nvar
c Total number of variables.
c
c DO I = 1, nvar
c Rec #4.i (*) : var_name(i), var_value(i), hinic(i)
c ENDDO
c Name and initial value of the variables. The derivatives will be
c computed with respect to this point. The hinic() represent the
c initial step h used in the derivative algorithm. The initial step
c does not need to be a very small quantity, it is rather
c preferible to use an interval such that the function changes
c appreciably its value.
c
c Rec #5 (*) : prec
c precision required in the calculation of the derivatives.
c
c Rec #6.x (*) : iord, (ivar(i), i = 1, iord)
c Iord establishes the order of the derivative (i.e. 1 for first
c derivatives, 2 for second ones, ...), and the IVAR() indicates
c what are the variables with respect to which the derivative will
c be obtained.
c In the case of second derivatives, when the indices of the
c variables are entered as "NEGATIVE NUMBERS", the following
c symmetries will be assumed in order to reduce the cpu:
c (a) Direct second derivative: FUNC(x+h) = FUNC(x-h)
c (b) Crossed 2nd derivative: FUNC2(x+h1,y+h2) = FUNC2(x-h1,y-h2)
c and: FUNC2(x-h1,y+h2) = FUNC2(x+h1,y-h2)
c This line is repeated for every derivative required.
c
c-----------------------------------------------------------------------
c
c.....Requirements of the external procedure:
c
c The function to derive is supossed to be evaluated by an external
c procedure, which will be run in a subshell by means of the order:
c
c Function_name var_value(1) var_value(2) ... var_value(nvar)
c
c This procedure should print the function value (and only that) in
c a file called File_name, with arbitrary precision. It should be
c understood that the precision used to evaluate the function will
c influence the maximum precision attainable in the derivatives.
c
c-----------------------------------------------------------------------