Changeset 32 in TRACY3 for trunk/tracy/tracy/src/read_script.cc


Ignore:
Timestamp:
Apr 9, 2014, 3:50:11 PM (10 years ago)
Author:
zhangj
Message:

active the transport of the twiss functions and orbits of the transfer line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tracy/tracy/src/read_script.cc

    r11 r32  
    7878 
    7979 
    80   char    str[max_str]="voidstring", dummy[max_str]="voidstring",dummy2[max_str]="voidstring", nextpara[max_str]="voidpara";
    81   char    in[max_str];  //temporary line with preceding white space
     80  char    str[max_str]="", dummy[max_str]="",dummy2[max_str]="", nextpara[max_str]="";
     81  char    in[max_str]="";  //temporary line with preceding white space
    8282  char    *line = NULL; //line to store the command without preceding white space
    8383  size_t   len = 0;
    8484  ssize_t  read;
    85   char    name[max_str]="voidname";
     85  char    name[max_str]=""; //initialize with empty character array.
    8686 // char    lat_file[max_str]="voidlattice";
    87   char    EndName[]="void";
     87  char    EndName[5]="";
    8888
    8989  FILE    *inf;
     
    9292  long int    NameLen=0L;
    9393  int idummy=0;
    94   char full_param_file_name[max_str];
    95   char lat_FileName[max_str];
     94  char full_param_file_name[max_str]="";
     95  char lat_FileName[max_str]="";
    9696 //bool TuneTracFlag;
    9797  char *pch;
     
    115115     
    116116     LineNum++;
    117      if(prt){
     117     if(!prt){
    118118       printf("Line # %ld \n",LineNum);
    119119       printf("Retrieved line of length %zu : \n",read);
     
    126126    if (strstr(line, "#") == NULL && line[0] != '\n' &&
    127127        line[0] != '\r' && strcmp(line, "\r\n") != 0 ){
     128   
     129       
    128130      // get initial command token
    129131      sscanf(line, "%s", name);
     
    134136      //find the sequence of the bool flag in user input script
    135137      NameLen = strlen(name);
    136       EndName[0] = name[NameLen-4];
    137       EndName[1] = name[NameLen-3];
    138       EndName[2] = name[NameLen-2];
    139       EndName[3] = name[NameLen-1];         
    140      
     138      if(NameLen >= 4 ){
     139        EndName[0] = name[NameLen-4];
     140        EndName[1] = name[NameLen-3];
     141        EndName[2] = name[NameLen-2];
     142        EndName[3] = name[NameLen-1];         
     143      }
    141144      //find the bool flag whose last 4 character are 'Flag'
    142145      if(strcmp(EndName,"Flag")==0)
Note: See TracChangeset for help on using the changeset viewer.