Again Station and binary files to be read in grads
ahmed kareem
am_kareem2001 at YAHOO.COM
Mon Mar 24 13:58:10 EDT 2008
Dear Jayakrishnan
Thanks. I have tried the fortran and C program and both they go well.
did you see the sheet 2 in excel files.
Again thank
Ahmed
Jayakrishnan PR <prjayakrishnan at GMAIL.COM> wrote:
Dear Kareem,
I herewith attaches the programs with which I used to convert station files into grads figures. Try yourself. You first run the FORTRAN followed by C.
Hope this helps and best wishes....
On Sun, Mar 23, 2008 at 11:53 AM, ahmed kareem <am_kareem2001 at yahoo.com> wrote:
Dear grads user
I have a problem to covert, the standard rainfall data Sheet 1; to be read grads.
I have tried the program in the manual but with no success.
I have mange to put the data in the SURFE program (sheet 2).
I will be thankful for any assistant.
Thank you in advance
Ahmed A.Kareem
Phd. Student Uni. of Khartoum
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.
--
***********************************************
Jayakrishnan.P.R
Junior Research Fellow
Department of Atmospheric Sciences
Cochin University of Science And Technology (CUSAT), Cochin-16
Kerala, India.
Mob: 09895417565
*********************************************** #include
/* Structure that describes a report header in a stn file */
struct rpthdr {
char id[8]; /* Station ID */
float lat; /* Latitude of Station */
float lon; /* Longitude of Station */
float t; /* Time in grid-relative units */
int nlev; /* Number of levels following */
int flag; /* Level independent var set flag */
} hdr;
main ()
{
FILE *ifile, *ofile;
char rec[80];
int flag,year,month,yrsav,mnsav,i;
float val;
/* Open files */
ifile = fopen ("resultrain.txt","r");
ofile = fopen ("resultrain.bin","wb");
if (ifile==NULL || ofile==NULL) {
printf("Error opening files\n");
return;
}
/* Read, write loop */
flag = 1;
while (fgets(rec,79,ifile)!=NULL) {
/* Format conversion */
sscanf (rec,"%i %i",&year,&month);
sscanf (rec+20," %g %g %g",&hdr.lat,&hdr.lon,&val);
for (i=0; i<8; i++) hdr.id[i] = rec[i+11];
/* Time group terminator if needed */
if (flag) {
yrsav = year;
mnsav = month;
flag = 0;
}
if (yrsav!=year || mnsav!=month) {
hdr.nlev = 0;
fwrite(&hdr,sizeof(struct rpthdr), 1, ofile);
}
yrsav = year;
mnsav = month;
/* Write this report */
hdr.nlev = 1;
hdr.flag = 1;
hdr.t = 0.0;
fwrite (&hdr,sizeof(struct rpthdr), 1, ofile);
fwrite (&val,sizeof(float), 1, ofile);
}
hdr.nlev = 0;
fwrite (&hdr,sizeof(struct rpthdr), 1, ofile);
}
1010066 48.87 -123.28 21.1
1010235 48.40 -123.48 16.5
1010595 48.58 -123.52 19.6
1010774 48.50 -123.35 16.8
1010780 48.33 -123.63 18.0
1010960 48.60 -123.47 18.8
1010961 48.57 -123.45 18.2
1010965 48.57 -123.43 17.5
1011467 48.58 -123.42 15.9
10114F6 48.57 -123.37 17.8
10114FF 48.55 -123.40 17.2
1011500 48.93 -123.75 23.1
1011743 48.68 -123.60 21.6
1011745 48.65 -123.57 21.0
1011775 48.65 -123.40 18.6
1011810 48.42 -123.48 16.0
1011860 48.83 -123.83 22.1
1011920 48.53 -123.37 17.1
1011922 48.52 -123.37 17.0
1012008 48.42 -123.70 19.8
1012010 48.72 -123.55 23.9
1012018 48.73 -123.60 21.6
1012190 48.82 -123.67 21.2
1012550 48.78 -123.72 21.2
1012562 48.83 -123.72 21.9
1012566 48.78 -123.68 21.0
1012570 48.77 -123.68 21.0
1012573 48.73 -123.73 21.1
1012628 48.35 -123.63 18.0
1012655 48.52 -123.38 17.1
1012656 48.53 -123.38 17.2
1012700 48.43 -123.42 15.5
1012707 48.42 -123.47 15.9
1012710 48.42 -123.40 14.3
1012883 48.50 -123.53 19.0
1013045 48.90 -123.35 23.1
1013051 48.87 -123.50 21.5
10130DE 48.87 -123.32 21.0
10130MN 48.98 -123.57 26.9
1013240 48.45 -123.55 18.1
1013241 48.62 -123.53 20.0
1013720 48.60 -123.35 17.8
1014430 48.97 -123.63 23.6
1014530 48.43 -123.53 17.3
1014820 48.58 -123.53 19.9
1014930 48.85 -123.33 20.9
1014931 48.85 -123.32 20.9
1015105 48.37 -123.57 14.7
1015107 48.42 -123.53 16.9
1015109 48.40 -123.53 16.7
1015134 48.65 -123.55 20.8
1015136 48.65 -123.55 20.8
1015150 48.48 -123.55 18.3
1015160 48.35 -123.73 20.5
1015242 48.38 -123.88 20.0
1015628 48.82 -123.72 21.2
1015638 48.82 -123.32 20.7
1016120 48.77 -123.30 20.3
1016169 48.70 -123.42 19.4
1016203 48.40 -123.98 19.8
1016641 48.30 -123.53 16.8
1016940 48.62 -123.42 18.2
1016941 48.50 -123.42 17.1
1016942 48.50 -123.40 17.0
1016980 48.97 -123.77 23.4
1016990 48.85 -123.50 20.5
1016992 48.82 -123.48 20.5
1016995 48.88 -123.55 21.4
10169DK 48.52 -123.42 17.2
10169MK 48.55 -123.42 17.2
1016RM0 48.60 -123.43 18.2
1017 43.73 -116.20 46.5
1017000 48.88 -123.57 21.4
1017098 48.80 -123.15 21.8
1017101 48.78 -123.05 25.6
1017230 48.65 -123.63 23.5
1017233 48.65 -123.63 23.5
1017329 48.68 -123.40 19.2
1017556 48.37 -123.73 22.2
1017559 48.42 -123.63 18.3
1017560 48.52 -123.70 20.6
1017563 48.57 -123.65 22.4
1017570 48.37 -123.82 20.2
1017575 48.38 -123.67 18.9
1017610 48.75 -123.22 19.9
1018590 48.45 -123.28 16.3
1018592 48.63 -123.47 18.9
1018595 48.43 -123.37 15.5
1018600 48.47 -123.47 16.6
1018605 48.48 -123.45 16.9
1018610 48.42 -123.32 14.0
1018611 48.42 -123.32 14.0
1018614 48.47 -123.30 17.0
1018616 48.52 -123.52 20.8
1018617 48.48 -123.40 16.6
1018620 48.65 -123.43 17.6
1018629 48.43 -123.33 15.4
1018640 48.43 -123.32 15.4
1018642 48.37 -123.75 21.1
1018644 48.43 -123.30 15.5c program
parameter (nl=26)
real alat1(nl),alon1(nl),clim(nl)
character sid(nl)
open(unit=1,file='rain.txt')
open(unit=2,file='resultrain.txt')
do 20 i=1,nl
read(1,*)sid(i),alat1(i),alon1(i),clim(i)
20 continue
12 format(f10.2,2x,f10.2,56(2x,f10.2))
c 12 format(f6.3,2x,f7.3,14(2x,f10.2),14(2x,f10.2),14(2x,f10.2)
c 1 ,14(2x,f10.2))
iyr=1961
imon=06
do 30 i=1,nl
c t1(i)=300.
write(2,14)iyr,imon,i,alat1(i),alon1(i),clim(i)
30 continue
14 format(i4,2x,i2,2x,i5,'ab',9x,f10.3,2x,f10.3,2x,f10.3)
stop
end
---------------------------------
Never miss a thing. Make Yahoo your homepage.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20080324/b287d7df/attachment.html
More information about the gradsusr
mailing list