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 "ecco.h" |
34 |
|
#include "ctrl.h" |
35 |
|
#include "optim.h" |
36 |
|
|
37 |
|
c == routine arguments == |
38 |
|
|
39 |
|
integer nn |
40 |
|
|
41 |
|
c == local variables == |
42 |
|
|
43 |
|
_RL objf |
44 |
|
|
45 |
|
#if defined (DYNAMIC) |
46 |
|
_RL xx(nn) |
47 |
|
_RL adxx(nn) |
48 |
|
_RL dd(nn) |
49 |
|
_RL gold(nn) |
50 |
|
_RL xdiff(nn) |
51 |
|
#elif defined (USE_POINTER) || (MAX_INDEPEND == 0) |
52 |
|
_RL xx |
53 |
|
_RL adxx |
54 |
|
_RL dd(1) |
55 |
|
_RL gold(1) |
56 |
|
_RL xdiff(1) |
57 |
|
pointer (pxx,xx(1)) |
58 |
|
pointer (padxx,adxx(1)) |
59 |
|
pointer (pdd,dd) |
60 |
|
pointer (pgold,gold) |
61 |
|
pointer (pxdiff,xdiff) |
62 |
|
#else |
63 |
|
integer nmax |
64 |
|
parameter( nmax = MAX_INDEPEND ) |
65 |
|
_RL xx(nmax) |
66 |
|
_RL adxx(nmax) |
67 |
|
_RL dd(nmax) |
68 |
|
_RL gold(nmax) |
69 |
|
_RL xdiff(nmax) |
70 |
|
#endif |
71 |
|
|
72 |
|
c-- Allocate memory for the control variables and the gradient vector. |
73 |
|
#if defined(DYNAMIC) |
74 |
|
#elif defined(USE_POINTER) || (MAX_INDEPEND == 0) |
75 |
|
call myalloc( pxx , nn*REAL_BYTE ) |
76 |
|
call myalloc( padxx, nn*REAL_BYTE ) |
77 |
|
call myalloc( pdd, nn*REAL_BYTE ) |
78 |
|
call myalloc( pgold, nn*REAL_BYTE ) |
79 |
|
call myalloc( pxdiff, nn*REAL_BYTE ) |
80 |
|
#endif |
81 |
|
|
82 |
|
integer ifail |
83 |
|
integer itmax |
84 |
|
logical loffline |
85 |
|
|
86 |
|
c == external == |
87 |
|
|
88 |
|
external simul |
89 |
|
external lsline |
90 |
|
|
91 |
|
c == end of interface == |
92 |
|
|
93 |
|
c-- Initialisize the model and set a first guess of the control |
94 |
|
c-- variables. |
95 |
|
call optim_initmod( nn, xx ) |
96 |
|
|
97 |
|
#if defined (DYNAMIC) |
98 |
|
#elif defined(USE_POINTER) || (MAX_INDEPEND == 0) |
99 |
|
#else |
100 |
|
if (nn .gt. nmax) then |
101 |
|
print*,' OPTIMUM: Not enough space.' |
102 |
|
print*,' nmax = ',nmax |
103 |
|
print*,' nn = ',nn |
104 |
|
print* |
105 |
|
print*,' Set MAX_INDEPEND in Makefile .ge. ',nn |
106 |
|
print* |
107 |
|
stop ' ... stopped in OPTIMUM.' |
108 |
|
endif |
109 |
|
#endif |
110 |
|
|
111 |
|
print*, ' OPTIMUM: Calling lsopt for iteration: ',optimcycle |
112 |
|
print*, ' OPTIMUM: with nn, REAL_BYTE = ', nn, REAL_BYTE |
113 |
|
|
114 |
|
loffline = .true. |
115 |
|
itmax = numiter |
116 |
|
|
117 |
|
c-- Large scale optimization --> Gilbert & Lemarechal. |
118 |
|
call lsopt_top( nn, xx, objf, adxx |
119 |
|
& , simul, lsline |
120 |
|
& , epsx, fmin, epsg |
121 |
|
& , iprint |
122 |
|
& , itmax, nfunc, nupdate |
123 |
|
& , dd, gold, xdiff |
124 |
|
& , loffline |
125 |
|
& , ifail ) |
126 |
|
|
127 |
|
return |
128 |
|
end |