39 use nc_diag_read_mod,
only: nc_diag_read_get_var, nc_diag_read_get_global_attr
82 character(len=20) :: isis
83 character(len=10) :: id
84 character(len=10) :: obstype
85 integer(i_kind) :: jiter
86 integer(i_kind) :: nchan
87 integer(i_kind) :: npred
88 integer(i_kind) :: idate
89 integer(i_kind) :: ireal
90 integer(i_kind) :: ipchan
91 integer(i_kind) :: iextra
92 integer(i_kind) :: jextra
93 integer(i_kind) :: idiag
94 integer(i_kind) :: angord
95 integer(i_kind) :: iversion
96 integer(i_kind) :: inewpc
97 integer(i_kind) :: isens
101 character(len=10),
dimension(ireal_radiag) :: fix
102 character(len=10),
dimension(:),
allocatable :: chn
106 real(r_single) :: freq
107 real(r_single) :: polar
108 real(r_single) :: wave
109 real(r_single) :: varch
110 real(r_single) :: tlapmean
111 integer(i_kind):: iuse
112 integer(i_kind):: nuchan
113 integer(i_kind):: iochan
117 real(r_single) :: lat
118 real(r_single) :: lon
119 real(r_single) :: zsges
120 real(r_single) :: obstime
121 real(r_single) :: senscn_pos
122 real(r_single) :: senscn_ang
123 real(r_single) :: satzen_ang
124 real(r_single) :: satazm_ang
125 real(r_single) :: solzen_ang
126 real(r_single) :: solazm_ang
127 real(r_single) :: sungln_ang
128 real(r_single) :: water_frac
129 real(r_single) :: land_frac
130 real(r_single) :: ice_frac
131 real(r_single) :: snow_frac
132 real(r_single) :: water_temp
133 real(r_single) :: land_temp
134 real(r_single) :: ice_temp
135 real(r_single) :: snow_temp
136 real(r_single) :: soil_temp
137 real(r_single) :: soil_mois
138 real(r_single) :: land_type
139 real(r_single) :: veg_frac
140 real(r_single) :: snow_depth
141 real(r_single) :: sfc_wndspd
142 real(r_single) :: qcdiag1
143 real(r_single) :: qcdiag2
144 real(r_single) :: tref
145 real(r_single) :: dtw
146 real(r_single) :: dtc
147 real(r_single) :: tz_tr
151 real(r_single) :: tbobs
152 real(r_single) :: omgbc
153 real(r_single) :: omgnbc
154 real(r_single) :: errinv
155 real(r_single) :: qcmark
156 real(r_single) :: emiss
157 real(r_single) :: tlap
158 real(r_single) :: tb_tz
159 real(r_single) :: bicons
160 real(r_single) :: biang
161 real(r_single) :: biclw
162 real(r_single) :: bilap2
163 real(r_single) :: bilap
164 real(r_single) :: bicos
165 real(r_single) :: bisin
166 real(r_single) :: biemis
167 real(r_single),
dimension(:),
allocatable :: bifix
168 real(r_single) :: bisst
172 real(r_single) :: extra
187 integer(i_kind) :: cur_ob_idx
188 integer(i_kind) :: num_records
202 character(len=*),
intent(in) :: what
203 integer(i_kind),
intent(in) :: iv
204 integer(i_kind),
intent(out):: ier
206 if(trim(what)==
'version')
then 213 character(len=*),
intent(in) :: what
214 integer(i_kind),
intent(out):: iv
215 integer(i_kind),
intent(out):: ier
217 if(trim(what)==
'version')
then 241 logical,
intent(in) :: use_netcdf
248 character*500,
intent(in) :: filename
249 integer(i_kind),
intent(inout) :: ftin
255 write(6,*)
'OPEN_RADIAG: ***ERROR*** Cannot open more than ', &
280 open(ftin,form=
"unformatted",file=filename)
287 character*500,
intent(in) :: filename
288 integer(i_kind),
intent(inout) :: ftin
290 integer(i_kind) :: id
295 write(6,*)
'CLOSE_RADIAG: ***ERROR*** ncdiag file ', filename, &
320 subroutine read_radiag_header(ftin,npred_radiag,retrieval,header_fix,header_chan,data_name,iflag,lverbose)
350 integer(i_kind),
intent(in) :: ftin
351 integer(i_kind),
intent(in) :: npred_radiag
352 logical,
intent(in) :: retrieval
356 integer(i_kind),
intent(out) :: iflag
357 logical,
optional,
intent(in) :: lverbose
361 print *,
'netcdf slot' 362 call read_radiag_header_nc(ftin,npred_radiag,retrieval,header_fix,header_chan,data_name,iflag,lverbose)
369 subroutine read_radiag_header_nc(ftin,npred_radiag,retrieval,header_fix,header_chan,data_name,iflag,lverbose)
398 integer(i_kind),
intent(in) :: ftin
399 integer(i_kind),
intent(in) :: npred_radiag
400 logical,
intent(in) :: retrieval
401 type(diag_header_fix_list ),
intent(out):: header_fix
402 type(diag_header_chan_list),
allocatable :: header_chan(:)
403 type(diag_data_name_list) :: data_name
404 integer(i_kind),
intent(out) :: iflag
405 logical,
optional,
intent(in) :: lverbose
408 integer(i_kind) :: nchan_dim
409 real(r_kind),
allocatable,
dimension(:) :: r_var_stor
410 integer(i_kind),
allocatable,
dimension(:) :: i_var_stor
411 character(20) :: isis
412 character(10) :: id, obstype
414 integer(i_kind) :: jiter, nchan_diag, npred, idate, &
415 ireal, ipchan, iextra, jextra, &
416 idiag, angord, iversion, inewpc, &
421 nchan_dim = nc_diag_read_get_dim(ftin,
'nchans')
422 write(*,*)
'Number of channels=',nchan_dim
423 header_fix%nchan = nchan_dim
425 call nc_diag_read_get_global_attr(ftin,
"Number_of_channels", nchan_diag)
427 if (nchan_dim .ne. nchan_diag)
then 428 write(*,*)
'ERROR: Number of channels from dimension do not match those from header, aborting.' 432 call nc_diag_read_get_global_attr(ftin,
"Satellite_Sensor", isis) ; header_fix%isis = isis
433 call nc_diag_read_get_global_attr(ftin,
"Satellite", id) ; header_fix%id = id
434 call nc_diag_read_get_global_attr(ftin,
"Observation_type", obstype) ; header_fix%obstype = obstype
435 call nc_diag_read_get_global_attr(ftin,
"Outer_Loop_Iteration", jiter) ; header_fix%jiter = jiter
436 call nc_diag_read_get_global_attr(ftin,
"Number_of_Predictors", npred) ; header_fix%npred = npred
437 call nc_diag_read_get_global_attr(ftin,
"date_time", idate) ; header_fix%idate = idate
438 call nc_diag_read_get_global_attr(ftin,
"ireal_radiag", ireal) ; header_fix%ireal = ireal
439 call nc_diag_read_get_global_attr(ftin,
"ipchan_radiag", ipchan) ; header_fix%ipchan = ipchan
440 call nc_diag_read_get_global_attr(ftin,
"iextra", iextra) ; header_fix%iextra = iextra
441 call nc_diag_read_get_global_attr(ftin,
"jextra", jextra) ; header_fix%jextra = jextra
442 call nc_diag_read_get_global_attr(ftin,
"idiag", idiag) ; header_fix%idiag = idiag
443 call nc_diag_read_get_global_attr(ftin,
"angord", angord) ; header_fix%angord = angord
444 call nc_diag_read_get_global_attr(ftin,
"iversion_radiag", iversion) ; header_fix%iversion = iversion
445 call nc_diag_read_get_global_attr(ftin,
"New_pc4pred", inewpc) ; header_fix%inewpc = inewpc
446 call nc_diag_read_get_global_attr(ftin,
"ioff0", isens) ; header_fix%isens = isens
449 allocate(header_chan(nchan_dim) )
451 allocate(r_var_stor(nchan_dim), &
452 i_var_stor(nchan_dim) )
454 call nc_diag_read_get_var(ftin,
'frequency',r_var_stor) ; header_chan%freq = r_var_stor
455 call nc_diag_read_get_var(ftin,
'polarization',i_var_stor) ; header_chan%polar = i_var_stor
456 call nc_diag_read_get_var(ftin,
'wavenumber',r_var_stor) ; header_chan%wave = r_var_stor
457 call nc_diag_read_get_var(ftin,
'error_variance',r_var_stor) ; header_chan%varch = r_var_stor
458 call nc_diag_read_get_var(ftin,
'mean_lapse_rate',r_var_stor); header_chan%tlapmean = r_var_stor
459 call nc_diag_read_get_var(ftin,
'use_flag',i_var_stor) ; header_chan%iuse = i_var_stor
460 call nc_diag_read_get_var(ftin,
'sensor_chan',i_var_stor) ; header_chan%nuchan = i_var_stor
461 call nc_diag_read_get_var(ftin,
'satinfo_chan',i_var_stor) ; header_chan%iochan = i_var_stor
466 subroutine read_radiag_header_bin(ftin,npred_radiag,retrieval,header_fix,header_chan,data_name,iflag,lverbose)
499 integer(i_kind),
intent(in) :: ftin
500 integer(i_kind),
intent(in) :: npred_radiag
501 logical,
intent(in) :: retrieval
502 type(diag_header_fix_list ),
intent(out):: header_fix
503 type(diag_header_chan_list),
allocatable :: header_chan(:)
504 type(diag_data_name_list) :: data_name
505 integer(i_kind),
intent(out) :: iflag
506 logical,
optional,
intent(in) :: lverbose
509 character(len=2):: string
510 character(len=10):: satid,sentype
511 character(len=20):: sensat
512 integer(i_kind) :: i,ich
513 integer(i_kind):: jiter,nchanl,npred,ianldate,ireal,ipchan,iextra,jextra
514 integer(i_kind):: idiag,angord,iversion,inewpc,isens
515 integer(i_kind):: iuse_tmp,nuchan_tmp,iochan_tmp
516 real(r_single) :: freq_tmp,polar_tmp,wave_tmp,varch_tmp,tlapmean_tmp
520 if(
present(lverbose)) loutall=lverbose
523 read(ftin,iostat=iflag) sensat,satid,sentype,jiter,nchanl,npred,ianldate,&
524 ireal,ipchan,iextra,jextra,idiag,angord,iversion,inewpc,isens
527 read(ftin,iostat=iflag) sensat,satid,sentype,jiter,nchanl,npred,ianldate,&
528 ireal,ipchan,iextra,jextra,idiag,angord,iversion,inewpc
534 read(ftin,iostat=iflag) sensat,satid,sentype,jiter,nchanl,npred,ianldate,&
535 ireal,ipchan,iextra,jextra
542 write(6,*)
'READ_RADIAG_HEADER: ***ERROR*** Unknown file format. Cannot read' 547 header_fix%isis = sensat
548 header_fix%id = satid
549 header_fix%obstype = sentype
550 header_fix%jiter = jiter
551 header_fix%nchan = nchanl
552 header_fix%npred = npred
553 header_fix%idate = ianldate
554 header_fix%ireal = ireal
555 header_fix%ipchan = ipchan
556 header_fix%iextra = iextra
557 header_fix%jextra = jextra
558 header_fix%idiag = idiag
559 header_fix%angord = angord
560 header_fix%iversion= iversion
561 header_fix%inewpc = inewpc
562 header_fix%isens = isens
565 write(6,*)
'READ_RADIAG_HEADER: isis=',header_fix%isis,&
566 ' nchan=',header_fix%nchan,&
567 ' npred=',header_fix%npred,&
568 ' angord=',header_fix%angord,&
569 ' idiag=',header_fix%idiag,&
570 ' iversion=',header_fix%iversion,&
571 ' inewpc=',header_fix%inewpc,&
572 ' isens=',header_fix%isens
574 if ( header_fix%iextra /= 0) &
575 write(6,*)
'READ_RADIAG_HEADER: extra diagnostic information available, ',&
576 'iextra=',header_fix%iextra
579 if (header_fix%npred /= npred_radiag .and. npred_radiag /= 0) &
580 write(6,*)
'READ_RADIAG_HEADER: **WARNING** header_fix%npred,npred=',&
581 header_fix%npred,npred_radiag
584 if (
allocated(header_chan))
deallocate(header_chan)
585 if (
allocated(data_name%chn))
deallocate(data_name%chn)
587 allocate(header_chan( header_fix%nchan))
588 allocate(data_name%chn(header_fix%idiag))
590 data_name%fix(1) =
'lat ' 591 data_name%fix(2) =
'lon ' 592 data_name%fix(3) =
'zsges ' 593 data_name%fix(4) =
'obstim ' 594 data_name%fix(5) =
'scanpos ' 595 data_name%fix(6) =
'satzen ' 596 data_name%fix(7) =
'satazm ' 597 data_name%fix(8) =
'solzen ' 598 data_name%fix(9) =
'solazm ' 599 data_name%fix(10)=
'sungln ' 600 data_name%fix(11)=
'fwater ' 601 data_name%fix(12)=
'fland ' 602 data_name%fix(13)=
'fice ' 603 data_name%fix(14)=
'fsnow ' 604 data_name%fix(15)=
'twater ' 605 data_name%fix(16)=
'tland ' 606 data_name%fix(17)=
'tice ' 607 data_name%fix(18)=
'tsnow ' 608 data_name%fix(19)=
'tsoil ' 609 data_name%fix(20)=
'soilmoi ' 610 data_name%fix(21)=
'landtyp ' 611 data_name%fix(22)=
'vegfrac ' 612 data_name%fix(23)=
'snowdep ' 613 data_name%fix(24)=
'wndspd ' 614 data_name%fix(25)=
'qc1 ' 615 data_name%fix(26)=
'qc2 ' 616 data_name%fix(27)=
'tref ' 617 data_name%fix(28)=
'dtw ' 618 data_name%fix(29)=
'dtc ' 619 data_name%fix(30)=
'tz_tr ' 621 data_name%chn(1)=
'obs ' 622 data_name%chn(2)=
'omgbc ' 623 data_name%chn(3)=
'omgnbc ' 624 data_name%chn(4)=
'errinv ' 625 data_name%chn(5)=
'qcmark ' 626 data_name%chn(6)=
'emiss ' 627 data_name%chn(7)=
'tlap ' 628 data_name%chn(8)=
'tb_tz ' 631 data_name%chn( 8)=
'bifix ' 632 data_name%chn( 9)=
'bilap ' 633 data_name%chn(10)=
'bilap2 ' 634 data_name%chn(11)=
'bicons ' 635 data_name%chn(12)=
'biang ' 636 data_name%chn(13)=
'biclw ' 637 if (retrieval) data_name%chn(13)=
'bisst ' 639 data_name%chn( 8)=
'bicons ' 640 data_name%chn( 9)=
'biang ' 641 data_name%chn(10)=
'biclw ' 642 data_name%chn(11)=
'bilap2 ' 643 data_name%chn(12)=
'bilap ' 644 do i=1,header_fix%angord
645 write(
string,
'(i2.2)') header_fix%angord-i+1
646 data_name%chn(12+i)=
'bifix' //
string 648 data_name%chn(12+header_fix%angord+1)=
'bifix ' 649 data_name%chn(12+header_fix%angord+2)=
'bisst ' 651 data_name%chn( 9)=
'bicons ' 652 data_name%chn(10)=
'biang ' 653 data_name%chn(11)=
'biclw ' 654 data_name%chn(12)=
'bilap2 ' 655 data_name%chn(13)=
'bilap ' 656 do i=1,header_fix%angord
657 write(
string,
'(i2.2)') header_fix%angord-i+1
658 data_name%chn(13+i)=
'bifix' //
string 660 data_name%chn(13+header_fix%angord+1)=
'bifix ' 661 data_name%chn(13+header_fix%angord+2)=
'bisst ' 663 data_name%chn( 9)=
'bicons ' 664 data_name%chn(10)=
'biang ' 665 data_name%chn(11)=
'biclw ' 666 data_name%chn(12)=
'bilap2 ' 667 data_name%chn(13)=
'bilap ' 668 data_name%chn(14)=
'bicos ' 669 data_name%chn(15)=
'bisin ' 670 do i=1,header_fix%angord
671 write(
string,
'(i2.2)') header_fix%angord-i+1
672 data_name%chn(15+i)=
'bifix' //
string 674 data_name%chn(15+header_fix%angord+1)=
'bifix ' 675 data_name%chn(15+header_fix%angord+2)=
'bisst ' 677 data_name%chn( 9)=
'bicons ' 678 data_name%chn(10)=
'biang ' 679 data_name%chn(11)=
'biclw ' 680 data_name%chn(12)=
'bilap2 ' 681 data_name%chn(13)=
'bilap ' 682 data_name%chn(14)=
'bicos ' 683 data_name%chn(15)=
'bisin ' 684 data_name%chn(16)=
'biemis ' 685 do i=1,header_fix%angord
686 write(
string,
'(i2.2)') header_fix%angord-i+1
687 data_name%chn(16+i)=
'bifix' //
string 689 data_name%chn(16+header_fix%angord+1)=
'bifix ' 690 data_name%chn(16+header_fix%angord+2)=
'bisst ' 694 do ich=1, header_fix%nchan
695 read(ftin,iostat=iflag) freq_tmp,polar_tmp,wave_tmp,varch_tmp,tlapmean_tmp,iuse_tmp,nuchan_tmp,iochan_tmp
696 header_chan(ich)%freq = freq_tmp
697 header_chan(ich)%polar = polar_tmp
698 header_chan(ich)%wave = wave_tmp
699 header_chan(ich)%varch = varch_tmp
700 header_chan(ich)%tlapmean = tlapmean_tmp
701 header_chan(ich)%iuse = iuse_tmp
702 header_chan(ich)%nuchan = nuchan_tmp
703 header_chan(ich)%iochan = iochan_tmp
713 integer,
intent(in) :: ftin
728 subroutine read_radiag_data(ftin,header_fix,retrieval,data_fix,data_chan,data_extra,iflag )
759 integer(i_kind),
intent(in) :: ftin
761 logical,
intent(in) :: retrieval
765 integer(i_kind),
intent(out) :: iflag
767 integer(i_kind) :: id
773 write(6,*)
'READ_RADIAG_DATA: ***ERROR*** netcdf diag file ', ftin,
' has not been opened yet.' 789 if (iflag .ge. 0)
then 799 subroutine read_all_radiag(ftin, header_fix, retrieval, all_data_fix, &
800 all_data_chan, all_data_extra, &
803 integer(i_kind),
intent(in) :: ftin
805 logical,
intent(in) :: retrieval
806 integer(i_kind),
intent(out) :: iflag
810 integer(i_kind),
intent(out) :: nobs
812 integer(i_kind) :: id
817 write(6,*)
'READ_RADIAG_DATA: ***ERROR*** netcdf diag file ', ftin,
' has not been opened yet.' 827 if (.not.
allocated(all_data_fix))
allocate(all_data_fix(nobs))
828 if (.not.
allocated(all_data_chan))
allocate(all_data_chan(nobs,header_fix%nchan) )
829 if (.not.
allocated(all_data_extra))
allocate(all_data_extra(nobs,header_fix%iextra, header_fix%nchan) )
867 integer(i_kind),
intent(in) :: ftin
868 type(ncdiag_status),
intent(inout) :: diag_status
869 type(diag_header_fix_list ),
intent(in) :: header_fix
870 logical,
intent(in) :: retrieval
873 integer(i_kind) :: nrecord, ndatum, nangord
874 integer(i_kind) :: cch, ic, ir, cdatum
875 real(r_kind),
allocatable,
dimension(:) :: Latitude, Longitude, Elevation, Obs_Time, Scan_Position, Scan_Angle, &
876 Sat_Zenith_Angle, Sat_Azimuth_Angle, Sol_Zenith_Angle, Sol_Azimuth_Angle, &
877 Sun_Glint_Angle, Water_Fraction, Land_Fraction, Ice_Fraction, &
878 Snow_Fraction, Water_Temperature, Land_Temperature, Ice_Temperature, &
879 Snow_Temperature, Soil_Temperature, Soil_Moisture, &
880 tsavg5, sstcu, sstph, sstnv, dta, dqa, dtp_avh, Vegetation_Fraction, &
881 Snow_Depth, tpwc_amsua, clw_guess_retrieval, Sfc_Wind_Speed, &
882 Cloud_Frac, CTP, CLW, TPWC, clw_obs, clw_guess, Foundation_Temperature, SST_Warm_layer_dt, &
883 SST_Cool_layer_tdrop, SST_dTz_dTfound, Observation, Obs_Minus_Forecast_adjusted, &
884 Obs_Minus_Forecast_unadjusted, Inverse_Observation_Error, QC_Flag, Emissivity, &
885 Weighted_Lapse_Rate, dTb_dTs, BC_Constant, BC_Scan_Angle, &
886 BC_Cloud_Liquid_Water, BC_Lapse_Rate_Squared, BC_Lapse_Rate, BC_Cosine_Latitude_times_Node, &
887 BC_Sine_Latitude,BC_Emissivity,BC_Fixed_Scan_Position
888 integer(i_kind),
allocatable,
dimension(:) :: Channel_Index, Land_Type_Index
889 real(r_kind),
allocatable,
dimension(:,:) :: BC_angord
891 real(r_kind) :: clat, clon
893 ndatum = nc_diag_read_get_dim(ftin,
'nobs')
894 if (header_fix%angord > 0)
then 895 nangord = nc_diag_read_get_dim(ftin,
'BC_angord_arr_dim')
898 nrecord = ndatum / header_fix%nchan
899 diag_status%num_records = nrecord
901 allocate( channel_index(ndatum), &
902 latitude(ndatum), longitude(ndatum), elevation(ndatum), &
903 obs_time(ndatum), scan_position(ndatum), sat_zenith_angle(ndatum), &
904 sat_azimuth_angle(ndatum), sol_zenith_angle(ndatum), sol_azimuth_angle(ndatum), &
905 sun_glint_angle(ndatum), water_fraction(ndatum), land_fraction(ndatum), &
906 ice_fraction(ndatum), snow_fraction(ndatum), water_temperature(ndatum), &
907 land_temperature(ndatum), ice_temperature(ndatum), snow_temperature(ndatum), &
908 soil_temperature(ndatum), soil_moisture(ndatum), tsavg5(ndatum), &
909 sstcu(ndatum), sstph(ndatum), sstnv(ndatum), &
910 dta(ndatum), dqa(ndatum), dtp_avh(ndatum), &
911 vegetation_fraction(ndatum), snow_depth(ndatum), tpwc_amsua(ndatum), &
912 clw_guess_retrieval(ndatum), sfc_wind_speed(ndatum), cloud_frac(ndatum), &
913 ctp(ndatum), clw(ndatum), tpwc(ndatum), &
914 clw_obs(ndatum), clw_guess(ndatum), foundation_temperature(ndatum), &
915 sst_warm_layer_dt(ndatum), sst_cool_layer_tdrop(ndatum), sst_dtz_dtfound(ndatum), &
916 observation(ndatum), obs_minus_forecast_adjusted(ndatum),obs_minus_forecast_unadjusted(ndatum), &
917 inverse_observation_error(ndatum),qc_flag(ndatum), emissivity(ndatum), &
918 weighted_lapse_rate(ndatum), dtb_dts(ndatum), bc_constant(ndatum), &
919 bc_scan_angle(ndatum), bc_cloud_liquid_water(ndatum), bc_lapse_rate_squared(ndatum), &
920 bc_lapse_rate(ndatum), bc_cosine_latitude_times_node(ndatum), bc_sine_latitude(ndatum), &
921 bc_emissivity(ndatum), bc_fixed_scan_position(ndatum), land_type_index(ndatum), &
924 if (header_fix%angord > 0)
then 925 allocate( bc_angord(nangord, ndatum) )
928 if (
allocated(diag_status%all_data_fix))
deallocate(diag_status%all_data_fix)
929 if (
allocated(diag_status%all_data_chan))
deallocate(diag_status%all_data_chan)
930 if (
allocated(diag_status%all_data_extra))
deallocate(diag_status%all_data_extra)
931 allocate( diag_status%all_data_fix(nrecord) )
932 allocate( diag_status%all_data_chan(nrecord, header_fix%nchan))
933 allocate( diag_status%all_data_extra(nrecord, header_fix%iextra, header_fix%jextra) )
935 call nc_diag_read_get_var(ftin,
'Channel_Index', channel_index)
936 call nc_diag_read_get_var(ftin,
'Latitude', latitude)
937 call nc_diag_read_get_var(ftin,
'Longitude', longitude)
938 call nc_diag_read_get_var(ftin,
'Elevation', elevation)
939 call nc_diag_read_get_var(ftin,
'Obs_Time', obs_time)
940 call nc_diag_read_get_var(ftin,
'Scan_Position', scan_position)
941 call nc_diag_read_get_var(ftin,
'Scan_Angle', scan_angle)
942 call nc_diag_read_get_var(ftin,
'Sat_Zenith_Angle', sat_zenith_angle)
943 call nc_diag_read_get_var(ftin,
'Sat_Azimuth_Angle', sat_azimuth_angle)
944 call nc_diag_read_get_var(ftin,
'Sol_Zenith_Angle', sol_zenith_angle)
945 call nc_diag_read_get_var(ftin,
'Sol_Azimuth_Angle', sol_azimuth_angle)
946 call nc_diag_read_get_var(ftin,
'Sun_Glint_Angle', sun_glint_angle)
947 call nc_diag_read_get_var(ftin,
'Water_Fraction', water_fraction)
948 call nc_diag_read_get_var(ftin,
'Land_Fraction', land_fraction)
949 call nc_diag_read_get_var(ftin,
'Ice_Fraction', ice_fraction)
950 call nc_diag_read_get_var(ftin,
'Snow_Fraction', snow_fraction)
951 call nc_diag_read_get_var(ftin,
'Water_Temperature', water_temperature)
952 call nc_diag_read_get_var(ftin,
'Land_Temperature', land_temperature)
953 call nc_diag_read_get_var(ftin,
'Ice_Temperature', ice_temperature)
954 call nc_diag_read_get_var(ftin,
'Snow_Temperature', snow_temperature)
955 call nc_diag_read_get_var(ftin,
'Soil_Temperature', soil_temperature)
956 call nc_diag_read_get_var(ftin,
'Soil_Moisture', soil_moisture)
957 call nc_diag_read_get_var(ftin,
'tsavg5', tsavg5)
958 call nc_diag_read_get_var(ftin,
'sstcu', sstcu)
959 call nc_diag_read_get_var(ftin,
'sstph', sstph)
960 call nc_diag_read_get_var(ftin,
'sstnv', sstnv)
961 call nc_diag_read_get_var(ftin,
'dta', dta)
962 call nc_diag_read_get_var(ftin,
'dqa', dqa)
963 call nc_diag_read_get_var(ftin,
'dtp_avh', dtp_avh)
964 call nc_diag_read_get_var(ftin,
'Vegetation_Fraction', vegetation_fraction)
965 call nc_diag_read_get_var(ftin,
'Snow_Depth', snow_depth)
966 call nc_diag_read_get_var(ftin,
'tpwc_amsua', tpwc_amsua)
967 call nc_diag_read_get_var(ftin,
'clw_guess_retrieval', clw_guess_retrieval)
968 call nc_diag_read_get_var(ftin,
'Sfc_Wind_Speed', sfc_wind_speed)
969 call nc_diag_read_get_var(ftin,
'Cloud_Frac', cloud_frac)
970 call nc_diag_read_get_var(ftin,
'CTP', ctp)
971 call nc_diag_read_get_var(ftin,
'CLW', clw)
972 call nc_diag_read_get_var(ftin,
'TPWC', tpwc)
973 call nc_diag_read_get_var(ftin,
'clw_obs', clw_obs)
974 call nc_diag_read_get_var(ftin,
'clw_guess', clw_guess)
975 call nc_diag_read_get_var(ftin,
'Foundation_Temperature', foundation_temperature)
976 call nc_diag_read_get_var(ftin,
'SST_Warm_layer_dt', sst_warm_layer_dt)
977 call nc_diag_read_get_var(ftin,
'SST_Cool_layer_tdrop', sst_cool_layer_tdrop)
978 call nc_diag_read_get_var(ftin,
'SST_dTz_dTfound', sst_dtz_dtfound)
979 call nc_diag_read_get_var(ftin,
'Observation', observation)
980 call nc_diag_read_get_var(ftin,
'Obs_Minus_Forecast_adjusted', obs_minus_forecast_adjusted)
981 call nc_diag_read_get_var(ftin,
'Obs_Minus_Forecast_unadjusted', obs_minus_forecast_unadjusted)
982 call nc_diag_read_get_var(ftin,
'Inverse_Observation_Error', inverse_observation_error)
983 call nc_diag_read_get_var(ftin,
'QC_Flag', qc_flag)
984 call nc_diag_read_get_var(ftin,
'Emissivity', emissivity)
985 call nc_diag_read_get_var(ftin,
'Weighted_Lapse_Rate', weighted_lapse_rate)
986 call nc_diag_read_get_var(ftin,
'dTb_dTs', dtb_dts)
987 call nc_diag_read_get_var(ftin,
'BC_Constant', bc_constant)
988 call nc_diag_read_get_var(ftin,
'BC_Scan_Angle', bc_scan_angle)
989 call nc_diag_read_get_var(ftin,
'BC_Cloud_Liquid_Water', bc_cloud_liquid_water)
990 call nc_diag_read_get_var(ftin,
'BC_Lapse_Rate_Squared', bc_lapse_rate_squared)
991 call nc_diag_read_get_var(ftin,
'BC_Lapse_Rate', bc_lapse_rate)
992 call nc_diag_read_get_var(ftin,
'BC_Cosine_Latitude_times_Node', bc_cosine_latitude_times_node)
993 call nc_diag_read_get_var(ftin,
'BC_Sine_Latitude', bc_sine_latitude)
994 call nc_diag_read_get_var(ftin,
'BC_Emissivity', bc_emissivity)
995 call nc_diag_read_get_var(ftin,
'BC_Fixed_Scan_Position', bc_fixed_scan_position)
996 call nc_diag_read_get_var(ftin,
'Land_Type_Index', land_type_index)
997 if (header_fix%angord > 0)
then 998 call nc_diag_read_get_var(ftin,
'BC_angord ', bc_angord )
1007 clat = latitude(cdatum)
1008 clon = longitude(cdatum)
1009 diag_status%all_data_fix(ir)%lat = latitude(cdatum)
1010 diag_status%all_data_fix(ir)%lon = longitude(cdatum)
1011 diag_status%all_data_fix(ir)%zsges = elevation(cdatum)
1012 diag_status%all_data_fix(ir)%obstime = obs_time(cdatum)
1013 diag_status%all_data_fix(ir)%senscn_pos = scan_position(cdatum)
1014 diag_status%all_data_fix(ir)%senscn_ang = scan_angle(cdatum)
1015 diag_status%all_data_fix(ir)%satzen_ang = sat_zenith_angle(cdatum)
1016 diag_status%all_data_fix(ir)%satazm_ang = sat_azimuth_angle(cdatum)
1017 diag_status%all_data_fix(ir)%solzen_ang = sol_zenith_angle(cdatum)
1018 diag_status%all_data_fix(ir)%solazm_ang = sol_azimuth_angle(cdatum)
1019 diag_status%all_data_fix(ir)%sungln_ang = sun_glint_angle(cdatum)
1020 diag_status%all_data_fix(ir)%water_frac = water_fraction(cdatum)
1021 diag_status%all_data_fix(ir)%land_frac = land_fraction(cdatum)
1022 diag_status%all_data_fix(ir)%ice_frac = ice_fraction(cdatum)
1023 diag_status%all_data_fix(ir)%snow_frac = snow_fraction(cdatum)
1024 diag_status%all_data_fix(ir)%water_temp = water_temperature(cdatum)
1025 diag_status%all_data_fix(ir)%land_temp = land_temperature(cdatum)
1026 diag_status%all_data_fix(ir)%ice_temp = ice_temperature(cdatum)
1027 diag_status%all_data_fix(ir)%snow_temp = snow_temperature(cdatum)
1028 diag_status%all_data_fix(ir)%soil_temp = soil_temperature(cdatum)
1029 diag_status%all_data_fix(ir)%soil_mois = soil_moisture(cdatum)
1030 diag_status%all_data_fix(ir)%land_type = land_type_index(cdatum)
1031 diag_status%all_data_fix(ir)%veg_frac = vegetation_fraction(cdatum)
1032 diag_status%all_data_fix(ir)%snow_depth = snow_depth(cdatum)
1033 diag_status%all_data_fix(ir)%sfc_wndspd = sfc_wind_speed(cdatum)
1034 diag_status%all_data_fix(ir)%qcdiag1 = cloud_frac(cdatum)
1035 diag_status%all_data_fix(ir)%qcdiag2 = ctp(cdatum)
1036 diag_status%all_data_fix(ir)%tref = foundation_temperature(cdatum)
1037 diag_status%all_data_fix(ir)%dtw = sst_warm_layer_dt(cdatum)
1038 diag_status%all_data_fix(ir)%dtc = sst_cool_layer_tdrop(cdatum)
1039 diag_status%all_data_fix(ir)%tz_tr = sst_dtz_dtfound(cdatum)
1042 diag_status%all_data_fix(ir)%water_temp = tsavg5(cdatum)
1043 diag_status%all_data_fix(ir)%land_temp = sstcu(cdatum)
1044 diag_status%all_data_fix(ir)%ice_temp = sstph(cdatum)
1045 diag_status%all_data_fix(ir)%snow_temp = sstnv(cdatum)
1046 diag_status%all_data_fix(ir)%soil_temp = dta(cdatum)
1047 diag_status%all_data_fix(ir)%soil_mois = dqa(cdatum)
1048 diag_status%all_data_fix(ir)%land_type = dtp_avh(cdatum)
1051 do ic=1,header_fix%nchan
1052 if (clat .ne. latitude(cdatum) .or. clon .ne. longitude(cdatum))
then 1053 write(*,*)
'ERROR: Lats & Lons are mismatched. This is bad' 1054 print *,
'irecord=',ir
1055 print *,
'clat,clon=',clat,clon
1056 print *,
'lat/lon(datum)=',latitude(cdatum), longitude(cdatum)
1059 cch = channel_index(cdatum)
1060 if (
allocated(diag_status%all_data_chan(ir,cch)%bifix))
deallocate(diag_status%all_data_chan(ir,cch)%bifix )
1061 if (header_fix%angord > 0)
then 1062 allocate(diag_status%all_data_chan(ir,cch)%bifix(nangord))
1064 allocate(diag_status%all_data_chan(ir,cch)%bifix(1))
1067 diag_status%all_data_chan(ir,cch)%tbobs = observation(cdatum)
1068 diag_status%all_data_chan(ir,cch)%omgbc = obs_minus_forecast_adjusted(cdatum)
1069 diag_status%all_data_chan(ir,cch)%omgnbc= obs_minus_forecast_unadjusted(cdatum)
1070 diag_status%all_data_chan(ir,cch)%errinv= inverse_observation_error(cdatum)
1071 diag_status%all_data_chan(ir,cch)%qcmark= qc_flag(cdatum)
1072 diag_status%all_data_chan(ir,cch)%emiss = emissivity(cdatum)
1073 diag_status%all_data_chan(ir,cch)%tlap = weighted_lapse_rate(cdatum)
1074 diag_status%all_data_chan(ir,cch)%tb_tz = dtb_dts(cdatum)
1075 diag_status%all_data_chan(ir,cch)%bicons= bc_constant(cdatum)
1076 diag_status%all_data_chan(ir,cch)%biang = bc_scan_angle(cdatum)
1077 diag_status%all_data_chan(ir,cch)%biclw = bc_cloud_liquid_water(cdatum)
1078 diag_status%all_data_chan(ir,cch)%bilap2= bc_lapse_rate_squared(cdatum)
1079 diag_status%all_data_chan(ir,cch)%bilap = bc_lapse_rate(cdatum)
1080 diag_status%all_data_chan(ir,cch)%bicos = bc_cosine_latitude_times_node(cdatum)
1081 diag_status%all_data_chan(ir,cch)%bisin = bc_sine_latitude(cdatum)
1082 diag_status%all_data_chan(ir,cch)%biemis= bc_emissivity(cdatum)
1083 if (header_fix%angord > 0)
then 1084 diag_status%all_data_chan(ir,cch)%bifix = bc_angord(1:nangord,cdatum)
1086 diag_status%all_data_chan(ir,cch)%bifix(1) = bc_fixed_scan_position(cdatum)
1093 diag_status%nc_read = .true.
1094 diag_status%cur_ob_idx = 1
1097 subroutine read_radiag_data_nc(ftin,diag_status,header_fix,retrieval,data_fix,data_chan,data_extra,iflag )
1125 integer(i_kind),
intent(in) :: ftin
1126 type(ncdiag_status),
intent(inout) :: diag_status
1127 type(diag_header_fix_list ),
intent(in) :: header_fix
1128 logical,
intent(in) :: retrieval
1129 type(diag_data_fix_list) ,
intent(out):: data_fix
1130 type(diag_data_chan_list) ,
allocatable :: data_chan(:)
1131 type(diag_data_extra_list) ,
allocatable :: data_extra(:,:)
1132 integer(i_kind),
intent(out) :: iflag
1135 if (.not.
allocated(data_chan))
allocate(data_chan(header_fix%nchan) )
1136 if (.not.
allocated(data_extra))
allocate(data_extra(header_fix%iextra, header_fix%nchan) )
1138 data_fix = diag_status%all_data_fix(diag_status%cur_ob_idx)
1139 data_chan(:) = diag_status%all_data_chan(diag_status%cur_ob_idx,:)
1140 data_extra(:,:) = diag_status%all_data_extra(diag_status%cur_ob_idx,:,:)
1142 diag_status%cur_ob_idx = diag_status%cur_ob_idx + 1
1146 subroutine read_radiag_data_bin(ftin,header_fix,retrieval,data_fix,data_chan,data_extra,iflag )
1177 integer(i_kind),
intent(in) :: ftin
1178 type(diag_header_fix_list ),
intent(in) :: header_fix
1179 logical,
intent(in) :: retrieval
1180 type(diag_data_fix_list) ,
intent(out):: data_fix
1181 type(diag_data_chan_list) ,
allocatable :: data_chan(:)
1182 type(diag_data_extra_list) ,
allocatable :: data_extra(:,:)
1183 integer(i_kind),
intent(out) :: iflag
1185 integer(i_kind) :: ich,iang,i,j
1186 real(r_single),
dimension(:,:),
allocatable :: data_tmp
1187 real(r_single),
dimension(:),
allocatable :: fix_tmp
1188 real(r_single),
dimension(:,:),
allocatable :: extra_tmp
1191 if (
allocated(data_chan))
deallocate(data_chan)
1192 allocate(data_chan(header_fix%nchan))
1194 do ich=1,header_fix%nchan
1195 if (
allocated(data_chan(ich)%bifix))
deallocate(data_chan(ich)%bifix)
1196 allocate(data_chan(ich)%bifix(header_fix%angord+1))
1199 if (header_fix%iextra > 0)
then 1200 if (
allocated(data_extra))
deallocate(data_extra)
1201 allocate(data_extra(header_fix%iextra,header_fix%jextra))
1202 allocate(extra_tmp(header_fix%iextra,header_fix%jextra))
1206 allocate(data_tmp(header_fix%idiag,header_fix%nchan))
1216 if (header_fix%iextra == 0)
then 1217 read(ftin,iostat=iflag) fix_tmp, data_tmp
1219 read(ftin,iostat=iflag) fix_tmp, data_tmp, extra_tmp
1222 if (iflag /= 0)
return 1225 data_fix%lat = fix_tmp(1)
1226 data_fix%lon = fix_tmp(2)
1227 data_fix%zsges = fix_tmp(3)
1228 data_fix%obstime = fix_tmp(4)
1229 data_fix%senscn_pos = fix_tmp(5)
1230 data_fix%satzen_ang = fix_tmp(6)
1231 data_fix%satazm_ang = fix_tmp(7)
1232 data_fix%solzen_ang = fix_tmp(8)
1233 data_fix%solazm_ang = fix_tmp(9)
1234 data_fix%sungln_ang = fix_tmp(10)
1235 data_fix%water_frac = fix_tmp(11)
1236 data_fix%land_frac = fix_tmp(12)
1237 data_fix%ice_frac = fix_tmp(13)
1238 data_fix%snow_frac = fix_tmp(14)
1239 data_fix%water_temp = fix_tmp(15)
1240 data_fix%land_temp = fix_tmp(16)
1241 data_fix%ice_temp = fix_tmp(17)
1242 data_fix%snow_temp = fix_tmp(18)
1243 data_fix%soil_temp = fix_tmp(19)
1244 data_fix%soil_mois = fix_tmp(20)
1245 data_fix%land_type = fix_tmp(21)
1246 data_fix%veg_frac = fix_tmp(22)
1247 data_fix%snow_depth = fix_tmp(23)
1248 data_fix%sfc_wndspd = fix_tmp(24)
1249 data_fix%qcdiag1 = fix_tmp(25)
1250 data_fix%qcdiag2 = fix_tmp(26)
1258 data_fix%tref = fix_tmp(27)
1259 data_fix%dtw = fix_tmp(28)
1260 data_fix%dtc = fix_tmp(29)
1261 data_fix%tz_tr = fix_tmp(30)
1266 do ich=1,header_fix%nchan
1267 data_chan(ich)%tbobs =data_tmp(1,ich)
1268 data_chan(ich)%omgbc =data_tmp(2,ich)
1269 data_chan(ich)%omgnbc=data_tmp(3,ich)
1270 data_chan(ich)%errinv=data_tmp(4,ich)
1271 data_chan(ich)%qcmark=data_tmp(5,ich)
1272 data_chan(ich)%emiss =data_tmp(6,ich)
1273 data_chan(ich)%tlap =data_tmp(7,ich)
1274 data_chan(ich)%tb_tz =data_tmp(8,ich)
1277 do ich=1,header_fix%nchan
1278 data_chan(ich)%bifix(1)=data_tmp(8,ich)
1279 data_chan(ich)%bilap =data_tmp(9,ich)
1280 data_chan(ich)%bilap2 =data_tmp(10,ich)
1281 data_chan(ich)%bicons =data_tmp(11,ich)
1282 data_chan(ich)%biang =data_tmp(12,ich)
1283 data_chan(ich)%biclw =data_tmp(13,ich)
1287 data_chan(ich)%bisst =data_tmp(13,ich)
1291 do ich=1,header_fix%nchan
1292 data_chan(ich)%bicons=data_tmp(8,ich)
1293 data_chan(ich)%biang =data_tmp(9,ich)
1294 data_chan(ich)%biclw =data_tmp(10,ich)
1295 data_chan(ich)%bilap2=data_tmp(11,ich)
1296 data_chan(ich)%bilap =data_tmp(12,ich)
1298 do ich=1,header_fix%nchan
1299 do iang=1,header_fix%angord+1
1300 data_chan(ich)%bifix(iang)=data_tmp(12+iang,ich)
1302 data_chan(ich)%bisst = data_tmp(12+header_fix%angord+2,ich)
1305 do ich=1,header_fix%nchan
1306 data_chan(ich)%bicons=data_tmp(9,ich)
1307 data_chan(ich)%biang =data_tmp(10,ich)
1308 data_chan(ich)%biclw =data_tmp(11,ich)
1309 data_chan(ich)%bilap2=data_tmp(12,ich)
1310 data_chan(ich)%bilap =data_tmp(13,ich)
1312 do ich=1,header_fix%nchan
1313 do iang=1,header_fix%angord+1
1314 data_chan(ich)%bifix(iang)=data_tmp(13+iang,ich)
1316 data_chan(ich)%bisst = data_tmp(13+header_fix%angord+2,ich)
1319 do ich=1,header_fix%nchan
1320 data_chan(ich)%bicons=data_tmp(9,ich)
1321 data_chan(ich)%biang =data_tmp(10,ich)
1322 data_chan(ich)%biclw =data_tmp(11,ich)
1323 data_chan(ich)%bilap2=data_tmp(12,ich)
1324 data_chan(ich)%bilap =data_tmp(13,ich)
1325 data_chan(ich)%bicos =data_tmp(14,ich)
1326 data_chan(ich)%bisin =data_tmp(15,ich)
1328 do ich=1,header_fix%nchan
1329 do iang=1,header_fix%angord+1
1330 data_chan(ich)%bifix(iang)=data_tmp(15+iang,ich)
1332 data_chan(ich)%bisst = data_tmp(15+header_fix%angord+2,ich)
1335 do ich=1,header_fix%nchan
1336 data_chan(ich)%bicons=data_tmp(9,ich)
1337 data_chan(ich)%biang =data_tmp(10,ich)
1338 data_chan(ich)%biclw =data_tmp(11,ich)
1339 data_chan(ich)%bilap2=data_tmp(12,ich)
1340 data_chan(ich)%bilap =data_tmp(13,ich)
1341 data_chan(ich)%bicos =data_tmp(14,ich)
1342 data_chan(ich)%bisin =data_tmp(15,ich)
1343 data_chan(ich)%biemis=data_tmp(16,ich)
1345 do ich=1,header_fix%nchan
1346 do iang=1,header_fix%angord+1
1347 data_chan(ich)%bifix(iang)=data_tmp(16+iang,ich)
1349 data_chan(ich)%bisst = data_tmp(16+header_fix%angord+2,ich)
1354 if (header_fix%iextra > 0)
then 1355 do j=1,header_fix%jextra
1356 do i=1,header_fix%iextra
1357 data_extra(i,j)%extra=extra_tmp(i,j)
1362 deallocate(data_tmp, fix_tmp)
1363 if (header_fix%iextra > 0)
deallocate(extra_tmp)
integer(i_kind), parameter iversion_radiag_2
integer(i_kind), save nopen_ncdiag
subroutine, public read_radiag_header(ftin, npred_radiag, retrieval, header_fix, header_chan, data_name, iflag, lverbose)
integer(i_kind), parameter, public ipchan_radiag
integer, parameter, public i_kind
subroutine get_radiag_int_(what, iv, ier)
integer(i_kind) function find_ncdiag_id(ftin)
integer(i_kind), parameter iversion_radiag_3
subroutine read_radiag_data_nc(ftin, diag_status, header_fix, retrieval, data_fix, data_chan, data_extra, iflag)
integer(i_kind), parameter max_open_ncdiag
subroutine, public set_netcdf_read(use_netcdf)
type(ncdiag_status), dimension(max_open_ncdiag), save ncdiag_open_status
integer(i_kind), parameter ireal_old_radiag
subroutine read_radiag_header_bin(ftin, npred_radiag, retrieval, header_fix, header_chan, data_name, iflag, lverbose)
subroutine, public read_radiag_data(ftin, header_fix, retrieval, data_fix, data_chan, data_extra, iflag)
integer(i_kind), dimension(max_open_ncdiag), save ncdiag_open_id
integer(i_kind), parameter iversion_radiag_1
subroutine, public close_radiag(filename, ftin)
subroutine set_radiag_int_(what, iv, ier)
subroutine read_radiag_data_nc_init(ftin, diag_status, header_fix, retrieval)
subroutine read_radiag_header_nc(ftin, npred_radiag, retrieval, header_fix, header_chan, data_name, iflag, lverbose)
real(r_single), parameter rmiss_radiag
integer(i_kind), save iversion_radiag
subroutine read_radiag_data_bin(ftin, header_fix, retrieval, data_fix, data_chan, data_extra, iflag)
integer(i_kind), parameter, public ireal_radiag
subroutine nc_diag_read_close(filename, file_ncdr_id, from_pop)
subroutine, public read_all_radiag(ftin, header_fix, retrieval, all_data_fix, all_data_chan, all_data_extra, nobs, iflag)
integer(i_kind), parameter iversion_radiag_4
subroutine, public open_radiag(filename, ftin)
integer, parameter, public r_single
integer, parameter, public r_kind
subroutine nc_diag_read_init(filename, file_ncdr_id, from_push)