⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grid.c

📁 seismic software,very useful
💻 C
字号:
#include <stdio.h>#include "par.h"#include "cwp.h"#include "gridhd.h"readvgrid (file,array,header)char *file;float **array;ghed *header;	{	FILE *infp;	long long fsize, hsize, ipos;	int itmp;	double rint();	if (!strcmp(file,"stdin")) {        infp = stdin; 	} else	{		infp = efopen(file,"r");	}	file2g(infp);	fprintf(stderr,"sizeof(header)=%d \n",sizeof(header[0]));	ipos = 0;	fseek64(infp,ipos,SEEK_END);	fsize = ftell64(infp);	fsize = fsize - sizeof(header[0]);	fseek64(infp,fsize,0);	fread(header,1,sizeof(header[0]),infp);	hsize = rint(header->n1 / header->scale)			*rint(header->n2 / header->scale)			*rint(header->n3 / header->scale)			*rint(header->n4 / header->scale)			*rint(header->n5 / header->scale)			*rint(header->dtype / header->scale);	if (hsize != fsize) {		fprintf (stderr, "hsize=%g fsize=%g\n",(float)hsize,(float)fsize);		fprintf (stderr, "file %s not vgrid type or inconsistent size\n", file);		fclose (infp);		return (0);		}	if (array) {		if ((*array = (float*)malloc(hsize)) == 0) {			fprintf (stderr, "cant allocate space for vgrid array %s\n", file);			fclose (infp);			return (0);			}		fseek64(infp,0,0);		if (fread (*array,1,hsize,infp) != hsize) {			fprintf (stderr, "cant read vgrid data from %s\n", file);			fclose(infp);			return (0);			}	}	fclose(infp);	return (hsize);}writevgrid (file,array,header)char *file, *array;ghed header;	{	long long size;	FILE *outfp;	double rint();	if (!strcmp (file,"stdout")) {		outfp = stdout;	} else	{		outfp = efopen(file,"w");	}	file2g(outfp);	size = rint(header.n1 / header.scale)	      * rint(header.n2 / header.scale)	      * rint(header.n3 / header.scale)	      * rint(header.n4 / header.scale)	      * rint(header.n5 / header.scale)	      * rint(header.dtype / header.scale);	if (fwrite(array,1,size,outfp) != size) {		fprintf (stderr, "cant write vgrid file %s data\n", file);		return (0);	}	if (fwrite(&header,1,sizeof(header),outfp) != sizeof(header)) {		fprintf (stderr, "cant write vgrid file %s data\n", file);		return (0);	}	return (size);}/*main ()	{	float *array;	ghed header;	printf ("size=%d\n",readvgrid("stdin",&array,&header));	printf ("size=%d\n",writevgrid("junk",array,header));	}*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -