1 |
C $Header: $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "COST_CPPOPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine cost_ReadscatxFields( |
8 |
I irec, |
9 |
I mythid |
10 |
& ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_ReadscatxFields |
14 |
c ================================================================== |
15 |
c |
16 |
c o Read a given record of the SST data. |
17 |
c |
18 |
c started: Christian Eckert eckert@mit.edu 25-May-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 ================================================================== |
26 |
c SUBROUTINE cost_ReadscatxFields |
27 |
c ================================================================== |
28 |
|
29 |
implicit none |
30 |
|
31 |
c == global variables == |
32 |
|
33 |
#include "EEPARAMS.h" |
34 |
#include "SIZE.h" |
35 |
#include "PARAMS.h" |
36 |
#include "GRID.h" |
37 |
|
38 |
#include "cal.h" |
39 |
#include "ecco_cost.h" |
40 |
|
41 |
c == routine arguments == |
42 |
|
43 |
integer irec |
44 |
integer mythid |
45 |
|
46 |
c == local variables == |
47 |
|
48 |
integer bi,bj |
49 |
integer i,j,k |
50 |
integer itlo,ithi |
51 |
integer jtlo,jthi |
52 |
integer jmin,jmax |
53 |
integer imin,imax |
54 |
integer nobs |
55 |
integer scatxrec |
56 |
integer beginscatx |
57 |
integer beginrun |
58 |
|
59 |
_RL spval |
60 |
_RL vartile |
61 |
|
62 |
cnew( |
63 |
integer il |
64 |
integer mody, modm |
65 |
integer iyear, imonth |
66 |
character*(80) fnametmp |
67 |
logical exst |
68 |
cnew) |
69 |
|
70 |
c == external functions == |
71 |
|
72 |
integer ilnblnk |
73 |
external ilnblnk |
74 |
|
75 |
c == end of interface == |
76 |
|
77 |
parameter (spval = -1.8 ) |
78 |
ce --> there is certainly a better place for this. |
79 |
|
80 |
jtlo = mybylo(mythid) |
81 |
jthi = mybyhi(mythid) |
82 |
itlo = mybxlo(mythid) |
83 |
ithi = mybxhi(mythid) |
84 |
jmin = 1 |
85 |
jmax = sny |
86 |
imin = 1 |
87 |
imax = snx |
88 |
|
89 |
c beginscatx = scatxstartdate(1)/10000 |
90 |
c beginrun = modelstartdate(1)/10000 |
91 |
c if ( beginscatx .eq. beginrun ) then |
92 |
c scatxrec = mod(modelstartdate(1)/100,100) - |
93 |
c & mod(scatxstartdate(1)/100,100) + irec |
94 |
c else |
95 |
c scatxrec = ( beginrun - beginscatx - 1)*nmonthyear + |
96 |
c & (nmonthyear - mod(scatxstartdate(1)/100,100) + |
97 |
c & 1) + mod(modelstartdate(1)/100,100) - 1 + irec |
98 |
c endif |
99 |
|
100 |
|
101 |
cnew( |
102 |
mody = modelstartdate(1)/10000 |
103 |
modm = modelstartdate(1)/100 - mody*100 |
104 |
iyear = mody + INT((modm-1+irec-1)/12) |
105 |
imonth = 1 + MOD(modm-1+irec-1,12) |
106 |
|
107 |
il=ilnblnk(scatxdatfile) |
108 |
write(fnametmp(1:80),'(2a,i4)') |
109 |
& scatxdatfile(1:il), '_', iyear |
110 |
inquire( file=fnametmp, exist=exst ) |
111 |
if (.NOT. exst) then |
112 |
write(fnametmp(1:80),'(a)') scatxdatfile(1:il) |
113 |
imonth = irec |
114 |
endif |
115 |
|
116 |
call mdsreadfield( fnametmp, cost_iprec, cost_yftype, 1, |
117 |
& scatxdat, imonth, mythid ) |
118 |
cnew) |
119 |
|
120 |
nobs = 0 |
121 |
|
122 |
do bj = jtlo,jthi |
123 |
do bi = itlo,ithi |
124 |
k = 1 |
125 |
do j = jmin,jmax |
126 |
do i = imin,imax |
127 |
if (maskW(i,j,k,bi,bj) .eq. 0.) then |
128 |
scatxmask(i,j,bi,bj) = 0. _d 0 |
129 |
else if (_hFacC(i,j,13,bi,bj) .eq. 0.) then |
130 |
scatxmask(i,j,bi,bj) = 0. _d 0 |
131 |
else |
132 |
scatxmask(i,j,bi,bj) = 1. _d 0 |
133 |
endif |
134 |
if (scatxdat(i,j,bi,bj) .lt. spval) then |
135 |
scatxmask(i,j,bi,bj) = 0. _d 0 |
136 |
endif |
137 |
if (scatxdat(i,j,bi,bj) .eq. 0. _d 0 ) then |
138 |
scatxmask(i,j,bi,bj) = 0. _d 0 |
139 |
endif |
140 |
scatxmask(i,j,bi,bj) = scatxmask(i,j,bi,bj)*frame(i,j) |
141 |
scatxdat(i,j,bi,bj) = scatxdat(i,j,bi,bj)* |
142 |
& scatxmask(i,j,bi,bj) |
143 |
nobs = nobs + int(scatxmask(i,j,bi,bj)) |
144 |
enddo |
145 |
enddo |
146 |
enddo |
147 |
enddo |
148 |
|
149 |
c-- Calculate the field variance for present subdomain. |
150 |
c-- One could of course do a global sum here. |
151 |
vartile = 0. _d 0 |
152 |
do bj = jtlo,jthi |
153 |
do bi = itlo,ithi |
154 |
do j = jmin,jmax |
155 |
do i = imin,imax |
156 |
vartile=vartile+scatxdat(i,j,bi,bj)*scatxdat(i,j,bi,bj) |
157 |
enddo |
158 |
enddo |
159 |
enddo |
160 |
enddo |
161 |
|
162 |
if (nobs .gt. 0) then |
163 |
vartile = vartile/float(nobs) |
164 |
else |
165 |
vartile = spval |
166 |
endif |
167 |
|
168 |
return |
169 |
end |
170 |
|