int main(int argc, char *argv[]) { int i, n, HaveSpace, pos_hsym; int F_Convention, Last_F_Convention; int F_ListTable, F_CIF; int F_XYZ, F_AllXYZ, F_Maple; int F_Space, F_Shelx, F_Schakal; int F_hklList; int F_Standard, F_UnitCell; int F_Verbose, F_Verify, F_ClearError; T_LatticeConstants LatConA, LatConB; char *cp, xtrac; const char *SgName; const T_TabSgName *tsgn; T_SgInfo SpgrInfo[2], BC_SgInfo, *SgInfo; int nSgList, iSgList; T_SgList SgList[2]; T_RTMx *CBMx, *InvCBMx; T_RTMx CCBMx, CInvCBMx; /* Macintosh extras (Courtesy Jon Tischler <*****@*****.**>) */ #ifdef __THINK__ console_options.nrows = CONSOLE_LINES; console_options.ncols = CONSOLE_COLUMNS; console_options.title = "\psgInfo version 1.0.1"; #endif #ifdef __MWERKS__ SIOUXSettings.autocloseonquit = false; SIOUXSettings.asktosaveonclose = true; SIOUXSettings.columns = CONSOLE_COLUMNS; SIOUXSettings.rows = CONSOLE_LINES; #endif #if defined(__THINK__) || defined(__MWERKS__) argc = ccommand(&argv); #endif nSgList = 0; F_Convention = 'A'; Last_F_Convention = 0; F_ListTable = 0; F_CIF = 0; F_XYZ = 0; F_AllXYZ = 0; F_Maple = 0; F_Space = 0; F_Shelx = 0; F_Schakal = 0; F_hklList = 0; F_Standard = 0; F_UnitCell = 0; F_Verbose = 0; F_Verify = 0; F_ClearError = 0; for (i = 1; i < argc; i++) { if (str_icmp(argv[i], "-Hall") == 0) { F_Convention = 'H'; Last_F_Convention = 0; } else if (str_icmp(argv[i], "-VolA") == 0) { F_Convention = 'A'; Last_F_Convention = 'A'; } else if ( str_icmp(argv[i], "-VolI") == 0 || str_icmp(argv[i], "-Vol1") == 0) { F_Convention = 'I'; Last_F_Convention = 'I'; } else if (str_ibegin(argv[i], "-ListTable") == 0) { cp = argv[i] + 10; if (*cp == '\0') F_ListTable = -1; else if (*cp++ == '=') { n = sscanf(cp, "%d%c", &F_ListTable, &xtrac); if (n != 1 || F_ListTable < 1 || F_ListTable > 230) usage(); } else usage(); } else if (str_icmp(argv[i], "-CIF") == 0) F_CIF = 1; else if (str_icmp(argv[i], "-XYZ") == 0) F_XYZ = 1; else if (str_icmp(argv[i], "-AllXYZ") == 0) F_AllXYZ = 1; else if (str_icmp(argv[i], "-Maple") == 0) F_Maple = 1; else if (str_icmp(argv[i], "-Space") == 0) F_Space = 1; else if (str_icmp(argv[i], "-Shelx") == 0) F_Shelx = 1; else if (str_icmp(argv[i], "-Schakal") == 0) F_Schakal = 1; else if (str_icmp(argv[i], "-hklList") == 0) F_hklList = 1; else if (str_icmp(argv[i], "-Standard") == 0) F_Standard = 1; else if (str_ibegin(argv[i], "-UnitCell=") == 0) { F_UnitCell = sscanf(&argv[i][10], "%lf%lf%lf%lf%lf%lf", &LatConA.a, &LatConA.b, &LatConA.c, &LatConA.alpha, &LatConA.beta, &LatConA.gamma); if (F_UnitCell < 1) usage(); if (F_UnitCell > 3) LatConA.alpha *= PIover180; if (F_UnitCell > 4) LatConA.beta *= PIover180; if (F_UnitCell > 5) LatConA.gamma *= PIover180; } else if (str_icmp(argv[i], "-v") == 0) F_Verbose = 1; else if (str_icmp(argv[i], "-Verify") == 0) F_Verify = 1; else if (str_icmp(argv[i], "-ClearError") == 0) F_ClearError = 1; else if (nSgList < 2) { SgName = argv[i]; while (*SgName == ' ' || *SgName == '\t') SgName++; if (F_Convention == 'H' && isdigit(*SgName)) SgList[nSgList].Convention = 'A'; else SgList[nSgList].Convention = F_Convention; SgList[nSgList].SgName = SgName; SgList[nSgList].InpTSgN = NULL; SgList[nSgList].RefTSgN = NULL; nSgList++; } else usage(); } if (F_ListTable) { ListTabSgName(F_ListTable, Last_F_Convention, stdout); PrintClearSgError(1, 0); putc('\n', stdout); } if (F_CIF) { ListCIF(stdout); PrintClearSgError(1, 0); putc('\n', stdout); } if (nSgList == 0) { if (F_ListTable == 0 && F_CIF == 0) usage(); else exit(0); } if (F_Space == 0) { putc('#', stdout); for (i = 0; i < argc; i++) { putc(' ', stdout); HaveSpace = 0; if (i) { for (n = 0; argv[i][n]; n++) { if (isspace(argv[i][n])) { HaveSpace = 1; break; } } } if (HaveSpace == 0) fprintf(stdout, "%s", argv[i]); else { putc('"', stdout); for (n = 0; argv[i][n]; n++) if (argv[i][n] == '"') putc('+', stdout); else putc(argv[i][n], stdout); putc('"', stdout); } } putc('\n', stdout); } BC_SgInfo.MaxList = 0; BC_SgInfo.ListSeitzMx = NULL; BC_SgInfo.ListRotMxInfo = NULL; for (iSgList = 0; iSgList < nSgList; iSgList++) { if (iSgList) putc('\n', stdout); if (nSgList > 1 || F_Standard) fprintf(stdout, "Setting %c:\n\n", "AB"[iSgList]); SgInfo = &SpgrInfo[iSgList]; SgInfo->MaxList = 192; SgInfo->ListSeitzMx = malloc(SgInfo->MaxList * sizeof (*SgInfo->ListSeitzMx)); if (SgInfo->ListSeitzMx == NULL) NotEnoughCore(); #ifndef No_ListRotMxInfo SgInfo->ListRotMxInfo = malloc(SgInfo->MaxList * sizeof (*SgInfo->ListRotMxInfo)); if (SgInfo->ListRotMxInfo == NULL) NotEnoughCore(); #else SgInfo->ListRotMxInfo = NULL; #endif F_Convention = SgList[iSgList].Convention; SgName = SgList[iSgList].SgName; tsgn = NULL; if (F_Convention == 'A' || F_Convention == 'I') { tsgn = FindTabSgNameEntry(SgName, F_Convention); if (tsgn == NULL) { PrintClearSgError(1, 0); progerror("Error: Unknown Space Group Symbol"); } if (F_Space == 0) { fprintf(stdout, "Space Group "); PrintTabSgNameEntry(tsgn, 0, 0, stdout); putc('\n', stdout); } SgName = tsgn->HallSymbol; } SgList[iSgList].InpTSgN = tsgn; InitSgInfo(SgInfo); SgInfo->TabSgName = tsgn; if (tsgn) SgInfo->GenOption = 1; pos_hsym = ParseHallSymbol(SgName, SgInfo); if (SgError != NULL) { fprintf(stdout, " %s\n", SgName); for (i = 0; i < pos_hsym; i++) putc('-', stdout); fprintf(stdout, "---^\n"); fprintf(stdout, "%s\n", SgError); exit(1); } if (CompleteSgInfo(SgInfo) != 0) PrintClearSgError(F_ClearError, 1); if (tsgn == NULL && F_Space == 0) { if (SgInfo->TabSgName) { fprintf(stdout, "Space Group "); PrintTabSgNameEntry(SgInfo->TabSgName, 0, 0, stdout); putc('\n', stdout); } else fprintf(stdout, "Hall Symbol %s\n", SgInfo->HallSymbol); } PrintClearSgError(F_ClearError, 0); #if USE_GS_SI if (Try_GS_si(SgInfo) < 0) #else if (Set_si(SgInfo) < 0) #endif PrintClearSgError(F_ClearError, 1); if (F_Space == 0) { ListSgInfo(SgInfo, F_XYZ, F_Verbose, stdout); PrintClearSgError(F_ClearError, 0); } if (F_AllXYZ) { PutAllXYZ(SgInfo, stdout); PrintClearSgError(F_ClearError, 0); } if (F_Maple) { PutMaple(SgInfo, stdout); PrintClearSgError(F_ClearError, 0); } if (F_Space) { PutSpaceSymFile(SgInfo, stdout); PrintClearSgError(F_ClearError, 0); } if (F_Shelx) { PutShelx(SgInfo, stdout); PrintClearSgError(F_ClearError, 0); } if (F_Schakal) { PutSchakal(SgInfo, stdout); PrintClearSgError(F_ClearError, 0); } if (F_hklList) { Simple_hklList(SgInfo, 4, 4, 4, F_Verbose); PrintClearSgError(F_ClearError, 0); } if (nSgList > 1 || F_Standard) { CBMx = &SgList[iSgList].CBMx; InvCBMx = &SgList[iSgList].InvCBMx; SgList[iSgList].RefTSgN = FindReferenceSpaceGroup(SgInfo, CBMx, InvCBMx); PrintClearSgError(F_ClearError, 0); if (SgList[iSgList].RefTSgN) { if (F_Verbose || F_Verify) { fprintf(stdout, "Change of Basis => Reference Setting "); PrintTabSgNameEntry(SgList[iSgList].RefTSgN, 0, 0, stdout); putc('\n', stdout); ShowCBMx(CBMx, InvCBMx, F_Maple); PrintClearSgError(F_ClearError, 0); } if (F_Verify) { if (BC_SgInfo.MaxList == 0) { BC_SgInfo.MaxList = 192; BC_SgInfo.ListSeitzMx = malloc(BC_SgInfo.MaxList * sizeof (*BC_SgInfo.ListSeitzMx)); if (BC_SgInfo.ListSeitzMx == NULL) NotEnoughCore(); BC_SgInfo.ListRotMxInfo = malloc(BC_SgInfo.MaxList * sizeof (*BC_SgInfo.ListRotMxInfo)); if (BC_SgInfo.ListRotMxInfo == NULL) NotEnoughCore(); } InitSgInfo(&BC_SgInfo); if (TransformSgInfo(SgInfo, CBMx, InvCBMx, &BC_SgInfo) == 0) CompleteSgInfo(&BC_SgInfo); if (SgError) { PrintClearSgError(F_ClearError, 0); SgList[iSgList].RefTSgN = NULL; } else if (BC_SgInfo.TabSgName != SgList[iSgList].RefTSgN) { fprintf(stdout, "Hall Symbol %s\n", BC_SgInfo.HallSymbol); SetSgError("Verify Error: Wrong CBMx/InvCBMx"); PrintClearSgError(F_ClearError, 0); SgList[iSgList].RefTSgN = NULL; } else fprintf(stdout, "Verify O.K.\n\n"); } } tsgn = SgList[iSgList].RefTSgN; if (tsgn && F_Standard && nSgList == 1) { if (Last_F_Convention == 'A' || Last_F_Convention == 'I') SgList[nSgList].Convention = Last_F_Convention; else SgList[nSgList].Convention = 'A'; SgList[nSgList].SgName = SchoenfliesSymbols[tsgn->SgNumber]; SgList[nSgList].InpTSgN = NULL; SgList[nSgList].RefTSgN = NULL; nSgList++; } } } if ( nSgList == 2 && SgList[0].RefTSgN && SgList[1].RefTSgN && SgList[0].RefTSgN->SgNumber == SgList[1].RefTSgN->SgNumber) { putc('\n', stdout); fprintf(stdout, "Change of Basis Setting A -> Setting B:\n"); RTMxMultiply( &CCBMx, &SgList[1].InvCBMx, &SgList[0].CBMx, CRBF, CRBF * CTBF); RTMxMultiply(&CInvCBMx, &SgList[0].InvCBMx, &SgList[1].CBMx, CRBF, CRBF * CTBF); for (i = 0; i < 12; i++) { if ( CCBMx.a[i] % CRBF) break; if (CInvCBMx.a[i] % CRBF) break; CCBMx.a[i] /= CRBF; CInvCBMx.a[i] /= CRBF; } if (i < 12) { SetSgError("Internal Error: Can't combine CBMx's"); PrintClearSgError(1, 1); } else { ShowCBMx(&CCBMx, &CInvCBMx, F_Maple); PrintClearSgError(F_ClearError, 0); if (F_Verify) { InitSgInfo(&BC_SgInfo); if (TransformSgInfo(&SpgrInfo[0], &CCBMx, &CInvCBMx, &BC_SgInfo) == 0) CompleteSgInfo(&BC_SgInfo); if (SgError) PrintClearSgError(F_ClearError, 1); else if (strcmp(SpgrInfo[1].HallSymbol, BC_SgInfo.HallSymbol) != 0) { fprintf(stdout, "Hall Symbol %s\n", SpgrInfo[1].HallSymbol); fprintf(stdout, "Hall Symbol %s\n", BC_SgInfo.HallSymbol); SetSgError("Verify Error: Wrong CBMx/InvCBMx"); PrintClearSgError(F_ClearError, 1); } else fprintf(stdout, "Verify O.K.\n"); } if (F_UnitCell) { putc('\n', stdout); if (TransformLatticeConstants(&LatConA, F_UnitCell, &LatConB, &SpgrInfo[0], CInvCBMx.s.R) != 0) PrintClearSgError(0, 1); fprintf(stdout, "Setting A UnitCell %.6g %.6g %.6g %.6g %.6g %.6g\n", LatConA.a, LatConA.b, LatConA.c, LatConA.alpha / PIover180, LatConA.beta / PIover180, LatConA.gamma / PIover180); fprintf(stdout, "Setting B UnitCell %.6g %.6g %.6g %.6g %.6g %.6g\n", LatConB.a, LatConB.b, LatConB.c, LatConB.alpha / PIover180, LatConB.beta / PIover180, LatConB.gamma / PIover180); } } putc('\n', stdout); } exit(0); /* old VAX didn't like "return 0;" */ return 0; }
int main(int argc, char *argv[]) { int iarg, ifld, idata, n; int lcount; FILE *fpin; char *fnin, buf[256], xtrac; double Scale; double Ttheta, Intens; Scale = 1.; fnin = NULL; fpin = NULL; for (iarg = 1; iarg < argc; iarg++) { if (argv[iarg][0] == '-') { if (str_ibegin(argv[iarg], "-Scale=") == 0) { n = sscanf(argv[iarg] + 7, "%lf %c", &Scale, &xtrac); if (n != 1) usage(); } else usage(); } else { if (fnin) usage(); fnin = argv[iarg]; } } if (fnin == NULL) fpin = stdin; else { fpin = fopen(fnin, "r"); if (fpin == NULL) { fprintf(stderr, "%s: Can't open %s\n", progn, fnin); exit(1); } } ifld = 0; idata = 0; lcount = 0; while (fgetline(fpin, buf, sizeof buf)) { lcount++; if (firstnonblank(buf) != '#') { n = sscanf(buf, "%lf%lf", &Ttheta, &Intens); if (n != 2) IllegalLine(fnin, lcount); Intens *= Scale; if (Intens < 1.) Intens = 1.; if (ifld == 8) { putc('\n', stdout); ifld = 0; } if (ifld == 0) putc(' ', stdout); fprintf(stdout, "%8.0f", Intens); ifld++; idata++; if (idata == 4095) break; } } if (fpin != stdin) fclose(fpin); if (ifld) putc('\n', stdout); fprintf(stdout, " %8.0f\n", 0.); exit(0); return 0; }