Next Previous Contents

3. Getting started

Have a quick look at the test program tracytest.c ( Source):

#include <math.h>

#include "tracy.h"
#include "datatyp.h"
#include "physlib.h"

main() {
  boolean chroma;
  double dP;
  globvalrec globv;
  long lastpos;

  t2init();
  
  fi=fopen("sls.lat","r"); /* open the lattice input file  */
  fo=fopen("sls.out","w"); /* open the lattice output file */

  if (Lattice_Read(&fi, &fo)) { /* read lattice */
    Cell_Init(); /* initialize cell structure */

    getglobv_(&globv);

    /* define x/y aperture limits */
    for (i = 0; i <= globval.Cell_nLoc; i++)
      globv.maxampl[i][0] = globv.maxampl[i][1] = 1e0;

    globv.MatMeth = false; globv.Cavity_on = false;
    globv.radiation = false; globv.emittance = false;
    globv.pathlength = false; globv.CODimax = 15;
    globv.bpm = ElemIndex("mon");

    putglobv_(&globv);

    chroma=true;
    dP=0.0;

    getglobv_(&globv);
    printglob();

    Ring_GetTwiss(chroma, dP); /* get Twiss parameters */

    printglob(); /* print parameter list */
    printlatt(); /* dump linear lattice functions into "linlat.dat" */

    getcod(0.0, &lastpos); /* determine closed orbit */
    printcod(); /* dump closed orbit into "cod.dat" */
  }
}
This C program corresponds to the PASCAL inp file which was interpreted by the PASCAL-S interpreter which was itself written in PASCAL and part of TRACY. The inc files which were included at runtime by the PASCAL-S interpreter have been replaced by C headers. The master header file is tracy.h. It contains all definitions of data structures and routines contained in the TRACY library. As in the case of the PASCAL inc files there are high level header files containing routines which make use of the more basic library functions. physlib.h is a prominent example of such a header file (refer to C_library_header_files for details).


Next Previous Contents