Author Message Please, please help!

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

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!

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?

Any help would be appreciated,

Stephen

Sun, 09 Mar 1997 06:30:33 GMT  Please, please help!

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

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

Tue, 11 Mar 1997 08:12:14 GMT  Please, please help!

Quote:
>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.
>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?

As these must be functions you should declare them as such:

EXTERNAL OBJFUN,CONFUN

Otherwise the compiler thinks these are arrays as you make a call like:

OBJ=F(X,Y,...)

As I recall f77 supports up to 7-dimensional arrays...
--
Sepe Susi ("Zeke the Wolf")
alias Tero Tommila
KCL/Finland

Mon, 10 Mar 1997 21:18:18 GMT

 Page 1 of 1 [ 3 post ]

Relevant Pages