1 |
|
2 |
|
3 |
subroutine optim_sub( |
4 |
I nn |
5 |
& ) |
6 |
|
7 |
c ================================================================== |
8 |
c SUBROUTINE optim_sub |
9 |
c ================================================================== |
10 |
c |
11 |
c o Initialization of optimization run. |
12 |
c |
13 |
c started: Christian Eckert eckert@mit.edu 15-Feb-2000 |
14 |
c |
15 |
c changed: Christian Eckert eckert@mit.edu 10-Mar-2000 |
16 |
c |
17 |
c - Added ECCO layout. |
18 |
c |
19 |
c changed: Patrick Heimbach heimbach@mit.edu 19-Jun-2000 |
20 |
c - finished, revised and debugged |
21 |
c |
22 |
c ================================================================== |
23 |
c SUBROUTINE optim_sub |
24 |
c ================================================================== |
25 |
|
26 |
implicit none |
27 |
|
28 |
c == global variables == |
29 |
|
30 |
#include "EEPARAMS.h" |
31 |
#include "SIZE.h" |
32 |
|
33 |
#include "ctrl.h" |
34 |
#include "optim.h" |
35 |
|
36 |
c == routine arguments == |
37 |
|
38 |
integer nn |
39 |
|
40 |
c == local variables == |
41 |
|
42 |
_RL objf |
43 |
|
44 |
#if defined (DYNAMIC) |
45 |
_RL xx(nn) |
46 |
_RL adxx(nn) |
47 |
_RL dd(nn) |
48 |
_RL gold(nn) |
49 |
_RL xdiff(nn) |
50 |
#elif defined (USE_POINTER) || (MAX_INDEPEND == 0) |
51 |
_RL xx |
52 |
_RL adxx |
53 |
_RL dd(1) |
54 |
_RL gold(1) |
55 |
_RL xdiff(1) |
56 |
pointer (pxx,xx(1)) |
57 |
pointer (padxx,adxx(1)) |
58 |
pointer (pdd,dd) |
59 |
pointer (pgold,gold) |
60 |
pointer (pxdiff,xdiff) |
61 |
#else |
62 |
integer nmax |
63 |
parameter( nmax = MAX_INDEPEND ) |
64 |
_RL xx(nmax) |
65 |
_RL adxx(nmax) |
66 |
_RL dd(nmax) |
67 |
_RL gold(nmax) |
68 |
_RL xdiff(nmax) |
69 |
#endif |
70 |
|
71 |
c-- Allocate memory for the control variables and the gradient vector. |
72 |
#if defined(DYNAMIC) |
73 |
#elif defined(USE_POINTER) || (MAX_INDEPEND == 0) |
74 |
call myalloc( pxx , nn*REAL_BYTE ) |
75 |
call myalloc( padxx, nn*REAL_BYTE ) |
76 |
call myalloc( pdd, nn*REAL_BYTE ) |
77 |
call myalloc( pgold, nn*REAL_BYTE ) |
78 |
call myalloc( pxdiff, nn*REAL_BYTE ) |
79 |
#endif |
80 |
|
81 |
integer ifail |
82 |
integer itmax |
83 |
logical loffline |
84 |
|
85 |
c == external == |
86 |
|
87 |
external simul |
88 |
external lsline |
89 |
|
90 |
c == end of interface == |
91 |
|
92 |
c-- Initialisize the model and set a first guess of the control |
93 |
c-- variables. |
94 |
call optim_initmod( nn, xx ) |
95 |
|
96 |
#if defined (DYNAMIC) |
97 |
#elif defined(USE_POINTER) || (MAX_INDEPEND == 0) |
98 |
#else |
99 |
if (nn .gt. nmax) then |
100 |
print*,' OPTIMUM: Not enough space.' |
101 |
print*,' nmax = ',nmax |
102 |
print*,' nn = ',nn |
103 |
print* |
104 |
print*,' Set MAX_INDEPEND in Makefile .ge. ',nn |
105 |
print* |
106 |
stop ' ... stopped in OPTIMUM.' |
107 |
endif |
108 |
#endif |
109 |
|
110 |
print*, ' OPTIMUM: Calling lsopt for iteration: ',optimcycle |
111 |
print*, ' OPTIMUM: with nn, REAL_BYTE = ', nn, REAL_BYTE |
112 |
|
113 |
loffline = .true. |
114 |
itmax = numiter |
115 |
|
116 |
c-- Large scale optimization --> Gilbert & Lemarechal. |
117 |
call lsopt_top( nn, xx, objf, adxx |
118 |
& , simul, lsline |
119 |
& , epsx, fmin, epsg |
120 |
& , iprint |
121 |
& , itmax, nfunc, nupdate |
122 |
& , dd, gold, xdiff |
123 |
& , loffline |
124 |
& , ifail ) |
125 |
|
126 |
return |
127 |
end |