示例#1
0
int_f
nh5ltget_attribute_float_c(hid_t_f *loc_id,
                          int_f *namelen,
                          _fcd dsetname,
                          int_f *attrnamelen,
                          _fcd attrname,
                          void *buf)
{
 int     ret_value = -1;
 herr_t  ret;
 hid_t   c_loc_id;
 char    *c_name;
 int     c_namelen;
 char    *c_attrname;
 int     c_attrnamelen;

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = (int)*namelen;
 c_name = (char *)HD5f2cstring(dsetname, c_namelen);
 if (c_name == NULL) return ret_value;

 c_attrnamelen = (int)*attrnamelen;
 c_attrname = (char *)HD5f2cstring(attrname, c_attrnamelen);
 if (c_attrname == NULL) return ret_value;

/*
 * Call H5LTget_attribute_int function.
 */
 c_loc_id = (hid_t)*loc_id;

 ret = H5LTget_attribute_float(c_loc_id,c_name,c_attrname,buf);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}
示例#2
0
int_f
h5ltmake_dataset_c (hid_t_f *loc_id,
                     size_t_f *namelen,
                     _fcd name,
                     int_f *rank,
                     hsize_t_f *dims,
                     hid_t_f *type_id,
                     void *buf)
{
    int     ret_value = -1;
    herr_t  ret;
    char    *c_name = NULL;
    hsize_t *c_dims = NULL;
    int     i;

    /*
    * convert FORTRAN name to C name
    */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_dims =  (hsize_t *)HDmalloc(sizeof(hsize_t) * ( (size_t)*rank ));
    if (c_dims == NULL)
        goto done;
    /*
    * transpose dimension arrays because of C-FORTRAN storage order
    */
    for (i = 0; i < *rank ; i++)
    {
        c_dims[i] =  dims[*rank - i - 1];
    }

    /*
    * call H5LTmake_dataset function.
    */

    ret = H5LTmake_dataset((hid_t)*loc_id, c_name, (int)*rank, c_dims, (hid_t)*type_id, buf );
    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if(c_name!=NULL)
        HDfree(c_name);
    if(c_dims!=NULL)
        HDfree(c_dims);
    return ret_value;
}
/****if* H5Of/h5oget_comment_by_name_c
 * NAME
 *  h5oget_comment_by_name_c
 * PURPOSE
 *  Calls H5Oget_comment_by_name
 * INPUTS
 *  object_id  - Identifier for the target object.
 *  bufsize    - Anticipated required size of the comment buffer.
 * OUTPUTS
 *  comment    - The comment.
 *
 * RETURNS
 *  0 on success, -1 on failure
 * AUTHOR
 *  M. Scot Breitenfeld
 *  July 6, 2012
 * SOURCE
*/
int_f
nh5oget_comment_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *name_size, 
			   _fcd comment, size_t_f *commentsize, size_t_f *bufsize, hid_t_f *lapl_id)
/******/
{
  char *c_comment = NULL;  /* Buffer to hold C string */
  char *c_name = NULL;     /* Buffer to hold C string */
  int_f ret_value = 0;     /* Return value */
  ssize_t c_bufsize;
  size_t c_commentsize;

  /*
   * Convert FORTRAN string to C string
   */
  if((c_name = HD5f2cstring(name, (size_t)*name_size)) == NULL)
    HGOTO_DONE(FAIL);

  c_commentsize = (size_t)*commentsize + 1;

  /*
   * Allocate buffer to hold comment name
   */
  
  if(NULL == (c_comment = (char *)HDmalloc(c_commentsize)))
    HGOTO_DONE(FAIL);

  /*
   * Call H5Oget_comment_by_name function.
   */ 

  if((c_bufsize = H5Oget_comment_by_name((hid_t)*loc_id, c_name, c_comment, (size_t)*commentsize,(hid_t)*lapl_id )) < 0)
    HGOTO_DONE(FAIL);

  *bufsize = (size_t_f)c_bufsize;

  /*
   * Convert C name to FORTRAN and place it in the given buffer
   */
  if(c_comment)
    HD5packFstring(c_comment, _fcdtocp(comment), c_commentsize - 1);
  return ret_value;

 done:
  if(c_comment)
    HDfree(c_comment);
  if(c_name)
    HDfree(c_name);

  return ret_value;
}
示例#4
0
int_f
nh5ltmake_dataset_c (hid_t_f *loc_id,
                     int_f *namelen,
                     _fcd name,
                     int_f *rank,
                     hsize_t_f *dims,
                     hid_t_f *type_id,
                     void *buf)
{
 int     ret_value = -1;
 herr_t  ret;
 hid_t   c_loc_id;
 hid_t   c_type_id;
 char    *c_name;
 int     c_namelen;
 hsize_t *c_dims;
 int     i;

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = *namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return ret_value;

 c_dims =  malloc(sizeof(hsize_t) * (*rank ));
 if (!c_dims) return ret_value;

/*
 * Transpose dimension arrays because of C-FORTRAN storage order
 */
 for (i = 0; i < *rank ; i++) {
  c_dims[i] =  dims[*rank - i - 1];
 }

/*
 * Call H5LTmake_dataset function.
 */
 c_loc_id = (hid_t)*loc_id;
 c_type_id = (hid_t)*type_id;

 ret = H5LTmake_dataset(c_loc_id, c_name, *rank, c_dims, c_type_id, buf );

 free (c_dims);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}
