diff --git a/tracy/tracy/src/soleillib.cc b/tracy/tracy/src/soleillib.cc index bea629725192a10b2fc3254fb8963805772297f9..d9ee18d9ccd723a3ab8826b2168ad6711b7df6fe 100644 --- a/tracy/tracy/src/soleillib.cc +++ b/tracy/tracy/src/soleillib.cc @@ -419,214 +419,6 @@ void SetErr2(long seed,double fac) } } -/****************************************************************************/ -/* void ChamberOn(void) - - Purpose: - Switch on the vacuum chamber - Called by Read_Lattice - - Input: - none - - Output: - none - - Return: - none - - Global variables: - none - - specific functions: - DefineCh - - Comments: - none - -****************************************************************************/ -// Previously defined in soleilcommon.cc - -void ChamberOn(void) -{ - DefineCh(); - status.chambre = true; -} - -/****************************************************************************/ -/* void DefineCh(void) - - Purpose: called by read_Lattice - Defines the vacuum chamber around the ring - with the in vacuum undulator U20 - - Input: - none - - Output: - none - - Return: - none - - Global variables: - globval - - specific functions: - none - - Comments: - This function works providing that the makers have unique names into - the lattice - -****************************************************************************/ -void DefineCh(void) -{ - long i; - long isep1=-1L, isep2=-1L, hu600=-1L, - isdm1=-1L, isdm2=-1L, isdac1=-1L, isdac2=-1L; - -// trace=0; - isep1 = Elem_GetPos(ElemIndex("ssep"), 1); - isep2 = Elem_GetPos(ElemIndex("esep"), 1)-1; - hu600 = Elem_GetPos(ElemIndex("ehu600"), 1)-1; - isdm1 = Elem_GetPos(ElemIndex("ssdm"), 1); - isdm2 = Elem_GetPos(ElemIndex("esdm"), 1); - isdac1 = Elem_GetPos(ElemIndex("ssdac"), 1); - isdac2 = Elem_GetPos(ElemIndex("esdac"), 1)-1; - - /* Set the vaccum chamber */ - for (i = 0; i <= globval.Cell_nLoc; i++) - { - if ((i<isep1) || ((i>isep2) && (i<isdm1)) || - ((i>isdm2) && (i<isdac1)) || (i>isdac2)) - { /* ch normale */ - Cell[i].maxampl[X_][0] = -35.e-3; - Cell[i].maxampl[X_][1] = 35.e-3; - Cell[i].maxampl[Y_][0] = -12.5e-3; - Cell[i].maxampl[Y_][1] = 12.5e-3; - } - else if ((i>=isdm1) && (i<=isdm2)) - { /* SD13 */ - Cell[i].maxampl[X_][0] = -21e-3; - Cell[i].maxampl[X_][1] = 21e-3; - Cell[i].maxampl[Y_][0] = -5.0e-3; - Cell[i].maxampl[Y_][1] = 5.0e-3; - } - else if ((i>=isep1) && (i<=isep2)) - { /* septum */ - Cell[i].maxampl[X_][0] = -20e-3; - Cell[i].maxampl[X_][1] = 35e-3; - Cell[i].maxampl[Y_][0] = -12.5e-3; - Cell[i].maxampl[Y_][1] = 12.5e-3; - } - else if ((i>=isdac1) && (i<=isdac2)) - { /* with the minigap U20 */ - Cell[i].maxampl[X_][0] = -35e-3; - Cell[i].maxampl[X_][1] = 25e-3; - Cell[i].maxampl[Y_][0] = -2.5e-3; - Cell[i].maxampl[Y_][1] = 2.5e-3; - } - if (i<=hu600) -// if ((i>isep1) && (i<=hu600)) /* debut maille en section courte PB 25-09-07 */ - { /* HU640 */ - Cell[i].maxampl[Y_][0] = -7.0e-3; - Cell[i].maxampl[Y_][1] = 7.0e-3; - } - } -} - - -/****************************************************************************/ -/* void DefineChnoU20(void) - - Purpose: called by read_Lattice - Defines the vacuum chamber around the ring - without in vacuum undulator U20 - - Input: - none - - Output: - none - - Return: - none - - Global variables: - globval - - specific functions: - none - - Comments: - This function works providing that the makers have unique names into - the lattice - - This function is from Tracy 2, and useless here, since user can define - the vacuum chamber using ReadCh() - -****************************************************************************/ -void DefineChNoU20(void) -{ - long i; - long isep1=-1L, isep2=-1L, hu600=-1L, - isdm1=-1L, isdm2=-1L, isdac1=-1L, isdac2=-1L; - -// trace=0; -/* Look for indices for defining the vaccum pipe*/ - isep1 = Elem_GetPos(ElemIndex("ssep"), 1); - isep2 = Elem_GetPos(ElemIndex("esep"), 1)-1; - hu600 = Elem_GetPos(ElemIndex("ehu600"), 1)-1; - isdm1 = Elem_GetPos(ElemIndex("ssdm"), 1); - isdm2 = Elem_GetPos(ElemIndex("esdm"), 1); - isdac1 = Elem_GetPos(ElemIndex("ssdac"), 1); - isdac2 = Elem_GetPos(ElemIndex("esdac"), 1)-1; - -/* Set the vaccum chamber */ - for (i = 0; i <= globval.Cell_nLoc; i++) - { - if ((i<isep1) || ((i>isep2) && (i<isdm1)) || - ((i>isdm2) && (i<isdac1)) || (i>isdac2)) - { /* ch normale */ - Cell[i].maxampl[X_][0] = -35.e-3; - Cell[i].maxampl[X_][1] = 35.e-3; - Cell[i].maxampl[Y_][0] = -12.5e-3; - Cell[i].maxampl[Y_][1] = 12.5e-3; - } - else if ((i>=isdm1) && (i<=isdm2)) - { /* SD13 */ - Cell[i].maxampl[X_][0] = -21e-3; - Cell[i].maxampl[X_][1] = 21e-3; - Cell[i].maxampl[Y_][0] = -5.0e-3; - Cell[i].maxampl[Y_][1] = 5.0e-3; - } - else if ((i>=isep1) && (i<=isep2)) - { /* septum */ - Cell[i].maxampl[X_][0] = -20e-3; - Cell[i].maxampl[X_][1] = 35e-3; - Cell[i].maxampl[Y_][0] = -12.5e-3; - Cell[i].maxampl[Y_][1] = 12.5e-3; - } - else if ((i>=isdac1) && (i<=isdac2)) - { /* open the minigap U20*/ - Cell[i].maxampl[X_][0] = -35e-3; - Cell[i].maxampl[X_][1] = 25e-3; - Cell[i].maxampl[Y_][0] = -12.5e-3; - Cell[i].maxampl[Y_][1] = 12.5e-3; - } - if (i<=hu600) -// if ((i>isep1) && (i<=hu600)) /* debut maille en section courte PB 25-09-07 */ - { /* HU640 */ - Cell[i].maxampl[Y_][0] = -7.0e-3; - Cell[i].maxampl[Y_][1] = 7.0e-3; - } - } - - // turn on the global flag for CheckAmpl() - globval.Aperture_on = true; -} - /****************************************************************************/ /* void ReadCh(Const char *AperFile) @@ -671,7 +463,8 @@ void DefineChNoU20(void) ****************************************************************************/ void ReadCh(const char *AperFile) { - char line[max_str], Name1[max_str], Name2[max_str]; + char in[max_str], Name1[max_str], Name2[max_str]; + char *line; int Fnum1=0, Fnum2=0, Kidnum1=0, Kidnum2=0, k1=0, k2=0; int i=0, LineNum=0; double dxmin=0.0, dxmax=0.0, dymin=0.0, dymax=0.0; // min and max x and apertures @@ -683,7 +476,13 @@ void ReadCh(const char *AperFile) printf("\n"); printf("Loading and setting vacuum apertures to lattice elements...\n"); - while (fgets(line, max_str, fp) != NULL) { + while (line=fgets(in, max_str, fp)) { + /* kill preceding whitespace generated by "table" key + or "space" key, but leave \n + so we're guaranteed to have something*/ + while(*line == ' ' || *line == '\t') { + line++; + } /* count the line number that has been read*/ LineNum++; /* NOT read comment line or blank line with the end of line symbol '\n','\r' or '\r\n'*/ @@ -5217,7 +5016,8 @@ void set_RFVoltage(const int Fnum, const double V_RF){ *****************************************************************************************************/ void ReadFieldErr(const char *FieldErrorFile) { - char line[max_str], name[max_str], *prm; + char in[max_str], name[max_str], *prm; + char *line; int n = 0; /* field error order*/ int LineNum = 0; double Bn = 0.0, An = 0.0, r0 = 0.0; /* field error components and radius when the field error is measured */ @@ -5231,7 +5031,13 @@ void ReadFieldErr(const char *FieldErrorFile) printf("\n"); /* read lines*/ - while (fgets(line, max_str, inf) != NULL) { + while (line=fgets(in, max_str, inf)) { + /* kill preceding whitespace generated by "table" key + or "space" key, but leave \n + so we're guaranteed to have something*/ + while(*line == ' ' || *line == '\t') { + line++; + } LineNum++; /* check the line is whether comment line or null line*/ if (strstr(line, "#") == NULL && strcmp(line,"\n") != 0 &&