44 |
|
|
45 |
#include "ctrl.h" |
#include "ctrl.h" |
46 |
#include "cost.h" |
#include "cost.h" |
47 |
|
#include "optim.h" |
48 |
|
|
49 |
#ifdef ALLOW_ECCO |
#ifdef ALLOW_ECCO |
50 |
# include "ecco_cost.h" |
# include "ecco_cost.h" |
52 |
# include "ctrl_weights.h" |
# include "ctrl_weights.h" |
53 |
#endif |
#endif |
54 |
|
|
|
#ifdef ALLOW_ECCO_OPTIMIZATION |
|
|
# include "optim.h" |
|
|
#endif |
|
|
|
|
55 |
c == routine arguments == |
c == routine arguments == |
56 |
|
|
57 |
logical first |
logical first |
60 |
#ifndef EXCLUDE_CTRL_PACK |
#ifndef EXCLUDE_CTRL_PACK |
61 |
c == local variables == |
c == local variables == |
62 |
|
|
|
#ifndef ALLOW_ECCO_OPTIMIZATION |
|
|
integer optimcycle |
|
|
_RL fmin |
|
|
#endif |
|
|
|
|
63 |
_RL fcloc |
_RL fcloc |
64 |
|
|
65 |
integer i, j, k |
integer i, j, k |
89 |
c == end of interface == |
c == end of interface == |
90 |
|
|
91 |
#ifndef ALLOW_ECCO_OPTIMIZATION |
#ifndef ALLOW_ECCO_OPTIMIZATION |
|
optimcycle = 0 |
|
92 |
fmin = 0. _d 0 |
fmin = 0. _d 0 |
93 |
#endif |
#endif |
94 |
|
|
98 |
c-- Initialise adjoint variables on active files. |
c-- Initialise adjoint variables on active files. |
99 |
ladinit = .false. |
ladinit = .false. |
100 |
|
|
101 |
|
c-- Initialise global buffer index |
102 |
|
nbuffglobal = 0 |
103 |
|
|
104 |
c-- Assign file names. |
c-- Assign file names. |
105 |
|
|
106 |
call ctrl_set_fname(xx_theta_file, fname_theta, mythid) |
call ctrl_set_fname(xx_theta_file, fname_theta, mythid) |
131 |
c-- Only the master thread will do I/O. |
c-- Only the master thread will do I/O. |
132 |
_BEGIN_MASTER( mythid ) |
_BEGIN_MASTER( mythid ) |
133 |
|
|
134 |
if ( first .AND. optimcycle .EQ. 0 ) then |
if ( first ) then |
135 |
c >>> Initialise control vector for optimcycle=0 <<< |
c >>> Initialise control vector for optimcycle=0 <<< |
136 |
lxxadxx = .TRUE. |
lxxadxx = .TRUE. |
137 |
ictrlgrad = 1 |
ictrlgrad = 1 |
138 |
fcloc = fmin |
fcloc = fmin |
139 |
write(cfile(1:128),'(4a,i4.4)') |
write(cfile(1:128),'(4a,i4.4)') |
140 |
& ctrlname(1:9),'_',yctrlid(1:10),'.opt', optimcycle |
& ctrlname(1:9),'_',yctrlid(1:10), |
141 |
|
& yctrlpospack, optimcycle |
142 |
|
print *, 'ph-pack: unpacking ', ctrlname(1:9) |
143 |
else |
else |
144 |
c >>> Write gradient vector <<< |
c >>> Write gradient vector <<< |
145 |
lxxadxx = .FALSE. |
lxxadxx = .FALSE. |
146 |
ictrlgrad = 2 |
ictrlgrad = 2 |
147 |
fcloc = fc |
fcloc = fc |
148 |
write(cfile(1:128),'(4a,i4.4)') |
write(cfile(1:128),'(4a,i4.4)') |
149 |
& costname(1:9),'_',yctrlid(1:10),'.opt', optimcycle |
& costname(1:9),'_',yctrlid(1:10), |
150 |
|
& yctrlpospack, optimcycle |
151 |
|
print *, 'ph-pack: unpacking ', costname(1:9) |
152 |
endif |
endif |
153 |
|
|
154 |
call mdsfindunit( cunit, mythid ) |
call mdsfindunit( cunit, mythid ) |
162 |
write(cunit) nvarlength |
write(cunit) nvarlength |
163 |
write(cunit) yctrlid |
write(cunit) yctrlid |
164 |
write(cunit) optimCycle |
write(cunit) optimCycle |
165 |
write(cunit) fcloc |
write(cunit) fc |
166 |
write(cunit) 1 |
C place holder of obsolete variable iG |
|
write(cunit) 1 |
|
167 |
write(cunit) 1 |
write(cunit) 1 |
168 |
|
C place holder of obsolete variable jG |
169 |
write(cunit) 1 |
write(cunit) 1 |
170 |
|
write(cunit) nsx |
171 |
|
write(cunit) nsy |
172 |
write(cunit) (nWetcGlobal(k), k=1,nr) |
write(cunit) (nWetcGlobal(k), k=1,nr) |
173 |
write(cunit) (nWetsGlobal(k), k=1,nr) |
write(cunit) (nWetsGlobal(k), k=1,nr) |
174 |
write(cunit) (nWetwGlobal(k), k=1,nr) |
write(cunit) (nWetwGlobal(k), k=1,nr) |
190 |
#endif |
#endif |
191 |
write(cunit) (ncvarindex(i), i=1,maxcvars) |
write(cunit) (ncvarindex(i), i=1,maxcvars) |
192 |
write(cunit) (ncvarrecs(i), i=1,maxcvars) |
write(cunit) (ncvarrecs(i), i=1,maxcvars) |
193 |
write(cunit) (nx, i=1,maxcvars) |
write(cunit) (ncvarxmax(i), i=1,maxcvars) |
194 |
write(cunit) (ny, i=1,maxcvars) |
write(cunit) (ncvarymax(i), i=1,maxcvars) |
195 |
write(cunit) (ncvarnrmax(i), i=1,maxcvars) |
write(cunit) (ncvarnrmax(i), i=1,maxcvars) |
196 |
write(cunit) (ncvargrd(i), i=1,maxcvars) |
write(cunit) (ncvargrd(i), i=1,maxcvars) |
197 |
write(cunit) |
write(cunit) |