[cmor] 61/190: need to test this under Linux
Alastair McKinstry
mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:38 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 268f94dea550fb6062280f15c8280745a2a803a2
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date: Thu Oct 21 15:46:59 2010 -0700
need to test this under Linux
---
Lib/__init__.py | 2 +-
Lib/pywrapper.py | 48 +++++++++++++++++++++++++++++++++++++++++++--
Src/_cmormodule.c | 44 +++++++++++++++++++++++++++++++++++++++++
Src/cmor.c | 6 +++---
Src/cmor_variables.c | 49 +++++++++++++++++++++++++++++++---------------
Test/test_python_common.py | 2 +-
configure | 18 ++++++++---------
configure.ac | 2 +-
include/cmor.h | 14 +++++++------
9 files changed, 146 insertions(+), 39 deletions(-)
diff --git a/Lib/__init__.py b/Lib/__init__.py
index 49c36f0..4b54fa6 100644
--- a/Lib/__init__.py
+++ b/Lib/__init__.py
@@ -1,6 +1,6 @@
from cmor_const import *
-from pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path
+from pywrapper import axis,variable,write,setup,load_table,dataset,set_table,zfactor,close,grid,set_grid_mapping,time_varying_grid_coordinate,set_cur_dataset_attribute,get_cur_dataset_attribute,has_cur_dataset_attribute,create_output_path,set_variable_attribute,get_variable_attribute,has_variable_attribute
try:
from check_CMOR_compliant import checkCMOR
diff --git a/Lib/pywrapper.py b/Lib/pywrapper.py
index e0a2bea..c1e8aeb 100644
--- a/Lib/pywrapper.py
+++ b/Lib/pywrapper.py
@@ -871,7 +871,7 @@ def set_cur_dataset_attribute(name,value):
val = str(value)
return _cmor.set_cur_dataset_attribute(name,val)
-def has_cur_dataset_attribute(name,value):
+def has_cur_dataset_attribute(name):
"""determines if the current cmor dataset has an attribute
Usage:
cmor.het_cur_dataset_attribute(name)
@@ -886,7 +886,7 @@ def has_cur_dataset_attribute(name,value):
return False
def get_cur_dataset_attribute(name):
- """Gets an attribute onto the current cmor dataset
+ """Gets an attribute from the current cmor dataset
Usage:
cmor.get_cur_dataset_attribute(name)
Where:
@@ -898,6 +898,50 @@ def get_cur_dataset_attribute(name):
else:
return None
+def set_variable_attribute(var_id,name,value):
+ """Sets an attribute onto a cmor variable
+ Usage:
+ cmor.set_variable_attribute(var_id,name,value)
+ Where:
+ var_id: is cmor variable id
+ name : is the name of the attribute
+ value : is the value for this attribute
+ """
+ if value is None:
+ val=""
+ else:
+ val = str(value)
+ return _cmor.set_variable_attribute(var_id,name,val)
+
+def has_variable_attribute(var_id,name):
+ """determines if the a cmor variable has an attribute
+ Usage:
+ cmor.het_variable_attribute(name)
+ Where:
+ var_id: is cmor variable id
+ name: is the name of the attribute
+ Returns True if the dataset has the attribute, False otherwise
+ """
+ test = _cmor.has_variable_attribute(var_id,name)
+ if test == 0 :
+ return True
+ else:
+ return False
+
+def get_variable_attribute(var_id,name):
+ """Gets an attribute from a cmor variable
+ Usage:
+ cmor.get_variable_attribute(name)
+ Where:
+ var_id: is cmor variable id
+ name: is the name of the attribute
+ Returns none if attribute is non-existant
+ """
+ if has_variable_attribute(name):
+ return _cmor.get_variable_attribute(var_id,name)
+ else:
+ return None
+
def create_output_path(varid):
"""returns the output path where a variable would be stored, given a varid (as returned by a call to cmor.variable)
diff --git a/Src/_cmormodule.c b/Src/_cmormodule.c
index 1987caa..93f6a65 100644
--- a/Src/_cmormodule.c
+++ b/Src/_cmormodule.c
@@ -70,6 +70,47 @@ static PyObject *
return Py_BuildValue("i",ierr);
}
+
+static PyObject *
+ PyCMOR_set_variable_attribute(PyObject *self,PyObject *args)
+{
+ char *name;
+ char *value;
+ int ierr, var_id;
+ if (!PyArg_ParseTuple(args,"iss",&var_id,&name,&value))
+ return NULL;
+ printf("ok set %s, to %s on %i\n",name,value,var_id);
+ ierr = cmor_set_variable_attribute(var_id,name,'c',(void *)value);
+ printf("ok we got err: %i\n",ierr);
+ if (ierr != 0 ) return NULL;
+ /* Return NULL Python Object */
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+static PyObject *
+ PyCMOR_get_variable_attribute(PyObject *self,PyObject *args)
+{
+ char *name;
+ char value[CMOR_MAX_STRING];
+ int ierr, *var_id;
+ if (!PyArg_ParseTuple(args,"is",&var_id,&name))
+ return NULL;
+ ierr = cmor_get_variable_attribute(*var_id,name,(void *)value);
+ if (ierr != 0 ) return NULL;
+ return Py_BuildValue("s",value);
+}
+
+static PyObject *
+ PyCMOR_has_variable_attribute(PyObject *self,PyObject *args)
+{
+ char *name;
+ int ierr, *var_id;
+ if (!PyArg_ParseTuple(args,"is",&var_id,&name))
+ return NULL;
+ ierr = cmor_has_variable_attribute(*var_id,name);
+ return Py_BuildValue("i",ierr);
+}
+
static PyObject *
PyCMOR_setup(PyObject *self,PyObject *args)
{
@@ -749,6 +790,9 @@ static PyMethodDef MyExtractMethods[]= {
{"set_cur_dataset_attribute",PyCMOR_set_cur_dataset_attribute, METH_VARARGS},
{"get_cur_dataset_attribute",PyCMOR_get_cur_dataset_attribute, METH_VARARGS},
{"has_cur_dataset_attribute",PyCMOR_has_cur_dataset_attribute, METH_VARARGS},
+ {"set_variable_attribute",PyCMOR_set_variable_attribute, METH_VARARGS},
+ {"get_variable_attribute",PyCMOR_get_variable_attribute, METH_VARARGS},
+ {"has_variable_attribute",PyCMOR_has_variable_attribute, METH_VARARGS},
{"create_output_path",PyCMOR_create_output_path, METH_VARARGS},
{"get_original_shape",PyCMOR_get_original_shape, METH_VARARGS},
{NULL, NULL} /*sentinel */
diff --git a/Src/cmor.c b/Src/cmor.c
index 46eaefc..2881099 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -2097,9 +2097,9 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
strncat(ctmp,ctmp3,CMOR_MAX_STRING-strlen(ctmp));
- if (cmor_has_variable_attribute(var_id,"cell_measures")==0) {
+ if (cmor_has_variable_attribute(var_id,"ext_cell_measures")==0) {
/*Ok does it contain "area" */
- cmor_get_variable_attribute(var_id,"cell_measures",&ctmp5[0]);
+ cmor_get_variable_attribute(var_id,"ext_cell_measures",&ctmp5[0]);
k=-1;
for (i=0;i<strlen(ctmp5)-5;i++) {
if (strncmp(&ctmp5[i],"area:",5)==0) {
@@ -3112,7 +3112,7 @@ int cmor_write(int var_id,void *data, char type, char *suffix, int ntimes_passed
}
}
}
-
+
/* ok now write the zfactor values if necessary */
for(i=0;i<nzfactors;i++) {
if (cmor_vars[zfactors[i]].values != NULL) {/* ok this one has value defined we need to store it */
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index aa969c6..eab22f5 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -78,17 +78,24 @@ int cmor_set_variable_attribute(int id, char *attribute_name, char type, void *v
int i,index;
char msg[CMOR_MAX_STRING];
cmor_add_traceback("cmor_set_variable_attribute");
+
+ if (type=='c') printf("in C: setting %s, to %s on var: %i\n",attribute_name, value, id);
cmor_is_setup();
index=-1;
cmor_trim_string(attribute_name,msg);
for (i=0;i<cmor_vars[id].nattributes;i++) {
if (strcmp(cmor_vars[id].attributes[i],msg)==0) {index=i;break;} /* we found it */
}
+ printf("ok it is found at index: %i\n",index);
if (index==-1) {index=cmor_vars[id].nattributes; cmor_vars[id].nattributes+=1;}
+ printf("ok we now operate on index: %i, i is: %i\n",index,i);
strncpy(cmor_vars[id].attributes[index],msg,CMOR_MAX_STRING); /*stores the name */
- cmor_vars[id].attributes_type[i]=type;
+ printf("copied attribute name (%s)\n",cmor_vars[id].attributes[index]);
+ cmor_vars[id].attributes_type[index]=type;
+ printf("copied type: %c\n",type);
if (type=='c') {
if (strlen(value)>0) {
+ printf("strlen is: %i\n",strlen(value));
strncpytrim(cmor_vars[id].attributes_values_char[index],value,CMOR_MAX_STRING);
}
else {
@@ -643,7 +650,7 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
cmor_update_history(vrid,msg);
}
cmor_set_variable_attribute(vrid,"cell_methods",'c',refvar.cell_methods);
- cmor_set_variable_attribute(vrid,"cell_measures",'c',refvar.cell_measures);
+ cmor_set_variable_attribute(vrid,"ext_cell_measures",'c',refvar.cell_measures);
/*if ((refvar.positive!='\0') && (positive!=NULL) && (positive[0]!=refvar.positive)) cmor_vars[vrid].sign=-1;*/
if ((positive!=NULL) && (positive[0]!='\0')) {
if ((positive[0]!='d') && positive[0]!='u') {
@@ -691,7 +698,7 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
laxes_ids[i] = axes_ids[i];
}
lndims=ndims;
-/* printf("ok ndims is actually: %i\n",ndims); */
+ /* printf("ok ndims is actually: %i\n",ndims); */
aint=0; /* just to know if we deal with a grid */
/* ok we need to replace grids definitions with the grid axes */
for (i=0;i<ndims;i++) {
@@ -727,14 +734,14 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
}
}
}
-/* printf("&&&&&&&&&&&&&&&&&&&&&&&&&&&&& refvar (%s), has: %i dimensions! aint: %i, lndims: %i\n",refvar.id,refvar.ndims,aint,lndims); */
-/* for(i=0;i<lndims;i++) fprintf(stderr,"after the grid id section: %i, id: %i\n",i,laxes_ids[i]); */
+ /* printf("&&&&&&&&&&&&&&&&&&&&&&&&&&&&& refvar (%s), has: %i dimensions! aint: %i, lndims: %i\n",refvar.id,refvar.ndims,aint,lndims); */
+ /* for(i=0;i<lndims;i++) fprintf(stderr,"after the grid id section: %i, id: %i\n",i,laxes_ids[i]); */
olndims = lndims;
if (refvar.ndims+aint!=lndims) {
lndims=0;
/* ok before we panic we check if there is a "dummy" dim */
j=refvar.ndims-olndims+aint;
-/* printf("at the start: refvar: %i, ndims: %i, aint: %i, lndims: %i, olndims: %i, j:%i\n",refvar.ndims,ndims,aint,lndims,olndims,j); */
+ /* printf("at the start: refvar: %i, ndims: %i, aint: %i, lndims: %i, olndims: %i, j:%i\n",refvar.ndims,ndims,aint,lndims,olndims,j); */
for (i=0;i<refvar.ndims;i++) {
/* printf("ok none matchng # of dims, i: %d, id: %s, value: %lf, lndims is: %d\n",i,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].id,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].value,olndims); */
if (cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].value!=1.e20) {
@@ -747,12 +754,13 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
else {
strcpy(msg,"nope");
}
-/* printf("k: %d, axes_id: %d, stdnm: %s, ref stdnm: %s\n",k,laxes_ids[k],msg,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].standard_name); */
+ /* printf("k: %d, axes_id: %d, stdnm: %s, ref stdnm: %s\n",k,laxes_ids[k],msg,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].standard_name); */
if (strcmp(msg,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].standard_name)==0) {
/* ok user did define this one on its own */
l=k;
break;
}
+ /* printf("And now l is: %i\n",l); */
}
if (l==-1) { /* ok it is a singleton dimension */
j-=1;
@@ -763,11 +771,11 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
else {
ierr = cmor_axis(&k,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].id,cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].units,1,&cmor_tables[CMOR_TABLE].axes[refvar.dimensions[i]].value,'d',NULL,0,"");
}
-/* printf("messing up laxes: %i, replacing from %i to %i\n",olndims,laxes_ids[olndims],k); */
+ /* printf("messing up laxes: %i, replacing from %i to %i\n",olndims,laxes_ids[olndims],k); */
laxes_ids[olndims]=k;
lndims+=1;
}
-/* printf("after l is :%i, j is: %i\n",l,j); */
+ /* printf("after l is :%i, j is: %i\n",l,j); */
}
}
@@ -779,6 +787,12 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
}
else {
lndims += ndims;
+ for (j=0;j<ndims;j++) {
+ /* printf("ok laxes_ids is: %i\n",axes_ids[j]); */
+ if (axes_ids[j]<-CMOR_MAX_GRIDS+1) { /* grid definition */
+ lndims+=cmor_grids[grid_id].ndims-1;
+ }
+ }
}
}
/* At that point we need to check that the dims we passed match what's in the refvar */
@@ -809,9 +823,9 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
}
k=0;
/* ok now loop thru axes */
-/* printf("lndims is: %i\n",lndims); */
+ /* printf("lndims is: %i\n",lndims); */
for (i=0;i<lndims;i++) {
-/* printf("i and k: %i, %i, %i \n",i,k,laxes_ids[i]); */
+ /* printf("i and k: %i, %i, %i \n",i,k,laxes_ids[i]); */
if (laxes_ids[i]>cmor_naxes) {
snprintf(msg,CMOR_MAX_STRING,"Axis %i not defined",axes_ids[i]);
cmor_handle_error(msg,CMOR_CRITICAL);
@@ -822,8 +836,8 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
snprintf(msg,CMOR_MAX_STRING,"While creating variable %s, you are passing axis %i (named %s) which has been defined using table %i (%s) but the current table is %i (%s) (and isgridaxis says: %i)",cmor_vars[vrid].id,laxes_ids[i],cmor_axes[laxes_ids[i]].id,cmor_axes[laxes_ids[i]].ref_table_id,cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].table_id,CMOR_TABLE,cmor_tables[CMOR_TABLE].table_id,cmor_axes[laxes_ids[i]].isgridaxis);
cmor_handle_error(msg,CMOR_CRITICAL);
}
-/* printf("ok: %s \n" , cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].axes[cmor_axes[laxes_ids[i]].ref_axis_id].id); */
-/* printf("ok: %lf \n" , cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].axes[cmor_axes[laxes_ids[i]].ref_axis_id].value); */
+ /* printf("ok: %s \n" , cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].axes[cmor_axes[laxes_ids[i]].ref_axis_id].id); */
+ /* printf("ok: %lf \n" , cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].axes[cmor_axes[laxes_ids[i]].ref_axis_id].value); */
if (cmor_tables[cmor_axes[laxes_ids[i]].ref_table_id].axes[cmor_axes[laxes_ids[i]].ref_axis_id].value != 1.e20) {
/*singleton dim */
snprintf(msg,CMOR_MAX_STRING,"Treated scalar dimension: '%s'",cmor_axes[laxes_ids[i]].id);
@@ -852,9 +866,9 @@ int cmor_variable(int *var_id, char *name, char *units, int ndims, int axes_ids[
/* Now figures out the real order... */
k=0;
-/* for (i=0;i<lndims;i++) { */
-/* printf("OK IN CMOR VAR (%s),ORIGINAL ORDER FOR %i is: %i\n",cmor_vars[vrid].id,i,cmor_vars[vrid].original_order[i]); */
-/* } */
+ for (i=0;i<lndims;i++) {
+ /* printf("OK IN CMOR VAR (%s),ORIGINAL ORDER FOR %i is: %i\n",cmor_vars[vrid].id,i,cmor_vars[vrid].original_order[i]); */
+ }
for (i=0;i<lndims;i++) {
if (((strcmp(cmor_tables[refvar.table_id].axes[refvar.dimensions[i]].id,"latitude")==0) ||
@@ -1066,6 +1080,9 @@ int cmor_set_var_def_att(cmor_var_def_t *var,char att[CMOR_MAX_STRING],char val[
else if (strcmp(att,"cell_methods")==0) {
strncpy(var->cell_methods,val,CMOR_MAX_STRING);
}
+ else if (strcmp(att,"ext_cell_measures")==0) {
+ strncpy(var->cell_measures,val,CMOR_MAX_STRING);
+ }
else if (strcmp(att,"cell_measures")==0) {
strncpy(var->cell_measures,val,CMOR_MAX_STRING);
}
diff --git a/Test/test_python_common.py b/Test/test_python_common.py
index c4566b2..c278f4f 100644
--- a/Test/test_python_common.py
+++ b/Test/test_python_common.py
@@ -1,7 +1,7 @@
import numpy
# this test tries to mimic ippc_test_code.c but from python
# This one is using direct C calls from python not the python around it
-ntimes=2
+ntimes=5
lon=4
lat=3
lev=5
diff --git a/configure b/configure
index 7634a77..d3774b8 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for cmor 2.2.1.
+# Generated by GNU Autoconf 2.61 for cmor 2.3.0.
#
# Report bugs to <doutriaux1 at llnl.gov>.
#
@@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='cmor'
PACKAGE_TARNAME='cmor'
-PACKAGE_VERSION='2.2.1'
-PACKAGE_STRING='cmor 2.2.1'
+PACKAGE_VERSION='2.3.0'
+PACKAGE_STRING='cmor 2.3.0'
PACKAGE_BUGREPORT='doutriaux1 at llnl.gov'
ac_default_prefix=/usr/local/cmor
@@ -1185,7 +1185,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures cmor 2.2.1 to adapt to many kinds of systems.
+\`configure' configures cmor 2.3.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1251,7 +1251,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of cmor 2.2.1:";;
+ short | recursive ) echo "Configuration of cmor 2.3.0:";;
esac
cat <<\_ACEOF
@@ -1350,7 +1350,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-cmor configure 2.2.1
+cmor configure 2.3.0
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1364,7 +1364,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by cmor $as_me 2.2.1, which was
+It was created by cmor $as_me 2.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -4989,7 +4989,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by cmor $as_me 2.2.1, which was
+This file was extended by cmor $as_me 2.3.0, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -5032,7 +5032,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-cmor config.status 2.2.1
+cmor config.status 2.3.0
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index b1bfccb..81346b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.
dnl AC_PREREQ(2.59)
-AC_INIT(cmor, 2.2.1, doutriaux1 at llnl.gov)
+AC_INIT(cmor, 2.3.0, doutriaux1 at llnl.gov)
GIT_TAG=`./get_git_version.sh`
diff --git a/include/cmor.h b/include/cmor.h
index c15522f..048f13e 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -1,5 +1,13 @@
#ifndef CMOR_H
#define CMOR_H
+
+#define CMOR_VERSION_MAJOR 2
+#define CMOR_VERSION_MINOR 3
+#define CMOR_VERSION_PATCH 0
+
+#define CMOR_CF_VERSION_MAJOR 1
+#define CMOR_CF_VERSION_MINOR 4
+
#define CMOR_MAX_STRING 1024
#define CMOR_DEF_ATT_STR_LEN 256
#define CMOR_MAX_ELEMENTS 500
@@ -18,12 +26,6 @@
#define CMOR_EXIT 1
#define CMOR_EXIT_ON_WARNING 2
-#define CMOR_VERSION_MAJOR 2
-#define CMOR_VERSION_MINOR 2
-#define CMOR_VERSION_PATCH 1
-#define CMOR_CF_VERSION_MAJOR 1
-#define CMOR_CF_VERSION_MINOR 4
-
#define CMOR_WARNING 20
#define CMOR_NORMAL 21
#define CMOR_CRITICAL 22
--
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