[cmor] 132/190: Seems to be working again, all python test fortran and C test pass, including jamie's bug ones
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:47 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 340598db2a5e3b0432fcbf5aae6a8a9ad5a27884
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Wed Jun 5 17:50:46 2013 -0700
Seems to be working again, all python test fortran and C test pass, including jamie's bug ones
---
Src/cmor.c | 15 ++++++++++++
Src/cmor_axes.c | 43 +++++++++++++----------------------
Src/cmor_variables.c | 19 +++++++++++-----
Test/cmor_speed_and_compression.py | 3 ++-
Test/cmor_speed_and_compression_01.py | 2 +-
Test/test_compression.py | 2 +-
Test/test_python_joerg_2.py | 1 +
include/cmor.h | 4 ++--
8 files changed, 51 insertions(+), 38 deletions(-)
diff --git a/Src/cmor.c b/Src/cmor.c
index a25894e..6c00988 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -2075,6 +2075,13 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
}
else {
cmor_vars[var_id].time_bnds_nc_id=i;
+ /* Here I need to store first/last bounds for appending issues */
+ starts[0]=cmor_vars[var_id].ntimes_written-1;
+ starts[1]=1;
+ ierr = nc_get_var1_double(ncid,cmor_vars[var_id].time_bnds_nc_id,&starts[0],&cmor_vars[var_id].last_bound);
+ starts[1]=0;
+ ierr = nc_get_var1_double(ncid,cmor_vars[var_id].time_bnds_nc_id,&starts[0],&cmor_vars[var_id].first_bound);
+ /* printf("ok we read back in: %f, %f, associated: %i\n",cmor_vars[var_id].first_bound,cmor_vars[var_id].last_bound,cmor_vars[var_id].associated_ids[0]);*/
}
cmor_vars[var_id].initialized=ncid;
}
@@ -3315,6 +3322,14 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
}
}
if (refvar!=NULL) {
+ /* if (cmor_vars[var_id].first_bound==1.e20) {
+ cmor_vars[var_id].first_bound = cmor_vars[*refvar].first_bound;
+ cmor_vars[var_id].last_bound = cmor_vars[*refvar].last_bound;
+ cmor_vars[var_id].last_time = cmor_vars[*refvar].last_time;
+
+ printf("We did reset the first and last bounds: %f, %f \n",cmor_vars[var_id].first_bound, cmor_vars[var_id].last_bound);
+ }
+ */
for(i=0;i<10;i++) {
if (cmor_vars[*refvar].associated_ids[i]==var_id) {
if (cmor_vars[*refvar].ntimes_written_associated[i] == 0) {
diff --git a/Src/cmor_axes.c b/Src/cmor_axes.c
index 98639e0..449e87f 100644
--- a/Src/cmor_axes.c
+++ b/Src/cmor_axes.c
@@ -560,27 +560,6 @@ int cmor_check_monotonic(double *values,int length, char *name,int isbounds, int
}
}
}
- /* here we check if interval is about right */
- if ( (refaxis->axis=='T')) {
- /* do not do the following in case of climatological stuff.... */
- if (refaxis->climatology==0) {
- /* just keep the begining of units out no need to know the since part */
- j=0;
- while (refaxis->units[j]==' ') j++;
- i=0;
- while ((refaxis->units[i+j]!=' ') && (refaxis->units[i+j]!='\0')) {
- msg2[i]=refaxis->units[i+j];
- i++;
- }
- msg2[i]='\0';
- snprintf(msg,CMOR_MAX_STRING,"%lf %s",cmor_tables[cmor_axes[axis_id].ref_table_id].interval,msg2);
- /* printf("calling chck interv: %i\n",length); */
- /* for(i=0;i<length;i++) printf("i:%i ,val: %lf\n",i,values[i]); */
- /* ok skip this for non standard cal */
-
- i = cmor_check_interval(axis_id,msg,&values[0],length,isbounds);
- }
- }
cmor_pop_traceback();
return treatlon;
}
@@ -604,7 +583,6 @@ int cmor_treat_axis_values(int axis_id, double *values, int length, int n_reques
cmor_add_traceback("cmor_treat_axis_values");
cmor_is_setup();
- fprintf(stderr,"Treat values for %s, %i\n",name,isbounds);
axis = &cmor_axes[axis_id];
refaxis = &cmor_tables[axis->ref_table_id].axes[axis->ref_axis_id];
@@ -833,11 +811,9 @@ int cmor_treat_axis_values(int axis_id, double *values, int length, int n_reques
if (isbounds==0) { /* Dealing with coords */
for (i=0;i<length;i++) /* ok lets add 360. until it's all good */
while (values[i]<refaxis->valid_min) {
- fprintf(stderr,"Adding 360 at index: %i , %f\n",i,values[i]);
values[i]+=360.;
cmor_axes[axis_id].wrapping[i]+=1;
}
- fprintf(stderr,"Ok we are out of this loop\n");
/* ok now need to determine the offset */
for (i=0;i<length-1;i++) {
if (values[i]>values[i+1]) {
@@ -847,7 +823,6 @@ int cmor_treat_axis_values(int axis_id, double *values, int length, int n_reques
}
}
}
- printf("now offset is: %i\n",axis->offset);
treatlon=0;
if (refaxis->valid_max!=1.e20) for (i=0;i<length;i++) if (values[i]>refaxis->valid_max) {
if ((refaxis->axis=='X')&& (strncmp(refaxis->units,"degrees",7)==0)) {
@@ -883,7 +858,6 @@ int cmor_treat_axis_values(int axis_id, double *values, int length, int n_reques
}
/* ok now need to move the offset thing */
if (axis->offset!=0) {
- printf("Ok we are in the reoffseting section: %i\n",axis->offset);
if (isbounds==0) {
/* printf("ok unoffseted values are (axes): (offset is: %i) \n",axis->offset); */
/* for (i=0;i<length;i++) printf("%i : %f\n",i,values[i]); */
@@ -942,7 +916,6 @@ int cmor_check_interval(int axis_id, char *interval, double *values, int nvalues
axis = &cmor_axes[axis_id];
refaxis = &cmor_tables[axis->ref_table_id].axes[axis->ref_axis_id];
- for(i=0;i<nvalues;i++) printf("I: %i, val: %f\n",i,values[i]);
if (isbounds==0) {
nval = nvalues;
@@ -1331,6 +1304,22 @@ int cmor_axis(int *axis_id, char *name,char *units, int length,void *coord_vals,
if ((refaxis.axis=='T')&&(refaxis.climatology==0)) {
/* ok now we need to overwrite the time values with mid point */
for (i=0;i<length;i++) cmor_axes[cmor_naxes].values[i]=(cmor_axes[cmor_naxes].bounds[2*i]+cmor_axes[cmor_naxes].bounds[2*i+1])/2.;
+ /* here we check if interval is about right */
+ /* just keep the begining of units out no need to know the since part */
+ j=0;
+ while (refaxis.units[j]==' ') j++;
+ i=0;
+ while ((refaxis.units[i+j]!=' ') && (refaxis.units[i+j]!='\0')) {
+ ctmp[i]=refaxis.units[i+j];
+ i++;
+ }
+ ctmp[i]='\0';
+ snprintf(msg,CMOR_MAX_STRING,"%lf %s",cmor_tables[cmor_axes[cmor_naxes].ref_table_id].interval,ctmp);
+ /* printf("calling chck interv: %i\n",length); */
+ /* for(i=0;i<length;i++) printf("i:%i ,val: %lf\n",i,values[i]); */
+ /* ok skip this for non standard cal */
+
+ i = cmor_check_interval(cmor_naxes,msg,&cmor_axes[cmor_naxes].values[0],length,0);
}
}
}
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index a0ccec8..4131522 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -1640,23 +1640,30 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
cmor_handle_error(msg,CMOR_CRITICAL);
}
if (avar->ntimes_written>0) {
- tmpindex = 1;
- tmp_vals[0]=avar->last_time;
+ if ((avar->last_time!=-999.)&&(avar->last_bound!=1.e20)) {
+ tmpindex = 1;
+ tmp_vals[0]=avar->last_time;
+ }
+ else {
+ tmpindex=0;
+ }
}
else {
tmpindex = 0;
}
ierr = cmor_convert_time_values(time_vals,'d',ntimes_passed,&tmp_vals[tmpindex],cmor_axes[avar->axes_ids[0]].iunits,msg,msg2,msg2);
ierr = cmor_check_monotonic(&tmp_vals[0],ntimes_passed+tmpindex,"time",0,avar->axes_ids[0]);
-
+printf("ok we got: %f, %f--------\n",avar->last_time,avar->last_bound);
if (avar->ntimes_written>0) {
- tmp_vals[0] = 2*avar->last_time-avar->last_bound;
- tmp_vals[1] = avar->last_bound;
+ if ((avar->last_time!=-999.)&&(avar->last_bound!=1.e20)) {
+ tmp_vals[0] = 2*avar->last_time-avar->last_bound;
+ tmp_vals[1] = avar->last_bound;
+ }
}
ierr = cmor_convert_time_values(time_bounds,'d',ntimes_passed*2,&tmp_vals[2*tmpindex],cmor_axes[avar->axes_ids[0]].iunits,msg,msg2,msg2);
ierr = cmor_check_monotonic(&tmp_vals[0],(ntimes_passed+tmpindex)*2,"time",1,avar->axes_ids[0]);
ierr = cmor_check_values_inside_bounds(&time_vals[0],&time_bounds[0], ntimes_passed, "time");
- ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,tmp_vals);
+ ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,&tmp_vals[2*tmpindex]);
if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NetCDF error (%i) writing time bounds for variable '%s', already written in file: %i",ierr,avar->id,avar->ntimes_written);cmor_handle_error(msg,CMOR_CRITICAL);}
/* /\* ok first time around the we need to store bounds *\/ */
if (avar->ntimes_written == 0) {
diff --git a/Test/cmor_speed_and_compression.py b/Test/cmor_speed_and_compression.py
index 6206618..35b4a39 100644
--- a/Test/cmor_speed_and_compression.py
+++ b/Test/cmor_speed_and_compression.py
@@ -56,7 +56,8 @@ print 'Tables ids:',tables
## read in data, just one slice
-f=cdms2.open(sys.prefix+'/sample_data/tas_dnm-95a_1984.01-1984.12.nc')
+f=cdms2.open(sys.prefix+'/sample_data/tas_ccsr-95a.xml')
+
s=f("tas",time=slice(0,1),squeeze=1)
ntimes = 12
diff --git a/Test/cmor_speed_and_compression_01.py b/Test/cmor_speed_and_compression_01.py
index f46d344..b084b74 100644
--- a/Test/cmor_speed_and_compression_01.py
+++ b/Test/cmor_speed_and_compression_01.py
@@ -56,7 +56,7 @@ print 'Tables ids:',tables
## read in data, just one slice
-f=cdms2.open(sys.prefix+'/sample_data/tas_dnm-95a_1984.01-1984.12.nc')
+f=cdms2.open(sys.prefix+'/sample_data/tas_ccsr-95a.xml')
s=f("tas",time=slice(0,12),squeeze=1)
ntimes = 12
diff --git a/Test/test_compression.py b/Test/test_compression.py
index b48efe5..5d2287b 100644
--- a/Test/test_compression.py
+++ b/Test/test_compression.py
@@ -7,7 +7,7 @@ except:
import cmor,numpy
-f=cdms2.open(os.path.join(cmor.__path__[0],'..','..','..','..','sample_data/clt.nc'))
+f=cdms2.open(os.path.join(sys.prefix,'sample_data/clt.nc'))
pth = os.path.split(os.path.realpath(os.curdir))
if pth[-1]=='Test':
diff --git a/Test/test_python_joerg_2.py b/Test/test_python_joerg_2.py
index c1545ab..1fa23aa 100644
--- a/Test/test_python_joerg_2.py
+++ b/Test/test_python_joerg_2.py
@@ -71,6 +71,7 @@ def test_mode(mode,i,suffix=''):
missing_value = -99
)
print 'suffix is:',suffix
+ print "Sending time bounds:",[[i,i+1]]
cmor.write(varid, values, time_vals = [i], time_bnds = [ [i,i+1] ],file_suffix=suffix)
fnm = cmor.close(varid,file_name=True)
diff --git a/include/cmor.h b/include/cmor.h
index 350dea9..7641990 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -2,8 +2,8 @@
#define CMOR_H
#define CMOR_VERSION_MAJOR 2
-#define CMOR_VERSION_MINOR 8
-#define CMOR_VERSION_PATCH 3
+#define CMOR_VERSION_MINOR 9
+#define CMOR_VERSION_PATCH 0
#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