I need some help. I will try to summarize this as briefly as I

can. I am about to pull my hair about this problem.

Goal: Minimize f(x) with nonlinear constraints on x. [x is x(n)]

I am using a package called npsol to do the minimization. Here's the

deal. The package npsol is a minimizer that solves the above type

of problem. npsol needs two external functions, OBJFUN (the objective

function to minimize-- "f" in the goal above), and CONFUN, a

constraint function which calculates a vector c(x) which are

the values of the nonlinear constraints. OBJFUN must look like this

SUBROUTINE OBJFUN(X,N,OBJF,...)

DOUBLE PRECISION X(n)

DOUBLE PRECISION OBJF

x is the vector, n is the size of the vector, and objf

is a variable which is given the value of f(x) for this

particular x.

Now I also have a common block in the subroutine OBJFUN because I need

to use some data (which varies) to calculate the value of the function.

COMMON /mydata/ XX1, XX2, etc....

So the routine basically does this:

OBJF = F(X,N,XXX1, XXX2)

That's all. What happens is that OBJFUN is successfully called

several times, and then all of a sudden, when you try to assign

_any_ value to OBJF, you get a BUS error, as if it thinks that OBJF should be an array!

---or a different type from dummy parameter OBJF.

I know that everything has been declared double precision.

What would cause FORTRAN to think that OBJF is now an array, when

the subroutine is successfully called several times?

---That would depend on how the parameter (corresponding to the

dummy parameter OBJF) is defined.

If this is not the problem, then you should investigate the possibility of

subscript errors. Do you have subscript bounds checking enabled? Do you always

use adjustable dimensions properly?