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

📄 strain.c

📁 一个很好的分子动力学程序
💻 C
字号:
/* strain.c  *//*************************************************************************History*************************************************************************//*31 Jul 1992  Last record of existing version20 Jan 1998  Added support for .cor file, cleaned code a little*//*************************************************************************Includes*************************************************************************/#include <stdio.h>#include <stdlib.h>#include <cor0.h>#include <cstrain.h>#include <ctype.h>#include <string.h>/*************************************************************************Module-wide Variables*************************************************************************/char *Usage[] =	{   "\n",   " Usage: STRAIN [-t ftype] [-i filist] rad fn1 fn2 step1 step2",	"\n",   "    rad   radius of neighbor circle",   "    fn1   is input cor or rcv file with reference step",   "    fn2   is input cor or rcv file with steps to calculate STRAIN",   "    step1 is step number of step in fn1",   "    step2 is step number of step in fn2",	"\n",   " OPTIONS",   "    -t ftype  TYPELIST file (first line TYPELIST n followed by types)",   "    -i filist ILIST    file (first line ILIST    n followed by indices)",   " Calculates relative strain between step1 in file fn1 and step2 in file fn2.",	"\n",	__DATE__,	"\n",	NULL	};/*************************************************************************Main Function*************************************************************************/int main (int argc, char *argv[]) 	{   CFILE *cfin;   FILE  *fin;   int step1, step2;   float rad;   stepdata *s = (stepdata *) calloc (1, sizeof(stepdata));   stepdata *r = (stepdata *) calloc (1, sizeof(stepdata));   int  tflag=0, iflag=0;   char *ilistname = NULL;	char *typename = NULL;	char *refname = NULL;	char *curname = NULL;	char **TempPtr = NULL;   int c;   int iopt = 1;   /*  GET OPTIONAL FLAGS  */   /*   Parse while parameter has - and is not a number  */   while (     iopt<argc && argv[iopt][0]=='-'            && (                  (c=argv[iopt][1])<'0' || c>'9'                )         )   	{      c = toupper(c);      switch (c) 			{         case 'T':                    tflag = 1;                    typename = strdup (argv[iopt+1]);                    iopt += 1;                    break;         case 'I':                    iflag = 1;                    ilistname = strdup (argv[iopt+1]);                    iopt += 1;                    break;         default :                    fprintf (stderr,                       "Command line switch %s unknown.\n", argv[iopt]);                    break;      	}      iopt++;	   }   /*  PRINT USAGE MESSAGE  */   if (argc-iopt<5) 		{		TempPtr = Usage;		while (*TempPtr!=NULL)			{         printf ("%s\n", *TempPtr);			TempPtr++;			}      return 0;      }   /*  READ REQUIRED PARAMETERS  */   rad      = atof   (argv[iopt  ]);   refname  = strdup (argv[iopt+1]);   curname  = strdup (argv[iopt+2]);   step1    = atoi   (argv[iopt+3]);   step2    = atoi   (argv[iopt+4]);   /*  READ REFERENCE STEP  */   cfin = OpenCoordinateFile (refname, "r");   if (cfin==NULL) 		{      printf ("Sorry.  Can not open file %s.\n", refname);      return(0);		}	/*  Search for requested step  */   while ( ReadCoordinateFile (cfin,r)!=EOF && r->step!=step1);	/*  Close input file  */   CloseCoordinateFile (cfin);	/*  Test test requested step was found  */   if (r->step!=step1) 		{      printf 			("Sorry.  Reference step %i in file %s not found.\n", step1, refname);      return 1;		}   /*  READ CURRENT STEP  */   cfin = OpenCoordinateFile (curname, "r");   if (cfin==NULL) 		{      printf ("Sorry.  Can not open file %s.\n", curname);      return(1);		}   while ( ReadCoordinateFile(cfin,s)!=EOF && s->step!=step2 );   CloseCoordinateFile (cfin);   if (s->step!=step2) 		{      printf 			("Sorry.  Current step %i in file %s not found.\n", step2, curname);      return 1 ;		}   /*  READ TYPE FILE   */   if (tflag) 		{      fin = fopen (typename, "rt");      if (fin==NULL) 			{         fprintf (stderr, "ERROR:  Cannot open type file %s.\n", typename);         return(1);      	}      readtype (fin, s);      s->selkeep=1;       /*  Set flag to maintain type values  */      fclose (fin);   	}   /*  READ ILIST FILE  */   if (iflag) 		{      fin = fopen (ilistname, "rt");      if (fin==NULL) 			{         fprintf (stderr, "ERROR:  Cannot open ilist file %s.\n", ilistname);         return 1;			}      readilist (fin, s);      s->selkeep=1;       /*  Set flag to maintain type values  */      fclose (fin);   	}   /*  CALCULATE AND WRITE STRAIN TO STANDARD OUTPUT  */   calc_strain (rad, r, s, iflag);   return 0;	}

⌨️ 快捷键说明

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