# h5dwrite\_f API and mem\_space\_id

**URL:** <https://forum.hdfgroup.org/t/h5dwrite-f-api-and-mem-space-id/2276>\
**Category:** Hdf-forum archives\
**Created:** [August 18, 2011, 9:57pm UTC](https://forum.hdfgroup.org/t/h5dwrite-f-api-and-mem-space-id/2276 "2011-08-18T21:57:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Izaak\_Beekman](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/izaak_beekman/32/864_2.png) [@Izaak\_Beekman](https://forum.hdfgroup.org/u/Izaak_Beekman)\
**Post date:** [August 18, 2011, 9:57pm UTC](https://forum.hdfgroup.org/t/h5dwrite-f-api-and-mem-space-id/2276/1 "2011-08-18T21:57:27Z")

</div>

Another question, hopefully this one garners more responses than the last:  
In the Fortran API, when an entire array is passed to h5dwrite\_f as  
the data buffer, buf, the purpose of the mem\_space\_id is to select a  
certain subset of the data in memory to write to the file, correct?

If I have a regular hyperslab of an in memory array, am I correct in  
saying that I have two options of writing this to the file:  
1) pass the entire array (as buf) to h5dwrite\_f along with a  
mem\_space\_id pointing to a data space where the appropriate hyperslab  
has been selected, or  
2) exclude the mem\_space\_id argument and pass a Fortran array  
subsection containing only the data from the array I wish to have  
written to the file

i.e. are the following two statements equivalent, assuming  
mem\_space\_id points to a memory space with the appropriate hyperslab  
selected

CALL h5dwrite\_f(dset\_id, mem\_type\_id, buf, dims, hdferr, mem\_space\_id)

vs

CALL h5dwrite\_f(dset\_id, mem\_type\_id, buf(i1:i2:is,j1:j2:js,...), dims, hdferr)

I assume the point of the mem\_space\_id is to deal with more  
complicated selections (cherry picking for example) and for c  
programmers since modern Fortran has a useful array subsection syntax  
which, to my knowledge, c is lacking.

Thanks  
Izaak Beekman

> **···**
>
> ===================================  
> (301)244-9367  
> UMD-CP Visiting Graduate Student  
> Aerospace Engineering  
> ibeekman@umiacs.umd.edu  
> ibeekman@umd.edu
