Hi SAC user,<br><br>I am trying to write the complete sac header for evenly space file using wsac0() in c program.<br>But i am always getting error or segmentation fault. The problem is that I am not able to understand <br>what input it is taking to write the complete header information using wsac0() function. what is the 2nd and <br>3rd input in wsac0(). The code to write the sac file is given here. What is the problem in the code or I would be thankful for your advise to correct the code. <br><br><br><br>int main(int argc, char *argv[])<br>{ <br>&nbsp; FILE *fp1;<br>&nbsp; char **fi;<br>&nbsp; char fi1[400];<br>&nbsp; static int nrf=0;<br>&nbsp; int i;<br>&nbsp; nrf=count(argv[1]);<br>&nbsp; fp1=fopen(argv[1],"r");<br>&nbsp;&nbsp;&nbsp; fscanf(fp1,"%s",fi1);<br>&nbsp;&nbsp;&nbsp; fi=malloc ( strlen(fi1) + 1 );<br>&nbsp;&nbsp;&nbsp; strcpy(fi,fi1);<br>&nbsp; fclose(fp1);<br>&nbsp; /* Define variables to be used in the call to rsac1() and getfhv() */<br>&nbsp;&nbsp;&nbsp; static&nbsp; int max = MAX, nlen, nerr, n1, n2, npts=0;<br>&nbsp;&nbsp;&nbsp; static float xarray[ MAX ] , yarray [ MAX ], beg , del , delta , b , o, e, stla=0, stlo=0, stel=0, evla,evlo,evdp, mag, cmpaz;<br>&nbsp; int leven=1;<br>&nbsp; float minimum=1.0, maximum=6.0;<br><br>&nbsp;&nbsp;&nbsp; static char kname[ 31 ], out[31], *kstnm, *kcmpnm;<br>&nbsp;&nbsp;&nbsp; strcpy(kname,fi[i]);<br>&nbsp;&nbsp;&nbsp; rsac1(kname, yarray, &amp; nlen, &amp; beg, &amp; del, &amp; max, &amp; nerr, strlen( kname ) ) ;<br>&nbsp;&nbsp;&nbsp; /* Check the Error status */<br>&nbsp;&nbsp;&nbsp; if ( nerr != 0 ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Error reading SAC file: %s\n", kname);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(-1);<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; newhdr();<br>&nbsp;&nbsp;&nbsp; setnhv("NPTS", &amp; npts, &amp; nerr, strlen("NPTS"));<br>&nbsp;&nbsp;&nbsp; setfhv("DELTA", &amp; del, &amp;nerr, strlen("DELTA"));<br>&nbsp;&nbsp;&nbsp; setfhv("B", &amp; b, &amp; nerr, strlen("B"));<br>&nbsp;&nbsp;&nbsp; setfhv("E", &amp; e, &amp; nerr, strlen("E"));<br>&nbsp;&nbsp;&nbsp; setfhv("O", &amp; o, &amp; nerr, strlen("O"));<br>&nbsp;&nbsp;&nbsp; setfhv("STLA", &amp; stla, &amp; nerr, strlen("STLA"));<br>&nbsp;&nbsp;&nbsp; setfhv("STLO", &amp; stlo, &amp; nerr, strlen("STLO"));<br>&nbsp;&nbsp;&nbsp; setfhv("STEL", &amp; stel, &amp; nerr, strlen("STEL"));<br>&nbsp;&nbsp;&nbsp; setfhv("EVLA", &amp; evla, &amp; nerr, strlen("EVLA"));<br>&nbsp;&nbsp;&nbsp; setfhv("EVLO", &amp; evlo, &amp; nerr, strlen("EVLO"));<br>&nbsp;&nbsp;&nbsp; setfhv("EVDP", &amp; evdp, &amp; nerr, strlen("EVDP"));<br>&nbsp;&nbsp;&nbsp; setkhv("KSTNM", kstnm, &amp; nerr, strlen("KSTNM"),strlen(kstnm));<br>&nbsp;&nbsp;&nbsp; setfhv("CMPAZ", &amp;cmpaz, &amp;nerr, strlen("CMPAZ"));<br>&nbsp;&nbsp;&nbsp; setkhv("KCMPNM", kcmpnm, &amp; nerr, strlen("KCMPNM"),strlen(kcmpnm));<br>&nbsp;&nbsp;&nbsp; setfhv("MAG", &amp; mag, &amp; nerr, strlen("MAG"));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(nerr != 0) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Error in reading SAC File: %s\n", kname);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; sprintf(out,"%s.out",fi);<br>&nbsp;&nbsp;&nbsp; strcpy(kname,out);<br>&nbsp;&nbsp; wsac0 (kname, b, yarray, &amp;nerr, strlen( out ));<br>&nbsp;&nbsp;&nbsp; if ( nerr != 0 ) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, "Error getting header variable: delta\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit(-1); }<br>&nbsp; free(fi);<br>&nbsp; return 0;<br>}<br><br><br>Error Message:<br>xx3.c: In function ‘main’:<br>xx3.c:105:4: error: incompatible type for argument 2 of ‘wsac0’<br>../include/sacio.h:104:6: note: expected ‘float *’ but argument is of type ‘float’<br><br>What will be the input in 2nd and 3rd place of wsac0() for evenly space file<br><br>Thanking you,<br><br>Sunil Roy<br>Research Scholar<br>National Geophysical Research Institute<br>Hyderbad, India<br><br><A HREF="http://sigads.rediff.com/RealMedia/ads/click_nx.ads/www.rediffmail.com/signatureline.htm@Middle?" target="_blank"><IMG SRC="http://sigads.rediff.com/RealMedia/ads/adstream_nx.ads/www.rediffmail.com/signatureline.htm@Middle"></A><br><table width="578" border="0" cellspacing="0" cellpadding="0"><tr><td><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#393939;">Follow&nbsp;<span style="color:#0000CC;"><b><u><a href="http://track.rediff.com/click?url=___http://dealhojaye.rediff.com?sc_cid=rediffmailsignature___&cmp=signature&lnk=rediffmailsignature&newservice=deals" target="_blank">Rediff Deal ho jaye!</a></u></b></span>&nbsp;to get exciting offers in your city everyday.</span></td></tr></table>