示例#5
0
int_f
nh5tbdelete_field_c(hid_t_f *loc_id,
                    int_f *namelen,
                    _fcd name,
																				int_f *namelen1,
																				_fcd field_name)
{
 int     ret_value = -1;
 herr_t  ret;
 char    *c_name;
 int     c_namelen;
 char    *c_name1;
 int     c_namelen1;
 hid_t   c_loc_id     = *loc_id;

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = *namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return ret_value;

 c_namelen1 = *namelen1;
 c_name1 = (char *)HD5f2cstring(field_name, c_namelen1);
 if (c_name1 == NULL) return ret_value;

/*
 * Call H5TBinsert_field function.
 */

 ret = H5TBdelete_field(c_loc_id,c_name,c_name1);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}
/****if* H5Ff/h5fcreate_c
 * NAME
 *        h5fcreate_c
 * PURPOSE
 *     Call H5Fcreate to create the file
 * INPUTS
 *      name - name of the file
 *              namelen - name length
 *              access_flags - file access  flags
 *              crt_pr  - identifier of creation property list
 *              acc_prp - identifier of access property list
 * OUTPUTS
 *     file_id - file identifier
 * RETURNS
 *     0 on success, -1 on failure
 * AUTHOR
 *  Elena Pourmal
 *              Monday, July 26, 1999
 * SOURCE
*/
int_f
nh5fcreate_c(_fcd name, int_f *namelen, int_f *access_flags, hid_t_f* crt_prp, hid_t_f *acc_prp, hid_t_f *file_id)
/******/
{
     int ret_value = -1;
     char *c_name;
     int_f c_namelen;
     hid_t c_file_id;
     unsigned c_access_flags;
     hid_t c_crt_prp;
     hid_t c_acc_prp;

     /*
      * Define access flags
      */
     c_access_flags = (unsigned) *access_flags;

     /*
      * Define creation property
      */
     c_crt_prp = *crt_prp;

     /*
      * Define access property
      */
     c_acc_prp = *acc_prp;

     /*
      * Convert FORTRAN name to C name
      */
     c_namelen = *namelen;
     c_name = (char *)HD5f2cstring(name, (size_t)c_namelen);
     if(c_name == NULL)
         return ret_value;

     /*
      * Call H5Fcreate function.
      */
     c_file_id = H5Fcreate(c_name, c_access_flags, c_crt_prp, c_acc_prp);

     if (c_file_id >= 0) {
         ret_value = 0;
         *file_id = c_file_id;
     }

     HDfree(c_name);
     return ret_value;
}
示例#7
0
int_f
nh5tbwrite_field_index_c(hid_t_f *loc_id,
                        int_f *namelen,
                        _fcd name,
                        int_f *field_index,
                        hsize_t_f *start,
                        hsize_t_f *nrecords,
                        size_t_f *type_size,
                        void *buf)
{
 int     ret_value = -1;
 herr_t  ret;
 char    *c_name;
 int     c_namelen;
 hid_t   c_loc_id     = *loc_id;
 hsize_t c_start      = *start;
 hsize_t c_nrecords   = *nrecords;
 size_t  c_type_size  = *type_size;
	size_t  c_type_sizes[1];
	int     c_field_index[1];

	c_type_sizes[0] = c_type_size;
	c_field_index[0] = *field_index - 1; /* C zero based index */


/*
 * Convert FORTRAN name to C name
 */
 c_namelen = *namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return ret_value;


/*
 * Call H5TBwrite_fields_name function.
 */

 ret = H5TBwrite_fields_index(c_loc_id,c_name,(hsize_t)1,c_field_index,c_start,c_nrecords,c_type_size,
   0,c_type_sizes,buf);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}
示例#8
0
文件: H5LTfc.c 项目: chaako/sceptic3D
int_f
nh5ltread_dataset_c (hid_t_f *loc_id,
                     int_f *namelen,
                     _fcd name,
                     hid_t_f *type_id,
                     void *buf,
                     hsize_t_f *dims)
{
    int     ret_value = -1;
    herr_t  ret;
    hid_t   c_loc_id;
    hid_t   c_type_id;
    char    *c_name = NULL;
    int     c_namelen;

    /*
    * convert FORTRAN name to C name
    */
    c_namelen = *namelen;
    c_name = (char *)HD5f2cstring(name, c_namelen);
    if (c_name == NULL)
        goto done;

    /*
    * call H5LTread_dataset function.
    */
    c_loc_id = (hid_t)*loc_id;
    c_type_id = (hid_t)*type_id;

    ret = H5LTread_dataset(c_loc_id, c_name, c_type_id, buf );

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if(c_name!=NULL)
        free(c_name);

    return ret_value;
}
示例#9
0
文件: H5Ff.c 项目: MattNapsAlot/rHDF5
/*----------------------------------------------------------------------------
 * Name:        h5fopen_c
 * Purpose:     Call H5Fopen to open the file
 * Inputs:      name - name of the file
 *              namelen - name length
 *              access_flags - file access  flags
 *              acc_prp - identifier of access property list
 * Outputs:     file_id - file identifier
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Tuesday, August 3, 1999
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5fopen_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid_t_f *file_id)
{
     int ret_value = -1;
     char *c_name;
     int_f c_namelen;
     hid_t c_file_id;
     unsigned c_access_flags;
     hid_t c_acc_prp;
     c_acc_prp = (hid_t)*acc_prp;

     /*
      * Define access flags
      */
     c_access_flags = (unsigned) *access_flags;
     /*
      * Define access property
      */
     c_acc_prp = *acc_prp;
