1 |
gforget |
1.17 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_readers.F,v 1.16 2014/10/18 18:15:44 gforget Exp $ |
2 |
jmc |
1.7 |
C $Name: $ |
3 |
heimbach |
1.1 |
|
4 |
jmc |
1.13 |
#include "ECCO_OPTIONS.h" |
5 |
heimbach |
1.1 |
|
6 |
|
|
|
7 |
heimbach |
1.4 |
subroutine cost_readers( irec, mythid ) |
8 |
heimbach |
1.1 |
|
9 |
|
|
c ================================================================== |
10 |
heimbach |
1.4 |
c SUBROUTINE cost_readers |
11 |
heimbach |
1.1 |
c ================================================================== |
12 |
|
|
c |
13 |
|
|
c o Read a given record of the ERS SSH data. |
14 |
|
|
c |
15 |
|
|
c started: Christian Eckert eckert@mit.edu 25-May-1999 |
16 |
|
|
c |
17 |
|
|
c changed: Christian Eckert eckert@mit.edu 25-Feb-2000 |
18 |
|
|
c |
19 |
|
|
c - Restructured the code in order to create a package |
20 |
|
|
c for the MITgcmUV. |
21 |
|
|
c |
22 |
|
|
c ================================================================== |
23 |
heimbach |
1.4 |
c SUBROUTINE cost_readers |
24 |
heimbach |
1.1 |
c ================================================================== |
25 |
|
|
|
26 |
|
|
implicit none |
27 |
|
|
|
28 |
|
|
c == global variables == |
29 |
|
|
|
30 |
gforget |
1.16 |
#ifdef ALLOW_SSH_ERSANOM_COST_CONTRIBUTION |
31 |
heimbach |
1.1 |
#include "EEPARAMS.h" |
32 |
|
|
#include "SIZE.h" |
33 |
|
|
#include "PARAMS.h" |
34 |
|
|
#include "GRID.h" |
35 |
|
|
|
36 |
|
|
#include "cal.h" |
37 |
|
|
#include "ecco_cost.h" |
38 |
gforget |
1.16 |
#endif |
39 |
heimbach |
1.1 |
|
40 |
|
|
c == routine arguments == |
41 |
|
|
|
42 |
|
|
integer irec |
43 |
|
|
integer mythid |
44 |
|
|
|
45 |
|
|
#ifdef ALLOW_SSH_ERSANOM_COST_CONTRIBUTION |
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 sshrec |
55 |
|
|
integer difftime(4) |
56 |
jmc |
1.12 |
integer tempDate_1 |
57 |
heimbach |
1.1 |
integer middate(4) |
58 |
|
|
integer noffset |
59 |
|
|
_RL diffsecs |
60 |
|
|
_RL spval |
61 |
|
|
_RL factor |
62 |
|
|
|
63 |
heimbach |
1.2 |
cnew( |
64 |
|
|
integer il |
65 |
|
|
_RL daytime |
66 |
|
|
integer dayiter |
67 |
|
|
integer daydate(4) |
68 |
|
|
integer yday, ymod |
69 |
|
|
integer md, dd, sd, ld, wd |
70 |
|
|
character*(80) fnametmp |
71 |
|
|
logical exst |
72 |
|
|
cnew) |
73 |
|
|
|
74 |
|
|
c == external functions == |
75 |
jmc |
1.7 |
|
76 |
heimbach |
1.2 |
integer ilnblnk |
77 |
|
|
external ilnblnk |
78 |
|
|
|
79 |
heimbach |
1.1 |
c == end of interface == |
80 |
|
|
|
81 |
|
|
jtlo = mybylo(mythid) |
82 |
|
|
jthi = mybyhi(mythid) |
83 |
|
|
itlo = mybxlo(mythid) |
84 |
|
|
ithi = mybxhi(mythid) |
85 |
|
|
jmin = 1 |
86 |
|
|
jmax = sny |
87 |
|
|
imin = 1 |
88 |
|
|
imax = snx |
89 |
|
|
|
90 |
jmc |
1.9 |
factor = 0.01 _d 0 |
91 |
|
|
spval = -9990. _d 0 |
92 |
heimbach |
1.1 |
|
93 |
heimbach |
1.2 |
cnew( |
94 |
gforget |
1.6 |
daytime = FLOAT(secondsperday*(irec-1)) + modelstart |
95 |
|
|
dayiter = hoursperday*(irec-1)+modeliter0 |
96 |
heimbach |
1.2 |
call cal_getdate( dayiter, daytime, daydate, mythid ) |
97 |
|
|
call cal_convdate( daydate,yday,md,dd,sd,ld,wd,mythid ) |
98 |
|
|
ymod = ersstartdate(1)/10000 |
99 |
|
|
|
100 |
gforget |
1.11 |
if ( ymod .GE. yday ) then |
101 |
|
|
call cal_FullDate( ersstartdate(1), 0, middate, mythid) |
102 |
heimbach |
1.2 |
else |
103 |
jmc |
1.12 |
tempDate_1 = yday*10000+100+1 |
104 |
|
|
call cal_FullDate( tempDate_1, 0, middate, mythid) |
105 |
heimbach |
1.2 |
endif |
106 |
heimbach |
1.1 |
|
107 |
heimbach |
1.2 |
call cal_TimePassed( middate, daydate, difftime, mythid ) |
108 |
heimbach |
1.1 |
call cal_ToSeconds( difftime, diffsecs, mythid ) |
109 |
gforget |
1.11 |
c sshrec = floor(diffsecs/ersperiod) + 1 |
110 |
heimbach |
1.2 |
sshrec = int(diffsecs/ersperiod) + 1 |
111 |
heimbach |
1.1 |
|
112 |
heimbach |
1.2 |
il=ilnblnk(ersfile) |
113 |
|
|
write(fnametmp(1:80),'(2a,i4)') |
114 |
|
|
& ersfile(1:il), '_', yday |
115 |
|
|
inquire( file=fnametmp, exist=exst ) |
116 |
|
|
if (.NOT. exst) then |
117 |
|
|
write(fnametmp(1:80),'(a)') ersfile(1:il) |
118 |
gforget |
1.11 |
call cal_TimePassed(ersstartdate,daydate,difftime,mythid) |
119 |
|
|
call cal_ToSeconds( difftime, diffsecs, mythid ) |
120 |
|
|
c sshrec = floor(diffsecs/ersperiod) + 1 |
121 |
|
|
sshrec = int(diffsecs/ersperiod) + 1 |
122 |
|
|
inquire( file=fnametmp, exist=exst ) |
123 |
heimbach |
1.1 |
endif |
124 |
jmc |
1.7 |
|
125 |
heimbach |
1.2 |
cnew) |
126 |
|
|
|
127 |
gforget |
1.11 |
c read data: |
128 |
|
|
if ( (sshrec .GT. 0).AND.(exst) ) then |
129 |
jmc |
1.7 |
call mdsreadfield( fnametmp, cost_iprec, cost_yftype, 1, ersobs, |
130 |
heimbach |
1.2 |
& sshrec, mythid ) |
131 |
gforget |
1.11 |
else |
132 |
|
|
do bj = jtlo,jthi |
133 |
|
|
do bi = itlo,ithi |
134 |
|
|
do j = jmin,jmax |
135 |
|
|
do i = imin,imax |
136 |
|
|
ersobs(i,j,bi,bj) = spval |
137 |
|
|
enddo |
138 |
|
|
enddo |
139 |
|
|
enddo |
140 |
|
|
enddo |
141 |
|
|
endif |
142 |
heimbach |
1.2 |
|
143 |
heimbach |
1.1 |
do bj = jtlo,jthi |
144 |
|
|
do bi = itlo,ithi |
145 |
|
|
k = 1 |
146 |
|
|
do j = jmin,jmax |
147 |
|
|
do i = imin,imax |
148 |
|
|
if (_hFacC(i,j,k,bi,bj) .eq. 0.) then |
149 |
|
|
ersmask(i,j,bi,bj) = 0. _d 0 |
150 |
|
|
else |
151 |
|
|
ersmask(i,j,bi,bj) = 1. _d 0 |
152 |
|
|
endif |
153 |
|
|
if (ersobs(i,j,bi,bj) .le. spval) then |
154 |
|
|
ersmask(i,j,bi,bj) = 0. _d 0 |
155 |
|
|
endif |
156 |
|
|
if (abs(ersobs(i,j,bi,bj)) .lt. 1.d-8 ) then |
157 |
|
|
ersmask(i,j,bi,bj) = 0. _d 0 |
158 |
|
|
endif |
159 |
|
|
|
160 |
gforget |
1.14 |
#ifndef ALLOW_SHALLOW_ALTIMETRY |
161 |
heimbach |
1.8 |
if ( R_low(i,j,bi,bj) .GT. -200. ) then |
162 |
heimbach |
1.1 |
ersmask(i,j,bi,bj) = 0. _d 0 |
163 |
|
|
endif |
164 |
gforget |
1.14 |
#endif |
165 |
gforget |
1.15 |
#ifndef ALLOW_HIGHLAT_ALTIMETRY |
166 |
|
|
if ( abs(YC(i,j,bi,bj)) .GT. 66. ) then |
167 |
|
|
ersmask(i,j,bi,bj) = 0. _d 0 |
168 |
|
|
endif |
169 |
|
|
#endif |
170 |
heimbach |
1.1 |
|
171 |
|
|
ersmask(i,j,bi,bj) = ersmask(i,j,bi,bj)*frame(i,j) |
172 |
heimbach |
1.5 |
ersobs(i,j,bi,bj) = ersmask(i,j,bi,bj)*factor* |
173 |
jmc |
1.7 |
& ( ersobs(i,j,bi,bj) - |
174 |
heimbach |
1.5 |
& ( ersintercept + ersslope*irec*hoursperday ) ) |
175 |
heimbach |
1.1 |
enddo |
176 |
|
|
enddo |
177 |
|
|
enddo |
178 |
|
|
enddo |
179 |
|
|
|
180 |
|
|
#endif |
181 |
|
|
|
182 |
|
|
return |
183 |
|
|
end |