<div>The GrADS Users Guide, in the &quot;Creating a Station Data File&quot; section, shows a short sample dataset as follows:</div><div><pre><span class="Apple-style-span" style="font-size: large;">Year   Month  Stid    Lat    Lon    Rainfall
1980     1     QQQ    34.3  -85.5    123.3 
1980     1     RRR    44.2  -84.5     87.1 
1980     1     SSS    22.4  -83.5    412.8
1980     1     TTT    33.4  -82.5     23.3 
1980     2     QQQ    34.3  -85.5    145.1
1980     2     RRR    44.2  -84.5    871.4
1980     2     SSS    22.4  -83.5    223.1
1980     2     TTT    33.4  -82.5     45.5</span>
</pre></div>I output the attached (test.sta.dat) binary file using an Excel VBA macro, shown here:<div><br><div><div>Private Type stadathdr � � � � &#39;data type &quot;station data header&quot; (len=24)</div><div>�� �stid As String * 8 � � �&#39;station ID (e.g., &quot;QQQ&quot;) � len=8</div>
<div>�� �lat As Single � � � � � &#39;station latitude �(world � len=4</div><div>�� �lon As Single � � � � � &#39;station longitude �coords) len=4</div><div>�� �tim As Single � � � � � &#39;time (grid-relative units) len=4</div>
<div>�� �nlev As Integer � � � � &#39;# data groups after header len=2</div><div>�� �nflg As Integer � � � � &#39;level indep var set flag � len=2</div><div>End Type</div><div>Sub WriteStaDat()</div><div>�� �Close � � � &#39;close any open files</div>
<div>�� �Dim hdr As stadathdr</div><div>�� �Dim yr, mo, flg As Integer � � �&#39;year (yyyy), month (m), flag</div><div>�� �Dim rf As Single � � � �&#39;rainfall (mm)</div><div>�� �Dim oldyr, oldmo As Integer � � &#39;old year, old month</div>
<div>�� �stadatfile = &quot;c:\projectmgr\stationdata\out\test.sta.dat&quot;</div><div>�� �rnum = 8 � &#39;# of data reports to read/write</div><div>�� �flg = 1 � � &#39;initialize flag</div><div>�� �Range(&quot;a1&quot;).Select</div>
<div>�� �Open stadatfile For Binary Access Write As #1</div><div>�� �For r = 1 To rnum � � &#39;loop through data rows, read in data</div><div>�� � � �yr = ActiveCell.Offset(r, 0)</div><div>�� � � �mo = ActiveCell.Offset(r, 1)</div>
<div>�� � � �hdr.stid = ActiveCell.Offset(r, 2)</div><div>�� � � �hdr.lat = ActiveCell.Offset(r, 3)</div><div>�� � � �hdr.lon = ActiveCell.Offset(r, 4)</div><div>�� � � �rf = ActiveCell.Offset(r, 5)</div><div>��� � � If flg = 1 Then</div>
<div>�� � � � � �oldyr = yr: oldmo = mo: flg = 0</div><div>�� � � �End If</div><div>�� � � �If oldyr &lt;&gt; yr Or oldmo &lt;&gt; mo Then �&#39;if new time group</div><div>�� � � � � �hdr.nlev = 0</div><div>�� � � � � �Put #1, , hdr � � &#39;write station header/time group terminator (no variable)</div>
<div>�� � � � � �&#39;rec = rec + 1</div><div>�� � � �End If</div><div>�� � � �oldyr = yr: oldmo = mo</div><div>�� � � �hdr.tim = 0#: hdr.nlev = 1: hdr.nflg = 1</div><div>�� � � �Put #1, , hdr � �&#39;write station header</div>
<div>�� � � �Put #1, , rf</div><div>�� �Next r</div><div>�� �hdr.nlev = 0</div><div>��� Put #1, , hdr � � &#39;write last time group terminator</div><div>�� �Close #1</div><div>End Sub</div><div><br></div><div>When I ran the stnmap utility, here were my results:</div>
<div>&gt;stnmap -i c:/projectmgr/stationdata/out/test.sta.ctl</div><div><div>��Name of binary data set: c:\projectmgr\stationdata\out\test.sta.dat</div><div>��Number of times in the data set: 2</div><div>��Number of surface variables: 1</div>
<div>��Number of level dependent variables: 0</div><div><br></div><div>Starting scan of station data binary file.</div><div>Binary data file open: c:\projectmgr\stationdata\out\test.sta.dat</div><div><br></div><div>Processing time step 1</div>
<div>��Invalid station hdr found in station binary file</div><div>��Possible causes: �Invalid level count in hdr</div><div>�� � � � � � � � � �Descriptor file mismatch</div><div>�� � � � � � � � � �File not station data</div>
<div>�� � � � � � � � � �Invalid relative time</div><div>�� � � � � � � � � �Invalid sequential format</div><div>�� �levs = 1123457434 �flag = 542265938 �time = 9.18369e-41�</div><div><br></div><div>It appears the station data file was not properly formatted. �Perhaps someone can understand why I&#39;m getting this result, and how to resolve.</div>
<div><br></div><div>Stephen Mc</div><br><div class="gmail_quote">On Thu, Apr 29, 2010 at 5:15 PM, Stephen McMillan <span dir="ltr">&lt;<a href="mailto:smcmillan@planalytics.com">smcmillan@planalytics.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Does anyone have a &quot;simple&quot; example of an Excel VBA (macro) for creating a station data file for use in GrADS? �I have searched the User Archives but came up empty. �I am familiar with the format instructions and the C and Fortran examples in the GrAD&#39;s Users Guide, but wish to use Excel to create the file.<div>

<br></div><div>I could probably eventually translate from the Fortran example to VBA, but it would help if someone has already done that!</div><div><br></div><div>Stephen M</div><div><div><br></div><div><br></div></div>
</blockquote></div><br></div></div></div>

<pre>***************************************************
The information contained in this e-mail message 
is intended only for the use of the recipient(s) 
named above and may contain information that is 
privileged, confidential, and/or proprietary. 
If you are not the intended recipient, you may not
review, copy or distribute this message. If you have
received this communication in error, please notify 
the sender immediately by e-mail, and delete the original message.
***************************************************