11 Integer,
Parameter :: NP = 150
12 Integer,
Parameter :: NV = 2*np
13 Integer,
Parameter :: NO = np-1
14 Integer,
Parameter :: ND = np*(np-1)/2
15 Integer,
dimension(ND) :: Rowmapi, RowmapJ
16 Integer,
dimension(NP,NP) :: rowmapk
49 INTEGER,
Dimension(:),
Pointer :: cntvect
52 real*8 time0, time1, time2
53 Integer :: iter1, iter2
103 coi_error = coi_createfort( cntvect )
113 coi_error = max( coi_error,
coidef_optfile( cntvect,
'mp_polygon.opt' ) )
124#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
125 coi_error = max( coi_error,
coidef_license( cntvect, license_int_1, license_int_2, license_int_3, license_text) )
128 If ( coi_error .ne. 0 )
THEN
130 write(*,*)
'**** Fatal Error while loading CONOPT Callback routines.'
132 call flog(
"Skipping Solve due to setup errors", 1 )
134 coi_error = max( coi_error,
coidef_itlim( cntvect, 50 ) )
138 time0 = omp_get_wtime()
140 time1 = omp_get_wtime() - time0
143 write(*,*)
'End of Polygon example with one thread. Return code=',coi_error
145 If ( coi_error /= 0 )
then
146 call flog(
"One thread: Errors encountered during solution", 1 )
147 elseif ( stacalls == 0 .or. solcalls == 0 )
then
148 call flog(
"One thread: Status or Solution routine was not called", 1 )
157 time0 = omp_get_wtime()
159 time2 = omp_get_wtime() - time0
162 write(*,*)
'End of Polygon example with multiple threads. Return code=',coi_error
164 If ( coi_error /= 0 )
then
165 call flog(
"Multi thread: Errors encountered during solution", 1 )
166 elseif ( stacalls == 0 .or. solcalls == 0 )
then
167 call flog(
"Multi thread: Status or Solution routine was not called", 1 )
173 if ( coi_free( cntvect ) /= 0 )
call flog(
"Error while freeing control vector", 1 )
176 write(*,
"('Time for single thread',f10.3)") time1
177 write(*,
"('Time for multi thread',f10.3)") time2
178 write(*,
"('Speedup ',f10.3)") time1/time2
179 write(*,
"('Efficiency ',f10.3)") time1/time2/omp_get_max_threads()
180 write(*,
"('Speedup/iteration ',f10.3)") time1/time2/iter1*iter2
181 write(*,
"('Efficiency/iteration ',f10.3)") time1/time2/iter1*iter2/omp_get_max_threads()
183 call flog(
"Successful Solve", 0 )
195 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
221 real*8,
parameter :: pi = 3.141592
241 curr(i) = 4.d0*i*(
np+1-i)/(1+
np)**2
378Integer Function poly_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
379 n, nz, thread, usrmem )
385 integer,
intent (in) :: n
386 integer,
intent (in) :: rowno
387 integer,
intent (in) :: nz
388 real*8,
intent (in),
dimension(n) :: x
389 real*8,
intent (in out) :: g
390 real*8,
intent (in out),
dimension(n) :: jac
391 integer,
intent (in),
dimension(nz) :: jcnm
393 integer,
intent (in) :: mode
395 integer,
intent (in) :: ignerr
397 integer,
intent (in out) :: errcnt
399 integer,
intent (in) :: thread
410 if ( rowno ==
no+
nd+1 )
then
415 if ( mode .eq. 1 .or. mode .eq. 3 )
then
418 g = g + x(i+1)*x(i)*sin(x(
np+i+1)-x(
np+i))
425 if ( mode .eq. 2 .or. mode .eq. 3 )
then
431 s = 0.5d0*sin(x(
np+i+1)-x(
np+i))
432 jac(i+1) = jac(i+1) + x(i)*s
433 jac(i) = jac(i) + x(i+1)*s
434 c = 0.5d0*x(i+1)*x(i)*cos(x(
np+i+1)-x(
np+i))
435 jac(
np+i+1) = jac(
np+i+1) + c
436 jac(
np+i) = jac(
np+i) - c
440 Else if ( rowno >
no )
then
447 if ( mode .eq. 1 .or. mode .eq. 3 )
then
448 g = x(i)**2 + x(j)**2 -2.d0*x(i)*x(j)*cos(x(j+
np)-x(i+
np))
453 if ( mode .eq. 2 .or. mode .eq. 3 )
then
454 c = cos(x(j+
np)-x(i+
np))
455 jac(i) = 2.d0*(x(i)-x(j)*c)
456 jac(j) = 2.d0*(x(j)-x(i)*c)
457 s = 2.d0*sin(x(j+
np)-x(i+
np))*x(i)*x(j)
462 write(*,*)
'Fdeval called with rowno=',rowno
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_threads(cntvect, threads)
number of threads allowed internally in CONOPT.
integer function coidef_itlim(cntvect, itlim)
define the Iteration Limit.
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_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.
program polygon
Main program. A simple setup and call of CONOPT.
integer, dimension(nd) rowmapj
integer, dimension(np, np) rowmapk
integer, dimension(nd) rowmapi
subroutine flog(msg, code)
integer function poly_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
integer function poly_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.