/*
     if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT;
*/

     /*
      * Convert FORTRAN name to C name
      */
     c_namelen = *namelen;
     c_name = (char *)HD5f2cstring(name, (size_t)c_namelen);
     if (c_name == NULL) return ret_value;

     /*
      * Call H5Fopen function.
      */
     c_file_id = H5Fopen(c_name, c_access_flags, c_acc_prp);

     if (c_file_id < 0) return ret_value;
     *file_id = (hid_t_f)c_file_id;

     HDfree(c_name);
     ret_value = 0;
     return ret_value;
}
示例#10
0
文件: H5LTfc.c 项目: chaako/sceptic3D
int_f
nh5ltget_dataset_ndims_c(hid_t_f *loc_id,
                         int_f *namelen,
                         _fcd name,
                         int_f *rank)
{
    int     ret_value = -1;
    herr_t  ret;
    hid_t   c_loc_id;
    char    *c_name = NULL;
    int     c_namelen;
    int     c_rank;

    /*
    * Convert FORTRAN name to C name
    */
    c_namelen = (int)*namelen;
    c_name = (char *)HD5f2cstring(name, c_namelen);
    if (c_name == NULL) 
        goto done;

    /*
    * Call H5LTget_dataset_ndims function.
    */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_dataset_ndims(c_loc_id, c_name, &c_rank);

    if (ret < 0) 
        goto done;

    *rank = (int_f)c_rank;
    ret_value = 0;


done:
    if(c_name!=NULL)
        free(c_name);

    return ret_value;
}
示例#11
0
文件: H5Af.c 项目: MattNapsAlot/rHDF5
/*----------------------------------------------------------------------------
 * Name:        h5acreate_c
 * Purpose:     Call H5Acreate to create an attribute
 * Inputs:      obj_id - object identifier
 *              name - name of the attribute
 *              namelen - name length
 *              type_id - datatype identifier
 *              space_id - dataspace identifier
 *              crt_pr  - identifier of creation property list
 * Outputs:     attr_id - attribute identifier
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Thursday, August 12, 1999
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5acreate_c (hid_t_f *obj_id, _fcd name, size_t_f *namelen, hid_t_f *type_id, hid_t_f *space_id, hid_t_f *crt_prp,  hid_t_f *attr_id)
{
    char *c_name=NULL;          /* Buffer to hold C string */
    int_f ret_value=0;          /* Return value */

     /*
      * Convert FORTRAN name to C name
      */
    if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
        HGOTO_DONE(FAIL);

     /*
      * Call H5Acreate function.
      */
    if((*attr_id = (hid_t_f)H5Acreate((hid_t)*obj_id, c_name, (hid_t)*type_id, (hid_t)*space_id, (hid_t)*crt_prp))<0)
        HGOTO_DONE(FAIL);

