<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"><title>Minor bug found in Grell-Devenyi cumulus scheme (WRF 3.2.1 and WRF 3.3)</title>
</head>
<body>
<font face="Lucida Grande"><span style="font-size:11pt"><br>
All:<br>
<br>
I’ve found a minor bug in the Grell-Devenyi cumulus scheme while running a test domain including the Himalayas and with run time checking turned on. The relevant code is in lines 261-276 of module_cu_gd.F:<br>
<br>
do k= kts+1,ktf-1<br>
DO I = its,itf<br>
if((p2d(i,1)-p2d(i,k)).gt.150.and.p2d(i,k).gt.300)then<br>
dp=-.5*(p2d(i,k+1)-p2d(i,k-1))<br>
umean(i)=umean(i)+us(i,k)*dp<br>
vmean(i)=vmean(i)+vs(i,k)*dp<br>
pmean(i)=pmean(i)+dp<br>
endif<br>
enddo<br>
enddo<br>
DO I = its,itf<br>
umean(i)=umean(i)/pmean(i)<br>
vmean(i)=vmean(i)/pmean(i)<br>
direction(i)=(atan2(umean(i),vmean(i))+3.1415926)*57.29578<br>
if(direction(i).gt.360.)direction(i)=direction(i)-360.<br>
ENDDO<br>
<br>
<br>
p2d is the 2D slab of pressure in mb. Pmean is an average pressure thickness of model levels below the 300 mb level and 150 mb above the model level closest to the ground. Pmean is initialized to zero earlier in the routine. In my test run, I encountered a situation in the Himalayas where the pmean value is not updated, triggering a division-by-zero error in the umean, vmean, and direction calculations. My suggested bug fix is:<br>
<br>
DO I = its,itf<br>
!EMK Bug fix<br>
if (pmean(i) > 0) then<br>
umean(i)=umean(i)/pmean(i)<br>
vmean(i)=vmean(i)/pmean(i)<br>
direction(i)=(atan2(umean(i),vmean(i))+3.1415926)*57.29578<br>
if(direction(i).gt.360.)direction(i)=direction(i)-360.<br>
end if<br>
!EMK END Bug fix<br>
ENDDO<br>
<br>
Note that umean and vmean are only used to calculate direction, and direction is initialized as zero. It does not appear that this direction variable is actually used anywhere else in the code (code fragments that did use it are all commented out), so this is a minor bug and bug fix that shouldn’t change simulation results. Nonetheless I suggest fixing it, since it can interfere with run-time checks for other errors (as it did in my test case!) and it could slow down the simulation by producing NaNs.<br>
<br>
-Eric<br>
<br>
</span></font><span style="font-size:11pt"><font face="Courier, Courier New">--------------------------------------------------------------------<br>
Eric M. Kemp Northrop Grumman Corporation<br>
Meteorologist Information Systems<br>
Civil Enterprise Solutions Civil Systems Division<br>
<br>
Goddard Space Flight Center<br>
Mailstop 610.3<br>
Greenbelt, MD 20771<br>
Telephone 301-286-9768<br>
Fax 301-286-1775<br>
E-mail: <a href="eric.kemp@nasa.gov">eric.kemp@nasa.gov</a><br>
E-mail: <a href="eric.kemp@ngc.com">eric.kemp@ngc.com</a><br>
--------------------------------------------------------------------<br>
<br>
</font><font face="Lucida Grande"><br>
</font></span>
</body>
</html>