Error in processing binary file with stnmap utility

SB smitabodepudi at YAHOO.COM
Mon Feb 13 00:49:47 EST 2006


Hi All,

I am getting the following error while running stnmap on the sample data:
Could any one help me in identifying wht is wrong . I am trying to follow
the station map example program written in c on my windows xp.

Thanks a lot


ga-> !stnmap -i stat1.ctl
  Name of binary data set: c:\programs\output.txt
  Number of times in the data set: 1
  Number of surface variables: 1
  Number of level dependent variables: 0

Starting scan of station data binary file.
Binary data file open: c:\programs\output.txt
Processing time = 1
  Invalid station hdr found in station binary file
  Possible causes:  Invalid level count in hdr
                    Descriptor file mismatch
                    File not station data
                    Invalid relative time
    levs = 0  flag = 1633771873  time = 0
ga->

My c program is : (compiled with turbo c on windows xp)

#include <stdio.h>
#include <string.h>

struct stnhdr
{
  char id[8];
  float lat;
  float lon;
  float t;
  int nlev;
  int flag;
}stn;

FILE *f2;

int main ()
{

int i,j,k;

float value;
f2 = fopen("OUTPUT.TXT","wb");

for(i =0;i<8;i++)
   stn.id[i]='a';

for(j=0;j<10;j++)
{
for(i = 0; i< 10; i++)
{
   stn.lat = j;
   stn.lon = i;
   value = i*j;
  if (i == 0)
  {
     stn.nlev = 0;
     stn.flag = 0;
     stn.t = 0.0;
     fwrite(&stn,sizeof(struct stnhdr),1,f2);
  }

  stn.nlev=1;
  stn.flag =1;
  fwrite(&stn,sizeof(struct stnhdr),1,f2);
  fwrite(&value, sizeof(float),1,f2);

}
}

stn.nlev = 0;
fwrite(&stn,sizeof(struct stnhdr),1,f2);
printf("size of struct stnhdr %d",sizeof(struct stnhdr));

}
/* end of program */


And the ctl file is :

dset  c:\programs\output.txt
dtype station
stnmap stndat.map
undef -9999
title Station data sample
tdef 1 linear 12FEB2006 1dy
zdef 1 levels 1000
vars 1
x 0 99 test data
endvars



More information about the gradsusr mailing list