<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle">P {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
</style>
</head>
<body fPStyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<p>* Open your netCDF file<br>
* ---------------------------<br>
'sdfopen xxxxxxx.nc'</p>
<p>&nbsp;</p>
<p>* Get the start time<br>
* ---------------------<br>
'set t 1'<br>
'q time'<br>
startTime = subwrd(result, 3)</p>
<p>&nbsp;</p>
<p>* Get end time requires you to find the number<br>
* of time steps in the data set first<br>
* ---------------------------------------------------------<br>
'q ctlinfo'<br>
ctlRes = result</p>
<p>&nbsp;</p>
<p>* Loop through the result of 'q ctlinfo'<br>
* to find the line that starts with 'tdef'<br>
* ---------------------------------------------<br>
line = 1<br>
found = 0<br>
while (!found)<br>
&nbsp; info = sublin(ctlRes, line)<br>
&nbsp; if (subwrd(info, 1) = 'tdef')<br>
&nbsp;&nbsp;&nbsp; handle = info<br>
&nbsp;&nbsp;&nbsp; found = 1<br>
&nbsp; endif<br>
&nbsp; line = line &#43; 1<br>
endwhile</p>
<p>&nbsp;</p>
<p>* Variable 'handle' now contains the line that starts<br>
* with 'tdef'<br>
*<br>
* Second word on the line is the number of time steps<br>
* -----------------------------------------------------------------<br>
numOfSteps = subwrd(handle, 2)</p>
<p>&nbsp;</p>
<p>* Set time environment to last step of data set<br>
* ---------------------------------------------------------<br>
'set t 'numOfSteps<br>
'q time'</p>
<p>&nbsp;</p>
<p>* Grab time of last time step<br>
* ----------------------------<br>
endTime = subwrd(result, 3)</p>
<p>&nbsp;</p>
<p>* Write out to text file<br>
* [Here you enter the path and name of the text file<br>
* you want to output]<br>
* -----------------------------------------------------<br>
rc=write(NAME_AND_PATH_OF_TEXTFILE, 'Start time = 'startTime', End time = 'endTime)<br>
rc=close(NAME_AND_PATH_OF_TEXTFILE)</p>
<div DanaPrelude="1">
<p>&nbsp;</p>
<div class="WordSection1">
<p class="MsoNormal"></p>
<hr tabindex="-1">
<p></p>
</div>
</div>
<div style="FONT-SIZE: 16px; FONT-FAMILY: Times New Roman; COLOR: #000000">
<div id="divRpF757784" style="DIRECTION: ltr"><font color="#000000" size="2" face="Tahoma"><b>From:</b> gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] on behalf of Malleswararao Maguluri [mallesh4science@gmail.com]<br>
<b>Sent:</b> Wednesday, June 11, 2014 10:58 AM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> [gradsusr] how to extract start date and end date using GrADS script from netcdf file?<br>
</font><br>
</div>
<div></div>
<div>
<div dir="ltr">
<div>Hi,<br>
<br>
&nbsp; how to extract start date and end date using GrADS script from netcdf file?. I need start date and end date output in text file.<br>
<br>
</div>
<div>Waiting for your reply,<br>
</div>
<div><br>
</div>
Thanks &amp; regards, <br clear="all">
<div>
<div><br>
-- <br>
<div dir="ltr">M. MALLESWARA RAO<br>
M.Tech (Atmospheric Science) &amp; M.Sc (Physics)<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>