<p><b>duda</b> 2011-01-06 17:00:09 -0700 (Thu, 06 Jan 2011)</p><p>BRANCH COMMIT<br>
<br>
Add code for moist initialization from atmos_physics branch to the<br>
non-hydrostatic core; setting config_mp_physics to a non-zero value<br>
activates this code during test case setup.<br>
<br>
Provided that negative mixing ratios aren't zeroed-out in the<br>
non-hydrostatic solver of the atmos_physics branch, the atmos_physics<br>
branch and atmos_nonhydrostatic branch now produce the same results for<br>
both dry and moist versions of test case 2 without physics.<br>
<br>
M    src/core_nhyd_atmos/module_test_cases.F<br>
</p><hr noshade><pre><font color="gray">Modified: branches/atmos_nonhydrostatic/src/core_nhyd_atmos/module_test_cases.F
===================================================================
--- branches/atmos_nonhydrostatic/src/core_nhyd_atmos/module_test_cases.F        2011-01-06 20:36:31 UTC (rev 679)
+++ branches/atmos_nonhydrostatic/src/core_nhyd_atmos/module_test_cases.F        2011-01-07 00:00:09 UTC (rev 680)
@@ -554,6 +554,37 @@
             ztemp   = .5*(zgrid(k,i)+zgrid(k+1,i))
             ptemp   = ppb(k,i) + pp(k,i)
 
+            if (config_mp_physics /= 0) then
+
+               !.. ldf (11-15-2010): move calculation of the relative humidity inside iteration loop to 
+               !.. calculate the saturation mixing ratio and initialize the water vapor mixing ratio.
+               !.. We assume the temperature computed above is the virtual temperature when moisture is
+               !.. present:
+               if(ptemp &lt; 50000.) then
+                  relhum(k,i) = 0.0
+               elseif(ptemp &gt; p0) then
+                  relhum(k,i) = 1.0
+               else
+                  relhum(k,i) = (1.-((p0-ptemp)/50000.)**1.25)
+               endif
+               relhum(k,i) = min(rh_max,relhum(k,i))
+   
+               !.. conversion from virtual temperature to temperature:
+               ttemp = temperature(k)/(1.+0.608*scalars(index_qv,k,i))
+   
+               !.. calculation of water vapor mixing ratio:
+               if (ttemp &gt; 273.15) then
+                   es  = 1000.*0.6112*exp(17.67*(ttemp-273.15)/(ttemp-29.65))
+               else
+                   es  = 1000.*0.6112*exp(21.8745584*(ttemp-273.15)/(ttemp-7.66))
+               end if           
+               qsat(k,i) = (287.04/461.6)*es/(ptemp-es)
+               if(relhum(k,i) .eq. 0.0) qsat(k,i) = 0.0
+               scalars(index_qv,k,i) = relhum(k,i)*qsat(k,i)
+               qv(k,i) = scalars(index_qv,k,i)
+
+            end if
+
             !.. conversion from virtual temperature to &quot;modified&quot; temperature:
             tt(k) = temperature(k)*(1+scalars(index_qv,k,i))
 

</font>
</pre>