<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="OPENWEBMAIL" name=GENERATOR>
</HEAD>
<BODY bgColor=#ffffff>
<font size="2">
<p><font face="verdana,arial,helvetica,sans-serif" size="2">Dear GrADS Users,</font></p>
<p><font face="verdana,arial,helvetica,sans-serif" size="2">I want to plot the stations' climatology contour. My TXT data file is the format of (stnid, lat, lon, climatology value). So I did as followings but it doesn't work. I don't how I shuld do.</font></p>
<p><font face="verdana,arial,helvetica,sans-serif" size="2"><strong>First, I used the following C++ program to write the TXT file into DAT file:</strong></font></p>
<p>#include "stdafx.h"
<br />#include <stdio.h></p>
<p>int main(int argc, char* argv[])
<br />{
<br /> /* Structure that describes a report header in a stn file */
<br /> struct rpthdr
<br /> {
<br /> char id[8]; /* Station ID */
<br /> float lat; /* Latitude of Station */
<br /> float lon; /* Longitude of Station */
<br /> float t; /* Time in grid-relative units */
<br /> int nlev; /* Number of levels following */
<br /> int flag; /* Level independent var set flag */
<br /> } hdr;</p>
<p> FILE *ifile, *ofile;
<br /> char rec[80];
<br /> //int flag,year,month,yrsav,mnsav;
<br /> int i;
<br /> float val;</p>
<p>/* Open files */
<br /> ifile = fopen ("clim.txt","r");
<br /> ofile = fopen ("clim.dat","wb"); </p>
<p> if (ifile==NULL || ofile==NULL) {
<br /> printf("Error opening files\n");
<br /> return 1;
<br /> }</p>
<p>/* Read, write loop */
<br /> val = 0.0;
<br /> while (fgets(rec,79,ifile)!=NULL) {
<br /> /* Format conversion */
<br /> sscanf (rec+8," %g %g %g",&hdr.lat,&hdr.lon,&val);
<br /> for (i=0; i<8; i++) hdr.id[i] = rec[i]; </p>
<p> /* Write this report */
<br /> hdr.nlev = 1;
<br /> hdr.flag = 1;
<br /> hdr.t = 0.0;
<br /> fwrite (&hdr,sizeof(struct rpthdr), 1, ofile);
<br /> fwrite (&val,sizeof(float), 1, ofile);
<br /> }
<br /> /* Time group terminator */
<br /> hdr.nlev = 0;
<br /> fwrite (&hdr,sizeof(struct rpthdr), 1, ofile); </p>
<p> fclose(ifile);
<br /> fclose(ofile); </p>
<p> return 0;
<br />}
<br /></p>
<p><strong>Second, I write the ctl file 'clim.ctl' as</strong></p>
<p>DSET ^clim.dat
<br />DTYPE station
<br />STNMAP ^clim.map
<br />UNDEF -999.9
<br />TITLE 61-90 climatology
<br />TDEF 1 LINEAR Jan1960 1mo
<br />VARS 1
<br />prep 1 99 precipitation climatology of station
<br />ENDVARS</p>
<p><strong>Finally, I write the gs file 'clim.gs' as</strong></p>
<p>'!stnmap -i ../stnmap/AB_elev.ctl'</p>
<p>'reinit'
<br />'open ../stnmap/AB_elev.ctl'
<br />'set gxout contour'
<br />'set grads off'
<br />'set mproj nps'
<br />'set grid off'
<br />'set frame off'
<br />'set cstyle 3'
<br />'set csmooth off'
<br />'set t 1 1'
<br />'d prep'</p>
<p>'set font 1'
<br />'set string 1 tc 3'
<br />'set strsiz 0.15 0.15'
<br />'draw title 1961-1990 Climatology in January'
<br />'printim ../Clim.gif gif white'</p>
<p>Thanks.</p>
<p>Qingfang
<br /></p>
</font>
</BODY>
</HTML>