[cmor] 32/190: 2010-06-14 : expanded the CMOR_MAX_GRIDS to 100 form 10. And replaced the "10" in the code with CMOR_MAX_GRIDS 2010-06-14 : updated python example and testtable to work w/o error about abs mean
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:33 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 dc39d23c090d9c513746ba47a32d2bc69b31074e
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Mon Jun 14 12:42:43 2010 -0700
2010-06-14 : expanded the CMOR_MAX_GRIDS to 100 form 10. And replaced the "10" in the code with CMOR_MAX_GRIDS
2010-06-14 : updated python example and testtable to work w/o error about abs mean
---
Doc/cmor_users_guide.doc | Bin 360448 -> 357376 bytes
RELEASE-NOTES | 2 ++
Src/cmor.c | 2 +-
Src/cmor_fortran_interface.f90 | 4 +--
Src/cmor_grids.c | 30 ++++++++---------
Src/cmor_variables.c | 12 +++----
Test/test_python_common.py | 4 +--
Test/test_python_jamie.py | 2 +-
Test/test_python_jamie_2.py | 4 +--
Test/test_python_jamie_6.py | 2 +-
Test/test_python_joerg_2.py | 2 +-
Test/test_python_joerg_3.py | 2 +-
Test/test_python_memory_check.py | 6 ++--
Test/test_python_open_close_cmor_multiple.py | 2 +-
TestTables/CMIP5_6hrLev | 48 +++++++++++++++++++++++++++
include/cmor.h | 4 +--
16 files changed, 88 insertions(+), 38 deletions(-)
diff --git a/Doc/cmor_users_guide.doc b/Doc/cmor_users_guide.doc
index 8ea579f..b495bc0 100644
Binary files a/Doc/cmor_users_guide.doc and b/Doc/cmor_users_guide.doc differ
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index c7e27db..1c2c240 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,5 @@
+2010-06-14 : expanded the CMOR_MAX_GRIDS to 100 form 10. And replaced the "10" in the code with CMOR_MAX_GRIDS
+2010-06-14 : updated python example and testtable to work w/o error about abs mean
2010-06-11 : shorten the TestTables to a minimum so they can't be confused with the real one and used in production
2010-06-11 : removed tables unused by examples
2010-06-11 : add ${Prefix}/share to the list of locations where to search for tables
diff --git a/Src/cmor.c b/Src/cmor.c
index 9d0a86b..71cbc5b 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -2666,7 +2666,7 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
ierr = cmor_put_nc_char_attribute(ncafid,m,"grid_mapping_name",cmor_grids[cmor_vars[var_id].grid_id].mapping,cmor_vars[var_id].id);
for (k=0;k<cmor_grids[cmor_vars[var_id].grid_id].nattributes;k++){
if (strcmp(cmor_grids[cmor_vars[var_id].grid_id].attributes_names[k],"standard_parallel1")==0 ||strcmp(cmor_grids[cmor_vars[var_id].grid_id].attributes_names[k],"standard_parallel2")==0 ){
- i = -cmor_vars[var_id].grid_id-10;
+ i = -cmor_vars[var_id].grid_id-CMOR_MAX_GRIDS;
if ((cmor_has_grid_attribute(i,"standard_parallel1")==0) && (cmor_has_grid_attribute(i,"standard_parallel2")==0)) {
cmor_get_grid_attribute(i,"standard_parallel1",&tmps[0]);
cmor_get_grid_attribute(i,"standard_parallel2",&tmps[1]);
diff --git a/Src/cmor_fortran_interface.f90 b/Src/cmor_fortran_interface.f90
index f6a8eea..91c6f45 100644
--- a/Src/cmor_fortran_interface.f90
+++ b/Src/cmor_fortran_interface.f90
@@ -897,12 +897,12 @@ module cmor_users_functions
integer, parameter:: CMOR_MAX_ELEMENTS = 500
integer, parameter:: CMOR_MAX_AXES = CMOR_MAX_ELEMENTS*3
integer, parameter:: CMOR_MAX_VARIABLES = CMOR_MAX_ELEMENTS
- integer, parameter:: CMOR_MAX_GRIDS = 10
+ integer, parameter:: CMOR_MAX_GRIDS = 100
integer, parameter:: CMOR_MAX_DIMENSIONS = 7
integer, parameter:: CMOR_MAX_ATTRIBUTES = 100
integer, parameter:: CMOR_MAX_ERRORS = 10
integer, parameter:: CMOR_MAX_TABLES = 10
- integer, parameter:: CMOR_MAX_GRID_ATTRIBUTES = 15
+ integer, parameter:: CMOR_MAX_GRID_ATTRIBUTES = 25
integer, parameter:: CMOR_QUIET = 0
diff --git a/Src/cmor_grids.c b/Src/cmor_grids.c
index b799ddc..d0c9498 100644
--- a/Src/cmor_grids.c
+++ b/Src/cmor_grids.c
@@ -52,7 +52,7 @@ int cmor_copy_data(double **dest1, void *data, char type, int nelts) {
int cmor_has_grid_attribute(int gid, char *name) {
int i;
int grid_id;
- grid_id=-gid-10;
+ grid_id=-gid-CMOR_MAX_GRIDS;
for (i=0;i<cmor_grids[grid_id].nattributes;i++) {
if (strcmp(name,cmor_grids[grid_id].attributes_names[i])==0) return 0;
}
@@ -62,7 +62,7 @@ int cmor_has_grid_attribute(int gid, char *name) {
int cmor_get_grid_attribute(int gid, char *name, double *value) {
int i,j;
int grid_id;
- grid_id=-gid-10;
+ grid_id=-gid-CMOR_MAX_GRIDS;
j=-1;
for (i=0;i<cmor_grids[grid_id].nattributes;i++) {
if (strcmp(name,cmor_grids[grid_id].attributes_names[i])==0) j=i;
@@ -120,7 +120,7 @@ int cmor_set_grid_attribute(int gid, char *name, double *value, char *units) {
double tmp;
cmor_add_traceback("cmor_set_grid_attribute");
- grid_id=-gid-10;
+ grid_id=-gid-CMOR_MAX_GRIDS;
iatt = cmor_grids[grid_id].nattributes;
tmp = *value;
@@ -429,7 +429,7 @@ int cmor_set_grid_mapping(int gid, char *name, int nparam, char **attributes_nam
bchar += lnunits;
}
/* for(i=0;i<nparam;i++) printf("ok paramter: %i is: %s, with value %lf and units '%s'\n",i,lattributes_names[i],attributes_values[i],lunits[i]); */
- grid_id = -gid-10;
+ grid_id = -gid-CMOR_MAX_GRIDS;
/* reads in grid definitions */
cmor_grid_valid_mapping_attribute_names(name, &nattributes, grid_attributes,&ndims,grid_dimensions);
@@ -502,7 +502,7 @@ int cmor_time_varying_grid_coordinate(int *coord_grid_id, int grid_id, char *ta
char msg[CMOR_MAX_STRING];
int ctype=-1;
double *dummy_values;
- int nvertices=cmor_grids[-grid_id-10].nvertices;
+ int nvertices=cmor_grids[-grid_id-CMOR_MAX_GRIDS].nvertices;
axes[0]=grid_id;
@@ -511,9 +511,9 @@ int cmor_time_varying_grid_coordinate(int *coord_grid_id, int grid_id, char *ta
strcpy(msg,"not found");
if (coordinate_type == NULL) {
- for (j=0;j<cmor_tables[cmor_axes[cmor_grids[-grid_id-10].axes_ids[0]].ref_table_id].nvars;j++) {
- if (strcmp(cmor_tables[cmor_axes[cmor_grids[-grid_id-10].axes_ids[0]].ref_table_id].vars[j].id,table_entry)==0) {
- strncpy(msg,cmor_tables[cmor_axes[cmor_grids[-grid_id-10].axes_ids[0]].ref_table_id].vars[j].standard_name,CMOR_MAX_STRING);
+ for (j=0;j<cmor_tables[cmor_axes[cmor_grids[-grid_id-CMOR_MAX_GRIDS].axes_ids[0]].ref_table_id].nvars;j++) {
+ if (strcmp(cmor_tables[cmor_axes[cmor_grids[-grid_id-CMOR_MAX_GRIDS].axes_ids[0]].ref_table_id].vars[j].id,table_entry)==0) {
+ strncpy(msg,cmor_tables[cmor_axes[cmor_grids[-grid_id-CMOR_MAX_GRIDS].axes_ids[0]].ref_table_id].vars[j].standard_name,CMOR_MAX_STRING);
break;
}
}
@@ -546,10 +546,10 @@ int cmor_time_varying_grid_coordinate(int *coord_grid_id, int grid_id, char *ta
for (j=0;j<nvertices;j++) dummy_values[j]=(double)j;
cmor_axis(&axes[1],"vertices","1",nvertices,dummy_values,'d',NULL,0,NULL);
free(dummy_values);
- cmor_grids[-grid_id-10].nvertices = axes[1];
+ cmor_grids[-grid_id-CMOR_MAX_GRIDS].nvertices = axes[1];
}
else {
- axes[1] = cmor_grids[-grid_id-10].nvertices;
+ axes[1] = cmor_grids[-grid_id-CMOR_MAX_GRIDS].nvertices;
}
ierr = cmor_variable(coord_grid_id,table_entry,units,2,axes,type,missing,NULL,NULL,NULL,NULL,NULL);
cmor_grids[cmor_vars[*coord_grid_id].grid_id].associated_variables[2] = *coord_grid_id;
@@ -574,10 +574,10 @@ int cmor_time_varying_grid_coordinate(int *coord_grid_id, int grid_id, char *ta
for (j=0;j<nvertices;j++) dummy_values[j]=(double)j;
cmor_axis(&axes[1],"vertices","1",nvertices,dummy_values,'d',NULL,0,NULL);
free(dummy_values);
- cmor_grids[-grid_id-10].nvertices = axes[1];
+ cmor_grids[-grid_id-CMOR_MAX_GRIDS].nvertices = axes[1];
}
else {
- axes[1] = cmor_grids[-grid_id-10].nvertices;
+ axes[1] = cmor_grids[-grid_id-CMOR_MAX_GRIDS].nvertices;
}
ierr = cmor_variable(coord_grid_id,table_entry,units,2,axes,type,missing,NULL,NULL,NULL,NULL,NULL);
cmor_grids[cmor_vars[*coord_grid_id].grid_id].associated_variables[3] = *coord_grid_id;
@@ -644,7 +644,7 @@ int cmor_grid(int *grid_id, int ndims, int *axes_ids, char type, void *lat, void
}
}
else {
- axes[0]=-cmor_ngrids-10;
+ axes[0]=-cmor_ngrids-CMOR_MAX_GRIDS;
if (cmor_grids[cmor_ngrids].istimevarying != 1) {
cmor_copy_data(&cmor_grids[cmor_ngrids].lats,lat,type,n);
cmor_variable(&cmor_grids[cmor_ngrids].associated_variables[0],"latitude","degrees_north",1,&axes[0],'d',NULL,NULL,NULL,NULL,NULL,NULL);
@@ -662,7 +662,7 @@ int cmor_grid(int *grid_id, int ndims, int *axes_ids, char type, void *lat, void
}
else {
cmor_copy_data(&cmor_grids[cmor_ngrids].lons,lon,type,n);
- axes[0]=-cmor_ngrids-10;
+ axes[0]=-cmor_ngrids-CMOR_MAX_GRIDS;
/* for (i=0;i<5;i++) printf("%i: %lf\n",i,cmor_grids[cmor_ngrids].lons[i]); */
cmor_variable(&cmor_grids[cmor_ngrids].associated_variables[1],"longitude","degrees_east",1,&axes[0],'d',NULL,NULL,NULL,NULL,NULL,NULL);
cmor_vars[cmor_grids[cmor_ngrids].associated_variables[1]].needsinit=0;
@@ -727,7 +727,7 @@ int cmor_grid(int *grid_id, int ndims, int *axes_ids, char type, void *lat, void
/* cmor_variable(&cmor_grids[cmor_ngrids].associated_variables[4],"area","m2",1,&axes[0],'d',NULL,NULL,NULL,NULL,NULL,NULL); */
/* cmor_vars[cmor_grids[cmor_ngrids].associated_variables[4]].needsinit=0; */
/* } */
- *grid_id = -cmor_ngrids-10;
+ *grid_id = -cmor_ngrids-CMOR_MAX_GRIDS;
cmor_pop_traceback();
return 0;
}
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index 79c406e..044f47a 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -223,7 +223,7 @@ int cmor_zfactor (int *zvar_id,int axis_id, char *name, char *units, int ndims,
}
else {
/* ok irregular grid */
- gid = -axes_ids[i]-10;
+ gid = -axes_ids[i]-CMOR_MAX_GRIDS;
for (j=0;j<cmor_grids[gid].ndims;j++) {
n*=cmor_axes[cmor_grids[gid].axes_ids[j]].length;
}
@@ -296,7 +296,7 @@ int cmor_zfactor (int *zvar_id,int axis_id, char *name, char *units, int ndims,
}
else {
/* ok irregular grid */
- gid = -axes_ids[i]-10;
+ gid = -axes_ids[i]-CMOR_MAX_GRIDS;
for (j=0;j<cmor_grids[gid].ndims;j++) {
if (cmor_axes[cmor_grids[gid].axes_ids[j]].axis=='T') {
k=1;
@@ -695,13 +695,13 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
/* ok we need to replace grids definitions with the grid axes */
for (i=0;i<ndims;i++) {
if (laxes_ids[i]<-9) { /* grid definition */
- grid_id = -laxes_ids[i]-10;
+ grid_id = -laxes_ids[i]-CMOR_MAX_GRIDS;
/* here we need to know if the refvar has been defined with lat/lon or in the grid space */
k=0;
for (j=0;j<refvar.ndims;j++) {
if (strcmp(cmor_tables[refvar.table_id].axes[refvar.dimensions[j]].id,"longitude")==0) k++;
if (strcmp(cmor_tables[refvar.table_id].axes[refvar.dimensions[j]].id,"latitude")==0) k++;
- if (refvar.dimensions[j]==-10) k++;
+ if (refvar.dimensions[j]==-CMOR_MAX_GRIDS) k++;
}
if (k==2) {
aint = cmor_grids[grid_id].ndims-2; /* basically replaces the lat/lon with the number of dims in our grid */
@@ -860,7 +860,7 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
}
k++;
}
- else if (refvar.dimensions[i]==-10) {
+ else if (refvar.dimensions[i]==-CMOR_MAX_GRIDS) {
/* ok this is either a lat/lon */
for(j=0;j<ndims;j++) if (axes_ids[j]<-9) break;
l=j;
@@ -1012,7 +1012,7 @@ int cmor_set_var_def_att(cmor_var_def_t *var,char att[CMOR_MAX_STRING],char val[
snprintf(msg,CMOR_MAX_STRING,"Reading table: axis name: '%s' for variable: '%s' is not defined in table. Table defines dimensions: '%s' for this variable",dim,var->id,val);cmor_handle_error(msg,CMOR_CRITICAL);
}
else {
- var->dimensions[var->ndims]=-10;
+ var->dimensions[var->ndims]=-CMOR_MAX_GRIDS;
}
}
}
diff --git a/Test/test_python_common.py b/Test/test_python_common.py
index 579de2b..c4566b2 100644
--- a/Test/test_python_common.py
+++ b/Test/test_python_common.py
@@ -112,8 +112,8 @@ def read_3d_input_files(it, varname, n0, n1, n2, ntimes):
def read_2d_input_files(it, varname, n0, n1):
if varname=="LATENT":
- factor = 1.;
- offset = 120.;
+ factor = 1.25;
+ offset = 100.;
elif varname == "TSURF":
factor = 2.0;
offset = -230.;
diff --git a/Test/test_python_jamie.py b/Test/test_python_jamie.py
index f184c82..d92c624 100644
--- a/Test/test_python_jamie.py
+++ b/Test/test_python_jamie.py
@@ -30,7 +30,7 @@ def path_test():
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
varid = cmor.variable('ts', 'K', axis_ids)
- cmor.write(varid, [273])
+ cmor.write(varid, [275])
path=cmor.close(varid, file_name=True)
print path
diff --git a/Test/test_python_jamie_2.py b/Test/test_python_jamie_2.py
index 1634159..6c4c36f 100644
--- a/Test/test_python_jamie_2.py
+++ b/Test/test_python_jamie_2.py
@@ -27,10 +27,10 @@ def multi_call_test():
axis_id = cmor.axis(**axis)
axis_ids.append(axis_id)
varid = cmor.variable('ts', 'K', axis_ids)
- cmor.write(varid, [273], time_vals = [15], time_bnds = [ [0,30] ])
+ cmor.write(varid, [275], time_vals = [15], time_bnds = [ [0,30] ])
print 'First write worked as expected'
try:
- cmor.write(varid, [273], time_vals = [15], time_bnds = [ [0], [30] ])
+ cmor.write(varid, [275], time_vals = [15], time_bnds = [ [0], [30] ])
raise Exception,"We shouldn't be getting in here"
except:
print 'Second write that should have failed did fail, good!'
diff --git a/Test/test_python_jamie_6.py b/Test/test_python_jamie_6.py
index a332212..9b04a95 100644
--- a/Test/test_python_jamie_6.py
+++ b/Test/test_python_jamie_6.py
@@ -155,7 +155,7 @@ for it in range(ntimes):
time = numpy.array((it))
bnds_time = numpy.array((it,it+1))
- data3d = numpy.random.random((5,360,180)).astype('f')*100.
+ data3d = numpy.random.random((5,360,180)).astype('f')*40.
error_flag = cmor.write(
var_id = var3d_ids,
diff --git a/Test/test_python_joerg_2.py b/Test/test_python_joerg_2.py
index 7142930..f72dd0f 100644
--- a/Test/test_python_joerg_2.py
+++ b/Test/test_python_joerg_2.py
@@ -56,7 +56,7 @@ def test_mode(mode,i,suffix=''):
'coord_vals': levels},
]
- values = numpy.array(range(len(levels)), numpy.float32)+175
+ values = numpy.array(range(len(levels)), numpy.float32)+195
axis_ids = list()
for axis in axes:
axis_id = cmor.axis(**axis)
diff --git a/Test/test_python_joerg_3.py b/Test/test_python_joerg_3.py
index 6e1068d..c06412c 100644
--- a/Test/test_python_joerg_3.py
+++ b/Test/test_python_joerg_3.py
@@ -135,7 +135,7 @@ for d in range(2):
data=data.astype("f")
cmor.write(ivar2,data,time_vals=tval,time_bnds=tbnd,file_suffix=file_suffix2)
print 'wrote var 2 time:',i
- data=numpy.random.random((ntimes,nlat,nlon))*50.+101300.
+ data=numpy.random.random((ntimes,nlat,nlon))*8.+96300.
data=data.astype("f")
cmor.write(ips1,data,store_with=ivar1,ntimes_passed=1,time_vals=tval,time_bnds=tbnd)
print 'wrote ps in var 1 time:',i
diff --git a/Test/test_python_memory_check.py b/Test/test_python_memory_check.py
index 17dc6cb..bdbe74d 100644
--- a/Test/test_python_memory_check.py
+++ b/Test/test_python_memory_check.py
@@ -114,13 +114,13 @@ def memory_check():
memi,resi,stki = memory_usage(sys.stdout)
for time in range(ntimes):
- a = [273]
+ a = [275]
if passtime:
tval = [15 + time*30]
tbounds = [time*30, (time + 1)*30]
- cmor.write(varid, [273], time_vals = tval, time_bnds = tbounds)
+ cmor.write(varid, [275], time_vals = tval, time_bnds = tbounds)
else:
- cmor.write(varid, [273])
+ cmor.write(varid, [275])
mem,res,stk = memory_usage(sys.stdout,mem,res,stk)
#mem,res,stk = memory_usage(sys.stdout,memi,resi,stki)
print '---'
diff --git a/Test/test_python_open_close_cmor_multiple.py b/Test/test_python_open_close_cmor_multiple.py
index 895d497..7891bbc 100644
--- a/Test/test_python_open_close_cmor_multiple.py
+++ b/Test/test_python_open_close_cmor_multiple.py
@@ -3,7 +3,7 @@ import cmor,numpy
-vars ={'hfls' : ['W.m-2',25.,30.],'tas':['K',25,273.15],'clt':['%',100.,0.],'ta':['K',25,273.15]}
+vars ={'hfls' : ['W.m-2',25.,40.],'tas':['K',25,268.15],'clt':['%',100.,0.],'ta':['K',25,273.15]}
nlat = 90
diff --git a/TestTables/CMIP5_6hrLev b/TestTables/CMIP5_6hrLev
index 04877ff..bc9b6a9 100644
--- a/TestTables/CMIP5_6hrLev
+++ b/TestTables/CMIP5_6hrLev
@@ -525,4 +525,52 @@ ok_min_mean_abs: -0.0003539
ok_max_mean_abs: 0.01027
!----------------------------------
!
+!============
+variable_entry: ta
+!============
+modeling_realm: atmos
+!----------------------------------
+! Variable attributes:
+!----------------------------------
+standard_name: air_temperature
+units: K
+cell_measures: area: areacella
+long_name: Air Temperature
+comment: on all model levels
+!----------------------------------
+! Additional variable information:
+!----------------------------------
+dimensions: longitude latitude alevel time1
+out_name: ta
+type: real
+valid_min: 157.1
+valid_max: 326.4
+ok_min_mean_abs: 200.2
+ok_max_mean_abs: 289.9
+!----------------------------------
+
+!============
+variable_entry: ps
+!============
+modeling_realm: atmos
+!----------------------------------
+! Variable attributes:
+!----------------------------------
+standard_name: surface_air_pressure
+units: Pa
+cell_measures: area: areacella
+long_name: Surface Air Pressure
+comment: surface pressure, not mean sea level pressure
+!----------------------------------
+! Additional variable information:
+!----------------------------------
+dimensions: longitude latitude time1
+out_name: ps
+type: real
+valid_min: 4.792e+04
+valid_max: 1.093e+05
+ok_min_mean_abs: 9.606e+04
+ok_max_mean_abs: 9.743e+04
+!----------------------------------
+!
diff --git a/include/cmor.h b/include/cmor.h
index 1b7dba0..986a8b1 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -5,12 +5,12 @@
#define CMOR_MAX_ELEMENTS 500
#define CMOR_MAX_AXES CMOR_MAX_ELEMENTS*3
#define CMOR_MAX_VARIABLES CMOR_MAX_ELEMENTS
-#define CMOR_MAX_GRIDS 10
+#define CMOR_MAX_GRIDS 100
#define CMOR_MAX_DIMENSIONS 7
#define CMOR_MAX_ATTRIBUTES 100
#define CMOR_MAX_ERRORS 10
#define CMOR_MAX_TABLES 10
-#define CMOR_MAX_GRID_ATTRIBUTES 15
+#define CMOR_MAX_GRID_ATTRIBUTES 25
#define CMOR_QUIET 0
--
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