<p><b>mhoffman@lanl.gov</b> 2012-03-06 16:13:46 -0700 (Tue, 06 Mar 2012)</p><p>BRANCH COMMIT -- land_ice<br>
<br>
Created python script to setup initial conditions in a netCDF file for the dome land ice test case.  The land ice core test case module still needs to be edited to remove the dome test case from there after testing of the python script approach is completed.<br>
</p><hr noshade><pre><font color="gray">Added: branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py
===================================================================
--- branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py                                (rev 0)
+++ branches/land_ice_projects/test_cases/dome/setup_dome_initial_conditions.py        2012-03-06 23:13:46 UTC (rev 1599)
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# Generate initial conditions for dome land ice test case
+
+import sys, numpy
+from Scientific.IO.NetCDF import *
+from math import sqrt
+
+# Check to see if a grid file was specified on the command line.
+# If not, land_ice_grid.nc is used.
+if len(sys.argv) &gt; 1:
+  if sys.argv[1][0] == '-': # The filename can't begin with a hyphen
+    print '</font>
<font color="black">Usage:  python setup_dome_initial_conditions.py [GRID.NC]</font>
<font color="blue">If no filename is supplied, land_ice_grid.nc will be used.'
+    sys.exit(0)
+  else:
+    gridfilename = sys.argv[1]
+else:
+  gridfilename = 'land_ice_grid.nc'
+
+
+
+try:
+    # Open the file, get needed dimensions
+    gridfile = NetCDFFile(gridfilename,'r+')
+    nVertLevels = gridfile.dimensions['nVertLevels']
+    
+    # Get variables
+    xCell = gridfile.variables['xCell'][:]
+    yCell = gridfile.variables['yCell'][:]
+    thickness = gridfile.variables['thickness'][:]
+    bedTopography = gridfile.variables['bedTopography'][:]
+    normalVelocity = gridfile.variables['normalVelocity'][:]
+    layerThicknessFractions = gridfile.variables['layerThicknessFractions'][:]
+    tracers = gridfile.variables['tracers'][:]
+except:
+    sys.exit('Error: The grid file specified is either missing or lacking needed dimensions/variables.')
+
+
+indexTemperature = 0  # IS THIS RIGHT?
+
+
+# Assign variable values for dome
+# Define dome dimensions - all in meters
+r0 = 60000.0 * sqrt(0.125)
+h0 = 2000.0 * sqrt(0.125)
+x0 = 30000.0
+y0 = 30000.0
+# Calculate distance of each cell center from dome center
+r = ((xCell - x0)**2 + (yCell - y0)**2)**0.5
+# Set default value for non-dome cells
+thickness[:] = 0.0
+# Calculate the dome thickness for cells within the desired radius (thickness will be NaN otherwise)
+thickness[0, r&lt;r0] = h0 * (1.0 - (r[r&lt;r0] / r0)**2)**0.5
+# zero velocity everywhere
+normalVelocity[:] = 0.0
+# flat bed at sea level
+bedTopography[:] = 0.0
+# constant, arbitrary temperature, degrees C
+tracers[:,:,:,indexTemperature] = -20.0 
+# Setup layerThicknessFractions
+layerThicknessFractions[:] = 1.0 / nVertLevels
+# (lowerSurface and upperSurface need to be calculated in MPAS)
+
+# Reassign the modified numpy array values back into netCDF variable objects
+gridfile.variables['thickness'][:] = thickness
+gridfile.variables['normalVelocity'][:] = normalVelocity
+gridfile.variables['bedTopography'][:] = bedTopography
+gridfile.variables['tracers'][:] = tracers
+gridfile.variables['layerThicknessFractions'][:] = layerThicknessFractions
+
+
+gridfile.close()
+

</font>
</pre>