8 nc_diag_write, nc_diag_data2d, nc_diag_chaninfo_dim_set, nc_diag_chaninfo
12 real,
parameter:: missing = -9.99e9
13 integer,
parameter:: imissing = -999999
15 integer nargs, iargc, n
16 character*256,
allocatable :: arg(:)
36 logical :: append_suffix
38 character*256 infn, outfn
39 logical linfile, loutfile
41 integer,
parameter :: inlun = 51
42 integer,
parameter :: outlun= 52
43 integer,
parameter :: nllun = 53
46 integer iuse, ich, nch, ipr
48 logical,
dimension(:),
allocatable :: luse
51 integer,
parameter :: nvar = 4
77 integer :: inobstotal, inobsassim
78 real(r_single) :: rvomf_nbc, rvomf_bc, rvtotbias, rvfixbias
79 real(r_single),
dimension(:),
allocatable :: rvbiasterms
80 character(len=13),
dimension(:),
allocatable :: chfrwn
82 integer,
parameter :: max_npred = 9
84 character(len=10),
dimension(max_npred) :: biasnames
85 data biasnames /
'bc_const ', &
95 real(r_quad) :: cvar, rch
106 append_suffix = .false.
110 call getarg(n,arg(n))
113 if (trim(arg(n)).eq.
'-debug' ) debug=.true.
114 if (trim(arg(n)).eq.
'-sst_ret' ) sst_ret=.true.
115 if (trim(arg(n)).eq.
'-append_nc4') append_suffix=.true.
116 if (trim(arg(n)).eq.
'-npred' )
read ( arg(n+1),* ) npred_read
117 if (trim(arg(n)).eq.
'-iversion' )
read ( arg(n+1),* ) iversion
122 if (debug)
write(*,*)
'Debugging on - Verbose Printing' 125 call getarg(nargs, infn)
129 write(*,*)
'Input bin diag: ',trim(infn)
130 inquire(file=trim(infn), exist=linfile)
131 if (.not. linfile)
then 132 write(*,*)trim(infn) //
' does not exist - exiting' 136 if (.not. append_suffix)
then 137 outfn = infn(1:
strlen-3) //
'nc4' 139 outfn = infn(1:
strlen) //
'.nc4' 143 write(*,*)
'Output NC4 diag: ',trim(outfn)
144 inquire(file=trim(outfn), exist=loutfile)
145 if (loutfile)
write(*,*)
'WARNING: ' // trim(infn) //
' exists - overwriting' 149 open(inlun,file=infn,form=
'unformatted',convert=
'big_endian')
152 call read_radiag_header( inlun, npred_read, sst_ret, header_fix, header_chan, headname, iflag, debug )
154 call nc_diag_chaninfo_dim_set(header_fix%nchan)
156 call nc_diag_header(
"Satellite_Sensor", header_fix%isis )
157 call nc_diag_header(
"Satellite", header_fix%id )
158 call nc_diag_header(
"Observation_type", header_fix%obstype )
159 call nc_diag_header(
"Outer_Loop_Iteration", header_fix%jiter )
160 call nc_diag_header(
"Number_of_channels", header_fix%nchan )
161 call nc_diag_header(
"Number_of_Predictors", header_fix%npred )
162 call nc_diag_header(
"date_time", header_fix%idate )
163 call nc_diag_header(
"ireal_radiag", header_fix%ireal )
164 call nc_diag_header(
"ipchan_radiag", header_fix%ipchan )
165 call nc_diag_header(
"iextra", header_fix%iextra )
166 call nc_diag_header(
"jextra", header_fix%jextra )
167 call nc_diag_header(
"idiag", header_fix%idiag )
168 call nc_diag_header(
"angord", header_fix%angord )
169 call nc_diag_header(
"iversion_radiag", header_fix%iversion)
170 call nc_diag_header(
"New_pc4pred", header_fix%inewpc )
171 call nc_diag_header(
"ioff0", header_fix%isens )
174 nch = header_fix%nchan
179 write(*,*)
'Number of Channels: ',nch
180 write(*,*)
'Number of variationalbc predictors: ',npred_read
181 write(*,*)
' predictors: ',biasnames(1:npred_read)
182 write(*,*)
' iversion=',header_fix%iversion
185 if (iversion .gt. 0)
then 186 write(*,*)
'BE AWARE THAT iversion IS BEING OVERRIDEN!' 187 write(*,*)
' iversion diag, override=',header_fix%iversion,iversion
188 write(*,*)
' (this was made necessary w/ emis bc...hopefully only temporary)' 189 header_fix%iversion = iversion
193 call nc_diag_chaninfo(
"chaninfoidx", i )
194 call nc_diag_chaninfo(
"frequency", header_chan(i)%freq )
195 call nc_diag_chaninfo(
"polarization", header_chan(i)%polar )
196 call nc_diag_chaninfo(
"wavenumber", header_chan(i)%wave )
197 call nc_diag_chaninfo(
"error_variance", header_chan(i)%varch )
198 call nc_diag_chaninfo(
"mean_lapse_rate", header_chan(i)%tlapmean)
199 call nc_diag_chaninfo(
"use_flag", header_chan(i)%iuse )
200 call nc_diag_chaninfo(
"sensor_chan", header_chan(i)%nuchan )
201 call nc_diag_chaninfo(
"satinfo_chan", header_chan(i)%iochan )
205 do while (iflag .ge. 0)
209 if (iflag .lt. 0) cycle
212 lqcpass = luse(ich) .and. data_chan(ich)%qcmark .eq. 0
214 call nc_diag_metadata(
"Channel_Index", i )
215 call nc_diag_metadata(
"Observation_Class",
' rad' )
216 call nc_diag_metadata(
"Latitude", data_fix%lat )
217 call nc_diag_metadata(
"Longitude", data_fix%lon )
219 call nc_diag_metadata(
"Elevation", data_fix%zsges )
221 call nc_diag_metadata(
"Obs_Time", data_fix%obstime )
223 call nc_diag_metadata(
"Scan_Position", data_fix%senscn_pos )
224 call nc_diag_metadata(
"Sat_Zenith_Angle", data_fix%satzen_ang )
225 call nc_diag_metadata(
"Sat_Azimuth_Angle", data_fix%satazm_ang )
226 call nc_diag_metadata(
"Sol_Zenith_Angle", data_fix%solzen_ang )
227 call nc_diag_metadata(
"Sol_Azimuth_Angle", data_fix%solazm_ang )
228 call nc_diag_metadata(
"Sun_Glint_Angle", data_fix%sungln_ang )
230 call nc_diag_metadata(
"Water_Fraction", data_fix%water_frac )
231 call nc_diag_metadata(
"Land_Fraction", data_fix%land_frac )
232 call nc_diag_metadata(
"Ice_Fraction", data_fix%ice_frac )
233 call nc_diag_metadata(
"Snow_Fraction", data_fix%snow_frac )
235 if (.not. sst_ret)
then 236 call nc_diag_metadata(
"Water_Temperature", data_fix%water_temp )
237 call nc_diag_metadata(
"Land_Temperature", data_fix%land_temp )
238 call nc_diag_metadata(
"Ice_Temperature", data_fix%ice_temp )
239 call nc_diag_metadata(
"Snow_Temperature", data_fix%snow_temp )
240 call nc_diag_metadata(
"Soil_Temperature", data_fix%soil_temp )
241 call nc_diag_metadata(
"Soil_Moisture", data_fix%soil_mois )
242 call nc_diag_metadata(
"Land_Type_Index", data_fix%land_type )
244 call nc_diag_metadata(
"tsavg5", missing )
245 call nc_diag_metadata(
"sstcu", missing )
246 call nc_diag_metadata(
"sstph", missing )
247 call nc_diag_metadata(
"sstnv", missing )
248 call nc_diag_metadata(
"dta", missing )
249 call nc_diag_metadata(
"dqa", missing )
250 call nc_diag_metadata(
"dtp_avh", missing )
252 call nc_diag_metadata(
"Water_Temperature", missing )
253 call nc_diag_metadata(
"Land_Temperature", missing )
254 call nc_diag_metadata(
"Ice_Temperature", missing )
255 call nc_diag_metadata(
"Snow_Temperature", missing )
256 call nc_diag_metadata(
"Soil_Temperature", missing )
257 call nc_diag_metadata(
"Soil_Moisture", missing )
258 call nc_diag_metadata(
"Land_Type_Index", missing )
260 call nc_diag_metadata(
"tsavg5", data_fix%water_temp )
261 call nc_diag_metadata(
"sstcu", data_fix%land_temp )
262 call nc_diag_metadata(
"sstph", data_fix%ice_temp )
263 call nc_diag_metadata(
"sstnv", data_fix%snow_temp )
264 call nc_diag_metadata(
"dta", data_fix%soil_temp )
265 call nc_diag_metadata(
"dqa", data_fix%soil_mois )
266 call nc_diag_metadata(
"dtp_avh", data_fix%land_type )
269 call nc_diag_metadata(
"Vegetation_Fraction", data_fix%veg_frac )
270 call nc_diag_metadata(
"Snow_Depth", data_fix%snow_depth )
272 call nc_diag_metadata(
"tpwc_amsua", missing )
273 call nc_diag_metadata(
"clw_guess_retrieval", data_fix%qcdiag1 )
275 call nc_diag_metadata(
"Sfc_Wind_Speed", data_fix%sfc_wndspd )
276 call nc_diag_metadata(
"Cloud_Frac", data_fix%qcdiag1 )
277 call nc_diag_metadata(
"CTP", data_fix%qcdiag2 )
278 call nc_diag_metadata(
"CLW", data_fix%qcdiag1 )
279 call nc_diag_metadata(
"TPWC", data_fix%qcdiag2 )
280 call nc_diag_metadata(
"clw_obs", data_fix%qcdiag1 )
281 call nc_diag_metadata(
"clw_guess", data_fix%qcdiag2 )
283 call nc_diag_metadata(
"Foundation_Temperature", data_fix%tref )
284 call nc_diag_metadata(
"SST_Warm_layer_dt", data_fix%dtw )
285 call nc_diag_metadata(
"SST_Cool_layer_tdrop", data_fix%dtc )
286 call nc_diag_metadata(
"SST_dTz_dTfound", data_fix%tz_tr )
288 call nc_diag_metadata(
"Observation", data_chan(ich)%tbobs )
289 call nc_diag_metadata(
"Obs_Minus_Forecast_adjusted", data_chan(ich)%omgbc )
290 call nc_diag_metadata(
"Obs_Minus_Forecast_unadjusted", data_chan(ich)%omgnbc )
292 call nc_diag_metadata(
"Inverse_Observation_Error", data_chan(ich)%errinv )
297 call nc_diag_metadata(
"QC_Flag", data_chan(ich)%qcmark )
299 call nc_diag_metadata(
"Emissivity", data_chan(ich)%emiss )
300 call nc_diag_metadata(
"Weighted_Lapse_Rate", data_chan(ich)%tlap )
301 call nc_diag_metadata(
"dTb_dTs", data_chan(ich)%tb_tz )
303 call nc_diag_metadata(
"BC_Constant", data_chan(ich)%bicons )
304 call nc_diag_metadata(
"BC_Scan_Angle", data_chan(ich)%biang )
305 call nc_diag_metadata(
"BC_Cloud_Liquid_Water", data_chan(ich)%biclw )
306 call nc_diag_metadata(
"BC_Lapse_Rate_Squared", data_chan(ich)%bilap2 )
307 call nc_diag_metadata(
"BC_Lapse_Rate", data_chan(ich)%bilap )
308 call nc_diag_metadata(
"BC_Cosine_Latitude_times_Node", data_chan(ich)%bicos )
309 call nc_diag_metadata(
"BC_Sine_Latitude", data_chan(ich)%bisin )
310 call nc_diag_metadata(
"BC_Emissivity", data_chan(ich)%biemis )
311 if (header_fix%angord .eq. 1)
then 312 call nc_diag_metadata(
"BC_Fixed_Scan_Position", data_chan(ich)%bifix(1) )
313 else if (header_fix%angord .ge. 2)
then 314 call nc_diag_data2d(
'BC_angord ', data_chan(ich)%bifix )
327 100
format(
"Usage: ",/,/ &
328 " convert_rad_diag.x <options> <filename>",/,/ &
330 " -debug : Set debug verbosity",/ &
331 " -sst_ret : SST BC term is included (default: not included)",/ &
332 " -npred INT : Number of preductors (default: 7)",/ &
333 " -iversion INT : Override iversion with INT (default: use internal iversion)",/ &
334 " -append_txt : Append .txt suffix, instead of replace last three",/ &
335 " characters (default: replaced)",/ &
336 " Note: The GMAO diag files end with .bin or .nc4,",/ &
337 " which is where fixed 3-char truncation originates",/,/,/ &
339 " convert_rad_diag.x nc_4emily.diag_hirs4_n19_ges.20161202_00z.bin",/ &
341 " nc_4emily.diag_hirs4_n19_ges.20161202_00z.nc4",/ &
subroutine, public read_radiag_header(ftin, npred_radiag, retrieval, header_fix, header_chan, data_name, iflag, lverbose)
integer, parameter, public strlen
subroutine nc_diag_init(filename, append)
subroutine, public read_radiag_data(ftin, header_fix, retrieval, data_fix, data_chan, data_extra, iflag)
integer, parameter, public r_quad
integer, parameter, public r_single