39 USE nc_diag_read_mod,
ONLY: nc_diag_read_get_var, nc_diag_read_get_global_attr
74 CHARACTER(len=20) :: isis
75 CHARACTER(len=10) :: id
76 CHARACTER(len=10) :: obstype
77 INTEGER(i_kind) :: jiter
78 INTEGER(i_kind) :: nchan
79 INTEGER(i_kind) :: idate
80 INTEGER(i_kind) :: ireal
81 INTEGER(i_kind) :: ipchan
82 INTEGER(i_kind) :: nsig
83 INTEGER(i_kind) :: isens
87 CHARACTER(len=10),
DIMENSION(ireal_aod) :: fix
88 CHARACTER(len=10),
DIMENSION(:),
ALLOCATABLE :: chn
98 REAL(r_kind) :: tlapmean
99 INTEGER(i_kind):: iuse
100 INTEGER(i_kind):: nuchan
101 INTEGER(i_kind):: iochan
109 REAL(r_kind) :: obstime
110 REAL(r_kind) :: solzen_ang
111 REAL(r_kind) :: solazm_ang
116 REAL(r_kind) :: aodobs
117 REAL(r_kind) :: omgaod
118 REAL(r_kind) :: errinv
119 REAL(r_kind) :: qcmark
135 CHARACTER(len=*),
INTENT(in) :: what
136 INTEGER(i_kind),
INTENT(in) :: iv
137 INTEGER(i_kind),
INTENT(out):: ier
142 CHARACTER(len=*),
INTENT(in) :: what
143 INTEGER(i_kind),
INTENT(out):: iv
144 INTEGER(i_kind),
INTENT(out):: ier
166 LOGICAL,
INTENT(in) :: use_netcdf
200 INTEGER(i_kind),
INTENT(in) :: ftin
204 INTEGER(i_kind),
INTENT(out) :: iflag
205 LOGICAL,
OPTIONAL,
INTENT(in) :: lverbose
209 print *,
'netcdf slot' 246 INTEGER(i_kind),
INTENT(in) :: ftin
247 TYPE(diag_header_fix_list_aod ),
INTENT(out):: header_fix
248 TYPE(diag_header_chan_list_aod),
ALLOCATABLE :: header_chan(:)
249 TYPE(diag_data_name_list_aod) :: data_name
250 INTEGER(i_kind),
INTENT(out) :: iflag
251 LOGICAL,
OPTIONAL,
INTENT(in) :: lverbose
254 INTEGER(i_kind) :: nchan_dim
255 REAL(r_kind),
ALLOCATABLE,
DIMENSION(:) :: r_var_stor
256 INTEGER(i_kind),
ALLOCATABLE,
DIMENSION(:) :: i_var_stor
257 CHARACTER(20) :: isis
258 CHARACTER(10) :: id, obstype
260 INTEGER(i_kind) :: jiter, nchan_diag, idate, &
266 header_fix%nchan = nchan_dim
267 WRITE(*,*)
'Number of channels=',nchan_dim
269 CALL nc_diag_read_get_global_attr(ftin,
"Number_of_channels", nchan_diag)
271 IF (nchan_dim .NE. nchan_diag)
THEN 272 WRITE(*,*)
'ERROR: Number of channels from dimension do not match those from header, aborting.' 276 CALL nc_diag_read_get_global_attr(ftin,
"Satellite_Sensor", isis) ; header_fix%isis = isis
277 CALL nc_diag_read_get_global_attr(ftin,
"Satellite", id) ; header_fix%id = id
278 CALL nc_diag_read_get_global_attr(ftin,
"Observation_type", obstype) ; header_fix%obstype = obstype
279 CALL nc_diag_read_get_global_attr(ftin,
"Outer_Loop_Iteration", jiter) ; header_fix%jiter = jiter
280 CALL nc_diag_read_get_global_attr(ftin,
"date_time", idate) ; header_fix%idate = idate
281 CALL nc_diag_read_get_global_attr(ftin,
"ireal_aoddiag", ireal) ; header_fix%ireal = ireal
282 CALL nc_diag_read_get_global_attr(ftin,
"ipchan_aoddiag", ipchan) ; header_fix%ipchan = ipchan
283 CALL nc_diag_read_get_global_attr(ftin,
"ioff0", isens) ; header_fix%isens = isens
285 ALLOCATE(header_chan(nchan_dim) )
287 ALLOCATE(r_var_stor(nchan_dim), &
288 i_var_stor(nchan_dim) )
290 CALL nc_diag_read_get_var(
'frequency',r_var_stor) ; header_chan%freq = r_var_stor
291 CALL nc_diag_read_get_var(
'polarization',r_var_stor) ; header_chan%polar = r_var_stor
292 CALL nc_diag_read_get_var(
'wavenumber',r_var_stor) ; header_chan%wave = r_var_stor
293 CALL nc_diag_read_get_var(
'error_variance',r_var_stor) ; header_chan%varch = r_var_stor
294 CALL nc_diag_read_get_var(
'use_flag',i_var_stor) ; header_chan%iuse = i_var_stor
295 CALL nc_diag_read_get_var(
'sensor_chan',i_var_stor) ; header_chan%nuchan = i_var_stor
296 CALL nc_diag_read_get_var(
'satinfo_chan',i_var_stor) ; header_chan%iochan = i_var_stor
332 INTEGER(i_kind),
INTENT(in) :: ftin
333 TYPE(diag_header_fix_list_aod ),
INTENT(out):: header_fix
334 TYPE(diag_header_chan_list_aod),
ALLOCATABLE :: header_chan(:)
335 TYPE(diag_data_name_list_aod) :: data_name
336 INTEGER(i_kind),
INTENT(out) :: iflag
337 LOGICAL,
OPTIONAL,
INTENT(in) :: lverbose
340 CHARACTER(len=2):: string
341 CHARACTER(len=10):: satid,sentype
342 CHARACTER(len=20):: sensat
343 INTEGER(i_kind) :: i,ich
344 INTEGER(i_kind):: jiter,nchanl,ianldate,ireal,ipchan,nsig,isens
345 INTEGER(i_kind):: iuse_tmp,nuchan_tmp,iochan_tmp
346 REAL(r_single) :: freq_tmp,polar_tmp,wave_tmp,varch_tmp,tlapmean_tmp
350 IF(
PRESENT(lverbose)) loutall=lverbose
353 READ(ftin,iostat=iflag) sensat,satid,sentype,jiter,nchanl,ianldate,&
354 ireal,ipchan,nsig,isens
357 WRITE(6,*)
'READ_AODDIAG_HEADER: ***ERROR*** Unknown file format. Cannot read' 361 header_fix%isis = sensat
362 header_fix%id = satid
363 header_fix%obstype = sentype
364 header_fix%jiter = jiter
365 header_fix%nchan = nchanl
366 header_fix%idate = ianldate
367 header_fix%ireal = ireal
368 header_fix%ipchan = ipchan
369 header_fix%nsig = nsig
370 header_fix%isens = isens
373 WRITE(6,*)
'READ_AODDIAG_HEADER: isis=',header_fix%isis,&
374 ' nchan=',header_fix%nchan,&
375 ' isens=',header_fix%isens
379 IF (
ALLOCATED(header_chan))
DEALLOCATE(header_chan)
380 IF (
ALLOCATED(data_name%chn))
DEALLOCATE(data_name%chn)
382 ALLOCATE(header_chan( header_fix%nchan))
383 ALLOCATE(data_name%chn(header_fix%ipchan))
385 data_name%fix(1) =
'lat ' 386 data_name%fix(2) =
'lon ' 387 data_name%fix(3) =
'psfc ' 388 data_name%fix(4) =
'obstim ' 389 data_name%fix(5) =
'solzen ' 390 data_name%fix(6) =
'solazm ' 391 data_name%chn(1)=
'obs ' 392 data_name%chn(2)=
'omg ' 393 data_name%chn(3)=
'errinv ' 394 data_name%chn(4)=
'qcmark ' 397 DO ich=1, header_fix%nchan
398 READ(ftin,iostat=iflag) freq_tmp,polar_tmp,wave_tmp,varch_tmp,iuse_tmp,nuchan_tmp,iochan_tmp
400 header_chan(ich)%freq = freq_tmp
401 header_chan(ich)%polar = polar_tmp
402 header_chan(ich)%wave = wave_tmp
403 header_chan(ich)%varch = varch_tmp
404 header_chan(ich)%iuse = iuse_tmp
405 header_chan(ich)%nuchan = nuchan_tmp
406 header_chan(ich)%iochan = iochan_tmp
444 INTEGER(i_kind),
INTENT(in) :: ftin
448 INTEGER(i_kind),
INTENT(out) :: iflag
470 SUBROUTINE read_all_aoddiag(ftin,header_fix,all_data_fix,all_data_chan,nlocs,iflag)
501 INTEGER(i_kind),
INTENT(in) :: ftin
503 INTEGER(i_kind),
INTENT(out) :: iflag
506 INTEGER(i_kind),
INTENT(out) :: nlocs
510 REAL(r_kind),
ALLOCATABLE,
DIMENSION(:) :: latitude, longitude, &
511 &Obs_Time, Psfc, Sol_Zenith_Angle, Sol_Azimuth_Angle,&
512 &Observation, Obs_Minus_Forecast_unadjusted, &
513 &Inverse_Observation_Error, QC_Flag
515 INTEGER(i_kind),
ALLOCATABLE,
DIMENSION(:) :: channel_index
517 INTEGER(i_kind) :: i,ic,ii,ci,ndatum
522 nlocs = ndatum / header_fix%nchan
525 &channel_index(ndatum), latitude(ndatum), longitude(ndatum), &
526 &obs_time(ndatum), psfc(ndatum),&
527 &sol_zenith_angle(ndatum), sol_azimuth_angle(ndatum),&
528 &observation(ndatum), obs_minus_forecast_unadjusted(ndatum),&
529 &inverse_observation_error(ndatum),qc_flag(ndatum))
533 CALL nc_diag_read_get_var(
'Channel_Index', channel_index)
534 CALL nc_diag_read_get_var(
'Latitude', latitude)
535 CALL nc_diag_read_get_var(
'Longitude', longitude)
536 CALL nc_diag_read_get_var(
'Psfc', psfc)
537 CALL nc_diag_read_get_var(
'Obs_Time', obs_time)
538 CALL nc_diag_read_get_var(
'Sol_Zenith_Angle', sol_zenith_angle)
539 CALL nc_diag_read_get_var(
'Sol_Azimuth_Angle', sol_azimuth_angle)
540 CALL nc_diag_read_get_var(
'Observation', observation)
541 CALL nc_diag_read_get_var(
'Obs_Minus_Forecast_unadjusted', obs_minus_forecast_unadjusted)
542 CALL nc_diag_read_get_var(
'Inverse_Observation_Error', inverse_observation_error)
543 CALL nc_diag_read_get_var(
'QC_Flag', qc_flag)
555 DO ic=1,header_fix%nchan
556 ci = channel_index(ii)
558 all_data_chan(i,ci)%omgaod = obs_minus_forecast_unadjusted(ii)
566 print *,
'read_aod_diag binary not working - stopping' 600 INTEGER(i_kind),
INTENT(in) :: ftin
601 TYPE(diag_header_fix_list_aod ),
INTENT(in) :: header_fix
604 INTEGER(i_kind) :: nrecord, ndatum, nangord
605 INTEGER(i_kind) :: cch, ic, ir, cdatum
606 REAL(r_kind),
ALLOCATABLE,
DIMENSION(:) :: Latitude, Longitude, &
607 &Obs_Time, Psfc, Sol_Zenith_Angle, Sol_Azimuth_Angle,&
608 &Observation, Obs_Minus_Forecast_unadjusted, &
609 &Inverse_Observation_Error, QC_Flag
611 INTEGER(i_kind),
ALLOCATABLE,
DIMENSION(:) :: Channel_Index
613 REAL(r_kind) :: clat, clon
616 nrecord = ndatum / header_fix%nchan
619 WRITE(*,*)
'Reading ndatum, nrecord=',ndatum,nrecord
622 &channel_index(ndatum), latitude(ndatum), longitude(ndatum), &
623 &obs_time(ndatum), psfc(ndatum),&
624 &sol_zenith_angle(ndatum), sol_azimuth_angle(ndatum),&
625 &observation(ndatum), obs_minus_forecast_unadjusted(ndatum),&
626 &inverse_observation_error(ndatum),qc_flag(ndatum))
631 CALL nc_diag_read_get_var(
'Channel_Index', channel_index)
632 CALL nc_diag_read_get_var(
'Latitude', latitude)
633 CALL nc_diag_read_get_var(
'Longitude', longitude)
634 CALL nc_diag_read_get_var(
'Psfc', psfc)
635 CALL nc_diag_read_get_var(
'Obs_Time', obs_time)
636 CALL nc_diag_read_get_var(
'Sol_Zenith_Angle', sol_zenith_angle)
637 CALL nc_diag_read_get_var(
'Sol_Azimuth_Angle', sol_azimuth_angle)
638 CALL nc_diag_read_get_var(
'Observation', observation)
639 CALL nc_diag_read_get_var(
'Obs_Minus_Forecast_unadjusted', obs_minus_forecast_unadjusted)
640 CALL nc_diag_read_get_var(
'Inverse_Observation_Error', inverse_observation_error)
641 CALL nc_diag_read_get_var(
'QC_Flag', qc_flag)
645 clat = latitude(cdatum)
646 clon = longitude(cdatum)
654 DO ic=1,header_fix%nchan
655 IF (clat .NE. latitude(cdatum) .OR. clon .NE. longitude(cdatum))
THEN 656 WRITE(*,*)
'ERROR: Lats & Lons are mismatched. This is bad' 657 print *,
'irecord=',ir
658 print *,
'clat,clon=',clat,clon
659 print *,
'lat/lon(datum)=',latitude(cdatum), longitude(cdatum)
662 cch = channel_index(cdatum)
664 all_data_chan(ir,cch)%omgaod = obs_minus_forecast_unadjusted(cdatum)
665 all_data_chan(ir,cch)%errinv= inverse_observation_error(cdatum)
703 INTEGER(i_kind),
INTENT(in) :: ftin
704 TYPE(diag_header_fix_list_aod ),
INTENT(in) :: header_fix
705 TYPE(diag_data_fix_list_aod) ,
INTENT(out):: data_fix
706 TYPE(diag_data_chan_list_aod) ,
ALLOCATABLE :: data_chan(:)
707 INTEGER(i_kind),
INTENT(out) :: iflag
710 IF (.NOT.
ALLOCATED(data_chan))
ALLOCATE(data_chan(header_fix%nchan) )
749 INTEGER(i_kind),
INTENT(in) :: ftin
750 TYPE(diag_header_fix_list_aod ),
INTENT(in) :: header_fix
751 TYPE(diag_data_fix_list_aod) ,
INTENT(out):: data_fix
752 TYPE(diag_data_chan_list_aod) ,
ALLOCATABLE :: data_chan(:)
753 INTEGER(i_kind),
INTENT(out) :: iflag
755 INTEGER(i_kind) :: ich,iang,i,j
756 REAL(r_single),
DIMENSION(:,:),
ALLOCATABLE :: data_tmp
757 REAL(r_single),
DIMENSION(:),
ALLOCATABLE :: fix_tmp
760 IF (
ALLOCATED(data_chan))
DEALLOCATE(data_chan)
761 ALLOCATE(data_chan(header_fix%nchan))
764 ALLOCATE(data_tmp(header_fix%ipchan,header_fix%nchan))
770 READ(ftin,iostat=iflag) fix_tmp, data_tmp
773 data_fix%lat = fix_tmp(1)
774 data_fix%lon = fix_tmp(2)
775 data_fix%psfc = fix_tmp(3)
776 data_fix%obstime = fix_tmp(4)
777 data_fix%solzen_ang = fix_tmp(5)
778 data_fix%solazm_ang = fix_tmp(6)
781 DO ich=1,header_fix%nchan
782 data_chan(ich)%aodobs =data_tmp(1,ich)
783 data_chan(ich)%omgaod =data_tmp(2,ich)
784 data_chan(ich)%errinv=data_tmp(3,ich)
785 data_chan(ich)%qcmark=data_tmp(4,ich)
788 DEALLOCATE(data_tmp, fix_tmp)
subroutine, public read_aoddiag_data(ftin, header_fix, data_fix, data_chan, iflag)
integer(i_kind), parameter, public ireal_aod
subroutine read_aoddiag_data_bin(ftin, header_fix, data_fix, data_chan, iflag)
integer(i_kind), parameter, public ipchan_aod
subroutine read_aoddiag_data_nc_init(ftin, header_fix)
integer, parameter, public i_kind
subroutine set_aoddiag_int_(what, iv, ier)
integer, save num_records
subroutine read_aoddiag_header_nc(ftin, header_fix, header_chan, data_name, iflag, lverbose)
type(diag_data_chan_list_aod), dimension(:,:), allocatable, save all_data_chan
subroutine, public read_all_aoddiag(ftin, header_fix, all_data_fix, all_data_chan, nlocs, iflag)
subroutine read_aoddiag_header_bin(ftin, header_fix, header_chan, data_name, iflag, lverbose)
subroutine read_aoddiag_data_nc(ftin, header_fix, data_fix, data_chan, iflag)
subroutine get_aoddiag_int_(what, iv, ier)
subroutine, public set_netcdf_read_aod(use_netcdf)
subroutine, public read_aoddiag_header(ftin, header_fix, header_chan, data_name, iflag, lverbose)
type(diag_data_fix_list_aod), dimension(:), allocatable, save all_data_fix
integer, parameter, public r_single
integer, parameter, public r_kind
real(r_kind), parameter rmiss_aoddiag