New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
test_fbgenerate.F90 in branches/2014/dev_r4650_UKMO14.11_SETTE_OBSASM/NEMOGCM/TOOLS/OBSTOOLS/src – NEMO

source: branches/2014/dev_r4650_UKMO14.11_SETTE_OBSASM/NEMOGCM/TOOLS/OBSTOOLS/src/test_fbgenerate.F90 @ 4751

Last change on this file since 4751 was 4751, checked in by djlea, 10 years ago

Changes to include an OBS test in SETTE. At the moment this uses an example profile observation.

File size: 30.3 KB
Line 
1MODULE test_fbgenerate 
2USE obs_fbm
3USE test_arrays_mod
4USE fbgenerate_coords
5
6CONTAINS
7
8   SUBROUTINE tester
9   IMPLICIT NONE
10   REAL(KIND=fbdp) :: array10_in(10), array1_in(1), array2_in(2), array3_in(3)
11   REAL(KIND=fbdp) :: array10_out(10), array1_out(1), array2_out(2), array3_out(3)
12   REAL(KIND=fbdp) :: array_4x3_in(3,4,1), array_4x3_out(3,4,1)
13   REAL(KIND=fbdp), ALLOCATABLE :: lat_array_in(:), lat_array_out(:)
14   REAL(KIND=fbdp), ALLOCATABLE :: lon_array_in(:), lon_array_out(:)
15   INTEGER :: iarray10_in(10), iarray1_in(1), iarray2_in(2), iarray3_in(3)
16   INTEGER :: iarray10_out(10), iarray1_out(1), iarray2_out(2), iarray3_out(3)
17   LOGICAL :: okay = .TRUE.
18   LOGICAL :: okay_too = .TRUE.
19   LOGICAL :: all_okay = .TRUE.
20   INTEGER, PARAMETER :: FV_int = 99999
21   REAL(KIND=fbdp), PARAMETER :: FV_real = 99999.0_fbdp
22   
23   ! A single non-FillVal value should be replicated n times
24   array1_in(:)=(/1.0_fbdp/)
25   array1_out(:)=(/1.0_fbdp/)
26   CALL set_depths(array1_in,1,FV_real)
27   okay = test_arrays(array1_in,array1_out)
28   IF (okay .EQV. .FALSE.) THEN
29      WRITE(*,*) "Test 1 failed"
30      all_okay = .FALSE.
31   END IF
32
33   ! A single non-FillVal value should be replicated n times
34   array2_in(:) = (/1.0_fbdp, FV_real/)
35   array2_out(:) = (/1.0_fbdp, 1.0_fbdp/)
36   CALL set_depths(array2_in,2,FV_real)
37   okay = test_arrays(array2_in,array2_out)
38   IF (okay .EQV. .FALSE.) THEN
39      WRITE(*,*) "Test 2 failed"
40      all_okay = .FALSE.
41   END IF
42
43   ! A single non-FillVal value should be replicated n times
44   array10_in(:) = (/1.0_fbdp,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real/)
45   array10_out(:) = 1.0_fbdp
46   CALL set_depths(array10_in,10,FV_real)
47   okay = test_arrays(array10_in,array10_out)
48   IF (okay .EQV. .FALSE.) THEN
49      WRITE(*,*) "Test 3 failed"
50      all_okay = .FALSE.
51   END IF
52
53   ! A single non-FillVal value should be replicated n times
54   array3_in(:) = (/1.0_fbdp,FV_real,FV_real/)
55   array3_out(:) = 1.0_fbdp
56   CALL set_depths(array3_in,3,FV_real)
57   okay = test_arrays(array3_in,array3_out)
58   IF (okay .EQV. .FALSE.) THEN
59      WRITE(*,*) "Test 4 failed"
60      all_okay = .FALSE.
61   END IF
62     
63   ! A full list of n non-FillVals should be left unaltered.
64   array2_in(:) = (/1.0_fbdp, 2.0_fbdp/)
65   array2_out(:) = (/1.0_fbdp, 2.0_fbdp/)
66   CALL set_depths(array2_in,2,FV_real)
67   okay = test_arrays(array2_in,array2_out)
68   IF (okay .EQV. .FALSE.) THEN
69      WRITE(*,*) "Test 5 failed"
70      all_okay = .FALSE.
71   END IF
72
73   ! A full list of n non-FillVals should be left unaltered.
74   array3_in(:) = (/3.0_fbdp, 2.0_fbdp, 56.23_fbdp/)
75   array3_out(:) = (/3.0_fbdp, 2.0_fbdp, 56.23_fbdp/)
76   CALL set_depths(array3_in,3,FV_real)
77   okay = test_arrays(array3_in,array3_out)
78   IF (okay .EQV. .FALSE.) THEN
79      WRITE(*,*) "Test 6 failed"
80      all_okay = .FALSE.
81   END IF
82
83   ! A full list of n non-FillVals should be left unaltered.
84   array10_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, -5.0_fbdp, 5.0_fbdp, 67.0_fbdp, 7.0_fbdp, 8.0_fbdp, 9.0_fbdp, 10.0_fbdp/)
85   array10_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, -5.0_fbdp, 5.0_fbdp, 67.0_fbdp, 7.0_fbdp, 8.0_fbdp, 9.0_fbdp, 10.0_fbdp/)
86   CALL set_depths(array10_in,10,FV_real)
87   okay = test_arrays(array10_in,array10_out)
88   IF (okay .EQV. .FALSE.) THEN
89      WRITE(*,*) "Test 7 failed"
90      all_okay = .FALSE.
91   END IF
92
93   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
94   array10_in(:) = (/1.0_fbdp,10.0_fbdp,1.0_fbdp,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real/)
95   array10_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp, 6.0_fbdp, 7.0_fbdp, 8.0_fbdp, 9.0_fbdp, 10.0_fbdp/)
96   CALL set_depths(array10_in,10,FV_real)
97   okay = test_arrays(array10_in,array10_out)
98   IF (okay .EQV. .FALSE.) THEN
99      WRITE(*,*) "Test 8 failed"
100      all_okay = .FALSE.
101   END IF
102
103   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
104   array10_in(:) = (/1.0_fbdp, 3.25_fbdp, 0.25_fbdp, FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real/)
105   array10_out(:) = (/1.0_fbdp, 1.25_fbdp, 1.5_fbdp, 1.75_fbdp, 2.0_fbdp, 2.25_fbdp, 2.5_fbdp, 2.75_fbdp, 3.0_fbdp, 3.25_fbdp/)
106   CALL set_depths(array10_in,10,FV_real)
107   okay = test_arrays(array10_in,array10_out)
108   IF (okay .EQV. .FALSE.) THEN
109      WRITE(*,*) "Test 9 failed"
110      all_okay = .FALSE.
111   END IF
112
113   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
114   array10_in(:) = (/3.25_fbdp, 1.0_fbdp, -0.25_fbdp, FV_real,FV_real,FV_real,FV_real,FV_real,FV_real,FV_real/)
115   array10_out(:) = (/3.25_fbdp, 3.0_fbdp, 2.75_fbdp, 2.5_fbdp, 2.25_fbdp, 2.0_fbdp, 1.75_fbdp, 1.5_fbdp, 1.25_fbdp, 1.0_fbdp/)
116   CALL set_depths(array10_in,10,FV_real)
117   okay = test_arrays(array10_in,array10_out)
118   IF (okay .EQV. .FALSE.) THEN
119      WRITE(*,*) "Test 11 failed"
120      all_okay = .FALSE.
121   END IF
122   
123   ! A single non-FillVal value should be replicated n times
124   iarray1_in(:)=(/19991231/)
125   iarray1_out(:)=(/19991231/)
126   CALL set_date(iarray1_in,1,FV_int)
127   okay = test_arrays(iarray1_in,iarray1_out)
128   IF (okay .EQV. .FALSE.) THEN
129      WRITE(*,*) "Test 12 failed"
130      all_okay = .FALSE.
131   END IF
132
133   ! A single non-FillVal value should be replicated n times
134   iarray2_in(:) = (/19991231, FV_int/)
135   iarray2_out(:) = (/19991231, 19991231/)
136   CALL set_date(iarray2_in,2,FV_int)
137   okay = test_arrays(iarray2_in,iarray2_out)
138   IF (okay .EQV. .FALSE.) THEN
139      WRITE(*,*) "Test 13 failed"
140      all_okay = .FALSE.
141   END IF
142
143   ! A single non-FillVal value should be replicated n times
144   iarray10_in(:) = (/20110101,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
145   iarray10_out(:) = 20110101
146   CALL set_date(iarray10_in,10,FV_int)
147   okay = test_arrays(iarray10_in,iarray10_out)
148   IF (okay .EQV. .FALSE.) THEN
149      WRITE(*,*) "Test 14 failed"
150      all_okay = .FALSE.
151   END IF
152
153   ! A single non-FillVal value should be replicated n times
154   iarray3_in(:) = (/20110101,FV_int,FV_int/)
155   iarray3_out(:) = 20110101
156   CALL set_date(iarray3_in,3,FV_int)
157   okay = test_arrays(iarray3_in,iarray3_out)
158   IF (okay .EQV. .FALSE.) THEN
159      WRITE(*,*) "Test 15 failed"
160      all_okay = .FALSE.
161   END IF
162     
163   ! A full list of n non-FillVals should be left unaltered.
164   iarray2_in(:) = (/19991231, 20000101/)
165   iarray2_out(:) = (/19991231, 20000101/)
166   CALL set_date(iarray2_in,2,FV_int)
167   okay = test_arrays(iarray2_in,iarray2_out)
168   IF (okay .EQV. .FALSE.) THEN
169      WRITE(*,*) "Test 16 failed"
170      all_okay = .FALSE.
171   END IF
172
173   ! A full list of n non-FillVals should be left unaltered.
174   iarray3_in(:) = (/19840101, 19001231, 20500612/)
175   iarray3_out(:) = (/19840101, 19001231, 20500612/)
176   CALL set_date(iarray3_in,3,FV_int)
177   okay = test_arrays(iarray3_in,iarray3_out)
178   IF (okay .EQV. .FALSE.) THEN
179      WRITE(*,*) "Test 17 failed"
180      all_okay = .FALSE.
181   END IF
182
183   ! A full list of n non-FillVals should be left unaltered.
184   iarray10_in(:) = (/20091231, 20100101, 20100102, 20100103, 20091231, &
185                       20100105, 20100106, 20091231, 20100108, 20100109/)
186   iarray10_out(:) = (/20091231, 20100101, 20100102, 20100103, 20091231, &
187                       20100105, 20100106, 20091231, 20100108, 20100109/)
188   CALL set_date(iarray10_in,10,FV_int)
189   okay = test_arrays(iarray10_in,iarray10_out)
190   IF (okay .EQV. .FALSE.) THEN
191      WRITE(*,*) "Test 18 failed"
192      all_okay = .FALSE.
193   END IF
194
195   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
196   iarray10_in(:) = (/20091231,20100109,1,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
197   iarray10_out(:) = (/20091231, 20100101, 20100102, 20100103, 20100104, &
198                       20100105, 20100106, 20100107, 20100108, 20100109/)
199   CALL set_date(iarray10_in,10,FV_int)
200   okay = test_arrays(iarray10_in,iarray10_out)
201   IF (okay .EQV. .FALSE.) THEN
202      WRITE(*,*) "Test 19 failed"
203      all_okay = .FALSE.
204   END IF
205
206   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
207   iarray10_in(:) = (/20100109,20091231,-1,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
208   iarray10_out(:) = (/20100109, 20100108, 20100107, 20100106, 20100105, &
209                       20100104, 20100103, 20100102, 20100101, 20091231/)
210   CALL set_date(iarray10_in,10,FV_int)
211   okay = test_arrays(iarray10_in,iarray10_out)
212   IF (okay .EQV. .FALSE.) THEN
213      WRITE(*,*) "Test 20 failed"
214      all_okay = .FALSE.
215   END IF
216
217   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
218   iarray10_in(:) = (/20100101,20100401,10,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
219   iarray10_out(:) = (/20100101, 20100111, 20100121, 20100131, 20100210, &
220                       20100220, 20100302, 20100312, 20100322, 20100401/)
221   CALL set_date(iarray10_in,10,FV_int)
222   okay = test_arrays(iarray10_in,iarray10_out)
223   IF (okay .EQV. .FALSE.) THEN
224      WRITE(*,*) "Test 21 failed"
225      all_okay = .FALSE.
226   END IF
227
228   ! A single non-FillVal value should be replicated n times
229   iarray1_in(:)=(/0000/)
230   iarray1_out(:)=(/0/)
231   CALL set_time(iarray1_in,1,FV_int)
232   okay = test_arrays(iarray1_in,iarray1_out)
233   IF (okay .EQV. .FALSE.) THEN
234      WRITE(*,*) "Test 22 failed"
235      all_okay = .FALSE.
236   END IF
237
238   ! A single non-FillVal value should be replicated n times
239   iarray2_in(:) = (/0600, FV_int/)
240   iarray2_out(:) = (/600, 600/)
241   CALL set_time(iarray2_in,2,FV_int)
242   okay = test_arrays(iarray2_in,iarray2_out)
243   IF (okay .EQV. .FALSE.) THEN
244      WRITE(*,*) "Test 23 failed"
245      all_okay = .FALSE.
246   END IF
247
248   ! A full list of n non-FillVals should be left unaltered.
249   iarray2_in(:) = (/0600, 1200/)
250   iarray2_out(:) = (/0600, 1200/)
251   CALL set_time(iarray2_in,2,FV_int)
252   okay = test_arrays(iarray2_in,iarray2_out)
253   IF (okay .EQV. .FALSE.) THEN
254      WRITE(*,*) "Test 24 failed"
255      all_okay = .FALSE.
256   END IF
257
258   ! A full list of n non-FillVals should be left unaltered.
259   iarray10_in(:) = (/1, 2, 3, -5, 5, 67, 7, 8, 9, 10/)
260   iarray10_out(:) = (/1, 2, 3, -5, 5, 67, 7, 8, 9, 10/)
261   CALL set_time(iarray10_in,10,FV_int)
262   okay = test_arrays(iarray10_in,iarray10_out)
263   IF (okay .EQV. .FALSE.) THEN
264      WRITE(*,*) "Test 25 failed"
265      all_okay = .FALSE.
266   END IF
267
268   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
269   iarray10_in(:) = (/0000,0430,0030,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
270   iarray10_out(:) = (/0, 30, 100, 130, 200, &
271                       230, 300, 330, 400, 430/)
272   CALL set_time(iarray10_in,10,FV_int)
273   okay = test_arrays(iarray10_in,iarray10_out)
274   IF (okay .EQV. .FALSE.) THEN
275      WRITE(*,*) "Test 26 failed"
276      WRITE(*,*) iarray10_in
277      all_okay = .FALSE.
278   END IF
279
280   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
281   iarray10_in(:) = (/2200,0230,0030,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
282   iarray10_out(:) = (/2200, 2230, 2300, 2330, 0, &
283                       30, 100, 130, 200, 230/)
284   CALL set_time(iarray10_in,10,FV_int)
285   okay = test_arrays(iarray10_in,iarray10_out)
286   IF (okay .EQV. .FALSE.) THEN
287      WRITE(*,*) "Test 27 failed"
288      WRITE(*,*) iarray10_in
289      all_okay = .FALSE.
290   END IF
291
292   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
293   iarray10_in(:) = (/2200,1730,-0030,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
294   iarray10_out(:) = (/2200, 2130, 2100, 2030, 2000, &
295                       1930, 1900, 1830, 1800, 1730/)
296   CALL set_time(iarray10_in,10,FV_int)
297   okay = test_arrays(iarray10_in,iarray10_out)
298   IF (okay .EQV. .FALSE.) THEN
299      WRITE(*,*) "Test 28 failed"
300      WRITE(*,*) iarray10_in
301      all_okay = .FALSE.
302   END IF
303
304   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
305   iarray10_in(:) = (/0100,2200,-0020,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
306   iarray10_out(:) = (/0100, 0040, 0020, 0000, 2340, &
307                       2320, 2300, 2240, 2220, 2200/)
308   CALL set_time(iarray10_in,10,FV_int)
309   okay = test_arrays(iarray10_in,iarray10_out)
310   IF (okay .EQV. .FALSE.) THEN
311      WRITE(*,*) "Test 29 failed"
312      WRITE(*,*) iarray10_in
313      all_okay = .FALSE.
314   END IF
315
316   ! Three non-FillVal values should be used as the start, end, step in conjunction with n
317   iarray10_in(:) = (/1700,0630,90,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int,FV_int/)
318   iarray10_out(:) = (/1700, 1830, 2000, 2130, 2300, &
319                       0030, 0200, 0330, 0500, 0630/)
320   CALL set_time(iarray10_in,10,FV_int)
321   okay = test_arrays(iarray10_in,iarray10_out)
322   IF (okay .EQV. .FALSE.) THEN
323      WRITE(*,*) "Test 30 failed"
324      WRITE(*,*) iarray10_in
325      all_okay = .FALSE.
326   END IF
327
328   ! A single obs value should be replicated throught the array(obs,levels)
329   array_4x3_in(:,1,1) = (/1.0,FV_real,FV_real/)
330   array_4x3_in(:,2,1) = (/FV_real,FV_real,FV_real/)
331   array_4x3_in(:,3,1) = (/FV_real,FV_real,FV_real/)
332   array_4x3_in(:,4,1) = (/FV_real,FV_real,FV_real/)
333   array_4x3_out(:,1,1) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
334   array_4x3_out(:,2,1) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
335   array_4x3_out(:,3,1) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
336   array_4x3_out(:,4,1) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
337   CALL set_obs_values(array_4x3_in,1,4,3,FV_real)
338   okay = test_arrays(array_4x3_in,array_4x3_out)
339   IF (okay .EQV. .FALSE.) THEN
340      WRITE(*,*) "Test 31 failed"
341      WRITE(*,*) array_4x3_in
342      WRITE(*,*)
343      WRITE(*,*) array_4x3_out
344      all_okay = .FALSE.
345   END IF
346
347   ! A full specification of the obs values should be unaltered
348   array_4x3_in(:,1,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
349   array_4x3_in(:,2,1) = (/4.0_fbdp, 5.0_fbdp, 6.0_fbdp/)
350   array_4x3_in(:,3,1) = (/7.0_fbdp, 8.0_fbdp, 9.0_fbdp/)
351   array_4x3_in(:,4,1) = (/10.0_fbdp, 11.0_fbdp, 12.0_fbdp/)
352   array_4x3_out(:,1,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
353   array_4x3_out(:,2,1) = (/4.0_fbdp, 5.0_fbdp, 6.0_fbdp/)
354   array_4x3_out(:,3,1) = (/7.0_fbdp, 8.0_fbdp, 9.0_fbdp/)
355   array_4x3_out(:,4,1) = (/10.0_fbdp, 11.0_fbdp, 12.0_fbdp/)
356   CALL set_obs_values(array_4x3_in,1,4,3,FV_real)
357   okay = test_arrays(array_4x3_in,array_4x3_out)
358   IF (okay .EQV. .FALSE.) THEN
359      WRITE(*,*) "Test 32 failed"
360      WRITE(*,*) array_4x3_in
361      WRITE(*,*)
362      WRITE(*,*) array_4x3_out
363      all_okay = .FALSE.
364   END IF
365
366   ! A single profile should be replicated at all lat/lons
367   array_4x3_in(:,1,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
368   array_4x3_in(:,2,1) = (/FV_real, FV_real, FV_real/)
369   array_4x3_in(:,3,1) = (/FV_real, FV_real, FV_real/)
370   array_4x3_in(:,4,1) = (/FV_real, FV_real, FV_real/)
371   array_4x3_out(:,1,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
372   array_4x3_out(:,2,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
373   array_4x3_out(:,3,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
374   array_4x3_out(:,4,1) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
375   CALL set_obs_values(array_4x3_in,1,4,3,FV_real)
376   okay = test_arrays(array_4x3_in,array_4x3_out)
377   IF (okay .EQV. .FALSE.) THEN
378      WRITE(*,*) "Test 33 failed"
379      WRITE(*,*) array_4x3_in
380      WRITE(*,*)
381      WRITE(*,*) array_4x3_out
382      all_okay = .FALSE.
383   END IF
384
385   ! A single profile position should only be given where nobs=1
386   ALLOCATE(lat_array_in(1),  &
387            lon_array_in(1),  &
388            lat_array_out(1), &
389            lon_array_out(1)  )
390   lat_array_in(:) = (/1.0_fbdp/)
391   lon_array_in(:) = (/1.0_fbdp/)
392   lat_array_out(:) = (/1.0_fbdp/)
393   lon_array_out(:) = (/1.0_fbdp/)
394   CALL set_spatial_coords(lat_array_in,lon_array_in,1,FV_real)
395   okay = test_arrays(lat_array_in,lat_array_out)
396   okay_too = test_arrays(lon_array_in,lon_array_out)
397   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
398      WRITE(*,*) "Test 34 failed"
399      WRITE(*,*) lat_array_in
400      WRITE(*,*) lon_array_in
401      WRITE(*,*) lat_array_out
402      WRITE(*,*) lon_array_out
403      all_okay = .FALSE.
404   END IF
405   DEALLOCATE(lat_array_in,   &
406              lon_array_in,   &
407              lat_array_out,  &
408              lon_array_out   )
409
410   ! A single lat and list of lons should give nobs observations
411   ALLOCATE(lat_array_in(4),  &
412            lon_array_in(4),  &
413            lat_array_out(4), &
414            lon_array_out(4)  )
415   lat_array_in(:) = (/1.0_fbdp, FV_real, FV_real, FV_real/)
416   lon_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp/)
417   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
418   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp/)
419   CALL set_spatial_coords(lat_array_in,lon_array_in,4,FV_real)
420   okay = test_arrays(lat_array_in,lat_array_out)
421   okay_too = test_arrays(lon_array_in,lon_array_out)
422   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
423      WRITE(*,*) "Test 35 failed"
424      WRITE(*,*) lat_array_in
425      WRITE(*,*) lon_array_in
426      WRITE(*,*) lat_array_out
427      WRITE(*,*) lon_array_out
428      all_okay = .FALSE.
429   END IF
430   DEALLOCATE(lat_array_in,   &
431              lon_array_in,   &
432              lat_array_out,  &
433              lon_array_out   )
434
435   ! A single lat and bounded lons should give nobs = no elements in expanded bounds
436   ALLOCATE(lat_array_in(3),  &
437            lon_array_in(3),  &
438            lat_array_out(3), &
439            lon_array_out(3)  )
440   lat_array_in(:) = (/1.0_fbdp, FV_real, FV_real/)
441   lon_array_in(:) = (/1.0_fbdp, 3.0_fbdp, 1.0_fbdp/)
442   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
443   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp/)
444   CALL set_spatial_coords(lat_array_in,lon_array_in,3,FV_real)
445   okay = test_arrays(lat_array_in,lat_array_out)
446   okay_too = test_arrays(lon_array_in,lon_array_out)
447   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
448      WRITE(*,*) "Test 36 failed"
449      WRITE(*,*) lat_array_in
450      WRITE(*,*) lon_array_in
451      WRITE(*,*) lat_array_out
452      WRITE(*,*) lon_array_out
453      all_okay = .FALSE.
454   END IF
455   DEALLOCATE(lat_array_in,   &
456              lon_array_in,   &
457              lat_array_out,  &
458              lon_array_out   )
459
460   ! A single lat and bounded lons should give nobs = no elements in expanded bounds
461   ALLOCATE(lat_array_in(5),  &
462            lon_array_in(5),  &
463            lat_array_out(5), &
464            lon_array_out(5)  )
465   lat_array_in(:) = (/1.0_fbdp, FV_real, FV_real, FV_real, FV_real/)
466   lon_array_in(:) = (/1.0_fbdp, 5.0_fbdp, 1.0_fbdp, FV_real, FV_real/)
467   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
468   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
469   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
470   okay = test_arrays(lat_array_in,lat_array_out)
471   okay_too = test_arrays(lon_array_in,lon_array_out)
472   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
473      WRITE(*,*) "Test 37 failed"
474      WRITE(*,*) lat_array_in
475      WRITE(*,*) lon_array_in
476      WRITE(*,*) lat_array_out
477      WRITE(*,*) lon_array_out
478      all_okay = .FALSE.
479   END IF
480   DEALLOCATE(lat_array_in,   &
481              lon_array_in,   &
482              lat_array_out,  &
483              lon_array_out   )
484
485   ! A single lon and bounded lats should give nobs = no elements in expanded bounds
486   ALLOCATE(lat_array_in(5),  &
487            lon_array_in(5),  &
488            lat_array_out(5), &
489            lon_array_out(5)  )
490   lat_array_in(:) = (/1.0_fbdp, 5.0_fbdp, 1.0_fbdp, FV_real, FV_real/)
491   lon_array_in(:) = (/1.0_fbdp, FV_real, FV_real, FV_real, FV_real/)
492   lat_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
493   lon_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
494   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
495   okay = test_arrays(lat_array_in,lat_array_out)
496   okay_too = test_arrays(lon_array_in,lon_array_out)
497   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
498      WRITE(*,*) "Test 38 failed"
499      WRITE(*,*) lat_array_in
500      WRITE(*,*) lon_array_in
501      WRITE(*,*) lat_array_out
502      WRITE(*,*) lon_array_out
503      all_okay = .FALSE.
504   END IF
505   DEALLOCATE(lat_array_in,   &
506              lon_array_in,   &
507              lat_array_out,  &
508              lon_array_out   )
509
510   ! A list of lats and lons with same number of elements as nobs should be unaltered
511   ALLOCATE(lat_array_in(5),  &
512            lon_array_in(5),  &
513            lat_array_out(5), &
514            lon_array_out(5)  )
515   lat_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
516   lon_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
517   lat_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
518   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
519   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
520   okay = test_arrays(lat_array_in,lat_array_out)
521   okay_too = test_arrays(lon_array_in,lon_array_out)
522   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
523      WRITE(*,*) "Test 39 failed"
524      WRITE(*,*) lat_array_in
525      WRITE(*,*) lon_array_in
526      WRITE(*,*) lat_array_out
527      WRITE(*,*) lon_array_out
528      all_okay = .FALSE.
529   END IF
530   DEALLOCATE(lat_array_in,   &
531              lon_array_in,   &
532              lat_array_out,  &
533              lon_array_out   )
534
535   ! A list of lats and lons with fewer elements as nobs should be gridded
536   ! to produce nobs observations - list all lons at same lat, before stepping in lat.
537   ALLOCATE(lat_array_in(25), &
538            lon_array_in(25), &
539            lat_array_out(25), &
540            lon_array_out(25) )
541   lat_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
542                       FV_real, FV_real, FV_real, FV_real, FV_real, &
543                       FV_real, FV_real, FV_real, FV_real, FV_real, &
544                       FV_real, FV_real, FV_real, FV_real, FV_real, &
545                       FV_real, FV_real, FV_real, FV_real, FV_real/)
546   lon_array_in(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
547                       FV_real, FV_real, FV_real, FV_real, FV_real, &
548                       FV_real, FV_real, FV_real, FV_real, FV_real, &
549                       FV_real, FV_real, FV_real, FV_real, FV_real, &
550                       FV_real, FV_real, FV_real, FV_real, FV_real/)
551   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, & 
552                        2.0_fbdp, 2.0_fbdp, 2.0_fbdp, 2.0_fbdp, 2.0_fbdp, &
553                        3.0_fbdp, 3.0_fbdp, 3.0_fbdp, 3.0_fbdp, 3.0_fbdp, &
554                        4.0_fbdp, 4.0_fbdp, 4.0_fbdp, 4.0_fbdp, 4.0_fbdp, &
555                        5.0_fbdp, 5.0_fbdp, 5.0_fbdp, 5.0_fbdp, 5.0_fbdp/)
556   lon_array_out(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
557                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
558                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
559                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
560                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp/)
561   CALL set_spatial_coords(lat_array_in,lon_array_in,25,FV_real)
562   okay = test_arrays(lat_array_in,lat_array_out)
563   okay_too = test_arrays(lon_array_in,lon_array_out)
564   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
565      WRITE(*,*) "Test 40 failed"
566      WRITE(*,*) lat_array_in
567      WRITE(*,*) lon_array_in
568      WRITE(*,*) lat_array_out
569      WRITE(*,*) lon_array_out
570      all_okay = .FALSE.
571   END IF
572   DEALLOCATE(lat_array_in,   &
573              lon_array_in,   &
574              lat_array_out,  &
575              lon_array_out   )
576
577   ! A list of lats and lon bounds with fewer elements as nobs should be gridded
578   ! to produce nobs observations - list all lons at same lat, before stepping in lat.
579   ALLOCATE(lat_array_in(25), &
580            lon_array_in(25), &
581            lat_array_out(25), &
582            lon_array_out(25) )
583   lat_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
584                       FV_real, FV_real, FV_real, FV_real, FV_real, &
585                       FV_real, FV_real, FV_real, FV_real, FV_real, &
586                       FV_real, FV_real, FV_real, FV_real, FV_real, &
587                       FV_real, FV_real, FV_real, FV_real, FV_real/)
588   lon_array_in(:) = (/10.0_fbdp, 50.0_fbdp, 10.0_fbdp, FV_real, FV_real,&
589                       FV_real, FV_real, FV_real, FV_real, FV_real, &
590                       FV_real, FV_real, FV_real, FV_real, FV_real, &
591                       FV_real, FV_real, FV_real, FV_real, FV_real, &
592                       FV_real, FV_real, FV_real, FV_real, FV_real/)
593   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, & 
594                        2.0_fbdp, 2.0_fbdp, 2.0_fbdp, 2.0_fbdp, 2.0_fbdp, &
595                        3.0_fbdp, 3.0_fbdp, 3.0_fbdp, 3.0_fbdp, 3.0_fbdp, &
596                        4.0_fbdp, 4.0_fbdp, 4.0_fbdp, 4.0_fbdp, 4.0_fbdp, &
597                        5.0_fbdp, 5.0_fbdp, 5.0_fbdp, 5.0_fbdp, 5.0_fbdp/)
598   lon_array_out(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
599                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
600                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
601                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp,&
602                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp/)
603   CALL set_spatial_coords(lat_array_in,lon_array_in,25,FV_real)
604   okay = test_arrays(lat_array_in,lat_array_out)
605   okay_too = test_arrays(lon_array_in,lon_array_out)
606   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
607      WRITE(*,*) "Test 41 failed"
608      WRITE(*,*) lat_array_in
609      WRITE(*,*) lon_array_in
610      WRITE(*,*) lat_array_out
611      WRITE(*,*) lon_array_out
612      all_okay = .FALSE.
613   END IF
614   DEALLOCATE(lat_array_in,   &
615              lon_array_in,   &
616              lat_array_out,  &
617              lon_array_out   )
618
619
620   ! A list of lats and lon bounds with the same number of elements as nobs should be
621   ! unaltered expect for bounds expansion
622   ALLOCATE(lat_array_in(5),  &
623            lon_array_in(5),  &
624            lat_array_out(5), &
625            lon_array_out(5)  )
626   lat_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
627   lon_array_in(:) = (/10.0_fbdp, 50.0_fbdp, 10.0_fbdp, FV_real, FV_real/)
628   lat_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
629   lon_array_out(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp/)
630   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
631   okay = test_arrays(lat_array_in,lat_array_out)
632   okay_too = test_arrays(lon_array_in,lon_array_out)
633   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
634      WRITE(*,*) "Test 42 failed"
635      WRITE(*,*) lat_array_in
636      WRITE(*,*) lon_array_in
637      WRITE(*,*) lat_array_out
638      WRITE(*,*) lon_array_out
639      all_okay = .FALSE.
640   END IF
641   DEALLOCATE(lat_array_in,   &
642              lon_array_in,   &
643              lat_array_out,  &
644              lon_array_out   )
645   
646
647   ! A list of lons and lat bounds with the same number of elements as nobs should be
648   ! unaltered expect for bounds expansion
649   ALLOCATE(lat_array_in(5),  &
650            lon_array_in(5),  &
651            lat_array_out(5), &
652            lon_array_out(5)  )
653   lat_array_in(:) = (/10.0_fbdp, 50.0_fbdp, 10.0_fbdp, FV_real, FV_real/)
654   lon_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
655   lat_array_out(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp, 50.0_fbdp/)
656   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
657   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
658   okay = test_arrays(lat_array_in,lat_array_out)
659   okay_too = test_arrays(lon_array_in,lon_array_out)
660   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
661      WRITE(*,*) "Test 43 failed"
662      WRITE(*,*) lat_array_in
663      WRITE(*,*) lon_array_in
664      WRITE(*,*) lat_array_out
665      WRITE(*,*) lon_array_out
666      all_okay = .FALSE.
667   END IF
668   DEALLOCATE(lat_array_in,   &
669              lon_array_in,   &
670              lat_array_out,  &
671              lon_array_out   )
672   
673
674   ! A list of lons and lat bounds with fewer elements as nobs should be gridded
675   ! to produce nobs observations - list all lons at same lat, before stepping in lat.
676   ALLOCATE(lat_array_in(25), &
677            lon_array_in(25), &
678            lat_array_out(25), &
679            lon_array_out(25) )
680   lat_array_in(:) = (/10.0_fbdp, 50.0_fbdp, 10.0_fbdp, FV_real, FV_real,&
681                       FV_real, FV_real, FV_real, FV_real, FV_real, &
682                       FV_real, FV_real, FV_real, FV_real, FV_real, &
683                       FV_real, FV_real, FV_real, FV_real, FV_real, &
684                       FV_real, FV_real, FV_real, FV_real, FV_real/)
685   lon_array_in(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
686                       FV_real, FV_real, FV_real, FV_real, FV_real, &
687                       FV_real, FV_real, FV_real, FV_real, FV_real, &
688                       FV_real, FV_real, FV_real, FV_real, FV_real, &
689                       FV_real, FV_real, FV_real, FV_real, FV_real/)
690   lat_array_out(:) = (/10.0_fbdp, 10.0_fbdp, 10.0_fbdp, 10.0_fbdp, 10.0_fbdp, & 
691                        20.0_fbdp, 20.0_fbdp, 20.0_fbdp, 20.0_fbdp, 20.0_fbdp, &
692                        30.0_fbdp, 30.0_fbdp, 30.0_fbdp, 30.0_fbdp, 30.0_fbdp, &
693                        40.0_fbdp, 40.0_fbdp, 40.0_fbdp, 40.0_fbdp, 40.0_fbdp, &
694                        50.0_fbdp, 50.0_fbdp, 50.0_fbdp, 50.0_fbdp, 50.0_fbdp/)
695   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
696                        1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
697                        1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
698                        1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp,&
699                        1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
700   CALL set_spatial_coords(lat_array_in,lon_array_in,25,FV_real)
701   okay = test_arrays(lat_array_in,lat_array_out)
702   okay_too = test_arrays(lon_array_in,lon_array_out)
703   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
704      WRITE(*,*) "Test 44 failed"
705      WRITE(*,*) lat_array_in
706      WRITE(*,*) lon_array_in
707      WRITE(*,*) lat_array_out
708      WRITE(*,*) lon_array_out
709      all_okay = .FALSE.
710   END IF
711   DEALLOCATE(lat_array_in,   &
712              lon_array_in,   &
713              lat_array_out,  &
714              lon_array_out   )
715
716
717   ! A single lat and bounded lons should give nobs = no elements in expanded bounds
718   ALLOCATE(lat_array_in(5),  &
719            lon_array_in(5),  &
720            lat_array_out(5), &
721            lon_array_out(5)  )
722   lat_array_in(:) = (/1.0_fbdp, FV_real, FV_real, FV_real, FV_real/)
723   lon_array_in(:) = (/1.0_fbdp, 5.0_fbdp, 1.0_fbdp, FV_real, FV_real/)
724   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp/)
725   lon_array_out(:) = (/1.0_fbdp, 2.0_fbdp, 3.0_fbdp, 4.0_fbdp, 5.0_fbdp/)
726   CALL set_spatial_coords(lat_array_in,lon_array_in,5,FV_real)
727   okay = test_arrays(lat_array_in,lat_array_out)
728   okay_too = test_arrays(lon_array_in,lon_array_out)
729   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
730      WRITE(*,*) "Test 45 failed"
731      WRITE(*,*) lat_array_in
732      WRITE(*,*) lon_array_in
733      WRITE(*,*) lat_array_out
734      WRITE(*,*) lon_array_out
735      all_okay = .FALSE.
736   END IF
737   DEALLOCATE(lat_array_in,   &
738              lon_array_in,   &
739              lat_array_out,  &
740              lon_array_out   )
741
742
743   ! Bounded lat and bounded lons - list all lons at same lat, before stepping in lat.
744   ALLOCATE(lat_array_in(20), &
745            lon_array_in(20), &
746            lat_array_out(20), &
747            lon_array_out(20) )
748   lat_array_in(:) = (/1.0_fbdp, 5.0_fbdp, 1.0_fbdp, FV_real, FV_real,&
749                       FV_real, FV_real, FV_real, FV_real, FV_real, &
750                       FV_real, FV_real, FV_real, FV_real, FV_real, &
751                       FV_real, FV_real, FV_real, FV_real, FV_real/)
752   lon_array_in(:) = (/10.0_fbdp, 40.0_fbdp, 10.0_fbdp, FV_real, FV_real,&
753                       FV_real, FV_real, FV_real, FV_real, FV_real, &
754                       FV_real, FV_real, FV_real, FV_real, FV_real, &
755                       FV_real, FV_real, FV_real, FV_real, FV_real/)
756   lat_array_out(:) = (/1.0_fbdp, 1.0_fbdp, 1.0_fbdp, 1.0_fbdp, & 
757                        2.0_fbdp, 2.0_fbdp, 2.0_fbdp, 2.0_fbdp, &
758                        3.0_fbdp, 3.0_fbdp, 3.0_fbdp, 3.0_fbdp, &
759                        4.0_fbdp, 4.0_fbdp, 4.0_fbdp, 4.0_fbdp, &
760                        5.0_fbdp, 5.0_fbdp, 5.0_fbdp, 5.0_fbdp/)
761   lon_array_out(:) = (/10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp,&
762                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp,&
763                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp,&
764                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp,&
765                        10.0_fbdp, 20.0_fbdp, 30.0_fbdp, 40.0_fbdp/)
766   CALL set_spatial_coords(lat_array_in,lon_array_in,20,FV_real)
767   okay = test_arrays(lat_array_in,lat_array_out)
768   okay_too = test_arrays(lon_array_in,lon_array_out)
769   IF ((okay .EQV. .FALSE.) .OR. (okay_too .EQV. .FALSE.)) THEN
770      WRITE(*,*) "Test 46 failed"
771      WRITE(*,*) lat_array_in
772      WRITE(*,*) lon_array_in
773      WRITE(*,*) lat_array_out
774      WRITE(*,*) lon_array_out
775      all_okay = .FALSE.
776   END IF
777   DEALLOCATE(lat_array_in,   &
778              lon_array_in,   &
779              lat_array_out,  &
780              lon_array_out   )
781
782
783   IF (all_okay) WRITE(*,*) "All tests passed"
784   
785   END SUBROUTINE tester
786
787END MODULE test_fbgenerate 
Note: See TracBrowser for help on using the repository browser.