1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_sla_read.F,v 1.5 2012/08/10 19:45:26 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ECCO_OPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine cost_sla_read( sla_file, sla_startdate, sla_period, |
8 |
I sla_intercept, sla_slope, |
9 |
O sla_obs, sla_mask, |
10 |
I irec, mythid ) |
11 |
|
12 |
c ================================================================== |
13 |
c SUBROUTINE cost_sla_read |
14 |
c ================================================================== |
15 |
c |
16 |
c o Read a given record of the SLA data. |
17 |
c |
18 |
c started: Gael Forget 20-Oct-2009 |
19 |
c |
20 |
c ================================================================== |
21 |
c SUBROUTINE cost_sla_read |
22 |
c ================================================================== |
23 |
|
24 |
implicit none |
25 |
|
26 |
c == global variables == |
27 |
|
28 |
#include "EEPARAMS.h" |
29 |
#include "SIZE.h" |
30 |
#include "PARAMS.h" |
31 |
#include "GRID.h" |
32 |
|
33 |
#include "cal.h" |
34 |
#include "ecco_cost.h" |
35 |
|
36 |
c == routine arguments == |
37 |
|
38 |
integer irec |
39 |
integer mythid |
40 |
|
41 |
c == local variables == |
42 |
|
43 |
integer bi,bj |
44 |
integer i,j,k |
45 |
integer itlo,ithi |
46 |
integer jtlo,jthi |
47 |
integer jmin,jmax |
48 |
integer imin,imax |
49 |
integer sshrec |
50 |
integer difftime(4) |
51 |
integer tempDate_1 |
52 |
integer middate(4) |
53 |
integer noffset |
54 |
_RL diffsecs |
55 |
_RL spval |
56 |
_RL factor |
57 |
|
58 |
integer sla_startdate(4) |
59 |
_RL sla_period |
60 |
_RL sla_intercept |
61 |
_RL sla_slope |
62 |
_RL sla_obs (1-olx:snx+olx,1-oly:sny+oly, nsx,nsy) |
63 |
_RL sla_mask (1-olx:snx+olx,1-oly:sny+oly, nsx,nsy) |
64 |
character*(MAX_LEN_FNAM) sla_file |
65 |
|
66 |
cnew( |
67 |
integer il |
68 |
_RL daytime |
69 |
integer dayiter |
70 |
integer daydate(4) |
71 |
integer yday, ymod |
72 |
integer md, dd, sd, ld, wd |
73 |
character*(80) fnametmp |
74 |
logical exst |
75 |
cnew) |
76 |
|
77 |
c == external functions == |
78 |
|
79 |
integer ilnblnk |
80 |
external ilnblnk |
81 |
|
82 |
c == end of interface == |
83 |
|
84 |
jtlo = mybylo(mythid) |
85 |
jthi = mybyhi(mythid) |
86 |
itlo = mybxlo(mythid) |
87 |
ithi = mybxhi(mythid) |
88 |
jmin = 1 |
89 |
jmax = sny |
90 |
imin = 1 |
91 |
imax = snx |
92 |
|
93 |
factor = 0.01 |
94 |
spval = -9990. |
95 |
|
96 |
c select data record to read |
97 |
daytime = FLOAT(secondsperday*(irec-1)) + modelstart |
98 |
dayiter = hoursperday*(irec-1)+modeliter0 |
99 |
call cal_getdate( dayiter, daytime, daydate, mythid ) |
100 |
call cal_convdate( daydate,yday,md,dd,sd,ld,wd,mythid ) |
101 |
ymod = sla_startdate(1)/10000 |
102 |
|
103 |
if ( ymod .GE. yday ) then |
104 |
call cal_FullDate( sla_startdate(1), 0, middate, mythid) |
105 |
else |
106 |
tempDate_1 = yday*10000+100+1 |
107 |
call cal_FullDate( tempDate_1, 0, middate, mythid) |
108 |
endif |
109 |
|
110 |
call cal_TimePassed( middate, daydate, difftime, mythid ) |
111 |
call cal_ToSeconds( difftime, diffsecs, mythid ) |
112 |
c sshrec = floor(diffsecs/sla_period) + 1 |
113 |
sshrec = int(diffsecs/sla_period) + 1 |
114 |
|
115 |
il=ilnblnk(sla_file) |
116 |
write(fnametmp(1:80),'(2a,i4)') |
117 |
& sla_file(1:il), '_', yday |
118 |
inquire( file=fnametmp, exist=exst ) |
119 |
|
120 |
c read data: |
121 |
if ( (sshrec .GT. 0).AND.(exst) ) then |
122 |
call mdsreadfield( fnametmp, cost_iprec, cost_yftype, |
123 |
& 1, sla_obs, sshrec, mythid ) |
124 |
else |
125 |
do bj = jtlo,jthi |
126 |
do bi = itlo,ithi |
127 |
do j = jmin,jmax |
128 |
do i = imin,imax |
129 |
sla_obs(i,j,bi,bj) = spval |
130 |
enddo |
131 |
enddo |
132 |
enddo |
133 |
enddo |
134 |
endif |
135 |
|
136 |
c mask data: |
137 |
do bj = jtlo,jthi |
138 |
do bi = itlo,ithi |
139 |
k = 1 |
140 |
do j = jmin,jmax |
141 |
do i = imin,imax |
142 |
if (_hFacC(i,j,k,bi,bj) .eq. 0.) then |
143 |
sla_mask(i,j,bi,bj) = 0. _d 0 |
144 |
else |
145 |
sla_mask(i,j,bi,bj) = 1. _d 0 |
146 |
endif |
147 |
if (sla_obs(i,j,bi,bj) .le. spval) then |
148 |
sla_mask(i,j,bi,bj) = 0. _d 0 |
149 |
endif |
150 |
if (abs(sla_obs(i,j,bi,bj)) .lt. 1.d-8 ) then |
151 |
sla_mask(i,j,bi,bj) = 0. _d 0 |
152 |
endif |
153 |
|
154 |
cph( |
155 |
#ifndef ALLOW_SHALLOW_ALTIMETRY |
156 |
if ( R_low(i,j,bi,bj) .GT. -200. ) then |
157 |
sla_mask(i,j,bi,bj) = 0. _d 0 |
158 |
endif |
159 |
#endif |
160 |
cph) |
161 |
|
162 |
sla_mask(i,j,bi,bj) = sla_mask(i,j,bi,bj)*frame(i,j) |
163 |
sla_obs(i,j,bi,bj) = sla_mask(i,j,bi,bj)*factor* |
164 |
& ( sla_obs(i,j,bi,bj) - |
165 |
& ( sla_intercept + sla_slope*irec*hoursperday ) ) |
166 |
enddo |
167 |
enddo |
168 |
enddo |
169 |
enddo |
170 |
|
171 |
|
172 |
return |
173 |
end |
174 |
|