1 subroutine da_read_omb_tmp(filename,unit_in,num,obs_type_in,nc,if_wind_sd)
3 !-------------------------------------------------------------------------
4 ! read diagnostics written to temporary file by WRFVAR
6 ! 07 MAR 2014 -- Variables of OMB/OMA for wind obs. in diagnostic files
7 ! are optional, i.e. SPD/DIR or U/V -- Feng Gao
8 !-------------------------------------------------------------------------
12 integer ,intent (in) :: unit_in
13 integer ,intent (inout) :: num
14 character*(*),intent (in) :: obs_type_in, filename
15 integer ,intent (in) :: nc
17 integer :: num_obs, ios
18 character*20 :: iv_type
19 logical :: if_write, if_wind_sd
21 ! data format from da_write_obs_chem_sfc.inc
22 character(len=120) :: fmt_chem = '(i8,3x,a6,2f9.2,5(2f17.7,i8,2f17.7))'
23 character(len=120) :: fmt_chem1 = '(i8,2x,a6,2f11.6,2f11.2,i8,2f11.2)'
24 character(len=120) :: fmt_chem2 = '(i8,2x,a6,2f11.6,2(2f11.2,i8,2f11.2))'
25 character(len=120) :: fmt_chem4 = '(i8,2x,a6,2f11.6,4(2f12.3,i8,2f12.3))'
26 character(len=120) :: wrt_chem1 = '(a6,2f11.6,2f11.2,i8,2f11.2)'
27 character(len=120) :: wrt_chem2 = '(a6,2f11.6,2(2f11.2,i8,2f11.2))'
28 character(len=120) :: wrt_chem4 = '(a6,2f11.6,4(2f12.3,i8,2f12.3))'
31 integer :: n, k, kk, l, levels, dummy_i
32 real :: lat, lon, press, height, dummy
33 real :: tpw_obs, tpw_inv, tpw_err, tpw_inc
34 real :: u_obs, u_inv, u_error, u_inc, &
35 v_obs, v_inv, v_error, v_inc, &
36 t_obs, t_inv, t_error, t_inc, &
37 p_obs, p_inv, p_error, p_inc, &
38 q_obs, q_inv, q_error, q_inc, &
39 spd_obs, spd_inv, spd_err, spd_inc, &
40 ref_obs, ref_inv, ref_error, ref_inc, &
41 eph_obs, eph_inv, eph_error, eph_inc, &
42 rain_obs, rain_inv, rain_error, rain_inc, zk, &
43 w_obs, w_inv, w_error, w_inc, & ! lightning
44 div_obs, div_inv, div_error, div_inc ! lightning
45 integer :: u_qc, v_qc, t_qc, p_qc, q_qc, tpw_qc, spd_qc, ref_qc, rain_qc, w_qc, div_qc
47 real :: chem_obs, chem_inv, chem_err, chem_inc, &
48 chem_obs2, chem_inv2, chem_err2, chem_inc2, &
49 chem_obs3, chem_inv3, chem_err3, chem_inc3, &
50 chem_obs4, chem_inv4, chem_err4, chem_inc4, &
51 chem_obs5, chem_inv5, chem_err5, chem_inc5, &
52 chem_obs6, chem_inv6, chem_err6, chem_inc6
53 integer :: chem_qc, chem_qc2, chem_qc3, chem_qc4, chem_qc5, chem_qc6
58 if (trace_use_dull) call da_trace_entry("da_read_omb_tmp")
60 open(unit=unit_in,file=trim(filename),form='formatted',status='old',iostat=ios)
62 call da_error(__FILE__,__LINE__, (/"Cannot open file"//filename/))
67 read(unit_in,'(a20,i8)', end = 999, err = 1000) iv_type,num_obs
69 if (index(iv_type,OBS_type_in(1:nc)) > 0) if_write = .true.
71 select case (trim(adjustl(iv_type)))
73 case ('synop', 'ships', 'buoy', 'metar', 'sonde_sfc', 'tamdar_sfc')
76 read(unit_in,'(2i8)')levels, ifgat
78 write(omb_unit,'(2i8)')levels, ifgat
82 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
83 kk,l, stn_id, & ! Station
84 lat, lon, press, & ! Lat/lon, pressure
85 u_obs, u_inv, u_qc, u_error, u_inc, &
86 v_obs, v_inv, v_qc, v_error, v_inc, &
87 t_obs, t_inv, t_qc, t_error, t_inc, &
88 p_obs, p_inv, p_qc, p_error, p_inc, &
89 q_obs, q_inv, q_qc, q_error, q_inc
91 if (.not. if_wind_sd .and. wind_stats_sd) &
92 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_uv2fd)
93 if (if_wind_sd .and. .not. wind_stats_sd) &
94 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_fd2uv)
97 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
98 num, k, stn_id, & ! Station
99 lat, lon, press, & ! Lat/lon, pressure
100 u_obs, u_inv, u_qc, u_error, u_inc, &
101 v_obs, v_inv, v_qc, v_error, v_inc, &
102 t_obs, t_inv, t_qc, t_error, t_inc, &
103 p_obs, p_inv, p_qc, p_error, p_inc, &
104 q_obs, q_inv, q_qc, q_error, q_inc
109 if (if_write) exit reports
112 case ('pilot', 'profiler', 'geoamv', 'qscat', 'polaramv')
113 if (num_obs > 0) then
115 read(unit_in,'(2i8)')levels, ifgat
117 write(omb_unit,'(2i8)')levels, ifgat
121 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
122 kk, l, stn_id, & ! Station
123 lat, lon, press, & ! Lat/lon, pressure
124 u_obs, u_inv, u_qc, u_error, u_inc, &
125 v_obs, v_inv, v_qc, v_error, v_inc
127 if (.not. if_wind_sd .and. wind_stats_sd) &
128 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_uv2fd)
129 if (if_wind_sd .and. .not. wind_stats_sd) &
130 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_fd2uv)
133 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
134 num, k, stn_id, & ! Station
135 lat, lon, press, & ! Lat/lon, pressure
136 u_obs, u_inv, u_qc, u_error, u_inc, &
137 v_obs, v_inv, v_qc, v_error, v_inc
142 if (if_write) exit reports
146 if (num_obs > 0) then
148 read(unit_in,'(2i8)')levels, ifgat
150 write(omb_unit,'(2i8)')levels, ifgat
154 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
155 kk,l, stn_id, & ! Station
156 lat, lon, dummy, & ! Lat/lon, dummy
157 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
159 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
160 num, k, stn_id, & ! Station
161 lat, lon, dummy, & ! Lat/lon, dummy
162 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
166 if (if_write) exit reports
169 case ('sound', 'tamdar', 'airep')
170 if (num_obs > 0) then
172 read(unit_in,'(2i8)')levels, ifgat
174 write(omb_unit,'(2i8)')levels, ifgat
178 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
179 kk,l, stn_id, & ! Station
180 lat, lon, press, & ! Lat/lon, dummy
181 u_obs, u_inv, u_qc, u_error, u_inc, &
182 v_obs, v_inv, v_qc, v_error, v_inc, &
183 t_obs, t_inv, t_qc, t_error, t_inc, &
184 q_obs, q_inv, q_qc, q_error, q_inc
186 if (.not. if_wind_sd .and. wind_stats_sd) &
187 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_uv2fd)
188 if (if_wind_sd .and. .not. wind_stats_sd) &
189 call da_ffdduv_diagnose(u_obs, u_inv, u_inc, v_obs, v_inv, v_inc, u_qc, v_qc, convert_fd2uv)
192 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
193 num, k, stn_id, & ! Station
194 lat, lon, press, & ! Lat/lon, dummy
195 u_obs, u_inv, u_qc, u_error, u_inc, &
196 v_obs, v_inv, v_qc, v_error, v_inc, &
197 t_obs, t_inv, t_qc, t_error, t_inc, &
198 q_obs, q_inv, q_qc, q_error, q_inc
202 if (if_write) exit reports
206 if (num_obs > 0) then
208 read(unit_in,'(i8)')levels
210 write(omb_unit,'(i8)')levels
214 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
215 kk,l, stn_id, & ! Station
216 lat, lon, dummy, & ! Lat/lon, dummy
217 spd_obs, spd_inv, spd_qc, spd_err, spd_inc, &
218 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
220 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
221 num, k, stn_id, & ! Station
222 lat, lon, dummy, & ! Lat/lon, dummy
223 spd_obs, spd_inv, spd_qc, spd_err, spd_inc, &
224 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
228 if (if_write) exit reports
232 if (num_obs > 0) then
234 read(unit_in,'(i8)')levels
236 write(omb_unit,'(i8)')levels
240 read(unit_in,'(2i8,a5,2f9.2,f17.7,7(2f17.7,i8,2f17.7))', err= 1000)&
241 kk,l, stn_id, & ! Station
242 lat, lon, dummy, & ! Lat/lon, dummy
243 dummy, dummy, dummy_i, dummy, dummy, &
244 dummy, dummy, dummy_i, dummy, dummy, &
245 dummy, dummy, dummy_i, dummy, dummy, &
246 dummy, dummy, dummy_i, dummy, dummy, &
247 dummy, dummy, dummy_i, dummy, dummy, &
248 dummy, dummy, dummy_i, dummy, dummy, &
249 dummy, dummy, dummy_i, dummy, dummy
251 write(omb_unit,'(2i8,a5,2f9.2,f17.7,7(2f17.7,i8,2f17.7))', err= 1000)&
252 num,k,stn_id, & ! Station
253 lat, lon, dummy, & ! Lat/lon, dummy
254 dummy, dummy, dummy_i, dummy, dummy, &
255 dummy, dummy, dummy_i, dummy, dummy, &
256 dummy, dummy, dummy_i, dummy, dummy, &
257 dummy, dummy, dummy_i, dummy, dummy, &
258 dummy, dummy, dummy_i, dummy, dummy, &
259 dummy, dummy, dummy_i, dummy, dummy, &
260 dummy, dummy, dummy_i, dummy, dummy
264 if (if_write) exit reports
268 if (num_obs > 0) then
270 read(unit_in,'(i8)') levels
272 write(omb_unit,'(i8)')levels
276 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
277 kk,l, stn_id, & ! Station
278 lat, lon, press, & ! Lat/lon, dummy
279 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
281 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
282 num,k,stn_id, & ! Station
283 lat, lon, press, & ! Lat/lon, dummy
284 tpw_obs, tpw_inv, tpw_qc, tpw_err, tpw_inc
288 if (if_write) exit reports
291 case ('ssmt1' , 'ssmt2' )
292 if (num_obs > 0) then
294 read(unit_in,'(i8)') levels
296 write(omb_unit,'(i8)')levels
300 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
301 kk,l, stn_id, & ! Station
302 lat, lon, dummy, & ! Lat/lon, dummy
303 dummy,dummy, dummy_i, dummy, dummy
305 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
306 num,k,stn_id, & ! Station
307 lat, lon, dummy, & ! Lat/lon, dummy
308 dummy,dummy, dummy_i, dummy, dummy
312 if (if_write) exit reports
316 ! TC Bogus data is written in two records
317 ! 1st record holds info about surface level
318 ! 2nd is for upper air
320 if (num_obs > 0) then
322 read(unit_in,'(i8)') levels
324 write(omb_unit,'(i8)')levels
328 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
329 kk,l, stn_id, & ! Station
330 lat, lon, press, & ! Lat/lon, dummy
331 u_obs, u_inv, u_qc, u_error, u_inc, &
332 v_obs, v_inv, v_qc, v_error, v_inc
334 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
335 num,l,stn_id, & ! Station
336 lat, lon, press, & ! Lat/lon, dummy
337 u_obs, u_inv, u_qc, u_error, u_inc, &
338 v_obs, v_inv, v_qc, v_error, v_inc
340 read(unit_in,'(i8)') levels
342 write(omb_unit,'(i8)')levels
345 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
346 kk,l, stn_id, & ! Station
347 lat, lon, press, & ! Lat/lon, dummy
348 u_obs, u_inv, u_qc, u_error, u_inc, &
349 v_obs, v_inv, v_qc, v_error, v_inc
351 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
352 num,l,stn_id, & ! Station
353 lat, lon, press, & ! Lat/lon, dummy
354 u_obs, u_inv, u_qc, u_error, u_inc, &
355 v_obs, v_inv, v_qc, v_error, v_inc
359 if (if_write) exit reports
363 if (num_obs > 0) then
365 read(unit_in,'(2i8)') levels, ifgat
367 write(omb_unit,'(2i8)')levels, ifgat
371 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
372 kk,l, stn_id, & ! Station
373 lat, lon, press, & ! Lat/lon, dummy
374 t_obs, t_inv, t_qc, t_error, t_inc, &
375 q_obs, q_inv, q_qc, q_error, q_inc
377 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
378 num,k,stn_id, & ! Station
379 lat, lon, press, & ! Lat/lon, dummy
380 t_obs, t_inv, t_qc, t_error, t_inc, &
381 q_obs, q_inv, q_qc, q_error, q_inc
385 if (if_write) exit reports
389 if (num_obs > 0) then
391 read(unit_in,'(2i8)') levels, ifgat
393 write(omb_unit,'(2i8)')levels, ifgat
397 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
398 kk,l, stn_id, & ! Station
399 lat, lon, height, & ! Lat/lon, height
400 ref_obs, ref_inv, ref_qc, ref_error, ref_inc
402 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
403 num,k,stn_id, & ! Station
404 lat, lon, height, & ! Lat/lon, height
405 ref_obs, ref_inv, ref_qc, ref_error, ref_inc
409 if (if_write) exit reports
413 if (num_obs > 0) then
415 read(unit_in,'(2i8)') levels, ifgat
416 if (if_write) write(omb_unit,'(2i8)')levels, ifgat
419 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
420 kk, l, stn_id, & ! Station
421 lat, lon, height, & ! Lat/lon, height
422 eph_obs, eph_inv, eph_qc, eph_error, eph_inc
424 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
425 num, l, stn_id, & ! Station
426 lat, lon, height, & ! Lat/lon, height
427 eph_obs, eph_inv, eph_qc, eph_error, eph_inc
431 if (if_write) exit reports
435 if (num_obs > 0) then
437 read(unit_in,'(2i8)') levels, ifgat
439 write(omb_unit,'(2i8)')levels, ifgat
443 read(unit_in,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
444 kk,l, stn_id, & ! Station
445 lat, lon, height, & ! Lat/lon, height
446 rain_obs, rain_inv, rain_qc, rain_error, rain_inc
448 write(omb_unit,'(2i8,a5,2f9.2,f17.7,5(2f17.7,i8,2f17.7))', err= 1000)&
449 num,k,stn_id, & ! Station
450 lat, lon, height, & ! Lat/lon, height
451 rain_obs, rain_inv, rain_qc, rain_error, rain_inc
455 if (if_write) exit reports
459 if (num_obs > 0) then
461 read(unit_in,'(2i8)') levels, ifgat
463 write(omb_unit,'(2i8)')levels, ifgat
467 read(unit_in,'(2i8,a5,2f9.2,f17.7,3(2f17.7,i8,2f17.7))', err= 1000)&
468 kk,l, stn_id, & ! Station
469 lat, lon, height, & ! Lat/lon, height
470 w_obs, w_inv, w_qc, w_error, w_inc, & ! vertical velocity
471 div_obs, div_inv, div_qc, div_error, div_inc, & ! divergence
472 q_obs, q_inv, q_qc, q_error, q_inc ! water vapor
474 write(omb_unit,'(2i8,a5,2f9.2,f17.7,3(2f17.7,i8,2f17.7))', err= 1000)&
475 num,k,stn_id, & ! Station
476 lat, lon, height, & ! Lat/lon, height
477 w_obs, w_inv, w_qc, w_error, w_inc, & ! vertical velocity
478 div_obs, div_inv, div_qc, div_error, div_inc, & ! divergence
479 q_obs, q_inv, q_qc, q_error, q_inc ! water vapor
483 if (if_write) exit reports
488 if (num_obs > 0) then
490 read(unit_in,'(2i8)')levels, ifgat
492 write(omb_unit,'(2i8)')levels, ifgat
496 if (chemicda_opt == 1 .or. chemicda_opt ==2 ) then
497 read(unit_in,fmt=fmt_chem1, err= 1000)&
498 kk, stn_id, & ! Station
499 lat, lon, & ! Lat/lon
500 chem_obs, chem_inv, chem_qc, chem_err, chem_inc
502 write(omb_unit,fmt=wrt_chem1, err= 1000)&
504 lat, lon, & ! Lat/lon
505 chem_obs, chem_inv, chem_qc, chem_err, chem_inc
506 else if (chemicda_opt == 3) then
507 read(unit_in,fmt=fmt_chem2, err= 1000)&
508 kk, stn_id, & ! Station
509 lat, lon, & ! Lat/lon
510 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
511 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2
513 write(omb_unit,fmt=wrt_chem2, err= 1000)&
515 lat, lon, & ! Lat/lon
516 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
517 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2
518 else if (chemicda_opt == 4) then
519 read(unit_in,fmt=fmt_chem4, err= 1000)&
520 kk, stn_id, & ! Station
521 lat, lon, & ! Lat/lon
522 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
523 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2, &
524 chem_obs3, chem_inv3, chem_qc3, chem_err3, chem_inc3, &
525 chem_obs4, chem_inv4, chem_qc4, chem_err4, chem_inc4
527 write(omb_unit,fmt=wrt_chem4, err= 1000)&
529 lat, lon, & ! Lat/lon, dummy
530 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
531 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2, &
532 chem_obs3, chem_inv3, chem_qc3, chem_err3, chem_inc3, &
533 chem_obs4, chem_inv4, chem_qc4, chem_err4, chem_inc4
534 else if (chemicda_opt == 5) then
535 read(unit_in,fmt=fmt_chem2, err= 1000)&
536 kk, stn_id, & ! Station
537 lat, lon, & ! Lat/lon
538 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
539 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2
541 write(omb_unit,fmt=wrt_chem2, err= 1000)&
543 lat, lon, & ! Lat/lon
544 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
545 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2
551 end if ! if (num_obs > 0) then
553 if (if_write) exit reports
557 if (num_obs > 0) then
559 read(unit_in,'(2i8)')levels, ifgat
561 write(omb_unit,'(2i8)')levels, ifgat
564 if (chemicda_opt == 4 .or. chemicda_opt == 5) then
565 read(unit_in, fmt = fmt_chem4, err= 1000)&
566 kk, stn_id, & ! Station
567 lat, lon, & ! Lat/lon
568 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
569 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2, &
570 chem_obs3, chem_inv3, chem_qc3, chem_err3, chem_inc3, &
571 chem_obs4, chem_inv4, chem_qc4, chem_err4, chem_inc4
573 write(omb_unit, fmt = wrt_chem4, err= 1000)&
574 stn_id, lat, lon, & ! station, lat/lon
575 chem_obs, chem_inv, chem_qc, chem_err, chem_inc, &
576 chem_obs2, chem_inv2, chem_qc2, chem_err2, chem_inc2, &
577 chem_obs3, chem_inv3, chem_qc3, chem_err3, chem_inc3, &
578 chem_obs4, chem_inv4, chem_qc4, chem_err4, chem_inc4
580 end do ! do n = 1, num_obs
581 end if ! if (num_obs > 0) then
583 if (if_write) exit reports
589 write(unit=message(1), fmt='(a,a20,a,i3)') &
590 'Got unknown obs_type string:', trim(iv_type),' on unit ',unit_in
591 call da_error(__FILE__,__LINE__,message(1:1))
598 if (trace_use_dull) call da_trace_exit("da_read_omb_tmp")
602 write(unit=message(1), fmt='(a,i3)') &
603 'read error on unit: ',unit_in
604 call da_warning(__FILE__,__LINE__,message(1:1))
606 end subroutine da_read_omb_tmp