<div dir="ltr"><div dir="ltr">On Thu, Apr 8, 2021 at 4:08 AM Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com">thibault.bridelbertomeu@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi everyone, <div><br></div><div>Thank you for your answers.</div><div>Unfortunately, it does not work yet.</div><div><br></div><div>1/ I first tried just adding</div><div><br></div><div> <span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(197,134,192)">call</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap"> </span><span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap">(hdf5Viewer, 20, ierr); CHKERRA(ierr)</span></div><div><br></div><div>(the latest iteration in the *.hdf5 is iter 20) before the VecLoad, i.e.:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre-wrap"><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerCreate</span>(PETSC_COMM_WORLD, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerSetType</span>(hdf5Viewer, PETSCVIEWERHDF5, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetMode</span>(hdf5Viewer, FILE_MODE_READ, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetName</span>(hdf5Viewer, <span style="color:rgb(220,220,170)">trim</span>(restartname), ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span>(hdf5Viewer, 20, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerHDF5PushGroup</span>(hdf5Viewer, <span style="color:rgb(206,145,120)">"/fields"</span>, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">VecLoad</span>(sol, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerDestroy</span>(hdf5Viewer, ierr); CHKERRA(ierr)</div></div></div><div><br></div><div>but it does not change anything, the error is exactly the same as before (with or without the PushGroup by the way).</div></div></blockquote><div><br></div><div>This is the one I do not believe. If the Viewer has a non-negative timestep, it will increase the length index:</div><div><br></div><div>  <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/vec/is/utils/hdf5io.c#L78">https://gitlab.com/petsc/petsc/-/blob/main/src/vec/is/utils/hdf5io.c#L78</a></div><div><br></div><div>and we can see all the sizes in your HDF5 file. Are you sure you are running the one with the changed code?</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>2/ I then tried adding </div><div><br></div><div> <span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(197,134,192)">call</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap"> </span><span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap">(hdf5Viewer, -1, ierr); CHKERRA(ierr)</span><br></div><div><br></div><div>before the VecView to "prevent blocking with timesteps" as the doc says (<a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerHDF5SetTimestep.html#PetscViewerHDF5SetTimestep" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerHDF5SetTimestep.html#PetscViewerHDF5SetTimestep</a>), i.e. :</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre-wrap"><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerCreate</span>(PETSC_COMM_WORLD, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerSetType</span>(hdf5Viewer, PETSCVIEWERHDF5, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetMode</span>(hdf5Viewer, FILE_MODE_WRITE, ierr); CHKERRA(ierr);</div><div>                <span style="color:rgb(197,134,192)">write</span>(filename,<span style="color:rgb(206,145,120)">'(A,I5.5,A)'</span>) <span style="color:rgb(206,145,120)">"restart_"</span>, stepnum, <span style="color:rgb(206,145,120)">".h5"</span></div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetName</span>(hdf5Viewer, <span style="color:rgb(220,220,170)">trim</span>(filename), ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span>(hdf5Viewer, -1, ierr); CHKERRA(ierr)<br></div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">VecView</span>(X, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerDestroy</span>(hdf5Viewer, ierr); CHKERRA(ierr)</div></div></div><div><br></div><div>but the hdf5 files keep increasing in size and each one stores more data than the previous one ... can I not disable that "stacking" effect and just keep the iteration I want ?</div><div><br></div><div>3/ I tried adding </div><div><br></div><div> <span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(197,134,192)">call</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap"> </span><span style="background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap;color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;white-space:pre-wrap">(hdf5Viewer, stepnum, ierr); CHKERRA(ierr)</span><br></div><div><br></div><div>before the VecView to try and just keep one iteration in the file, i.e. :</div><div><br></div><div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre-wrap"><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerCreate</span>(PETSC_COMM_WORLD, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerSetType</span>(hdf5Viewer, PETSCVIEWERHDF5, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetMode</span>(hdf5Viewer, FILE_MODE_WRITE, ierr); CHKERRA(ierr);</div><div>                <span style="color:rgb(197,134,192)">write</span>(filename,<span style="color:rgb(206,145,120)">'(A,I5.5,A)'</span>) <span style="color:rgb(206,145,120)">"restart_"</span>, stepnum, <span style="color:rgb(206,145,120)">".h5"</span></div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerFileSetName</span>(hdf5Viewer, <span style="color:rgb(220,220,170)">trim</span>(filename), ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerHDF5SetTimestep</span>(hdf5Viewer, stepnum, ierr); CHKERRA(ierr)<br></div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">VecView</span>(X, hdf5Viewer, ierr); CHKERRA(ierr)</div><div>                <span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerDestroy</span>(hdf5Viewer, ierr); CHKERRA(ierr)</div></div></div><div></div></div><div><br></div><div>but it has no effect whatsoever on the hdf5 files that are written ... they still store several timesteps, and then I cannot VecLoad what I want, i still get the same error.</div><div><br></div><div>Any more idea ? I keep reading the doc on the HDF5 viewer and thinking that this or that function could solve the issue but either it has zero effect or does not solve the issue ...</div><div><br></div><div>Thanks !!!</div><div><br></div><div>Thibault</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 8 avr. 2021 à 02:42, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div>   Matt,<div><br></div><div>   Is there anyway to provide this "extra meta-data" inside the generated HDF file? Then when a fresh viewer opens the file it uses this meta-data to know that the file contains "time-steps" and allows processing of them? The simplest thing would be to have the viewer generate an error if the file has time-steps but the user does not "request a (or more) time-steps" instead of getting confused about the vector sizes.</div><div><br></div><div>  Barry</div><div><br></div><div><br><div><br><blockquote type="cite"><div>On Apr 7, 2021, at 6:32 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div dir="ltr">On Wed, Apr 7, 2021 at 4:10 PM Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank">thibault.bridelbertomeu@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello Vaclav,<div><br></div><div>Thank you for your quick answer !!</div><div>OK so, if I need to push the group, I added :</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre-wrap"><div><span style="color:rgb(197,134,192)">call</span> <span style="color:rgb(220,220,170)">PetscViewerHDF5PushGroup</span>(hdf5Viewer, <span style="color:rgb(206,145,120)">"/fields"</span>, ierr); CHKERRA(ierr)</div></div></div><div><br></div><div>right after the call to PetscViewerFileSetName.</div><div>The result is the same, it produces the following error :</div><div><br></div><div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(172,31,22);background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures"><b>[0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</b></span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Unexpected data in file</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Global size of array in file is 105, not 25300 as expected</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Petsc Development GIT revision: v3.14.4-671-g707297fd510<span>  </span>GIT Date: 2021-02-24 22:50:05 +0000</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: ../../../bin/eulerian3D on a<span>  </span>named macbook-pro-de-thibault.home by tbridel Wed Apr<span>  </span>7 22:05:14 2021</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: Configure options --with-clean=1 --prefix=/Users/tbridel/Documents/1-CODES/04-PETSC/build_uns3D --with-make-np=2 --with-windows-graphics=0 --with-debugging=0 --download-fblaslapack --download-mpich-shared=0 --with-x=0 --with-pthread=0 --with-valgrind=0 --PETSC_ARCH=macosx_uns3D --with-fc=/usr/local/bin/mpifort --with-cc=/usr/local/bin/mpicc --with-cxx=/usr/local/bin/mpic++ --with-openmp=0 --download-hypre=yes --download-sowing=yes --download-metis=yes --download-parmetis=yes --download-triangle=yes --download-tetgen=yes --download-ctetgen=yes --download-p4est=yes --download-zlib=yes --download-c2html=yes --download-eigen=yes --download-pragmatic=yes --with-hdf5-dir=/usr/local/opt/hdf5-mpi --with-cmake-dir=/usr/local/opt/cmake --with-libtoolize=/usr/local/bin/glibtoolize --with-autoreconf=/usr/local/bin/autoreconf</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #1 PetscViewerHDF5ReadSizes_Private() line 114 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/vec/is/utils/hdf5io.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #2 PetscViewerHDF5Load() line 208 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/vec/is/utils/hdf5io.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #3 VecLoad_HDF5() line 132 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/vec/vec/utils/vecio.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #4 VecLoad_Default() line 257 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/vec/vec/utils/vecio.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #5 VecLoad_Plex_Local() line 474 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/dm/impls/plex/plex.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #6 VecLoad_Plex_HDF5_Internal() line 295 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/dm/impls/plex/plexhdf5.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #7 VecLoad_Plex() line 496 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/dm/impls/plex/plex.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #8 VecLoad() line 953 in /Users/tbridel/Documents/1-CODES/04-PETSC/src/vec/vec/interface/vector.c</span></div><div style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;background-color:rgb(252,238,207)"><span style="font-variant-ligatures:no-common-ligatures">[0]PETSC ERROR: #9 User provided function() line 0 in User file</span></div></div><div><br></div><div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><div><div><div>Do you know where it could come from ?</div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote><div><br></div><div>I think I understand this. PETSc tries to be clever to allow you to store timesteps. It gives the HDF5 array an extra dimension. Somehow</div><div>the Viewer has to know this. The TS does this automatically, so you have an array</div><div><br></div><div>  <span style="font-variant-ligatures:no-common-ligatures;font-size:11px">GROUP "fields" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      DATASET "Solution" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATATYPE  H5T_IEEE_F64LE</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATASPACE  SIMPLE { ( 21, 5060, 5 ) / ( H5S_UNLIMITED, 5060, 5 ) }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   }</span></div><div><br></div><div>which has 21 timesteps. However, when you create a brand new Viewer, it does not know, and mistakenly thinks there is a single vector</div><div>of length 21 * 5 = 105. You can tell your reader which timestep you want to extract using</div><div><br></div><div>    <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerHDF5SetTimestep.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/PetscViewerHDF5SetTimestep.html</a><br></div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div><div><div><div>As for what I am doing exactly : i am using the DMPlex with a PetscFV to solve the fluid mechanics Euler equations in 3D. The PetscFV linked to the DS of the DMPlex might be why there is a /fields before the /Solution maybe .. ?</div><div><br></div><div>Cheers and thank you again for your help !!</div><div><br></div><div>Thibault</div></div></div></div></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 7 avr. 2021 à 10:07, Hapla  Vaclav <<a href="mailto:vaclav.hapla@erdw.ethz.ch" target="_blank">vaclav.hapla@erdw.ethz.ch</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div><span>Dear Thibault</span></div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div>On 7 Apr 2021, at 08:18, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank">thibault.bridelbertomeu@gmail.com</a>> wrote:</div>
<br>
<div>
<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 lang="fortran"><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC45" lang="fortran"><span>            </span><span>    call</span><span> </span><span>DMCreateGlobalVector</span><span>(</span><span>dm</span><span>,</span><span> </span><span>sol</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>           </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC46" lang="fortran"><span>            </span><span>    call</span><span> </span><span>VecZeroEntries</span><span>(X</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>                     </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC47" lang="fortran"><span>            </span><span>    call</span><span> </span><span>PetscObjectSetName</span><span>(X</span><span>,</span><span> </span><span>"Solution"</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>     </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC65" lang="fortran"><span>        <br></span></span></pre>
<pre lang="fortran"><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC65" lang="fortran"><span>                < do something with X to fill it up with relevant data ><br></span></span></pre>
<pre lang="fortran"><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC65" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerCreate</span><span>(</span><span>PETSC_COMM_WORLD</span><span>,</span><span> </span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC66" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerSetType</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>PETSCVIEWERHDF5</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC67" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerFileSetMode</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>FILE_MODE_WRITE</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>);</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC68" lang="fortran"><span>                </span><span>write</span><span>(</span><span>filename</span><span>,</span><span>'(A,I5.5,A)'</span><span>)</span><span> </span><span>"restart_"</span><span>,</span><span> </span><span>stepnum</span><span>,</span><span> </span><span>".h5"</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC69" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerFileSetName</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>trim</span><span>(</span><span>filename</span><span>),</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC70" lang="fortran"><span>                </span><span>call</span><span> </span><span>VecView</span><span>(</span><span>X</span><span>,</span><span> </span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC71" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerDestroy</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</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 lang="fortran"><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC64" lang="fortran"><span><span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC45" lang="fortran"><span>            </span><span>    call</span><span> </span><span>DMCreateGlobalVector</span><span>(</span><span>dm</span><span>,</span><span> </span><span>sol</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>           </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC46" lang="fortran"><span>            </span><span>    call</span><span> </span><span>VecZeroEntries</span><span>(</span><span>sol</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>                     </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC47" lang="fortran"><span>            </span><span>    call</span><span> </span><span>PetscObjectSetName</span><span>(</span><span>sol</span><span>,</span><span> </span><span>"Solution"</span><span>,</span><span> </span><span>ierr</span><span>);</span><span>     </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>               <br>                </span><span>call</span><span> </span><span>PetscViewerCreate</span><span>(</span><span>PETSC_COMM_WORLD</span><span>,</span><span> </span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC65" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerSetType</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>PETSCVIEWERHDF5</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC66" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerFileSetMode</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>FILE_MODE_READ</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC67" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerFileSetName</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>trim</span><span>(</span><span>restartname</span><span>),</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC68" lang="fortran"><span>                </span><span>call</span><span> </span><span>VecLoad</span><span>(</span><span>sol</span><span>,</span><span> </span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</span></span>
<span id="gmail-m_1441798517920077622gmail-m_4982510822038283072gmail-m_3416988461638334820gmail-m_6621939839129280338gmail-LC69" lang="fortran"><span>                </span><span>call</span><span> </span><span>PetscViewerDestroy</span><span>(</span><span>hdf5Viewer</span><span>,</span><span> </span><span>ierr</span><span>);</span><span> </span><span>CHKERRA</span><span>(</span><span>ierr</span><span>)</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" target="_blank">
https://drive.google.com/file/d/1owLAx5vknNhj61_5ieAwnWOR9cmkTseL/view?usp=sharing</a></div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>
<div>I'm just looking at the HDF5 file. The structure is like this</div>
<div><br>
</div>
<div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">> $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">
<span style="font-variant-ligatures:no-common-ligatures"> </span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">HDF5 "restart_00020.h5" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">GROUP "/" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   GROUP "cell_fields" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      DATASET "Solution_FV solver" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATATYPE  H5T_IEEE_F64LE</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATASPACE  SIMPLE { ( 21, 3884, 5 ) / ( H5S_UNLIMITED, 3884, 5 ) }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         ATTRIBUTE "vector_field_type" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">            DATATYPE  H5T_STRING {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">               STRSIZE 7;</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">               STRPAD H5T_STR_NULLTERM;</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">               CSET H5T_CSET_ASCII;</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">               CTYPE H5T_C_S1;</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">            }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">            DATASPACE  SCALAR</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   GROUP "fields" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      DATASET "Solution" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATATYPE  H5T_IEEE_F64LE</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">         DATASPACE  SIMPLE { ( 21, 5060, 5 ) / ( H5S_UNLIMITED, 5060, 5 ) }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   DATASET "time" {</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      DATATYPE  H5T_IEEE_F64LE</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">      DATASPACE  SIMPLE { ( 21, 1 ) / ( H5S_UNLIMITED, 1 ) }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">   }</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
<div style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal">
<span style="font-variant-ligatures:no-common-ligatures">}</span></div>
</div>
</div>
<br>
<blockquote type="cite">
<div>
<div dir="ltr">
<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>
</div>
</blockquote>
<div><br>
</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>
</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>
</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>
</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>
</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>
<blockquote type="cite">
<div>
<div dir="ltr">
<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>
</div>
</blockquote>
<br>
</div>
<div>Thanks,</div>
<div>Vaclav</div>
<br>
</div>
</div>

</blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</div></blockquote></div><br></div></div></blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>