40 INTEGER,
Dimension(:),
Pointer :: cntvect
56 real*8 time0, time1, time4
62 coi_error = coi_createfort( cntvect )
69 coi_error = max( coi_error,
coidef_numnz( cntvect, 2*nr ) )
73 coi_error = max( coi_error,
coidef_optfile( cntvect,
'mp_rosex.opt' ) )
84#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
85 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
88 If ( coi_error .ne. 0 )
THEN
90 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
92 call flog(
"Skipping Solve due to setup errors", 1 )
98 time0 = omp_get_wtime()
100 time1 = omp_get_wtime() - time0
101 If ( coi_error /= 0 )
then
102 call flog(
"Solve 1: Errors encountered during solution", 1 )
103 elseif ( stacalls == 0 .or. solcalls == 0 )
then
104 call flog(
"Solve 1: Status or Solution routine was not called", 1 )
105 elseif ( sstat /= 1 .or. mstat /= 2 )
then
106 call flog(
"Solve 1: Solver and Model Status was not as expected (1,2)", 1 )
107 elseif ( abs(
obj-0.0d0 ) > 0.000001d0 )
then
108 call flog(
"Solve 1: Incorrect objective returned", 1 )
111 maxthread = omp_get_max_threads()
112 coi_error = max( coi_error,
coidef_threadc( cntvect, maxthread ) )
114#if defined (complete)
120 time0 = omp_get_wtime()
122 time1a = omp_get_wtime() - time0
123 If ( coi_error /= 0 )
then
124 call flog(
"Solve 1a: Errors encountered during solution", 1 )
125 elseif ( stacalls == 0 .or. solcalls == 0 )
then
126 call flog(
"Solve 1a: Status or Solution routine was not called", 1 )
127 elseif ( sstat /= 1 .or. mstat /= 2 )
then
128 call flog(
"Solve 1a: Solver and Model Status was not as expected (1,2)", 1 )
129 elseif ( abs(
obj-0.0d0 ) > 0.000001d0 )
then
130 call flog(
"Solve 1a: Incorrect objective returned", 1 )
137 time0 = omp_get_wtime()
139 time2 = omp_get_wtime() - time0
140 If ( coi_error /= 0 )
then
141 call flog(
"Solve 2: Errors encountered during solution", 1 )
142 elseif ( stacalls == 0 .or. solcalls == 0 )
then
143 call flog(
"Solve 2: Status or Solution routine was not called", 1 )
144 elseif ( sstat /= 1 .or. mstat /= 2 )
then
145 call flog(
"Solve 2: Solver and Model Status was not as expected (1,2)", 1 )
146 elseif ( abs(
obj-0.0d0 ) > 0.000001d0 )
then
147 call flog(
"Solve 2: Incorrect objective returned", 1 )
150 if ( maxthread >= 4 )
then
156 time0 = omp_get_wtime()
158 time4 = omp_get_wtime() - time0
159 If ( coi_error /= 0 )
then
160 call flog(
"Solve 4: Errors encountered during solution", 1 )
161 elseif ( stacalls == 0 .or. solcalls == 0 )
then
162 call flog(
"Solve 4: Status or Solution routine was not called", 1 )
163 elseif ( sstat /= 1 .or. mstat /= 2 )
then
164 call flog(
"Solve 4: Solver and Model Status was not as expected (1,2)", 1 )
165 elseif ( abs(
obj-0.0d0 ) > 0.000001d0 )
then
166 call flog(
"Solve 4: Incorrect objective returned", 1 )
170 if ( coi_free( cntvect ) /= 0 )
call flog(
"Error while freeing control vector", 1 )
173 write(*,
"('Time for single thread ',f10.3)") time1
174#if defined (complete)
175 write(*,
"('Time for single thread ',f10.3)") time1a
176 write(*,
"('Time for dual threads ',f10.3)") time2
178 if ( maxthread >= 4 )
then
179 write(*,
"('Time for quad threads ',f10.3)") time4
182 write(*,*)
'End of Extended Rosenbrock Function example. Return code=',coi_error
184 call flog(
"Successful Solve", 0 )
196 colsta, rowno, value, nlflag, n, m, nz, &
202 integer,
intent (in) :: n
203 integer,
intent (in) :: m
204 integer,
intent (in) :: nz
205 real*8,
intent (in out),
dimension(n) :: lower
206 real*8,
intent (in out),
dimension(n) :: curr
207 real*8,
intent (in out),
dimension(n) :: upper
208 integer,
intent (in out),
dimension(n) :: vsta
210 integer,
intent (out),
dimension(m) ::
type
211 integer,
intent (in out),
dimension(m) :: esta
213 real*8,
intent (in out),
dimension(m) :: rhs
214 integer,
intent (in out),
dimension(n+1) :: colsta
215 integer,
intent (out),
dimension(nz) :: rowno
216 integer,
intent (in out),
dimension(nz) :: nlflag
217 real*8,
intent (in out),
dimension(nz) ::
value
288Integer Function ros_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
289 n, nz, thread, usrmem )
295 integer,
intent (in) :: n
296 integer,
intent (in) :: rowno
297 integer,
intent (in) :: nz
298 real*8,
intent (in),
dimension(n) :: x
299 real*8,
intent (in out) :: g
300 real*8,
intent (in out),
dimension(n) :: jac
301 integer,
intent (in),
dimension(nz) :: jcnm
303 integer,
intent (in) :: mode
305 integer,
intent (in) :: ignerr
307 integer,
intent (in out) :: errcnt
309 integer,
intent (in) :: thread
319 if ( rowno .eq. 1 )
then
323 if ( mode .eq. 1 .or. mode .eq. 3 )
then
326 g = g + (x(2*i-1)-1.d0)**2 + 1.d2*(x(2*i)-x(2*i-1)**2)**2
332 if ( mode .eq. 2 .or. mode .eq. 3 )
then
336 jac(2*i-1) = 2.d0*(x(2*i-1)-1.d0) - 4.d2*(x(2*i)-x(2*i-1)**2)*x(2*i-1)
337 jac(2*i ) = 2.d2*(x(2*i)-x(2*i-1)**2)
347Integer Function ros_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
357 INTEGER,
Intent(IN) :: n, m
358 INTEGER,
Intent(IN),
Dimension(N) :: xbas, xsta
359 INTEGER,
Intent(IN),
Dimension(M) :: ybas, ysta
360 real*8,
Intent(IN),
Dimension(N) :: xval, xmar
361 real*8,
Intent(IN),
Dimension(M) :: yval, ymar
362 real*8,
Intent(IN OUT) :: usrmem(*)
365 solcalls = solcalls + 1
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_threadf(cntvect, threadf)
number of threads allowed for simultaneous FDEval calls.
integer function coidef_threads(cntvect, threads)
number of threads allowed internally in CONOPT.
integer function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
integer function coidef_threadc(cntvect, threadc)
check for thread compatibility.
integer function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
integer function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
integer function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
integer function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
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 coi_solve(cntvect)
method for starting the solving process of CONOPT.
integer function ros_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
subroutine flog(msg, code)
integer function ros_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function ros_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
program rosex
Main program. A simple setup and call of CONOPT.