Beispiel #1
0
void SortSF_Tables(void)
{
  int  i;


  Flag_SF_Tab_SortFunction = -1.;

  for (i = 0; i < nSF_Tables; i++)
  {
    if (SF_Tables[i].nTab > 1)
    {
      qsort((void *)  SF_Tables[i].Tab, SF_Tables[i].nTab,
            sizeof (*(SF_Tables[i].Tab)),
            (SortFunction) SF_Tab_SortFunction);

      if (Flag_SF_Tab_SortFunction != -1.)
      {
        char  buf[128];

        Sprintf(buf,
          "ScatteringFactor %.60s: duplicate sin(Theta)/Lambda %.6g",
          SF_Tables[i].Label, Flag_SF_Tab_SortFunction);

        progerror(buf);
      }
    }
  }
}
Beispiel #2
0
static void SetProfileReferenceReflIndex(void)
{
  int         iLFc, iLFcClose, h, k, l;
  Fprec       TT, DeltaTT, CloseDelta;
  T_ListFcal  *LFc;


  iLFcClose  = -1;

  if      (ProfileReferenceRefl.Mode == PRRM_hkl)
  {
    h = ProfileReferenceRefl.h;
    k = ProfileReferenceRefl.k;
    l = ProfileReferenceRefl.l;

    if (IsSysAbsent_hkl(&SpgrInfo, h, k, l, NULL) != 0)
      progerror("ProfileReferenceRefl hkl is systematically absent");

    LFc = ListFcal;

    for (iLFc = 0; iLFc < nListFcal; iLFc++, LFc++)
    {
      if (AreSymEquivalent_hkl(&SpgrInfo, 1,
                               h, k, l,
                               LFc->h, LFc->k, LFc->l)) {
        iLFcClose = iLFc;
        break;
      }
    }
  }
  else if (ProfileReferenceRefl.Mode == PRRM_TTheta)
  {
    CloseDelta = 0.;

    LFc = ListFcal;

    for (iLFc = 0; iLFc < nListFcal; iLFc++, LFc++)
    {
                TT = TwoThetaDeg(LFc->Q);
      DeltaTT = TT - ProfileReferenceRefl.TTheta;
      DeltaTT = AppFabs(DeltaTT);

      if (CloseDelta > DeltaTT || iLFcClose < 0)
      {
          iLFcClose  = iLFc;
          CloseDelta = DeltaTT;
      }
    }
  }

  ProfileReferenceRefl.Index = iLFcClose;

  if (Debug1 && iLFcClose >= 0)
    Fprintf(stdout, "# ProfileReferenceRefl.Index -> %d %d %d  %.6g\n\n",
      ListFcal[iLFcClose].h,
      ListFcal[iLFcClose].k,
      ListFcal[iLFcClose].l,
      TwoThetaDeg(ListFcal[iLFcClose].Q));
}
Beispiel #3
0
static Fprec CalcSF_SFT(T_SF_Tables *SFT, Fprec stol)
{
  int       hit;
  Fprec     f0;
  int       iTab;
  T_SF_Tab  *Tab;


  Tab = SFT->Tab;

  hit = 0;

  for (iTab = 0; iTab < SFT->nTab; iTab++, Tab++)
  {
    if (stol <= Tab->stol)
    {
      hit = 1;
      break;
    }
  }

  if (hit == 0 || stol < SFT->Tab[0].stol)
  {
    char  buf[128];

    Sprintf(buf,
      "ScatteringFactor %.60s: sinTovL = %.6g out of range",
      SFT->Label, stol);

    progerror(buf);
  }

  if (iTab == 0 || stol == Tab->stol)
    f0 = Tab->f;
  else
  {      Tab--;
    f0 = Tab[0].f + (Tab[1].f - Tab[0].f) * (Tab[1].stol -        stol)
                                          / (Tab[1].stol - Tab[0].stol);
  }

  return f0;
}
Beispiel #4
0
static void NotEnoughCore(void)
{
  progerror("Not enough core");
}
Beispiel #5
0
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;
}
Beispiel #6
0
static Fprec DetFcalMaxQ(int UseRefrRefl, Fprec PeakRange)
{
  int    TT, h, k, l;
  Fprec  TTl, TTe, tanT, FWHM;
  Fprec  Q, FcalMaxQ;


  if (ProfileEnd == 0.)
  {
        TTe = TwoThetaDeg(FobsMaxQ);
    if (TTe == 0.)
      TT = 179;
    else {
          TT = (int) TTe + 1;
      if (TT > 179)
          TT = 179;
    }

    ProfileEnd = (Fprec) TT;
  }

  TTe = ProfileGenEnd = ProfileEnd;

  if (UseRefrRefl)
  {
    if      (ProfileReferenceRefl.Mode == PRRM_hkl)
    {
      h = ProfileReferenceRefl.h;
      k = ProfileReferenceRefl.k;
      l = ProfileReferenceRefl.l;

      if (IsSysAbsent_hkl(&SpgrInfo, h, k, l, NULL) != 0)
        progerror("ProfileReferenceRefl hkl is systematically absent");

      Q = Q_hkl(h, k, l, &LatConR);

      TTe = TwoThetaDeg(Q);
    }
    else if (   ProfileReferenceRefl.Mode == PRRM_TTheta
             && ProfileReferenceRefl.TTheta > 0.)
    {
          Q = SetHighQ(ProfileReferenceRefl.TTheta);
      if (Q == 0.)
        TTe = 179.;
      else
        TTe = TwoThetaDeg(Q);
    }

    if (ProfileGenEnd < TTe)
        ProfileGenEnd = TTe;

    TTe = ProfileGenEnd;
  }

  if (PeakRange > 0.)
  {
    for (TT = (int) ProfileGenEnd; TT < 179; TT++)
    {
                          tanT = AppTan(TT * .5 * PIover180);
          FWHM = CalcFWHM(tanT);
      if (FWHM >= 0.)
      {
            TTl = TT - FWHM * .5 * PeakRange;
        if (TTl <= ProfileGenEnd && TTe < (Fprec)(TT + 1))
          TTe = (Fprec)(TT + 1);
      }
    }
  }

  FcalMaxQ = Q_TTheta(TTe, LambdaLength);

  return FcalMaxQ;
}
Beispiel #7
0
void CompleteSite(T_Site *S, int nS, T_AtomType *AT, int nAT)
{
  int         iS, iAT;
  Fprec       Occ, Uiso;
  char        buf[128];
  T_AtomType  *eAT;


  for (iS = 0; iS < nS; iS++, S++)
  {
    if (S->SF_Info.Lbl)
    {
      if (CompleteSF_Info(&S->SF_Info, 1, 1) != 0)
      {
        Sprintf(buf, "Site  %s  %.60s: Unknown Scattering Factor Label",
          S->Label, S->SF_Info.Lbl);

        progerror(buf);
      }

      AppFree((char *) S->SF_Info.Lbl, strlen(S->SF_Info.Lbl) + 1);
    }
    else
    {
      S->SF_Info.Lbl = S->Label;

      if (CompleteSF_Info(&S->SF_Info, 0, 1) != 0)
      {
        Sprintf(buf, "Site  %s: Unknown Scattering Factor Label", S->Label);
        progerror(buf);
      }
    }

    if (S->SF_Info.SFT)
      S->SF_Info.Lbl = S->SF_Info.SFT->Label;
    else
      S->SF_Info.Lbl = S->SF_Info.CAA->Label;

    if (S->F_Occ == 0 || S->F_Uiso == 0)
    {
      for (iAT = 0, eAT = AT; iAT < nAT; iAT++, eAT++)
        if (eAT->SF_Info.Lbl == S->SF_Info.Lbl) break;

      if (iAT < nAT)
      {
        Occ  = eAT->OccDefault;
        Uiso = eAT->UisoDefault;
      }
      else
      {
        Occ  = Df_OccDefault;
        Uiso = Df_UisoDefault;
      }
    }

    if (S->F_Occ  == 0)
    {
      S->Occ  = Occ;
      S->F_Occ  = -1;
    }

    if (S->F_Uiso == 0)
    {
      S->Uiso = Uiso;
      S->F_Uiso = -1;
    }
  }
}
Beispiel #8
0
int CompleteSF_Info(T_SF_Info *SFI, int LblExact, int Set_f_stol_0)
{
  int          m;
  const char   *lt, *li;
  int          iSFT;
  T_SF_Tables  *SFT;


  if (SFI->SFT || SFI->CAA || SFI->f_stol_0 != -1.)
    InternalError("CompleteSF_Info(): SFI already set");

  SFT = SF_Tables;

  for (iSFT = 0; iSFT < nSF_Tables; iSFT++, SFT++)
  {
    if (str_icmp(SFT->Label, SFI->Lbl) == 0)
    {
      SFI->SFT = SFT;
      break;
    }
  }

  if (SFI->SFT == NULL && LblExact == 0)
  {
    SFT = SF_Tables;

    for (iSFT = 0; iSFT < nSF_Tables; iSFT++, SFT++)
    {
      m = 0;

      for (lt = SFT->Label, li = SFI->Lbl; isalpha(*lt); lt++, li++)
      {
        if (toupper(*lt) != toupper(*li))
        {
          m = 0;
          break;
        }

        m++;
      }

      if (m)
      {
        SFI->SFT = SFT;
        break;
      }
    }
  }

  if (SFI->SFT)
  {
    if (Set_f_stol_0)
    {
      if (SFI->SFT->Tab[0].stol != 0.)
      {
        char  buf[128];

        Sprintf(buf,
          "ScatteringFactor %.60s: missing entry for sinTovL = 0",
          SFI->SFT->Label);

        progerror(buf);
      }

      SFI->f_stol_0 = SFI->SFT->Tab[0].f;
    }
  }
  else
  {
    if (ModeScatteringFactorTable == 0)
    {
      SFI->CAA = FindSF_WK95_CAA(SFI->Lbl, LblExact);
      // printf("atom: %s -> using xray scattering factors from WK95\n", SFI->Lbl);
      if (NULL == SFI->CAA)
        return -1;
  
      if (Set_f_stol_0)
        SFI->f_stol_0 = CalcSF_WK95_CAA(SFI->CAA, 0.);
    }
 //   else if (ModeScatteringFactorTable == 1)
 //   {
 //     SFI->CAA = FindSF_IT92_CAA(SFI->Lbl, LblExact);
 //     printf("%s -> using scattering factors from IT92\n", SFI->Lbl);
 //     if (NULL == SFI->CAA)
 //       return -1;
 // 
 //     if (Set_f_stol_0)
 //       SFI->f_stol_0 = CalcSF_IT92_CAA(SFI->CAA, 0.);
 //   }
    else if (ModeScatteringFactorTable == 2)
    {
      SFI->CAA = FindSF_IT4322(SFI->Lbl, LblExact); // StefS 
      // printf("atom: %s -> using electron scattering factors from IT 4.3.2.2\n", SFI->Lbl); 
      if (NULL == SFI->CAA)
        return -1;
  
      if (Set_f_stol_0)
        SFI->f_stol_0 = CalcSF_IT4322(SFI->CAA, 0.);
    }
    else if (ModeScatteringFactorTable == 3)
    {
      SFI->CAA = FindSF_IT4323(SFI->Lbl, LblExact); // StefS 
      // printf("atom: %s -> using electron scattering factors from IT 4.3.2.3\n", SFI->Lbl); 
      if (NULL == SFI->CAA)
        return -1;
  
      if (Set_f_stol_0)
        SFI->f_stol_0 = CalcSF_IT4323(SFI->CAA, 0.);
    }
  }

  return 0;
}
int userinfo(void)
{
	
	/* Declarations */
	getmaxyx(stdscr, y,x); /* Screen Sizes */
	
	uid_t uid;
	gid_t gid;
	struct passwd *pw;
	
	uid = getuid();
	gid = getgid();
	
	WINDOW *uidlg; /* Prompt Username Window */
	
	
	
	/* Draw to screen */
	
	clear();
	box(stdscr, ACS_VLINE, ACS_HLINE);
	
	/*                  y x  - Screens */
	uidlg = newwin(6,61,6,8); /* User name input dialog */
	box(uidlg, ACS_VLINE, ACS_HLINE);
	wattron(uidlg, A_UNDERLINE);
	mvwprintw(uidlg, 1, 20, "User Information");
	wattroff(uidlg, A_UNDERLINE);
	
	/*  Buffer control */
	
	if((loginname = malloc(sizeof(char) * USER_BUFFER + 1)) == NULL)
		return(1);
	
	echo();    /* Turns on Echo to see the text typed */
	/* Username Prompt */
	mvwprintw(uidlg, 3, 1,  "Please type in username to look up:");
	mvwprintw(uidlg, 3, 37, "______________");
	wrefresh(uidlg);
	/* Now We need to gain strings that is typed in */
	
	
	/* Show a highlighted Field */
	wattron(uidlg, A_REVERSE);
	mvwprintw(uidlg, 3, 37, "______________");
	wrefresh(uidlg);
	mvwgetnstr(uidlg, 3,37, loginname, 15);
	wattroff(uidlg, A_REVERSE);
	noecho(); /* Removes Echo */
	

	werase(uidlg);	
	
	/* Shows User Information */
	refresh();
	
	attron(A_UNDERLINE);
	mvprintw(1, 25, "%s User Information", PROG_NAME); /* Title */
	attroff(A_UNDERLINE);
	
	refresh();
	

	/* Process User Info now has error handling */
		
	if (pw = getpwnam(loginname) == NULL) {
		progerror();
		free(loginname);
		return 1;
	} 
	else {
		pw = getpwnam(loginname);
	} 

	 
	mvprintw(4, 10, "Username: "******"%s", pw->pw_name); 
	mvprintw(5, 10, "User ID: "); 
	mvprintw(5, 25, "%d", pw->pw_uid);
	mvprintw(6, 10, "Group ID: ");
	mvprintw(6, 25, "%d", pw->pw_gid);
	mvprintw(7, 10, "Shell: ");
	mvprintw(7, 25, "%s", pw->pw_shell);
	mvprintw(8, 10, "Home dir: ");
	mvprintw(8, 25, "%s", pw->pw_dir);
	mvprintw(9, 10, "Comment: ");
	mvprintw(9, 25, "%s", pw->pw_gecos); 
	
	mvprintw(15,20, "Press Enter to return after viewing");
	
	getch();
	
	free(loginname);
	return 0;
}