done:
    if(c_name) HDfree(c_name);
    return ret_value;
}
示例#12
0
文件: H5Af.c 项目: MattNapsAlot/rHDF5
/*----------------------------------------------------------------------------
 * Name:        h5adelete_c
 * Purpose:     Call H5Adelete to delete an attribute
 * Inputs:      obj_id - object identifier
 *              name - name of the attribute
 *              namelen - name length
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Thursday, August 12, 1999
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5adelete_c (hid_t_f *obj_id, _fcd name, size_t_f *namelen)
{
    char *c_name=NULL;          /* Buffer to hold C string */
    int_f ret_value=0;          /* Return value */

     /*
      * Convert FORTRAN name to C name
      */
     if ((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
        HGOTO_DONE(FAIL);

     /*
      * Call H5Adelete function.
      */
     if (H5Adelete((hid_t)*obj_id, c_name) < 0)
         HGOTO_DONE(FAIL);

done:
    if(c_name) HDfree(c_name);
    return ret_value;
}
示例#13
0
/****if* H5Ff/h5fmount_c
 * NAME
 *        h5fmount_c
 * PURPOSE
 *     Call H5Fmount to mount the file
 * INPUTS
 *      loc_id - Identifier for file or group
 *              dsetname - name of dataset
 *              namelen - dsetname length
 *              file_id - file identifier for the file to be mounted
 *              acc_prp - identifier of access property list
 * RETURNS
 *     0 on success, -1 on failure
 * AUTHOR
 *  Xiangyang Su
 *              Monday, October 25, 1999
 * HISTORY
*/
int_f
nh5fmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp)
/******/
{
     int ret_value = -1;
     char *c_name;
     int_f c_namelen;
     hid_t c_loc_id;
     hid_t c_file_id;
     hid_t c_acc_prp;
     htri_t status;

     /*
      * Define access property
      */
     c_acc_prp = *acc_prp;
/*
     if ( H5P_DEFAULT_F == c_acc_prp ) c_acc_prp = H5P_DEFAULT;
*/

     c_loc_id = *loc_id;
     c_file_id = *file_id;
     /*
      * Convert FORTRAN name to C name
      */
     c_namelen = *namelen;
     c_name = (char *)HD5f2cstring(dsetname, (size_t)c_namelen);
     if (c_name == NULL) return ret_value;

     /*
      * Call H5Fmount function.
      */
     status = H5Fmount(c_loc_id, c_name, c_file_id, c_acc_prp);

     if (status >= 0)  ret_value = 0;

     HDfree(c_name);
     return ret_value;
}
示例#14
0
/****if* H5Of/h5oset_comment_c
 * NAME
 *  h5oset_comment_c
 * PURPOSE
 *  Calls H5Oset_comment
 * INPUTS
 *  object_id  - Identifier of the target object.
 *  comment    - The new comment.
 *  commentlen - Length of the comment.
 * RETURNS
 *  0 on success, -1 on failure
 * AUTHOR
 *  M. Scot Breitenfeld
 *  May 17, 2012
 * SOURCE
*/
int_f
nh5oset_comment_c (hid_t_f *object_id, _fcd comment, size_t_f *commentlen)
/******/
{
  char *c_comment = NULL;   /* Buffer to hold C string */
  int_f ret_value = 0;     /* Return value */

  /*
   * Convert FORTRAN string to C string
   */
  if((c_comment = HD5f2cstring(comment, (size_t)*commentlen)) == NULL)
    HGOTO_DONE(FAIL);

  /*
   * Call H5Oset_comment function.
   */
  if((hid_t_f)H5Oset_comment((hid_t)*object_id, c_comment) < 0)
    HGOTO_DONE(FAIL);

 done:
  if(c_comment)
    HDfree(c_comment);
  return ret_value;
}
示例#15
0
文件: t.c 项目: MattNapsAlot/rHDF5
/*----------------------------------------------------------------------------
 * Name:        h5_cleanup_c
 * Purpose:     Call h5_cleanup to clean temporary files.
 * Inputs:      base_name - name of the file
 *              base_namelen - name length
 *              fapl - file access property list
 * Returns:     0 on success, -1 on failure
 * Programmer:  Elena Pourmal
 *              Thursday, September 19, 2002
 * Modifications:
 *---------------------------------------------------------------------------*/
int_f
nh5_cleanup_c(_fcd base_name, size_t_f *base_namelen, hid_t_f* fapl)
{
     char filename[1024];
     int ret_value = -1;
     char *c_base_name[1];
     hid_t c_fapl;

     /*
      * Define ifile access property list
      */
     c_fapl = (hid_t)*fapl;
     /*c_fapl = H5Pcreate(H5P_FILE_ACCESS);*/
     /*
      * Convert FORTRAN name to C name
      */
     c_base_name[0] = (char *)HD5f2cstring(base_name, (size_t)*base_namelen);
     if (c_base_name[0] == NULL) goto DONE;

     /*
      * Call h5_cleanup function.
      */
     /*if (h5_cleanup(c_base_name, c_fapl) != 0) {
     ret_value = 0;
     goto DONE;
     }
*/
     h5_fixname(c_base_name[0], c_fapl, filename, sizeof(filename));
     HDremove(filename);
     ret_value =0;

DONE:
     if (NULL != c_base_name[0]) HDfree(c_base_name[0]);
     return ret_value;

}
示例#16
0
int_f
h5ltread_dataset_string_c (hid_t_f *loc_id,
                            size_t_f *namelen,
                            _fcd name,
                            char *buf)
{
    int     ret_value = -1;
    herr_t  ret;
    hid_t   c_loc_id;
    char    *c_name = NULL;

    /*
    * convert FORTRAN name to C name
    */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    /*
    * call H5LTread_dataset_string function.
    */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTread_dataset_string(c_loc_id,c_name,buf);

    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if(c_name!=NULL)
        HDfree(c_name);

    return ret_value;
}
示例#17
0
int_f
nh5ltfind_dataset_c(hid_t_f *loc_id,
                    int_f *namelen,
                    _fcd name)
{
 hid_t   c_loc_id;
 char    *c_name;
 int     c_namelen;

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = (int)*namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return -1;

/*
 * Call H5LTget_dataset_ndims function.
 */
 c_loc_id = (hid_t)*loc_id;

 return( H5LTfind_dataset(c_loc_id, c_name));

}
示例#18
0
文件: H5Of.c 项目: polyactis/test
/****if* H5Of/h5oopen_c
 * NAME
 *  h5oopen_c
 * PURPOSE
 *  Calls H5Oopen
 * INPUTS
 *  loc_id  - File or group identifier
 *  name    - Attribute access property list
 *  namelen - Size of name
 *  lapl_id - Link access property list
 * OUTPUTS
 *  obj_id  - Dataset identifier
 * RETURNS
 *  0 on success, -1 on failure
 * AUTHOR
 *  M. Scot Breitenfeld
 *  April 18, 2008
 * SOURCE
*/
int_f
nh5oopen_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id, hid_t_f *obj_id)
/******/
{
  char *c_name = NULL;          /* Buffer to hold C string */
  int_f ret_value = 0;          /* Return value */

  /*
   * Convert FORTRAN name to C name
   */
  if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
    HGOTO_DONE(FAIL);

  /*
   * Call H5Oopen function.
   */
  if((*obj_id = (hid_t_f)H5Oopen((hid_t)*loc_id, c_name, (hid_t)*lapl_id)) < 0)
    HGOTO_DONE(FAIL);

 done:
  if(c_name)
    HDfree(c_name);
  return ret_value;
}
示例#19
0
文件: H5Df.c 项目: ElaraFX/hdf5
int_f
h5dwrite_vl_string_c( hid_t_f *dset_id ,  hid_t_f *mem_type_id, hid_t_f *mem_space_id, hid_t_f *file_space_id, hid_t_f *xfer_prp, _fcd buf, hsize_t_f *dims, size_t_f *len)
/******/
{
  int ret_value = -1;
  hid_t c_dset_id;
  hid_t c_mem_type_id;
  hid_t c_mem_space_id;
  hid_t c_file_space_id;
  hid_t c_xfer_prp;
  herr_t status;
  char *tmp, *tmp_p;
  size_t max_len;

  char **c_buf;
  hsize_t i;
  hsize_t num_elem;

  max_len = (size_t)dims[0];
  num_elem = (hsize_t)dims[1];

  c_dset_id       = (hid_t)*dset_id;
  c_mem_type_id   = (hid_t)*mem_type_id;
  c_mem_space_id  = (hid_t)*mem_space_id;
  c_file_space_id = (hid_t)*file_space_id;
  c_xfer_prp      = (hid_t)*xfer_prp;

  /*
   * Allocate arra of character pointers
   */
  c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *));
  if (c_buf == NULL) return ret_value;

  /* Copy data to long C string */
  tmp = (char *)HD5f2cstring(buf, (size_t)(max_len*num_elem));
  if (tmp == NULL) { HDfree(c_buf);
                     return ret_value;
                   }
  /*
   * Move data from temorary buffer
   */
   tmp_p = tmp;
   for (i=0; i < num_elem; i++) {
        c_buf[i] = (char *) HDmalloc((size_t)len[i]+1);
        memcpy(c_buf[i], tmp_p, (size_t)len[i]);
        c_buf[i][len[i]] = '\0';
        tmp_p = tmp_p + max_len;
   }

  /*
   * Call H5Dwrite function.
   */
   status = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf);

  if( status < 0) goto DONE;
  ret_value = 0;
