[cmor] 54/190: Adding debug codes for Joerg's problem

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:37 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository cmor.

commit 9accda70f6eeb645205b5f9bdc1e982db016ac11
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Fri Sep 24 08:10:11 2010 -0700

    Adding debug codes for Joerg's problem
---
 Lib/pywrapper.py            |  6 ++-
 Test/test_joerg_broken.f90  | 70 ++++++++++++++++++++++++++++++++++
 Test/test_python_joerg_9.py | 91 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+), 1 deletion(-)

diff --git a/Lib/pywrapper.py b/Lib/pywrapper.py
index 982db07..e0a2bea 100644
--- a/Lib/pywrapper.py
+++ b/Lib/pywrapper.py
@@ -547,6 +547,10 @@ def zfactor(zaxis_id,zfactor_name,units="",axis_ids=None,type=None,zfactor_value
 
 def write(var_id,data,ntimes_passed=None,file_suffix="",time_vals=None,time_bnds=None,store_with=None):
 
+    """ write data to a cmor variable
+    Usage:
+    ierr = write(var_id,data,ntimes_passed=None,file_suffix="",time_vals=None,time_bnds=None,store_with=None
+    """
     if not isinstance(var_id,(int,numpy.int,numpy.int32)):
         raise Exception, "error var_id must be an integer"
     var_id = int(var_id)
@@ -666,7 +670,7 @@ def write(var_id,data,ntimes_passed=None,file_suffix="",time_vals=None,time_bnds
             else:
                 ltv=len(time_vals)
             if len(time_bnds)!=ltv+1:
-                raise Excpetion,"error time_bnds if 1D must be 1 elt greater than time_vals, you have %i vs %i" % (len(time_bnds),ltv)
+                raise Exception,"error time_bnds if 1D must be 1 elt greater than time_vals, you have %i vs %i" % (len(time_bnds),ltv)
             bnds=[]
             for i in range(ltv):
                 bnds.append([time_bnds[i],time_bnds[i+1]])
diff --git a/Test/test_joerg_broken.f90 b/Test/test_joerg_broken.f90
new file mode 100644
index 0000000..808eea0
--- /dev/null
+++ b/Test/test_joerg_broken.f90
@@ -0,0 +1,70 @@
+program joerg
+
+  USE cmor_users_functions
+  IMPLICIT NONE
+
+  integer axes(10),error_flag
+    error_flag = cmor_setup(inpath='Test', netcdf_file_action='replace')
+
+
+  error_flag = cmor_dataset(                                   &
+       outpath='Test',                                         &
+       experiment_id='abrupt 4XCO2',           &
+       institution=                                            &
+       'GICC (Generic International Climate Center, ' //       &
+       'Geneva, Switzerland)',                                 &
+       source='GICCM1 (2002): ' //                             &
+       'atmosphere:  GICAM3 (gicam_0_brnchT_itea_2, T63L32); '// &
+       'ocean: MOM (mom3_ver_3.5.2, 2x3L15); '             //  &
+       'sea ice: GISIM4; land: GILSM2.5',                      &
+       calendar='noleap',                                      &
+       realization=1,                                          &
+       history='Output from archive/giccm_03_std_2xCO2_2256.', &
+       institute_id = 'PCMDI', &
+       comment='Equilibrium reached after 30-year spin-up ' // &
+       'after which data were output starting with nominal '// &
+       'date of January 2030',                                 &
+       references='Model described by Koder and Tolkien ' //   &
+       '(J. Geophys. Res., 2001, 576-591).  Also '        //   &
+       'see http://www.GICC.su/giccm/doc/index.html '     //   &
+       ' 2XCO2 simulation described in Dorkey et al. '    //   &
+       '(Clim. Dyn., 2003, 323-357.)',&
+       model_id='GICCM1',forcing='TO',contact="Barry Bonds",&
+       parent_experiment_id="N/A",branch_time=bt)
+
+    call cmor_set_table(table_id=ntables(2))
+     axes(1) = cmor_axis(                            &
+       table_entry        = 'i_index',               &
+       length             = nlon,                    &
+       coord_vals         = xii,                     &
+       units              = '1')
+
+     axes(2) = cmor_axis(                            &
+       table_entry        = 'j_index',               &
+       length             = nlat,                    &
+       coord_vals         = yii,                     &
+       units              = '1')
+
+     grid_id = cmor_grid(                            &
+       axis_ids           = axes,                    &
+       latitude           = olat_val,                &
+       longitude          = olon_val,                &
+       latitude_vertices  = bnds_olat,               &
+       longitude_vertices = bnds_olon)
+
+     call cmor_set_table(table_id=ntables(1))
+
+      var_ids              = cmor_variable(           &
+        table_entry        = vartabin(1,i),           &
+        units              = vartabin(2,i),                  &
+        positive           = vartabin(3,i),           &
+        axis_ids           = (/ grid_id, tim_id /),   &
+        missing_value      = miss_val(i) )
+
+      error_flag = cmor_write(                        &
+         var_id            = var_ids,                 &
+         data              = ar5all2d(:,:,:,i),       &
+         ntimes_passed     = ntim,                    &
+         file_suffix       = SUFFIX,                  &
+         time_vals         = time,                    &
+         time_bnds         = bnds_time)
diff --git a/Test/test_python_joerg_9.py b/Test/test_python_joerg_9.py
new file mode 100644
index 0000000..a23a87f
--- /dev/null
+++ b/Test/test_python_joerg_9.py
@@ -0,0 +1,91 @@
+import cmor,numpy,cdms2
+
+f=cdms2.open("Test/GR30s_halo.nc")
+
+nlon=f['grid_center_lat'].shape[1]
+nlat=f['grid_center_lat'].shape[0]
+
+
+error_flag = cmor.setup(inpath='Test', netcdf_file_action=cmor.CMOR_APPEND)
+  
+error_flag = cmor.dataset(                                   
+       outpath='Joerg',                                         
+       experiment_id='noVolc2000',
+       institution= 'GICC (Generic International Climate Center, Geneva, Switzerland)',
+       institute_id = "GICC",
+       source='GICCM1 (2002): ',
+       calendar='360_day',                                      
+       realization=1,                                          
+       contact = 'Rusty Koder (koder at middle_earth.net) ',      
+       history='Output from archivcl_A1.nce/giccm_03_std_2xCO2_2256.', 
+       comment='Equilibrium reached after 30-year spin-up ',                                 
+       references='Model described by Koder and Tolkien ',
+       model_id="GICCM1", 
+       forcing="Ant",
+       parent_experiment_id="lgm",branch_time=0)
+
+ntables=[cmor.load_table("/git/cmip5-cmor-tables/Tables/CMIP5_grids")]
+ntables.append(cmor.load_table("/git/cmip5-cmor-tables/Tables/CMIP5_OImon"))
+
+
+cmor.set_table(ntables[0])
+axes=numpy.zeros(2,numpy.int32)
+
+axes[0] = cmor.axis(                            
+    table_entry        = 'i_index',               
+    length             = nlon,                    
+    coord_vals         = numpy.arange(0,nlon,1,numpy.int32),                     
+    units              = '1')
+  
+axes[1] = cmor.axis(                            
+    table_entry        = 'j_index',               
+    length             = nlat,                    
+    coord_vals         = numpy.arange(0,nlat,1,numpy.int32),                     
+    units              = '1')
+
+
+olat_val  = f("grid_center_lat").filled()
+olon_val  = f("grid_center_lon").filled()
+bnds_olat = f("grid_corner_lat").filled()
+bnds_olon = f("grid_corner_lon").filled()
+
+grid_id = cmor.grid(                            
+    axis_ids           = axes,                    
+    latitude           = olat_val,                
+    longitude          = olon_val,                
+    latitude_vertices  = bnds_olat,               
+    longitude_vertices = bnds_olon)
+
+cmor.set_table(ntables[1])
+
+
+ntimes=12
+
+tim_id = cmor.axis( table_entry="time",
+                    units="months since 2010")
+time_vals = numpy.arange(ntimes)
+bnds_time = numpy.arange(ntimes+1)
+
+var_ids              = cmor.variable(           
+    table_entry        = "sic",           
+    units              = "%",                  
+##     positive           = vartabin(3,i),           
+    axis_ids           = [grid_id, tim_id ] 
+    )
+
+fnm=""
+for i in range(ntimes):
+    print 'writing time:',time_vals[i],bnds_time[i:i+2]
+    data = numpy.random.random((nlon,nlat))
+    error_flag = cmor.write(                        
+        var_id            = var_ids,                 
+        data              = data,
+        ntimes_passed     = 1,                    
+        file_suffix       = fnm,                  
+        time_vals         = time_vals[i],                    
+        time_bnds         = bnds_time[i:i+2])
+
+    fnm = cmor.close(var_ids,file_name=True,preserve=True)
+    print 'dumped to:',fnm
+
+cmor.close()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git



More information about the debian-science-commits mailing list