Skip to content

Commit

Permalink
PM converter bug fix, if station ID is not read by Z8 format, assign …
Browse files Browse the repository at this point in the history
…a new ID 9999999 (#53)

* PM converter bug fix, if station ID is not read by Z8 format, assign a new ID 9999999.

* PM converter bug fix, if station ID is not read by Z8 format, assign a new ID 99999999

---------

Co-authored-by: Ruifang.Li <[email protected]>
  • Loading branch information
Ruifang-Li and Ruifang.Li authored Nov 30, 2023
1 parent 23e60b4 commit fb121e8
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pm/process_pm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ program pmbufr
integer, parameter :: mxmn=35, mxlv=255, maxcnt=5000, pm_limit=-15
integer :: ireadmg,ireadsb,idate,nmsg,ntb,nsubset,nlvl
integer :: i,j,k,NARG,iret_hdr,iret_ob,interval
integer :: dhr,iret_hdr1,iret_ob1,cnt
integer :: dhr,iret_hdr1,iret_ob1,cnt,ios
integer :: unit_table,unit_out,unit_site,unit_var,nt,pm_len

integer(8) :: z_sid
character(80):: hdstr='SID XOB YOB DHR TYP T29 SQN PROCN RPT CAT TYPO TSIG'
character(80):: obstr='TPHR QCIND COPOPM'
character(8) :: subset,c_sid
character(8) :: subset,c_sid,c_sid_org
character(10):: analysis_time
character(20):: str,infile,outfile
character(20),allocatable,dimension(:)::sta_id, lat_str, lon_str, elv_str, pm_aqi_str, pm_measured_str, pm_str
Expand Down Expand Up @@ -100,6 +100,14 @@ program pmbufr

str=adjustl(sta_id(j))
c_sid=str(2:9)
c_sid_org=c_sid
read(c_sid,'(z8)',iostat=ios) z_sid
if (ios/=0) then
c_sid="99999999"
read(c_sid,'(z8)',iostat=ios) z_sid
if (ios/=0) write (*,'(a,2a15)') 'wrong station_id ', c_sid_org,c_sid
end if

hdr(1)=rstation_id; hdr(2)=lon; hdr(3)=lat; hdr(4)=0.0_8; hdr(5)=102; hdr(10)=6 ! Single level report


Expand All @@ -109,15 +117,15 @@ program pmbufr
if (pm > 0.0) then
obs(2,nlvl)=0.0_8
obs(3,nlvl)=pm*1e-9_8 ! "UG/M3" to KG/M3
write(*,'(a25,i7,a12,3f10.2,f15.12)') 'goodObs: pm>0',j,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
write(*,'(a25,i7,3x,2a14,3f10.2,f15.12)') 'goodObs: pm>0',j,c_sid_org,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
else if (pm > pm_limit) then
obs(2,nlvl)=0.0_8
obs(3,nlvl)=0.0_8
write(*,'(a25,i7,a12,3f10.2,f15.12)') 'limitObs: -15<pm<0',j,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
write(*,'(a25,i7,3x,2a14,3f10.2,f15.12)') 'limitObs: -15<pm<0',j,c_sid_org,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
else
obs(2,nlvl)=bmiss
obs(3,nlvl)=bmiss
write(*,'(a25,i7,a12,3f10.2,f15.12)') 'badObs: pm<-15',j,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
write(*,'(a25,i7,3x,2a14,3f10.2,f15.12)') 'badObs: pm<-15',j,c_sid_org,c_sid,lat,lon,obs(2,nlvl),obs(3,nlvl)
endif

! only encode hdr and obs, no err and qc since these are not defined in pm.bufrtable
Expand Down

0 comments on commit fb121e8

Please sign in to comment.