<!DOCTYPE html><!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">
hi Matt & all, I just had a query from one of my users which prompted me to see if any progress had been made on the issue below - using PETSc to get the number of time steps in an HDF5 file. I can't see anything new in PETSc on this -
</div>
<!-- Preheader Text : END -->
<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerStart</div>
<!--[if ((ie)|(mso))]>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" ><tr><td>
<table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #90a4ae;background-color:#D0D8DC;"><tr><td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px">
<tr><td style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr">
This Message Is From an External Sender
</td></tr>
<tr><td style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr">
This message came from outside your organization.
</td></tr>
</table>
</td></tr></table>
</td></tr></table>
<![endif]-->
<![if !((ie)|(mso))]>
<div dir="ltr" id="pfptBanner9q3rw1u" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #D0D8DC !important; background-color: #D0D8DC; border-top: 4px solid #90a4ae !important; border-top: 4px solid #90a4ae;">
<div id="pfptBanner9q3rw1u" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBanner9q3rw1u" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px">
This Message Is From an External Sender
</div>
<div id="pfptBanner9q3rw1u" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;">
This message came from outside your organization.
</div>
</div>
<div style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"> </div>
</div>
<![endif]>
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerEnd</div>
<!-- Email Banner : END -->
<!-- BaNnErBlUrFlE-BoDy-end -->
<html><head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBanner9q3rw1u { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButton9q3rw1u:hover, .pfptPrimaryButton9q3rw1u:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButton9q3rw1u:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>hi Matt & all,</p>
<p>I just had a query from one of my users which prompted me to see
if any progress had been made on the issue below - using PETSc to
get the number of time steps in an HDF5 file.</p>
<p>I can't see anything new in PETSc on this - I did try using
PetscViewerHDF5ReadSizes() to see if that would do it, but it
seems it doesn't. If I use that on the "time" dataset it just
returns 1.</p>
<p>Regards, Adrian<br>
</p>
<div class="moz-cite-prefix">On 11/10/21 2:08 pm, Adrian Croucher
wrote:<br>
</div>
<blockquote type="cite" cite="mid:220daca5-21ea-00df-bc51-ba6124d020ad@auckland.ac.nz">
<div class="moz-cite-prefix">On 10/11/21 11:59 AM, Matthew Knepley
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAMYG4G=8FOTHkBwUd5C0KHHcuv7rDdY7HZviQxw55Hwj=z0WYQ@mail.gmail.com">
<div dir="ltr">
<div dir="ltr">On Sun, Oct 10, 2021 at 6:51 PM Adrian Croucher
<<a href="mailto:a.croucher@auckland.ac.nz" moz-do-not-send="true" class="moz-txt-link-freetext">a.croucher@auckland.ac.nz</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">hi<br>
<br>
Is there any way to query the PETSc HDF5 viewer to find
the number of <br>
time steps in the file?<br>
<br>
A common use case I have is that an HDF5 file from a
previous simulation <br>
is used to get initial conditions for a subsequent run.
The most common <br>
thing you want to do is restart from the last set of
results in the <br>
previous output. To do that you need to know how many time
steps there <br>
are, so you can set the output index to be the last one.<br>
<br>
I thought maybe I could just query the size of the "time"
dataset, but I <br>
can't even see any obvious way to do that using the viewer
functions.<br>
</blockquote>
<div><br>
</div>
<div>There is nothing in there that does it right now. Do
you know how to do it in HDF5?</div>
<div>If so, I can put it in. Otherwise, I will have to learn
more HDF5 :)</div>
</div>
</div>
</blockquote>
<br>
<p>I haven't actually tried this myself but it looks like what you
do is:</p>
<p>1) get the dataspace for the dataset (in our case the "time"
dataset):</p>
<p>hid_t dspace = H5Dget_space(dset);</p>
<p>2) Get the dimensions of the dataspace:<br>
</p>
<p>const int ndims = 1;<br>
</p>
<p>hsize_t dims[ndims];<br>
H5Sget_simple_extent_dims(dspace, dims, NULL);</p>
<p>The first element of dims should be the number of time steps.
Here I've assumed the number of dimensions of the time dataset
is 1. In general you can instead query the rank of the dataspace
using H5Sget_simple_extent_ndims() to get the rank ndims.</p>
<p>Regards, Adrian<br>
</p>
</blockquote>
<pre class="moz-signature" cols="72">--
Dr Adrian Croucher
Senior Research Fellow
Department of Engineering Science
Waipapa Taumata Rau / University of Auckland, New Zealand
email: <a class="moz-txt-link-abbreviated" href="mailto:a.croucher@auckland.ac.nz">a.croucher@auckland.ac.nz</a>
tel: +64 (0)9 923 4611</pre>
</body>
</html>