DONE:
  H5Dvlen_reclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
  HDfree(c_buf);
  HDfree(tmp);
  return ret_value;
}
示例#20
0
文件: H5Of.c 项目: polyactis/test
/* ***if* H5Of/H5Oget_info_by_name_c
 * NAME
 *  H5Oget_info_by_name_c
 * PURPOSE
 *  Calls H5Oget_info_by_name
 * INPUTS
 *  loc_id       - File or group identifier specifying location of group in which object is located.
 *  name         - Name of group, relative to loc_id.
 *  namelen      - Name length.
 *  lapl_id      - Link access property list.
 * OUTPUTS
 *  corder_valid - Indicates whether the the creation order data is valid for this attribute.
 *  corder       - Is a positive integer containing the creation order of the attribute.
 *  cset         - Indicates the character set used for the attribute’s name.
 *  data_size    - indicates the size, in the number of characters, of the attribute.
 *
 * RETURNS
 *  0 on success, -1 on failure
 * AUTHOR
 *  M. Scot Breitenfeld
 *  December 1, 2008
 * SOURCE
*/
int_f
nh5oget_info_by_name_c (hid_t_f *loc_id, _fcd name, size_t_f *namelen, hid_t_f *lapl_id,
			H5O_info_t_f *object_info)
/******/
{
  char *c_name = NULL;          /* Buffer to hold C string */
  int_f ret_value = 0;          /* Return value */
  H5O_info_t Oinfo;
  struct tm *ts;
  
  /*
   * Convert FORTRAN name to C name
   */
  if((c_name = HD5f2cstring(name, (size_t)*namelen)) == NULL)
    HGOTO_DONE(FAIL);

  /*
   * Call H5Oinfo_by_name function.
   */
  if(H5Oget_info_by_name((hid_t)*loc_id, c_name,
			 &Oinfo, (hid_t)*lapl_id) < 0)
    HGOTO_DONE(FAIL);

  object_info->fileno    = Oinfo.fileno;
  object_info->addr      = (haddr_t_f)Oinfo.addr;
 

  object_info->type      = (int_f)Oinfo.type;
  object_info->rc        = (int_f)Oinfo.rc;

  ts = gmtime(&Oinfo.atime);

  object_info->atime[0]     = (int_f)ts->tm_year+1900; /* year starts at 1900 */
  object_info->atime[1]     = (int_f)ts->tm_mon+1; /* month starts at 0 in C */
  object_info->atime[2]     = (int_f)ts->tm_mday;
/*   object_info->atime[3]     = (int_f)ts->tm_gmtoff; /\* convert from seconds to minutes *\/ */
  object_info->atime[4]     = (int_f)ts->tm_hour;
  object_info->atime[5]     = (int_f)ts->tm_min;
  object_info->atime[6]     = (int_f)ts->tm_sec;
  object_info->atime[7]     = -32767; /* millisecond is not available, assign it -HUGE(0) */

  ts = gmtime(&Oinfo.btime);

  object_info->btime[0]     = (int_f)ts->tm_year+1900; /* year starts at 1900 */
  object_info->btime[1]     = (int_f)ts->tm_mon+1; /* month starts at 0 in C */
  object_info->btime[2]     = (int_f)ts->tm_mday;
/*   object_info->btime[3]     = (int_f)ts->tm_gmtoff/60; /\* convert from seconds to minutes *\/ */
  object_info->btime[4]     = (int_f)ts->tm_hour;
  object_info->btime[5]     = (int_f)ts->tm_min;
  object_info->btime[6]     = (int_f)ts->tm_sec;
  object_info->btime[7]     = -32767; /* millisecond is not available, assign it -HUGE(0) */

  ts = gmtime(&Oinfo.ctime);

  object_info->ctime[0]     = (int_f)ts->tm_year+1900; /* year starts at 1900 */
  object_info->ctime[1]     = (int_f)ts->tm_mon+1; /* month starts at 0 in C */
  object_info->ctime[2]     = (int_f)ts->tm_mday;
/*   object_info->ctime[3]     = (int_f)ts->tm_gmtoff/60; /\* convert from seconds to minutes *\/ */
  object_info->ctime[4]     = (int_f)ts->tm_hour;
  object_info->ctime[5]     = (int_f)ts->tm_min;
  object_info->ctime[6]     = (int_f)ts->tm_sec;
  object_info->ctime[7]     = -32767; /* millisecond is not available, assign it -HUGE(0) */

  ts = gmtime(&Oinfo.mtime);

  object_info->mtime[0]     = (int_f)ts->tm_year+1900; /* year starts at 1900 */
  object_info->mtime[1]     = (int_f)ts->tm_mon+1; /* month starts at 0 in C */
  object_info->mtime[2]     = (int_f)ts->tm_mday;
/*   object_info->mtime[3]     = (int_f)ts->tm_gmtoff/60; /\* convert from seconds to minutes *\/ */
  object_info->mtime[4]     = (int_f)ts->tm_hour;
  object_info->mtime[5]     = (int_f)ts->tm_min;
  object_info->mtime[6]     = (int_f)ts->tm_sec;
  object_info->mtime[7]     = -32767; /* millisecond is not available, assign it -HUGE(0) */

  object_info->num_attrs = (hsize_t_f)Oinfo.num_attrs;

  object_info->hdr.version = (int_f)Oinfo.hdr.version;
  object_info->hdr.nmesgs  = (int_f)Oinfo.hdr.nmesgs;
  object_info->hdr.nchunks = (int_f)Oinfo.hdr.nchunks;
  object_info->hdr.flags   = (int_f)Oinfo.hdr.flags;

  object_info->hdr.space.total = (hsize_t_f)Oinfo.hdr.space.total;
  object_info->hdr.space.meta  = (hsize_t_f)Oinfo.hdr.space.meta;
  object_info->hdr.space.mesg  = (hsize_t_f)Oinfo.hdr.space.mesg;
  object_info->hdr.space.free  = (hsize_t_f)Oinfo.hdr.space.free;

  object_info->hdr.mesg.present = Oinfo.hdr.mesg.present;
  object_info->hdr.mesg.shared  = Oinfo.hdr.mesg.shared;

  object_info->meta_size.obj.index_size = (hsize_t_f)Oinfo.meta_size.obj.index_size;
  object_info->meta_size.obj.heap_size  = (hsize_t_f)Oinfo.meta_size.obj.heap_size;

 done:
  return ret_value;
}
示例#21
0
文件: H5LTfc.c 项目: chaako/sceptic3D
int_f
nh5ltset_attribute_string_c(hid_t_f *loc_id,
                            int_f *namelen,
                            _fcd dsetname,
                            int_f *attrnamelen,
                            _fcd attrname,
                            int_f *buflen,
                            void *buf)
{
    int     ret_value = -1;
    herr_t  ret;
    hid_t   c_loc_id;
    char    *c_name = NULL;
    char    *c_attrname = NULL;
    int     c_namelen;
    int     c_attrnamelen;
    char    *c_buf = NULL;
    int     c_buflen;

    /*
    * convert FORTRAN name to C name
    */
    c_namelen = *namelen;
    c_name = (char *)HD5f2cstring(dsetname, c_namelen);
    if (c_name == NULL) 
        goto done;

    c_attrnamelen = *attrnamelen;
    c_attrname = (char *)HD5f2cstring(attrname, c_attrnamelen);
    if (c_attrname == NULL) 
        goto done;

    c_buflen = *buflen;
    c_buf = (char *)HD5f2cstring(buf, c_buflen);
    if (c_buf == NULL)
        goto done;


    /*
    * call H5LTset_attribute_string function.
    */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTset_attribute_string(c_loc_id,c_name,c_attrname,c_buf);

    if (ret < 0) 
        goto done;

    ret_value = 0;


done:
    if(c_name!=NULL)
        free(c_name);
    if(c_attrname!=NULL)
        free(c_attrname);
    if(c_buf!=NULL)
        free(c_buf);

    return ret_value;
}
示例#22
0
int_f
h5ltget_attribute_c(hid_t_f *loc_id,
                         size_t_f *namelen,
                         _fcd dsetname,
                         size_t_f *attrnamelen,
                         _fcd attrname,
		         void *buf, char *dtype, size_t_f *sizeof_val)
{
    int     ret_value = -1;
    herr_t  ret;
    hid_t   c_loc_id;
    char    *c_name = NULL;
    char    *c_attrname = NULL;

    /*
    * convert FORTRAN name to C name
    */
    c_name = (char *)HD5f2cstring(dsetname, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
    * call H5LTget_attribute_int function.
    */
    c_loc_id = (hid_t)*loc_id;

    if( HDstrncmp(dtype,"I",1) == 0) {
      if((size_t)*sizeof_val == sizeof(int))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_INT,buf);
      else if ((size_t)*sizeof_val == sizeof(long))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LONG,buf);
      else if ((size_t)*sizeof_val == sizeof(long long))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LLONG,buf);
      else
        goto done;
    } else if ( HDstrncmp(dtype,"R",1) == 0 ) {
      if((size_t)*sizeof_val == sizeof(float))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_FLOAT,buf);
      else if((size_t)*sizeof_val == sizeof(double))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_DOUBLE,buf);
