Skip to content

Commit

Permalink
additional code cleanup, enhance error checking (NOAA-EMC#808)
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTreadon-NOAA committed Dec 2, 2024
1 parent 68d52ac commit 849b3b1
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/gsi/m_berror_stats.f90
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,21 @@ subroutine nc_(myid)
n = getindex(cvars2d,'sst')
found2d(n)=.true.
call nc_berror_getpointer (cvars2d(nv),bvars,ptr2d,ier)
if(ier==0) corsst=ptr2d
if (ier/=0) call die(myname_," in cw, failed to find corsst ", 99)
corsst=ptr2d
call nc_berror_getpointer ('h'//cvars2d(nv),bvars,ptr2d,ier)
if(ier==0) hsst=ptr2d
if(ier/=0) call die(myname_," in cw, failed to find hsst ", 99)
hsst=ptr2d
endif
if (trim(cvars2d(nv))=='ps') then
n = getindex(cvars2d,'ps')
found2d(n)=.true.
call nc_berror_getpointer (cvars2d(nv),bvars,ptr1d,ier)
if(ier==0) corp(:,n)=ptr1d
if(ier/=0) call die(myname_," in cw, failed to find corp ", 99)
corp(:,n)=ptr1d
call nc_berror_getpointer ('h'//cvars2d(nv),bvars,ptr1d,ier)
if(ier==0) hwllp(:,n)=ptr1d
if(ier/=0) call die(myname_," in cw, failed to find hwllp ", 99)
hwllp(:,n)=ptr1d
endif
enddo
do nv=1,size(cvars3d)
Expand All @@ -725,9 +729,11 @@ subroutine nc_(myid)
found3d(n)=.true.
corz(:,:,n)=ptr2d
call nc_berror_getpointer ('h'//trim(cvars3d(nv)),bvars,ptr2d,ier)
if(ier==0) hwll(:,:,n)=ptr2d
if(ier/=0) call die(myname_," in cw, failed to find hwll ", 99)
hwll(:,:,n)=ptr2d
call nc_berror_getpointer ('v'//trim(cvars3d(nv)),bvars,ptr2d,ier)
if(ier==0) vz(:,:,n)=transpose(ptr2d)
if(ier/=0) call die(myname_," in cw, failed to find vz ", 99)
vz(:,:,n)=transpose(ptr2d)
if (trim(cvars3d(nv))=='cw' .and. cwoption==2) then
allocate(corq2(bvars%nlat,bvars%nsig))
call nc_berror_getpointer ('nrh',bvars,ptr2d,ier)
Expand All @@ -750,9 +756,6 @@ subroutine nc_(myid)
call nc_berror_getpointer ('nrh',bvars,ptr2d,ier)
if (ier==0) then
corq2=ptr2d
! corq2=max(0.0_r_kind,corq2) ! hack 1
! corq2=min(1.0_r_kind,2*corq2) ! hack 2
! print *, 'DEBUG (berr): ', minval(corq2),maxval(corq2)
do k=1,bvars%nsig
do i=1,bvars%nlat
corq2x=corq2(i,k)
Expand All @@ -766,7 +769,9 @@ subroutine nc_(myid)
deallocate(corq2)
endif
cycle
endif
else
call die(myname_," in cw, failed to find cvars3d bvars ", 99)
endif
if (trim(cvars3d(nv))=='q') then
n = getindex(cvars3d,'q')
found3d(n)=.true.
Expand Down

0 comments on commit 849b3b1

Please sign in to comment.