"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/cgns_internals.c" between
CGNS-4.1.2.tar.gz and CGNS-4.2.0.tar.gz

About: The CGNS (CFD General Notation System) provides a standard for recording and recovering computer data associated with the numerical solution of fluid dynamics equations.

cgns_internals.c  (CGNS-4.1.2):cgns_internals.c  (CGNS-4.2.0)
skipping to change at line 26 skipping to change at line 26
be misrepresented as being the original software. be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution. 3. This notice may not be removed or altered from any source distribution.
-------------------------------------------------------------------------*/ -------------------------------------------------------------------------*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <sys/types.h> #include <sys/types.h>
#if !defined(_WIN32) || defined(__NUTC__) #if !defined(_WIN32) || defined(__NUTC__)
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "cgnsconfig.h" #include "cgnsconfig.h"
#include "cgnslib.h" #include "cgnslib.h"
#include "cgns_header.h" #include "cgns_header.h"
#include "cgns_io.h" #include "cgns_io.h"
#include "cg_hashmap.h"
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
#include "cg_malloc.h" #include "cg_malloc.h"
#endif #endif
#if CG_BUILD_HDF5 #if CG_BUILD_HDF5
#include "adfh/ADFH.h" #include "adfh/ADFH.h"
#include "hdf5.h" #include "hdf5.h"
#endif #endif
#if CG_BUILD_COMPLEX_C99_EXT
#include <complex.h>
#undef I
#if defined(_MSC_VER)
#define cg_complex_float _Fcomplex
#define cg_complex_double _Dcomplex
#define __real__(c) c._Val[0]
#define __imag__(c) c._Val[1]
#else
#define cg_complex_float float _Complex
#define cg_complex_double double _Complex
#endif
#endif
#define CGNS_NAN(x) (!((x) < HUGE_VAL && (x) > -HUGE_VAL)) #define CGNS_NAN(x) (!((x) < HUGE_VAL && (x) > -HUGE_VAL))
/* Flag for contiguous (0) or compact storage (1) */ /* Flag for contiguous (0) or compact storage (1) */
extern int HDF5storage_type; extern int HDF5storage_type;
/*********************************************************************** /***********************************************************************
* global variable definitions * global variable definitions
***********************************************************************/ ***********************************************************************/
int Idim; /* current IndexDimension */ int Idim; /* current IndexDimension */
int Cdim; /* current CellDimension */ int Cdim; /* current CellDimension */
skipping to change at line 69 skipping to change at line 85
cgns_posit posit_stack[CG_MAX_GOTO_DEPTH+1]; cgns_posit posit_stack[CG_MAX_GOTO_DEPTH+1];
/***********************************************************************\ /***********************************************************************\
* Internal functions * * Internal functions *
\***********************************************************************/ \***********************************************************************/
void *cgi_malloc(size_t cnt, size_t size) void *cgi_malloc(size_t cnt, size_t size)
{ {
void *buf = calloc(cnt, size); void *buf = calloc(cnt, size);
if (buf == NULL) { if (buf == NULL) {
cgi_error("calloc failed for %d values of size %d", cnt, size); cgi_error("calloc failed for %zu values of size %zu", cnt, size);
exit (1); exit (1);
} }
return buf; return buf;
} }
void *cgi_realloc(void *oldbuf, size_t bytes) void *cgi_realloc(void *oldbuf, size_t bytes)
{ {
void *buf = realloc(oldbuf, bytes); void *buf = realloc(oldbuf, bytes);
if (buf == NULL) { if (buf == NULL) {
cgi_error("realloc failed for %d bytes", bytes); cgi_error("realloc failed for %zu bytes", bytes);
exit (1); exit (1);
} }
return buf; return buf;
} }
/***********************************************************************\ /***********************************************************************\
* Read CGNS file and store in internal data structures * * Read CGNS file and store in internal data structures *
\***********************************************************************/ \***********************************************************************/
int cgi_read() int cgi_read()
skipping to change at line 845 skipping to change at line 861
return CG_ERROR; return CG_ERROR;
} }
for (n=0; n<Idim; n++) { for (n=0; n<Idim; n++) {
if (zcoor[0][g].coord[z].dim_vals[n] != DataSize[n]) { if (zcoor[0][g].coord[z].dim_vals[n] != DataSize[n]) {
cgi_error("Invalid coordinates array dimension"); cgi_error("Invalid coordinates array dimension");
return CG_ERROR; return CG_ERROR;
} }
} }
if (strcmp(zcoor[0][g].coord[z].data_type,"R4") && if (strcmp(zcoor[0][g].coord[z].data_type,"R4") &&
strcmp(zcoor[0][g].coord[z].data_type,"R8")) { strcmp(zcoor[0][g].coord[z].data_type,"R8")) {
cgi_error("Datatype %d not supported for coordinates",zcoor[ 0][g].coord[z].data_type); cgi_error("Datatype %s not supported for coordinates",zcoor[ 0][g].coord[z].data_type);
return CG_ERROR; return CG_ERROR;
} }
} }
CGNS_FREE(id); CGNS_FREE(id);
} }
/* Descriptor_t, DataClass_t, DimensionalUnits_t */ /* Descriptor_t, DataClass_t, DimensionalUnits_t */
if (cgi_read_DDD(linked, zcoor[0][g].id, &zcoor[0][g].ndescr, if (cgi_read_DDD(linked, zcoor[0][g].id, &zcoor[0][g].ndescr,
&zcoor[0][g].descr, &zcoor[0][g].data_class, &zcoor[0][g].units)) &zcoor[0][g].descr, &zcoor[0][g].data_class, &zcoor[0][g].units))
return CG_ERROR; return CG_ERROR;
skipping to change at line 1556 skipping to change at line 1572
} else { } else {
if (sol[0][s].field[z].data_dim != 1 || if (sol[0][s].field[z].data_dim != 1 ||
sol[0][s].field[z].dim_vals[0] != DataCount) { sol[0][s].field[z].dim_vals[0] != DataCount) {
cgi_error("Invalid field array dimension for ptset solut ion"); cgi_error("Invalid field array dimension for ptset solut ion");
return CG_ERROR; return CG_ERROR;
} }
} }
if (strcmp(sol[0][s].field[z].data_type,"I4") && if (strcmp(sol[0][s].field[z].data_type,"I4") &&
strcmp(sol[0][s].field[z].data_type,"I8") && strcmp(sol[0][s].field[z].data_type,"I8") &&
strcmp(sol[0][s].field[z].data_type,"R4") && strcmp(sol[0][s].field[z].data_type,"R4") &&
strcmp(sol[0][s].field[z].data_type,"R8")) { strcmp(sol[0][s].field[z].data_type,"R8") &&
cgi_error("Datatype %d not supported for flow solutions",sol strcmp(sol[0][s].field[z].data_type,"X4") &&
[0][s].field[z].data_type); strcmp(sol[0][s].field[z].data_type,"X8")) {
cgi_error("Datatype %s not supported for flow solutions",sol
[0][s].field[z].data_type);
return CG_ERROR; return CG_ERROR;
} }
} }
CGNS_FREE(idf); CGNS_FREE(idf);
} }
/* Descriptor_t, DataClass_t, DimensionalUnits_t */ /* Descriptor_t, DataClass_t, DimensionalUnits_t */
if (cgi_read_DDD(linked, sol[0][s].id, &sol[0][s].ndescr, if (cgi_read_DDD(linked, sol[0][s].id, &sol[0][s].ndescr,
&sol[0][s].descr, &sol[0][s].data_class, &sol[0][s].units)) &sol[0][s].descr, &sol[0][s].data_class, &sol[0][s].units))
return CG_ERROR; return CG_ERROR;
skipping to change at line 3131 skipping to change at line 3149
/* verify data type */ /* verify data type */
if (strcmp(ptset->data_type,"I4") && strcmp(ptset->data_type,"I8")) { if (strcmp(ptset->data_type,"I4") && strcmp(ptset->data_type,"I8")) {
cgi_error("Data type %s not supported for point set type %d", cgi_error("Data type %s not supported for point set type %d",
ptset->data_type, ptset->type); ptset->data_type, ptset->type);
return CG_ERROR; return CG_ERROR;
} }
/* verify dimension vector */ /* verify dimension vector */
if (!(ndim==2 && dim_vals[0]>0 && dim_vals[1]>0)) { if (!(ndim==2 && dim_vals[0]>0 && dim_vals[1]>0)) {
cgi_error("Invalid definition of point set: ptset->type='%s', ndim=%d, dim_vals[0]=%d", cgi_error("Invalid definition of point set: ptset->type='%s', ndim=%d, dim_vals[0]=%ld",
PointSetTypeName[ptset->type], ndim, dim_vals[0]); PointSetTypeName[ptset->type], ndim, dim_vals[0]);
return CG_ERROR; return CG_ERROR;
} }
/* npts */ /* npts */
ptset->npts = dim_vals[1]; ptset->npts = dim_vals[1];
/* size_of_patch */ /* size_of_patch */
if (ptset->type == CGNS_ENUMV(PointList) || if (ptset->type == CGNS_ENUMV(PointList) ||
ptset->type == CGNS_ENUMV(ElementList) || ptset->type == CGNS_ENUMV(ElementList) ||
skipping to change at line 4050 skipping to change at line 4068
if (discrete[0][n].array[i].data_dim != 1 || if (discrete[0][n].array[i].data_dim != 1 ||
discrete[0][n].array[i].dim_vals[0] != DataCount) { discrete[0][n].array[i].dim_vals[0] != DataCount) {
cgi_error("Invalid array dimension for ptset solution"); cgi_error("Invalid array dimension for ptset solution");
return CG_ERROR; return CG_ERROR;
} }
} }
if (strcmp(discrete[0][n].array[i].data_type,"I4") && if (strcmp(discrete[0][n].array[i].data_type,"I4") &&
strcmp(discrete[0][n].array[i].data_type,"I8") && strcmp(discrete[0][n].array[i].data_type,"I8") &&
strcmp(discrete[0][n].array[i].data_type,"R4") && strcmp(discrete[0][n].array[i].data_type,"R4") &&
strcmp(discrete[0][n].array[i].data_type,"R8")) { strcmp(discrete[0][n].array[i].data_type,"R8")) {
cgi_error("Datatype %d not supported for Discrete Data",disc rete[0][n].array[i].data_type); cgi_error("Datatype %s not supported for Discrete Data",disc rete[0][n].array[i].data_type);
return CG_ERROR; return CG_ERROR;
} }
} }
CGNS_FREE(idi); CGNS_FREE(idi);
} }
/* UserDefinedData_t */ /* UserDefinedData_t */
if (cgi_read_user_data(linked, discrete[0][n].id, if (cgi_read_user_data(linked, discrete[0][n].id,
&discrete[0][n].nuser_data, &discrete[0][n].user_data)) return CG_ER ROR; &discrete[0][n].nuser_data, &discrete[0][n].user_data)) return CG_ER ROR;
} }
skipping to change at line 4295 skipping to change at line 4313
for (j=0; j<Idim; j++) { for (j=0; j<Idim; j++) {
if (amotion[0][n].array[i].dim_vals[j]!= DataSize[j]) { if (amotion[0][n].array[i].dim_vals[j]!= DataSize[j]) {
cgi_error("Invalid array dimension for ArbitraryGrid Motion array '%s'", cgi_error("Invalid array dimension for ArbitraryGrid Motion array '%s'",
amotion[0][n].array[i].name); amotion[0][n].array[i].name);
return CG_ERROR; return CG_ERROR;
} }
} }
} }
if (strcmp(amotion[0][n].array[i].data_type,"R4") && if (strcmp(amotion[0][n].array[i].data_type,"R4") &&
strcmp(amotion[0][n].array[i].data_type,"R8") ) { strcmp(amotion[0][n].array[i].data_type,"R8") ) {
cgi_error("Datatype %d not supported for ArbitraryGridMotion array",amotion[0][n].array[i].data_type); cgi_error("Datatype %s not supported for ArbitraryGridMotion array",amotion[0][n].array[i].data_type);
return CG_ERROR; return CG_ERROR;
} }
} }
CGNS_FREE(idi); CGNS_FREE(idi);
} }
/* UserDefinedData_t */ /* UserDefinedData_t */
if (cgi_read_user_data(linked, amotion[0][n].id, if (cgi_read_user_data(linked, amotion[0][n].id,
&amotion[0][n].nuser_data, &amotion[0][n].user_data)) return CG_ERRO R; &amotion[0][n].nuser_data, &amotion[0][n].user_data)) return CG_ERRO R;
} }
skipping to change at line 5500 skipping to change at line 5518
cg_io_error ("cgio_get_link"); cg_io_error ("cgio_get_link");
return CG_OK; return CG_OK;
} }
link->filename[file_len] = 0; link->filename[file_len] = 0;
link->name_in_file[name_len] = 0; link->name_in_file[name_len] = 0;
return link; return link;
} }
return CG_OK; return CG_OK;
} }
int cgi_datasize(int Idim, cgsize_t *CurrentDim, int cgi_datasize(int ndim, cgsize_t *dims,
CGNS_ENUMV(GridLocation_t) location, CGNS_ENUMV(GridLocation_t) location,
int *rind_planes, cgsize_t *DataSize) int *rind_planes, cgsize_t *DataSize)
{ {
int j; int j;
if (location==CGNS_ENUMV( Vertex )) { if (location==CGNS_ENUMV( Vertex )) {
for (j=0; j<Idim; j++) for (j=0; j<ndim; j++)
DataSize[j] = CurrentDim[j] + rind_planes[2*j] + rind_planes[2*j+1]; DataSize[j] = dims[j] + rind_planes[2*j] + rind_planes[2*j+1];
} else if (location==CGNS_ENUMV(CellCenter) || } else if (location==CGNS_ENUMV(CellCenter) ||
(location==CGNS_ENUMV(FaceCenter) && Cdim==2) || (location==CGNS_ENUMV(FaceCenter) && Cdim==2) ||
(location==CGNS_ENUMV(EdgeCenter) && Cdim==1)) { (location==CGNS_ENUMV(EdgeCenter) && Cdim==1)) {
for (j=0; j<Idim; j++) for (j=0; j<ndim; j++)
DataSize[j] = CurrentDim[j+Idim] + rind_planes[2*j] + rind_planes[2* DataSize[j] = dims[j+ndim] + rind_planes[2*j] + rind_planes[2*j+1];
j+1];
} else if (location == CGNS_ENUMV( IFaceCenter ) || } else if (location == CGNS_ENUMV( IFaceCenter ) ||
location == CGNS_ENUMV( JFaceCenter ) || location == CGNS_ENUMV( JFaceCenter ) ||
location == CGNS_ENUMV( KFaceCenter )) { location == CGNS_ENUMV( KFaceCenter )) {
for (j=0; j<Idim; j++) { for (j=0; j<ndim; j++) {
DataSize[j] = CurrentDim[j] + rind_planes[2*j] + rind_planes[2*j+1]; DataSize[j] = dims[j] + rind_planes[2*j] + rind_planes[2*j+1];
if ((location == CGNS_ENUMV( IFaceCenter ) && j!=0) || if ((location == CGNS_ENUMV( IFaceCenter ) && j!=0) ||
(location == CGNS_ENUMV( JFaceCenter ) && j!=1) || (location == CGNS_ENUMV( JFaceCenter ) && j!=1) ||
(location == CGNS_ENUMV( KFaceCenter ) && j!=2)) DataSize[j]--; (location == CGNS_ENUMV( KFaceCenter ) && j!=2)) DataSize[j]--;
} }
} else { } else {
cgi_error("Location not yet supported"); cgi_error("Location not yet supported");
return CG_ERROR; return CG_ERROR;
} }
return CG_OK; return CG_OK;
} }
skipping to change at line 5620 skipping to change at line 5638
#endif #endif
else { else {
if (cgio_read_all_data_type(cg->cgio, id, data_type, (void *)data)) { if (cgio_read_all_data_type(cg->cgio, id, data_type, (void *)data)) {
cg_io_error("cgio_read_all_data_type"); cg_io_error("cgio_read_all_data_type");
return CG_ERROR; return CG_ERROR;
} }
} }
return CG_OK; return CG_OK;
} }
int cgi_read_offset_data_type(double id, char const *data_type, cgsize_t start,
cgsize_t end, char const *m_type, void* data)
{
cgsize_t cnt = end - start + 1;
cgsize_t s_start[1], s_end[1], s_stride[1];
cgsize_t m_start[1], m_end[1], m_stride[1], m_dim[1];
int ier = CG_OK;
s_start[0] = start;
s_end[0] = end;
s_stride[0] = 1;
m_start[0] = 1;
m_end[0] = cnt;
m_stride[0] = 1;
m_dim[0] = cnt;
if (0 == strcmp(data_type, "I4") && 0 == strcmp(m_type, "I4")) {
if (cgio_read_data_type(cg->cgio, id,
s_start, s_end, s_stride, "I4", 1, m_dim,
m_start, m_end, m_stride, data)) {
cg_io_error("cgio_read_data");
return CG_ERROR;
}
}
else if (0 == strcmp(data_type, "I8") && 0 == strcmp(m_type, "I8")) {
if (cgio_read_data_type(cg->cgio, id,
s_start, s_end, s_stride, "I8", 1, m_dim,
m_start, m_end, m_stride, data)) {
cg_io_error("cgio_read_data");
return CG_ERROR;
}
}
else {
if (cg->filetype == CGIO_FILE_ADF || cg->filetype == CGIO_FILE_ADF2) {
void* conv_data = NULL;
conv_data = malloc((size_t)(cnt * size_of(data_type)));
if (conv_data == NULL) {
cgi_error("Error allocating conv_data");
return CG_ERROR;
}
if (cgio_read_data_type(cg->cgio, id,
s_start, s_end, s_stride,
data_type,
1, m_dim, m_start, m_end, m_stride, conv_data)) {
free(conv_data);
cg_io_error("cgio_read_data_type");
return CG_ERROR;
}
ier = cgi_convert_data(cnt, cgi_datatype(data_type),
conv_data, cgi_datatype(m_type), data);
free(conv_data);
if (ier) return CG_ERROR;
}
else {
/* in situ conversion */
if (cgio_read_data_type(cg->cgio, id,
s_start, s_end, s_stride, m_type, 1, m_dim,
m_start, m_end, m_stride, data)) {
cg_io_error("cgio_read_data_type");
return CG_ERROR;
}
}
}
return CG_OK;
}
int cgi_convert_data(cgsize_t cnt, int cgi_convert_data(cgsize_t cnt,
CGNS_ENUMT(DataType_t) from_type, const void *from_data, CGNS_ENUMT(DataType_t) from_type, const void *from_data,
CGNS_ENUMT(DataType_t) to_type, void *to_data) CGNS_ENUMT(DataType_t) to_type, void *to_data)
{ {
int ierr = 0; int ierr = 0;
cgsize_t n; cgsize_t n;
if (from_type == CGNS_ENUMV(Character)) { if (from_type == CGNS_ENUMV(Character)) {
const char *src = (const char *)from_data; const char *src = (const char *)from_data;
/* C1 -> C1 */ /* C1 -> C1 */
skipping to change at line 5811 skipping to change at line 5894
/* R8 -> R8 */ /* R8 -> R8 */
else if (to_type == CGNS_ENUMV(RealDouble)) { else if (to_type == CGNS_ENUMV(RealDouble)) {
double *dest = (double *)to_data; double *dest = (double *)to_data;
for (n = 0; n < cnt; n++) for (n = 0; n < cnt; n++)
dest[n] = (double)src[n]; dest[n] = (double)src[n];
} }
else { else {
ierr = 1; ierr = 1;
} }
} }
#if CG_BUILD_COMPLEX_C99_EXT
else if (from_type == CGNS_ENUMV(ComplexSingle)) {
const cg_complex_float *src = (const cg_complex_float *)from_data;
/* X4 -> X4 */
if (to_type == CGNS_ENUMV(ComplexSingle)) {
cg_complex_float *dest = (cg_complex_float *)to_data;
for (n = 0; n < cnt; n++)
dest[n] = src[n];
}
/* X4 -> X8 */
else if (to_type == CGNS_ENUMV(ComplexDouble)) {
cg_complex_double *dest = (cg_complex_double *)to_data;
for (n = 0; n < cnt; n++) {
__real__(dest[n]) = (double)crealf(src[n]);
__imag__(dest[n]) = (double)cimagf(src[n]);
}
}
else {
ierr = 1;
}
}
else if (from_type == CGNS_ENUMV(ComplexDouble)) {
const cg_complex_double *src = (const cg_complex_double *)from_data;
/* X8 -> X8 */
if (to_type == CGNS_ENUMV(ComplexDouble)) {
cg_complex_double *dest = (cg_complex_double *)to_data;
for (n = 0; n < cnt; n++)
dest[n] = src[n];
}
/* X8 -> X4 */
else if (to_type == CGNS_ENUMV(ComplexSingle)) {
cg_complex_float *dest = (cg_complex_float *)to_data;
for (n = 0; n < cnt; n++) {
__real__(dest[n]) = (float)creal(src[n]);
__imag__(dest[n]) = (float)cimag(src[n]);
}
}
else {
ierr = 1;
}
}
#endif
else { else {
ierr = 1; ierr = 1;
} }
if (ierr) if (ierr)
cgi_error("invalid data type conversion %d->%d", cgi_error("invalid data type conversion %d->%d",
from_type, to_type); from_type, to_type);
return ierr; return ierr;
} }
skipping to change at line 6918 skipping to change at line 7042
cgi_write_units(bcdata->id, bcdata->units)) return CG_ERROR; cgi_write_units(bcdata->id, bcdata->units)) return CG_ERROR;
/* UserDefinedData_t */ /* UserDefinedData_t */
for (n=0; n<bcdata->nuser_data; n++) for (n=0; n<bcdata->nuser_data; n++)
if (cgi_write_user_data(bcdata->id, &bcdata->user_data[n])) return CG_ER ROR; if (cgi_write_user_data(bcdata->id, &bcdata->user_data[n])) return CG_ER ROR;
return CG_OK; return CG_OK;
} }
int cgi_write_ptset(double parent_id, char_33 name, cgns_ptset *ptset, int cgi_write_ptset(double parent_id, char_33 name, cgns_ptset *ptset,
int Idim, void *ptset_ptr) int ndim, void *ptset_ptr)
{ {
cgsize_t dim_vals[12]; cgsize_t dim_vals[12];
int ndim; int num_dim;
char_33 label; char_33 label;
if (ptset->link) { if (ptset->link) {
return cgi_write_link(parent_id, name, ptset->link, &ptset->id); return cgi_write_link(parent_id, name, ptset->link, &ptset->id);
} }
/* Set label */ /* Set label */
if (ptset->type == CGNS_ENUMV(PointRange) || if (ptset->type == CGNS_ENUMV(PointRange) ||
ptset->type == CGNS_ENUMV(ElementRange) || ptset->type == CGNS_ENUMV(ElementRange) ||
ptset->type == CGNS_ENUMV(PointRangeDonor)) ptset->type == CGNS_ENUMV(PointRangeDonor))
strcpy(label,"IndexRange_t"); strcpy(label,"IndexRange_t");
else strcpy(label,"IndexArray_t"); else strcpy(label,"IndexArray_t");
/* Dimension vector */ /* Dimension vector */
dim_vals[0]=Idim; dim_vals[0]=ndim;
dim_vals[1]=ptset->npts; dim_vals[1]=ptset->npts;
ndim = 2; num_dim = 2;
/* Create the node */ /* Create the node */
if (cgi_new_node(parent_id, name, label, &ptset->id, if (cgi_new_node(parent_id, name, label, &ptset->id,
ptset->data_type, ndim, dim_vals, ptset_ptr)) return CG_ERROR; ptset->data_type, num_dim, dim_vals, ptset_ptr)) return CG_ERROR;
return CG_OK; return CG_OK;
} }
int cgi_write_equations(double parent_id, cgns_equations *equations) int cgi_write_equations(double parent_id, cgns_equations *equations)
{ {
int n; int n;
cgsize_t dim_vals; cgsize_t dim_vals;
double dummy_id; double dummy_id;
cgns_governing *governing; cgns_governing *governing;
skipping to change at line 8100 skipping to change at line 8224
npt = m_rmax[n] - m_rmin[n] + 1; npt = m_rmax[n] - m_rmin[n] + 1;
m_numpt *= npt; m_numpt *= npt;
if (npt != m_dimvals[n]) { if (npt != m_dimvals[n]) {
*m_access_full_range = 0; *m_access_full_range = 0;
} }
} }
/* both the file hyperslab and memory hyperslab must have same number of /* both the file hyperslab and memory hyperslab must have same number of
* points */ * points */
if (s_numpt != m_numpt) { if (s_numpt != m_numpt) {
cgi_error("Number of locations in range of memory array (%d) do not " cgi_error("Number of locations in range of memory array (%ld) do not "
"match number of locations requested in range of file (%d)", "match number of locations requested in range of file (%ld)",
m_numpt, s_numpt); m_numpt, s_numpt);
return CG_ERROR; return CG_ERROR;
} }
*numpt = s_numpt; *numpt = s_numpt;
/* set s_rmin and s_rmax to file-space ranges used internally (the lower /* set s_rmin and s_rmax to file-space ranges used internally (the lower
bound of the arrays is 1 whereas from the user perspective, the lower bound of the arrays is 1 whereas from the user perspective, the lower
core cells have index 1) */ core cells have index 1) */
/* note: s_rmin and s_rmax are not used if reading full range in serial */ /* note: s_rmin and s_rmax are not used if reading full range in serial */
if (s_reset_range) { if (s_reset_range) {
skipping to change at line 8445 skipping to change at line 8569
cg_io_error("cgio_write_data_type"); cg_io_error("cgio_write_data_type");
return CG_ERROR; return CG_ERROR;
} }
} }
} }
return CG_OK; return CG_OK;
} }
/***********************************************************************\ /***********************************************************************\
* Alphanumerical sorting routine * * Alphanumerical sorting routine *
* Warning: This is an insert sort that leads to performance issues *
\***********************************************************************/ \***********************************************************************/
int cgi_sort_names(int nnam, double *ids) int cgi_sort_names(int nnam, double *ids)
{ {
int i,j,k; int i,j;
int leni, lenj;
char_33 temp; char_33 temp;
double temp_id; double temp_id;
char_33 *names; char_33 *names;
names = CGNS_NEW(char_33, nnam); names = CGNS_NEW(char_33, nnam);
for (i=0; i<nnam; i++) { for (i=0; i<nnam; i++) {
if (cgio_get_name(cg->cgio, ids[i], names[i])) { if (cgio_get_name(cg->cgio, ids[i], names[i])) {
cg_io_error("cgio_get_name"); cg_io_error("cgio_get_name");
CGNS_FREE(names); CGNS_FREE(names);
return CG_ERROR; return CG_ERROR;
} }
} }
for (i=0; i<nnam; i++) { for (i=1; i<nnam; i++) {
leni=(int)strlen(names[i]); memcpy(temp, names[i], 33);
temp_id = ids[i];
for (j=i+1; j<nnam; j++) { j = i - 1;
lenj=(int)strlen(names[j]);
for (k=0; k<leni && k<lenj; k++) { while (j >= 0 && strcmp(names[j], temp) > 0)
{
if ((int)names[j][k] < (int)names[i][k]) { memcpy(names[j+1], names[j], 33);
strcpy(temp, names[i]); ids[j+1] = ids[j];
strcpy(names[i], names[j]); j = j - 1;
strcpy(names[j], temp); }
leni=(int)strlen(names[i]); if (j + 1 == i) continue;
temp_id = ids[i]; memcpy(names[j + 1], temp, 33);
ids[i]=ids[j]; ids[j + 1] = temp_id;
ids[j]=temp_id;
break;
} else if ((int)names[j][k]>(int)names[i][k]) {
break;
}
if (k==(int)(strlen(names[j])-1)) {
strcpy(temp, names[i]);
strcpy(names[i], names[j]);
strcpy(names[j], temp);
leni=(int)strlen(names[i]);
temp_id = ids[i];
ids[i]=ids[j];
ids[j]=temp_id;
}
}
}
} }
CGNS_FREE(names); CGNS_FREE(names);
return CG_OK; return CG_OK;
} }
/***********************************************************************\ /***********************************************************************\
* ADF parser: returns the children id with "label" under "parent_id" * * ADF parser: returns the children id with "label" under "parent_id" *
\***********************************************************************/ \***********************************************************************/
skipping to change at line 8577 skipping to change at line 8683
} }
} }
int size_of(const char_33 data_type) int size_of(const char_33 data_type)
{ {
if (strcmp(data_type, "I4") == 0) return sizeof(int); if (strcmp(data_type, "I4") == 0) return sizeof(int);
if (strcmp(data_type, "I8") == 0) return sizeof(cglong_t); if (strcmp(data_type, "I8") == 0) return sizeof(cglong_t);
if (strcmp(data_type, "R4") == 0) return sizeof(float); if (strcmp(data_type, "R4") == 0) return sizeof(float);
if (strcmp(data_type, "R8") == 0) return sizeof(double); if (strcmp(data_type, "R8") == 0) return sizeof(double);
if (strcmp(data_type, "C1") == 0) return sizeof(char); if (strcmp(data_type, "C1") == 0) return sizeof(char);
if (strcmp(data_type, "X4") == 0) return 2*sizeof(float);
if (strcmp(data_type, "X8") == 0) return 2*sizeof(double);
cgi_error("data_type '%s' not supported by function 'size_of'",data_type); cgi_error("data_type '%s' not supported by function 'size_of'",data_type);
return CG_OK; return CG_OK;
} }
const char *cgi_adf_datatype(CGNS_ENUMV(DataType_t) type) const char *cgi_adf_datatype(CGNS_ENUMV(DataType_t) type)
{ {
if (type == CGNS_ENUMV(Integer)) return "I4"; if (type == CGNS_ENUMV(Integer)) return "I4";
if (type == CGNS_ENUMV(LongInteger)) return "I8"; if (type == CGNS_ENUMV(LongInteger)) return "I8";
if (type == CGNS_ENUMV(RealSingle)) return "R4"; if (type == CGNS_ENUMV(RealSingle)) return "R4";
if (type == CGNS_ENUMV(RealDouble)) return "R8"; if (type == CGNS_ENUMV(RealDouble)) return "R8";
if (type == CGNS_ENUMV(Character)) return "C1"; if (type == CGNS_ENUMV(Character)) return "C1";
if (type == CGNS_ENUMV(ComplexSingle)) return "X4";
if (type == CGNS_ENUMV(ComplexDouble)) return "X8";
return "NULL"; return "NULL";
} }
CGNS_ENUMT(DataType_t) cgi_datatype(cchar_33 adf_type) CGNS_ENUMT(DataType_t) cgi_datatype(cchar_33 adf_type)
{ {
if (strcmp(adf_type, "I4") == 0) return CGNS_ENUMV(Integer); if (strcmp(adf_type, "I4") == 0) return CGNS_ENUMV(Integer);
if (strcmp(adf_type, "I8") == 0) return CGNS_ENUMV(LongInteger); if (strcmp(adf_type, "I8") == 0) return CGNS_ENUMV(LongInteger);
if (strcmp(adf_type, "R4") == 0) return CGNS_ENUMV(RealSingle); if (strcmp(adf_type, "R4") == 0) return CGNS_ENUMV(RealSingle);
if (strcmp(adf_type, "R8") == 0) return CGNS_ENUMV(RealDouble); if (strcmp(adf_type, "R8") == 0) return CGNS_ENUMV(RealDouble);
if (strcmp(adf_type, "C1") == 0) return CGNS_ENUMV(Character); if (strcmp(adf_type, "C1") == 0) return CGNS_ENUMV(Character);
if (strcmp(adf_type, "X4") == 0) return CGNS_ENUMV(ComplexSingle);
if (strcmp(adf_type, "X8") == 0) return CGNS_ENUMV(ComplexDouble);
return CGNS_ENUMV(DataTypeNull); return CGNS_ENUMV(DataTypeNull);
} }
/***********************************************************************\ /***********************************************************************\
* Check input functions * * Check input functions *
\***********************************************************************/ \***********************************************************************/
int cgi_zone_no(cgns_base *base, char *zonename, int *zone_no) int cgi_zone_no(cgns_base *base, char *zonename, int *zone_no)
{ {
int i; int i;
skipping to change at line 9082 skipping to change at line 9194
} else { } else {
cgi_error("No grid connectivity information for zone %d", Z); cgi_error("No grid connectivity information for zone %d", Z);
return CG_OK; return CG_OK;
} }
} }
zone->active_zconn = 1; zone->active_zconn = 1;
return zone->zconn; return zone->zconn;
} }
cgns_cprop *cgi_get_cprop(cgns_file *cg, int B, int Z, int I) cgns_cprop *cgi_get_cprop(cgns_file *cg, int B, int Z, int J)
{ {
cgns_conn *conn; cgns_conn *conn;
conn = cgi_get_conn(cg, B, Z, I); conn = cgi_get_conn(cg, B, Z, J);
if (conn==0) return CG_OK; if (conn==0) return CG_OK;
if (conn->cprop == 0) if (conn->cprop == 0)
cgi_error("GridConnectivityProperty_t node doesn't exist under GridConne ctivity_t %d",I); cgi_error("GridConnectivityProperty_t node doesn't exist under GridConne ctivity_t %d",J);
return conn->cprop; return conn->cprop;
} }
cgns_hole *cgi_get_hole(cgns_file *cg, int B, int Z, int I) cgns_hole *cgi_get_hole(cgns_file *cg, int B, int Z, int J)
{ {
cgns_zconn *zconn; cgns_zconn *zconn;
zconn = cgi_get_zconn(cg, B, Z); zconn = cgi_get_zconn(cg, B, Z);
if (zconn==0) return CG_OK; if (zconn==0) return CG_OK;
if (I>zconn->nholes || I<=0) { if (J>zconn->nholes || J<=0) {
cgi_error("OversetHoles node number %d invalid",I); cgi_error("OversetHoles node number %d invalid",J);
return CG_OK; return CG_OK;
} }
return &(zconn->hole[I-1]); return &(zconn->hole[J-1]);
} }
cgns_conn *cgi_get_conn(cgns_file *cg, int B, int Z, int I) cgns_conn *cgi_get_conn(cgns_file *cg, int B, int Z, int J)
{ {
cgns_zconn *zconn; cgns_zconn *zconn;
zconn = cgi_get_zconn(cg, B, Z); zconn = cgi_get_zconn(cg, B, Z);
if (zconn==0) return CG_OK; if (zconn==0) return CG_OK;
if (I>zconn->nconns || I<=0) { if (J>zconn->nconns || J<=0) {
cgi_error("GridConnectivity_t node number %d invalid",I); cgi_error("GridConnectivity_t node number %d invalid",J);
return CG_OK; return CG_OK;
} }
return &(zconn->conn[I-1]); return &(zconn->conn[J-1]);
} }
cgns_1to1 *cgi_get_1to1(cgns_file *cg, int B, int Z, int I) cgns_1to1 *cgi_get_1to1(cgns_file *cg, int B, int Z, int J)
{ {
cgns_zconn *zconn; cgns_zconn *zconn;
zconn = cgi_get_zconn(cg, B, Z); zconn = cgi_get_zconn(cg, B, Z);
if (zconn==0) return CG_OK; if (zconn==0) return CG_OK;
if (I>zconn->n1to1 || I<=0) { if (J>zconn->n1to1 || J<=0) {
cgi_error("GridConnectivity1to1_t node number %d invalid",I); cgi_error("GridConnectivity1to1_t node number %d invalid",J);
return CG_OK; return CG_OK;
} }
return &(zconn->one21[I-1]); return &(zconn->one21[J-1]);
} }
cgns_zboco *cgi_get_zboco(cgns_file *cg, int B, int Z) cgns_zboco *cgi_get_zboco(cgns_file *cg, int B, int Z)
{ {
cgns_zone *zone; cgns_zone *zone;
zone = cgi_get_zone(cg, B, Z); zone = cgi_get_zone(cg, B, Z);
if (zone==0) return CG_OK; if (zone==0) return CG_OK;
/* Allocate automatically only in MODE_WRITE. In MODE_MODIFY, can't do it /* Allocate automatically only in MODE_WRITE. In MODE_MODIFY, can't do it
skipping to change at line 12305 skipping to change at line 12417
/* 0,N DataArray_t under GridCoordinates_t */ /* 0,N DataArray_t under GridCoordinates_t */
if (strcmp(posit->label,"GridCoordinates_t")==0) { if (strcmp(posit->label,"GridCoordinates_t")==0) {
ADDRESS4MULTIPLE(cgns_zcoor, ncoords, coord, cgns_array) ADDRESS4MULTIPLE(cgns_zcoor, ncoords, coord, cgns_array)
array = coord; array = coord;
/* 2 DataArray_t under Elements_t: connect and parent */ /* 2 DataArray_t under Elements_t: connect and parent */
} else if (strcmp(posit->label,"Elements_t")==0) { } else if (strcmp(posit->label,"Elements_t")==0) {
cgns_section *section= (cgns_section *)posit->posit; cgns_section *section= (cgns_section *)posit->posit;
if (local_mode==CG_MODE_WRITE) { if (local_mode==CG_MODE_WRITE) {
if (strcmp(given_name,"ElementConnectivity") && if (strcmp(given_name,"ElementStartOffset") &&
strcmp(given_name,"ElementConnectivity") &&
strcmp(given_name,"ParentElements") && strcmp(given_name,"ParentElements") &&
strcmp(given_name,"ParentElementsPosition") && strcmp(given_name,"ParentElementsPosition") &&
strcmp(given_name,"ParentData")) { strcmp(given_name,"ParentData")) {
cgi_error("User defined DataArray_t node not supported under '%s ' type node",posit->label); cgi_error("User defined DataArray_t node not supported under '%s ' type node",posit->label);
(*ier) = CG_ERROR; (*ier) = CG_ERROR;
return CG_OK; return CG_OK;
} }
if (section->connect==0 && strcmp(given_name,"ElementConnectivity")= =0) { if (section->connect==0 && strcmp(given_name,"ElementConnectivity")= =0) {
section->connect = CGNS_NEW(cgns_array, 1); section->connect = CGNS_NEW(cgns_array, 1);
array = section->connect; array = section->connect;
skipping to change at line 12982 skipping to change at line 13095
void cgi_free_base(cgns_base *base) void cgi_free_base(cgns_base *base)
{ {
int n; int n;
if (base->nzones) { if (base->nzones) {
for (n=0; n<base->nzones; n++) for (n=0; n<base->nzones; n++)
cgi_free_zone(&base->zone[n]); cgi_free_zone(&base->zone[n]);
CGNS_FREE(base->zone); CGNS_FREE(base->zone);
} }
if (base->zonemap) {
cgi_hashmap_clear(base->zonemap);
CGNS_FREE(base->zonemap);
}
if (base->ndescr) { if (base->ndescr) {
for (n=0; n<base->ndescr; n++) for (n=0; n<base->ndescr; n++)
cgi_free_descr(&base->descr[n]); cgi_free_descr(&base->descr[n]);
CGNS_FREE(base->descr); CGNS_FREE(base->descr);
} }
if (base->state) { if (base->state) {
cgi_free_state(base->state); cgi_free_state(base->state);
CGNS_FREE(base->state); CGNS_FREE(base->state);
} }
if (base->units) { if (base->units) {
skipping to change at line 14178 skipping to change at line 14295
} }
if (subreg->narrays) { if (subreg->narrays) {
for (n=0; n<subreg->narrays; n++) for (n=0; n<subreg->narrays; n++)
cgi_free_array(&subreg->array[n]); cgi_free_array(&subreg->array[n]);
CGNS_FREE(subreg->array); CGNS_FREE(subreg->array);
} }
if (subreg->ptset) { if (subreg->ptset) {
cgi_free_ptset(subreg->ptset); cgi_free_ptset(subreg->ptset);
CGNS_FREE(subreg->ptset); CGNS_FREE(subreg->ptset);
} }
if (subreg->bcname) cgi_free_descr(subreg->bcname); if (subreg->bcname){
if (subreg->gcname) cgi_free_descr(subreg->gcname); cgi_free_descr(subreg->bcname);
CGNS_FREE(subreg->bcname);
}
if (subreg->gcname){
cgi_free_descr(subreg->gcname);
CGNS_FREE(subreg->gcname);
}
if (subreg->units) { if (subreg->units) {
cgi_free_units(subreg->units); cgi_free_units(subreg->units);
CGNS_FREE(subreg->units); CGNS_FREE(subreg->units);
} }
if (subreg->rind_planes) CGNS_FREE(subreg->rind_planes); if (subreg->rind_planes) CGNS_FREE(subreg->rind_planes);
if (subreg->nuser_data) { if (subreg->nuser_data) {
for (n=0; n < subreg->nuser_data; n++) for (n=0; n < subreg->nuser_data; n++)
cgi_free_user_data(&subreg->user_data[n]); cgi_free_user_data(&subreg->user_data[n]);
CGNS_FREE(subreg->user_data); CGNS_FREE(subreg->user_data);
} }
 End of changes. 44 change blocks. 
77 lines changed or deleted 200 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)