/* C Test Code for XGrafix. */ /*Note that SCALAR should be defined as "float" in XGrafix for this test*/ #include #include #include #include #include "../src/xgrafix.h" #define SIZE 21 #define False 0 #define True 1 #define HISTMAX 100 double t; int index_; int nx, ny, nx_irr, ny_irr; float xg[31], yg[31], **zg, **wg, **vg; float yg1[31], yg2[31]; float **x_irr, **y_irr, **z_irr; float dx, dy; int openFlag1, openFlag2, openFlag3, openFlag4; int testInt = 100, oldtestInt; float testFloat = 101.0, oldtestFloat; double testDouble = 102.0, oldtestDouble; char testChar = 'a', oldtestChar; struct data_struct { float x; float y; }; struct data_struct *data_array; void Setup() { int i, j; double r, theta; oldtestInt = testInt; oldtestFloat = testFloat; oldtestDouble = testDouble; oldtestChar = testChar; nx = SIZE; ny = SIZE; dx = 2*M_PI / nx; dy = M_PI / ny; /* The 2-d plot stuff */ for (i = 0; i < nx; i++) { xg[i] = i*dx; yg1[i] = cos(2*i*dy); yg2[i] = 1e3*exp(-i/5.0); } /* The regular 3-d plot stuff */ zg = (float **) malloc(nx * sizeof(float *)); wg = (float **) malloc(nx * sizeof(float *)); vg = (float **) malloc(nx * sizeof(float *)); for (i = 0; i < nx; i++) { zg[i] = (float *) malloc(ny * sizeof(float)); wg[i] = (float *) malloc(ny * sizeof(float)); vg[i] = (float *) malloc(ny * sizeof(float)); for (j = 0; j < ny; j++) { yg[j] = j * dy; zg[i][j] = sin(i*dx)*cos(j*dy); wg[i][j] = 0.25*cos(i*dx); vg[i][j] = 1e3*exp(-i*dx)*cos(0.5*M_PI*j*dy); } } /* the irregular 3-d plot stuff */ nx_irr = 31; ny_irr = 31; x_irr = (float **)malloc((nx_irr+1)*sizeof(float *)); y_irr = (float **)malloc((nx_irr+1)*sizeof(float *)); z_irr = (float **)malloc((nx_irr+1)*sizeof(float *)); for (i=0; i=HISTMAX) index_ -= HISTMAX; /* Test if dynamic variable changing works. */ if (oldtestInt != testInt) { printf("New value of testInt = %d\n", testInt); oldtestInt= testInt; } if (oldtestFloat != testFloat) { printf("New value of testFloat = %f\n",testFloat); oldtestFloat = testFloat; } if (oldtestDouble != testDouble){ printf("New value of testDouble = %f\n",testDouble); oldtestDouble = testDouble; } if (oldtestChar != testChar) { printf("New value of testChar = %c\n", testChar); oldtestChar = testChar; } } void Dump(char *filename) { printf("Dumping to file %s\n",filename); } void Quit() { printf("Quitting\n"); }