--- trunk/tcProps/tcProps.c 2004/02/13 22:13:06 1052 +++ trunk/tcProps/tcProps.c 2004/02/20 21:20:37 1062 @@ -2,84 +2,432 @@ #include #include +#include #include "params.h" #include "tcProps.h" #include "readWrite.h" +#include "scdCorr.h" +#include "directorHead.h" +#define VERSION_MAJOR 0 +#define VERSION_MINOR 1 + +char *programName; /*the name of the program */ +void usage(void); + int main( int argC, char *argV[] ){ // list of 'a priori' constants - const int nLipAtoms = 19; - const int nBonds = 18; - const int nLipids = NLIPIDS; - const int nSSD = NSSD; - const int nAtoms = nLipAtoms * nLipids + nSSD; + const int nLipAtoms = NL_ATOMS; + const int nBonds = NBONDS; + const int nLipids = NLIPIDS; + const int nSSD = NSSD; + const int nAtoms = nLipAtoms * nLipids + nSSD; // different needed variables struct atomCoord atoms[nAtoms]; int i,j,k; - char* inName; - int nFrames; + + char* outPrefix; // the output prefix + char currentFlag; // used in parsing the flags + int done = 0; // multipurpose boolean + int havePrefix; // boolean for the output prefix + int haveMaxLength; + char* conversionCheck; + int conversionError; + int optionError; + char* pair1; + char* pair2; + int scdCorr; + double startTime; + double maxLength; + int directorHead, directorWhole; // system initialization isScanned = 0; + fileOpen = 0; + nFrames = 0; + frameTimes = NULL; + + outPrefix = NULL; + inName = NULL; + + haveMaxLength = 0; + conversionError = 0; + optionError = 0; + havePrefix = 0; + scdCorr = 0; + startTime = 0.0; + directorHead = 0; + directorWhole = 0; + + + // parse the command line + + programName = argV[0]; /*save the program name in case we need it*/ + + for( i = 1; i < argC; i++){ + + if(argV[i][0] =='-'){ + + // parse the option + + if(argV[i][1] == '-' ){ + + // parse long word options + + if( !strcmp( argV[i], "--gofr" ) ){ + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofr\n"); + usage(); + exit(0); + } + pair1 = argV[i]; + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofr\n"); + usage(); + exit(0); + } + pair2 = argV[i]; + + } + + else if( !strcmp( argV[i], "--gofrTheta" ) ){ + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofrTheta\n"); + usage(); + exit(0); + } + pair1 = argV[i]; + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofrTheta\n"); + usage(); + exit(0); + } + pair2 = argV[i]; + + } + + else if( !strcmp( argV[i], "--gofrOmega" ) ){ + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofrOmega\n"); + usage(); + exit(0); + } + pair1 = argV[i]; + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for --gofrOmega\n"); + usage(); + exit(0); + } + pair2 = argV[i]; + + } + + else if( !strcmp( argV[i], "--version") ){ + + printf("\n" + "tcProps version %d.%d\n" + "\n", + VERSION_MAJOR, VERSION_MINOR ); + exit(0); + + } + + else if( !strcmp( argV[i], "--help") ){ + + usage(); + exit(0); + } + + // anything else is an error + + else{ + fprintf( stderr, + "Invalid option \"%s\"\n", argV[i] ); + usage(); + exit(0); + } + } + + else{ + + // parse single character options + + done =0; + j = 1; + currentFlag = argV[i][j]; + while( (currentFlag != '\0') && (!done) ){ + + switch(currentFlag){ + + case 'o': + // -o => the output prefix. + + j++; + currentFlag = argV[i][j]; + + if( currentFlag != '\0' ) optionError = 1; + + if( optionError ){ + fprintf( stderr, + "\n" + "The -o flag should end an option sequence.\n" + " example: -r *NOT* -or \n" ); + usage(); + exit(0); + } + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for -o\n"); + usage(); + exit(0); + } + + outPrefix = argV[i]; + if( outPrefix[0] == '-' ) optionError = 1; + + if( optionError ){ + fprintf( stderr, + "\n" + "\"%s\" is not a valid out prefix/name.\n" + "Out prefix/name should not begin with a dash.\n", + outPrefix ); + usage(); + exit(0); + } + + havePrefix = 1; + done = 1; + break; + + case 'l': + // -l set to the maxLength + + haveMaxLength = 1; + j++; + currentFlag = argV[i][j]; + + if( currentFlag != '\0' ) optionError = 1; + + if( optionError ){ + fprintf( stderr, + "\n" + "The -l flag should end an option sequence.\n" + " example: -sl *NOT* -ls \n" ); + usage(); + exit(0); + } + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for -l\n"); + usage(); + exit(0); + } + maxLength = atof( argV[i] ); + + done = 1; + + break; + + case 't': + // -t set to the startTime + + j++; + currentFlag = argV[i][j]; + + if( currentFlag != '\0' ) optionError = 1; + + if( optionError ){ + fprintf( stderr, + "\n" + "The -t flag should end an option sequence.\n" + " example: -st *NOT* -ts \n" ); + usage(); + exit(0); + } + + i++; + if( i>=argC ){ + fprintf( stderr, + "\n" + "not enough arguments for -t\n"); + usage(); + exit(0); + } + + startTime = atof( argV[i] ); + done = 1; + break; + + case 's': + // -s turn on Scd corr + + scdCorr = 1; + break; + + case 'h': + // -h turn on director head + + directorHead = 1; + break; + + case 'w': + // -h turn on director head + + directorWhole = 1; + break; + + + default: + + fprintf( stderr, + "\n" + "Bad option \"-%c\"\n", currentFlag); + usage(); + exit(0); + } + j++; + currentFlag = argV[i][j]; + } + } + } + + else{ + + if( inName != NULL ){ + fprintf( stderr, + "Error at \"%s\", program does not currently support\n" + "more than one input dump file.\n" + "\n", + argV[i]); + usage(); + exit(0); + } + + inName = argV[i]; + + } + } + + if( inName == NULL ){ + fprintf( stderr, + "Error, dump file is needed to run.\n" ); + usage(); + exit(0); + } + + if( outPrefix == NULL ) + outPrefix = inName; + + // initialize the arrays for(i=0;i\n" + "\n" + "Options:\n" + "\n" + " short:\n" + " ------\n" + " -o The output prefix\n" + " -t