1 | SUBROUTINE grstat (pcorx, pcory, psgr, kmsk, kngx, kngy, cdtyp, |
---|
2 | $ pdr, psr, phhi, kvma) |
---|
3 | C**** |
---|
4 | C ***************************** |
---|
5 | C * OASIS ROUTINE - LEVEL T * |
---|
6 | C * ------------- ------- * |
---|
7 | C ***************************** |
---|
8 | C |
---|
9 | C**** *grstat* - Statistic routine |
---|
10 | C |
---|
11 | C Purpose: |
---|
12 | C ------- |
---|
13 | C Given a grid, calculate the average grid square size, |
---|
14 | C the total surface and the inverse of sum of surface elements squared. |
---|
15 | C |
---|
16 | C** Interface: |
---|
17 | C --------- |
---|
18 | C *CALL* *grstat (pcorx, pcory, psgr, kmsk, kngx, kngy |
---|
19 | C pdr, psr, phhi, kvma)* |
---|
20 | C |
---|
21 | C Input: |
---|
22 | C ----- |
---|
23 | C pcorx : the grid points longitude (real 2D) |
---|
24 | C pcory : the grid points latitude (real 2D) |
---|
25 | C psgr : surface elements (real 2D) |
---|
26 | C kmsk : the grid mask (integer 2D) |
---|
27 | C kngx : the grid size in direction 1 |
---|
28 | C kngy : the grid size in direction 2 |
---|
29 | C cdtyp : type of source grid |
---|
30 | C kvma : integer value of the mask |
---|
31 | C |
---|
32 | C Output: |
---|
33 | C ------ |
---|
34 | C pdr : the average grid square size |
---|
35 | C psr : the total surface |
---|
36 | C phhi : inverse of sum of surface elements squared |
---|
37 | C |
---|
38 | C Workspace: |
---|
39 | C --------- |
---|
40 | C None |
---|
41 | C |
---|
42 | C Externals: |
---|
43 | C --------- |
---|
44 | C sqdis |
---|
45 | C |
---|
46 | C Reference: |
---|
47 | C --------- |
---|
48 | C O. Thual, Simple ocean-atmosphere interpolation. |
---|
49 | C Part A: The method, EPICOA 0629 (1992) |
---|
50 | C Part B: Software implementation, EPICOA 0630 (1992) |
---|
51 | C |
---|
52 | C See also OASIS manual (1995) |
---|
53 | C |
---|
54 | C History: |
---|
55 | C ------- |
---|
56 | C Version Programmer Date Description |
---|
57 | C ------- ---------- ---- ----------- |
---|
58 | C 1.1 O. Thual 94/01/01 created |
---|
59 | C 2.0 L. Terray 95/12/26 modified : to suit OASIS 2.0 |
---|
60 | C |
---|
61 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
62 | C |
---|
63 | C* ---------------------------- Include files --------------------------- |
---|
64 | C |
---|
65 | |
---|
66 | USE mod_kinds_oasis |
---|
67 | USE mod_unit |
---|
68 | C |
---|
69 | C* ---------------------------- Argument declarations ------------------- |
---|
70 | C |
---|
71 | REAL (kind=ip_realwp_p) pcorx(kngx,kngy), pcory(kngx,kngy) |
---|
72 | REAL (kind=ip_realwp_p) psgr(kngx,kngy) |
---|
73 | INTEGER (kind=ip_intwp_p) kmsk(kngx,kngy) |
---|
74 | CHARACTER*1 cdtyp |
---|
75 | C |
---|
76 | C* ---------------------------- Local declarations ---------------------- |
---|
77 | C |
---|
78 | CHARACTER*1 cltyp |
---|
79 | C |
---|
80 | C* ---------------------------- Poema verses ---------------------------- |
---|
81 | C |
---|
82 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
83 | C |
---|
84 | C* 1. Initialization |
---|
85 | C -------------- |
---|
86 | C |
---|
87 | ivma = kvma |
---|
88 | cltyp = cdtyp |
---|
89 | C |
---|
90 | C |
---|
91 | C* 2. Interdistances only for unmasked points |
---|
92 | C --------------------------------------- |
---|
93 | C |
---|
94 | C* Average distance squared in x-direction |
---|
95 | C |
---|
96 | ztot2 = 0. |
---|
97 | icount = 0 |
---|
98 | DO 210 j2 = 1, kngy |
---|
99 | zsum = 0. |
---|
100 | DO 220 j1 = 1, kngx-1 |
---|
101 | IF (kmsk(j1,j2) .NE. ivma) THEN |
---|
102 | iadd = 0 |
---|
103 | IF (cltyp .ne. 'D') iadd = 1 |
---|
104 | C* For reduced grid, calculate distance only in the x-direction between |
---|
105 | C* points located on same latitude circle. |
---|
106 | IF (cltyp .eq. 'D' .and. pcory(j1,j2) .eq. pcory(j1+1,j2)) |
---|
107 | $ iadd = 1 |
---|
108 | C* For U grid, the average distance will be calculated based on all |
---|
109 | C* consecutive points. |
---|
110 | IF (iadd .eq. 1) then |
---|
111 | zdis = sqdis(pcorx(j1,j2), pcory(j1,j2), |
---|
112 | $ pcorx(j1+1,j2), pcory(j1+1,j2)) |
---|
113 | icount = icount + iadd |
---|
114 | zsum = zsum + zdis |
---|
115 | ENDIF |
---|
116 | ENDIF |
---|
117 | 220 CONTINUE |
---|
118 | ztot2 = ztot2 + zsum |
---|
119 | 210 CONTINUE |
---|
120 | WRITE(nulan, *)'In grstat, icount= ', icount |
---|
121 | ztot2 = ztot2 / float(icount) |
---|
122 | C |
---|
123 | C* Average distance squared in y-direction |
---|
124 | C |
---|
125 | IF ((cltyp .eq. 'D') .or. (cltyp .eq. 'U')) THEN |
---|
126 | pdr = ztot2 |
---|
127 | ztot1 = 0. |
---|
128 | ELSE |
---|
129 | ztot1 = 0. |
---|
130 | icount = 0 |
---|
131 | DO 230 j1 = 1, kngx |
---|
132 | zsum = 0. |
---|
133 | DO 240 j2 = 1, kngy-1 |
---|
134 | IF(kmsk(j1,j2) .NE. ivma) THEN |
---|
135 | zdis = sqdis(pcorx(j1,j2), pcory(j1,j2), |
---|
136 | $ pcorx(j1,j2+1), pcory(j1,j2+1)) |
---|
137 | icount = icount + 1 |
---|
138 | zsum = zsum + zdis |
---|
139 | ENDIF |
---|
140 | 240 CONTINUE |
---|
141 | ztot1 = ztot1 + zsum |
---|
142 | 230 CONTINUE |
---|
143 | ztot1 = ztot1 / float(icount) |
---|
144 | C |
---|
145 | C* Get average grid square size |
---|
146 | C |
---|
147 | pdr = (ztot1 + ztot2) / 2. |
---|
148 | ENDIF |
---|
149 | |
---|
150 | C |
---|
151 | C |
---|
152 | C* 3. Surface and <hh>^-1 |
---|
153 | C ------------------- |
---|
154 | C |
---|
155 | zsurf = 0. |
---|
156 | zhhi = 0. |
---|
157 | DO 310 j2 = 1, kngy |
---|
158 | DO 320 j1 = 1, kngx |
---|
159 | IF (kmsk(j1,j2) .NE. ivma) THEN |
---|
160 | zsurf = zsurf + psgr(j1,j2) |
---|
161 | zhhi = zhhi + psgr(j1,j2) * psgr(j1,j2) |
---|
162 | ENDIF |
---|
163 | 320 CONTINUE |
---|
164 | 310 CONTINUE |
---|
165 | C |
---|
166 | C* Get total surface and inverse of sum of elements squared |
---|
167 | C |
---|
168 | psr = zsurf |
---|
169 | IF (zhhi .ne. 0.) phhi = 1. / zhhi |
---|
170 | C |
---|
171 | C |
---|
172 | C* 4. End of routine |
---|
173 | C -------------- |
---|
174 | C |
---|
175 | RETURN |
---|
176 | END |
---|