/[MITgcm]/MITgcm/pkg/ecco/ecco_cost_init_fixed.F
ViewVC logotype

Contents of /MITgcm/pkg/ecco/ecco_cost_init_fixed.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.18 - (show annotations) (download)
Wed Sep 30 15:49:56 2009 UTC (14 years, 8 months ago) by mlosch
Branch: MAIN
CVS Tags: checkpoint62, checkpoint62c, checkpoint62b, checkpoint62a, checkpoint61w, checkpoint61z, checkpoint61x, checkpoint61y
Changes since 1.17: +31 -20 lines
catch the case of empty filenames

1 C $Header: /u/gcmpack/MITgcm/pkg/ecco/ecco_cost_init_fixed.F,v 1.17 2009/03/23 23:29:29 jmc Exp $
2 C $Name: $
3
4 #include "PACKAGES_CONFIG.h"
5 #include "AD_CONFIG.h"
6 #include "COST_CPPOPTIONS.h"
7
8 subroutine ecco_cost_init_fixed( mythid )
9
10 c ==================================================================
11 c SUBROUTINE ecco_cost_init_fixed
12 c ==================================================================
13 c
14 c o Set contributions to the cost function and the cost function
15 c itself to zero. The cost function and the individual contribu-
16 c tions are defined in the header file "ecco_cost.h".
17 c
18 c started: Christian Eckert eckert@mit.edu 30-Jun-1999
19 c
20 c changed: Christian Eckert eckert@mit.edu 25-Feb-2000
21 c
22 c - Restructured the code in order to create a package
23 c for the MITgcmUV.
24 c
25 c changed: Ralf Giering 18-Jan-2001
26 c
27 c - move namelist reading to cost_readparms.F
28 c
29 c ==================================================================
30 c SUBROUTINE ecco_cost_init_fixed
31 c ==================================================================
32
33 implicit none
34
35 c == global variables ==
36
37 #include "EEPARAMS.h"
38 #include "SIZE.h"
39 #include "GRID.h"
40 #include "PARAMS.h"
41
42 #ifdef ALLOW_CAL
43 #include "cal.h"
44 #endif
45 #include "ecco_cost.h"
46
47 c == routine arguments ==
48
49 integer mythid
50
51 c == local variables ==
52
53 integer tempDate1(4)
54 integer tempDate2(4)
55 integer gwunit
56 integer ilo,ihi
57 integer irec
58 logical exst
59 _RL dummy
60 _RL missingObsFlag
61 PARAMETER ( missingObsFlag = 1. _d 23 )
62 character*(max_len_mbuf) msgbuf
63
64 c == external functions ==
65
66 integer cal_IntYears
67 external cal_IntYears
68 integer cal_IntMonths
69 external cal_IntMonths
70 integer cal_IntDays
71 external cal_IntDays
72 integer ifnblnk
73 external ifnblnk
74 integer ilnblnk
75 external ilnblnk
76
77 c == end of interface ==
78
79 #ifdef ALLOW_CAL
80
81 c-- The number of monthly and daily averages generated by the
82 c-- current model integration.
83 nyearsrec = cal_IntYears( mythid )
84 nmonsrec = cal_IntMonths( mythid )
85 ndaysrec = cal_IntDays( mythid )
86
87 _BEGIN_MASTER( myThid )
88
89 c-- Get the complete dates of the ...
90 c-- ... TMI data.
91 if ( tmidatfile .ne. ' ' )
92 & call cal_FullDate( tmistartdate1, tmistartdate2,
93 & tmistartdate, mythid )
94 c-- ... SST data.
95 if ( sstdatfile .ne. ' ' )
96 & call cal_FullDate( sststartdate1, sststartdate2,
97 & sststartdate, mythid )
98 c-- ... SSS data.
99 if ( sssdatfile .ne. ' ' )
100 & call cal_FullDate( sssstartdate1, sssstartdate2,
101 & sssstartdate, mythid )
102 c-- ... BP data.
103 if ( bpdatfile .ne. ' ' )
104 & call cal_FullDate( bpstartdate1, bpstartdate2,
105 & bpstartdate, mythid )
106 c-- ... T/P data.
107 if ( topexfile .ne. ' ' )
108 & call cal_FullDate( topexstartdate1, topexstartdate2,
109 & topexstartdate, mythid )
110 c-- ... ERS data.
111 if ( ersfile .ne. ' ' )
112 & call cal_FullDate( ersstartdate1, ersstartdate2,
113 & ersstartdate, mythid )
114 c-- ... GFO data.
115 if ( gfofile .ne. ' ' )
116 & call cal_FullDate( gfostartdate1, gfostartdate2,
117 & gfostartdate, mythid )
118 c-- ... SCAT data.
119 if ( scatxdatfile .ne. ' ' )
120 & call cal_FullDate( scatstartdate1, scatstartdate2,
121 & scatxstartdate, mythid )
122 if ( scatydatfile .ne. ' ' )
123 & call cal_FullDate( scatstartdate1, scatstartdate2,
124 & scatystartdate, mythid )
125 c-- ... ARGO data.
126 if ( argotfile .ne. ' ' )
127 & call cal_FullDate( argotstartdate1, argotstartdate2,
128 & argotstartdate, mythid )
129 if ( argosfile .ne. ' ' )
130 & call cal_FullDate( argosstartdate1, argotstartdate2,
131 & argosstartdate, mythid )
132
133 _END_MASTER( mythid )
134
135 #endif /* ALLOW_CAL */
136
137 call ecco_check( myThid )
138
139 c-- Get the weights that are to be used for the individual cost
140 c-- function contributions.
141 call ecco_cost_weights( mythid )
142
143 c-- Initialise adjoint of monthly mean files calculated
144 c-- in cost_averagesfields (and their ad...).
145 cph(
146 cph The following init. shoud not be applied if in the middle
147 cph of a divided adjoint run
148 cph)
149 #ifndef ALLOW_TANGENTLINEAR_RUN
150 cph!!! and I think it needs to be seen by TAF
151 cph!!! for repeated TLM runs
152 cph!!!
153 inquire( file='costfinal', exist=exst )
154 if ( .NOT. exst) then
155 call ecco_cost_init_barfiles( mythid )
156 endif
157 #endif
158
159 #ifdef ALLOW_TRANSPORT_COST_CONTRIBUTION
160 do irec = 1, ndaysrec
161 wtransp(irec) = 0. _d 0
162 transpobs(irec) = 0. _d 0
163 enddo
164
165 if ( costTranspDataFile .NE. ' ' ) then
166 _BEGIN_MASTER(myThid)
167 ilo = ifnblnk(costTranspDataFile)
168 ihi = ilnblnk(costTranspDataFile)
169 CALL OPEN_COPY_DATA_FILE(
170 I costTranspDataFile(ilo:ihi),
171 I 'ECCO_COST_INIT_FIXED',
172 O gwunit,
173 I myThid )
174 do irec = 1, ndaysrec
175 c-- read daily transport time series
176 c-- 1st: transport in m/s
177 c-- 2nd: date in YYYYMMDD
178 c-- 3rd: uncertainty in m/s
179 read(gwunit,*) transpobs(irec), dummy, wtransp(irec)
180 c-- convert std.dev. to weight
181 if ( wtransp(irec) .NE. 0. )
182 & wtransp(irec) =1.0/(wtransp(irec)*wtransp(irec))
183 c-- set weight to zero for missing values
184 if ( transpobs(irec) .EQ. missingObsFlag )
185 & wtransp(irec) = 0. _d 0
186 enddo
187 _END_MASTER(myThid)
188 _BARRIER
189 endif
190 #endif /* ALLOW_TRANSPORT_COST_CONTRIBUTION */
191
192 #ifdef ALLOW_SSH_COST_CONTRIBUTION
193
194 c-- Read flags for picking SSH time averages
195 do irec = 1, ndaysrec
196 tpTimeMask(irec) = 1. _d 0
197 ersTimeMask(irec) = 1. _d 0
198 gfoTimeMask(irec) = 1. _d 0
199 enddo
200 c
201 _BEGIN_MASTER(myThid)
202 c
203 #ifdef ALLOW_SSH_TPANOM_COST_CONTRIBUTION
204 if ( tpTimeMaskFile .NE. ' ' ) then
205 ilo = ifnblnk(tpTimeMaskFile)
206 ihi = ilnblnk(tpTimeMaskFile)
207 CALL OPEN_COPY_DATA_FILE(
208 I tpTimeMaskFile(ilo:ihi),
209 I 'cost_ssh tp',
210 O gwunit,
211 I myThid )
212 do irec = 1, ndaysrec
213 read(gwunit,*) tpTimeMask(irec)
214 enddo
215 endif
216 #endif
217 c
218 #ifdef ALLOW_SSH_ERSANOM_COST_CONTRIBUTION
219 if ( ersTimeMaskFile .NE. ' ' ) then
220 ilo = ifnblnk(ersTimeMaskFile)
221 ihi = ilnblnk(ersTimeMaskFile)
222 CALL OPEN_COPY_DATA_FILE(
223 I ersTimeMaskFile(ilo:ihi),
224 I 'cost_ssh ers',
225 O gwunit,
226 I myThid )
227 do irec = 1, ndaysrec
228 read(gwunit,*) ersTimeMask(irec)
229 enddo
230 endif
231 #endif
232 c
233 #ifdef ALLOW_SSH_GFOANOM_COST_CONTRIBUTION
234 if ( gfoTimeMaskFile .NE. ' ' ) then
235 ilo = ifnblnk(gfoTimeMaskFile)
236 ihi = ilnblnk(gfoTimeMaskFile)
237 CALL OPEN_COPY_DATA_FILE(
238 I gfoTimeMaskFile(ilo:ihi),
239 I 'cost_ssh gfo',
240 O gwunit,
241 I myThid )
242 do irec = 1, ndaysrec
243 read(gwunit,*) gfoTimeMask(irec)
244 enddo
245 endif
246 #endif
247 c
248 do irec = 1, ndaysrec
249 if (
250 & ( tpTimeMask(irec).NE.0. .AND. tpTimeMask(irec).NE.1. ) .OR.
251 & ( ersTimeMask(irec).NE.0. .AND. ersTimeMask(irec).NE.1. ) .OR.
252 & ( ersTimeMask(irec).NE.0. .AND. ersTimeMask(irec).NE.1. ) )
253 & then
254 WRITE(msgBuf,'(2A,I10)')
255 & 'ecco_cost_init_fixed: (SSH)TimeMask not 0. or 1. ',
256 & 'for irec (=day) ', irec
257 CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
258 & SQUEEZE_RIGHT , myThid )
259 CALL PRINT_ERROR( msgBuf , myThid )
260 STOP 'ABNORMAL END: S/R ECCO_COST_INIT_FIXED'
261 endif
262 enddo
263 c
264 _END_MASTER(myThid)
265 _BARRIER
266 #endif
267
268 c-- Summarize the cost function's setup.
269 _BEGIN_MASTER( mythid )
270 call ecco_cost_summary( mythid )
271 _END_MASTER( mythid )
272
273 _BARRIER
274
275 end

  ViewVC Help
Powered by ViewVC 1.1.22