On Thu, Jan 19, 2012 at 9:54 PM, Mohamad M. Nasr-Azadani <span dir="ltr"><<a href="mailto:mmnasr@gmail.com">mmnasr@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi, <div><br></div><div>I am trying to use VecView() and hdf5 viewer. </div><div>I am trying to create a "parallel" vector of size N which has N elements on only processor zero and 0 elements on all other processors. </div>
<div><br></div><div>This is the code that I have (if it helps): </div><div><br></div><div>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#55ff55">PetscViewer</span><span style="color:#c0c0c0"> </span>H5viewer<span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#55ffff">//</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">Create</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">the</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">HDF5</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">viewer</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">int</span><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>PetscViewerHDF5Open<span style="color:#aaaaaa">(</span>PCW<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span><span style="color:#ff55ff">"temp.h5"</span><span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span><span style="font-style:italic;color:#55ff55">FILE_MODE_WRITE</span><span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">&</span>H5viewer<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#55ff55">Vec</span><span style="color:#c0c0c0"> </span>x<span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecCreate<span style="color:#aaaaaa">(</span>PCW<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">&</span>x<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">int</span><span style="color:#c0c0c0"> </span>n_local<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span><span style="color:#ff55ff">0</span><span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#aaaaaa">/* Rank of current processor */</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">if</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">(</span>params<span style="color:#aaaaaa">-></span>rank<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">==</span><span style="color:#c0c0c0"> </span>MASTER<span style="color:#aaaaaa">)</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>n_local<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>N<span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecSetSizes<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">,</span>n_local<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span>N<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecSetFromOptions<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">double</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">*</span>vcoord<span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecGetArray<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">&</span>vcoord<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">int</span><span style="color:#c0c0c0"> </span>i<span style="color:#aaaaaa">;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#ffff55">for</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">(</span>i<span style="color:#aaaaaa">=</span><span style="color:#ff55ff">0</span><span style="color:#aaaaaa">;</span><span style="color:#c0c0c0"> </span>i<span style="color:#aaaaaa"><</span>n_local<span style="color:#aaaaaa">;</span><span style="color:#c0c0c0"> </span>i<span style="color:#aaaaaa">++)</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>vcoord<span style="color:#aaaaaa">[</span>i<span style="color:#aaaaaa">]</span><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>coord<span style="color:#aaaaaa">[</span>i<span style="color:#aaaaaa">];</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecRestoreArray<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span>vcoord<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>PetscObjectSetName<span style="color:#aaaaaa">((</span><span style="color:#55ff55">PetscObject</span><span style="color:#aaaaaa">)</span><span style="color:#c0c0c0"> </span>x<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span>gridname<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span><span style="color:#55ffff">//</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">Write</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">the</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">H5</span><span style="color:#c0c0c0"> </span><span style="color:#55ffff">file</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecView<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">,</span><span style="color:#c0c0c0"> </span>H5viewer<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>VecDestroy<span style="color:#aaaaaa">(</span>x<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0"> </span>ierr<span style="color:#c0c0c0"> </span><span style="color:#aaaaaa">=</span><span style="color:#c0c0c0"> </span>PetscViewerDestroy<span style="color:#aaaaaa">(</span>H5viewer<span style="color:#aaaaaa">);</span><span style="color:#c0c0c0"> </span>PETScErrAct<span style="color:#aaaaaa">(</span>ierr<span style="color:#aaaaaa">);</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"></pre></div><div><br></div><div><br></div><div>When I create a viewer and use VecView() to write this vector to file, this is the error I get. Apparently, it seems it does not like it that other processors do not have any elements. </div>
<div>Any ideas how to fix that? </div><div><br></div><div>HDF5-DIAG: Error detected in HDF5 (1.8.4) HDF5-DIAG: Error detected in HDF5 (1.8.4) HDF5-DIAG: Error detected in HDF5 (1.8.4) MPI-process 2MPI-process 3:</div><div>
<div> #000: H5S.c line 1335 in H5Screate_simple(): zero sized dimension for non-unlimited dimension</div></div></blockquote><div><br></div><div>It appears that HDF5 has some limitations.</div><div><br></div><div> Matt</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>:</div><div> #000: H5S.c line 1335 in H5Screate_simple(): zero sized dimension for non-unlimited dimension</div>
<div> major: Invalid arguments to routine</div><div> minor: Bad value</div><div> major: Invalid arguments to routine</div><div> minor: Bad value</div><div>[2]PETSC ERROR: MPI-process 1--------------------- Error Message ------------------------------------</div>
<div>[3]PETSC ERROR: --------------------- Error Message ------------------------------------</div><div>[2]PETSC ERROR: Error in external library!</div><div>[3]PETSC ERROR: Error in external library!</div><div>[2]PETSC ERROR: Cannot H5Screate_simple()!</div>
<div>[3]PETSC ERROR: Cannot H5Screate_simple()!</div><div>[2]PETSC ERROR: [3]PETSC ERROR: ------------------------------------------------------------------------</div><div>[2]PETSC ERROR: ------------------------------------------------------------------------</div>
<div>:</div><div> #000: H5S.c line 1335 in H5Screate_simple(): zero sized dimension for non-unlimited dimension</div><div> major: Invalid arguments to routine</div><div> minor: Bad value</div><div>[1]PETSC ERROR: --------------------- Error Message ------------------------------------</div>
<div>[1]PETSC ERROR: Error in external library!</div><div>[1]PETSC ERROR: Cannot H5Screate_simple()!</div><div>[1]PETSC ERROR: ------------------------------------------------------------------------</div><div>[1]PETSC ERROR: Petsc Release Version 3.1.0, Patch 8, Thu Mar 17 13:37:48 CDT 2011</div>
<div>[1]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[1]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[1]PETSC ERROR: See docs/index.html for manual pages.</div><div>
[1]PETSC ERROR: ------------------------------------------------------------------------</div><div>[1]PETSC ERROR: ./gvg on a linux-gnu named mylaptop by mmnasr Thu Jan 19 19:47:49 2012</div><div>[1]PETSC ERROR: Libraries linked from /home/mmnasr/Softwares/petsc-3.1-p8/linux-gnuPetsc Release Version 3.1.0, Patch 8, Thu Mar 17 13:37:48 CDT 2011</div>
<div>-hdf5/lib</div><div>[1]PETSC ERROR: Configure run at Tue Sep 6 18:38:57 2011</div><div>[1]PETSC ERROR: Configure options PETSC_ARCH=linux-gnu-hdf5 --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1 --with-debugging=0 COPTFLAGS=-O3 FOPTFLAGS=-O3 --download-hypre=/home/mmnasr/Softwares/hypre-2.7.0b.tar.gz --download-hdf5=1</div>
<div>[1]PETSC ERROR: ------------------------------------------------------------------------</div><div>[1]PETSC ERROR: VecView_MPI_HDF5() line 748 in src/vec/vec/impls/mpi/pdvec.c</div><div>[1]PETSC ERROR: VecView_MPI() line 840 in src/vec/vec/impls/mpi/pdvec.c</div>
<div>[1]PETSC ERROR: VecView() line 710 in src/vec/vec/interface/vector.c</div><div>[1]PETSC ERROR: Output_grid_hdf5() line 2358 in "unknowndirectory/"Output.c</div><div>[2]PETSC ERROR: See docs/changes/index.html for recent updates.</div>
<div>[3]PETSC ERROR: [2]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>Petsc Release Version 3.1.0, Patch 8, Thu Mar 17 13:37:48 CDT 2011</div><div>[2]PETSC ERROR: See docs/index.html for manual pages.</div>
<div>[2]PETSC ERROR: [3]PETSC ERROR: See docs/changes/index.html for recent updates.</div><div>[3]PETSC ERROR: See docs/faq.html for hints about trouble shooting.</div><div>[3]PETSC ERROR: See docs/index.html for manual pages.</div>
<div>[3]PETSC ERROR: ------------------------------------------------------------------------</div><div>[3]PETSC ERROR: ./gvg on a linux-gnu named mylaptop by mmnasr Thu Jan 19 19:47:49 2012</div><div>[3]PETSC ERROR: Libraries linked from /home/mmnasr/Softwares/petsc-3.1-p8/linux-gnu-hdf5/lib</div>
<div>[3]PETSC ERROR: Configure run at Tue Sep 6 18:38:57 2011</div><div>[3]PETSC ERROR: Configure options PETSC_ARCH=linux-gnu-hdf5 --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1 --with-debugging=0 COPTFLAGS=-O3 FOPTFLAGS=-O3 --download-hypre=/home/mmnasr/Softwares/hypre-2.7.0b.tar.gz --download-hdf5=1</div>
<div>[3]PETSC ERROR: ------------------------------------------------------------------------</div><div>[3]PETSC ERROR: VecView_MPI_HDF5() line 748 in src/vec/vec/impls/mpi/pdvec.c</div><div>[3]PETSC ERROR: VecView_MPI() line 840 in src/vec/vec/impls/mpi/pdvec.c</div>
<div>[3]PETSC ------------------------------------------------------------------------</div><div>ERROR: VecView() line 710 in src/vec/vec/interface/vector.c</div><div>[3]PETSC ERROR: Output_grid_hdf5() line 2358 in "unknowndirectory/"Output.c</div>
<div>[2]PETSC ERROR: ./gvg on a linux-gnu named mylaptop by mmnasr Thu Jan 19 19:47:49 2012</div><div>[2]PETSC ERROR: Libraries linked from /home/mmnasr/Softwares/petsc-3.1-p8/linux-gnu-hdf5/lib</div><div>[2]PETSC ERROR: Configure run at Tue Sep 6 18:38:57 2011</div>
<div>[2]PETSC ERROR: Configure options PETSC_ARCH=linux-gnu-hdf5 --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1 --with-debugging=0 COPTFLAGS=-O3 FOPTFLAGS=-O3 --download-hypre=/home/mmnasr/Softwares/hypre-2.7.0b.tar.gz --download-hdf5=1</div>
<div>[2]PETSC ERROR: ------------------------------------------------------------------------</div><div>[2]PETSC ERROR: VecView_MPI_HDF5() line 748 in src/vec/vec/impls/mpi/pdvec.c</div><div>[2]PETSC ERROR: VecView_MPI() line 840 in src/vec/vec/impls/mpi/pdvec.c</div>
<div>[2]PETSC ERROR: VecView() line 710 in src/vec/vec/interface/vector.c</div><div>[2]PETSC ERROR: Output_grid_hdf5() line 2358 in "unknowndirectory/"Output.c</div></div><div><br></div><div><br></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>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<br>