1 subroutine da_final_write_obs(it,iv)
3 !-------------------------------------------------------------------------
4 ! Purpose: Writes full diagnostics for O, (O-B) & OMA together
5 !-------------------------------------------------------------------------
9 integer, intent(in) :: it
10 type (iv_type), intent(in) :: iv ! O-B structure.
11 integer :: n, k, iunit
12 integer :: ios ! Error code from MPI routines.
15 character(len=filename_len), allocatable :: filename(:)
16 character(len=filename_len) :: file
19 if (trace_use) call da_trace_entry("da_final_write_obs")
22 ! Wait to ensure all temporary files have been written
23 call mpi_barrier(comm, ierr)
27 call da_get_unit(iunit)
28 allocate (filename(0:num_procs-1))
30 write(unit=filename(k),fmt ='(a,i2.2,a,i4.4)')'gts_omb_oma_',it,'.',k
32 call da_get_unit(omb_unit)
33 write(unit=file,fmt ='(a,i2.2)')'gts_omb_oma_',it
34 open(unit=omb_unit,file=trim(file),form='formatted', status='replace', iostat=ios)
35 if (ios /= 0) call da_error(__FILE__,__LINE__, &
36 (/"Cannot open file "//file/))
40 if (iv%info(synop)%nlocal > 0) then
41 do n = 1, iv%info(synop)%nlocal
42 if(iv%info(synop)%proc_domain(1,n)) num_obs = num_obs + 1
45 call da_proc_sum_int(num_obs)
47 if (wind_sd_synop) if_wind_sd = .true.
48 if (num_obs > 0 .and. rootproc) then
49 write(omb_unit,'(a20,i8)')'synop', num_obs
52 call da_read_omb_tmp(filename(k),iunit,num_obs,'synop',5,if_wind_sd)
56 !------------------------------------------------------------------
58 !------------------------------------------------------------------
61 if (iv%info(metar)%nlocal > 0) then
62 do n = 1, iv%info(metar)%nlocal
63 if (iv%info(metar)%proc_domain(1,n)) num_obs = num_obs + 1
66 call da_proc_sum_int(num_obs)
68 if (wind_sd_metar) if_wind_sd = .true.
69 if (num_obs > 0 .and. rootproc) then
70 write(omb_unit,'(a20,20i8)')'metar', num_obs
73 call da_read_omb_tmp(filename(k),iunit,num_obs,'metar',5,if_wind_sd)
77 !------------------------------------------------------------------
79 !------------------------------------------------------------------
82 if (iv%info(ships)%nlocal > 0) then
83 do n = 1, iv%info(ships)%nlocal
84 if(iv%info(ships)%proc_domain(1,n)) num_obs = num_obs + 1
87 call da_proc_sum_int(num_obs)
89 if (wind_sd_ships) if_wind_sd = .true.
90 if (num_obs > 0 .and. rootproc) then
91 write(omb_unit,'(a20,i8)')'ships', num_obs
94 call da_read_omb_tmp(filename(k),iunit,num_obs,'ships',5,if_wind_sd)
98 !------------------------------------------------------------------
100 !------------------------------------------------------------------
103 if (iv%info(geoamv)%nlocal > 0) then
104 do n = 1, iv%info(geoamv)%nlocal
105 if (iv%info(geoamv)%proc_domain(1,n)) num_obs = num_obs + 1
108 call da_proc_sum_int(num_obs)
110 if (wind_sd_geoamv) if_wind_sd = .true.
111 if (num_obs > 0 .and. rootproc) then
112 write(omb_unit,'(a20,i8)')'geoamv', num_obs
115 call da_read_omb_tmp(filename(k),iunit,num_obs,'geoamv',6,if_wind_sd)
119 !------------------------------------------------------------------
120 ! [5] writing PolarAMV
121 !------------------------------------------------------------------
124 if (iv%info(polaramv)%nlocal > 0) then
125 do n = 1, iv%info(polaramv)%nlocal
126 if (iv%info(polaramv)%proc_domain(1,n)) num_obs = num_obs + 1
129 call da_proc_sum_int(num_obs)
131 if (wind_sd_polaramv) if_wind_sd = .true.
132 if (num_obs > 0 .and. rootproc) then
133 write(omb_unit,'(a20,i8)')'polaramv', num_obs
136 call da_read_omb_tmp(filename(k),iunit,num_obs,'polaramv',8,if_wind_sd)
140 !------------------------------------------------------------------
142 !------------------------------------------------------------------
145 if (iv%info(gpspw)%nlocal > 0) then
146 do n = 1, iv%info(gpspw)%nlocal
147 if(iv%info(gpspw)%proc_domain(1,n)) num_obs = num_obs + 1
150 call da_proc_sum_int(num_obs)
152 if (num_obs > 0 .and. rootproc) then
153 write(omb_unit,'(a20,i8)')'gpspw', num_obs
156 call da_read_omb_tmp(filename(k),iunit,num_obs,'gpspw',5,if_wind_sd)
160 !------------------------------------------------------------------
162 !------------------------------------------------------------------
165 if (iv%info(sound)%nlocal > 0) then
166 do n = 1, iv%info(sound)%nlocal
167 if (iv%info(sound)%proc_domain(1,n)) num_obs = num_obs + 1
170 call da_proc_sum_int(num_obs)
172 if (wind_sd_sound) if_wind_sd = .true.
173 if (num_obs > 0 .and. rootproc) then
174 write(omb_unit,'(a20,i8)')'sound', num_obs
177 call da_read_omb_tmp(filename(k),iunit,num_obs,'sound',5,if_wind_sd)
183 if (iv%info(sonde_sfc)%nlocal > 0) then
184 do n = 1, iv%info(sonde_sfc)%nlocal
185 if(iv%info(sonde_sfc)%proc_domain(1,n)) num_obs = num_obs + 1
188 call da_proc_sum_int(num_obs)
189 if (num_obs > 0 .and. rootproc) then
190 write(omb_unit,'(a20,i8)')'sonde_sfc', num_obs
193 call da_read_omb_tmp(filename(k),iunit,num_obs,'sonde_sfc',9,if_wind_sd)
197 !------------------------------------------------------------------
199 !------------------------------------------------------------------
202 if (iv%info(airep)%nlocal > 0) then
203 do n = 1, iv%info(airep)%nlocal
204 if(iv%info(airep)%proc_domain(1,n)) num_obs = num_obs + 1
207 call da_proc_sum_int(num_obs)
209 if (wind_sd_airep) if_wind_sd = .true.
210 if (num_obs > 0 .and. rootproc) then
211 write(omb_unit,'(a20,i8)')'airep', num_obs
214 call da_read_omb_tmp(filename(k),iunit,num_obs,'airep',5,if_wind_sd)
218 !------------------------------------------------------------------
220 !------------------------------------------------------------------
223 if (iv%info(pilot)%nlocal > 0) then
224 do n = 1, iv%info(pilot)%nlocal
225 if(iv%info(pilot)%proc_domain(1,n)) num_obs = num_obs + 1
228 call da_proc_sum_int(num_obs)
230 if (wind_sd_pilot) if_wind_sd = .true.
231 if (num_obs > 0 .and. rootproc) then
232 write(omb_unit,'(a20,i8)')'pilot', num_obs
235 call da_read_omb_tmp(filename(k),iunit,num_obs,'pilot',5,if_wind_sd)
239 !------------------------------------------------------------------
240 ! [9] writing ssmi_rv
241 !------------------------------------------------------------------
244 if (iv%info(ssmi_rv)%nlocal > 0) then
245 do n = 1, iv%info(ssmi_rv)%nlocal
246 if(iv%info(ssmi_rv)%proc_domain(1,n)) num_obs = num_obs + 1
249 call da_proc_sum_int(num_obs)
251 if (num_obs > 0 .and. rootproc) then
252 write(omb_unit,'(a20,i8)')'ssmir', num_obs
255 call da_read_omb_tmp(filename(k),iunit,num_obs,'ssmir',5,if_wind_sd)
259 !------------------------------------------------------------------
260 ! [10] writing SSMITB
261 !------------------------------------------------------------------
264 if (iv%info(ssmi_tb)%nlocal > 0) then
265 do n = 1, iv%info(ssmi_tb)%nlocal
266 if (iv%info(ssmi_tb)%proc_domain(1,n)) num_obs = num_obs + 1
269 call da_proc_sum_int(num_obs)
271 if (num_obs > 0 .and. rootproc) then
272 write(omb_unit,'(a20,i8)')'ssmiT', num_obs
275 call da_read_omb_tmp(filename(k),iunit,num_obs,'ssmiT',5,if_wind_sd)
279 !------------------------------------------------------------------
281 !------------------------------------------------------------------
284 if (iv%info(satem)%nlocal > 0) then
285 do n = 1, iv%info(satem)%nlocal
286 if(iv%info(satem)%proc_domain(1,n)) num_obs = num_obs + 1
289 call da_proc_sum_int(num_obs)
291 if (num_obs > 0 .and. rootproc) then
292 write(omb_unit,'(a20,i8)')'satem', num_obs
295 call da_read_omb_tmp(filename(k),iunit,num_obs,'satem',5,if_wind_sd)
299 !------------------------------------------------------------------
301 !------------------------------------------------------------------
304 if (iv%info(ssmt1)%nlocal > 0) then
305 do n = 1, iv%info(ssmt1)%nlocal
306 if(iv%info(ssmt1)%proc_domain(1,n)) num_obs = num_obs + 1
309 call da_proc_sum_int(num_obs)
311 if (num_obs > 0 .and. rootproc) then
312 write(omb_unit,'(a20,i8)')'ssmt1', num_obs
315 call da_read_omb_tmp(filename(k),iunit,num_obs,'ssmt1',5,if_wind_sd)
319 !------------------------------------------------------------------
321 !------------------------------------------------------------------
324 if (iv%info(ssmt2)%nlocal > 0) then
325 do n = 1, iv%info(ssmt2)%nlocal
326 if(iv%info(ssmt2)%proc_domain(1,n)) num_obs = num_obs + 1
329 call da_proc_sum_int(num_obs)
331 if (num_obs > 0 .and. rootproc) then
332 write(omb_unit,'(a20,i8)')'ssmt2', num_obs
335 call da_read_omb_tmp(filename(k),iunit,num_obs,'ssmt2',5,if_wind_sd)
339 !------------------------------------------------------------------
341 !------------------------------------------------------------------
344 if (iv%info(qscat)%nlocal > 0) then
345 do n = 1, iv%info(qscat)%nlocal
346 if(iv%info(qscat)%proc_domain(1,n)) num_obs = num_obs + 1
349 call da_proc_sum_int(num_obs)
351 if (wind_sd_qscat) if_wind_sd = .true.
352 if (num_obs > 0 .and. rootproc) then
353 write(omb_unit,'(a20,i8)')'qscat', num_obs
356 call da_read_omb_tmp(filename(k),iunit,num_obs,'qscat',5,if_wind_sd)
360 !------------------------------------------------------------------
361 ! [15] writing Profiler
362 !------------------------------------------------------------------
365 if (iv%info(profiler)%nlocal > 0) then
366 do n = 1, iv%info(profiler)%nlocal
367 if(iv%info(profiler)%proc_domain(1,n)) num_obs = num_obs + 1
370 call da_proc_sum_int(num_obs)
372 if (wind_sd_profiler) if_wind_sd = .true.
373 if (num_obs > 0 .and. rootproc) then
374 write(omb_unit,'(a20,i8)')'profiler', num_obs
377 call da_read_omb_tmp(filename(k),iunit,num_obs,'profiler',8,if_wind_sd)
381 !------------------------------------------------------------------
383 !------------------------------------------------------------------
386 if (iv%info(buoy)%nlocal > 0) then
387 do n = 1, iv%info(buoy)%nlocal
388 if(iv%info(buoy)%proc_domain(1,n)) num_obs = num_obs + 1
391 call da_proc_sum_int(num_obs)
393 if (wind_sd_buoy) if_wind_sd = .true.
394 if (num_obs > 0 .and. rootproc) then
395 write(omb_unit,'(a20,i8)')'buoy', num_obs
398 call da_read_omb_tmp(filename(k),iunit,num_obs,'buoy',4,if_wind_sd)
402 !------------------------------------------------------------------
404 !------------------------------------------------------------------
407 if (iv%info(bogus)%nlocal > 0) then
408 do n = 1, iv%info(bogus)%nlocal
409 if(iv%info(bogus)%proc_domain(1,n)) num_obs = num_obs + 1
412 call da_proc_sum_int(num_obs)
414 if (num_obs > 0 .and. rootproc) then
415 write(omb_unit,'(a20,i8)')'bogus', num_obs
418 call da_read_omb_tmp(filename(k),iunit,num_obs,'bogus',5,if_wind_sd)
422 !------------------------------------------------------------------
423 ! [18] writing Tamdar
424 !------------------------------------------------------------------
427 if (iv%info(tamdar)%nlocal > 0) then
428 do n = 1, iv%info(tamdar)%nlocal
429 if (iv%info(tamdar)%proc_domain(1,n)) num_obs = num_obs + 1
432 call da_proc_sum_int(num_obs)
434 if (wind_sd_tamdar) if_wind_sd = .true.
435 if (num_obs > 0 .and. rootproc) then
436 write(omb_unit,'(a20,i8)')'tamdar', num_obs
439 call da_read_omb_tmp(filename(k),iunit,num_obs,'tamdar',6,if_wind_sd)
446 if (iv%info(tamdar_sfc)%nlocal > 0) then
447 do n = 1, iv%info(tamdar_sfc)%nlocal
448 if(iv%info(tamdar_sfc)%proc_domain(1,n)) num_obs = num_obs + 1
451 call da_proc_sum_int(num_obs)
452 if (num_obs > 0 .and. rootproc) then
453 write(omb_unit,'(a20,i8)')'tamdar_sfc', num_obs
456 call da_read_omb_tmp(filename(k),iunit,num_obs,'tamdar_sfc',10,if_wind_sd)
460 !------------------------------------------------------------------
461 ! [19] writing AIRS retrievals:
462 !------------------------------------------------------------------
465 if (iv%info(airsr)%nlocal > 0) then
466 do n = 1, iv%info(airsr)%nlocal
467 if(iv%info(airsr)%proc_domain(1,n)) num_obs = num_obs + 1
470 call da_proc_sum_int(num_obs)
472 if (num_obs > 0 .and. rootproc) then
473 write(omb_unit,'(a20,i8)')'airsr', num_obs
476 call da_read_omb_tmp(filename(k),iunit,num_obs,'airsr',5,if_wind_sd)
480 !------------------------------------------------------------------
481 ! [20] writing GPS refractivity
482 !------------------------------------------------------------------
485 if (iv%info(gpsref)%nlocal > 0) then
486 do n = 1, iv%info(gpsref)%nlocal
487 if(iv%info(gpsref)%proc_domain(1,n)) num_obs = num_obs + 1
490 call da_proc_sum_int(num_obs)
492 if (num_obs > 0 .and. rootproc) then
493 write(omb_unit,'(a20,i8)')'gpsref', num_obs
496 call da_read_omb_tmp(filename(k),iunit,num_obs,'gpsref',6,if_wind_sd)
500 !------------------------------------------------------------------
501 ! [20.1] writing GPS Excess Phase
502 !------------------------------------------------------------------
505 if (iv%info(gpseph)%nlocal > 0) then
506 do n = 1, iv%info(gpseph)%nlocal
507 if(iv%info(gpseph)%proc_domain(1,n)) num_obs = num_obs + 1
510 call da_proc_sum_int(num_obs)
511 if (num_obs > 0 .and. rootproc) then
512 write(omb_unit,'(a20,i8)')'gpseph', num_obs
515 call da_read_omb_tmp(filename(k),iunit,num_obs,'gpseph',6,if_wind_sd)
519 !------------------------------------------------------------------
521 !------------------------------------------------------------------
524 if (iv%info(rain)%nlocal > 0) then
525 do n = 1, iv%info(rain)%nlocal
526 if(iv%info(rain)%proc_domain(1,n)) num_obs = num_obs + 1
529 call da_proc_sum_int(num_obs)
531 if (num_obs > 0 .and. rootproc) then
532 write(omb_unit,'(a20,i8)')'rain', num_obs
535 call da_read_omb_tmp(filename(k),iunit,num_obs,'rain',4,if_wind_sd)
539 !------------------------------------------------------------------
540 ! [22] writing lightning
541 !------------------------------------------------------------------
544 if (iv%info(lightning)%nlocal > 0) then
545 do n = 1, iv%info(lightning)%nlocal
546 if(iv%info(lightning)%proc_domain(1,n)) num_obs = num_obs + 1
549 call da_proc_sum_int(num_obs)
551 if (num_obs > 0 .and. rootproc) then
552 write(omb_unit,'(a20,i8)')'lightning', num_obs
555 call da_read_omb_tmp(filename(k),iunit,num_obs,'lightning',5,if_wind_sd)
563 call da_free_unit(iunit)
564 call da_free_unit(omb_unit)
565 deallocate (filename)
568 if (trace_use) call da_trace_exit("da_final_write_obs")
570 end subroutine da_final_write_obs