<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div class=""><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">Dear Thibault</span></div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 7 Apr 2021, at 08:18, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" class="">thibault.bridelbertomeu@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div class="">Dear all, <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I have been facing a problem with VecLoad recently, even though it seems to me I did exactly like in the examples/tutorials.</div>
<div class=""><br class="">
</div>
<div class="">Basically, a program writes a vector with the HDF5 writer like this :</div>
<div class=""></div>
<div class="">
<pre class="gmail-highlight gmail-code" lang="fortran"><span id="gmail-LC45" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">DMCreateGlobalVector</span><span class="gmail-p">(</span><span class="gmail-n">dm</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">sol</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC46" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">VecZeroEntries</span><span class="gmail-p">(X</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC47" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">PetscObjectSetName</span><span class="gmail-p">(X</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-s2">"Solution"</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span><span id="gmail-LC65" class="gmail-line" lang="fortran"><span class="gmail-w"> <br class=""></span></span></pre>
<pre class="gmail-highlight gmail-code" lang="fortran"><span id="gmail-LC65" class="gmail-line" lang="fortran"><span class="gmail-w"> < do something with X to fill it up with relevant data ><br class=""></span></span></pre>
<pre class="gmail-highlight gmail-code" lang="fortran"><span id="gmail-LC65" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerCreate</span><span class="gmail-p">(</span><span class="gmail-n">PETSC_COMM_WORLD</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC66" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerSetType</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">PETSCVIEWERHDF5</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC67" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerFileSetMode</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">FILE_MODE_WRITE</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">);</span></span>
<span id="gmail-LC68" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">write</span><span class="gmail-p">(</span><span class="gmail-n">filename</span><span class="gmail-p">,</span><span class="gmail-s1">'(A,I5.5,A)'</span><span class="gmail-p">)</span><span class="gmail-w"> </span><span class="gmail-s2">"restart_"</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">stepnum</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-s2">".h5"</span></span>
<span id="gmail-LC69" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerFileSetName</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-nb">trim</span><span class="gmail-p">(</span><span class="gmail-n">filename</span><span class="gmail-p">),</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC70" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">VecView</span><span class="gmail-p">(</span><span class="gmail-n">X</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC71" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerDestroy</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
</pre>
</div>
<div class="">and the same program (but with different start-up options, say) re-reads such a file like this :</div>
<div class=""><br class="">
</div>
<div class="">
<pre class="gmail-highlight gmail-code" lang="fortran"><span id="gmail-LC64" class="gmail-line" lang="fortran"><span class="gmail-w"><span id="gmail-LC45" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">DMCreateGlobalVector</span><span class="gmail-p">(</span><span class="gmail-n">dm</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">sol</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC46" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">VecZeroEntries</span><span class="gmail-p">(</span><span class="gmail-n">sol</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC47" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k"> call</span><span class="gmail-w"> </span><span class="gmail-n">PetscObjectSetName</span><span class="gmail-p">(</span><span class="gmail-n">sol</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-s2">"Solution"</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span> <br class=""> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerCreate</span><span class="gmail-p">(</span><span class="gmail-n">PETSC_COMM_WORLD</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC65" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerSetType</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">PETSCVIEWERHDF5</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC66" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerFileSetMode</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">FILE_MODE_READ</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC67" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerFileSetName</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-nb">trim</span><span class="gmail-p">(</span><span class="gmail-n">restartname</span><span class="gmail-p">),</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC68" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">VecLoad</span><span class="gmail-p">(</span><span class="gmail-n">sol</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
<span id="gmail-LC69" class="gmail-line" lang="fortran"><span class="gmail-w"> </span><span class="gmail-k">call</span><span class="gmail-w"> </span><span class="gmail-n">PetscViewerDestroy</span><span class="gmail-p">(</span><span class="gmail-n">hdf5Viewer</span><span class="gmail-p">,</span><span class="gmail-w"> </span><span class="gmail-n">ierr</span><span class="gmail-p">);</span><span class="gmail-w"> </span><span class="gmail-n">CHKERRA</span><span class="gmail-p">(</span><span class="gmail-n">ierr</span><span class="gmail-p">)</span></span>
</pre>
</div>
<div class=""><br class="">
</div>
<div class="">Such a dataset can be found under this link : <a href="https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing" class="">
https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing</a></div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">I'm just looking at the HDF5 file. The structure is like this</div>
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class="">
</div>
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">> $PETSC_DIR/$PETSC_ARCH/bin/h5dump -H restart_00020.h5</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">HDF5 "restart_00020.h5" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">GROUP "/" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> GROUP "cell_fields" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASET "Solution_FV solver" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATATYPE H5T_IEEE_F64LE</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASPACE SIMPLE { ( 21, 3884, 5 ) / ( H5S_UNLIMITED, 3884, 5 ) }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> ATTRIBUTE "vector_field_type" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATATYPE H5T_STRING {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> STRSIZE 7;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> STRPAD H5T_STR_NULLTERM;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> CSET H5T_CSET_ASCII;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> CTYPE H5T_C_S1;</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASPACE SCALAR</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> GROUP "fields" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASET "Solution" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATATYPE H5T_IEEE_F64LE</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASPACE SIMPLE { ( 21, 5060, 5 ) / ( H5S_UNLIMITED, 5060, 5 ) }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASET "time" {</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATATYPE H5T_IEEE_F64LE</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> DATASPACE SIMPLE { ( 21, 1 ) / ( H5S_UNLIMITED, 1 ) }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
</div>
</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">I would like the reader to read the /fields/Solution group basically, but I am not even sure it tries to do that.</div>
<div class="">Anyhow, I got an error, saying that the size found in the file (105) does not match the expected size (25300). If I look at the shape of /fields/Solution it is given as (21, 5030, 5). First, it is weird, cause the 21 seems to be 1 + current iteration
number ... but anyways we find the 5 variables and the 5030 cells. Only the reader seems to do 21 * 5 when it should be doing 5030 * 5 ...</div>
<div class="">I tried adding 'PetscViewerHDF5PushGroup(hdf5Viewer, "/fields/Solution", ierr)' to force it to read that group, but it does not change anything.</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>You definitely need to push the group, unless it's the root group "/". There is no way the reader would guess the correct group if it's not the root one [and I don't think it would be a good idea to implement such searching].</div>
<div><br class="">
</div>
<div>If you tried adding</div>
<div> PetscViewerHDF5PushGroup(hdf5Viewer, "/fields/Solution", ierr)</div>
<div>you likely pushed a wrong group. If the Vec name was set to "Solution" like in your snippet [using PetscObjectSetName()], the absolute dataset name to look up would be "/fields/Solution/Solution".</div>
<div><br class="">
</div>
<div>But in your file, there's just a dataset "/fields/Solution", so its parent group is just "/fields". So please try pushing this.</div>
<div><br class="">
</div>
<div>I would gladly try to reproduce your case - perhaps the error handling should be improved so that it would guide you into the right direction. But it would be helpful to know exactly what you're doing - the snippet with VecView() above should produce "/Solution"
dataset but in the file you're sending, there's "/fields/Solution".</div>
<div><br class="">
</div>
<div>Note also you don't need to do VecZeroEntries() before loading because VecLoad() fully rewrites the Vec data in memory anyway.</div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div dir="ltr" class="">
<div class=""><br class="">
</div>
<div class="">I would appreciate it if anyone could give me pointers on this issue ...
<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Thank you very much in advance !!</div>
<div class=""><br class="">
</div>
<div class="">Thibault<br class="">
</div>
</div>
</div>
</blockquote>
<br class="">
</div>
<div>Thanks,</div>
<div>Vaclav</div>
<br class="">
</div>
</body>
</html>