int forwsearch(int f, int n) { int status; hst_init('/'); status = fsearch(f, n, FALSE, FALSE); hst_flush(); return status; }
/** Intersection of lists of occurrences **/ int svs (void *index, uint *idsIn, uint nids, uint **list, uint *len) { //sorting ids ==> lists are sorted by frequency !! uint i; uint *ids = (uint *)malloc (sizeof(uint) * nids); for (i=0;i<nids;i++) ids[i]=idsIn[i]; simplesort(ids,nids); // ==> change to sort by lenList !! /**starting SVS ------------------------ */ //Creating the first list; { uint i,j,n; uint *firstlist; uint matches; uncompressList (index, ids[0], list, len); firstlist =*list; n=*len; uint result; for (i=1; i<nids; i++) { //the nids-1 remaining lists matches =0; for (j=0;j<n;j++) { result=fsearch (index, firstlist[j] , ids[i]); //result=fsearchUNCOMPRESS (index, firstlist[j] , ids[i]); if (result) { //if (fsearch (index, firstlist[j] , ids[i])) { //if (fsearchUNCOMPRESS (index, firstlist[j] , ids[i])) { firstlist[matches++]= firstlist[j]; //printf("\nFSEARCH de posicion %d = acierto contra palabra ",firstlist[j]); } //else printf("\nFSEARCH de posicion %d = fallo contra palabra ",firstlist[j]); } n=matches; if (n ==0) { free(*list); *list=NULL;*len =0; break; } } *len =n; free(ids); } return 0; }
static int make_alias_fname(mmv_t *mmv, REP *p) { char *fstart; char *seqstart; int seq; fstart = mmv->pathbuf + strlen(mmv->pathbuf); strcpy(fstart, TEMP); seqstart = fstart + strlen(TEMP); seq = 0; while (true) { sprintf(seqstart, "%03d", seq); if (fsearch(fstart, p->r_hto->h_di) == NULL) { break; } ++seq; } return (seq); }
//------------------------------------------------------------------------- void reply_search(uint8_t * receivebuffer) { char filename[13]; uint8_t searchresults[20]; uint8_t numofsearch; uint8_t i; mystrncpy(filename, (char *)&receivebuffer[3], receivebuffer[0] - 3); filename[receivebuffer[0] - 3] = '\0'; fsearch(searchresults, &numofsearch, filename); for (i = 0; i < numofsearch; i++) { fdirnode((char *)&reply[3], 29, searchresults[i]); reply[0] = mystrlen((char *)&reply[3]) + 3; reply[1] = 221; reply[2] = nodeid; //printStringN(reply,32); StandardSocketSend(0xefef, 0xffff, 32, reply); } }
int scrforwsearch(int f, int n) { return fsearch(f, n, FALSE, TRUE); }
/* ARGSUSED */ static int rsearch(int f, int n, int dummy GCC_UNUSED, int fromscreen) { int status; int wrapok; MARK curpos; int didwrap; assert(curwp != 0); if (f && n < 0) /* reverse direction */ return fsearch(f, -n, FALSE, fromscreen); if (n == 0) n = 1; wrapok = window_b_val(curwp, MDWRAPSCAN); last_srch_direc = REVERSE; /* ask the user for the regular expression to search for, and * find n'th occurrence. */ status = readpattern("Reverse search: ", &searchpat, &gregexp, EOS, fromscreen); if (status != TRUE) return status; ignorecase = window_b_val(curwp, MDIGNCASE); if (curwp == 0) return FALSE; curpos = DOT; scanboundry(wrapok, DOT, REVERSE); didwrap = FALSE; while (n--) { movenext(&(DOT), REVERSE); status = scanner(gregexp, REVERSE, wrapok, &didwrap); if (didwrap) { mlwrite( "[Search wrapped past start of buffer]"); didwrap = FALSE; } if (status != TRUE) break; } if (status == TRUE) { savematch(DOT, gregexp->mlen); if (samepoint(DOT, curpos)) { mlwrite(onlyonemsg); } } else if (status == FALSE) { movenext(&(DOT), FORWARD); not_found_msg(wrapok, REVERSE); } else if (status == ABORT) { mlwarn("[Aborted]"); DOT = curpos; return status; } attrib_matches(); return status; }
int main( int argc, char * argv[] ) { FILE * pgroinput , * pitpinput , * pCNDOoutput ; char inpgroname[ MAXCHARINLINE ] , inpitpname[ MAXCHARINLINE ] , outCNDOname[ MAXCHARINLINE ] ; int multiplicity , charge ; int natom , ncart , natomselect , natomDump ; int iatom ; double dtmp ; double dtmpArray[ MAXCHARINLINE ] ; int itmp ; char tmpString[ MAXCHARINLINE ] ; // --------> Declaring utility functions ... double tellmass( char * atomMDname ) ; int tellatom( char * atomMDname ) ; void dzeros( int dimrow, int dimcol, double *p ) ; void izeros( int dimrow, int dimcol, int *p ) ; // --------> Some default values ... multiplicity = 1 ; charge = 0 ; // ==============> Handling the file names and Charge & Multiplicity ... <========= // // -------> Parsing the Command Line Arguments ... char ** pcmd ; pcmd = argv ; //pcmd ++ ; int icmd = 1 ; //int exn = 10 ; int exr = 16 ; int exR = 18 ; int exH = 22 ; int exM = 28 ; int exL = 30 ; int exf = 1 ; int exo = 3 ; int exx = 36 ; int exs = 18 ; int exD = 28 ; char * flag ; printf("\n%d command-line arguments provided ...\n" , argc ); if( argc == 1 ) { printf("\n\nNo command-line arguments provided ... Mission aborting ...\n\n"); printf("\nPlease refer to the usage by typing ' %s -h '\n\n" , * argv ); exit(1); } while( icmd < argc ) { pcmd ++ ; flag = * pcmd ; printf("\nNo.%d argument , Currently @ flag = %s ...\n\n" , icmd , flag ); if( ( * flag == '-' ) && ( strlen( flag ) == 2 ) ) { switch ( *( flag + 1 ) ) { case 'f' : strcpy( inpgroname , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : Input File name : %s ...\n" , inpgroname ); exf = 7 ; icmd = icmd + 2 ; break ; case 'o' : strcpy( outCNDOname , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : Output File name : %s ...\n" , outCNDOname ); exo = 9 ; icmd = icmd + 2 ; break ; case 'x' : strcpy( inpitpname , *( ++ pcmd ) ) ; if( strcmp( inpitpname , "dummy") == 0 || strcmp( inpitpname , "none") == 0 || strcmp( inpitpname , "None") == 0 ) { exx = 99 ; printf("\nLooks like we are not using point charge here ... \n") ; } else { printf("\nCommand-line argument indicates : Input .itp File name : %s ...\n" , inpitpname ); exx = 37 ; } icmd = icmd + 2 ; break ; case 's' : strcpy( tmpString , *( ++ pcmd ) ) ; if( strcmp( tmpString , "all" ) == 0 || strcmp( tmpString , "All" ) == 0 || strcmp( tmpString , "ALL" ) == 0 ) { exs = 20 ; printf("\nCommand-line argument indicates : All atoms will be chosen as solute ...\n" ); } else { printf("\nReceived information : %s ...\n" , tmpString ) ; natomselect = atoi( tmpString ); exs = 19 ; printf("\nCommand-line argument indicates : First %d atoms will be chosen as solute ...\n" , natomselect ); } icmd = icmd + 2 ; break ; case 'D' : strcpy( tmpString , *( ++ pcmd ) ) ; if( strcmp( tmpString , "all" ) == 0 || strcmp( tmpString , "All" ) == 0 || strcmp( tmpString , "ALL" ) == 0 ) { exD = 30 ; printf("\nCommand-line argument indicates : All atoms will be chosen to be dumped in output file ...\n" ); } else if( strcmp( tmpString , "solute" ) == 0 || strcmp( tmpString , "Solute" ) == 0 || strcmp( tmpString , "SOLUTE" ) == 0 ) { exD = 31 ; printf("\nCommand-line argument indicates : Only selected solute atoms will be chosen to be dumped in output file ...\n" ); } else { printf("\nReceived information : %s ...\n" , tmpString ) ; natomDump = atoi( tmpString ); exD = 29 ; printf("\nCommand-line argument indicates : First %d atoms will be dumped into output file ...\n" , natomDump ); } icmd = icmd + 2 ; break ; /* case 'r' : radiusM = atof( *( ++ pcmd ) ); exr = 17 ; printf("\nCommand-line argument indicates : User defined radius for middle layer : %12.8f ...\n" , radiusM ); icmd = icmd + 2 ; break ; case 'R' : radiusL = atof( *( ++ pcmd ) ); exR = 19 ; printf("\nCommand-line argument indicates : User defined radius for lower layer : %12.8f ...\n" , radiusL ); icmd = icmd + 2 ; break ; case 'H' : strcpy( highest_method , *( ++ pcmd ) ); exH = 23 ; printf("\nCommand-line argument indicates : User defined method for Highest layer : %s ...\n" , highest_method ); icmd = icmd + 2 ; break ; case 'M' : strcpy( middle_method , *( ++ pcmd ) ); exM = 29 ; printf("\nCommand-line argument indicates : User defined method for Middle layer : %s ...\n" , middle_method ); icmd = icmd + 2 ; break ; case 'L' : strcpy( lower_method , *( ++ pcmd ) ); exL = 31 ; printf("\nCommand-line argument indicates : User defined method for Lower layer : %s ...\n" , lower_method ); icmd = icmd + 2 ; break ; */ case 'h' : printf("\nUsage: %s [ -f 'input gro file name' ] [(optional) -o 'output CNDO input file name' ] [ -x input GMX .itp file ] [ -s # of atoms chosen as the solute ] [ -D # of atoms chosen to be Dumped in output file ]\n\n" , * argv ); printf("\nNOTE : 1) [ -s all ] or [ -s All ] indicates all atoms chosen as solute;\n\n 2) Default for -s is all atoms when nresidue = 1 or natom in 1st residue when nresidue != 1 \n"); printf("\n 3) User can use [ -x none / None / dummy ] to indicate all selected atoms ( may be less than total number of atoms ) will be treated as solute \n\n"); //printf("\m 3) ") ; //printf("\nUsage: %s [ -t G09 calculation type : 1=ONIOM ; 2=Point Charge ] [ -f 'input gro file name' ] [(optional) -o 'output g09 file name' ] [ -n # of layers (integer) ] [ (optional) -r radius of middle layer (real) ] [-R radius of lower layer (real) ] [ -H method for Highest layer (string) ] [ (optional) -M method for Middle layer (string) ] [ -L method for Lower layer (string) ] [ -x input GMX .itp file ]\n\n" , * argv ); //exh = 9 ; icmd = icmd + 1 ; exit(1) ; default : printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); icmd = argc ; exit(1); } } else { printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); exit(1); } } // --------> Setting DEFAULT value for important variables ... char defoutname[ MAXCHARINLINE ] , definpname[ MAXCHARINLINE ] , defitpname[ MAXCHARINLINE ]; int inputnamelength , outputnamelength , inputitpnamelength; printf("\nID = %d ...\n" , exo * exf * exx ); switch( exo * exf * exx ) // File Names ... int exf = 1 / 7 ; int exo = 3 / 9; int exx = 36 / 37 - 99 ; { case 108 : strcpy( inpgroname , "sys.gro" ); strcpy( inpitpname , "sys.itp" ); strcpy( outCNDOname , "sys.dat" ); break ; case 1*3*99 : strcpy( inpgroname , "sys.gro" ); //strcpy( inpitpname , "sys.itp" ); strcpy( outCNDOname , "sys.dat" ); break ; case 756 : inputnamelength = strlen( inpgroname ) ; strncpy( defoutname, inpgroname , inputnamelength - 4 ) ; *( defoutname + inputnamelength - 4 ) = '\0' ; strcat( defoutname, ".dat") ; strcpy( outCNDOname , defoutname ) ; strncpy( defitpname , inpgroname , inputnamelength - 4 ); *( defitpname + inputnamelength - 4 ) = '\0' ; strcat( defitpname , ".itp" ); strcpy( inpitpname , defitpname ); break ; case 3*7*99 : inputnamelength = strlen( inpgroname ) ; strncpy( defoutname, inpgroname , inputnamelength - 4 ) ; *( defoutname + inputnamelength - 4 ) = '\0' ; strcat( defoutname, ".dat") ; strcpy( outCNDOname , defoutname ) ; break ; case 7*9*99 : printf("\n\nHoorayyyyyyyy ... Both input and output name are specified !!!\n\n"); printf("\nAnd ... We don't need itp file ! \n"); break ; case 324 : outputnamelength = strlen( outCNDOname ) ; strncpy( definpname, outCNDOname , outputnamelength - 4 ) ; *( definpname + outputnamelength - 4 ) = '\0' ; strcat( definpname, ".gro") ; strcpy( inpgroname , definpname ); strncpy( defitpname , outCNDOname , outputnamelength - 4 ); *( defitpname + outputnamelength - 4 ) = '\0' ; strcat( defitpname , ".itp" ); strcpy( inpitpname , defitpname ); break ; case 1*9*99 : outputnamelength = strlen( outCNDOname ) ; strncpy( definpname, outCNDOname , outputnamelength - 4 ) ; *( definpname + outputnamelength - 4 ) = '\0' ; strcat( definpname, ".gro") ; strcpy( inpgroname , definpname ); break ; case 111 : strcpy( inpgroname , "sys.gro" ); strcpy( outCNDOname , "sys.inp" ); break ; case 777 : inputnamelength = strlen( inpgroname ) ; strncpy( defoutname, inpgroname , inputnamelength - 4 ) ; *( defoutname + inputnamelength - 4 ) = '\0' ; strcat( defoutname, ".dat") ; strcpy( outCNDOname , defoutname ) ; break ; case 2331 : printf("\n\nHoorayyyyyyyy ... All file names are specified !!!\n\n"); break ; case 333 : outputnamelength = strlen( outCNDOname ) ; strncpy( definpname, outCNDOname , outputnamelength - 4 ) ; *( definpname + outputnamelength - 4 ) = '\0' ; strcat( definpname, ".gro") ; strcpy( inpgroname , definpname ); break ; } // --------------> Summarizing and File Access ... printf("\n\nInput GMX .gro file name is : %s ...\n" , inpgroname ); printf("\nOutput CNDO dat file name is %s ...\n" , outCNDOname ); if( ( pitpinput = fopen( inpitpname , "r" ) ) == NULL && exx != 99 ) { printf("\nUser defined .itp file %s does not exist ... \n" , inpitpname ); exit( 3 ); } // ==============> Reading information from GMX .gro file ... <========= // char grotitlestring[MAXLINE]; int iline = 3 ; int iload = 0 ; int blank_signal , groinfo ; char buffer[ MAXCHARINLINE ] ; char cache[ MAXCHARINLINE ] ; char tmp_char ; int natomgroline , natomgrotitle ; int exVelocity = 0 ; if( ( pgroinput = fopen( inpgroname , "r" ) ) == NULL ) { printf("\nUser defined .gro file %s does not exist ... \n" , inpgroname ); exit( 3 ); } else { rewind( pgroinput ); //printf("\nCurrent character is %c ... \n" , fgetc( pEqGRO ) ); fskip( pgroinput , 1 ); fscanf( pgroinput , "%d" , &natomgrotitle ); fskip( pgroinput , 1 ); printf("\n Second line of .gro file says it is describing %d atoms ... \n\n" , natomgrotitle ); while( ( groinfo = freadline( buffer , MAXCHARINLINE , pgroinput , ';' ) ) != 0 ) { itmp = inLineWC( buffer ) ; break ; } if( itmp == 6 ) { exVelocity = NO ; printf("\nI see there is no velocity information in .gro file ...\n\n") ; } else if( itmp == 9 ) { exVelocity = YES ; printf("\nI see velocity information is also included in .gro file ...\n\n") ; } else { printf("\nPlease check the format of you .gro file ... There are %d words in one line of your molecular specification ... \n" , itmp ) ; exit( 456 ); } } printf("\nNow let's pre-load the .gro file ans see how many atoms it is describing ... \n"); rewind( pgroinput ) ; fskip( pgroinput , 2 ) ; while( ( groinfo = freadline( buffer , MAXCHARINLINE , pgroinput , ';' ) ) != 0 ) { //printf("\n//--------------> WORKING ON NO. %d LINE ... <-------------//\n" , iline ); //info = freadline( buffer , MAXCHARINLINE , pinputfile , ';' ); //printf("\nNow we are at : %s\n" , buffer ); //printf("\n INFO is %d ...\n" , info ); blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; continue ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == ';' ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); continue ; } else { //printf("\nLine reads : %s ...\n" , buffer ); iload ++ ; } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iline ++ ; }//while( info != 0 ); natomgroline = iload - 1 ; // Because the last line is boxvector line . printf("\nIt can be seen that this .gro file is describing %d atoms ...\n" , natomgroline ); if( natomgrotitle > natomgroline ) { printf("\nYour .gro file is self-contradictory ... While the second line of your .gro file says there will be %d atoms, there are actually only %d atoms being described ... \n" , natomgrotitle , natomgroline ); printf("\nWe will take all the atoms we can to procede ... \n"); natom = natomgroline ; } else if( natomgrotitle == natomgroline ) { printf("\nOkay ... Your .gro file is fine ... NAtom will be %d ... \n" , natomgrotitle ); natom = natomgrotitle ; } else if( natomgrotitle < natomgroline ) { printf("\nThe second line of your .gro file indicates there are %d atoms in this file but there are more atoms ( %d atoms ) being described insided ... We will take the first %d atoms ... \n" , natomgrotitle , natomgroline , natomgrotitle ); natom = natomgrotitle ; } else { printf("\nSomething is wrong with checking the .gro file ... Please take a look at it ... \n"); exit( 81 ); } ncart = 3 * natom ; // =====> Actually Reading the GRO File ... GRO atomlist[ natom ] ; rewind( pgroinput ); fskip( pgroinput , 1 ); fskip( pgroinput , 1 ); printf("\nNow let's read the actual .gro file ... \n"); iload = 0 ; iline = 0 ; while( ( groinfo = freadline( buffer , MAXCHARINLINE , pgroinput , ';' ) ) != 0 ) { //printf("\n//--------------> WORKING ON NO. %d LINE ... <-------------//\n" , iline ); blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; continue ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == ';' ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); continue ; } else { //printf("\nLine reads : %s ...\n" , buffer ); sscanf( buffer , "%5d%5s" , &atomlist[ iload ].resnumber , atomlist[ iload ].resname ); //printf( "%s\t" , atomlist[ iatom ].resname ); //sscanf( pEqGRO , "%s" , EqAtomList[ iload ].atomname ); strpickword( buffer , 2 , cache ) ; strcpy( atomlist[ iload ].atomname , cache ) ; //printf( "%s" , atomlist[ iatom ].atomname ); //sscanf( pEqGRO , "%d" , &EqAtomList[ iload ].atomnumber ); strpickword( buffer , 3 , cache ) ; atomlist[ iload ].atomnumber = atoi( cache ) ; //printf( "\nWorking on No. %d atom ...\n" , EqAtomList[ iatom ].atomnumber ); //sscanf( pEqGRO , "%lf" , &EqAtomList[ iload ].cx ); //printf("\n Cx is %lf ...\t" , EqAtomList[ iatom ].cx); strpickword( buffer , 4 , cache ) ; atomlist[ iload ].cx = atof( cache ) ; //sscanf( pEqGRO , "%lf" , &EqAtomList[ iload ].cy ); //printf("\n Cy is %lf ...\t" , EqAtomList[ iatom ].cy); strpickword( buffer , 5 , cache ) ; atomlist[ iload ].cy = atof( cache ) ; //sscanf( pEqGRO , "%lf" , &EqAtomList[ iload ].cz ); //printf("\n Cz is %lf ...\n\n" , EqAtomList[ iatom ].cz); strpickword( buffer , 6 , cache ) ; atomlist[ iload ].cz = atof( cache ) ; if( exVelocity == YES ) { strpickword( buffer , 7 , cache ) ; atomlist[ iload ].vx = atof( cache ) ; strpickword( buffer , 8 , cache ) ; atomlist[ iload ].vy = atof( cache ) ; strpickword( buffer , 9 , cache ) ; atomlist[ iload ].vz = atof( cache ) ; } //fscanf( pgroinput , "%lf" , &EqAtomList[ iatom ].vx ); //printf("\n Vx is %lf ...\t" , EqAtomList[ iatom ].cx); //fscanf( pgroinput , "%lf" , &EqAtomList[ iatom ].vy ); //printf("\n Vy is %lf ...\t" , EqAtomList[ iatom ].cy); //fscanf( pgroinput , "%lf" , &EqAtomList[ iatom ].vz ); //printf("\n Vz is %lf ...\n\n" , EqAtomList[ iatom ].cz); iload ++ ; } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } if( iload == natom ) break ; iline ++ ; } if( natomgrotitle < natomgroline ) { fskip( pgroinput , natomgroline - natomgrotitle ) ; } double boxvector[ 3 ]; fscanf( pgroinput , "%lf" , boxvector + 0 ); fscanf( pgroinput , "%lf" , boxvector + 1 ); fscanf( pgroinput , "%lf" , boxvector + 2 ); // ---------------> Figuring out how many solvent molecules (residues) are in the system ... int nresidue = atomlist[ natom - 1 ].resnumber ; // ---------------> Figuring out how many atoms are in each residue ... int * n_of_atom_in_residues = calloc( nresidue , sizeof( int ) ) ; izeros( nresidue , 1 , n_of_atom_in_residues ); //double * molecularmass = calloc( nresidue , sizeof( double ) ) ; //dzeros( nresidue , 1 , molecularmass ); int iresidue = 1 ; for( iatom = 0 ; iatom < natom ; iatom ++ ) { if( atomlist[ iatom ].resnumber == ( iresidue + 1 ) ) { //printf("\n#%d residue has %d atoms ...\n" , iresidue , *( n_of_atom_in_residues + iresidue - 1 ) ); iresidue ++ ; //printf("\n\nStarting ... # %d residue (molecule) ... \n\n" , iresidue ); } else if( atomlist[ iatom ].resnumber == iresidue ) { //printf("\nStill in this residue ... \n"); //continue ; } else { printf("\nSomething is wrong with the atomlist or atomcast ... Mission Aborting ...\n\n"); exit(1); } *( n_of_atom_in_residues + iresidue - 1 ) = *( n_of_atom_in_residues + iresidue - 1 ) + 1 ; ///*( molecularmass + iresidue - 1 ) = *( molecularmass + iresidue - 1 ) + atomcast[ iatom ].atommass ; } //Just debugging ... for( iresidue = 1 ; ( iresidue - 1 ) < nresidue ; iresidue ++ ) { printf("\nThere are %d atoms in No. %d residue ... \n" , *( n_of_atom_in_residues + iresidue - 1 ) , iresidue ); //printf("\nThe molecular mass of No. %d residue is %lf ...\n" , iresidue , *( molecularmass + iresidue - 1 ) ); } //---> Dealing with the "Default senario " of Chosen Atoms ... if( exs == 18 && nresidue == 1 ) { natomselect = natom ; } else if( exs == 18 && nresidue > 1 ) { natomselect = *( n_of_atom_in_residues + 0 ) ; } else if( exs == 19 && natomselect > natom ) // Will be dead ... { printf("\nThere are only %d atoms in this system ... you cannot select more than that ... \n" , natom ); if( natomgrotitle > natomgroline && natomselect <= natomgrotitle ) { printf("\nAlthough ... the second line of your initial .gro file did indicate there were supposed to be %d atoms in system ... So go back and make sure what you are trying to do ... \n" , natomgrotitle ); } else if( natomgrotitle < natomgroline && natomselect <= natomgroline ) { printf("\nAlthough ... your initial .gro file did describe %d atoms in system ... So go back and make sure what you are trying to do ... \n" , natomgroline ); } exit( 78 ); } else if( exs == 19 && natomselect <= natom ) { printf("\nYou have selected %d atoms for rotation ... There are %d atoms en toto in this system ... \n" , natomselect , natom ); } else if( exs == 20 ) { natomselect = natom ; } else { printf("\nSomething is wrong with the atom selection process ... NAtom = %d , NAtomSelect = %d ... \n" , natom , natomselect ); exit( 78 ); } if( exD == 28 ) { natomDump = natom ; } else if( exD == 30 ) { natomDump = natom ; } else if( exD == 31 ) { natomDump = natomselect ; printf("\nBased on command-line input , only [ %d ] solute atoms will be dumped ...\n\n" , natomselect ) ; } else if( exD == 29 ) { if( natomDump <= natom && natomDump > natomselect ) { printf("\nBased on command-line input , besides solute , [ %d ] atoms from solvent will be dumped ...\n\n" , natomDump - natomselect ) ; } else if( natomDump == natomselect ) { printf("\nBased on command-line input , only [ %d ] solute atoms will be dumped ...\n\n" , natomselect ) ; } else if( natomDump < natomselect && natomDump >= 0 ) { printf("\nWARNING : You chose to dump ONLY PART OF SOLUTE atoms [ %d ] into your cndo .dat file ...\n\n" , natomDump ) ; } else if( natomDump < 0 ) { natomDump = natomselect ; printf("\nBased on command-line input , only [ %d ] solute atoms will be dumped ...\n\n" , natomselect ) ; } else if( natomDump > natom ) { printf("\nWARNING : There are in total only [ %d ] atoms in the system , so you cannot request more than [ %d ] atoms dumped ...\n\n" , natom , natom ) ; printf("\nNow we re-set the natomDump to be natom ...\n\n" ) ; natomDump = natom ; } } // -------------------------------> Reading ITP File ... <---------------------------------- // int itpinfo , natomITP ; if( exx != 99 ) { // =====> Pre-Loading ... printf("\nNow let's pre-load the .itp file and see how many atoms it is describing ... \n"); iline = 1 ; iload = 0 ; fsearch( pitpinput , "atoms" ) ; fskip( pitpinput , 1 ); while( ( itpinfo = freadline( buffer , MAXCHARINLINE , pitpinput , ';' ) ) != 0 ) { //printf("\n//--------------> WORKING ON NO. %d LINE ... <-------------//\n" , iline ); //info = freadline( buffer , MAXCHARINLINE , pinputfile , ';' ); //printf("\nNow we are at : %s\n" , buffer ); //printf("\n INFO is %d ...\n" , info ); blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == ';' ) { printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); } else if( ( tmp_char = getfirst( buffer ) ) == '[' ) { printf("\nSTARTING OF NEW DIRECTIVE ... END READING ... \n\n"); break ; } else { //printf("\nLine reads : %s ...\n" , buffer ); iload ++ ; } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iline ++ ; }//while( info != 0 ); natomITP = iload ; printf("\nThere are %d atoms described in itp file ...\n" , natomITP ); /* if( natomITP != natomselect ) { printf("\nWhile you specified you wanted %d atoms as the solute, in your itp file, there are only %d atoms being described ...\n" , natomsoluteSelect , natomITP ); printf("\nPlease check your itp file and make sure the # of atoms match ...\n"); printf("\nWe will continue anyway but once we find any required info does not exist in your itp file , we will terminate this process immediately ...\n\n") ; } */ } else { natomITP = natom ; natomselect = natom ; } ITP atomdatabase[ natomITP ]; if( exx != 99 ) { // =====> Loading ... printf("\nNow let's actually load the .itp file ... \n"); iline = 1 ; iload = 0 ; //ITP atomdatabase[ natomITP ]; rewind( pitpinput ) ; fsearch( pitpinput , "atoms" ) ; fskip( pitpinput , 1 ); while( ( itpinfo = freadline( buffer , MAXCHARINLINE , pitpinput , ';' ) ) != 0 ) { //printf("\n//--------------> WORKING ON NO. %d LINE ... <-------------//\n" , iline ); //info = freadline( buffer , MAXCHARINLINE , pinputfile , ';' ); //printf("\nNow we are at : %s\n" , buffer ); //printf("\n INFO is %d ...\n" , info ); blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == ';' ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); } else if( ( tmp_char = getfirst( buffer ) ) == '[' ) { //printf("\nSTARTING OF NEW DIRECTIVE ... END READING ... \n\n"); break ; } else { //printf("\nLine reads : %s ...\n" , buffer ); iload ++ ; strpickword( buffer , 1 , cache ); atomdatabase[ iload -1 ].nr = atoi( cache ) ; strpickword( buffer , 2 , cache ); strcpy( atomdatabase[ iload -1 ].type , cache ); strpickword( buffer , 3 , cache ); atomdatabase[ iload -1 ].resnr = atoi( cache ) ; strpickword( buffer , 4 , cache ); strcpy( atomdatabase[ iload -1 ].residue , cache ); strpickword( buffer , 5 , cache ); strcpy( atomdatabase[ iload -1 ].atomname , cache ); strpickword( buffer , 6 , cache ); atomdatabase[ iload -1 ].cgnr = atoi( cache ) ; strpickword( buffer , 7 , cache ); atomdatabase[ iload -1 ].charge = atof( cache ) ; strpickword( buffer , 8 , cache ); atomdatabase[ iload -1 ].mass = atof( cache ) ; printf("\nCharge of this atom is %lf ...\n" , atomdatabase[ iload -1 ].charge ) ; } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iline ++ ; } } // ==============> Organizing Info and Defining Layers ... <========= // // ---------------> Allocating mem for dat array ... DAT atomcast[ natom ]; for( iatom = 0 ; iatom < natom ; iatom ++ ) { atomcast[ iatom ].cx = atomlist[ iatom ].cx * 10.00 ; atomcast[ iatom ].cy = atomlist[ iatom ].cy * 10.00 ; atomcast[ iatom ].cz = atomlist[ iatom ].cz * 10.00 ; atomcast[ iatom ].atomlabel = tellatom( atomlist[ iatom ].atomname ); //atomcast[ iatom ].atommass = tellmass( atomlist[ iatom ].atomname ); atomcast[ iatom ].atomcharge = 0.00 ; //printf("\nNo. %d atom ; X = %lf ; Y = %lf ; Z = %lf ; Atom = %d Mass = %lf ...\n" , iatom+1 , atomcast[ iatom ].cx , atomcast[ iatom ].cy , atomcast[ iatom ].cz , atomcast[ iatom ].atomlabel , atomcast[ iatom ].atommass ); } // ==============> Loading information into atomcast ... <========= // int itype = 0 ; /* FILE * debug ; debug = fopen( "atomnames.deb" , "wb+" ); for( iatom = 0 ; iatom < natom ; iatom ++ ) { fprintf( debug , "\n%d\t%s\n" , iatom + 1 , atomlist[ iatom ].atomname ); } fclose( debug ); debug = fopen( "atomtypes.deb" , "wb+"); for( itype = 0 ; itype < ntype ; itype ++ ) { fprintf( debug , "%8d %s %lf\t\n" , atomdatabase[ itype ].nr , atomdatabase[ itype ].atomname , atomdatabase[ itype ].charge ); } fclose( debug ); */ int info_res , info_atomname ; int ntype ; if( exx != 99 ) { ntype = natomITP ; for( iatom = natomselect ; iatom < natom ; iatom ++ ) { for( itype = 0 ; itype < ntype ; itype ++ ) { if( ( info_res = strcmp( atomlist[ iatom ].resname , atomdatabase[ itype ].residue ) ) == 0 && ( info_atomname = strcmp( atomlist[ iatom ].atomname , atomdatabase[ itype ].atomname ) ) == 0 ) { atomcast[ iatom ].atomcharge = atomdatabase[ itype ].charge ; //printf("\nNo.%d atom , charge is %lf ...\n" , iatom + 1 , atomcast[ iatom ].atomcharge ); break ; } } } } // ---------------> Outputing ... pCNDOoutput = fopen( outCNDOname , "wb+" ); fprintf( pCNDOoutput , "%s\n" , inpgroname ); fprintf( pCNDOoutput , "%s\n" , "HAMILT= INDO" ); fprintf( pCNDOoutput , "%s\n" , "STOP= CI" ); fprintf( pCNDOoutput , "%s\n" , "ROTINV= YES" ); //fprintf( pCNDOoutput , "%s\n" , "SHIFT= 20" ); fprintf( pCNDOoutput , "%s\n" , "BETA= INDO/S" ); fprintf( pCNDOoutput , "%s\n" , "POINTGRP= C1" ); fprintf( pCNDOoutput , "%s\n" , "EX_FROM= 60" ); fprintf( pCNDOoutput , "%s\n" , "MAX_CI= 60" ); fprintf( pCNDOoutput , "%s\n" , "CI_DUMP= 60" ); //fprintf( pCNDOoutput , "%s\n" , "DUMP= MAX" ); fprintf( pCNDOoutput , "%s%d\n" , "CHARGE= " , charge ); fprintf( pCNDOoutput , "%s%d\n" , "MULT_CI= " , multiplicity ); fprintf( pCNDOoutput , "%s\n" , "MAX_ITS= 300" ); fprintf( pCNDOoutput , "%s\n\n" , "RESTART= MO" ); if( natomDump >= natomselect ) { for( iatom = 0 ; iatom < natomselect ; iatom ++ ) { fprintf( pCNDOoutput , "%7.3f %7.3f %7.3f %5d\n" , atomcast[ iatom ].cx , atomcast[ iatom ].cy , atomcast[ iatom ].cz , atomcast[ iatom ].atomlabel ); } } else { for( iatom = 0 ; iatom < natomDump ; iatom ++ ) { fprintf( pCNDOoutput , "%7.3f %7.3f %7.3f %5d\n" , atomcast[ iatom ].cx , atomcast[ iatom ].cy , atomcast[ iatom ].cz , atomcast[ iatom ].atomlabel ); } } //fprintf( pCNDOoutput , "\n\n\n" ); if( exx != 99 ) { if( natomDump > natomselect && natomDump <= natom ) { for( iatom = natomselect ; iatom < natomDump ; iatom ++ ) { //printf("\nPrinting out No.%d atom which is in residue : %s into CNDO input file ... \n\n" , iatom + 1 , atomlist[ iatom ].resname ); fprintf( pCNDOoutput , "%7.3f %7.3f %7.3f %5d %10.6f\n" , atomcast[ iatom ].cx , atomcast[ iatom ].cy , atomcast[ iatom ].cz , -1*atomcast[ iatom ].atomlabel , atomcast[ iatom ].atomcharge ); } } } fprintf( pCNDOoutput , "\n\n\n\n\n" ) ; /* */ // -----------------> The End ... Really??? return(0); }
int preLoadEntry( FILE * pfile , char entryName[] , char commentSymbol ) { int iline = 0 ; int iload = 0 ; int blank_signal , info ; char buffer[ MAXCHARINLINE ] ; //char cache[ MAXCHARINLINE ] ; char tmp_char ; rewind( pfile ) ; info = fsearch( pfile , entryName ) ; if( info == NO ) { printf("\nNo Entry Name [ %s ] Found !\n\n" , entryName ) ; exit( 179 ) ; } fskip( pfile , 1 ) ; while( ( info = freadline( buffer , MAXCHARINLINE , pfile , commentSymbol ) ) != 0 ) { //printf("\n//--------------> WORKING ON NO. %d LINE ... <-------------//\n" , iline ); //info = freadline( buffer , MAXCHARINLINE , pinputfile , ';' ); //printf("\nNow we are at : %s\n" , buffer ); //printf("\n INFO is %d ...\n" , info ); blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; continue ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == commentSymbol ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); continue ; } else { //printf("\nLine reads : %s ...\n" , buffer ); iload ++ ; } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iline ++ ; }//while( info != 0 ); return( iload ) ; }
int main( int argc, char * argv[] ) { FILE * pDATinput , * pGJFoutput ; char inpDATname[ 100 ] , outGJFname[ 100 ] ; char method[ 200 ] ; int multiplicity , charge ; int natom , ncart , natomselect , natomPrint ; int iatom ; double dtmp ; double dtmpArray[ 100 ] ; char buffer[ MAXCHARINLINE ] ; char cache[ MAXCHARINLINE ] ; char tmpString[ 150 ] ; char tmp_char ; int itmp , itmp2 ; // --------> Declaring utility functions ... // --------> Some default values ... multiplicity = 1 ; charge = 0 ; strcpy( method , "#P ZIndo( Singlets , NStates = 15 ) NoSymm Pop=Full Test" ) ; // ==============> Handling the file names and Charge & Multiplicity ... <========= // // -------> Parsing the Command Line Arguments ... char ** pcmd ; pcmd = argv ; //pcmd ++ ; int icmd = 1 ; //int exn = 10 ; int exr = 16 ; int exR = 18 ; int exH = 22 ; int exM = 28 ; int exL = 30 ; int exf = 1 ; int exo = 3 ; int exs = 18 ; int exmethod = 28 ; char * flag ; printf("\n%d command-line arguments provided ...\n" , argc ); if( argc == 1 ) { printf("\n\nNo command-line arguments provided ... Mission aborting ...\n\n"); printf("\nPlease refer to the usage by typing ' %s -h '\n\n" , * argv ); exit(1); } while( icmd < argc ) { pcmd ++ ; flag = * pcmd ; printf("\nNo.%d argument , Currently @ flag = %s ...\n\n" , icmd , flag ); if( ( * flag == '-' ) && ( strlen( flag ) == 2 ) ) { switch ( *( flag + 1 ) ) { case 'f' : strcpy( inpDATname , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : Input File name : %s ...\n" , inpDATname ); exf = 7 ; icmd = icmd + 2 ; break ; case 'o' : strcpy( outGJFname , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : Output File name : %s ...\n" , outGJFname ); exo = 9 ; icmd = icmd + 2 ; break ; case 'L' : strcpy( method , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : G09 Method is : %s ...\n" , method ); exmethod = 29 ; icmd = icmd + 2 ; break ; case 's' : strcpy( tmpString , *( ++ pcmd ) ) ; if( strcmp( tmpString , "all" ) == 0 || strcmp( tmpString , "All" ) == 0 ) { exs = 20 ; printf("\nCommand-line argument indicates : All atoms will be chosen as solute ...\n" ); } else { printf("\nReceived information : %s ...\n" , tmpString ) ; natomselect = atoi( tmpString ); exs = 19 ; printf("\nCommand-line argument indicates : First %d atoms will be chosen as solute ...\n" , natomselect ); } icmd = icmd + 2 ; break ; case 'h' : printf("\nUsage: %s [ -f 'input dat file name' ] [(optional) -o 'generated g09 input file name' ] [ -s # of atoms chosen as the solute ] [ -L Method for G09 Calculations ]\n\n" , * argv ); printf("\nNOTE : 1) [ -s all ] or [ -s All ] indicates all atoms chosen as solute;\n\n 2) Default for -s is all atoms when nresidue = 1 or natom in 1st residue when nresidue != 1 \n"); //exh = 9 ; icmd = icmd + 1 ; exit(1) ; default : printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); icmd = argc ; exit(1); } } else { printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); exit(1); } } // --------> Setting DEFAULT value for important variables ... char defGJFname[100] , defDATname[100] ; int inputnamelength , outputnamelength ; switch( exf * exo ) // File Names ... int exf = 1 / 7 ; int exo = 3 / 9; { case 1 * 3 : strcpy( inpDATname , "sys.dat" ); strcpy( outGJFname , "sys.inp" ) ; break ; case 1 * 9 : outputnamelength = strlen( outGJFname ) ; strncpy( defDATname, outGJFname , outputnamelength - 4 ) ; *( defDATname + outputnamelength - 4 ) = '\0' ; strcat( defDATname, ".dat") ; strcpy( inpDATname , defDATname ); break ; case 7 * 3 : inputnamelength = strlen( inpDATname ) ; strncpy( defGJFname, inpDATname , inputnamelength - 4 ) ; *( defGJFname + inputnamelength - 4 ) = '\0' ; strcat( defGJFname, ".inp") ; strcpy( outGJFname , defGJFname ) ; break ; case 7 * 9 : printf("\n\nHoorayyyyyyyy ... All file names are specified !!!\n\n"); break ; } // --------------> Summarizing and File Access ... printf("\n\nInput CNDO .dat file name is : %s ...\n" , inpDATname ); printf("\nOutput G09 inp file name is %s ...\n" , outGJFname ); if( ( pDATinput = fopen( inpDATname , "r" ) ) == NULL ) { printf("\nUser defined .dat file %s does not exist ... \n" , inpDATname ); exit( 3 ); } // pGJFoutput = fopen( outGJFname , "wb+" ) ; // --------------> Reading information from CNDO .dat file ... int iline = 0 , nRouteLines ; int iload = 0 , nload ; int blank_signal , info ; int isoluteAtom = 0 , nsoluteAtom = 0 ; int ipointCharge = 0 , npointCharge = 0 ; double * molecularSpecification ; if( fsearch( pDATinput , "CHARGE=" ) == 1 ) { fscanf( pDATinput , "%s" , cache ) ; charge = atoi( cache ) ; } rewind( pDATinput ) ; if( fsearch( pDATinput , "MULT_CI=" ) == 1 ) { fscanf( pDATinput , "%s" , cache ) ; multiplicity = atoi( cache ) ; } printf("\nCharge is %d , Multiplicity is %d ...\n" , charge , multiplicity ) ; rewind( pDATinput ) ; while( ( info = freadline( buffer , MAXCHARINLINE , pDATinput , '$' ) ) != 0 ) { blank_signal = stellblank( buffer ) ; printf("\nLine reads : %s ...\n" , buffer ); if( blank_signal == 0 ) { break ; } else { iline ++ ; } } nRouteLines = iline ; while( ( info = freadline( buffer , MAXCHARINLINE , pDATinput , '$' ) ) != 0 ) { blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; continue ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == '$' ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); continue ; } else { printf("\nLine reads : %s ...\n" , buffer ); itmp = inLineWC( buffer ) ; if( itmp == 4 ) { isoluteAtom ++ ; } else if( itmp == 5 ) { ipointCharge ++ ; } else { continue ; } } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iload ++ ; } nload = iload ; nsoluteAtom = isoluteAtom ; npointCharge = ipointCharge ; printf("\n En TOTO %d coordinates and other specifications loaded ... %d are atoms and %d are point charges ... \n" , nload , isoluteAtom , ipointCharge ) ; DAT atomlist[ nsoluteAtom + npointCharge ] ; rewind( pDATinput ) ; fskip( pDATinput , nRouteLines ) ; iload = 0 ; isoluteAtom = 0 ; ipointCharge = 0 ; while( ( info = freadline( buffer , MAXCHARINLINE , pDATinput , '$' ) ) != 0 ) { blank_signal = stellblank( buffer ) ; if( blank_signal == 0 ) { //printf("\nNo.%d line is a blank line ... Moving on ...\n" , iline ) ; continue ; } else if( blank_signal == 1 ) { //printf("\nNo.%d line is NOT a blank line ... loading ...\n" , iline ); if( ( tmp_char = getfirst( buffer ) ) == '$' ) { //printf("\nThis is a comment line ... So nothing will be loaded ...\n"); //fskip( pinputfile , 1 ); continue ; } else { //printf("\nLine reads : %s ...\n" , buffer ); itmp = inLineWC( buffer ) ; if( itmp == 4 ) { strpickword( buffer , 1 , cache ) ; atomlist[ isoluteAtom ].cx = atof( cache ) ; strpickword( buffer , 2 , cache ) ; atomlist[ isoluteAtom ].cy = atof( cache ) ; strpickword( buffer , 3 , cache ) ; atomlist[ isoluteAtom ].cz = atof( cache ) ; strpickword( buffer , 4 , cache ) ; atomlist[ isoluteAtom ].atomlabel = atoi( cache ) ; printf("\n No. %d atom ...\n" , isoluteAtom ) ; isoluteAtom ++ ; } else if( itmp == 5 ) { strpickword( buffer , 1 , cache ) ; atomlist[ nsoluteAtom + ipointCharge ].cx = atof( cache ) ; strpickword( buffer , 2 , cache ) ; atomlist[ nsoluteAtom + ipointCharge ].cy = atof( cache ) ; strpickword( buffer , 3 , cache ) ; atomlist[ nsoluteAtom + ipointCharge ].cz = atof( cache ) ; strpickword( buffer , 4 , cache ) ; atomlist[ nsoluteAtom + ipointCharge ].atomlabel = -1 * atoi( cache ) ; strpickword( buffer , 5 , cache ) ; atomlist[ nsoluteAtom + ipointCharge ].atomcharge = atof( cache ) ; printf("\n No. %d atom ...\n" , nsoluteAtom + ipointCharge ) ; ipointCharge ++ ; } else { continue ; } } //printf("\n%s\n" , buffer ); } else { printf("\nSomething is wrong with the reading file part ...\n"); exit(1); } iload ++ ; } if( iload == nload && ipointCharge == npointCharge && isoluteAtom == nsoluteAtom ) { printf("\n En TOTO %d coordinates and other specifications loaded ... %d are atoms and %d are point charges ... \n" , nload , nsoluteAtom , npointCharge ) ; } else { printf("\nEh...oh... Something is wrong during the loading ... \n"); printf("\n En TOTO %d coordinates and other specifications loaded ... %d are atoms and %d are point charges ... \n" , nload , nsoluteAtom , npointCharge ) ; exit( 515 ) ; } natom = nsoluteAtom + npointCharge ; switch ( exs ) { case 19 : natomPrint = natomselect ; break ; case 18 : natomPrint = nsoluteAtom ; break ; case 20 : natomPrint = natom ; break ; default : printf("\nSomething is wrong during the printing-out ...\n") ; exit( 538 ) ; } // --------------> Outputing ... char chkname[ 100 ] , rwfname[ 100 ] ; outputnamelength = strlen( outGJFname ) ; strncpy( chkname , outGJFname , outputnamelength - 4 ) ; *( chkname + outputnamelength - 4 ) = '\0' ; strcat( chkname, ".chk") ; strncpy( rwfname , outGJFname , outputnamelength - 4 ) ; *( rwfname + outputnamelength - 4 ) = '\0' ; strcat( rwfname, ".rwf") ; if( exmethod == 28 ) { printf("\nNo QC method specified in command-line , go with ===> %s <===\n" , method ); } pGJFoutput = fopen( outGJFname , "wb+" ); fprintf( pGJFoutput , "%%chk=%s\n%%rwf=%s\n%%mem=4GB\n%%nprocshared=2\n\n" , chkname , rwfname ); fprintf( pGJFoutput , "%s\n\n" , method ); fprintf( pGJFoutput , "%s corresponding QC\n\n" , inpDATname ); fprintf( pGJFoutput , "%d\t%d\t\n" , charge , multiplicity ); for( iatom = 0 ; iatom < natomPrint ; iatom ++ ) { fprintf( pGJFoutput , "%d\t% 16.12f\t% 16.12f\t% 16.12f\n" , atomlist[ iatom ].atomlabel , atomlist[ iatom ].cx , atomlist[ iatom ].cy , atomlist[ iatom ].cz ); } int nwords , signal ; nwords = inLineWC( method ) ; signal = 0 ; for( itmp = 0 ; itmp < nwords ; itmp ++ ) { strpickword( method , itmp + 1 , buffer ) ; if( strcmp( buffer , "dftba") == 0 || strcmp( buffer , "DFTBA") == 0 ) { signal = 1 ; break ; } } if( signal == 1 ) { fprintf( pGJFoutput , "\n@GAUSS_EXEDIR:dftba.prm\n\n" ); } fprintf( pGJFoutput , "\n" ) ; fclose( pGJFoutput ); }
int main( int argc , char * argv[ ] ) { FILE * pndx , * pdxdr , * pfreq , * patomlist , * passgn ; FILE * debug ; char dxdrname [ 50 ] , ndxname [ 50 ] , atomlistname [ 50 ] , freqname [ 50 ], outassgnname [ 50 ] ; char ** pcmd ; pcmd = argv ; int icmd , itmp ; int ncart , natom , nmode , nfreqprovide; int icart , iatom , imode , ifreq ; int exfreq , exatomlist ; int fakeOrNot = 0 ; time_t current_time; time( ¤t_time ); char now[ 300 ] ; strcpy( now , ctime( ¤t_time ) ); int lennow = strlen( now ) ; *( now + lennow - 1 ) = ' '; // ========> Recording Command-Line Arguments ... printf("\n**********************************************************************\n"); printf("* G_NMASSGN_D : Listing the localization of all vibrational modes. *\n"); printf("* *\n"); printf("* "); for( icmd = 0 ; icmd < argc ; icmd ++ ) { printf("%s " , *( pcmd + icmd ) ); } printf("\n"); printf("* *\n"); printf("* *\n"); printf("* Current Time : %s *\n" , now ); printf("* *\n"); printf("* *\n"); printf("**********************************************************************\n"); // =====> Setting up default file names ... strcpy( dxdrname , "dxdr.deb" ); strcpy( ndxname , "system.index" ); strcpy( freqname , "vibfrequency.deb" ); strcpy( outassgnname , "system.assgn" ); strcpy( atomlistname , "atom.list" ); // =====> Parsing command line input arguments ... if( argc == 1 ) { printf("\n\nNo command-line arguments provided ... Mission aborting ...\n\n"); printf("\nPlease refer to the usage by typing ' %s -h '\n\n" , * argv ); exit(1); } char * flag ; icmd = 1 ; while( icmd < argc ) { pcmd ++ ; flag = * pcmd ; printf("\nNo.%d argument , Currently @ flag = %s ...\n\n" , icmd , flag ); if( ( * flag == '-' ) && ( strlen( flag ) == 2 ) ) { switch ( *( flag + 1 ) ) { case 'f' : strcpy( dxdrname , *( ++ pcmd ) ) ; printf("\nCommand-line argument indicates : Input dxdr File name : %s ...\n" , dxdrname ); icmd = icmd + 2 ; break ; case 'o' : strcpy( outassgnname , *( ++ pcmd ) ); printf("\nCommand-line argument indicates : Output File name : %s ...\n" , outassgnname ); icmd = icmd + 2 ; break ; case 'w' : strcpy( freqname , *( ++ pcmd ) ); printf("\nCommand-line argument indicates : Input frequency File name : %s ...\n" , freqname ); icmd = icmd + 2 ; break ; case 'n' : strcpy( ndxname , *( ++ pcmd ) ); printf("\nCommand-line argument indicates : Input index File name : %s ...\n" , ndxname ); icmd = icmd + 2 ; break ; case 'l' : strcpy( atomlistname , *( ++ pcmd ) ); if( ( strcmp( atomlistname , "none" ) ) == 0 ) { printf("\nCommand-line argument indicates : No AtomList needed ... Will not produce fake frequency file ...\n" ); fakeOrNot = 0 ; } else { printf("\nCommand-line argument indicates : Input atom list File name : %s ...\n" , atomlistname ); fakeOrNot = 1 ; } icmd = icmd + 2 ; break ; case 'h' : printf("\nUsage: %s [ -f 'input dxdr file name' ] [ -n 'input index file name (in GROMACS .ndx format)' ] [(optional) -o 'output NM assignment file name' ] [ -l atom list file (listing the atomic number of all atoms in system ; \"none\" if no frequency file desired)][ -w 'input vibrational frequency file ; best case length = nmode' ]\n\n" , * argv ); printf("\n\n==> NOTE : In order to be fool-proof , if there is mis-match on the NAtom between dxdr file and any other file , this code will set NAtom to be the number from dxdr automatically ...\n\n"); //printf("\nUsage: %s [ -t G09 calculation type : 1=ONIOM ; 2=Point Charge ] [ -f 'input gro file name' ] [(optional) -o 'output g09 file name' ] [ -n # of layers (integer) ] [ (optional) -r radius of middle layer (real) ] [-R radius of lower layer (real) ] [ -H method for Highest layer (string) ] [ (optional) -M method for Middle layer (string) ] [ -L method for Lower layer (string) ] [ -x input GMX .itp file ]\n\n" , * argv ); //exh = 9 ; icmd = icmd + 1 ; exit(1) ; default : printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); icmd = argc ; exit(1); } } else { printf("\n\nInvalid option ' %s ' ... Please refer to the usage by typing ' %s -h '\n\n" , flag , * argv ); exit(1); } } // =====> Open the files ... if( ( pndx = fopen( ndxname , "r" ) ) == NULL ) { printf("\nUser-defined index file %s does not exist ...\n\n" , ndxname ); exit( 1 ); } if( ( pdxdr = fopen( dxdrname , "r" ) ) == NULL ) { printf("\nUser-defined dxdr file %s does not exist ...\n\n" , dxdrname ); exit( 1 ); } double * freq ; if( ( pfreq = fopen( freqname , "r" ) ) == NULL ) { printf("\nUser-defined frequency file %s does not exist ...\n\n" , freqname ); printf("\nBut it's OK , we will procede without frequency information ... \n"); exfreq = 0 ; } else { nfreqprovide = flength( pfreq ); rewind( pfreq ) ; freq = ( double * ) calloc( nfreqprovide , sizeof( double ) ) ; fload( pfreq , freq ); rewind( pfreq ); exfreq = 1 ; } int * atomlist , natomlistprovide ; if( fakeOrNot == 1 ) { if( ( patomlist = fopen( atomlistname , "r" ) ) == NULL ) { printf("\nUser-defined atom list file %s does not exist ...\n\n" , atomlistname ); printf("\nMeaning ... All of your atoms will be carbon ...\n"); exatomlist = 0 ; } else { natomlistprovide = flength( patomlist ); rewind( patomlist ); atomlist = ( int * ) calloc( natomlistprovide , sizeof( int ) ) ; int_fload( patomlist , atomlist ); exatomlist = 1 ; } } // =====> Read the index file (*****.ndx) ... int countlrb , countrrb ; int ngroup ; int ilrb , irrb , igroup ; char c ; char ** groupnames ; char tmpstring[ 100 ] ; char tmpchar ; // -----> Finding out how many groups are defined in index file ... ilrb = 0 ; irrb = 0 ; //fsearch( pndx , "begin" ); //fscanf( pndx , "%s" , tmpstring ); //if( strcmp( tmpstring , "]" ) != 0 ) //{ // printf("\nSomething is wrong with the ndx file format at the beginning ... Mission Aborting ... \n") ; // // exit(3); // //} //fskip( pndx , 1 ) ; rewind( pndx ) ; while( ( c = fgetc( pndx ) ) != EOF ) { if( c == '[' ) { ilrb ++ ; } else if( c == ']') { irrb ++ ; } else { continue ; } } if( ilrb == irrb ) { ngroup = ilrb ; printf("\nThere are %d defined groups in the index file ...\n" , ngroup ); } else { printf("\nSomething is wrong in the index file ... There are unmatched brackets or broken entries ...\n"); exit( 2 ); } if( ngroup == 0 ) { printf("\nThis index file is an empty file ... Mission Aborting ...\n"); exit(4); } // -----> Finding out how many atoms are in each group int * natom_in_each_group = calloc( ngroup , sizeof( int ) ) ; int current_atom_index , next_atom_index ; int info ; rewind( pndx ) ; //fsearch( pndx , "begin" ); //fskip( pndx , 1 ) ; for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { printf("\n--------------------------> GROUP #%d <----------------------------" , igroup + 1 ); //itmp = 0 ; fsearch( pndx , "]" ) ; //fskip( pndx , 1 ) ; //printf("\nHere we are ... : %c " , fgetc( pndx ) ); fscanf( pndx , "%s" , tmpstring ); //printf("\nFor this group , the 1st grabbed tmpstring is %s ... \n" , tmpstring ); //while( strcmp( tmpstring , "[") != 0 ) for( itmp = 0 ; strcmp( tmpstring , "[" ) != 0 && info != EOF ; ) { //printf("\nGrabbed tmpstring is %s ... \n" , tmpstring ) ; if( strcmp( tmpstring , "-" ) == 0 ) { //printf("\nThe '-' situation happened ... before '-' we are at No.%d atom ... \n" , current_atom_index ); fscanf( pndx , "%d" , &next_atom_index ); //printf("\nAnd after '-' we are at No.%d atom ... \n" , next_atom_index ); itmp = itmp + ( next_atom_index - current_atom_index ); *( natom_in_each_group + igroup ) = itmp ; current_atom_index = next_atom_index ; info = fscanf( pndx , "%s" , tmpstring ) ; } else { itmp ++ ; *( natom_in_each_group + igroup ) = itmp ; current_atom_index = atoi( tmpstring ); //printf("\nNormal situation ... current_atom_index is %d ... \n" , current_atom_index ); info = fscanf( pndx , "%s" , tmpstring ); } } if( info == EOF ) { printf("\nHit the bottom of file ...\n\n") ; break ; } printf("\nDone with #%d group ... \n" , igroup + 1 ); } printf("\n--------------------------> Done checking up groups <----------------------------"); /* Debugging output for this part ... */ printf("\n== Group Information Summary ==\n"); for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { printf("\nNo.%d Group Has %d atoms ...\n" , igroup + 1 , *( natom_in_each_group + igroup ) ); } // -----> Recording the name of each group ... groupnames = ( char ** ) calloc( ngroup , sizeof( char * ) ) ; int tmp_groupname_length ; rewind( pndx ) ; //fsearch( pndx , "begin" ); //fskip( pndx , 1 ); for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { fsearch( pndx , "[" ) ; fscanf( pndx , "%s" , tmpstring ); tmp_groupname_length = strlen( tmpstring ) ; *( groupnames + igroup ) = ( char * ) calloc( tmp_groupname_length + 3 , sizeof( char ) ) ; strcpy( *( groupnames + igroup ) , tmpstring ) ; printf("\nName of %d group is %s ...\n" , igroup + 1 , *( groupnames + igroup ) ); } // =====> Loading the eigenvectors ( dxdr file ) ... printf("\n--------------------------> Begin reading dxdr file ... <----------------------------" ); int len_dxdr = flength( pdxdr ) ; printf("\nThere are %d numbers in eigenvectors file ... \n" , len_dxdr ); ncart = sqrt( len_dxdr ); natom = ncart / 3 ; double * dxdr = calloc( len_dxdr , sizeof( double ) ) ; rewind( pdxdr ); fload( pdxdr , dxdr ) ; rewind( pdxdr ) ; printf("\nDone with loading dxdr file ... \n"); switch( natom ) { case 1 : printf("\nSeriously? Only ONE atom? ...\n") ; exit( 9 ) ; break ; case 2 : nmode = 6 ; break ; default : nmode = ncart - 0 ; break ; } if( exfreq == 0 ) { freq = ( double * ) calloc( nmode , sizeof( double ) ) ; dzeros( nmode , 1 , freq ) ; } else { if( nfreqprovide > nmode ) { printf("\nOkay ... The number of vibrational frequency you provided is more than the normal mode we have from eigenvectors ...\n"); printf("\nSo I will take only the first #_of_eigenvectors frequencies from the file you provided ...\n"); } else if( nfreqprovide < nmode ) { printf("\nOkay ... The number of vibrational frequency you provided is less than the normal mode we have from eigenvectors ...\n"); printf("\nThe rest will be padded with zeros ... Sorry, I really don't want to do the diagonalization ...\n"); free( freq ) ; freq = ( double * ) calloc( nmode , sizeof( double ) ) ; rewind( pfreq ); fload( pfreq , freq ) ; dzeros( nmode - nfreqprovide , 1 , freq + nfreqprovide ) ; } } if( exatomlist == 0 ) { if( fakeOrNot == 1 ) { for( iatom = 0 ; iatom < natom ; iatom ++ ) { *( atomlist + iatom ) = 6 ; } } } else { if( natomlistprovide > natom ) { printf("\nOkay ... The number of atom you provided is more than the NAtom we have from eigenvectors ...\n"); printf("\nSo I will take only the first #_of_atoms from the file you provided ...\n"); } else if( natomlistprovide < natom ) { printf("\nOkay ... The number of atom you provided is less than the NAtom we have from eigenvectors ...\n"); printf("\nSo all the rest will be automatically set as Carbon ... \n"); free( atomlist ); atomlist = ( int * ) calloc( natom , sizeof( int ) ) ; rewind( patomlist ); int_fload( patomlist , atomlist ); for( iatom = natom - natomlistprovide ; iatom < natom ; iatom ++ ) { *( atomlist + iatom ) = 6 ; } } } // =====> Loading the eigenvectors ( dxdr file ) ... // -----> Based on group information, prepare the recording structures (array) ... printf("\n=================================> _ <=====================================\n"); printf("\nStarting from here, we will actually read index file and give the assignment ... \n"); double * assgninfo = calloc( ngroup * nmode , sizeof( double ) ) ; rewind( pndx ) ; //fsearch( pndx , "begin" ); //fskip( pndx , 1 ) ; double tmp_xcomponent , tmp_ycomponent , tmp_zcomponent , tmp_magnitude ; //printf("\nDebugging ... Debugging ... % 12.8E\t% 12.8E\t% 12.8E\n\n" , *( dxdr + 3 ) , *( dxdr + 4 ) , *( dxdr + 5 ) ); info = 9 ; for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { printf("\n--------------------------> GROUP #%d : %s <----------------------------" , igroup + 1 , *( groupnames + igroup ) ); fsearch( pndx , "]" ) ; fscanf( pndx , "%s" , tmpstring ); //printf("\nFor this group , the 1st grabbed tmpstring is %s ... \n" , tmpstring ); for( itmp = 0 ; strcmp( tmpstring , "[" ) != 0 && info != EOF ; ) { //printf("\nGrabbed tmpstring is %s ... \n" , tmpstring ) ; if( strcmp( tmpstring , "-" ) == 0 ) { //printf("\nThe '-' situation happened ... before '-' we are at No.%d atom ... \n" , current_atom_index ); fscanf( pndx , "%d" , &next_atom_index ); //printf("\nAnd after '-' we are at No.%d atom ... \n" , next_atom_index ); itmp = itmp + ( next_atom_index - current_atom_index ); for( iatom = current_atom_index ; iatom < next_atom_index ; iatom ++ ) { //tmp_xcomponent = 0.0000 ; tmp_ycomponent = 0.0000 ; tmp_zcomponent = 0.0000 ; //tmp_magnitude = tmp_xcomponent * tmp_xcomponent + tmp_ycomponent * tmp_ycomponent + tmp_zcomponent * tmp_zcomponent ; printf("\nWorking on No.%d atom ... in No.%d group ...\n" , iatom + 1 , igroup + 1 ); for( imode = 0 ; imode < nmode ; imode ++ ) { tmp_xcomponent = *( dxdr + ( 3 * ( iatom - 0 ) + 0 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom X ... \n" , imode + 1 , tmp_xcomponent , iatom + 1 ); tmp_ycomponent = *( dxdr + ( 3 * ( iatom - 0 ) + 1 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom Y ... \n" , imode + 1 , tmp_ycomponent , iatom + 1 ); tmp_zcomponent = *( dxdr + ( 3 * ( iatom - 0 ) + 2 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom Z ... \n" , imode + 1 , tmp_zcomponent , iatom + 1 ); tmp_magnitude = tmp_xcomponent * tmp_xcomponent + tmp_ycomponent * tmp_ycomponent + tmp_zcomponent * tmp_zcomponent ; //printf("\nNO.%d mode has % 12.8E on #%d atom ... \n" , imode + 1 , tmp_magnitude , iatom + 1 ) ; *( assgninfo + igroup * nmode + imode ) = *( assgninfo + igroup * nmode + imode ) + tmp_magnitude ; printf("\nUp to No.%d atom , No.%d mode has % 12.8E on #%d group ...\n" , iatom + 1 , imode + 1 , *( assgninfo + igroup * nmode + imode ) , igroup + 1 ); } } current_atom_index = next_atom_index ; info = fscanf( pndx , "%s" , tmpstring ) ; } else { itmp ++ ; current_atom_index = atoi( tmpstring ); //printf("\nNormal situation ... current_atom_index is %d ... \n" , current_atom_index ); printf("\nWorking on No.%d atom ... in No.%d group ...\n" , current_atom_index , igroup + 1 ); for( imode = 0 ; imode < nmode ; imode ++ ) { tmp_xcomponent = *( dxdr + ( 3 * ( current_atom_index - 1 ) + 0 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom X ... \n" , imode + 1 , tmp_xcomponent , current_atom_index ); tmp_ycomponent = *( dxdr + ( 3 * ( current_atom_index - 1 ) + 1 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom Y ... \n" , imode + 1 , tmp_ycomponent , current_atom_index ); tmp_zcomponent = *( dxdr + ( 3 * ( current_atom_index - 1 ) + 2 ) * nmode + imode ) ; //printf("\nNO.%d mode has % 12.8E on #%d atom Z ... \n" , imode + 1 , tmp_zcomponent , current_atom_index ); tmp_magnitude = tmp_xcomponent * tmp_xcomponent + tmp_ycomponent * tmp_ycomponent + tmp_zcomponent * tmp_zcomponent ; //printf("\nNO.%d mode has % 12.8E on #%d atom ... \n" , imode + 1 , tmp_magnitude , current_atom_index ) ; *( assgninfo + igroup * nmode + imode ) = *( assgninfo + igroup * nmode + imode ) + tmp_magnitude ; printf("\nUp to No.%d atom , No.%d mode has % 12.8E on #%d group ...\n" , current_atom_index , imode + 1 , *( assgninfo + igroup * nmode + imode ) , igroup + 1 ); } info = fscanf( pndx , "%s" , tmpstring ); } } if( info == EOF ) { printf("\nHit the bottom of file ...\n\n") ; break ; } printf("\nDone Loading Information of [ % 5d ] group ... \n" , igroup + 1 ); } /* Debugging output ... */ debug = fopen( "assgnfull.info" , "wb+" ); fprintf( debug , "Mode#\t" ) ; for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { fprintf( debug , "% 12s\t" , *( groupnames + igroup ) ) ; } fprintf( debug , "vib-Frequencies" ); fprintf( debug , "\n\n" ); for( imode = 0 ; imode < nmode ; imode ++ ) { fprintf( debug , "%d\t" , imode + 1 ); for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { fprintf( debug , "% 12.8E\t" , *( assgninfo + igroup * nmode + imode ) ); } fprintf( debug , "% 12.8E\n\n" , *( freq + imode ) ) ; } // =====> Writing the output file ( MATLAB loadable pure number array file ) ... passgn = fopen( outassgnname , "wb+" ) ; fprintf( passgn , "\n\n" ); for( imode = 0 ; imode < nmode ; imode ++ ) { fprintf( passgn , "%d\t" , imode + 1 ); for( igroup = 0 ; igroup < ngroup ; igroup ++ ) { fprintf( passgn , "% 12.8E\t" , *( assgninfo + igroup * nmode + imode ) ); } fprintf( passgn , "% 12.8E\n\n" , *( freq + imode ) ) ; } // =====> Writing the output file ( MATLAB loadable pure number array file ) ... FILE * pfakefreq ; int ibatch = 0 ; int nbatch = nmode / 3 ; if( fakeOrNot == 1 ) { pfakefreq = fopen( "fakeg09.freq" , "wb+" ); if( natom == 1 ) { printf("\nReally? Really?? Really???\n\n"); exit( 1 ) ; } else if( natom == 2 ) { fprintf( pfakefreq , " 1\n A\nFrequencies -- %10.4f\n" , *( freq + 5 ) ) ; fprintf( pfakefreq , "Red. masses -- %10.4f\nFrc consts -- %10.4f\nIR Inten -- %10.4f\n Atom AN X Y Z \n" , 1.00 , 1.00 , 1.00 ); for( iatom = 0 ; iatom < natom ; iatom ++ ) { fprintf( pfakefreq , "%5d%4d % 8.4f % 8.4f %8.4f\n" , iatom + 1 , *( atomlist + iatom ) , *( dxdr + 3 * iatom + 0 ) , *( dxdr + 3 * iatom + 1 ) , *( dxdr + 3 * iatom + 2 ) ); } } else { for( ibatch = 2 ; ibatch < nbatch ; ibatch ++ ) { fprintf( pfakefreq , " %5d %5d %5d\n" , 3 * ( ibatch - 2 ) + 1 , 3 * ( ibatch - 2 ) + 2 , 3 * ( ibatch - 2 ) + 3 ); fprintf( pfakefreq , " %5c %5c %5c\n" , 'A' , 'A', 'A' ); fprintf( pfakefreq , "%-12s -- %10.4f %10.4f %10.4f\n" , " Frequencies" , *( freq + 3 * ibatch + 0 ) , *( freq + 3 * ibatch + 1 ) , *( freq + 3 * ibatch + 2 ) ); fprintf( pfakefreq , "%-12s -- %10.4f %10.4f %10.4f\n" , " Red. masses" , 1.00 , 1.00 , 1.00 ); fprintf( pfakefreq , "%-12s -- %10.4f %10.4f %10.4f\n" , " Frc consts" , 10.00 , 10.00 , 10.00 ); fprintf( pfakefreq , "%-12s -- %10.4f %10.4f %10.4f\n" , " IR Inten" , 10.00 , 10.00 , 10.00 ); fprintf( pfakefreq , " Atom AN X Y Z X Y Z X Y Z\n"); for( iatom = 0 ; iatom < natom ; iatom ++ ) { fprintf( pfakefreq , "%5d%4d" , iatom + 1 , *( atomlist + iatom ) ) ; fprintf( pfakefreq , " % 8.4f % 8.4f %8.4f" , *( dxdr + nmode * ( 3 * iatom + 0 ) + ( 3 * ( ibatch + 0 ) + 0 ) ) , *( dxdr + nmode * ( 3 * iatom + 1 ) + ( 3 * ( ibatch + 0 ) + 0 ) ) , *( dxdr + nmode * ( 3 * iatom + 2 ) + ( 3 * ( ibatch + 0 ) + 0 ) ) ) ; fprintf( pfakefreq , " % 8.4f % 8.4f %8.4f" , *( dxdr + nmode * ( 3 * iatom + 0 ) + ( 3 * ( ibatch + 0 ) + 1 ) ) , *( dxdr + nmode * ( 3 * iatom + 1 ) + ( 3 * ( ibatch + 0 ) + 1 ) ) , *( dxdr + nmode * ( 3 * iatom + 2 ) + ( 3 * ( ibatch + 0 ) + 1 ) ) ) ; fprintf( pfakefreq , " % 8.4f % 8.4f %8.4f\n" , *( dxdr + nmode * ( 3 * iatom + 0 ) + ( 3 * ( ibatch + 0 ) + 2 ) ) , *( dxdr + nmode * ( 3 * iatom + 1 ) + ( 3 * ( ibatch + 0 ) + 2 ) ) , *( dxdr + nmode * ( 3 * iatom + 2 ) + ( 3 * ( ibatch + 0 ) + 2 ) ) ) ; } } } } return( 0 ); } // The End ...