1 |
|
|
2 |
|
#ifdef ALLOW_OBCS |
3 |
|
c Include ECCO_CPPOPTIONS because ecco,ctrl,cost files have headers with options for OBCS masks. |
4 |
|
# include "ECCO_CPPOPTIONS.h" |
5 |
|
#else |
6 |
|
# include "CTRL_OPTIONS.h" |
7 |
|
#endif |
8 |
|
|
9 |
subroutine optim_readdata( |
subroutine optim_readdata( |
10 |
I nn, |
I nn, |
11 |
I dfile, |
I dfile, |
40 |
|
|
41 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
42 |
#include "SIZE.h" |
#include "SIZE.h" |
|
cgg Include ECCO_CPPOPTIONS because the ecco_ctrl,cost files |
|
|
cgg have headers with options for OBCS masks. |
|
|
#include "ECCO_CPPOPTIONS.h" |
|
|
|
|
43 |
#include "ctrl.h" |
#include "ctrl.h" |
44 |
#include "optim.h" |
#include "optim.h" |
45 |
#include "minimization.h" |
#include "minimization.h" |
285 |
|
|
286 |
if (.NOT. lheaderonly) then |
if (.NOT. lheaderonly) then |
287 |
c-- Read the data. |
c-- Read the data. |
288 |
icvoffset = 0 |
icvoffset = 0 |
289 |
do icvar = 1,maxcvars |
do icvar = 1,maxcvars |
290 |
if ( ncvarindex(icvar) .ne. -1 ) then |
if ( ncvarindex(icvar) .ne. -1 ) then |
291 |
do icvrec = 1,ncvarrecs(icvar) |
do icvrec = 1,ncvarrecs(icvar) |
292 |
do bj = 1,nsy |
cph do bj = 1,nsy |
293 |
do bi = 1,nsx |
cph do bi = 1,nsx |
294 |
read( funit ) ncvarindex(icvar) |
read( funit ) ncvarindex(icvar) |
295 |
read( funit ) filej |
read( funit ) filej |
296 |
read( funit ) filei |
read( funit ) filei |
297 |
do k = 1,ncvarnrmax(icvar) |
do k = 1,ncvarnrmax(icvar) |
298 |
cbuffindex = 0 |
cbuffindex = 0 |
299 |
if (ncvargrd(icvar) .eq. 'c') then |
if (ncvargrd(icvar) .eq. 'c') then |
300 |
cbuffindex = nWetcGlobal(k) |
cbuffindex = nWetcGlobal(k) |
301 |
else if (ncvargrd(icvar) .eq. 's') then |
else if (ncvargrd(icvar) .eq. 's') then |
302 |
cbuffindex = nWetsGlobal(k) |
cbuffindex = nWetsGlobal(k) |
303 |
else if (ncvargrd(icvar) .eq. 'w') then |
else if (ncvargrd(icvar) .eq. 'w') then |
304 |
cbuffindex = nWetwGlobal(k) |
cbuffindex = nWetwGlobal(k) |
305 |
else if (ncvargrd(icvar) .eq. 'v') then |
else if (ncvargrd(icvar) .eq. 'v') then |
306 |
cbuffindex = nWetvGlobal(k) |
cbuffindex = nWetvGlobal(k) |
307 |
#ifdef ALLOW_SHIFWFLX_CONTROL |
#ifdef ALLOW_SHIFWFLX_CONTROL |
308 |
else if (ncvargrd(icvar) .eq. 'i') then |
else if (ncvargrd(icvar) .eq. 'i') then |
309 |
cbuffindex = nWetiGlobal(k) |
cbuffindex = nWetiGlobal(k) |
310 |
#endif |
#endif |
311 |
cgg( O.B. points have the grid mask "m". |
cgg( O.B. points have the grid mask "m". |
312 |
else if (ncvargrd(icvar) .eq. 'm') then |
else if (ncvargrd(icvar) .eq. 'm') then |
313 |
cgg From "icvrec", calculate what iobcs must be. |
cgg From "icvrec", calculate what iobcs must be. |
314 |
gg = (icvrec-1)/nobcs |
gg = (icvrec-1)/nobcs |
315 |
igg = int(gg) |
igg = int(gg) |
316 |
iobcs= icvrec - igg*nobcs |
iobcs= icvrec - igg*nobcs |
317 |
#ifdef ALLOW_OBCSN_CONTROL |
#ifdef ALLOW_OBCSN_CONTROL |
318 |
if (icvar .eq. 11) then |
if (icvar .eq. 11) then |
319 |
cbuffindex = nWetobcsnGlo(k,iobcs) |
cbuffindex = nWetobcsnGlo(k,iobcs) |
320 |
endif |
endif |
321 |
#endif |
#endif |
322 |
#ifdef ALLOW_OBCSS_CONTROL |
#ifdef ALLOW_OBCSS_CONTROL |
323 |
if (icvar .eq. 12) then |
if (icvar .eq. 12) then |
324 |
cbuffindex = nWetobcssGlo(k,iobcs) |
cbuffindex = nWetobcssGlo(k,iobcs) |
325 |
endif |
endif |
326 |
#endif |
#endif |
327 |
#ifdef ALLOW_OBCSW_CONTROL |
#ifdef ALLOW_OBCSW_CONTROL |
328 |
if (icvar .eq. 13) then |
if (icvar .eq. 13) then |
329 |
cbuffindex = nWetobcswGlo(k,iobcs) |
cbuffindex = nWetobcswGlo(k,iobcs) |
330 |
endif |
endif |
331 |
#endif |
#endif |
332 |
#ifdef ALLOW_OBCSE_CONTROL |
#ifdef ALLOW_OBCSE_CONTROL |
333 |
if (icvar .eq. 14) then |
if (icvar .eq. 14) then |
334 |
cbuffindex = nWetobcseGlo(k,iobcs) |
cbuffindex = nWetobcseGlo(k,iobcs) |
335 |
endif |
endif |
336 |
#endif |
#endif |
337 |
cgg) |
cgg) |
338 |
endif |
endif |
339 |
if (cbuffindex .gt. 0) then |
if ( icvoffset + cbuffindex .gt. nvarlength ) then |
340 |
read( funit ) cbuffindex |
print* |
341 |
read( funit ) filek |
print *, ' ERROR:' |
342 |
read( funit ) (cbuff(ii), ii=1,cbuffindex) |
print *, ' There are at least ', icvoffset+cbuffindex, |
343 |
do icvcomp = 1,cbuffindex |
& ' records in '//fname(1:28)//'.' |
344 |
vv(icvoffset+icvcomp) = cbuff(icvcomp) |
print *, ' This is more than expected from nvarlength =', |
345 |
cgg( Right now, the changes to the open boundary velocities are not balanced. |
& nvarlength, '.' |
346 |
cgg( The model will crash due to physical reasons. |
print *, ' Something is wrong in the computation of '// |
347 |
cgg( However, we can optimize with respect to just O.B. T and S if the |
& 'the wet points or' |
348 |
cgg( next two lines are uncommented. |
print *, ' in computing the number of records in '// |
349 |
cgg if (iobcs .eq. 3) vv(icvoffset+icvcomp)=0. |
& 'some variable(s).' |
350 |
cgg if (iobcs .eq. 4) vv(icvoffset+icvcomp)=0. |
print *, ' ... stopped in OPTIM_READDATA.' |
351 |
enddo |
stop ' ... stopped in OPTIM_READDATA.' |
352 |
icvoffset = icvoffset + cbuffindex |
endif |
353 |
endif |
if (cbuffindex .gt. 0) then |
354 |
enddo |
read( funit ) cbuffindex |
355 |
enddo |
read( funit ) filek |
356 |
enddo |
read( funit ) (cbuff(ii), ii=1,cbuffindex) |
357 |
enddo |
do icvcomp = 1,cbuffindex |
358 |
endif |
vv(icvoffset+icvcomp) = cbuff(icvcomp) |
359 |
|
c If you want to optimize with respect to just O.B. T and S |
360 |
|
c uncomment the next two lines. |
361 |
|
c if (iobcs .eq. 3) vv(icvoffset+icvcomp)=0. |
362 |
|
c if (iobcs .eq. 4) vv(icvoffset+icvcomp)=0. |
363 |
|
enddo |
364 |
|
icvoffset = icvoffset + cbuffindex |
365 |
|
endif |
366 |
|
enddo |
367 |
|
cph enddo |
368 |
|
cph enddo |
369 |
enddo |
enddo |
370 |
|
endif |
371 |
|
enddo |
372 |
|
|
373 |
else |
else |
374 |
|
|
375 |
c-- Assign the number of control variables. |
c-- Assign the number of control variables. |
376 |
nn = nvarlength |
nn = nvarlength |
377 |
|
|
378 |
endif |
endif |
379 |
|
|
382 |
c-- Assign the cost function value in case we read the cost file. |
c-- Assign the cost function value in case we read the cost file. |
383 |
|
|
384 |
if ( dfile .eq. ctrlname ) then |
if ( dfile .eq. ctrlname ) then |
385 |
ff = 0. d 0 |
ff = 0. d 0 |
386 |
else if ( dfile .eq. costname ) then |
else if ( dfile .eq. costname ) then |
387 |
ff = fileff |
ff = fileff |
388 |
endif |
endif |
389 |
|
|
390 |
return |
return |