1 |
C $Header: /u/gcmpack/MITgcm/pkg/cost/cost_dependent_init.F,v 1.13 2012/09/11 01:32:02 heimbach Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_OPTIONS.h" |
5 |
|
6 |
subroutine cost_dependent_init( mythid ) |
7 |
|
8 |
c ================================================================== |
9 |
c SUBROUTINE cost_dependent_init |
10 |
c ================================================================== |
11 |
c |
12 |
c o Initialise the variable ad cost function part. |
13 |
c |
14 |
c started: heimbach@mit.edu 17-Jan-2002 |
15 |
c |
16 |
c ================================================================== |
17 |
c SUBROUTINE cost_dependent_init |
18 |
c ================================================================== |
19 |
|
20 |
implicit none |
21 |
|
22 |
c == global variables == |
23 |
|
24 |
#include "EEPARAMS.h" |
25 |
#include "SIZE.h" |
26 |
|
27 |
#include "cost.h" |
28 |
#include "adcost.h" |
29 |
|
30 |
c == routine arguments == |
31 |
|
32 |
integer mythid |
33 |
|
34 |
c == local variables == |
35 |
|
36 |
integer i,j,k |
37 |
integer bi,bj |
38 |
integer itlo,ithi |
39 |
integer jtlo,jthi |
40 |
|
41 |
c == external functions == |
42 |
|
43 |
c == end of interface == |
44 |
jtlo = mybylo(mythid) |
45 |
jthi = mybyhi(mythid) |
46 |
itlo = mybxlo(mythid) |
47 |
ithi = mybxhi(mythid) |
48 |
|
49 |
#ifdef ALLOW_OPENAD |
50 |
fc%v = 0.0 |
51 |
#else |
52 |
fc = 0. _d 0 |
53 |
#endif |
54 |
|
55 |
#ifdef ALLOW_AUTODIFF |
56 |
|
57 |
#ifdef ALLOW_OPENAD |
58 |
adfc = 1.0 |
59 |
#else |
60 |
if ( myProcId .EQ. 0 ) then |
61 |
adfc = 1. _d 0 |
62 |
endif |
63 |
#endif |
64 |
|
65 |
do bj = jtlo,jthi |
66 |
do bi = itlo,ithi |
67 |
#ifdef ALLOW_COST_VECTOR |
68 |
do i=1,sNx |
69 |
objf_vector(i,bi,bj) = 0. _d 0 |
70 |
adobjf_vector(i,bi,bj) = 1. _d 0 |
71 |
end do |
72 |
#endif |
73 |
#ifdef ALLOW_COST_STATE_FINAL |
74 |
do j=1,sNy |
75 |
do i=1,sNx |
76 |
do k=1,4*Nr |
77 |
objf_state_final(i,j,bi,bj,k) = 0. _d 0 |
78 |
enddo |
79 |
objf_state_final(i,j,bi,bj,4*Nr+1) = 0. _d 0 |
80 |
cph No init. of cost_state_final here, |
81 |
cph because we need it in ADM*TLM |
82 |
end do |
83 |
end do |
84 |
#endif |
85 |
enddo |
86 |
enddo |
87 |
|
88 |
#endif /* ALLOW_AUTODIFF */ |
89 |
|
90 |
return |
91 |
end |