120 INTEGER :: numcallback
121 INTEGER,
Dimension(:),
Pointer :: cntvect
134 Allocate( cntvect(numcallback) )
141 coi_error = max( coi_error,
coidef_numnz( cntvect, 6 ) )
144 coi_error = max( coi_error,
coidef_optfile( cntvect,
'cns12.opt' ) )
155#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
156 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
159 If ( coi_error .ne. 0 )
THEN
161 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
163 call flog(
"Skipping Solve due to setup errors", 1 )
172 casenum = 1; scale = 1.d0
175 If ( coi_error /= 0 )
then
176 call flog(
"Case 1: Errors encountered during solution", 1 )
178 call flog(
"Case 1: Status or Solution routine was not called", 1 )
179 elseif (
sstat /= 1 )
then
180 call flog(
"Case 1: Solver Status was not 1 as expected.", 1 )
182 if (
mstat == 16 )
then
185 if ( abs(
uprim(1)-scale)>tol )
then
186 call flog(
"Case 1: Bad e1 level.", 1 )
188 else if ( abs(
uprim(2)-0)>tol )
then
189 call flog(
"Case 1: Bad e2 level.", 1 )
191 else if ( abs(
uprim(3)-0)>tol )
then
192 call flog(
"Case 1: Bad e3 level.", 1 )
194 else if (
mstat /= 5 )
then
195 call flog(
"Case 1: Model Status was not as expected either 5 or 16.", 1 )
197 call flog(
"Case 1: Infeasibility count was zero.", 1 )
201#if defined (notfinished)
205 If ( coi_error /= 0 )
then
206 call flog(
"Case 2: Errors encountered during solution", 1 )
208 call flog(
"Case 2: Status or Solution routine was not called", 1 )
210 call flog(
"Case 2: Solver and Model Status was not as expected (1,16)", 1 )
212 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol ) .or. &
213 ( abs(
xprim(1)-x2) < tol .and. abs(
xprim(2)-y2) < tol )
215 write(10,*)
'Solution for case 2 was x=',
xprim(1),
' and y=',
xprim(2)
216 call flog(
"Case 2: Solver values were not correct.", 1 )
223 If ( coi_error /= 0 )
then
224 call flog(
"Case 3: Errors encountered during solution", 1 )
226 call flog(
"Case 3: Status or Solution routine was not called", 1 )
228 call flog(
"Case 3: Solver and Model Status was not as expected (1,16)", 1 )
230 ok = ( abs(
xprim(1)-x1) < tol .and. abs(
xprim(2)-y1) < tol )
232 write(10,*)
'Solution for case 3 was x=',
xprim(1),
' and y=',
xprim(2)
233 call flog(
"Case 3: Solver values were not correct.", 1 )
240 If ( coi_error /= 0 )
then
241 call flog(
"Case 4: Errors encountered during solution", 1 )
243 call flog(
"Case 4: Status or Solution routine was not called", 1 )
245 call flog(
"Case 4: Solver and Model Status was not as expected (1,5)", 1 )
247 call flog(
"Case 4: Infeasibility count is zero.", 1 )
252 write(*,*)
'End of Cns12 example. Return code=',coi_error
254 if ( coi_free(cntvect) /= 0 )
call flog(
"Error while freeing control vector",1)
256 call flog(
"Successful Solve", 0 )
268 colsta, rowno, value, nlflag, n, m, nz, &
275 integer,
intent (in) :: n
276 integer,
intent (in) :: m
277 integer,
intent (in) :: nz
278 real*8,
intent (in out),
dimension(n) :: lower
279 real*8,
intent (in out),
dimension(n) :: curr
280 real*8,
intent (in out),
dimension(n) :: upper
281 integer,
intent (in out),
dimension(n) :: vsta
283 integer,
intent (out),
dimension(m) ::
type
284 integer,
intent (in out),
dimension(m) :: esta
286 real*8,
intent (in out),
dimension(m) :: rhs
287 integer,
intent (in out),
dimension(n+1) :: colsta
288 integer,
intent (out),
dimension(nz) :: rowno
289 integer,
intent (in out),
dimension(nz) :: nlflag
290 real*8,
intent (in out),
dimension(nz) ::
value
297 if ( casenum == 1 )
then
380Integer Function cns12_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
381 n, nz, thread, usrmem )
387 integer,
intent (in) :: n
388 integer,
intent (in) :: rowno
389 integer,
intent (in) :: nz
390 real*8,
intent (in),
dimension(n) :: x
391 real*8,
intent (in out) :: g
392 real*8,
intent (in out),
dimension(n) :: jac
393 integer,
intent (in),
dimension(nz) :: jcnm
395 integer,
intent (in) :: mode
397 integer,
intent (in) :: ignerr
399 integer,
intent (in out) :: errcnt
401 integer,
intent (in) :: thread
406 if ( rowno .eq. 1 )
then
410 if ( mode .eq. 1 .or. mode .eq. 3 )
then
416 if ( mode .eq. 2 .or. mode .eq. 3 )
then
integer function cns12_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
program cns12
Main program. A simple setup and call of CONOPT.
integer function cns12_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function std_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
integer function std_status(modsta, solsta, iter, objval, usrmem)
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
integer function coidef_fdeval(cntvect, coi_fdeval)
define callback routine for performing function and derivative evaluations.
integer function coidef_errmsg(cntvect, coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
integer function coidef_message(cntvect, coi_message)
define callback routine for handling messages returned during the solution process.
integer function coidef_readmatrix(cntvect, coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
integer function coidef_status(cntvect, coi_status)
define callback routine for returning the completion status.
integer function coidef_solution(cntvect, coi_solution)
define callback routine for returning the final solution values.
integer function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
integer function coidef_square(cntvect, square)
square models.
integer function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
integer function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
integer function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
integer function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
integer function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
integer function coidef_size()
returns the size the Control Vector must have, measured in standard Integer units.
integer function coidef_inifort(cntvect)
initialisation method for Fortran applications.
integer function coi_solve(cntvect)
method for starting the solving process of CONOPT.
subroutine flog(msg, code)
real *8, dimension(:), pointer xprim
real *8, dimension(:), pointer uprim