diff --git a/tracy/tools/soltracy.cc b/tracy/tools/soltracy.cc
index 6a0846af07cb826a52f723a1e806736474912ae1..892de98e9885af7ae0bbb808b50b292a133f900e 100644
--- a/tracy/tools/soltracy.cc
+++ b/tracy/tools/soltracy.cc
@@ -33,13 +33,15 @@ int main(int argc, char *argv[]) {
 
   //  const double  x_max_FMA = 10e-3,  delta_FMA = 10e-2;
   //  const int     n_x = 801, n_dp = 80, n_tr = 2048;
-
+  long i=0L; //initilize the for loop to read command string
+  char CommandStr[max_str];
   double nux = 0, nuy = 0, ksix = 0, ksiy = 0;
-
   bool chroma;
   double dP = 0.0;
   long lastpos = -1L;
   char str1[S_SIZE];
+  
+ 
 
   // for time handling
   uint32_t start, stop;
@@ -63,10 +65,31 @@ int main(int argc, char *argv[]) {
   getcod(dP, lastpos);
   prt_cod("cod.out", globval.bpm, true);
 
-  // Flag factory
-
+  
+  //get_matching_params_scl(); // get tunes and beta functions at entrance
+  // compute up to 3rd order momentum compact factor
+  get_alphac2(); 
+  //cout << endl << "computing tune shifts" << endl;
+  //dnu_dA(10e-3, 5e-3, 0.002);
+  //get_ksi2(0.0); // this gets the chromas and writes them into chrom2.out
+  
+  
+  
+   // Flag factory
+  for(i=0;i<CommandNo;i++){//read user defined command by sequence
+   //assign user defined command
+    strcpy(CommandStr,UserCommand[i]); 
+    
+    //turn on flag for quadrupole fringe field
+    if(strcmp(CommandStr,"QuadFringeOnFlag") == 0) {
+      globval.quad_fringe = true;
+      cout << "\n";
+      cout << "globval.quad_fringe is " << globval.quad_fringe << "\n";
+   }
+    
   //set RF voltage  
-  if (RFvoltageFlag == true) {
+  //if (RFvoltageFlag == true) {
+  else if(strcmp(CommandStr,"RFvoltageFlag") == 0) {
     printf("\nSetting RF voltage:\n");
     printf("    Old RF voltage is: %lf [MV]\n", get_RFVoltage(ElemIndex("cav"))
         / 1e6);
@@ -76,36 +99,31 @@ int main(int argc, char *argv[]) {
   }
 
   // Chamber factory
- // if (ChamberFlag == false)
-  //  ChamberOff(); // turn off vacuum chamber setting, use the default +-1 meters
-  if (ReadChamberFlag == true)
+ // if (ReadChamberFlag == true)
+  else if(strcmp(CommandStr,"ReadChamberFlag") == 0) {
     ReadCh(chamber_file); /* read vacuum chamber from a file "Apertures.dat" , soleil version*/
   PrintCh(); // print chamber into chamber.out
+  }
 
-  //get_matching_params_scl(); // get tunes and beta functions at entrance
-  get_alphac2(); // compute up to 3rd order mcf
-  //cout << endl << "computing tune shifts" << endl;
-  //dnu_dA(10e-3, 5e-3, 0.002);
-  //get_ksi2(0.0); // this gets the chromas and writes them into chrom2.out
-
-
+ 
   // compute tunes by tracking (should be the same as by tps)
-  if (TuneTracFlag == true) {
+  else if (strcmp(CommandStr,"TuneTracFlag") == 0) {
     GetTuneTrac(1026L, 0.0, &nux, &nuy);
     fprintf(stdout, "From tracking: nux = % f nuz = % f \n", nux, nuy);
-  }
+    }
 
   // compute chromaticities by tracking (should be the same as by DA)
-  if (ChromTracFlag == true) {
+  else if(strcmp(CommandStr,"ChromTracFlag") == 0) {
     start = stampstart();
     GetChromTrac(2L, 1026L, 1e-5, &ksix, &ksiy);
     stop = stampstop(start);
-
     fprintf(stdout, "From tracking: ksix= % f ksiz= % f \n", ksix, ksiy);
-  }
+    }
+    
 
   //generic function, to fit tunes using 1 family of quadrupoles
-  if (FitTuneFlag == true) {
+ // if (FitTuneFlag == true) {
+  else if(strcmp(CommandStr,"FitTuneFlag") == 0) {
     double qf_bn = 0.0, qd_bn = 0.0;
     double qf_bn_fit = 0.0, qd_bn_fit = 0.0;
 
@@ -134,7 +152,8 @@ int main(int argc, char *argv[]) {
   }
 
   /* specific for soleil ring in which the quadrupole is cut into 2 parts*/
-  if (FitTune4Flag == true) {
+  //if (FitTune4Flag == true) {
+  else if(strcmp(CommandStr,"FitTune4Flag") == 0) {
     double qf1_bn = 0.0, qf2_bn = 0.0, qd1_bn = 0.0, qd2_bn = 0.0;
     double qf1_bn_fit = 0.0, qf2_bn_fit = 0.0, qd1_bn_fit = 0.0, qd2_bn_fit =
         0.0;
@@ -172,8 +191,9 @@ int main(int argc, char *argv[]) {
   }
 
   /* fit the chromaticities*/
-  if (FitChromFlag == true) {
-
+ // if (FitChromFlag == true) {
+  else if(strcmp(CommandStr,"FitChromFlag") == 0) {
+  
     double sxm1_bn = 0.0, sxm2_bn = 0.0;
     double sxm1_bn_fit = 0.0, sxm2_bn_fit = 0.0;
     sxm1_bn = Cell[Elem_GetPos(ElemIndex(sxm1), 1)].Elem.M->PB[HOMmax + 3];
@@ -199,7 +219,8 @@ int main(int argc, char *argv[]) {
   }
 
   // coupling calculation
-  if (CouplingFlag == true) {
+ // if (CouplingFlag == true) {
+  else if(strcmp(CommandStr,"CouplingFlag") == 0) {
     Ring_GetTwiss(chroma = true, 0.0); /* Compute and get Twiss parameters */
     printlatt(); /* dump linear lattice functions into "linlat.dat" */
    // GetEmittance(ElemIndex("cav"), true);  //only for test
@@ -209,7 +230,8 @@ int main(int argc, char *argv[]) {
   }
 
   // add coupling by random rotating of the full quadrupole magnets
-  if (ErrorCouplingFlag == true) {
+  //if (ErrorCouplingFlag == true) {
+  else if(strcmp(CommandStr,"ErrorCouplingFlag") == 0) {
     prtmfile("flat_file.dat"); //print the elements without rotation errors
     SetErr(err_seed, err_rms);
     prtmfile("flat_file_errcoupling_full.dat"); //print the elements with rotation errors
@@ -223,7 +245,8 @@ int main(int argc, char *argv[]) {
   }
   
   // add coupling by random rotating of the half quadrupole magnets, delicated for soleil
-  if (ErrorCoupling2Flag == true) {
+  //if (ErrorCoupling2Flag == true) {
+  else if(strcmp(CommandStr,"ErrorCoupling2Flag") == 0) {
     prtmfile("flat_file.dat"); //print the elements without rotation errors
     SetErr2(err_seed, err_rms);
     prtmfile("flat_file_errcoupling_half.dat"); //print the elements with rotation errors
@@ -238,7 +261,8 @@ int main(int argc, char *argv[]) {
   // WARNING Fit tunes and chromaticities before applying errors !!!!
   //set multipoles in all magnets
   // read multipole error from a file
-  if (ReadMultipoleFlag == true) {
+ // if (ReadMultipoleFlag == true) {
+  else if(strcmp(CommandStr,"ReadMultipoleFlag") == 0) {
     fprintf(stdout,
         "\n Read Multipoles file for lattice with thick sextupoles \n");
     ReadFieldErr(multipole_file);
@@ -249,71 +273,67 @@ int main(int argc, char *argv[]) {
   }
 
   //Old version to multipole errors in soleil lattice, is obsoleted
-  if (MultipoleFlag == true) {
-    if (ThinsextFlag == true) {
-      fprintf(stdout,
-          "\n Setting Multipoles for lattice with thin sextupoles \n");
-      Multipole_thinsext(fic_hcorr, fic_vcorr, fic_skew); /* for thin sextupoles */
-      prtmfile("flat_file_errmultipole.dat"); // writes flat file   /* very important file for debug*/
-      Ring_GetTwiss(chroma = true, 0.0); /* Compute and get Twiss parameters */
-      printglob();
-    } else {
-      fprintf(stdout,
-          "\n Setting Multipoles for lattice with thick sextupoles \n");
-      Multipole_thicksext(fic_hcorr, fic_vcorr, fic_skew); /* for thick sextupoles */
-      prtmfile("flat_file_errmultipole.dat"); // writes flat file   /* very important file for debug*/
-      Ring_GetTwiss(chroma = true, 0.0); /* Compute and get Twiss parameters */
-      printglob();
-    }
-  }
+ // if (MultipoleFlag == true) {
+  //  if (ThinsextFlag == true) {
+   //   fprintf(stdout,
+   //       "\n Setting Multipoles for lattice with thin sextupoles \n");
+   //   Multipole_thinsext(fic_hcorr, fic_vcorr, fic_skew); /* for thin sextupoles */
+   //   prtmfile("flat_file_errmultipole.dat"); // writes flat file   /* very important file for debug*/
+   //   Ring_GetTwiss(chroma = true, 0.0); /* Compute and get Twiss parameters */
+   //   printglob();
+   // } else {
+   //   fprintf(stdout,
+   //       "\n Setting Multipoles for lattice with thick sextupoles \n");
+   //   Multipole_thicksext(fic_hcorr, fic_vcorr, fic_skew); /* for thick sextupoles */
+   //   prtmfile("flat_file_errmultipole.dat"); // writes flat file   /* very important file for debug*/
+   //   Ring_GetTwiss(chroma = true, 0.0); /* Compute and get Twiss parameters */
+   //   printglob();
+   // }
+ // }
 
   /******************************************************************************************/
   // COMPUTATION PART after setting the model
   /******************************************************************************************/
 
   // computes TuneShift with amplitudes
-  if (AmplitudeTuneShiftFlag == true) {
-   // if (ChamberFlag == true) {
+ // if (AmplitudeTuneShiftFlag == true) {
+  else if(strcmp(CommandStr,"AmplitudeTuneShiftFlag") == 0) {
       TunesShiftWithAmplitude(_AmplitudeTuneShift_nxpoint, _AmplitudeTuneShift_nypoint,
           _AmplitudeTuneShift_nturn, _AmplitudeTuneShift_xmax,
           _AmplitudeTuneShift_ymax, _AmplitudeTuneShift_delta);
-      //NuDx(31L,21L,516L,0.025,0.005,dP);
-    } //else { // Utility ?
-     // TunesShiftWithAmplitude(50L, 30L, 516L, 0.035, 0.02, dP);
-   // }
-
-  //}
-  if (EnergyTuneShiftFlag == true) {
-   // if (ChamberFlag == true) {
+    } 
+   //compute tuneshift with energy
+  //if (EnergyTuneShiftFlag == true) {
+  else if(strcmp(CommandStr,"EnergyTuneShiftFlag") == 0) {
       TunesShiftWithEnergy(_EnergyTuneShift_npoint, _EnergyTuneShift_nturn,
           _EnergyTuneShift_deltamax);
-      //NuDp(31L,1026L,0.06);
-    }// else { // utility ?
-     // TunesShiftWithEnergy(31L, 1026L, 0.06);
-    //}
-
-  //}
+    }
 
   // Computes FMA
-  if (FmapFlag == true) {
+  //if (FmapFlag == true) {
+  else if(strcmp(CommandStr,"FmapFlag") == 0) {
+    printf("\n begin Fmap calculation for on momentum particles: \n");
     fmap(_FmapFlag_nxpoint, _FmapFlag_nypoint, _FmapFlag_nturn, _FmapFlag_xmax,
         _FmapFlag_ymax, _FmapFlag_delta, _FmapFlag_diffusion);
   }
 
   // Compute FMA dp
-  if (FmapdpFlag == true) {
+ // if (FmapdpFlag == true) {
+  else if(strcmp(CommandStr,"FmapdpFlag") == 0) {
+    printf("\n begin Fmap calculation for off momentum particles: \n");
     fmapdp(_FmapdpFlag_nxpoint, _FmapdpFlag_nepoint, _FmapdpFlag_nturn,
         _FmapdpFlag_xmax, _FmapdpFlag_emax, _FmapdpFlag_z,
         _FmapdpFlag_diffusion);
   }
 
-  if (CodeComparaisonFlag) {
+ // if (CodeComparaisonFlag) {
+  else if(strcmp(CommandStr,"CodeComparaisonFlag") == 0) {
     fmap(200, 100, 1026, -32e-3, 7e-3, 0.0, true);
   }
 
   // MOMENTUM ACCEPTANCE
-  if (MomentumAccFlag == true) {
-
+ // if (MomentumAccFlag == true) {
+  else if(strcmp(CommandStr,"MomentumAccFlag") == 0) {
     bool cavityflag, radiationflag;
     /* record the initial values*/
     cavityflag = globval.Cavity_on;
@@ -332,6 +352,7 @@ int main(int argc, char *argv[]) {
     };
 
     /* calculate momentum acceptance*/
+    printf("\n Calculate momentum acceptance: \n");
     MomentumAcceptance(_MomentumAccFlag_istart, _MomentumAccFlag_istop,
         _MomentumAccFlag_deltaminp, _MomentumAccFlag_deltamaxp,
         _MomentumAccFlag_nstepp, _MomentumAccFlag_deltaminn,
@@ -343,11 +364,14 @@ int main(int argc, char *argv[]) {
   }
 
   // induced amplitude 
-  if (InducedAmplitudeFlag == true) {
+ // if (InducedAmplitudeFlag == true) {
+  else if(strcmp(CommandStr,"InducedAmplitudeFlag") == 0) {
+   printf("\n Calculate induced amplitude: \n");
     InducedAmplitude(193L);
   }
 
-  if (EtaFlag == true) {
+ // if (EtaFlag == true) {
+  else if(strcmp(CommandStr,"EtaFlag") == 0) {
     // compute cod and Twiss parameters for different energy offsets
     for (int ii = 0; ii <= 40; ii++) {
       dP = -0.02 + 0.001 * ii;
@@ -364,7 +388,8 @@ int main(int argc, char *argv[]) {
     }
   }
 
-  if (PhaseSpaceFlag == true) {
+  //if (PhaseSpaceFlag == true) {
+  else if(strcmp(CommandStr,"PhaseSpaceFlag") == 0) {
     bool cavityflag, radiationflag;
     /* record the initial values*/
     cavityflag = globval.Cavity_on;
@@ -396,7 +421,10 @@ int main(int argc, char *argv[]) {
     globval.radiation = radiationflag;
   }
   
- 
+ else
+    printf("Wrong!!!!!");
+ }//end of looking for user defined flag
+  
 
   //  ????????????? NSRL version, Check with Soleil version "MomentumAcceptance"
   // IBS & TOUSCHEK
@@ -406,6 +434,7 @@ int main(int argc, char *argv[]) {
   const double Qb = 5e-9; // e charge in one bunch
 
   if (TouschekFlag == true) {
+//  else if(strcmp(CommandStr,"TouschekFlag") == 0) {
     double sum_delta[globval.Cell_nLoc + 1][2];
     double sum2_delta[globval.Cell_nLoc + 1][2];
 
@@ -448,7 +477,7 @@ int main(int argc, char *argv[]) {
     Touschek(Qb, globval.delta_RF, globval.eps[X_], globval.eps[Y_],
         sigma_delta, sigma_s);
 
-    // Intra Beam Scattering(IBS)
+ // Intra Beam Scattering(IBS)
     if (IBSFlag == true) {
       // initialize eps_IBS with eps_SR
       for (k = 0; k < 3; k++)
@@ -483,6 +512,7 @@ int main(int argc, char *argv[]) {
 
   }
 
+  
   return 0;
-}
+}//end of main() 
 
diff --git a/tracy/tracy/inc/read_script.h b/tracy/tracy/inc/read_script.h
index 5e0478e70f90b0b05f873517c77f38def3e30b3e..c5aba1e2c70bb18baf11ef87903f71beb01093f0 100644
--- a/tracy/tracy/inc/read_script.h
+++ b/tracy/tracy/inc/read_script.h
@@ -1,33 +1,38 @@
+//extern long max_line;
+extern char UserCommand[500][max_str];  //string array with bool flag
+extern long CommandNo;
+
 /* global flag, used in script_read() and main() for read the input from script*/
 
-extern bool QuadFringeOnFlag;
+//extern bool QuadFringeOnFlag;
 
-extern bool RFvoltageFlag; extern double RFvolt;
+//extern bool RFvoltageFlag; 
+extern double RFvolt;
 
-extern bool TuneTracFlag;
-extern bool ChromTracFlag ;
+//extern bool TuneTracFlag;
+//extern bool ChromTracFlag ;
 
-extern bool FmapFlag;
+//extern bool FmapFlag;
 extern long _FmapFlag_nxpoint, _FmapFlag_nypoint, _FmapFlag_nturn;
 extern double _FmapFlag_xmax, _FmapFlag_ymax, _FmapFlag_delta;
 extern bool _FmapFlag_diffusion;
 
-extern bool FmapdpFlag;
+//extern bool FmapdpFlag;
 extern long _FmapdpFlag_nxpoint, _FmapdpFlag_nepoint, _FmapdpFlag_nturn;
 extern double _FmapdpFlag_xmax, _FmapdpFlag_emax, _FmapdpFlag_z;
 extern bool _FmapdpFlag_diffusion;	
 
-extern bool AmplitudeTuneShiftFlag;
+//extern bool AmplitudeTuneShiftFlag;
 extern long _AmplitudeTuneShift_nxpoint, _AmplitudeTuneShift_nypoint;
 extern long _AmplitudeTuneShift_nturn;
 extern double _AmplitudeTuneShift_xmax, _AmplitudeTuneShift_ymax, _AmplitudeTuneShift_delta;
 
-extern bool EnergyTuneShiftFlag;
+//extern bool EnergyTuneShiftFlag;
 extern long _EnergyTuneShift_npoint, _EnergyTuneShift_nturn;
 extern double _EnergyTuneShift_deltamax;
 
 
-extern bool MomentumAccFlag;
+//extern bool MomentumAccFlag;
 extern char TrackDim[3];
 extern long  _MomentumAccFlag_istart, _MomentumAccFlag_istop,
             _MomentumAccFlag_nstepn, _MomentumAccFlag_nstepp;
@@ -41,27 +46,32 @@ extern long _Phase_nturn;
 extern char _Phase_Dim[3];
 extern bool _Phase_Damping;
 
-extern bool ErrorCouplingFlag ; extern long err_seed; extern double err_rms;
-extern bool ErrorCoupling2Flag ;
-extern bool CouplingFlag ;
+//extern bool ErrorCouplingFlag ; 
+extern long err_seed; extern double err_rms;
+//extern bool ErrorCoupling2Flag ;
+//extern bool CouplingFlag ;
 
 extern char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str];
 extern char multipole_file[max_str];
-extern bool ReadMultipoleFlag;
-extern bool MultipoleFlag , ThinsextFlag ;
+//extern bool ReadMultipoleFlag;
+//extern bool MultipoleFlag , ThinsextFlag ;
+
+//extern bool FitTuneFlag ; 
+extern char qf[max_str],qd[max_str]; extern double targetnux, targetnuz;
+//extern bool FitTune4Flag  ; 
+extern char qf1[max_str],qf2[max_str],qd1[max_str],qd2[max_str]; 
+//extern bool FitChromFlag ; 
+extern char sxm1[max_str],sxm2[max_str]; extern double targetksix, targetksiz ;
 
-extern bool FitTuneFlag ; extern char qf[max_str],qd[max_str]; extern double targetnux, targetnuz;
-extern bool FitTune4Flag  ; extern char qf1[max_str],qf2[max_str],qd1[max_str],qd2[max_str]; 
-extern bool FitChromFlag ; extern char sxm1[max_str],sxm2[max_str]; extern double targetksix, targetksiz ;
 //extern bool ChamberFlag , 
-extern bool ReadChamberFlag;
-extern bool GirderErrorFlag ;
-extern bool SigmaFlag ;
-extern bool PX2Flag;
-extern bool InducedAmplitudeFlag;
-extern bool CodeComparaisonFlag;
-extern bool EtaFlag;
-extern bool PhaseSpaceFlag;  
+//extern bool ReadChamberFlag;
+//extern bool GirderErrorFlag ;
+//extern bool SigmaFlag ;
+//extern bool PX2Flag;
+//extern bool InducedAmplitudeFlag;
+//extern bool CodeComparaisonFlag;
+//extern bool EtaFlag;
+//extern bool PhaseSpaceFlag;  
 extern bool TouschekFlag, IBSFlag, TousTrackFlag;
 extern char chamber_file[max_str];
 
diff --git a/tracy/tracy/src/read_script.cc b/tracy/tracy/src/read_script.cc
index 94a2fa061f236b532518abf802df82117990e857..f796b97be6b2968983e2561fd747a9a6048fa870 100644
--- a/tracy/tracy/src/read_script.cc
+++ b/tracy/tracy/src/read_script.cc
@@ -26,40 +26,48 @@
        Jianfeng Zhang 07/2010 soleil
 
 ****************************************************************************/
-/* global flag, used in script_read() and main() for read the input from script*/
+/* The string array stored the command which are read from user input script*/
+//long max_line = 500L;
+//#define max_line 500;
+char UserCommand[500][max_str];  //string array which store user command flag
+long CommandNo; //number of bool flags in the user script
+
 
-bool QuadFringeOnFlag = false;
+/* global flag, used in script_read() and main() for read the input from script*/
+//bool QuadFringeOnFlag = false;
 
-bool RFvoltageFlag =false; double RFvolt =0.0;
+//bool RFvoltageFlag =false; 
+double RFvolt =0.0;
 
-bool TuneTracFlag = false;
-bool ChromTracFlag = false;
+//char TuneTracFlag;
+//char ChromTracFlag;
 
-bool FmapFlag = false;
+//bool FmapFlag = false;
 long _FmapFlag_nxpoint=31L, _FmapFlag_nypoint=21L, _FmapFlag_nturn=516L;
 double _FmapFlag_xmax=0.025, _FmapFlag_ymax=0.005, _FmapFlag_delta=0.0;
 bool _FmapFlag_diffusion = true;
 
-bool FmapdpFlag = false;
+//bool FmapdpFlag = false;
 long _FmapdpFlag_nxpoint=31L, _FmapdpFlag_nepoint=21L, _FmapdpFlag_nturn=516L;
 double _FmapdpFlag_xmax=0.025, _FmapdpFlag_emax=0.005, _FmapdpFlag_z=0.0;
 bool _FmapdpFlag_diffusion = true;			
 
-bool AmplitudeTuneShiftFlag = false;
+//bool AmplitudeTuneShiftFlag = false;
 long _AmplitudeTuneShift_nxpoint=31L; long _AmplitudeTuneShift_nypoint=21L;
 long _AmplitudeTuneShift_nturn=516L; double _AmplitudeTuneShift_xmax=0.025;
 double _AmplitudeTuneShift_ymax=0.005, _AmplitudeTuneShift_delta=0.0;
 
-bool EnergyTuneShiftFlag = false;
+//bool EnergyTuneShiftFlag = false;
 long _EnergyTuneShift_npoint=31L; long _EnergyTuneShift_nturn=516L;
 double _EnergyTuneShift_deltamax=0.06;
 
-bool ErrorCouplingFlag = false; long err_seed=0L; double err_rms=0.0;  
-bool ErrorCoupling2Flag = false;
-bool CouplingFlag = false;
+//bool ErrorCouplingFlag = false; 
+long err_seed=0L; double err_rms=0.0;  
+//bool ErrorCoupling2Flag = false;
+//bool CouplingFlag = false;
 
 
-bool MomentumAccFlag = false;
+//bool MomentumAccFlag = false;
 char TrackDim[3] = "6D";
 long  _MomentumAccFlag_istart=1L, _MomentumAccFlag_istop=108L,
      _MomentumAccFlag_nstepn=100L, _MomentumAccFlag_nstepp=100L;
@@ -73,26 +81,29 @@ long _Phase_nturn=512L;
 char _Phase_Dim[3]="4D";
 bool _Phase_Damping = false;
 
-bool ReadMultipoleFlag = false;
-bool MultipoleFlag = false, ThinsextFlag = false;
+//bool ReadMultipoleFlag = false;
+//bool MultipoleFlag = false, ThinsextFlag = false;
 
 char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str];
 
 /*generic function to fit tunes using 1 family of quadrupoles*/
-bool FitTuneFlag  = false; char qf[max_str],qd[max_str]; double targetnux = 0.0, targetnuz = 0.0;
+//bool FitTuneFlag  = false; 
+char qf[max_str],qd[max_str]; double targetnux = 0.0, targetnuz = 0.0;
 /* specific for soleil lattice in which the quadrupole is cut into 2 parts*/
-bool FitTune4Flag  = false; char qf1[max_str],qf2[max_str],qd1[max_str],qd2[max_str];
+//bool FitTune4Flag  = false; 
+char qf1[max_str],qf2[max_str],qd1[max_str],qd2[max_str];
 
-bool FitChromFlag = false; char sxm1[max_str],sxm2[max_str]; double targetksix = 0.0, targetksiz = 0.0;
+//bool FitChromFlag = false; 
+char sxm1[max_str],sxm2[max_str]; double targetksix = 0.0, targetksiz = 0.0;
 //bool ChamberFlag = false, 
-bool ReadChamberFlag = false;
-bool GirderErrorFlag = false;
-bool SigmaFlag = false;
-bool PX2Flag = false;
-bool InducedAmplitudeFlag = false;
-bool CodeComparaisonFlag = false;
-bool EtaFlag = false;           
-bool PhaseSpaceFlag = false;
+//bool ReadChamberFlag = false;
+//bool GirderErrorFlag = false;
+//bool SigmaFlag = false;
+//bool PX2Flag = false;
+//bool InducedAmplitudeFlag = false;
+//bool CodeComparaisonFlag = false;
+//bool EtaFlag = false;           
+//bool PhaseSpaceFlag = false;
 bool TouschekFlag = false, IBSFlag = false, TousTrackFlag = false;
 
 char chamber_file[max_str];
@@ -102,17 +113,28 @@ char multipole_file[max_str];
 /*  Read script   */
 void read_script(const char *param_file_name, bool rd_lat)
  {
+  //initialize bool flag number in the user script
+  CommandNo = 0L; 
+ 
+  
   char    str[max_str]="voidstring", dummy[max_str]="voidstring";
-  char    line[max_str]="voidline", name[max_str]="voidname";
+  char    in[max_str];  //temporary line with preceding white space
+  char    *line; //line to store the command without preceding white space
+  char    name[max_str]="voidname";
   char    lat_file[max_str]="voidlattice";
+  char    EndName[]="void";
  
   FILE    *inf;
   const bool  prt = false; // for debugging printout each line of input file
   long int    LineNum=0L;
+  long int    NameLen=0L;
   char full_param_file_name[max_str];
   char lat_FileName[max_str];
  //bool TuneTracFlag;
   char *pch;
+  
+  
+  
 
   // Manipulation of the parameter file
   strcpy(dummy, param_file_name);
@@ -126,19 +148,46 @@ void read_script(const char *param_file_name, bool rd_lat)
   //
   inf = file_read(full_param_file_name);
 
-  // read line by line parameter file
-   while (fgets(line, max_str, inf) != NULL) {
+  
+  // read parameter file, line by line 
+ //  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++;
+     }       
+    
     if(prt)
       printf("cfg: %s",line);
       
       LineNum++;
-    
+           
     /* read the end of line symbol '\n','\r' or '\r\n' at different operation system*/
     if (strstr(line, "#") == NULL && strcmp(line,"\n") != 0 &&
         strcmp(line,"\r") != 0 && strcmp(line,"\r\n") != 0) {
       // get initial command token
       sscanf(line, "%s", name);
       
+      
+      //find the sequence of the bool flag in user input script 
+      NameLen = strlen(name);
+      EndName[0] = name[NameLen-4];
+      EndName[1] = name[NameLen-3];
+      EndName[2] = name[NameLen-2];
+      EndName[3] = name[NameLen-1];          
+      
+      //find the bool flag whose last 4 character are 'Flag' 
+      if(strcmp(EndName,"Flag")==0)
+        CommandNo++;
+      
+      
+      
+      
+      
       /*read file names................. */
       /* set file directory*/
       if (strcmp("in_dir", name) == 0)
@@ -175,38 +224,51 @@ void read_script(const char *param_file_name, bool rd_lat)
       } 
       
       /* read in bool flags */
-   //   else if (strcmp("ChamberFlag", name) == 0){
-   //	 ChamberFlag = true;
-   //  }
      else if (strcmp("ReadChamberFlag", name) == 0){
-         ReadChamberFlag = true;
-     }
+	  strcpy(UserCommand[CommandNo-1],name);
+      } 
+    // else if (strcmp("ReadChamberFlag", name) == 0){
+     //    ReadChamberFlag = true;
+	
+    // }
+     // else if (strcmp("QuadFringeOnFlag", name) == 0){
+      //  	globval.quad_fringe = true;
+     // }
       else if (strcmp("QuadFringeOnFlag", name) == 0){
-        	globval.quad_fringe = true;
+	  strcpy(UserCommand[CommandNo-1],name);
       }
       
+    //  else if (strcmp("RFvoltageFlag", name) == 0){
+     //     RFvoltageFlag = true;
+    //	  sscanf(line, "%*s %lf", &RFvolt);
+     // }
       else if (strcmp("RFvoltageFlag", name) == 0){
-          RFvoltageFlag = true;
 	  sscanf(line, "%*s %lf", &RFvolt);
+	  strcpy(UserCommand[CommandNo-1],name);
       }
       
-      
       else if (strcmp("TuneTracFlag", name) == 0){
-          TuneTracFlag = true;
+        //  TuneTracFlag = true;
+	  strcpy(UserCommand[CommandNo-1],name);
       }
       else if (strcmp("ChromTracFlag", name) == 0){
-          ChromTracFlag = true;
+        //  ChromTracFlag = true;
+	   strcpy(UserCommand[CommandNo-1],name);
+	   cout << UserCommand[CommandNo-1] << "\n";
       }
       // FMA
       else if (strcmp("FmapFlag", name) == 0){
+      //else if (strcmp("FmapFlag", name) == 0){
+          
     	  strcpy(dummy, "");
           sscanf(line, "%*s %ld %ld %ld %lf %lf %lf %s", 
           		&_FmapFlag_nxpoint, &_FmapFlag_nypoint,
           		&_FmapFlag_nturn, &_FmapFlag_xmax, &_FmapFlag_ymax,
           		&_FmapFlag_delta, dummy);
        
-           FmapFlag = true;
-        
+          // FmapFlag = true;
+         strcpy(UserCommand[CommandNo-1],name);
+	  
         if(strcmp(dummy, "true") == 0)
           _FmapFlag_diffusion = true;
         else if(strcmp(dummy, "false") == 0)
@@ -218,14 +280,17 @@ void read_script(const char *param_file_name, bool rd_lat)
       }
       // FMA dp
       else if (strcmp("FmapdpFlag", name) == 0){
+     // else if (strcmp("FmapdpFlag", name) == 0){
+          
     	  strcpy(dummy, "");
           sscanf(line, "%*s %ld %ld %ld %lf %lf %lf %s", 
           		&_FmapdpFlag_nxpoint, &_FmapdpFlag_nepoint,
           		&_FmapdpFlag_nturn, &_FmapdpFlag_xmax, &_FmapdpFlag_emax,
           		&_FmapdpFlag_z, dummy);
       
-           FmapdpFlag = true;
-      
+         //  FmapdpFlag = true;
+         strcpy(UserCommand[CommandNo-1],name);
+	 
         if(strcmp(dummy, "true") == 0)
           _FmapdpFlag_diffusion = true;
         else if(strcmp(dummy, "false") == 0)
@@ -236,36 +301,39 @@ void read_script(const char *param_file_name, bool rd_lat)
         }
       }
       else if (strcmp("AmplitudeTuneShiftFlag", name) == 0){
+      strcpy(UserCommand[CommandNo-1],name);
         sscanf(line, "%*s %ld %ld %ld %lf %lf %lf", &_AmplitudeTuneShift_nxpoint,
         		&_AmplitudeTuneShift_nypoint, &_AmplitudeTuneShift_nturn,
         		&_AmplitudeTuneShift_xmax, &_AmplitudeTuneShift_ymax,
         		&_AmplitudeTuneShift_delta);
    
-        	AmplitudeTuneShiftFlag = true;
+        //	AmplitudeTuneShiftFlag = true;
        
       }
       else if (strcmp("EnergyTuneShiftFlag", name) == 0){
+      strcpy(UserCommand[CommandNo-1],name);
         sscanf(line, "%*s  %ld %ld %lf",  &_EnergyTuneShift_npoint,
         		&_EnergyTuneShift_nturn, &_EnergyTuneShift_deltamax);
       
-        	EnergyTuneShiftFlag = true;
+        	//EnergyTuneShiftFlag = true;
         
       }
       else if (strcmp("ErrorCouplingFlag", name) == 0){
+      strcpy(UserCommand[CommandNo-1],name);
         sscanf(line, "%*s  %ld %lf",&err_seed,&err_rms);
       
-          ErrorCouplingFlag = true;
+        //  ErrorCouplingFlag = true;
         
       }
         else if (strcmp("ErrorCoupling2Flag", name) == 0){
         sscanf(line, "%*s  %ld %lf",&err_seed,&err_rms);
-      
-          ErrorCoupling2Flag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+        //  ErrorCoupling2Flag = true;
         
       }
       else if (strcmp("CouplingFlag", name) == 0){
-        
-          CouplingFlag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+         // CouplingFlag = true;
         
       }
        else if (strcmp("MomentumAccFlag", name) == 0){
@@ -274,23 +342,23 @@ void read_script(const char *param_file_name, bool rd_lat)
         		&_MomentumAccFlag_deltaminp, &_MomentumAccFlag_deltamaxp, &_MomentumAccFlag_nstepp,
         		&_MomentumAccFlag_deltaminn, &_MomentumAccFlag_deltamaxn, &_MomentumAccFlag_nstepn
         		);
-        
-          MomentumAccFlag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+        //  MomentumAccFlag = true;
          
       }
         else if (strcmp("ReadMultipoleFlag", name) == 0){
-     
-          ReadMultipoleFlag = true;
+            strcpy(UserCommand[CommandNo-1],name);
+        //  ReadMultipoleFlag = true;
         
       }
        else if (strcmp("MultipoleFlag", name) == 0){
-        
-          MultipoleFlag = true;
+         strcpy(UserCommand[CommandNo-1],name);
+          //MultipoleFlag = true;
       
       }
       else if (strcmp("ThinsextFlag", name) == 0){
-       
-          ThinsextFlag = true;
+           strcpy(UserCommand[CommandNo-1],name);
+        //  ThinsextFlag = true;
        
       }
       else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
@@ -305,52 +373,52 @@ void read_script(const char *param_file_name, bool rd_lat)
         sscanf(line, "%*s %s", str);
         sprintf(fic_skew,"%s%s", in_dir, str);
       } // generic one, fit for 1 family of quadrupoles
-         else if (strcmp("FitTuneFlag", name) == 0){
+      else if (strcmp("FitTuneFlag", name) == 0){
         sscanf(line, "%*s %s %s %lf %lf",qf,qd,&targetnux,&targetnuz);
-        
-          FitTuneFlag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+        //  FitTuneFlag = true;
         
       }// fit for 2 families,specific for the soleil lattice in which the quadrupole is cut into 2 parts
        else if (strcmp("FitTune4Flag", name) == 0){
         sscanf(line, "%*s %s %s %s %s %lf %lf",qf1,qf2,qd1,qd2,&targetnux,&targetnuz);
-       
-          FitTune4Flag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+        //  FitTune4Flag = true;
         
       }
        else if (strcmp("FitChromFlag", name) == 0){
         sscanf(line, "%*s  %s %s %lf %lf",sxm1,sxm2,&targetksix,&targetksiz);
-        
-          FitChromFlag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+        //  FitChromFlag = true;
         
       }
       else if (strcmp("GirderErrorFlag", name) == 0){
-       
-          GirderErrorFlag = true;
+       strcpy(UserCommand[CommandNo-1],name);
+         // GirderErrorFlag = true;
        
       }
        else if (strcmp("SigmaFlag", name) == 0){
-        
-          SigmaFlag = true;
+        strcpy(UserCommand[CommandNo-1],name);
+         // SigmaFlag = true;
         
       }
        else if (strcmp("PX2Flag", name) == 0){
-       
-          PX2Flag = true;
+       strcpy(UserCommand[CommandNo-1],name);
+         // PX2Flag = true;
         
       }
        else if (strcmp("InducedAmplitudeFlag", name) == 0){
-       
-          InducedAmplitudeFlag = true;
+       strcpy(UserCommand[CommandNo-1],name);
+        //  InducedAmplitudeFlag = true;
         
       }
        else if (strcmp("CodeComparaisonFlag", name) == 0){
-       
-          CodeComparaisonFlag = true;
+       strcpy(UserCommand[CommandNo-1],name);
+        //  CodeComparaisonFlag = true;
        
       }
        else if (strcmp("EtaFlag", name) == 0){
-       
-          EtaFlag = true;
+       strcpy(UserCommand[CommandNo-1],name);
+         // EtaFlag = true;
         
       }
        else if (strcmp("PhaseSpaceFlag", name) == 0) {
@@ -365,21 +433,22 @@ void read_script(const char *param_file_name, bool rd_lat)
           printf("set boolean flag true or false for PhaseSpaceFlag \n");
           exit_(1);
         }
-        PhaseSpaceFlag = true;
+	strcpy(UserCommand[CommandNo-1],name);
+        //PhaseSpaceFlag = true;
       }
       //calculate Touschek lifetime
        else if (strcmp("TouschekFlag", name) == 0){
-        
+        //strcpy(UserCommand[CommandNo-1],name);
           TouschekFlag = true;
        
       }
        else if (strcmp("IBSFlag", name) == 0){
-       
+       //strcpy(UserCommand[CommandNo-1],name);
           IBSFlag = true;
         
       }
        else if (strcmp("TousTrackFlag", name) == 0){
-       
+      // strcpy(UserCommand[CommandNo-1],name);
           TousTrackFlag = true;
         
       }