Skip to content

Commit

Permalink
cleaned up and bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
KristenBathmann committed Oct 15, 2021
1 parent 53f781a commit 33e46e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/gsi/correlated_obsmod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ subroutine set_(instrument,fname,mask,method,kreq,kmut,ErrorCov)
if (iuse_rad(ii)>0) then
coun=coun+1
endif
nctotf=nctotf+1
endif
nctotf=nctotf+1
enddo
! if no data available, turn off Correlated Error
if (coun==0) then
Expand Down Expand Up @@ -462,7 +462,6 @@ subroutine set_(instrument,fname,mask,method,kreq,kmut,ErrorCov)
do ii=1,ErrorCov%nch_active
indR=0
do jj=couns,nch_active
! if (indxR(jj)==ErrorCov%indxR(ii)) then
if (indxR(jj)==indxRf(ii)) then
indR=jj
couns=jj+1
Expand All @@ -484,7 +483,6 @@ subroutine set_(instrument,fname,mask,method,kreq,kmut,ErrorCov)
do ii=1,nch_active
indR=0
do jj=couns,ErrorCov%nch_active
! if (ErrorCov%indxR(jj)==indxR(ii)) then
if (indxRf(jj)==indxR(ii)) then
indR=jj
couns=jj+1
Expand Down
12 changes: 2 additions & 10 deletions util/Correlated_Obs/cov_calc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,12 @@ program cov_calc
deallocate(Rcovbig,divbig,ges_avebig1,ges_avebig2)
deallocate(n_pair_hl, obs_pairs_hl)
end if
reclen=kind(Rcov(1,1))
open(22,file='Rcov_iasicland',form='unformatted')
read(22) nch_active, nctot, reclen
read(22) indR
read(22) Rcov
close(22)
!output
reclen=kind(Rcov(1,1))
open(26,file=trim(cov_file),form='unformatted')
write(26) nch_active, nctot, reclen
write(26) indRf
write(26) Rcov
write(26) indRf(1:nch_active)
write(26) Rcov(1:nch_active,1:nch_active)
close(26)

if (out_wave) then
Expand All @@ -361,8 +355,6 @@ program cov_calc
write(25,rec=1) Rcorr
close(25)
end if
!KAB
print *, indRf
deallocate(Rcov,chaninfo,errout)
deallocate(indR,indRf)
deallocate(divider)
Expand Down
13 changes: 6 additions & 7 deletions util/Correlated_Obs/readsatobs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ subroutine get_chaninfo_nc(filename,chan_choice)
character(len=9), intent(in) :: filename
integer(i_kind), intent(in):: chan_choice
integer(i_kind) iunit, nobs, i,j
integer(i_kind), dimension(:), allocatable ::Use_Flag,chind,shind
integer(i_kind), dimension(:), allocatable ::Use_Flag,chind,schind
real(r_double), dimension(:), allocatable:: Waves,Inv_Errors
real(r_kind), dimension(:), allocatable:: Wave,Inv_Error

Expand All @@ -122,13 +122,13 @@ subroutine get_chaninfo_nc(filename,chan_choice)
nobs = nc_diag_read_get_dim(iunit,'nobs')
if (nobs <= 0) call nc_diag_read_close(filename)
nctot = nc_diag_read_get_dim(iunit,'nchans')
allocate(Use_Flag(nctot),chind(nobs),shind(nctot),Wave(nctot),Inv_Error(nctot))
allocate(Use_Flag(nctot),chind(nobs),schind(nctot),Wave(nctot),Inv_Error(nctot))
allocate(Waves(nctot),Inv_Errors(nctot))
call nc_diag_read_get_var(iunit, 'use_flag', Use_Flag)
call nc_diag_read_get_var(iunit, 'Channel_Index', chind)
call nc_diag_read_get_var(iunit, 'wavenumber', Waves)
call nc_diag_read_get_var(iunit, 'error_variance', Inv_Errors)
call nc_diag_read_get_var(iunit, 'sensor_chan', shind)
call nc_diag_read_get_var(iunit, 'sensor_chan', schind)
Wave=real(Waves,r_kind)
Inv_Error=real(Inv_Errors,r_kind)
call nc_diag_read_close(filename)
Expand All @@ -144,21 +144,20 @@ subroutine get_chaninfo_nc(filename,chan_choice)
allocate(indRf(nch_active),indR(nch_active),chaninfo(nch_active),errout(nch_active))
i=0
do j=1,nctot
print *, 'chan ', shind(j)
if (chan_choice==full_chan) then
indRf(j)=shind(j)!j
indRf(j)=schind(j)
indR(j)=j
else if (Use_Flag(chind(j))>0) then
i=i+1
indRf(i)=shind(j)!j
indRf(i)=schind(j)
indR(i)=j
end if
end do
do j=1,nch_active
chaninfo(j)=Wave(chind(indR(j)))
errout(j)=Inv_Error(chind(indR(j)))
end do
deallocate(Use_flag,chind,Wave,Inv_Error,Waves,Inv_Errors)
deallocate(Use_flag,chind,schind,Wave,Inv_Error,Waves,Inv_Errors)
end subroutine get_chaninfo_nc

! read radiance data
Expand Down

0 comments on commit 33e46e6

Please sign in to comment.