#if H5_SIZEOF_LONG_DOUBLE !=0
      else if((size_t)*sizeof_val == sizeof(long double))
	ret = H5LTget_attribute(c_loc_id,c_name,c_attrname,H5T_NATIVE_LDOUBLE,buf);
#endif
      else
        goto done;
    }
 
    if (ret < 0)
        goto done;

    ret_value = 0;

done:
    if(c_name!=NULL)
        HDfree(c_name);
    if(c_attrname!=NULL)
        HDfree(c_attrname);

    return ret_value;
}
示例#23
0
int_f
h5ltget_attribute_info_c(hid_t_f *loc_id,
                          size_t_f *namelen,
                          _fcd name,
                          size_t_f *attrnamelen,
                          _fcd attrname,
                          hsize_t_f *dims,
                          int_f *type_class,
                          size_t_f *type_size)
{
    int          ret_value = -1;
    herr_t       ret;
    hid_t        c_loc_id;
    char         *c_name = NULL;
    char         *c_attrname = NULL;
    H5T_class_t  c_classtype;
    size_t       c_type_size;
    hsize_t      c_dims[32];
    int          i;
    int          c_rank;

    /*
    * convert FORTRAN name to C name
    */
    c_name = (char *)HD5f2cstring(name, (size_t)*namelen);
    if (c_name == NULL)
        goto done;

    c_attrname = (char *)HD5f2cstring(attrname, (size_t)*attrnamelen);
    if (c_attrname == NULL)
        goto done;

    /*
    * call H5LTget_attribute_info function.
    */
    c_loc_id = (hid_t)*loc_id;

    ret = H5LTget_attribute_info(c_loc_id,c_name,c_attrname,c_dims,&c_classtype,&c_type_size);
    if (ret < 0)
        goto done;

    *type_class = c_classtype;
    *type_size = (size_t_f)c_type_size;

    /*
    * transpose dimension arrays because of C-FORTRAN storage order
    */

    ret = H5LTget_attribute_ndims(c_loc_id,c_name,c_attrname,&c_rank);
    if (ret < 0)
        goto done;

    for (i = 0; i < c_rank ; i++)
    {
        dims[i] = (hsize_t_f) c_dims[c_rank - i - 1];
    }

    ret_value = 0;


done:
    if(c_name!=NULL)
        HDfree(c_name);
    if(c_attrname!=NULL)
        HDfree(c_attrname);


    return ret_value;
}
示例#24
0
/*-------------------------------------------------------------------------
 * Function: h5tbmake_table_c
 *
 * Purpose: Call H5TBmake_table
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: [email protected]
 *
 * Date: October 06, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */
