<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">This question and similar variants comes up so often, I have finally written a documentation page about importing/exporting ASCII data. <div>Please see <a href="http://iges.org/grads/gadoc/ascii.html">http://iges.org/grads/gadoc/ascii.html</a>. This page is linked to from the headings "ASCII data" and "text data" in the documentation index. At the moment, the examples are all based on gridded data. The fprintf.gs script in the opengrads cookbook is quite similar to example #2 in the doc page. The third example takes it a bit further and shows you how to do what you are asking here. </div><div>--Jennifer</div><div><br></div><div><div>On Oct 6, 2013, at 8:51 PM, Muhammad Yunus Ahmad Mazuki wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div>Because you can combine string operands, You can combine the four variables that were in different operands into one operands, and print that whole string instead. Something like:<br><br></div>line.1=xlat.1+' '+x.lon.1+' 'temp.1+' 'ppt.1<br>
<br></div>Be sure to leave appropriate separator like spaces, or commas, depending whether you want to save in binary, text or csv.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Oct 7, 2013 at 6:56 AM, Andrew Friedman <span dir="ltr"><<a href="mailto:andfried@berkeley.edu" target="_blank">andfried@berkeley.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Uzair,<br>
<br>
I don't think that fprintf alone can make what you're looking for.<br>
<br>
I haven't done this, but two possible approaches come to mind:<br>
1. You can combine the output of different variables from fprintf using an external text processing utility such as awk.<br>
2. You can create a table from netcdf data directly using the NCO (netcdf operator) ncks:<br>
<a href="http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink" target="_blank">http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink</a> (see section 4.7.1: Filters for ncks)<br>
<br>
Can you describe more what you're using the table for? Others may be able to help with a better understanding of the specifics.<br>
<br>
Andrew<br>
<div><div class="h5"><br>
<br>
On Oct 6, 2013, at 10:18 AM, uzair manan <<a href="mailto:uzair_july@hotmail.com">uzair_july@hotmail.com</a>> wrote:<br>
<br>
> GOOD MORNING EVERYONE:<br>
><br>
> I've simulated global data using a regional climate model.. The output it generates is in netcdf format. The output file contains four variables which are :-<br>
> 1. Latitude (xlat)<br>
> 2. Longitude (xlon)<br>
> 3. Temperature (temp)<br>
> 4. Precipitation (ppt)<br>
><br>
> Now how can I generate, using fprintf or any other way, a single file that contains a template as shown below:- (FOR EXAMPLE)<br>
><br>
> LATITUDE LONGITUDE TEMPERATURE PRECIPITATION<br>
><br>
> 23 60 23 10mm<br>
> 23.5 60.5 26 26mm<br>
> . . . .<br>
> . . . .<br>
> . . . .<br>
><br>
> A format like above or anything similar to it will work. Please give an example<br>
><br>
> Any help will be appreciated...<br>
><br>
><br>
><br>
><br>
><br>
> Best regards<br>
><br>
> Uzair Mannan<br>
> Cell: +923323489950<br>
> NED University of Engineering & Technology<br>
> Karachi, Pakistan<br>
><br>
</div></div>> _______________________________________________<br>
> gradsusr mailing list<br>
> <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote></div><br></div>
_______________________________________________<br>gradsusr mailing list<br><a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>http://gradsusr.org/mailman/listinfo/gradsusr<br></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Jennifer M. Adams<br>Center for Ocean-Land-Atmosphere Studies (COLA)<br>111 Research Hall, Mail Stop 2B3<br>George Mason University<br>4400 University Drive<br>Fairfax, VA 22030 <br><br></div><div><br class="khtml-block-placeholder"></div><br class="Apple-interchange-newline"></span></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></body></html>