<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">you could use something like this:<div><br></div><div><div>'q time'</div><div>datetime = subwrd(result, 3)</div><div><br></div><div>That will give you the date and time in grads format, e.g., "00Z01JAN1979".&nbsp;If you want, you could go further, with something like this:</div><div><br></div><div><div>formatted_time = substr(datetime, 9, 4) '/' substr(datetime, 6, 3) '/' substr(datetime, 4, 2) ' ' substr(datetime, 1, 2) ':00'</div><div>say "formatted time: " formatted_time</div><div><br></div><div>Unfortunately, I don't know any way to convert "JAN" to "01" within grads. So you may need to use awk (or similar) to convert the dates after-the-fact, in which case you might as well just write the datetime directly to the file, and then convert that later.</div><div><br></div><div>Matthias</div><div><br></div></div><div><div>On Nov 4, 2009, at 4:26 PM, Javier Peņa wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div id="result_box" dir="ltr">Hello everyone, <br>&nbsp; <br>I have a netcdf file from&nbsp;which I can obtain any of the variables with the following script (for example to get u wind component): <br>&nbsp; <br>* takes the values of the component or in a column <br> 'reinit' <br>'sdfopen <a href="http://prueba.nc">prueba.nc</a>' <br>'set lat 41' <br>'set lon 359' <br>'set lev 1' <br>to = 1 <br>* Write the variable to a file <br>* 'set gxout vector' <br> * 'set fwrite z: \ dummy.dat' <br>while (to &lt;5) <br>'set t' to <br>tmp ='' <br>tmp = subwrd (rerult, 4) <br>'d u', tmp = tmp%''subwrd (result, 4) <br>rrc = write ( 'c: \ prueba_c \ pruebas_archivo_ecmwf \ new_u.txt', tmp) <br> to = to + 1 <br>endwhile <br><br>but my question is, can I get the date which belongs each variable value? That is, if I have values for the velocity component u: 2.3, 3.4, 5.6, 3.9, can I get a. txt what next? <br>&nbsp; <br> Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; U (m / s) <br>2009/12/06 00:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.3 <br>2009/12/06 06:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.4 <br>2009/12/06 18:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.6 <br>2009/12/07 00:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.9</div> <div><br clear="all">Thank you very much. Best regards.</div> <div><br>Javier Peņa</div></blockquote></div><br></div></body></html>