From 8b801cb38dfbf1e48d0e59fcf311e4b6f01757cb Mon Sep 17 00:00:00 2001 From: Michael Duda Date: Fri, 1 Aug 2014 21:08:40 +0000 Subject: [PATCH] Bug fix to vertical interpolation logic for missing levels in calc_ecmwf_p.F. Thanks to Daniel van Dijke (MeteoGroup). M util/src/calc_ecmwf_p.F git-svn-id: https://svn-wrf-wps.cgd.ucar.edu/trunk@842 86b71a92-4018-0410-97f8-d555beccfc3a --- util/src/calc_ecmwf_p.F | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/util/src/calc_ecmwf_p.F b/util/src/calc_ecmwf_p.F index 15f0b79..14473c9 100644 --- a/util/src/calc_ecmwf_p.F +++ b/util/src/calc_ecmwf_p.F @@ -301,26 +301,30 @@ program calc_ecmwf_p allocate(hgt_3ddata(ecmwf_data%nx,ecmwf_data%ny, n_levels)) end if - ! CvH_DvD: interpolate Q and T if they are not availalbe at all levels + ! CvH_DvD: interpolate Q and T if they are not available at all levels do i = n_levels, 1, -1 if (tt(1,1,i) .eq. 0) then ! CvH_DvD: If TT is zero, level is unknown, so moisture is zero too - if (i .ne. n_levels) then + if (i .eq. n_levels) then + write(6,*) 'WARNING First level is missing!' ! CvH_DvD: First level should be there! + else if (i .eq. 1) then + ! DvD: If TT is zero at the top level, so missing --> use previous level, + ! mod level will remove it anyway + tt(:,:,i)=tt(:,:,i+1) + qv(:,:,i)=qv(:,:,i+1) + else counter=1 ! CvH_DvD: Find first available level - do while ((tt(1,1,i-counter) .eq. 0) .and. (i-counter .gt. 1)) + do while ((i-counter .gt. 1) .and. (tt(1,1,i-counter) .eq. 0)) counter=counter+1 end do if (tt(1,1,i-counter) .gt. 0) then - ! CvH_DvD: If TT is zero, we're at the top level which is missing, so use previous level, - ! mod level will remove it anyway + ! DvD: Interpolate tt and qv from next available level tt(:,:,i)=tt(:,:,i+1)+(tt(:,:,i-counter)-tt(:,:,i+1))/(counter+1) qv(:,:,i)=qv(:,:,i+1)+(qv(:,:,i-counter)-qv(:,:,i+1))/(counter+1) else - tt(:,:,i)=tt(:,:,i+1) - qv(:,:,i)=qv(:,:,i+1) - end if - else - write(6,*) 'WARNING First level is missing!' ! CvH_DvD: First level should be there! + ! DvD: No available level found --> should not happen. + write(6,*) 'WARNING No available level found near level ',i,'!' + end if end if end if end do -- 2.11.4.GIT