"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/pcgnslib.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.

pcgnslib.c  (CGNS-4.1.2):pcgnslib.c  (CGNS-4.2.0)
skipping to change at line 108 skipping to change at line 108
/* Open the data */ /* Open the data */
if ((data_id = H5Dopen2(group_id, " data", H5P_DEFAULT)) < 0) { if ((data_id = H5Dopen2(group_id, " data", H5P_DEFAULT)) < 0) {
cgi_error("H5Dopen2() failed"); cgi_error("H5Dopen2() failed");
return CG_ERROR; return CG_ERROR;
} }
/* Set the start position and size for the data write */ /* Set the start position and size for the data write */
/* fix dimensions due to Fortran indexing and ordering */ /* fix dimensions due to Fortran indexing and ordering */
if((rw_mode == CG_PAR_WRITE && data[0].u.wbuf) || (rw_mode == CG_PAR_READ && d ata[0].u.rbuf)) { if((rw_mode == CG_PAR_WRITE && data[0].u.wbuf) || (rw_mode == CG_PAR_READ && d ata[0].u.rbuf)) {
for (k = 0; k < ndims; k++) { for (k = 0; k < ndims; k++) {
start[k] = rmin[ndims-k-1] - 1; start[k] = rmin[ndims-k-1] - 1;
dims[k] = rmax[ndims-k-1] - start[k]; dims[k] = rmax[ndims-k-1] - start[k];
} }
} }
else { /* no data to read or write, but must still call H5Screate_simple */ else { /* no data to read or write, but must still call H5Screate_simple */
for (k = 0; k < ndims; k++) { for (k = 0; k < ndims; k++) {
dims[k] = 0; dims[k] = 0;
} }
} }
/* Create a shape for the data in memory */ /* Create a shape for the data in memory */
mem_shape_id = H5Screate_simple(ndims, dims, NULL); mem_shape_id = H5Screate_simple(ndims, dims, NULL);
if (mem_shape_id < 0) { if (mem_shape_id < 0) {
skipping to change at line 375 skipping to change at line 375
/*================================*/ /*================================*/
int cgp_mpi_comm(MPI_Comm comm) int cgp_mpi_comm(MPI_Comm comm)
{ {
/* check if we are actually running a parallel program */ /* check if we are actually running a parallel program */
/* Flag is true if MPI_Init or MPI_Init_thread has been called and false oth erwise. */ /* Flag is true if MPI_Init or MPI_Init_thread has been called and false oth erwise. */
pcg_mpi_initialized = 0; pcg_mpi_initialized = 0;
MPI_Initialized(&pcg_mpi_initialized); MPI_Initialized(&pcg_mpi_initialized);
if (pcg_mpi_initialized) { if (pcg_mpi_initialized) {
if( cgio_configure(CG_CONFIG_HDF5_MPI_COMM, &comm) != -1) { if( cgio_configure(CG_CONFIG_HDF5_MPI_COMM, &comm) != CG_OK) {
return CG_ERROR; cgi_error("Invalid CG_CONFIG_HDF5_MPI_COMM configure parameter");
return CG_ERROR;
} }
pcg_mpi_comm=comm; pcg_mpi_comm=comm;
MPI_Comm_rank(pcg_mpi_comm, &pcg_mpi_comm_rank); MPI_Comm_rank(pcg_mpi_comm, &pcg_mpi_comm_rank);
MPI_Comm_size(pcg_mpi_comm, &pcg_mpi_comm_size); MPI_Comm_size(pcg_mpi_comm, &pcg_mpi_comm_size);
} }
return pcg_mpi_initialized ? CG_OK : CG_ERROR; return pcg_mpi_initialized ? CG_OK : CG_ERROR;
} }
skipping to change at line 442 skipping to change at line 443
} }
/* Flag this as a parallel access */ /* Flag this as a parallel access */
strcpy(hdf5_access,"PARALLEL"); strcpy(hdf5_access,"PARALLEL");
ierr = cg_set_file_type(CG_FILE_HDF5); ierr = cg_set_file_type(CG_FILE_HDF5);
if (ierr) return ierr; if (ierr) return ierr;
ierr = cg_open(filename, mode, fn); ierr = cg_open(filename, mode, fn);
cgns_filetype = old_type; cgns_filetype = old_type;
/* reset parallel access */
strcpy(hdf5_access,"NATIVE");
return ierr; return ierr;
} }
/*---------------------------------------------------------*/ /*---------------------------------------------------------*/
int cgp_close(int fn) int cgp_close(int fn)
{ {
/* reset parallel access */
strcpy(hdf5_access,"NATIVE");
return cg_close(fn); return cg_close(fn);
} }
/*===== Grid IO Prototypes ================================*/ /*===== Grid IO Prototypes ================================*/
int cgp_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type, int cgp_coord_write(int fn, int B, int Z, CGNS_ENUMT(DataType_t) type,
const char *coordname, int *C) const char *coordname, int *C)
{ {
cg = cgi_get_file(fn); cg = cgi_get_file(fn);
if (check_parallel(cg)) return CG_ERROR; if (check_parallel(cg)) return CG_ERROR;
skipping to change at line 498 skipping to change at line 498
if (zcoor==0) return CG_ERROR; if (zcoor==0) return CG_ERROR;
if (C > zcoor->ncoords || C <= 0) { if (C > zcoor->ncoords || C <= 0) {
cgi_error("coord number %d invalid",C); cgi_error("coord number %d invalid",C);
return CG_ERROR; return CG_ERROR;
} }
for (n = 0; n < zone->index_dim; n++) { for (n = 0; n < zone->index_dim; n++) {
dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] + dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] +
zcoor->rind_planes[2*n+1]; zcoor->rind_planes[2*n+1];
if(coords) { if(coords) {
if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) { if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) {
cgi_error("Invalid index ranges."); printf("%d %d %d", rmin[n]> rmax[n], rmin[n] <1, rmax[n] >dims[n]);
return CG_ERROR; cgi_error("Invalid index ranges. cgp_coord_write_data");
} return CG_ERROR;
} }
}
} }
type = cgi_datatype(zcoor->coord[C-1].data_type); type = cgi_datatype(zcoor->coord[C-1].data_type);
to_HDF_ID(zcoor->coord[C-1].id,hid); to_HDF_ID(zcoor->coord[C-1].id,hid);
cg_rw_t Data; cg_rw_t Data;
Data.u.wbuf = coords; Data.u.wbuf = coords;
return readwrite_data_parallel(hid, type, return readwrite_data_parallel(hid, type,
zone->index_dim, rmin, rmax, &Data, CG_PAR_WRI TE); zone->index_dim, rmin, rmax, &Data, CG_PAR_WRI TE);
} }
skipping to change at line 634 skipping to change at line 635
zcoor = cgi_get_zcoorGC(cg, B, Z); zcoor = cgi_get_zcoorGC(cg, B, Z);
if (zcoor==0) return CG_ERROR; if (zcoor==0) return CG_ERROR;
if (C > zcoor->ncoords || C <= 0) { if (C > zcoor->ncoords || C <= 0) {
cgi_error("coord number %d invalid",C); cgi_error("coord number %d invalid",C);
return CG_ERROR; return CG_ERROR;
} }
for (n = 0; n < zone->index_dim; n++) { for (n = 0; n < zone->index_dim; n++) {
dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] + dims[n] = zone->nijk[n] + zcoor->rind_planes[2*n] +
zcoor->rind_planes[2*n+1]; zcoor->rind_planes[2*n+1];
if(coords) { if(coords) {
if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) { if (rmin[n] > rmax[n] || rmin[n] < 1 || rmax[n] > dims[n]) {
cgi_error("Invalid index ranges."); cgi_error("Invalid index ranges.");
return CG_ERROR; return CG_ERROR;
}
} }
}
} }
type = cgi_datatype(zcoor->coord[C-1].data_type); type = cgi_datatype(zcoor->coord[C-1].data_type);
to_HDF_ID(zcoor->coord[C-1].id,hid); to_HDF_ID(zcoor->coord[C-1].id,hid);
cg_rw_t Data; cg_rw_t Data;
Data.u.rbuf = coords; Data.u.rbuf = coords;
return readwrite_data_parallel(hid, type, return readwrite_data_parallel(hid, type,
zone->index_dim, rmin, rmax, &Data, CG_PAR_READ); zone->index_dim, rmin, rmax, &Data, CG_PAR_READ);
} }
skipping to change at line 758 skipping to change at line 759
if (check_parallel(cg)) return CG_ERROR; if (check_parallel(cg)) return CG_ERROR;
if (!IS_FIXED_SIZE(type)) { if (!IS_FIXED_SIZE(type)) {
cgi_error("element must be a fixed size for parallel IO"); cgi_error("element must be a fixed size for parallel IO");
return CG_ERROR; return CG_ERROR;
} }
return cg_section_partial_write(fn, B, Z, sectionname, type, return cg_section_partial_write(fn, B, Z, sectionname, type,
start, end, nbndry, S); start, end, nbndry, S);
} }
int cgp_poly_section_write(int fn, int B, int Z, const char *sectionname,
CGNS_ENUMT(ElementType_t) type, cgsize_t start, cgsize_t end, cgsize_t maxof
fset,
int nbndry, int *S)
{
cgns_zone *zone;
cgns_section *section = NULL;
double dummy_id;
int index;
int data[2];
cgsize_t dim_vals;
cgsize_t num, ElementDataSize=0;
cg = cgi_get_file(fn);
if (check_parallel(cg)) return CG_ERROR;
if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE))
return CG_ERROR;
if (IS_FIXED_SIZE(type)) {
cgi_error("element type must not be a fixed size for this parallel IO");
return CG_ERROR;
}
return cg_section_general_write(fn, B, Z, sectionname, type,
cgi_datatype(CG_SIZE_DATATYPE), start, end, maxoffset, nbndry, S);
}
/*---------------------------------------------------------*/ /*---------------------------------------------------------*/
int cgp_elements_write_data(int fn, int B, int Z, int S, cgsize_t start, int cgp_elements_write_data(int fn, int B, int Z, int S, cgsize_t start,
cgsize_t end, const cgsize_t *elements) cgsize_t end, const cgsize_t *elements)
{ {
int elemsize; int elemsize;
hid_t hid; hid_t hid;
cgns_section *section; cgns_section *section;
cgsize_t rmin, rmax; cgsize_t rmin, rmax;
CGNS_ENUMT(DataType_t) type; CGNS_ENUMT(DataType_t) type;
skipping to change at line 780 skipping to change at line 808
cg = cgi_get_file(fn); cg = cgi_get_file(fn);
if (check_parallel(cg)) return CG_ERROR; if (check_parallel(cg)) return CG_ERROR;
if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE))
return CG_ERROR; return CG_ERROR;
section = cgi_get_section(cg, B, Z, S); section = cgi_get_section(cg, B, Z, S);
if (section == 0 || section->connect == 0) return CG_ERROR; if (section == 0 || section->connect == 0) return CG_ERROR;
if (elements) { if (elements) {
if (start > end || if (start > end ||
start < section->range[0] || start < section->range[0] ||
end > section->range[1]) { end > section->range[1]) {
cgi_error("Error in requested element data range."); cgi_error("Error in requested element data range.");
return CG_ERROR; return CG_ERROR;
} }
} }
if (!IS_FIXED_SIZE(section->el_type)) { if (!IS_FIXED_SIZE(section->el_type)) {
cgi_error("element must be a fixed size for parallel IO"); cgi_error("element must be a fixed size for parallel IO");
return CG_ERROR; return CG_ERROR;
} }
if (cg_npe(section->el_type, &elemsize)) return CG_ERROR; if (cg_npe(section->el_type, &elemsize)) return CG_ERROR;
rmin = (start - section->range[0]) * elemsize + 1; rmin = (start - section->range[0]) * elemsize + 1;
rmax = (end - section->range[0] + 1) * elemsize; rmax = (end - section->range[0] + 1) * elemsize;
type = cgi_datatype(section->connect->data_type); type = cgi_datatype(section->connect->data_type);
skipping to change at line 807 skipping to change at line 835
to_HDF_ID(section->connect->id, hid); to_HDF_ID(section->connect->id, hid);
cg_rw_t Data; cg_rw_t Data;
Data.u.wbuf = elements; Data.u.wbuf = elements;
return readwrite_data_parallel(hid, type, return readwrite_data_parallel(hid, type,
1, &rmin, &rmax, &Data, CG_PAR_WRITE); 1, &rmin, &rmax, &Data, CG_PAR_WRITE);
} }
/*---------------------------------------------------------*/ /*---------------------------------------------------------*/
int cgp_poly_elements_write_data(int fn, int B, int Z, int S, cgsize_t start,
cgsize_t end, const cgsize_t *elements, const cgsize
_t *offsets)
{
// Very experimental function
// is offset the local or global offset ?
// Should we had another argument global_offset in case offsets is local ?
// The serial partial writing get the global offset from the file
// so it is not necessary to provide it
hid_t hid, hid_elem;
cgns_section *section;
cgsize_t rmin, rmax;
cgsize_t rmin_elem, rmax_elem;
CGNS_ENUMT(DataType_t) type, elem_type;
cg_rw_t Data;
cg_rw_t DataElem;
int status;
/* get file and check mode */
cg = cgi_get_file(fn);
if (check_parallel(cg)) return CG_ERROR;
if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE))
return CG_ERROR;
section = cgi_get_section(cg, B, Z, S);
if (section == 0 || section->connect == 0) return CG_ERROR;
if (offsets)
{
if (start > end ||
start < section->range[0] ||
end > section->range[1])
{
cgi_error("Error in requested element data range.");
return CG_ERROR;
}
}
if (IS_FIXED_SIZE(section->el_type)) {
cgi_error("element must not be a fixed size for this parallel IO");
return CG_ERROR;
}
rmin = start - section->range[0] + 1;
rmax = end - section->range[0] + 2;
type = cgi_datatype(section->connect_offset->data_type);
elem_type = cgi_datatype(section->connect->data_type);
to_HDF_ID(section->connect_offset->id, hid);
to_HDF_ID(section->connect->id, hid_elem);
Data.u.wbuf = offsets;
DataElem.u.wbuf = elements;
if (offsets){
rmin_elem = offsets[0] + 1;
rmax_elem = offsets[end-start+1];
}
else
{
rmin_elem = 1;
rmax_elem = 1;
DataElem.u.wbuf = NULL;
}
status = readwrite_data_parallel(hid, type, 1, &rmin, &rmax, &Data, CG_PAR_WRI
TE);
if (status != CG_OK)
return status;
return readwrite_data_parallel(hid_elem, elem_type, 1, &rmin_elem, &rmax_elem,
&DataElem, CG_PAR_WRITE);
}
/*---------------------------------------------------------*/
int cgp_elements_read_data(int fn, int B, int Z, int S, cgsize_t start, int cgp_elements_read_data(int fn, int B, int Z, int S, cgsize_t start,
cgsize_t end, cgsize_t *elements) cgsize_t end, cgsize_t *elements)
{ {
int elemsize; int elemsize;
hid_t hid; hid_t hid;
cgns_section *section; cgns_section *section;
cgsize_t rmin, rmax; cgsize_t rmin, rmax;
CGNS_ENUMT(DataType_t) type; CGNS_ENUMT(DataType_t) type;
/* get file and check mode */ /* get file and check mode */
cg = cgi_get_file(fn); cg = cgi_get_file(fn);
if (check_parallel(cg)) return CG_ERROR; if (check_parallel(cg)) return CG_ERROR;
if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ)) if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_READ))
return CG_ERROR; return CG_ERROR;
section = cgi_get_section(cg, B, Z, S); section = cgi_get_section(cg, B, Z, S);
if (section == 0 || section->connect == 0) return CG_ERROR; if (section == 0 || section->connect == 0) return CG_ERROR;
if (elements) { /* A processor may have nothing to read */ if (elements) { /* A processor may have nothing to read */
if (start > end || if (start > end ||
start < section->range[0] || start < section->range[0] ||
end > section->range[1]) { end > section->range[1]) {
cgi_error("Error in requested element data range."); cgi_error("Error in requested element data range.");
return CG_ERROR; return CG_ERROR;
} }
} }
if (!IS_FIXED_SIZE(section->el_type)) { if (!IS_FIXED_SIZE(section->el_type)) {
cgi_error("element must be a fixed size for parallel IO"); cgi_error("element must be a fixed size for parallel IO");
return CG_ERROR; return CG_ERROR;
} }
if (cg_npe(section->el_type, &elemsize)) return CG_ERROR; if (cg_npe(section->el_type, &elemsize)) return CG_ERROR;
rmin = (start - section->range[0]) * elemsize + 1; rmin = (start - section->range[0]) * elemsize + 1;
rmax = (end - section->range[0] + 1) * elemsize; rmax = (end - section->range[0] + 1) * elemsize;
type = cgi_datatype(section->connect->data_type); type = cgi_datatype(sizeof(cgsize_t) == 4 ? "I4" : "I8");
to_HDF_ID(section->connect->id, hid); to_HDF_ID(section->connect->id, hid);
cg_rw_t Data; cg_rw_t Data;
Data.u.rbuf = elements; Data.u.rbuf = elements;
return readwrite_data_parallel(hid, type, return readwrite_data_parallel(hid, type,
1, &rmin, &rmax, &Data, CG_PAR_READ); 1, &rmin, &rmax, &Data, CG_PAR_READ);
} }
int cgp_parent_data_write(int fn, int B, int Z, int S, int cgp_parent_data_write(int fn, int B, int Z, int S,
cgsize_t start, cgsize_t end, cgsize_t start, cgsize_t end,
skipping to change at line 873 skipping to change at line 975
if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE)) if (cgi_check_mode(cg->filename, cg->mode, CG_MODE_WRITE))
return CG_ERROR; return CG_ERROR;
section = cgi_get_section(cg, B, Z, S); section = cgi_get_section(cg, B, Z, S);
if (section == 0) return CG_ERROR; if (section == 0) return CG_ERROR;
/* check input range */ /* check input range */
if (parent_data) { if (parent_data) {
if (start > end || if (start > end ||
start < section->range[0] || start < section->range[0] ||
end > section->range[1]) { end > section->range[1]) {
cgi_error("Error in requested element data range."); cgi_error("Error in requested element data range.");
return CG_ERROR; return CG_ERROR;
} }
} else { } else {
start = end = 0; start = end = 0;
} }
if (!IS_FIXED_SIZE(section->el_type)) { if (!IS_FIXED_SIZE(section->el_type)) {
cgi_error("element must be a fixed size for parallel IO"); cgi_error("element must be a fixed size for parallel IO");
return CG_ERROR; return CG_ERROR;
} }
skipping to change at line 1001 skipping to change at line 1103
field = cgi_get_field(cg, B, Z, S, F); field = cgi_get_field(cg, B, Z, S, F);
if (field==0) return CG_ERROR; if (field==0) return CG_ERROR;
/* verify that range requested does not exceed range stored */ /* verify that range requested does not exceed range stored */
if (data) { if (data) {
for (n = 0; n < field->data_dim; n++) { for (n = 0; n < field->data_dim; n++) {
if (rmin[n] > rmax[n] || if (rmin[n] > rmax[n] ||
rmax[n] > field->dim_vals[n] || rmax[n] > field->dim_vals[n] ||
rmin[n] < 1) { rmin[n] < 1) {
cgi_error("Invalid range of data requested"); cgi_error("Invalid range of data requested");
return CG_ERROR; return CG_ERROR;
} }
} }
} }
type = cgi_datatype(field->data_type); type = cgi_datatype(field->data_type);
to_HDF_ID(field->id,hid); to_HDF_ID(field->id,hid);
cg_rw_t Data; cg_rw_t Data;
Data.u.wbuf = data; Data.u.wbuf = data;
return readwrite_data_parallel(hid, type, return readwrite_data_parallel(hid, type,
 End of changes. 14 change blocks. 
41 lines changed or deleted 147 lines changed or added

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