diff --git a/src/gsi/pcgsoi.f90 b/src/gsi/pcgsoi.f90 index c918b37919..0b808c5c55 100644 --- a/src/gsi/pcgsoi.f90 +++ b/src/gsi/pcgsoi.f90 @@ -292,8 +292,7 @@ subroutine pcgsoi() ! Compare obs to solution and transpose back to grid call intall(sval,sbias,rval,rbias) - if (iter==0) then -! if (diag_print) then + if (diag_print) then do ii=1,nobs_bins call prt_state_norms(rval(ii),'rval') enddo diff --git a/src/gsi/read_prepbufr.f90 b/src/gsi/read_prepbufr.f90 index 7d563b6e9b..a1106e2203 100644 --- a/src/gsi/read_prepbufr.f90 +++ b/src/gsi/read_prepbufr.f90 @@ -294,7 +294,7 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& integer(i_kind) ireadmg,ireadsb,iqm,iuse,pmot integer(i_kind) lunin,i,maxobs,j,idomsfc,it29,nmsgmax,mxtb,maxall integer(i_kind) kk,klon1,klat1,klonp1,klatp1 - integer(i_kind) nc,isflg,ntread,itx,ii,ncsave,nxdata,nx + integer(i_kind) nc,isflg,ntread,ii,ncsave,nxdata,nx integer(i_kind) ihh,idd,idate,iret,im,iy,k,levs integer(i_kind) metarcldlevs,metarwthlevs,cldseqlevs,cld2seqlevs integer(i_kind) kx,kx0,nreal,nchanl,ilat,ilon,ithin @@ -318,7 +318,7 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& integer(i_kind),dimension(255):: pqm,qqm,tqm,wqm,pmq integer(i_kind),dimension(nconvtype)::ntxall integer(i_kind),dimension(nconvtype+1)::ntx - integer(i_kind),allocatable,dimension(:):: nrep,iloc + integer(i_kind),allocatable,dimension(:):: nrep integer(i_kind),allocatable,dimension(:,:):: tab integer(i_kind) ibfms,thisobtype_usage integer(i_kind) iwmo,ios @@ -384,7 +384,6 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& integer(i_kind) ntime_max,ntime_tmp,itype,ikx,numall ! integer(i_kind) numthin,numqc,numrem integer(i_kind),dimension(24) :: ntype_arr - integer,allocatable,dimension(:) :: nlevs integer(i_kind),allocatable,dimension(:,:) :: index_arr real(r_kind),allocatable,dimension(:,:,:) :: data_hilb real(r_kind),allocatable,dimension(:) :: rlat_hil,rlon_hil,height,wtob,wght_hilb @@ -890,9 +889,7 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& ! loop over convinfo file entries; operate on matches - allocate(cdata_all(nreal,maxall),rusage(maxall),rthin(maxall),iloc(mxtb),nlevs(mxtb)) - iloc=0 - nlevs=0 + allocate(cdata_all(nreal,maxall),rusage(maxall),rthin(maxall)) nread=0 ntest=0 nvtest=0 @@ -2989,8 +2986,6 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& ! ! End k loop over levs - if(nlevs(ntb) == 0)iloc(ntb)=iout - nlevs(ntb)=nlevs(ntb)+1 end do LOOP_K_LEVS end do loop_readsb @@ -3019,7 +3014,6 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& nxdata=ndata ndata=0 - allocate(cdata_out(nreal,nxdata)) if(nxdata > 0)then ! numthin=0 ! numqc=0 @@ -3036,29 +3030,26 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& ! write(6,*) ' prep ',trim(ioctype(nc)),ictype(nc),icsubtype(nc),numall,numrem,numqc,numthin ! If thinned data set quality mark to 14 ! If flag to not save thinned data is set - compress data - do i=1,mxtb + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - do j=1,nlevs(i) - itx=iloc(i)+j-1 - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. (rusage(itx) .and. .not. rthin(itx))) .or. & - (pmot == 3 .and. rusage(itx))) then - - if(rthin(itx) .and. iqm > 0)cdata_all(iqm,itx)=14 - if(.not. rusage(itx))cdata_all(iuse,itx) = max(cdata_all(iuse,itx),101.0_r_kind) - ndata=ndata+1 - do k=1,nreal - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. (rusage(i) .and. .not. rthin(i))) .or. & + (pmot == 3 .and. rusage(i))) then + + if(rthin(i) .and. iqm > 0)cdata_all(iqm,i)=14 + if(.not. rusage(i))cdata_all(iuse,i) = max(cdata_all(iuse,i),101.0_r_kind) + ndata=ndata+1 + if(i > ndata)then + do k=1,nreal + cdata_all(k,ndata)=cdata_all(k,i) + end do end if - end do + end if end do if(uvob)then nodata=nodata+2*ndata @@ -3066,12 +3057,12 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& nodata=nodata+ndata end if end if - deallocate(cdata_all,rusage,rthin,iloc,nlevs) + deallocate(rusage,rthin) ! Apply hilbert curve for cross validation if requested if(lhilbert) & - call apply_hilbertcurve(maxobs,obstype,cdata_out(thisobtype_usage,1:ndata)) + call apply_hilbertcurve(maxobs,obstype,cdata_all(thisobtype_usage,1:ndata)) ! the following is gettin the types which will be applied hilbert curve to ! estimate the density @@ -3164,25 +3155,25 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& index_arr=0 do k=1,ndata - ikx=nint(cdata_out(10,k)) + ikx=nint(cdata_all(10,k)) if (ikx>0) then itype=ictype(ikx) else itype=0 endif if( itype ==230 .or. itype ==231 .or. itype ==233) then - prest=r10*exp(cdata_out(4,k)) + prest=r10*exp(cdata_all(4,k)) if (prest <100.0_r_kind) cycle if(ithin_conv(ikx) >=5) then if(ptime_conv(ikx) >zero) then - ntime=int(((cdata_out(9,k)-time_offset)+three)/ptime_conv(ikx))+1 + ntime=int(((cdata_all(9,k)-time_offset)+three)/ptime_conv(ikx))+1 endif if(ntime >ntime_max) ntime=ntime_max if(ntime <0) ntime=1 ntype_arr(ntime)=ntype_arr(ntime)+1 ndata_hil=ntype_arr(ntime) - data_hilb(1,ndata_hil,ntime)=cdata_out(20,k) - data_hilb(2,ndata_hil,ntime)=cdata_out(19,k) + data_hilb(1,ndata_hil,ntime)=cdata_all(20,k) + data_hilb(2,ndata_hil,ntime)=cdata_all(19,k) prest=prest*100.0_r_kind if(prest >stndrd_atmos_ps) then prest=zero @@ -3200,7 +3191,7 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& write(6,*),'READ_PREPBUFR :something is wrong,lat,lon,prest=',& data_hilb(1,ndata_hil,ntime),& data_hilb(2,ndata_hil,ntime),& - cdata_out(4,k),data_hilb(3,ndata_hil,ntime) + cdata_all(4,k),data_hilb(3,ndata_hil,ntime) endif endif endif @@ -3227,7 +3218,7 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& endif do i=1,ndata - cdata_out(26,i)=wght_hilb(i) + cdata_all(26,i)=wght_hilb(i) enddo deallocate(wght_hilb) @@ -3242,24 +3233,24 @@ subroutine read_prepbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& if(metarcldobs .and. ndata > 0) then if(i_ens_mean /= 1) then maxobs=2000000 - allocate(cdata_all(nreal,maxobs)) - call reorg_metar_cloud(cdata_out,nreal,ndata,cdata_all,maxobs,iout) + allocate(cdata_out(nreal,maxobs)) + call reorg_metar_cloud(cdata_all,nreal,ndata,cdata_out,maxobs,iout) ndata=iout - deallocate(cdata_out) - allocate(cdata_out(nreal,ndata)) + deallocate(cdata_all) + allocate(cdata_all(nreal,ndata)) do i=1,nreal do j=1,ndata - cdata_out(i,j)=cdata_all(i,j) + cdata_all(i,j)=cdata_out(i,j) end do end do - deallocate(cdata_all) + deallocate(cdata_out) endif endif - call count_obs(ndata,nreal,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,nreal,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon,ndata - write(lunout) ((cdata_out(k,i),k=1,nreal),i=1,ndata) + write(lunout) ((cdata_all(k,i),k=1,nreal),i=1,ndata) - deallocate(cdata_out) + deallocate(cdata_all) call destroy_rjlists call destroy_aircraft_rjlists if(i_gsdsfc_uselist==1) call destroy_gsd_sfcuselist diff --git a/src/gsi/read_radar.f90 b/src/gsi/read_radar.f90 index 43a5c4830e..2743cdeabe 100644 --- a/src/gsi/read_radar.f90 +++ b/src/gsi/read_radar.f90 @@ -154,7 +154,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu character(30) outmessage character(255) filename - integer(i_kind) lnbufr,i,j,k,maxobs,icntpnt,n,istop + integer(i_kind) lnbufr,i,j,k,maxobs,n,istop integer(i_kind) nmrecs,ibadazm,ibadtilt,ibadrange,ibadwnd,ibaddist,ibadheight,ibadvad,kthin integer(i_kind) iyr,imo,idy,ihr,imn,isc,ithin integer(i_kind) ibadstaheight,ibaderror,notgood,idate,iheightbelowsta,ibadfit @@ -222,7 +222,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu real(r_kind),dimension(maxdat):: cdata - real(r_kind),allocatable,dimension(:,:):: cdata_all,cdata_out + real(r_kind),allocatable,dimension(:,:):: cdata_all real(r_double) rstation_id real(r_double),dimension(12):: hdr @@ -285,8 +285,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu real(r_kind) dx,dy,dx1,dy1,w00,w10,w01,w11 logical luse integer(i_kind) iout - integer(i_kind):: zflag,itx - integer(i_kind),allocatable,dimension(:) :: iloc + integer(i_kind):: zflag integer(i_kind) nlevz ! vertical level for thinning real(r_kind) crit1,timedif real(r_kind),allocatable,dimension(:):: zl_thin @@ -321,7 +320,6 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu !*********************************************************************************** print_verbose=.false. if(verbose)print_verbose=.true. - icntpnt=0 ! Check to see if radar wind files exist. If none exist, exit this routine. inquire(file='radar_supobs_from_level2',exist=lexist1) @@ -362,9 +360,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu hdrstr(2)='PTID YEAR MNTH DAYS HOUR MINU SECO CLAT CLON FLVLST ANAZ ANEL' end if - allocate(cdata_all(maxdat,maxobs),rusage(maxobs),rthin(maxobs),iloc(maxobs)) + allocate(cdata_all(maxdat,maxobs),rusage(maxobs),rthin(maxobs)) - iloc=0 rusage=.true. rthin=.false. @@ -858,10 +855,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu nsuper2_kept=nsuper2_kept+1 level2(ivad)=level2(ivad)+1 nobs_box(irrr,iaaa,ivadz,ivad)=nobs_box(irrr,iaaa,ivadz,ivad)+1 - icntpnt=icntpnt+1 ndata =min(ndata+1,maxobs) nodata =min(nodata+1,maxobs) - iloc(icntpnt) = ndata usage = zero if(icuse(ikx) < 0)usage=r100 if(ncnumgrp(ikx) > 0 )then ! cross validation on @@ -872,6 +867,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) LEVEL_TWO_READ: if(loop==0 .and. sis=='l2rw') then + write(6,*) ' radar1 ',height cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -1295,10 +1291,8 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu level3(ivad)=level3(ivad)+1 end if nobs_box(irrr,iaaa,ivadz,ivad)=nobs_box(irrr,iaaa,ivadz,ivad)+1 - icntpnt=icntpnt+1 ndata = min(ndata+1,maxobs) nodata = min(nodata+1,maxobs) - iloc(icntpnt) = ndata usage = zero if(icuse(ikx) < 0)usage=r100 if(ncnumgrp(ikx) > 0 )then ! cross validation on @@ -1308,6 +1302,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) + write(6,*) ' radar2 ',height cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -1984,16 +1979,15 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu write(6,'(1x,A128)')' *** *** WARNING --> INCREASE maxobs in READ_RADAR beyond 2,000,000, & re-compile GSI, re-run !!! <-- WARNING*** ***' end if - icntpnt=icntpnt+1 ndata = min(ndata+1,maxobs) nodata = min(nodata+1,maxobs) - iloc(icntpnt)=ndata usage = zero if(icuse(ikx) < 0)usage=r100 if(pmot >=2 .and. usage >= 100._r_kind) rusage(ndata)=.false. call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) + write(6,*) ' radar3 ',height cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -2423,8 +2417,6 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ntdrvr_kept=ntdrvr_kept+1 !#################### Data thinning ################### - icntpnt=icntpnt+1 - if(ithin > 0)then if(zflag == 0)then klon1= int(dlon); klat1= int(dlat) @@ -2476,8 +2468,6 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ndata =ndata+1 endif iout=ndata - icntpnt=icntpnt+1 - iloc(icntpnt)=iout if(ndata > maxobs) then write(6,*)'READ_PREPBUFR: ***WARNING*** ndata > maxobs for ',obstype @@ -2499,6 +2489,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call deter_sfc2(dlat_earth,dlon_earth,t4dv,idomsfc,skint,ff10,sfcr) + write(6,*) ' radar4 ',height cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude @@ -2941,8 +2932,7 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ntdrvr_kept=ntdrvr_kept+1 !#################### Data thinning ################### - icntpnt=icntpnt+1 - if(icntpnt>maxobs) exit + if(ndata>maxobs) exit if(ithin > 0)then if(zflag == 0)then @@ -3000,8 +2990,6 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ndata =ndata+1 endif iout=ndata - icntpnt=icntpnt+1 - iloc(icntpnt)=iout if(ndata > maxobs) then write(6,*)'READ_PREPBUFR: ***WARNING*** ndata > maxobs for ',obstype @@ -3079,7 +3067,6 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu call del3grids endif - allocate(cdata_out(maxdat,ndata)) nxdata=ndata ndata=0 @@ -3100,31 +3087,28 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu ! numrem,numqc,numthin,pmot ! If flag to not save thinned data is set - compress data - do i=1,icntpnt + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - itx=iloc(i) - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. (rusage(itx) .and. .not. rthin(itx))) .or. & - (pmot == 3 .and. rusage(itx))) then - - if(rthin(itx))cdata_all(12,itx)=101._r_kind - ndata=ndata+1 - do k=1,maxdat - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. (rusage(i) .and. .not. rthin(i))) .or. & + (pmot == 3 .and. rusage(i))) then + + if(rthin(i))cdata_all(12,i)=101._r_kind + ndata=ndata+1 + do k=1,maxdat + cdata_all(k,ndata)=cdata_all(k,i) + end do + end if end do end if nodata=nodata+ndata - deallocate(cdata_all,rusage,rthin) + deallocate(rusage,rthin) write(6,*)'READ_RADAR: # records saved in radar1 = ', ndata write(6,*)'READ_RADAR: # records(beams) read in nmrecs=', nmrecs @@ -3159,10 +3143,10 @@ subroutine read_radar(nread,ndata,nodata,infile,lunout,obstype,twind,sis,hgtl_fu write(6,*)'READ_RADAR: iimax =',iimax ! Write observation to scratch file - call count_obs(ndata,maxdat,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,maxdat,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon - write(lunout) ((cdata_out(k,i),k=1,maxdat),i=1,ndata) - deallocate(cdata_out) + write(lunout) ((cdata_all(k,i),k=1,maxdat),i=1,ndata) + deallocate(cdata_all) return @@ -4152,8 +4136,7 @@ subroutine read_radar_l2rw(ndata,nodata,lunout,obstype,sis,nobs,hgtl_full) azm=azm_earth end if !#################### Data thinning ################### - icntpnt=icntpnt+1 - if(icntpnt>maxobs) exit + if(ndata>maxobs) exit ithin=1 !number of obs to keep per grid box if(radar_no_thinning) then ithin=-1 @@ -4257,6 +4240,7 @@ subroutine read_radar_l2rw(ndata,nodata,lunout,obstype,sis,nobs,hgtl_full) end if nsuper2_kept=nsuper2_kept+1 + write(6,*) ' radar7 ',height cdata(1) = error ! wind obs error (m/s) cdata(2) = dlon ! grid relative longitude cdata(3) = dlat ! grid relative latitude diff --git a/src/gsi/read_rapidscat.f90 b/src/gsi/read_rapidscat.f90 index fa8a72820b..25fede6e50 100644 --- a/src/gsi/read_rapidscat.f90 +++ b/src/gsi/read_rapidscat.f90 @@ -107,13 +107,12 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, integer(i_kind) ireadmg,ireadsb,iuse,mxtb,nmsgmax integer(i_kind) i,maxobs,idomsfc,nsattype - integer(i_kind) nc,nx,isflg,itx,nchanl + integer(i_kind) nc,nx,isflg,nchanl integer(i_kind) ntb,ntmatch,ncx,ncsave,ntread integer(i_kind) kk,klon1,klat1,klonp1,klatp1 integer(i_kind) nmind,lunin,idate,ilat,ilon,iret,k integer(i_kind) nreal,ithin,iout,icount,ii integer(i_kind) itype,iosub,ixsub,isubsub,iobsub - integer(i_kind) lim_qm integer(i_kind) nlevp ! vertical level for thinning integer(i_kind) pflag integer(i_kind) ntest,nvtest @@ -127,7 +126,7 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, integer(i_kind),dimension(nconvtype+1) :: ntx integer(i_kind),dimension(5):: idate5 - integer(i_kind),allocatable,dimension(:):: nrep,iloc + integer(i_kind),allocatable,dimension(:):: nrep integer(i_kind),allocatable,dimension(:,:)::tab integer(i_kind) ietabl,itypex,lcount,iflag,m @@ -155,7 +154,7 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, real(r_double),dimension(3,4):: wnddat real(r_double),dimension(1,1):: r_prvstg,r_sprvstg real(r_kind),allocatable,dimension(:):: presl_thin - real(r_kind),allocatable,dimension(:,:):: cdata_all,cdata_out + real(r_kind),allocatable,dimension(:,:):: cdata_all logical,allocatable,dimension(:)::rthin,rusage logical save_all @@ -217,11 +216,6 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, werrmin=one nsattype=0 nreal=23 - if (noiqc) then - lim_qm=8 - else - lim_qm=4 - endif ! ** read convtype from convinfo file ! ** only read in rapidsat 296 for now ** @@ -342,8 +336,7 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, enddo msg_report ! Loop over convinfo file entries; operate on matches - allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs),iloc(maxobs)) - iloc=0 + allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs)) nread=0 ntest=0 nvtest=0 @@ -626,7 +619,6 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, ndata=ndata+1 endif iout=ndata - iloc(ntb)=iout woe=obserr oelev=r10 @@ -686,7 +678,6 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, ! Write header record and data to output file for further processing deallocate(etabl) - allocate(cdata_out(nreal,ndata)) nxdata=ndata ndata=0 if(nxdata > 0)then @@ -711,34 +702,31 @@ subroutine read_rapidscat(nread,ndata,nodata,infile,obstype,lunout,gstime,twind, end if end do ! If flag to not save thinned data is set - compress data - do i=1,maxobs + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - itx=iloc(i) - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. (rusage(itx) .and. .not. rthin(itx))) .or. & - (pmot == 3 .and. rusage(itx))) then - - ndata=ndata+1 - do k=1,nreal - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. (rusage(i) .and. .not. rthin(i))) .or. & + (pmot == 3 .and. rusage(i))) then + + ndata=ndata+1 + do k=1,nreal + cdata_all(k,ndata)=cdata_all(k,i) + end do end if end do end if nodata=nodata+ndata - deallocate(cdata_all,rusage,rthin) + deallocate(rusage,rthin) - call count_obs(ndata,nreal,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,nreal,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon - write(lunout) ((cdata_out(k,i),k=1,nreal),i=1,ndata) + write(lunout) ((cdata_all(k,i),k=1,nreal),i=1,ndata) - deallocate(cdata_out) + deallocate(cdata_all) if(diagnostic_reg .and. ntest>0) write(6,*)'READ_RAPIDSCAT: ',& 'ntest,disterrmax=',ntest,disterrmax diff --git a/src/gsi/read_satwnd.f90 b/src/gsi/read_satwnd.f90 index 4db89b822f..24797a88e3 100644 --- a/src/gsi/read_satwnd.f90 +++ b/src/gsi/read_satwnd.f90 @@ -174,7 +174,7 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis integer(i_kind) mxtb,nmsgmax,qcret integer(i_kind) ireadmg,ireadsb,iuse integer(i_kind) i,maxobs,idomsfc,nsattype,ncount - integer(i_kind) nc,nx,isflg,itx,j,nchanl + integer(i_kind) nc,nx,isflg,j,nchanl integer(i_kind) ntb,ntmatch,ncx,ncsave,ntread integer(i_kind) kk,klon1,klat1,klonp1,klatp1 integer(i_kind) nmind,lunin,idate,ilat,ilon,iret,k @@ -191,7 +191,7 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis integer(i_kind),dimension(nconvtype+1) :: ntx integer(i_kind),dimension(5):: idate5 - integer(i_kind),allocatable,dimension(:):: nrep,istab,iloc + integer(i_kind),allocatable,dimension(:):: nrep,istab integer(i_kind),allocatable,dimension(:,:):: tab integer(i_kind) :: icnt(1000) @@ -220,7 +220,7 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis real(r_double),dimension(3,12) :: qcdat real(r_double),dimension(1,1):: r_prvstg,r_sprvstg real(r_kind),allocatable,dimension(:):: presl_thin - real(r_kind),allocatable,dimension(:,:):: cdata_all,cdata_out + real(r_kind),allocatable,dimension(:,:):: cdata_all logical,allocatable,dimension(:)::rthin,rusage logical save_all @@ -661,10 +661,9 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis nchanl=0 ilon=2 ilat=3 - allocate(cdata_all(nreal,maxobs),rthin(maxobs),rusage(maxobs),iloc(maxobs)) + allocate(cdata_all(nreal,maxobs),rthin(maxobs),rusage(maxobs)) rusage = .true. rthin = .false. - iloc = 0 loop_convinfo: do nx=1,ntread @@ -1594,7 +1593,6 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis ndata=ndata+1 endif iout=ndata - iloc(ntb)=iout iuse=icuse(nc) if(iuse < 0)qm = 9 if(qm > 7 .or. iuse < 0 )rusage(iout)=.false. @@ -1686,40 +1684,36 @@ subroutine read_satwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis if(.not. rusage(i))cdata_all(14,i) = 100.0_r_kind end do nxdata=ndata - allocate(cdata_out(nreal,nxdata)) ! If flag to not save thinned data is set - compress data ndata=0 - do i=1,maxobs + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - itx=iloc(i) - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. rusage(itx) .and. .not. rthin(itx)) .or. & - (pmot == 3 .and. rusage(itx))) then - - ndata=ndata+1 - do k=1,nreal - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. rusage(i) .and. .not. rthin(i)) .or. & + (pmot == 3 .and. rusage(i))) then + + ndata=ndata+1 + do k=1,nreal + cdata_all(k,ndata)=cdata_all(k,i) + end do end if end do nodata=nodata+2*ndata end if - deallocate(cdata_all,rusage,rthin,iloc) + deallocate(rusage,rthin) ! Write header record and data to output file for further processing - call count_obs(ndata,nreal,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,nreal,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon - write(lunout) ((cdata_out(k,i),k=1,nreal),i=1,ndata) + write(lunout) ((cdata_all(k,i),k=1,nreal),i=1,ndata) - deallocate(cdata_out) + deallocate(cdata_all) if(diagnostic_reg)then if(ntest>0) write(6,*)'READ_SATWND: ',& diff --git a/src/gsi/read_sfcwnd.f90 b/src/gsi/read_sfcwnd.f90 index 13fe966424..bad5e2af64 100644 --- a/src/gsi/read_sfcwnd.f90 +++ b/src/gsi/read_sfcwnd.f90 @@ -97,7 +97,7 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis integer(i_kind) ireadmg,ireadsb,iuse,mxtb,nmsgmax integer(i_kind) i,maxobs,idomsfc,nsattype,j,ncount - integer(i_kind) nc,nx,isflg,itx,nchanl + integer(i_kind) nc,nx,isflg,nchanl integer(i_kind) ntb,ntmatch,ncx,ncsave,ntread integer(i_kind) kk,klon1,klat1,klonp1,klatp1 integer(i_kind) nmind,lunin,idate,ilat,ilon,iret,k @@ -116,7 +116,7 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis integer(i_kind),dimension(nconvtype+1) :: ntx integer(i_kind),dimension(5):: idate5 - integer(i_kind),allocatable,dimension(:):: nrep,iloc + integer(i_kind),allocatable,dimension(:):: nrep integer(i_kind),allocatable,dimension(:,:)::tab ! integer(i_kind) itypex,lcount,iflag,m @@ -142,7 +142,7 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis real(r_double),dimension(5,4):: wnddat real(r_double),dimension(1,1):: r_prvstg,r_sprvstg real(r_kind),allocatable,dimension(:):: presl_thin - real(r_kind),allocatable,dimension(:,:):: cdata_all,cdata_out + real(r_kind),allocatable,dimension(:,:):: cdata_all logical,allocatable,dimension(:)::rthin,rusage logical save_all @@ -328,8 +328,7 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis ! Loop over convinfo file entries; operate on matches - allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs),iloc(maxobs)) - iloc=0 + allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs)) nread=0 ntest=0 nvtest=0 @@ -673,7 +672,6 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis ndata=ndata+1 endif iout=ndata - iloc(ntb)=iout woe=obserr oelev=r10 @@ -734,7 +732,6 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis enddo loop_convinfo! loops over convinfo entry matches call closbf(lunin) deallocate(lmsg,nrep,tab) - allocate(cdata_out(nreal,ndata)) nxdata=ndata ndata=0 @@ -760,24 +757,21 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis end if end do ! If flag to not save thinned data is set - compress data - do i=1,maxobs + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - itx=iloc(i) - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. (rusage(itx) .and. .not. rthin(itx))) .or. & - (pmot == 3 .and. rusage(itx))) then - - ndata=ndata+1 - if(i > ndata)then - do k=1,nreal - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. (rusage(i) .and. .not. rthin(i))) .or. & + (pmot == 3 .and. rusage(i))) then + + ndata=ndata+1 + if(i > ndata)then + do k=1,nreal + cdata_all(k,ndata)=cdata_all(k,i) + end do end if end if end do @@ -789,11 +783,11 @@ subroutine read_sfcwnd(nread,ndata,nodata,infile,obstype,lunout,gstime,twind,sis ! deallocate(etabl) close(lunin) - call count_obs(ndata,nreal,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,nreal,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon - write(lunout) ((cdata_out(k,i),k=1,nreal),i=1,ndata) + write(lunout) ((cdata_all(k,i),k=1,nreal),i=1,ndata) - deallocate(cdata_out) + deallocate(cdata_all) if(diagnostic_reg .and. ntest>0) write(6,*)'READ_SFCWND: ',& 'ntest,disterrmax=',ntest,disterrmax diff --git a/src/gsi/read_wcpbufr.f90 b/src/gsi/read_wcpbufr.f90 index 5a067ec1d8..99cbfe1c2e 100644 --- a/src/gsi/read_wcpbufr.f90 +++ b/src/gsi/read_wcpbufr.f90 @@ -88,7 +88,7 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& integer(i_kind) ireadmg,ireadsb,icntpnt,icntpnt2 integer(i_kind) lunin,i,maxobs,nmsgmax,mxtb integer(i_kind) kk,klon1,klat1,klonp1,klatp1 - integer(i_kind) nc,nx,ntread,itx,ii,ncsave + integer(i_kind) nc,nx,ntread,ii,ncsave integer(i_kind) ihh,idd,idate,iret,im,iy,k,levs integer(i_kind) kx,nreal,nchanl,ilat,ilon,ithin integer(i_kind) qm, swcpq, lwcpq @@ -105,7 +105,7 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& integer(i_kind),dimension(255):: pqm integer(i_kind),dimension(nconvtype)::ntxall integer(i_kind),dimension(nconvtype+1)::ntx - integer(i_kind),allocatable,dimension(:):: nrep,iloc + integer(i_kind),allocatable,dimension(:):: nrep integer(i_kind),allocatable,dimension(:,:):: tab real(r_kind) time,timex,timeobs,toff,t4dv,zeps real(r_kind) rmesh,ediff,usage @@ -125,7 +125,7 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& real(r_kind),dimension(nsig-1):: dpres real(r_kind),dimension(255)::plevs real(r_kind),allocatable,dimension(:):: presl_thin - real(r_kind),allocatable,dimension(:,:):: cdata_all,cdata_out + real(r_kind),allocatable,dimension(:,:):: cdata_all logical,allocatable,dimension(:)::rthin,rusage logical save_all integer(i_kind) numthin,numqc,numrem @@ -299,8 +299,7 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& ! loop over convinfo file entries; operate on matches - allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs),iloc(maxobs)) - iloc=0 + allocate(cdata_all(nreal,maxobs),rusage(maxobs),rthin(maxobs)) nread=0 ntest=0 nvtest=0 @@ -601,7 +600,6 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& ndata=ndata+1 endif iout=ndata - iloc(ntb)=iout if(ndata > maxobs) then write(6,*)'READ_WCPBUFR: ***WARNING*** ndata > maxobs for ',obstype @@ -689,8 +687,6 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& close(lunin) deallocate(lmsg,tab,nrep) - allocate(cdata_out(nreal,ndata)) - nxdata=ndata nodata=0 if(nxdata > 0)then @@ -712,37 +708,34 @@ subroutine read_wcpbufr(nread,ndata,nodata,infile,obstype,lunout,twindin,sis,& if(rthin(i))cdata_all(11,i)=100._r_kind end do ! If flag to not save thinned data is set - compress data - do i=1,maxobs + do i=1,nxdata ! pmot=0 - all obs - thin obs ! pmot=1 - all obs ! pmot=2 - use obs ! pmot=3 - use obs + thin obs - itx=iloc(i) - if(itx > 0)then - if((pmot == 0 .and. .not. rthin(itx)) .or. & - (pmot == 1) .or. & - (pmot == 2 .and. (rusage(itx) .and. .not. rthin(itx))) .or. & - (pmot == 3 .and. rusage(itx))) then - - ndata=ndata+1 - do k=1,nreal - cdata_out(k,ndata)=cdata_all(k,itx) - end do - end if + if((pmot == 0 .and. .not. rthin(i)) .or. & + (pmot == 1) .or. & + (pmot == 2 .and. (rusage(i) .and. .not. rthin(i))) .or. & + (pmot == 3 .and. rusage(i))) then + + ndata=ndata+1 + do k=1,nreal + cdata_all(k,ndata)=cdata_all(k,i) + end do end if end do nodata=nodata+ndata end if - deallocate(cdata_all,rusage,rthin) + deallocate(rusage,rthin) ! Write header record and data to output file for further processing - call count_obs(ndata,nreal,ilat,ilon,cdata_out,nobs) + call count_obs(ndata,nreal,ilat,ilon,cdata_all,nobs) write(lunout) obstype,sis,nreal,nchanl,ilat,ilon,ndata - write(lunout) ((cdata_out(k,i),k=1,nreal),i=1,ndata) + write(lunout) ((cdata_all(k,i),k=1,nreal),i=1,ndata) - deallocate(cdata_out) + deallocate(cdata_all) if(diagnostic_reg .and. ntest>0) write(6,*)'READ_WCPBUFR: ',& 'ntest,disterrmax=',ntest,disterrmax