[cmor] 91/190: 2011-02-23 : releasing 2.5.6 2011-02-23 : got cmor_set_variable_attribute to actually do something and not raise error all the time, thx to Larry Solheim to spot this. 2011-02-23 : fixed issue when writing 1 time step at a time for climatological means, issue could led to seg fault and bad final file names, thx to Koji Ogochi to spot this one.

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:41 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 ef2ad0391ef000b6406bc1d1e037342520ecad1f
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Wed Feb 23 15:32:34 2011 -0800

    2011-02-23 : releasing 2.5.6
    2011-02-23 : got cmor_set_variable_attribute to actually do something and not raise error all the time, thx to Larry Solheim to spot this.
    2011-02-23 : fixed issue when writing 1 time step at a time for climatological means, issue could led to seg fault and bad final file names, thx to Koji Ogochi to spot this one.
---
 RELEASE-NOTES                |  3 +++
 Src/cmor_variables.c         | 14 +++++------
 Test/test_python_jamie_10.py | 59 ++++++++++++++++++++++++++++++++++++++++++++
 include/cmor.h               |  2 +-
 4 files changed, 70 insertions(+), 8 deletions(-)

diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 736ab89..6087f4d 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,6 @@
+2011-02-23 : releasing 2.5.6
+2011-02-23 : got cmor_set_variable_attribute to actually do something and not raise error all the time, thx to Larry Solheim to spot this.
+2011-02-23 : fixed issue when writing 1 time step at a time for climatological means, issue could led to seg fault and bad final file names, thx to Koji Ogochi to spot this one.
 2011-02-16 : releasing 2.5.5
 2011-02-16 : added process id to temporary file names so that code can be run via mpi
 2011-02-02 : releasing 2.5.4
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index 66051be..a27f867 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -137,14 +137,13 @@ int cmor_set_variable_attribute(int id, char *attribute_name, char type, void *v
       return 1;
     }
   /* Before setting the attribute we need to see if the variable has been initialized */
-  if (cmor_vars[id].initialized!=0) {
-    snprintf(msg,CMOR_MAX_STRING,"attribute %s on variable %s (table %s) will probably not be set as the variablehas already been created into the output NetCDF file, please place this call BEFORE any cal to cmor_write",attribute_name,cmor_vars[id].id,cmor_tables[cmor_vars[id].ref_table_id].table_id);
+  if (cmor_vars[id].initialized!=-1) {
+    snprintf(msg,CMOR_MAX_STRING,"attribute %s on variable %s (table %s) will probably not be set as the variable has already been created into the output NetCDF file, please place this call BEFORE any cal to cmor_write",attribute_name,cmor_vars[id].id,cmor_tables[cmor_vars[id].ref_table_id].table_id);
     cmor_handle_error(msg,CMOR_NORMAL);
     cmor_pop_traceback();
     return 1;
   }
   cmor_pop_traceback();
-  return 0;
   return cmor_set_variable_attribute_internal(id,attribute_name,type,value);
 }
 
@@ -1316,7 +1315,7 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
   cv_converter *ut_cmor_converter=NULL;
   char local_unit[CMOR_MAX_STRING];
   int n_lower_min=0,n_greater_max=0;
-  double emax,emin;
+  double emax,emin,first_time;
   char msg_min[CMOR_MAX_STRING];
   char msg_max[CMOR_MAX_STRING];
   extern ut_system *ut_read;  
@@ -1662,10 +1661,11 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	  for (i=0;i<ntimes_passed;i++) {
 	    tmp_vals[i]=(tmp_vals[2*i]+tmp_vals[2*i+1])/2.;
 	  }
+	  first_time = tmp_vals[0]; /*store for later */
 	}
 	else { /* we need to put into tmp_vals the right things */
-	  tmp_vals[ntimes_passed-2]=tmp_vals[0] ; /*store for later */
 	  ierr = cmor_convert_time_values(time_vals,'d',ntimes_passed,&tmp_vals[0],cmor_axes[avar->axes_ids[0]].iunits,msg,msg2,msg2);
+	  first_time = tmp_vals[0] ; /*store for later */
 	}
 	
 	
@@ -1676,12 +1676,12 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	  /* all good in that case */
 	}
 	else {
-	  tmp_vals[0] = tmp_vals[ntimes_passed*2-2];
+	  //tmp_vals[0] = tmp_vals[ntimes_passed*2-2];
 	  tmp_vals[ntimes_passed-1]=tmp_vals[ntimes_passed*2-1];
 	}	/* ok now we need to store first and last stuff */
 	if (avar->ntimes_written == 0) {
 	  /* ok first time we're putting data  in */
-	  avar->first_time = tmp_vals[0];
+	  avar->first_time = first_time;
 	}
 	else {
 	  if (tmp_vals[0]<avar->last_time) {
diff --git a/Test/test_python_jamie_10.py b/Test/test_python_jamie_10.py
new file mode 100644
index 0000000..6b88bdd
--- /dev/null
+++ b/Test/test_python_jamie_10.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+import cmor
+import numpy
+
+def main():
+    
+    cmor.setup(inpath='Tables',
+               netcdf_file_action = cmor.CMOR_REPLACE_3)
+    cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
+                 institute_id = 'ukmo',
+                 model_id = 'HadCM3',
+                 history = 'some global history',
+                 forcing = 'N/A',
+                 parent_experiment_id = 'N/A',
+                 parent_experiment_rip = 'N/A',
+                 branch_time = 0,
+                 contact = 'brian clough')
+ 
+    table = 'CMIP5_Amon'
+    cmor.load_table(table)
+    axes = [ {'table_entry': 'time',
+              'units': 'days since 2000-01-01 00:00:00',
+              },
+             {'table_entry': 'plevs',
+              'units': 'Pa',
+              'coord_vals': [100000., 92500., 85000., 70000., 60000., 50000., 40000., 30000., 25000., 20000., 15000., 10000., 7000., 5000., 3000., 2000., 1000.]},
+             {'table_entry': 'latitude',
+              'units': 'degrees_north',
+              'coord_vals': [0],
+              'cell_bounds': [-1, 1]},             
+             {'table_entry': 'longitude',
+              'units': 'degrees_east',
+              'coord_vals': [90],
+              'cell_bounds': [89, 91]},
+             ]
+
+
+    axis_ids = list()
+    for axis in axes:
+        print 'doing:',axis
+        axis_id = cmor.axis(**axis)
+        axis_ids.append(axis_id)
+
+    for var, units, value in (('ta', 'K', 274), ('ua', 'm s-1', 10)):
+        values = numpy.array([value,]*len(axes[1]['coord_vals']), numpy.float32)
+        varid = cmor.variable(var,
+                              units,
+                              axis_ids,
+                              history = 'variable history',
+                              missing_value = -99
+                              )
+        cmor.set_variable_attribute(varid, 'cell_measures', 'BLABLABLA')
+        cmor.write(varid, values, time_vals = [15], time_bnds = [ [0,30] ])
+
+    cmor.close()
+    
+if __name__ == '__main__':
+
+    main()
diff --git a/include/cmor.h b/include/cmor.h
index d6d3edc..0c27ac2 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -3,7 +3,7 @@
 
 #define CMOR_VERSION_MAJOR 2
 #define CMOR_VERSION_MINOR 5
-#define CMOR_VERSION_PATCH 4
+#define CMOR_VERSION_PATCH 6
 
 #define CMOR_CF_VERSION_MAJOR 1
 #define CMOR_CF_VERSION_MINOR 4

-- 
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