int_f
nh5tbmake_table_c(int_f *namelen1,
                  _fcd name1,
                  hid_t_f *loc_id,
                  int_f *namelen,
                  _fcd name,
                  hsize_t_f *nfields,
                  hsize_t_f *nrecords,
                  size_t_f *type_size,
                  size_t_f *field_offset,
                  hid_t_f *field_types,
                  hsize_t_f *chunk_size,
                  int_f *compress,
                  int_f *namelen2,       /* field_names lenghts */
                  _fcd field_names)      /* field_names */
{
 int     ret_value = -1;
 herr_t  ret;
 char    *c_name;
 int     c_namelen;
 char    *c_name1;
 int     c_namelen1;
 hsize_t num_elem;
 hsize_t i;
 int     max_len=1;
 hid_t   c_loc_id     = *loc_id;
 hsize_t c_nfields    = *nfields;
 hsize_t c_nrecords   = *nrecords;
 hsize_t c_chunk_size = *chunk_size;
 size_t  c_type_size  = *type_size;
 size_t  *c_field_offset;
 hid_t   *c_field_types;
 char    **c_field_names;
 char    *tmp, *tmp_p;

 num_elem = *nfields;

 for (i=0; i < num_elem; i++) {
  if (namelen2[i] > max_len) max_len = namelen2[i];
 }

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = *namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return ret_value;

 c_namelen1 = *namelen1;
 c_name1 = (char *)HD5f2cstring(name1, c_namelen1);
 if (c_name1 == NULL) return ret_value;

 c_field_offset =  (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
 if (!c_field_offset) return ret_value;

 c_field_types =  (hid_t*)malloc(sizeof(hid_t) * (size_t)c_nfields);
 if (!c_field_types) return ret_value;

 for (i=0; i < num_elem; i++) {
  c_field_offset[i] = field_offset[i];
  c_field_types[i]  = field_types[i];
 }

/*
 * Allocate array of character pointers
 */
 c_field_names = (char **)malloc((size_t)num_elem * sizeof(char *));
 if (c_field_names == NULL) return ret_value;

 /* Copy data to long C string */
 tmp = (char *)HD5f2cstring(field_names, (int)(max_len*num_elem));
 if (tmp == NULL) {
  free(c_field_names);
  return ret_value;
 }

/*
 * Move data from temorary buffer
 */
 tmp_p = tmp;
 for (i=0; i < num_elem; i++) {
  c_field_names[i] = (char *) malloc((size_t)namelen2[i]+1);
  memcpy(c_field_names[i], tmp_p, (size_t)namelen2[i]);
  c_field_names[i][namelen2[i]] = '\0';
  tmp_p = tmp_p + max_len;
 }

/*
 * Call H5TBmake_table function.
 */

 ret = H5TBmake_table(c_name1,c_loc_id,c_name,c_nfields,c_nrecords,c_type_size,
   c_field_names,c_field_offset,c_field_types,c_chunk_size,NULL,*compress,NULL);

 for (i=0; i < num_elem; i++) {
  free (c_field_names[i]);
 }
 free(c_field_names);
 free(tmp);
 free(c_field_offset);
 free(c_field_types);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}
示例#25
0
/*-------------------------------------------------------------------------
 * Function: h5tbget_field_info_c
 *
 * Purpose: Call H5TBget_field_info
 *
 * Return: Success: 0, Failure: -1
 *
 * Programmer: [email protected]
 *
 * Date: October 13, 2004
 *
 * Comments:
 *
 * Modifications:
 *
 *
 *-------------------------------------------------------------------------
 */
int_f
nh5tbget_field_info_c(hid_t_f *loc_id,
                  int_f *namelen,
                  _fcd name,
                  hsize_t_f *nfields,
                  size_t_f *field_sizes,
                  size_t_f *field_offsets,
                  size_t_f *type_size,
																		int_f *namelen2,       /* field_names lenghts */
                  _fcd field_names)      /* field_names */

{
 int     ret_value = -1;
 herr_t  ret;
 char    *c_name;
 int     c_namelen;
 hsize_t num_elem;
 hsize_t i;
 int     max_len=1;
 hid_t   c_loc_id   = *loc_id;
	hsize_t c_nfields  = *nfields;
 size_t  *c_field_sizes;
	size_t  *c_field_offsets;
	size_t  c_type_size;
	char    **c_field_names;
 char    *tmp, *tmp_p;
	int     c_lenmax=HLTB_MAX_FIELD_LEN;
	size_t length = 0;

 num_elem = c_nfields;

 for (i=0; i < num_elem; i++) {
  if (namelen2[i] > max_len) max_len = namelen2[i];
 }

/*
 * Convert FORTRAN name to C name
 */
 c_namelen = *namelen;
 c_name = (char *)HD5f2cstring(name, c_namelen);
 if (c_name == NULL) return ret_value;


 c_field_offsets =  (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
 if (!c_field_offsets) return ret_value;

	c_field_sizes =  (size_t*)malloc(sizeof(size_t) * (size_t)c_nfields);
 if (!c_field_sizes) return ret_value;

	c_field_names = malloc( sizeof(char*) * (size_t)c_nfields );
 if (!c_field_names) return ret_value;
	for ( i = 0; i < c_nfields; i++)
 {
  c_field_names[i] = malloc( sizeof(char) * HLTB_MAX_FIELD_LEN );
 }

/*
 * Call H5TBget_field_info function.
 */

 ret = H5TBget_field_info(c_loc_id,c_name,c_field_names,c_field_sizes,c_field_offsets,
		&c_type_size);

	/* return values*/

	/* names array */
	tmp = (char *)malloc(c_lenmax* (size_t) c_nfields + 1);
	tmp_p = tmp;
	memset(tmp,' ', c_lenmax* (size_t) c_nfields);
	tmp[c_lenmax*c_nfields] = '\0';
	for (i=0; i < c_nfields; i++) {
		memcpy(tmp_p, c_field_names[i], strlen(c_field_names[i]));
		namelen2[i] = (int_f)strlen(c_field_names[i]);
		length = MAX(length, strlen(c_field_names[i]));
		tmp_p = tmp_p + c_lenmax;
 }
 HD5packFstring(tmp, _fcdtocp(field_names), (int)(c_lenmax*c_nfields));


	*type_size = (size_t_f)c_type_size;
	for (i=0; i < num_elem; i++)
	{
		field_sizes[i]   = (size_t_f)c_field_sizes[i];
		field_offsets[i] = (size_t_f)c_field_offsets[i];
 }



	/* free */

 for (i=0; i < num_elem; i++) {
  free (c_field_names[i]);
 }
 free(c_field_names);
 free(tmp);
 free(c_field_offsets);
 free(c_field_sizes);

 if (ret < 0) return ret_value;
 ret_value = 0;
 return ret_value;
}