/* GZMAT */ int rjzmat(char *filename, int *atomnum, ATOM * atom, CONTROLINFO cinfo, MOLINFO minfo) { typedef struct { char str[MAXCHAR]; } STRNAME; FILE *fpin; int i, flag; int index = 0; int tmpint; int overflow_flag = 0; int findindex; int numatom; char tmpchar[MAXCHAR]; char tmpchar1[MAXCHAR]; char tmpchar2[MAXCHAR]; char tmpchar3[MAXCHAR]; char tmpchar4[MAXCHAR]; char tmpchar5[MAXCHAR]; char tmpchar6[MAXCHAR]; STRNAME *bondstr; STRNAME *anglestr; STRNAME *twiststr; char line[MAXCHAR]; bondstr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom + 10)); if (bondstr == NULL) { fprintf(stdout, "memory allocation error for *bondstr in rjzmat()\n"); exit(1); } anglestr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom + 10)); if (anglestr == NULL) { fprintf(stdout, "memory allocation error for *anglestr in rjzmat()\n"); exit(1); } twiststr = (STRNAME *) malloc(sizeof(STRNAME) * (cinfo.maxatom + 10)); if (twiststr == NULL) { fprintf(stdout, "memory allocation error for *twiststr in rjzmat()\n"); exit(1); } if ((fpin = fopen(filename, "r")) == NULL) { fprintf(stdout, "Cannot open the input file %s to read in rjzmat(), exit\n", filename); exit(1); } initial(cinfo.maxatom, atom, minfo.resname); numatom = 0; flag = 0; for (;;) { if (fgets(line, MAXCHAR, fpin) == NULL) { /* printf("\nFinished reading %s file.", cinfo.ifilename); */ break; } strcpy(tmpchar, ""); tmpchar[0]='\0'; sscanf(line, "%s", tmpchar); if(strncmp(tmpchar, "&zmat", 5)==0) { flag =1; continue; } if(strncmp(tmpchar, "&zvar", 5)==0) { index =1; break; } if (flag == 1 && strcmp(tmpchar, "&") ==0) { flag = 0; continue; } if(strncmp(tmpchar, "molchg=", 7)==0) { tmpint = 0; for(i=7;i<= strlen(tmpchar);i++) tmpchar2[tmpint++] = tmpchar[i]; minfo.icharge = atoi(tmpchar2); continue; } if(strncmp(tmpchar, "multip=", 7)==0) { tmpint = 0; for(i=7;i<= strlen(tmpchar);i++) tmpchar2[tmpint++] = tmpchar[i]; minfo.multiplicity = atoi(tmpchar2); continue; } if (overflow_flag == 0 && flag == 1) { sscanf(line, "%s", atom[numatom].name); if (numatom >= cinfo.maxatom && overflow_flag == 0) { printf ("\nInfo: the atom number exceeds the MAXATOM, reallocate memory automatically"); overflow_flag = 1; } numatom++; continue; } } *atomnum = numatom; rewind(fpin); flag = 0; numatom = 0; for (;;) { if (fgets(line, MAXCHAR, fpin) == NULL) break; strcpy(tmpchar, ""); tmpchar[0]='\0'; sscanf(line, "%s", tmpchar); if(strncmp(tmpchar, "&zmat", 5)==0) { flag =1; continue; } if(strncmp(tmpchar, "&zvar", 5)==0) { flag =2; continue; } if(flag == 1 && strcmp(tmpchar, "&")==0) { flag = 0; if(index == 1) continue; else break; } if(flag == 2 && strcmp(tmpchar, "&")==0) break; if (overflow_flag == 0 && flag == 1) { strcpy(tmpchar1, ""); strcpy(tmpchar2, ""); strcpy(tmpchar3, ""); strcpy(tmpchar4, ""); tmpchar1[0]='\0'; tmpchar2[0]='\0'; tmpchar3[0]='\0'; tmpchar4[0]='\0'; sscanf(line, "%s%s%s%s%s%s%s", tmpchar1, tmpchar2, bondstr[numatom].str, tmpchar3, anglestr[numatom].str, tmpchar4, twiststr[numatom].str); if(numatom > 0) { findindex = 0; for(i=0;i 1) { findindex = 0; for(i=0;i 2) { findindex = 0; for(i=0;i