Appreciated your help and thanks for that reply. I found that mistake soon after I mailed. BTW I have not looked at your other suggestion for reading HDf5 data row by row. I will look at your program and see what am I doing wrong. Thanks and regards
On Wed, Oct 17, 2012 at 11:43 AM, Barbara Jones <bljo...@hdfgroup.org>wrote: > Hi, > > Are you creating the dataset with a float datatype? > > Attached is an HDF4 program that creates a character dataset. > It creates the dataset as follows: > > sds_id = SDcreate(sd_id, "data1", DFNT_CHAR, rank, dims); > > -Barbara > > > ==================== > Barbara Jones > The HDF Helpdesk > > The HDF Group > h...@hdfgroup.org > ==================== > > > Folks >> I am trying to write a simple character array through SDwritedata but >> somehow my output SDS field ends up being of 32 bit floating bit type and >> the values are all big floating point values. What am I doing wrong? See >> some portions of my code below: >> >> char * ref_name = NULL: >> int32 ndata; >> int i; >> >> ndata = 7; >> ioparam->out_sds.data_type = DFNT_CHAR; >> ioparam->out_sds.data_size = DFKNTsize(ioparam->out_sds.**data_type); >> >> for (i = 0; i < ndata; i++) /* BIG Assumption that ref data will be always >> 1D */ >> { >> ref_name = (void *) calloc (size, sizeof(char)); >> status = get_name (foo, ref_name, size); /* Here the ref_name is >> set */ >> start[0] = i; >> edge[0] = 1; >> printf("Dataset: %s is %s\n",ioparam->in_sds.name,**ref_name); /* >> Here the names are printed correctly */ >> if (SDwritedata(ioparam->out_sds.**sds_id, start, NULL, edge, >> (VOIDP)ref_name) == FAIL) { >> fprintf(stderr, "Error writing ref data from SDS %s\n", ioparam-> >> out_sds.name); >> return -1; >> } >> if (ref_name != NULL) free(ref_name); >> } >> >> So the names are all printed correctly when I print them on the screen but >> when I check the output file the fields are all float32. >> >> Am I missing something here? >> Thanks >> >> > -- > Barbara L. Jones > bljo...@hdfgroup.org > _______________________________________________ > Hdf-forum is for HDF software users discussion. > Hdf-forum@hdfgroup.org > http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org > >
_______________________________________________ Hdf-forum is for HDF software users discussion. Hdf-forum@hdfgroup.org http://mail.hdfgroup.org/mailman/listinfo/hdf-forum_hdfgroup.org