25 character(3),
dimension(:),
allocatable :: obstype
26 integer(i_kind) :: n_obstype
27 integer(i_kind),
dimension(:),
allocatable :: n_observations
28 integer(i_kind) :: n_observations_mass
29 integer(i_kind) :: n_observations_wind
30 integer(i_kind) :: n_observations_total
31 integer(i_kind) :: date
35 character(8) :: station_id
36 character(3) :: observation_class
37 real(r_single) :: observation_type
39 real(r_single) :: latitude
40 real(r_single) :: longitude
41 real(r_single) :: station_elevation
42 real(r_single) :: pressure
43 real(r_single) :: height
44 real(r_single) :: time
45 real(r_single) :: prep_qc_mark
46 real(r_single) :: setup_qc_mark
47 real(r_single) :: prep_use_flag
48 real(r_single) :: analysis_use_flag
49 real(r_single) :: nonlinear_qc_rel_wgt
50 real(r_single) :: errinv_input
51 real(r_single) :: errinv_adjust
52 real(r_single) :: errinv_final
53 real(r_single) :: observation
54 real(r_single) :: obs_minus_forecast_adjusted
55 real(r_single) :: obs_minus_forecast_unadjusted
60 character(8) :: station_id
61 character(3) :: observation_class
62 real(r_single) :: observation_type
64 real(r_single) :: latitude
65 real(r_single) :: longitude
66 real(r_single) :: station_elevation
67 real(r_single) :: pressure
68 real(r_single) :: height
69 real(r_single) :: time
70 real(r_single) :: prep_qc_mark
71 real(r_single) :: setup_qc_mark
72 real(r_single) :: prep_use_flag
73 real(r_single) :: analysis_use_flag
74 real(r_single) :: nonlinear_qc_rel_wgt
75 real(r_single) :: errinv_input
76 real(r_single) :: errinv_adjust
77 real(r_single) :: errinv_final
78 real(r_single) :: u_observation
79 real(r_single) :: u_obs_minus_forecast_adjusted
80 real(r_single) :: u_obs_minus_forecast_unadjusted
81 real(r_single) :: v_observation
82 real(r_single) :: v_obs_minus_forecast_adjusted
83 real(r_single) :: v_obs_minus_forecast_unadjusted
84 real(r_single) :: wind_reduction_factor_at_10m
97 character(3),
intent(in) :: obstype
98 character(3),
intent(inout),
dimension(*) :: obstypearr
107 obstypearr(1) = obstype
109 print *,
'obstype=',obstype,
' set to index',idx
112 if (obstype .eq. obstypearr(i))
then 117 if (.not. matched)
then 121 print *,
'obstype=',obstype,
' set to index',idx
132 character(120),
intent(in) :: infn
134 type(
diag_aircft_mass),
dimension(aircft_header%n_Observations_Mass),
intent(in):: aircft_mass
135 type(
diag_aircft_wind),
dimension(aircft_header%n_Observations_Wind),
intent(in):: aircft_wind
136 logical,
intent(in) :: append_suffix
138 character(120) :: outfn
139 character(20) :: str, str2
143 do itype=1, aircft_header%n_ObsType
144 str = aircft_header%ObsType(itype)
145 if (.not. append_suffix)
then 146 str2 =
'diag_aircft_' // trim(adjustl(str))
149 outfn = outfn(1:
strlen-3) //
'nc4' 151 outfn = trim(infn) //
'.' // trim(adjustl(str)) //
'.nc4' 158 if (aircft_header%ObsType(itype) .eq.
' uv')
then 159 do i=1,aircft_header%n_Observations_Wind
160 call nc_diag_metadata(
"Station_ID", aircft_wind(i)%Station_ID )
161 call nc_diag_metadata(
"Observation_Class", aircft_wind(i)%Observation_Class )
162 call nc_diag_metadata(
"Observation_Type", aircft_wind(i)%Observation_Type )
164 call nc_diag_metadata(
"Latitude", aircft_wind(i)%Latitude )
165 call nc_diag_metadata(
"Longitude", aircft_wind(i)%Longitude )
166 call nc_diag_metadata(
"Station_Elevation", aircft_wind(i)%Station_Elevation )
167 call nc_diag_metadata(
"Pressure", aircft_wind(i)%Pressure )
168 call nc_diag_metadata(
"Height", aircft_wind(i)%Height )
169 call nc_diag_metadata(
"Time", aircft_wind(i)%Time )
170 call nc_diag_metadata(
"Prep_QC_Mark", aircft_wind(i)%Prep_QC_Mark )
171 call nc_diag_metadata(
"Setup_QC_Mark", aircft_wind(i)%Setup_QC_Mark )
172 call nc_diag_metadata(
"Prep_Use_Flag", aircft_wind(i)%Prep_Use_Flag )
173 call nc_diag_metadata(
"Analysis_Use_Flag", aircft_wind(i)%Analysis_Use_Flag )
174 call nc_diag_metadata(
"Nonlinear_QC_Rel_Wgt", aircft_wind(i)%Nonlinear_QC_Rel_Wgt )
175 call nc_diag_metadata(
"Errinv_Input", aircft_wind(i)%Errinv_Input )
176 call nc_diag_metadata(
"Errinv_Adjust", aircft_wind(i)%Errinv_Adjust )
177 call nc_diag_metadata(
"Errinv_Final", aircft_wind(i)%Errinv_Final )
178 call nc_diag_metadata(
"u_Observation", aircft_wind(i)%u_Observation )
179 call nc_diag_metadata(
"u_Obs_Minus_Forecast_adjusted", aircft_wind(i)%u_Obs_Minus_Forecast_adjusted )
180 call nc_diag_metadata(
"u_Obs_Minus_Forecast_unadjusted", aircft_wind(i)%u_Obs_Minus_Forecast_unadjusted )
181 call nc_diag_metadata(
"v_Observation", aircft_wind(i)%v_Observation )
182 call nc_diag_metadata(
"v_Obs_Minus_Forecast_adjusted", aircft_wind(i)%v_Obs_Minus_Forecast_adjusted )
183 call nc_diag_metadata(
"v_Obs_Minus_Forecast_unadjusted", aircft_wind(i)%v_Obs_Minus_Forecast_unadjusted )
184 call nc_diag_metadata(
"Wind_Reduction_Factor_at_10m", aircft_wind(i)%Wind_Reduction_Factor_at_10m )
187 do i=1,aircft_header%n_Observations_Mass
188 if (aircft_mass(i)%Observation_Class .eq. aircft_header%ObsType(itype) )
then 189 call nc_diag_metadata(
"Station_ID", aircft_mass(i)%Station_ID )
190 call nc_diag_metadata(
"Observation_Class", aircft_mass(i)%Observation_Class )
191 call nc_diag_metadata(
"Observation_Type", aircft_mass(i)%Observation_Type )
193 call nc_diag_metadata(
"Latitude", aircft_mass(i)%Latitude )
194 call nc_diag_metadata(
"Longitude", aircft_mass(i)%Longitude )
195 call nc_diag_metadata(
"Station_Elevation", aircft_mass(i)%Station_Elevation )
196 call nc_diag_metadata(
"Pressure", aircft_mass(i)%Pressure )
197 call nc_diag_metadata(
"Height", aircft_mass(i)%Height )
198 call nc_diag_metadata(
"Time", aircft_mass(i)%Time )
199 call nc_diag_metadata(
"Prep_QC_Mark", aircft_mass(i)%Prep_QC_Mark )
200 call nc_diag_metadata(
"Setup_QC_Mark", aircft_mass(i)%Setup_QC_Mark )
201 call nc_diag_metadata(
"Prep_Use_Flag", aircft_mass(i)%Prep_Use_Flag )
202 call nc_diag_metadata(
"Analysis_Use_Flag", aircft_mass(i)%Analysis_Use_Flag )
203 call nc_diag_metadata(
"Nonlinear_QC_Rel_Wgt", aircft_mass(i)%Nonlinear_QC_Rel_Wgt )
204 call nc_diag_metadata(
"Errinv_Input", aircft_mass(i)%Errinv_Input )
205 call nc_diag_metadata(
"Errinv_Adjust", aircft_mass(i)%Errinv_Adjust )
206 call nc_diag_metadata(
"Errinv_Final", aircft_mass(i)%Errinv_Final )
207 call nc_diag_metadata(
"Observation", aircft_mass(i)%Observation )
208 call nc_diag_metadata(
"Obs_Minus_Forecast_adjusted", aircft_mass(i)%Obs_Minus_Forecast_adjusted )
209 call nc_diag_metadata(
"Obs_Minus_Forecast_unadjusted", aircft_mass(i)%Obs_Minus_Forecast_unadjusted )
221 character(len=*),
intent(in) :: infn
224 integer(i_kind) :: fid,nobs
227 call nc_diag_read_init(infn,fid)
228 nobs = nc_diag_read_get_dim(fid,
'nobs')
229 call nc_diag_read_get_global_attr(fid,
"date_time", aircft_header%date )
230 aircft_header%n_Observations_Mass = nobs
231 aircft_header%n_Observations_Wind = nobs
232 call nc_diag_read_close(infn)
237 character(len=*),
intent(in) :: infn
240 integer,
intent(out) :: ierr
242 character(20) :: str, str2
243 integer(i_kind) :: ii, ic, fid, nobs, naircft, ncount(1)
244 integer(i_kind),
allocatable :: indx(:)
245 character(len=8),
allocatable,
dimension(:) :: c_var
246 integer(i_kind),
allocatable,
dimension(:) :: i_var
247 real(r_single),
allocatable,
dimension(:) :: r_var
252 call nc_diag_read_init(infn,fid)
254 nobs=aircft_header%n_Observations_Mass
255 allocate(rtmp_mass(nobs))
256 allocate(c_var(nobs))
257 allocate(i_var(nobs))
258 allocate(r_var(nobs))
263 call nc_diag_read_get_var(fid,
"Observation_Type", i_var ); rtmp_mass(:)%Observation_Type = i_var
265 call nc_diag_read_get_var(fid,
"Latitude", r_var ); rtmp_mass(:)%Latitude = r_var
266 call nc_diag_read_get_var(fid,
"Longitude", r_var ); rtmp_mass(:)%Longitude = r_var
267 call nc_diag_read_get_var(fid,
"Pressure", r_var ); rtmp_mass(:)%Pressure = r_var
268 call nc_diag_read_get_var(fid,
"Height", r_var ); rtmp_mass(:)%Height = r_var
269 call nc_diag_read_get_var(fid,
"Time", r_var ); rtmp_mass(:)%Time = r_var
270 call nc_diag_read_get_var(fid,
"Prep_QC_Mark", r_var ); rtmp_mass(:)%Prep_QC_Mark = r_var
271 call nc_diag_read_get_var(fid,
"Setup_QC_Mark", r_var ); rtmp_mass(:)%Setup_QC_Mark = r_var
272 call nc_diag_read_get_var(fid,
"Prep_Use_Flag", r_var ); rtmp_mass(:)%Prep_Use_Flag = r_var
273 call nc_diag_read_get_var(fid,
"Analysis_Use_Flag", r_var ); rtmp_mass(:)%Analysis_Use_Flag = r_var
274 call nc_diag_read_get_var(fid,
"Nonlinear_QC_Rel_Wgt", r_var ); rtmp_mass(:)%Nonlinear_QC_Rel_Wgt = r_var
275 call nc_diag_read_get_var(fid,
"Errinv_Input", r_var ); rtmp_mass(:)%Errinv_Input = r_var
276 call nc_diag_read_get_var(fid,
"Errinv_Adjust", r_var ); rtmp_mass(:)%Errinv_Adjust = r_var
277 call nc_diag_read_get_var(fid,
"Errinv_Final", r_var ); rtmp_mass(:)%Errinv_Final = r_var
278 call nc_diag_read_get_var(fid,
"Observation", r_var ); rtmp_mass(:)%Observation = r_var
279 call nc_diag_read_get_var(fid,
"Obs_Minus_Forecast_adjusted", r_var ); rtmp_mass(:)%Obs_Minus_Forecast_adjusted = r_var
280 call nc_diag_read_get_var(fid,
"Obs_Minus_Forecast_unadjusted",r_var ); rtmp_mass(:)%Obs_Minus_Forecast_unadjusted = r_var
289 rtmp_mass(ii)%Setup_QC_Mark==
t_qcmark)
then 294 allocate(indx(naircft))
299 rtmp_mass(ii)%Setup_QC_Mark==
t_qcmark)
then 305 print *,
' found this many aircft ', naircft
306 if(ic /= naircft)
then 307 print *,
'error determining Aircraft, inconsistent naircft, ic=', naircft, ic
309 deallocate(aircft_mass)
314 if(
associated(aircft_mass))
deallocate(aircft_mass)
315 allocate (aircft_mass(naircft))
316 aircft_header%n_Observations_Mass = naircft
320 aircft_mass(:)%Observation_Type = rtmp_mass(indx)%Observation_Type
322 aircft_mass(:)%Latitude = rtmp_mass(indx)%Latitude
323 aircft_mass(:)%Longitude = rtmp_mass(indx)%Longitude
324 aircft_mass(:)%Pressure = rtmp_mass(indx)%Pressure
325 aircft_mass(:)%Height = rtmp_mass(indx)%Height
326 aircft_mass(:)%Time = rtmp_mass(indx)%Time
327 aircft_mass(:)%Prep_QC_Mark = rtmp_mass(indx)%Prep_QC_Mark
328 aircft_mass(:)%Setup_QC_Mark = rtmp_mass(indx)%Setup_QC_Mark
329 aircft_mass(:)%Prep_Use_Flag = rtmp_mass(indx)%Prep_Use_Flag
330 aircft_mass(:)%Analysis_Use_Flag = rtmp_mass(indx)%Analysis_Use_Flag
331 aircft_mass(:)%Nonlinear_QC_Rel_Wgt= rtmp_mass(indx)%Nonlinear_QC_Rel_Wgt
332 aircft_mass(:)%Errinv_Input = rtmp_mass(indx)%Errinv_Input
333 aircft_mass(:)%Errinv_Adjust = rtmp_mass(indx)%Errinv_Adjust
334 aircft_mass(:)%Errinv_Final = rtmp_mass(indx)%Errinv_Final
335 aircft_mass(:)%Observation = rtmp_mass(indx)%Observation
336 aircft_mass(:)%Obs_Minus_Forecast_adjusted = rtmp_mass(indx)%Obs_Minus_Forecast_adjusted
337 aircft_mass(:)%Obs_Minus_Forecast_unadjusted = rtmp_mass(indx)%Obs_Minus_Forecast_unadjusted
340 deallocate(rtmp_mass)
342 call nc_diag_read_close(infn)
346 character(*) :: s,text,rep
347 character(len(s)+100) :: outs
350 outs = s ; nt = len_trim(text) ; nr = len_trim(rep)
351 i = index(outs,text(:nt))
352 outs = outs(:i-1) // rep(:nr) // outs(i+nt:)
integer, parameter maxobstype
integer, parameter, public strlen
integer, parameter, public i_kind
integer(i_kind) function get_obstype_index(obstype, obstypearr)
subroutine nc_diag_init(filename, append)
character(len(s)+100) function replace_text(s, text, rep)
subroutine, public read_aircft_diag_nc_header(infn, aircft_header)
subroutine, public write_split_aircft_diag_nc(infn, aircft_header, aircft_mass, aircft_wind, append_suffix)
subroutine, public read_aircft_diag_nc_mass(infn, aircft_header, aircft_mass, ierr)
subroutine nc_diag_read_close(filename, file_ncdr_id, from_pop)
integer, parameter, public r_double
integer, parameter, public r_single
integer, parameter, public r_kind
subroutine nc_diag_read_init(filename, file_ncdr_id, from_push)