<div dir="ltr"><div>Dear all, <br></div><div><br></div><div>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><br></div><div>Basically, a program writes a vector with the HDF5 writer like this :</div><div></div><div><pre class="gmail-code gmail-highlight" 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></span></span></pre><pre class="gmail-code gmail-highlight" 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></span></span></pre><pre class="gmail-code gmail-highlight" 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>and the same program (but with different start-up options, say) re-reads such a file like this :</div><div><br></div><div><pre class="gmail-code gmail-highlight" 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> </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><br></div><div>Such a dataset can be found under this link : <a href="https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing">https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing</a></div><div><br></div><div>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>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>I tried adding 'PetscViewerHDF5PushGroup(hdf5Viewer, "/fields/Solution", ierr)' to force it to read that group, but it does not change anything.</div><div><br></div><div>I would appreciate it if anyone could give me pointers on this issue ... <br></div><div><br></div><div>Thank you very much in advance !!</div><div><br></div><div>Thibault<br></div></div>