1 subroutine da_final_write_obs_gas_sfc(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 character(len=4) :: typestr
22 if (trace_use) call da_trace_entry("da_final_write_obs_gas_sfc")
25 ! Wait to ensure all temporary files have been written
26 call mpi_barrier(comm, ierr)
30 call da_get_unit(iunit)
31 allocate (filename(0:num_procs-1))
33 write(unit=filename(k),fmt ='(a,i2.2,a,i4.4)')'gas_omb_oma_',it,'.',k
35 call da_get_unit(omb_unit)
36 write(unit=file,fmt ='(a,i2.2)')'gas_omb_oma_',it
37 open(unit=omb_unit,file=trim(file),form='formatted', status='replace', iostat=ios)
38 if (ios /= 0) call da_error(__FILE__,__LINE__, &
39 (/"Cannot open file "//file/))
43 if (iv%info(chemic_surf)%nlocal > 0) then
44 do n = 1, iv%info(chemic_surf)%nlocal
45 if(iv%info(chemic_surf)%proc_domain(1,n)) num_obs = num_obs + 1
48 call da_proc_sum_int(num_obs)
49 if (num_obs > 0 .and. rootproc) then
50 write(omb_unit,'(a20,i8)') typestr, num_obs
53 call da_read_omb_tmp(filename(k),iunit,num_obs,typestr,3,if_wind_sd)
61 call da_free_unit(iunit)
62 call da_free_unit(omb_unit)
66 if (trace_use) call da_trace_exit("da_final_write_obs_gas_sfc")
68 end subroutine da_final_write_obs_gas_sfc