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

📄 vnd.h

📁 su 的源代码库
💻 H
📖 第 1 页 / 共 2 页
字号:
		vnd.ByteIncr[k]		vnd.BlockIncr[k]	VND *vnd 	VND control structure			Values required to be set on input			include vnd.N[k] and vnd.NumBytesPerNode	long lwmax	number of characters of memory available		int ich 	1 if force even number of first dimension			nodes per block (useful to allow			real-to-complex ffts and make it			possible to change number of bytes			per node at a later point)	return	-1 if all fits in memory		0 if successful in partitioning to fit in memory		1 if failed to partition so fits in memoryint VNDrwslice(VND *vnd,int iopanel, char mode, int idim, 			long iblock, long ipanel)	Read or write a slice for dimension idim into or from memory	VND *vnd	pointer to VND control structure	int iopanel	open panel counter (0 based. Always			equals 0 if only one panel open at a time.)	char mode	'r' for read; 'w' for write.	int idim	Dimension of slice to be read or written.			(0 based.  First dimension is idim=0.)	long iblock	Starting block for block matrix transpose 			slice associated with dimension idim.			(Be careful--not sequential 0,1,2,...)	long ipanel	Panel number (0 based) for desired slice.	Function returns a value of 0 if successful.int VNDseek(VND *vnd, long ib)	Seek the desired block in VND file structure.	(a) Go to the correct physical file, reopen if necessary	(b) Seek the correct starting byte within the file	VND *vnd	pointer to VND control structure	long ib		desired block number (0 based,			covers all panels and all files)	The function returns 0 if successful, Nonzero if fail.void VNDdump(VND *vnd,FILE *fp)	Dump out values stored in VND structure to file.	VND *vnd	pointer to VND control structure	FILE *fp	FILE pointer associated with output filevoid VNDerr(char *msg);	Abort and print message.	char *msg	message to print prior to abort.***************************************************************************//***************************************************************************This is the Fortran user interface to the VND routines.VNDOP(vnd, mode, lwmax, ndim, N, npanels, 		nbytes, file, ndir, dir, noppanels)		Open block matrix file structure.	int vnd		returns as pointer to filled out I/O 			control structure 	integer mode	0 for read only			1 for read and write (existing file)			2 for write and read (create new file)			3 for don't open, just compute buffer sizes 			and fill out structure	integer lwmax	Maximum memory buffer size in nodes to use	integer ndim	Number of block matrix transpose dimensions	integer N[ndim]	List of number of nodes for each dimension	integer npanels	Number of panels of block matrix structure	integer nbytes	Number of bytes per node	character*80 file File name from which other file names will be 			constructed.  The actual files used will have			.VND0, .VND1, ... extentions.  This name			should not have such an extention.	integer ndir	Number of file directories available for holding data.			Set ndir=0 to use one file in current directory.			Set ndir=-1 to look at .VND file for directories			to use.  File format is "number of directories"			on first line and then one line per directory name.	character*80 dir[] list of directories for VND files	int noppanels	Max number of panels to be open at one timeVNDRW(iop, iopanel, vnd, idim, key, ipanel, 		values, start, incr, nvalues, msgnum)	Read or write a vector for dimension "idim" 	character*1 iop	"r" for read; "w" for write	integer iopanel	Index of current open panel buffer 			(Ranges from 1 to noppanels.  Used to			allow access to multiple panels simultaneously.			For most applications, noppanels = 1 and 			iopanel will always equal 1.)		integer vnd	Structure holding block matrix file information.	integer idim	Current dimension for read or write			(idim=1 for first dimension.)	integer key[]	List of node positions for each dimension 			(Value for dimension "idim" needs to be there			but it's value is irrelevant.)	integer ipanel	Panel number for read or write.			(ipanel=1 for first panel.)	integer values[]Returns as values read or input as values to be 			written.	integer start	starting node (First node is 1, usually equals 1)	integer incr	node increment (usually 1)	integer nvalues	number of values to read or write 			(usually same as number of values in 			the specified dimension)	integer msgnum	A message number to be written out if error occurs.VNDCL(vnd, mode)	Close VND file structure.	integer vnd	Structure holding VND block matrix file information.	integer mode	0 means keep 			1 means deleteVNDFLUSH(vnd)	Flush out VND buffers to file.  	This may be important in applications where 	checkpoint/restart capabilities are needed.  	After VNDFLUSH, the data written by the VNDRW	routine are safely stored on disk rather than 	just in a memory buffer where it could be lost in	the event of a machine failure.	integer vnd	VND control structureAn example Fortran code similar to the C code example aboveappears below.  On the Cray (or Convex in PD8 mode), be sureto specify the bytes per node to be 8 instead of 4 in thethe VNDOP call.	PROGRAM EXAMPLE	INTEGER VND, N(3), KEY(3), BUF(50), I, J, K	CHARACTER*80 FILE	CHARACTER*80 DIR(2)	FILE='GEORGE'	N(1)=50	N(2)=50	N(3)=5	OPEN(10,FILE='LISTING')	CALL VNDOP(VND,2,1000,3,N,1,4,FILE,-1,DIR,1)	WRITE(10,*) ' '	WRITE(10,*) ' WRITE OUT THE DATA IN THE FIRST DIMENSION'	WRITE(10,*) ' DATA VALUES = I + J*100 + K*10000'	WRITE(10,*) ' WHERE I=1ST DIM, J=2ND DIM, AND K=3RD DIM'	DO 300 K=1,N(3)	   KEY(3)=K	   DO 200 J=1,N(2)		DO 100 I=1,N(1)  100		BUF(I) = I + 100*J + 10000*K		KEY(2)=J		CALL VNDRW('W',1,VND,1,KEY,1,BUF,1,1,N(1),1)  200      CONTINUE  300	CONTINUE	WRITE(10,*) ' '	WRITE(10,*) ' READ THE DATA ALONG DIMENSION 2 '	WRITE(10,*) ' THE 3RD DIMENSION IS HELD FIXED WITH K=2'	WRITE(10,*) ' VALUES ON A LINE SHOULD INCREMENT BY 100'	WRITE(10,*) ' VALUES SHOULD INCREMENT BY 1 FROM LINE TO LINE'	KEY(3)=2	DO 400 I=1,N(1)		KEY(1)=I		CALL VNDRW('R',1,VND,2,KEY,1,BUF,1,1,N(2),2)		WRITE(10,*) ' I = ',I,' BUF(1-5)=',(BUF(J),J=1,5)  400	CONTINUE	WRITE(10,*) ' '	WRITE(10,*) ' READ THE DATA ALONG DIMENSION 1'	WRITE(10,*) ' THE 3RD DIMENSION IS HELD FIXED WITH K=1'	WRITE(10,*) ' VALUES ON A LINE SHOULD INCREMENT BY 1'	WRITE(10,*) ' VALUES SHOULD DECREMENT BY 100'	KEY(3)=1	DO 500 J=1,N(2)		KEY(2)=N(2)+1-J		CALL VNDRW('R',1,VND,1,KEY,1,BUF,1,1,N(1),3)		WRITE(10,*) ' J = ',KEY(2),' BUF(1-5)=',(BUF(I),I=1,5)  500	CONTINUE	WRITE(10,*) ' '	WRITE(10,*) ' READ THE DATA ALONG DIMENSION 3'	WRITE(10,*) ' THE 1ST DIMENSION IS HELD FIXED WITH I=41 '	WRITE(10,*) ' VALUES ON A LINE SHOULD INCREMENT BY 10000'	WRITE(10,*) ' VALUES SHOULD INCREMENT BY 100 FROM LINE TO LINE'	KEY(1)=41	DO 600 J=1,N(2)		KEY(2)=J		CALL VNDRW('R',1,VND,3,KEY,1,BUF,1,1,N(3),4)		WRITE(10,*) ' J = ',J,' BUF(1-5)=',(BUF(K),K=1,5)  600	CONTINUE	CALL VNDCL(VND,1)		CLOSE(10)	STOP	END*************************************************************************//* MaxIOBuf is the maximum length of an Input/Output operation in bytes *//* allowed on current system.	If it is small, there may be no 	*//* advantage to using a large amount of memory for VND buffering so	*//* VND memory sizes are adjusted accordingly.				*//* #define MaxIOBuf 32768						*//* BytesPerSector equals the number of bytes per physical disk sector.	*//* If it is set to 1, then memory and i/o blocks for the VND routines	*//* are not rounded to to the next larger sector size so there is not	*//* any wasted space and files and memory buffers are as small as 	*//* possible.  On some machines, it is important to work in blocks that 	*//* are multiples of the sector size for efficiency reasons.  In that 	*//* case, use								*//*									*//* #define BytesPerSector BUFSIZ					*//*									*//* Note that BUFSIZ is defined in the stdio.h header file.		*/ /* Define integer size and routine names for Fortran interface		*//* Use this on CONVEX only if want 8 byte word length for *//* integers or floats.  Usually use the default. */#ifdef CONVEXPD8#define FORTINT long long int#define BytesPerSector BUFSIZ#define MaxIOBuf BUFSIZ*16/* The IBM RS6000 workstations assume Fortran routines *//* are all lower case if you are not using special compiler *//* options as are standardly done in systems like ProMAX.  */ /* For use with ProMAX, don't specify the compiler option *//* -DIBMRS6000 during your compiliation. */#elif IBMRS6000#define FORTINT long#define vndop_ vndop#define vndrw_ vndrw#define vndcl_ vndcl#define vndflush_ vndflush#define v2dr2c_ v2dr2c#define v2dc2r_ v2dc2r#define v2dr1_ v2dr1#define v2dr2_ v2dr2#define v2dw1_ v2dw1#define v2dw2_ v2dw2#define BytesPerSector BUFSIZ#define MaxIOBuf BUFSIZ*16/*  The CRAY assumes Fortran routines are capitalized.  *//*  Reals and ints are 8 bytes long.  Very long i/o's are best. *//*  New documentation suggests there is a better way to *//*  code Fortran string variables than done here for the Cray.  */#elif CRAY#define FORTINT int#define vndop_ VNDOP#define vndrw_ VNDRW#define vndcl_ VNDCL#define vndflush_ VNDFLUSH#define v2dr2c_ V2DR2C#define v2dc2r_ V2DC2R#define v2dr1_ V2DR1#define v2dr2_ V2DR2#define v2dw1_ V2DW1#define v2dw2_ V2DW2#define BytesPerSector BUFSIZ#define MaxIOBuf BUFSIZ*1024 /*  This works pretty well as the default on most machines. */#else#define FORTINT long#define BytesPerSector BUFSIZ#define MaxIOBuf BUFSIZ*8#endiftypedef struct{	long NumDim;		/* number of active dimensions 			*/	long NumBytesPerNode;	/* number of bytes per node 			*/	long NumBlocksPerPanel;	/* number of blocks per panel 			*/	long NumFiles;		/* number of physical files used 		*/	long NumPanels;		/* number of panels 				*/	long NumOpenPanels;	/* number of panels open at one time 		*/	long NumBytesMemBuf;	/* number of bytes in memory buffer 		*/	long NumBytesPerBlock;  /* number of bytes per block 			*/	long NumBytes1stDim;	/* number of bytes for IO in 1st dimension 	*/	long NumNodesPerBlock;	/* number of nodes per block 			*/	long NumBlocksPerFile;	/* number of blocks per physical file 		*/	int CurrentFile;	/* index (zero based) of current open file 	*/				/* -1 if not open 				*/	char *Mode;		/* file open mode: "rb", "rb+", or "wb+"	*/	FILE *FileDescriptor;	/* file descriptor for ANSI standard binary IO 	*/   				/* The following have "physical file number" as */				/* the first index 				*/	int *LenFileNames;	/* length of each file name in characters 	*/	char **FileNames;	/* list of file names for physical files 	*/	long *FirstDataByte;	/* first data byte for each physical file 	*/	long *LenFile;		/* length of each physical file in bytes 	*/   				/*The following are arrays dimensioned NumDim.	*/	long *N;		/* number of nodes for each dimension 		*/	long *NNodesPerBlock;	/* array of nodes per block for each dimension 	*/	long *NBlocks;		/* number of blocks in each dimension 		*/	long *ByteIncr;		/* byte increment between values in each 	*/				/* dimension 					*/	long *BlockIncr;	/* block increment for each dimension 		*/  				/* The following are arrays dimensioned 	*/				/* noppanels, one for each panel to open 	*/				/* simultaneously.				*/  	long *CurrentPanel;	/* current panel in memory (zero based) 	*/	int *CurrentDimension;	/* current dimension, -1 if none in memory 	*/	long *CurrentBlock;	/* starting block for current slice in memory 	*/				/* for current dimension 			*/	int *Modified;		/* 1 if current memory buffer has been modified */				/* 0 if current memory not modified and can be	*/				/*   thrown away without losing any information	*/	char *w;		/* pointer to internal memory buffer used by VND*/} VND;VND *VNDop(int mode, long lwmax, int ndim, long *N, long npanels, 		long nbytes, char *file, int ndir, char**dir, int noppanels);void VNDrw(char iop, int iopanel,VND *vnd,int idim, 		long *key, long ipanel, char *values,		long start, long incr, long nvalues,		int msgnum, char *msg);void VNDcl(VND *vnd, int mode);void VNDflush(VND *vnd);char *VNDtempname(char *root);int VNDGetDimensions(VND *vnd, long lwmax, int ich);int VNDrwslice(VND *vnd, int iopanel, char mode, int idim, long iblock, long ipanel);int VNDseek(VND *vnd, long ib);void VNDdump(VND *vnd,FILE *fp);void VNDlook(int *w, int lw);void *VNDemalloc(size_t n,char *msg);void VNDerr(char *msg);/* additions 2/94 to the C interface */void VNDr2c(VND *vnd);void VNDc2r(VND *vnd);VND *V2Dop(int mode, long lwmax, long nbytes, char *file, long n0, long n1);void V2Dr0(VND *vnd,long key,char *buf,int msgnum);void V2Dr1(VND *vnd,long key,char *buf,int msgnum);void V2Dw0(VND *vnd,long key,char *buf,int msgnum);void V2Dw1(VND *vnd,long key,char *buf,int msgnum);/* additions 2/94 to the Fortran interface */void vndr2c_(VND *vnd);void vndc2r_(VND *vnd);void v2dr1_(VND *vnd,FORTINT key,void *buf,FORTINT msgnum);void v2dr2_(VND *vnd,FORTINT key,void *buf,FORTINT msgnum);void v2dw1_(VND *vnd,FORTINT key,void *buf,FORTINT msgnum);void v2dw2_(VND *vnd,FORTINT key,void *buf,FORTINT msgnum);/* additions 9/94 to the C interface */void VNDmemchk( void *p , char * msg);void VNDfree( void *p, char *msg);long VNDtotalmem( void );#ifdef CRAYvoid vndop_( VND **vnd, FORTINT *fort_mode, FORTINT *fort_lwmax, 	FORTINT *fort_ndim, FORTINT *fort_N, FORTINT *fort_npanels,  	FORTINT *fort_nbytes, char *fort_file, 	FORTINT *fort_ndir, char *fort_dir, FORTINT *fort_noppanels);void vndrw_(char *fort_iop, FORTINT *fort_iopanel,VND **vnd,	FORTINT *fort_idim, FORTINT *fort_key, FORTINT *fort_ipanel,	void *values, FORTINT *fort_start, FORTINT *fort_incr,	FORTINT *fort_nvalues, FORTINT *fort_msgnum);#elsevoid vndop_( VND **vnd, FORTINT *fort_mode, FORTINT *fort_lwmax, 	FORTINT *fort_ndim, FORTINT *fort_N, FORTINT *fort_npanels,  	FORTINT *fort_nbytes, char *fort_file, 	FORTINT *fort_ndir, char *fort_dir, FORTINT *fort_noppanels, 	int lfile, int ldir);void vndrw_(char *fort_iop, FORTINT *fort_iopanel,VND **vnd,	FORTINT *fort_idim, FORTINT *fort_key, FORTINT *fort_ipanel,	void *values, FORTINT *fort_start, FORTINT *fort_incr,	FORTINT *fort_nvalues, FORTINT *fort_msgnum, long liop);#endifvoid vndcl_(VND **vnd, FORTINT *fort_mode);void vndflush_(VND **vnd);#ifdef IBMRS6000void *malloc();void free();#endif

⌨️ 快捷键说明

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