1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/ecco_cost_init_fixed.F,v 1.9 2007/09/20 18:23:34 heimbach Exp $ |
2 |
|
3 |
#include "PACKAGES_CONFIG.h" |
4 |
#include "AD_CONFIG.h" |
5 |
#include "COST_CPPOPTIONS.h" |
6 |
|
7 |
subroutine ecco_cost_init_fixed( mythid ) |
8 |
|
9 |
c ================================================================== |
10 |
c SUBROUTINE ecco_cost_init_fixed |
11 |
c ================================================================== |
12 |
c |
13 |
c o Set contributions to the cost function and the cost function |
14 |
c itself to zero. The cost function and the individual contribu- |
15 |
c tions are defined in the header file "ecco_cost.h". |
16 |
c |
17 |
c started: Christian Eckert eckert@mit.edu 30-Jun-1999 |
18 |
c |
19 |
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
20 |
c |
21 |
c - Restructured the code in order to create a package |
22 |
c for the MITgcmUV. |
23 |
c |
24 |
c changed: Ralf Giering 18-Jan-2001 |
25 |
c |
26 |
c - move namelist reading to cost_readparms.F |
27 |
c |
28 |
c ================================================================== |
29 |
c SUBROUTINE ecco_cost_init_fixed |
30 |
c ================================================================== |
31 |
|
32 |
implicit none |
33 |
|
34 |
c == global variables == |
35 |
|
36 |
#include "EEPARAMS.h" |
37 |
#include "SIZE.h" |
38 |
#include "GRID.h" |
39 |
#include "PARAMS.h" |
40 |
|
41 |
#ifdef ALLOW_CAL |
42 |
#include "cal.h" |
43 |
#endif |
44 |
#include "ecco_cost.h" |
45 |
|
46 |
c == routine arguments == |
47 |
|
48 |
integer mythid |
49 |
|
50 |
c == local variables == |
51 |
|
52 |
integer tempDate1(4) |
53 |
integer tempDate2(4) |
54 |
integer gwunit |
55 |
integer ilo,ihi |
56 |
integer irec |
57 |
logical exst |
58 |
_RL dummy |
59 |
_RL missingObsFlag |
60 |
PARAMETER ( missingObsFlag = 1. _d 23 ) |
61 |
|
62 |
c == external functions == |
63 |
|
64 |
integer cal_IntYears |
65 |
external cal_IntYears |
66 |
integer cal_IntMonths |
67 |
external cal_IntMonths |
68 |
integer cal_IntDays |
69 |
external cal_IntDays |
70 |
integer ifnblnk |
71 |
external ifnblnk |
72 |
integer ilnblnk |
73 |
external ilnblnk |
74 |
|
75 |
c == end of interface == |
76 |
|
77 |
#ifdef ALLOW_CAL |
78 |
|
79 |
c-- The number of monthly and daily averages generated by the |
80 |
c-- current model integration. |
81 |
nyearsrec = cal_IntYears( mythid ) |
82 |
nmonsrec = cal_IntMonths( mythid ) |
83 |
ndaysrec = cal_IntDays( mythid ) |
84 |
|
85 |
_BEGIN_MASTER( myThid ) |
86 |
|
87 |
c-- Get the complete dates of the ... |
88 |
c-- ... TMI data. |
89 |
call cal_FullDate( tmistartdate1, tmistartdate2, |
90 |
& tmistartdate, mythid ) |
91 |
c-- ... SST data. |
92 |
call cal_FullDate( sststartdate1, sststartdate2, |
93 |
& sststartdate, mythid ) |
94 |
c-- ... SSS data. |
95 |
call cal_FullDate( sssstartdate1, sssstartdate2, |
96 |
& sssstartdate, mythid ) |
97 |
c-- ... BP data. |
98 |
call cal_FullDate( bpstartdate1, bpstartdate2, |
99 |
& bpstartdate, mythid ) |
100 |
c-- ... T/P data. |
101 |
call cal_FullDate( topexstartdate1, topexstartdate2, |
102 |
& topexstartdate, mythid ) |
103 |
c-- ... ERS data. |
104 |
call cal_FullDate( ersstartdate1, ersstartdate2, |
105 |
& ersstartdate, mythid ) |
106 |
c-- ... GFO data. |
107 |
call cal_FullDate( gfostartdate1, gfostartdate2, |
108 |
& gfostartdate, mythid ) |
109 |
c-- ... SCAT data. |
110 |
call cal_FullDate( scatstartdate1, scatstartdate2, |
111 |
& scatxstartdate, mythid ) |
112 |
call cal_FullDate( scatstartdate1, scatstartdate2, |
113 |
& scatystartdate, mythid ) |
114 |
c-- ... ARGO data. |
115 |
call cal_FullDate( argotstartdate1, argotstartdate2, |
116 |
& argotstartdate, mythid ) |
117 |
call cal_FullDate( argosstartdate1, argotstartdate2, |
118 |
& argosstartdate, mythid ) |
119 |
|
120 |
_END_MASTER( mythid ) |
121 |
|
122 |
#endif /* ALLOW_CAL */ |
123 |
|
124 |
c-- Get the weights that are to be used for the individual cost |
125 |
c-- function contributions. |
126 |
call ecco_cost_weights( mythid ) |
127 |
|
128 |
c-- Initialise adjoint of monthly mean files calculated |
129 |
c-- in cost_averagesfields (and their ad...). |
130 |
cph( |
131 |
cph The following init. shoud not be applied if in the middle |
132 |
cph of a divided adjoint run |
133 |
cph) |
134 |
#ifndef ALLOW_TANGENTLINEAR_RUN |
135 |
cph!!! and I think it needs to be seen by TAF |
136 |
cph!!! for repeated TLM runs |
137 |
cph!!! |
138 |
inquire( file='costfinal', exist=exst ) |
139 |
if ( .NOT. exst) then |
140 |
call ecco_cost_init_barfiles( mythid ) |
141 |
endif |
142 |
#endif |
143 |
|
144 |
#ifdef ALLOW_TRANSPORT_COST_CONTRIBUTION |
145 |
_BEGIN_MASTER(myThid) |
146 |
ilo = ifnblnk(costTranspDataFile) |
147 |
ihi = ilnblnk(costTranspDataFile) |
148 |
CALL OPEN_COPY_DATA_FILE( |
149 |
I costTranspDataFile(ilo:ihi), |
150 |
I 'ECCO_COST_INIT_FIXED', |
151 |
O gwunit, |
152 |
I myThid ) |
153 |
do irec = 1, ndaysrec |
154 |
c-- read daily transport time series |
155 |
c-- 1st: transport in m/s |
156 |
c-- 2nd: date in YYYYMMDD |
157 |
c-- 3rd: uncertainty in m/s |
158 |
read(gwunit,*) transpobs(irec), dummy, wtransp(irec) |
159 |
c-- convert std.dev. to weight |
160 |
if ( wtransp(irec) .NE. 0. ) |
161 |
& wtransp(irec) =1./(wtransp(irec)*wtransp(irec)) |
162 |
c-- set weight to zero for missing values |
163 |
if ( transpobs(irec) .EQ. missingObsFlag ) |
164 |
& wtransp(irec) = 0. |
165 |
enddo |
166 |
_END_MASTER(myThid) |
167 |
_BARRIER |
168 |
#endif /* ALLOW_TRANSPORT_COST_CONTRIBUTION */ |
169 |
|
170 |
c-- Summarize the cost function's setup. |
171 |
_BEGIN_MASTER( mythid ) |
172 |
call ecco_cost_summary( mythid ) |
173 |
_END_MASTER( mythid ) |
174 |
|
175 |
_BARRIER |
176 |
|
177 |
end |