Commit 27541093 authored by Keith Bennett's avatar Keith Bennett

Merge branch 'release/2.6.0'

parents 92c1b72c b47106a9
project(SDF_UTILITIES)
cmake_minimum_required(VERSION 2.8.11)
set(CFLAGS "${CMAKE_C_FLAGS}")
set(CXXFLAGS "${CMAKE_CXX_FLAGS}")
set(CFLAGS "${CMAKE_C_FLAGS} -g")
set(CXXFLAGS "${CMAKE_CXX_FLAGS} -g")
if(${CMAKE_BUILD_TYPE}x STREQUAL "Debugx")
add_definitions(-DSDF_DEBUG_ALL)
set(DEBUG_OPT --debug)
......
......@@ -7,7 +7,7 @@ PYTHONCMD=`which python`
clean=0
errcode=0
CFLAGS="-DSDF_DEBUG_ALL -D_XOPEN_SOURCE=600 -I$SDFDIR/include -L$SDFDIR/lib"
OPT="$CFLAGS -O3"
OPT="$CFLAGS -O3 -g"
while getopts crdph23 name
do
......@@ -45,7 +45,7 @@ if [ $clean -le 1 ] ; then
fi
sh gen_commit_string.sh
gcc $OPT -o sdf2ascii sdf2ascii.c -lsdfc -ldl || errcode=1
gcc $OPT -o sdffilter sdffilter.c -lsdfc -ldl -lm || errcode=1
gcc $OPT -o sdffilter sdffilter.c sdf_vtk_writer.c -lsdfc -ldl -lm || errcode=1
gcc $OPT -o sdfdiff sdfdiff.c -lsdfc -ldl -lm || errcode=1
./sdf2ascii -V > /dev/null || rm -f sdf2ascii
# Test if python is new enough for the --user flag
......
......@@ -30,7 +30,7 @@
#include <mpi.h>
#endif
#define VERSION "2.4.18"
#define VERSION "2.6.0"
#define DBG_FLUSH() do { \
if (h && h->dbg_buf) { \
......
......@@ -64,7 +64,7 @@
#ifndef PyArray_SetBaseObject
#define PyArray_SetBaseObject(array, base) \
PyArray_BASE(array) = base
PyArray_BASE(array) = base
#endif
#if PY_MAJOR_VERSION >= 3
......@@ -308,6 +308,7 @@ static PyMemberDef BlockMeshVariable_members[] = {
{"grid_mid", T_OBJECT_EX, offsetof(Block, grid_mid), 0,
"Associated median mesh"},
{"grid_id", T_OBJECT_EX, offsetof(Block, grid_id), 0, "Associated mesh id"},
{"stagger", T_OBJECT_EX, offsetof(Block, stagger), 0, "Grid stagger"},
{"units", T_OBJECT_EX, offsetof(Block, units), 0, "Units of variable"},
{"mult", T_OBJECT_EX, offsetof(Block, mult), 0, "Multiplication factor"},
{NULL} /* Sentinel */
......@@ -325,7 +326,6 @@ static PyMemberDef BlockPointVariable_members[] = {
};
static PyMemberDef BlockPlainMesh_members[] = {
{"stagger", T_OBJECT_EX, offsetof(Block, stagger), 0, "Grid stagger"},
{NULL} /* Sentinel */
};
......@@ -335,7 +335,6 @@ static PyMemberDef BlockPointMesh_members[] = {
};
static PyMemberDef BlockStitchedMaterial_members[] = {
{"stagger", T_OBJECT_EX, offsetof(Block, stagger), 0, "Grid stagger"},
{"material_names", T_OBJECT_EX, offsetof(Block, material_names), 0,
"Material names"},
{"material_ids", T_OBJECT_EX, offsetof(Block, material_ids), 0,
......@@ -344,6 +343,7 @@ static PyMemberDef BlockStitchedMaterial_members[] = {
{"grid_mid", T_OBJECT_EX, offsetof(Block, grid_mid), 0,
"Associated median mesh"},
{"grid_id", T_OBJECT_EX, offsetof(Block, grid_id), 0, "Associated mesh id"},
{"stagger", T_OBJECT_EX, offsetof(Block, stagger), 0, "Grid stagger"},
{NULL} /* Sentinel */
};
......@@ -510,8 +510,8 @@ Block_alloc(SDFObject *sdf, sdf_block_t *b)
}
switch(b->blocktype) {
case SDF_BLOCKTYPE_PLAIN_MESH:
case SDF_BLOCKTYPE_LAGRANGIAN_MESH:
case SDF_BLOCKTYPE_PLAIN_VARIABLE:
case SDF_BLOCKTYPE_PLAIN_DERIVED:
case SDF_BLOCKTYPE_STITCHED_MATERIAL:
case SDF_BLOCKTYPE_CONTIGUOUS_MATERIAL:
ob->stagger = PyLong_FromLong(b->stagger);
......@@ -695,7 +695,7 @@ static PyObject *Block_getdata(Block *block, void *closure)
for (j = 0; j < block->adims[1]; j++) {
for (i = 0; i < block->adims[0]; i++) {
*ptr_out++ = 0.25 * (ptr_in[IJ(i,j)] + ptr_in[IJ(i+1,j)]
+ ptr_in[IJ(i,j+1)] + ptr_in[IJ(i+1,j+1)]);
+ ptr_in[IJ(i,j+1)] + ptr_in[IJ(i+1,j+1)]);
}}
} else if (double2d) {
double *ptr_in, *ptr_out;
......@@ -706,7 +706,7 @@ static PyObject *Block_getdata(Block *block, void *closure)
for (j = 0; j < block->adims[1]; j++) {
for (i = 0; i < block->adims[0]; i++) {
*ptr_out++ = 0.25 * (ptr_in[IJ(i,j)] + ptr_in[IJ(i+1,j)]
+ ptr_in[IJ(i,j+1)] + ptr_in[IJ(i+1,j+1)]);
+ ptr_in[IJ(i,j+1)] + ptr_in[IJ(i+1,j+1)]);
}}
}
......@@ -890,7 +890,7 @@ free_mem:
static void extract_station_time_histories(sdf_file_t *h, PyObject *stations,
PyObject *variables, double t0, double t1, PyObject *dict)
PyObject *variables, double t0, double t1, PyObject *dict)
{
Py_ssize_t nvars, i, nstat;
PyObject *sub;
......@@ -1270,10 +1270,10 @@ static Block *dict_find_mesh_id(PyObject *dict, char *id)
value = PyDict_GetItemString(dict, id);
if ( !value )
return NULL;
return NULL;
if ( !PyObject_TypeCheck(value, &BlockType) )
return NULL;
return NULL;
block = (Block*)value;
......@@ -1281,7 +1281,7 @@ static Block *dict_find_mesh_id(PyObject *dict, char *id)
case SDF_BLOCKTYPE_PLAIN_MESH:
case SDF_BLOCKTYPE_POINT_MESH:
case SDF_BLOCKTYPE_LAGRANGIAN_MESH:
return block;
return block;
}
return NULL;
......@@ -1559,7 +1559,7 @@ static PyMethodDef SDF_methods[] = {
" Starting time for station data.\n"
"t1 : double, optional\n"
" Ending time for station data.\n"
},
},
{NULL}
};
......@@ -1578,23 +1578,26 @@ MOD_INIT(sdf)
{
PyObject *m;
char *s;
long i;
MOD_DEF(m, "sdf", "SDF file reading library", SDF_methods)
if (!m)
return MOD_ERROR_VAL;
PyModule_AddStringConstant(m, "__version__", "2.4.18");
PyModule_AddStringConstant(m, "__version__", "2.6.0");
PyModule_AddStringConstant(m, "__commit_id__", SDF_COMMIT_ID);
PyModule_AddStringConstant(m, "__commit_date__", SDF_COMMIT_DATE);
s = sdf_get_library_commit_id();
PyModule_AddStringConstant(m, "__library_commit_id__", s);
if (s)
free(s);
free(s);
s = sdf_get_library_commit_date();
PyModule_AddStringConstant(m, "__library_commit_date__", s);
if (s)
free(s);
free(s);
for (i=0; i < sdf_stagger_len; i++)
PyModule_AddIntConstant(m, sdf_stagger_c[i], i);
SDFType.tp_dealloc = SDF_dealloc;
SDFType.tp_flags = Py_TPFLAGS_DEFAULT;
......
This diff is collapsed.
......@@ -35,7 +35,7 @@
#include <mpi.h>
#endif
#define VERSION "2.4.18"
#define VERSION "2.6.0"
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define ABS(a) (((a) < 0.0) ? -(a) : (a))
......@@ -84,7 +84,8 @@ static char width_fmt[16];
#define PRINTC(name,variable,fmt) do { \
printf(indent, 1); \
printf(width_fmt, (name)); \
printf(" " fmt, (variable)); \
printf(" "); \
printf(fmt, (variable)); \
printf("\n"); \
} while(0)
......@@ -97,8 +98,12 @@ static char width_fmt[16];
if (!(array)) break; \
printf(indent, 1); \
printf(width_fmt, (name)); \
printf(" (" fmt, (array)[0]); \
for (_i = 1; _i < (len); _i++) printf("," fmt, (array)[_i]); \
printf(" ("); \
printf(fmt, (array)[0]); \
for (_i = 1; _i < (len); _i++) { \
printf(","); \
printf(fmt, (array)[_i]); \
} \
printf(")\n"); \
} while(0)
......@@ -107,9 +112,12 @@ static char width_fmt[16];
if (!(array)) break; \
printf(indent, 1); \
printf(width_fmt, (name)); \
printf(" (" fmt, sdf_datatype_c[(array)[0]]); \
for (_i = 1; _i < (len); _i++) \
printf("," fmt, sdf_datatype_c[(array)[_i]]); \
printf(" ("); \
printf(fmt, sdf_datatype_c[(array)[0]]); \
for (_i = 1; _i < (len); _i++) { \
printf(","); \
printf(fmt, sdf_datatype_c[(array)[_i]]); \
} \
printf(")\n"); \
} while(0)
......@@ -638,7 +646,7 @@ static void print_value(void *data, int datatype)
printf(format_float, *((double*)data));
break;
//case SDF_DATATYPE_REAL16:
// printf("%g", (double)b->const_value);
// printf(format_float, (double)b->const_value);
// break;
case SDF_DATATYPE_CHARACTER:
printf("%c", *((char*)data));
......@@ -666,11 +674,11 @@ static void print_metadata_plain_mesh(sdf_block_t *b)
SET_WIDTH("dim_labels:");
if (verbose_metadata)
PRINTAR("dim_mults:", b->dim_mults, "%g", b->ndims);
PRINTAR("dim_mults:", b->dim_mults, format_float, b->ndims);
PRINTAR("dim_labels:", b->dim_labels, "%s", b->ndims);
PRINTAR("dim_units:", b->dim_units, "%s", b->ndims);
PRINT("geometry:", sdf_geometry_c[b->geometry], "%s");
PRINTAR("extents:", b->extents, "%g", 2*b->ndims);
PRINTAR("extents:", b->extents, format_float, 2*b->ndims);
PRINTAR("dims:", b->dims, "%" PRIi64, b->ndims);
}
......@@ -689,11 +697,11 @@ static void print_metadata_point_mesh(sdf_block_t *b)
SET_WIDTH("dim_labels:");
if (verbose_metadata)
PRINTAR("dim_mults", b->dim_mults, "%g", b->ndims);
PRINTAR("dim_mults", b->dim_mults, format_float, b->ndims);
PRINTAR("dim_labels", b->dim_labels, "%s", b->ndims);
PRINTAR("dim_units", b->dim_units, "%s", b->ndims);
PRINT("geometry:", sdf_geometry_c[b->geometry], "%s");
PRINTAR("extents", b->extents, "%g", 2*b->ndims);
PRINTAR("extents", b->extents, format_float, 2*b->ndims);
//PRINTAR("dims", b->dims, "%" PRIi64, b->ndims);
PRINT("nelements:", b->nelements, "%" PRIi64);
if (b->material_id)
......@@ -715,7 +723,7 @@ static void print_metadata_plain_variable(sdf_block_t *b)
PRINT("mesh id:", b->mesh_id, "%s");
PRINTAR("dims:", b->dims, "%" PRIi64, b->ndims);
if (verbose_metadata) {
PRINT("mult:", b->mult, "%g");
PRINT("mult:", b->mult, format_float);
PRINT("stagger:", sdf_stagger_c[b->stagger], "%s");
}
}
......@@ -737,53 +745,17 @@ static void print_metadata_point_variable(sdf_block_t *b)
if (b->material_id)
PRINT("species id:", b->material_id, "%s");
if (verbose_metadata)
PRINT("mult:", b->mult, "%g");
PRINT("mult:", b->mult, format_float);
}
static void print_metadata_constant(sdf_block_t *b)
{
int32_t i4;
int64_t i8;
float r4;
double r8;
// Metadata is
// - value TYPE_SIZE
printf("%svalue: ", indent);
switch (b->datatype) {
case SDF_DATATYPE_INTEGER4:
memcpy(&i4, b->const_value, sizeof(i4));
printf("%i", i4);
break;
case SDF_DATATYPE_INTEGER8:
memcpy(&i8, b->const_value, sizeof(i8));
printf("%" PRIi64, i8);
break;
case SDF_DATATYPE_REAL4:
memcpy(&r4, b->const_value, sizeof(r4));
printf("%g", r4);
break;
case SDF_DATATYPE_REAL8:
memcpy(&r8, b->const_value, sizeof(r8));
printf("%g", r8);
break;
//case SDF_DATATYPE_REAL16:
// printf("%g", (double)b->const_value);
// break;
case SDF_DATATYPE_CHARACTER:
printf("%c", *b->const_value);
break;
case SDF_DATATYPE_LOGICAL:
if (*b->const_value)
printf("True");
else
printf("False");
break;
}
print_value(b->const_value, b->datatype);
printf("\n");
}
......@@ -966,23 +938,23 @@ static void print_metadata_station(sdf_block_t *b)
PRINT("nvariables:", b->nvariables, "%i");
PRINT("step0:", b->step, "%i");
PRINT("step_increment:", b->step_increment, "%i");
PRINT("time0:", b->time, "%g");
PRINT("time_increment:", b->time_increment, "%g");
PRINT("time0:", b->time, format_float);
PRINT("time_increment:", b->time_increment, format_float);
PRINTAR("station_ids:", b->station_ids, "%s", b->nstations);
PRINTAR("station_names:", b->station_names, "%s", b->nstations);
PRINTAR("station_nvars:", b->station_nvars, "%i", b->nstations);
PRINTAR("station_move:", b->station_move, "%i", b->nstations);
PRINTAR("station_x:", b->station_x, "%g", b->nstations);
PRINTAR("station_x:", b->station_x, format_float, b->nstations);
if (b->ndims > 1)
PRINTAR("station_y:", b->station_y, "%g", b->nstations);
PRINTAR("station_y:", b->station_y, format_float, b->nstations);
if (b->ndims > 2)
PRINTAR("station_z:", b->station_z, "%g", b->nstations);
PRINTAR("station_z:", b->station_z, format_float, b->nstations);
PRINTAR("variable_ids:", b->variable_ids, "%s", b->nvariables);
PRINTAR("variable_names:", b->material_names, "%s", b->nvariables);
PRINTDAR("variable_types:", b->variable_types, "%s", b->nvariables);
PRINTAR("variable_units:", b->dim_units, "%s", b->nvariables);
if (b->dim_mults && verbose_metadata)
PRINTAR("variable_mults:", b->dim_mults, "%g", b->nvariables);
PRINTAR("variable_mults:", b->dim_mults, format_float, b->nvariables);
}
......@@ -1038,13 +1010,13 @@ static void print_metadata_namevalue(sdf_block_t *b)
case(SDF_DATATYPE_REAL4):
r4 = b->data;
for (i = 0; i < b->ndims; i++) {
PRINT(b->material_names[i], r4[i], "%g");
PRINT(b->material_names[i], r4[i], format_float);
}
break;
case(SDF_DATATYPE_REAL8):
r8 = b->data;
for (i = 0; i < b->ndims; i++) {
PRINT(b->material_names[i], r8[i], "%g");
PRINT(b->material_names[i], r8[i], format_float);
}
break;
case(SDF_DATATYPE_LOGICAL):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment