1 |
gforget |
1.5 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_bp_read.F,v 1.4 2012/08/10 19:45:25 jmc Exp $ |
2 |
gforget |
1.1 |
C $Name: $ |
3 |
|
|
|
4 |
jmc |
1.4 |
#include "ECCO_OPTIONS.h" |
5 |
gforget |
1.1 |
|
6 |
|
|
|
7 |
|
|
subroutine cost_bp_read( |
8 |
gforget |
1.5 |
I localobsfile, localstartdate, |
9 |
|
|
O localobs, localmask, |
10 |
|
|
I irec,myThid) |
11 |
gforget |
1.1 |
|
12 |
|
|
c ================================================================== |
13 |
|
|
c SUBROUTINE cost_bp_read |
14 |
|
|
c ================================================================== |
15 |
|
|
c |
16 |
|
|
c o Read a given record of the GRACE data. |
17 |
|
|
c |
18 |
|
|
c started: Gael Forget Oct-2009 |
19 |
|
|
c |
20 |
|
|
c ================================================================== |
21 |
|
|
c SUBROUTINE cost_bp_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 |
gforget |
1.5 |
#ifdef ALLOW_CAL |
34 |
|
|
# include "cal.h" |
35 |
|
|
#endif |
36 |
|
|
#ifdef ALLOW_ECCO |
37 |
|
|
# include "ecco_cost.h" |
38 |
|
|
#endif |
39 |
gforget |
1.1 |
|
40 |
|
|
c == routine arguments == |
41 |
|
|
|
42 |
gforget |
1.5 |
character*(MAX_LEN_FNAM) localobsfile |
43 |
|
|
integer localstartdate(4) |
44 |
|
|
_RL localobs (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
45 |
|
|
_RL localmask (1-olx:snx+olx,1-oly:sny+oly,nsx,nsy) |
46 |
gforget |
1.1 |
integer irec |
47 |
|
|
integer mythid |
48 |
|
|
|
49 |
gforget |
1.5 |
#ifdef ALLOW_ECCO |
50 |
gforget |
1.1 |
|
51 |
|
|
c == local variables == |
52 |
|
|
|
53 |
|
|
integer bi,bj |
54 |
|
|
integer i,j,k |
55 |
|
|
integer itlo,ithi |
56 |
|
|
integer jtlo,jthi |
57 |
|
|
integer jmin,jmax |
58 |
|
|
integer imin,imax |
59 |
|
|
integer nobs |
60 |
|
|
integer bprec |
61 |
|
|
integer beginbp |
62 |
|
|
integer beginrun |
63 |
|
|
|
64 |
gforget |
1.3 |
INTEGER beginlocal, beginmodel, obsrec |
65 |
|
|
|
66 |
gforget |
1.1 |
_RL spval |
67 |
|
|
_RL vartile |
68 |
|
|
|
69 |
|
|
cnew( |
70 |
|
|
integer il |
71 |
|
|
integer mody, modm |
72 |
|
|
integer iyear, imonth |
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 |
|
|
parameter (spval = -998. ) |
85 |
|
|
ce --> there is certainly a better place for this. |
86 |
|
|
|
87 |
|
|
jtlo = mybylo(mythid) |
88 |
|
|
jthi = mybyhi(mythid) |
89 |
|
|
itlo = mybxlo(mythid) |
90 |
|
|
ithi = mybxhi(mythid) |
91 |
|
|
jmin = 1 |
92 |
|
|
jmax = sny |
93 |
|
|
imin = 1 |
94 |
|
|
imax = snx |
95 |
|
|
|
96 |
gforget |
1.3 |
|
97 |
gforget |
1.5 |
beginlocal = localstartdate(1)/10000 |
98 |
gforget |
1.3 |
beginmodel = modelstartdate(1)/10000 |
99 |
|
|
obsrec = ( beginmodel - beginlocal )*nmonthyear |
100 |
|
|
& + ( mod(modelstartdate(1)/100,100) |
101 |
gforget |
1.5 |
& -mod(localstartdate(1)/100,100) ) |
102 |
gforget |
1.3 |
& + irec |
103 |
|
|
|
104 |
gforget |
1.1 |
mody = modelstartdate(1)/10000 |
105 |
|
|
modm = modelstartdate(1)/100 - mody*100 |
106 |
|
|
iyear = mody + INT((modm-1+irec-1)/12) |
107 |
|
|
imonth = 1 + MOD(modm-1+irec-1,12) |
108 |
|
|
|
109 |
gforget |
1.5 |
il=ilnblnk(localobsfile) |
110 |
gforget |
1.1 |
write(fnametmp(1:80),'(2a,i4)') |
111 |
gforget |
1.5 |
& localobsfile(1:il), '_', iyear |
112 |
gforget |
1.1 |
inquire( file=fnametmp, exist=exst ) |
113 |
|
|
if (.NOT. exst) then |
114 |
gforget |
1.5 |
write(fnametmp(1:80),'(a)') localobsfile(1:il) |
115 |
gforget |
1.3 |
imonth = obsrec |
116 |
gforget |
1.1 |
endif |
117 |
|
|
|
118 |
gforget |
1.3 |
if ( (obsrec.GT.0).AND.(imonth.GT.0) ) then |
119 |
|
|
call mdsreadfield( fnametmp, cost_iprec, cost_yftype, 1, |
120 |
gforget |
1.5 |
& localobs, imonth, mythid ) |
121 |
gforget |
1.3 |
else |
122 |
|
|
do bj = jtlo,jthi |
123 |
|
|
do bi = itlo,ithi |
124 |
|
|
do j = jmin,jmax |
125 |
|
|
do i = imin,imax |
126 |
gforget |
1.5 |
localobs(i,j,bi,bj) = spval |
127 |
gforget |
1.3 |
enddo |
128 |
|
|
enddo |
129 |
|
|
enddo |
130 |
|
|
enddo |
131 |
|
|
endif |
132 |
gforget |
1.1 |
|
133 |
|
|
nobs = 0 |
134 |
|
|
|
135 |
|
|
do bj = jtlo,jthi |
136 |
|
|
do bi = itlo,ithi |
137 |
|
|
k = 1 |
138 |
|
|
do j = jmin,jmax |
139 |
|
|
do i = imin,imax |
140 |
gforget |
1.2 |
c if (maskC(i,j,k,bi,bj) .eq. 0.) then |
141 |
gforget |
1.5 |
c localmask(i,j,bi,bj) = 0. _d 0 |
142 |
gforget |
1.2 |
c else |
143 |
gforget |
1.5 |
c localmask(i,j,bi,bj) = 1. _d 0 |
144 |
gforget |
1.2 |
c endif |
145 |
gforget |
1.5 |
if (localobs(i,j,bi,bj) .le. spval) then |
146 |
|
|
localmask(i,j,bi,bj) = 0. _d 0 |
147 |
gforget |
1.1 |
else |
148 |
gforget |
1.5 |
localmask(i,j,bi,bj) = 1. _d 0 |
149 |
gforget |
1.1 |
endif |
150 |
gforget |
1.5 |
localobs(i,j,bi,bj) = localobs(i,j,bi,bj)* |
151 |
|
|
& localmask(i,j,bi,bj) |
152 |
|
|
nobs = nobs + int(localmask(i,j,bi,bj)) |
153 |
gforget |
1.1 |
enddo |
154 |
|
|
enddo |
155 |
|
|
enddo |
156 |
|
|
enddo |
157 |
|
|
|
158 |
|
|
#endif |
159 |
|
|
|
160 |
|
|
return |
161 |
|
|
end |
162 |
|
|
|