[cmor] 130/190: Gap issue with multiple write call seem to be fixed now. Thx Jamie
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:46 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 533ef24c6573c2cd7cec276623cf374cd680340d
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Fri May 17 17:51:23 2013 -0700
Gap issue with multiple write call seem to be fixed now. Thx Jamie
---
Src/cmor_variables.c | 34 +++++++++++++++++++++++++---------
Test/test_time_gap_multi_write.py | 8 ++++----
Test/test_time_gap_single_write1.py | 4 ++--
Test/test_time_gap_single_write2.py | 4 ++--
include/cmor.h | 2 ++
5 files changed, 35 insertions(+), 17 deletions(-)
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index a58c4e8..a0ccec8 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -1318,7 +1318,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
double emax,emin,first_time;
char msg_min[CMOR_MAX_STRING];
char msg_max[CMOR_MAX_STRING];
- extern ut_system *ut_read;
+ extern ut_system *ut_read;
+ int tmpindex=0;
cmor_add_traceback("cmor_write_var_to_file");
cmor_is_setup();
@@ -1633,17 +1634,27 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
/* cmor_handle_error(msg,CMOR_CRITICAL); */
/* } */
/* } */
- tmp_vals = malloc(ntimes_passed*2*sizeof(double));
+ tmp_vals = malloc((ntimes_passed+1)*2*sizeof(double));
if (tmp_vals == NULL) {
snprintf(msg,CMOR_MAX_STRING,"cannot malloc %i tmp bounds time vals for variable '%s' (table: %s)",ntimes_passed*2,avar->id,cmor_tables[avar->ref_table_id].table_id);
cmor_handle_error(msg,CMOR_CRITICAL);
}
+ if (avar->ntimes_written>0) {
+ tmpindex = 1;
+ tmp_vals[0]=avar->last_time;
+ }
+ 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]);
- ierr = cmor_convert_time_values(time_vals,'d',ntimes_passed,&tmp_vals[0],cmor_axes[avar->axes_ids[0]].iunits,msg,msg2,msg2);
- ierr = cmor_check_monotonic(&tmp_vals[0],ntimes_passed,"time",0,avar->axes_ids[0]);
-
- ierr = cmor_convert_time_values(time_bounds,'d',ntimes_passed*2,&tmp_vals[0],cmor_axes[avar->axes_ids[0]].iunits,msg,msg2,msg2);
- ierr = cmor_check_monotonic(&tmp_vals[0],ntimes_passed*2,"time",1,avar->axes_ids[0]);
+ if (avar->ntimes_written>0) {
+ 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);
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);}
@@ -1652,8 +1663,13 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
/* ok first time we're putting data in */
avar->first_bound = tmp_vals[0];
}
- avar->last_bound = tmp_vals[ntimes_passed*2-1];
-
+ else {
+ /* ok let's put the bounds back on "normal" (start at 0) indices */
+ for (i=0;i<2*ntimes_passed;i++) {
+ tmp_vals[i]=tmp_vals[i+2];
+ }
+ }
+ avar->last_bound = tmp_vals[ntimes_passed*2-1];
/* ok since we have bounds we need to set time in the middle */
/* but only do this in case of none climato */
diff --git a/Test/test_time_gap_multi_write.py b/Test/test_time_gap_multi_write.py
index ba7ce3a..05e2b53 100644
--- a/Test/test_time_gap_multi_write.py
+++ b/Test/test_time_gap_multi_write.py
@@ -2,7 +2,7 @@ import cmor
import numpy
def cmor_initialisation():
- cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
netcdf_file_action = cmor.CMOR_REPLACE_3,
create_subdirectories = 0)
cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
@@ -14,7 +14,7 @@ def cmor_initialisation():
parent_experiment_rip = 'N/A',
branch_time = 0.,
contact = 'bob',
- outpath = '/data/local/hadju/test')
+ outpath = 'hadju/test')
def setup_data():
axes = [ {'table_entry': 'time',
@@ -49,8 +49,8 @@ def cmor_define_and_write(values, axes):
positive = 'up'
)
- for time in (15, 17):
- cmor.write(varid, values, time_vals = [time], time_bnds = [time - 0.5, time + 0.5])
+ for time in (15, 16, 17):
+ cmor.write(varid, values, time_vals = [time], time_bnds = [time - 0.45, time + 0.45])
def version(cmor):
return '%s.%s.%s' % (cmor.CMOR_VERSION_MAJOR,
diff --git a/Test/test_time_gap_single_write1.py b/Test/test_time_gap_single_write1.py
index c98096d..dc0302f 100644
--- a/Test/test_time_gap_single_write1.py
+++ b/Test/test_time_gap_single_write1.py
@@ -2,7 +2,7 @@ import cmor
import numpy
def cmor_initialisation():
- cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
netcdf_file_action = cmor.CMOR_REPLACE_3,
create_subdirectories = 0)
cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
@@ -14,7 +14,7 @@ def cmor_initialisation():
parent_experiment_rip = 'N/A',
branch_time = 0.,
contact = 'bob',
- outpath = '/data/local/hadju/test')
+ outpath = 'hadju/test')
def setup_data():
axes = [ {'table_entry': 'time',
diff --git a/Test/test_time_gap_single_write2.py b/Test/test_time_gap_single_write2.py
index f4c54de..e00420e 100644
--- a/Test/test_time_gap_single_write2.py
+++ b/Test/test_time_gap_single_write2.py
@@ -3,7 +3,7 @@ import cmor
import numpy
def cmor_initialisation():
- cmor.setup(inpath='/net/home/h03/hadju/Projects/MipTables/cmip5-cmor-tables/Tables',
+ cmor.setup(inpath='/git/cmip5-cmor-tables/Tables',
netcdf_file_action = cmor.CMOR_REPLACE_3,
create_subdirectories = 0)
cmor.dataset('pre-industrial control', 'ukmo', 'HadCM3', '360_day',
@@ -15,7 +15,7 @@ def cmor_initialisation():
parent_experiment_rip = 'N/A',
branch_time = 0.,
contact = 'bob',
- outpath = '/data/local/hadju/test')
+ outpath = 'hadju/test')
def setup_data():
axes = [ {'table_entry': 'time1',
diff --git a/include/cmor.h b/include/cmor.h
index d5fb492..31f61e4 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -184,6 +184,8 @@ typedef struct cmor_var_ {
int nc_zfactors[CMOR_MAX_VARIABLES];
int nzfactor;
int ntimes_written;
+ double last_time_written;
+ double last_time_bounds_written[2];
int ntimes_written_coords[10];
int associated_ids[10];
int ntimes_written_associated[10];
--
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