1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_bp_read.F,v 1.3 2012/02/28 00:51:07 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ECCO_OPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine cost_bp_read( |
8 |
I irec, |
9 |
I mythid |
10 |
& ) |
11 |
|
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 |
#include "cal.h" |
34 |
#include "ecco_cost.h" |
35 |
|
36 |
c == routine arguments == |
37 |
|
38 |
integer irec |
39 |
integer mythid |
40 |
|
41 |
#ifdef ALLOW_BP_COST_CONTRIBUTION |
42 |
|
43 |
c == local variables == |
44 |
|
45 |
integer bi,bj |
46 |
integer i,j,k |
47 |
integer itlo,ithi |
48 |
integer jtlo,jthi |
49 |
integer jmin,jmax |
50 |
integer imin,imax |
51 |
integer nobs |
52 |
integer bprec |
53 |
integer beginbp |
54 |
integer beginrun |
55 |
|
56 |
INTEGER beginlocal, beginmodel, obsrec |
57 |
|
58 |
_RL spval |
59 |
_RL vartile |
60 |
|
61 |
cnew( |
62 |
integer il |
63 |
integer mody, modm |
64 |
integer iyear, imonth |
65 |
character*(80) fnametmp |
66 |
logical exst |
67 |
cnew) |
68 |
|
69 |
c == external functions == |
70 |
|
71 |
integer ilnblnk |
72 |
external ilnblnk |
73 |
|
74 |
c == end of interface == |
75 |
|
76 |
parameter (spval = -998. ) |
77 |
ce --> there is certainly a better place for this. |
78 |
|
79 |
jtlo = mybylo(mythid) |
80 |
jthi = mybyhi(mythid) |
81 |
itlo = mybxlo(mythid) |
82 |
ithi = mybxhi(mythid) |
83 |
jmin = 1 |
84 |
jmax = sny |
85 |
imin = 1 |
86 |
imax = snx |
87 |
|
88 |
|
89 |
beginlocal = bpstartdate(1)/10000 |
90 |
beginmodel = modelstartdate(1)/10000 |
91 |
obsrec = ( beginmodel - beginlocal )*nmonthyear |
92 |
& + ( mod(modelstartdate(1)/100,100) |
93 |
& -mod(bpstartdate(1)/100,100) ) |
94 |
& + irec |
95 |
|
96 |
mody = modelstartdate(1)/10000 |
97 |
modm = modelstartdate(1)/100 - mody*100 |
98 |
iyear = mody + INT((modm-1+irec-1)/12) |
99 |
imonth = 1 + MOD(modm-1+irec-1,12) |
100 |
|
101 |
il=ilnblnk(bpdatfile) |
102 |
write(fnametmp(1:80),'(2a,i4)') |
103 |
& bpdatfile(1:il), '_', iyear |
104 |
inquire( file=fnametmp, exist=exst ) |
105 |
if (.NOT. exst) then |
106 |
write(fnametmp(1:80),'(a)') bpdatfile(1:il) |
107 |
imonth = obsrec |
108 |
endif |
109 |
|
110 |
if ( (obsrec.GT.0).AND.(imonth.GT.0) ) then |
111 |
call mdsreadfield( fnametmp, cost_iprec, cost_yftype, 1, |
112 |
& bpdat, imonth, mythid ) |
113 |
else |
114 |
do bj = jtlo,jthi |
115 |
do bi = itlo,ithi |
116 |
do j = jmin,jmax |
117 |
do i = imin,imax |
118 |
bpdat(i,j,bi,bj) = spval |
119 |
enddo |
120 |
enddo |
121 |
enddo |
122 |
enddo |
123 |
endif |
124 |
|
125 |
nobs = 0 |
126 |
|
127 |
do bj = jtlo,jthi |
128 |
do bi = itlo,ithi |
129 |
k = 1 |
130 |
do j = jmin,jmax |
131 |
do i = imin,imax |
132 |
c if (maskC(i,j,k,bi,bj) .eq. 0.) then |
133 |
c bpmask(i,j,bi,bj) = 0. _d 0 |
134 |
c else |
135 |
c bpmask(i,j,bi,bj) = 1. _d 0 |
136 |
c endif |
137 |
if (bpdat(i,j,bi,bj) .le. spval) then |
138 |
bpmask(i,j,bi,bj) = 0. _d 0 |
139 |
else |
140 |
bpmask(i,j,bi,bj) = 1. _d 0 |
141 |
endif |
142 |
bpdat(i,j,bi,bj) = bpdat(i,j,bi,bj)* |
143 |
& bpmask(i,j,bi,bj) |
144 |
nobs = nobs + int(bpmask(i,j,bi,bj)) |
145 |
enddo |
146 |
enddo |
147 |
enddo |
148 |
enddo |
149 |
|
150 |
#endif |
151 |
|
152 |
return |
153 |
end |
154 |
|