Switched to FFTW-3.
[grace.git] / grace_np / test_np.c
blob7d1c90849088964e85bdfd23036434559bd61274
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include "grace_np.h"
6 #ifndef EXIT_SUCCESS
7 # define EXIT_SUCCESS 0
8 #endif
10 #ifndef EXIT_FAILURE
11 # define EXIT_FAILURE -1
12 #endif
14 void my_error_function(const char *msg)
16 fprintf(stderr, "library message : \"%s\"\n", msg);
19 int
20 main (int argc, char* argv[])
22 int i;
24 GraceRegisterErrorFunction (my_error_function);
26 /* Start Grace with a buffer size of 2048 and open the pipe */
27 if (GraceOpen(2048) == -1) {
28 fprintf (stderr, "Can't run Grace. \n");
29 exit (EXIT_FAILURE);
32 /* Send some initialization commands to Grace */
33 GracePrintf ("world xmax 100");
34 GracePrintf ("world ymax 10000");
35 GracePrintf ("xaxis tick major 20");
36 GracePrintf ("xaxis tick minor 10");
37 GracePrintf ("yaxis tick major 2000");
38 GracePrintf ("yaxis tick minor 1000");
39 GracePrintf ("s0 on");
40 GracePrintf ("s0 symbol 1");
41 GracePrintf ("s0 symbol size 0.3");
42 GracePrintf ("s0 symbol fill pattern 1");
43 GracePrintf ("s1 on");
44 GracePrintf ("s1 symbol 1");
45 GracePrintf ("s1 symbol size 0.3");
46 GracePrintf ("s1 symbol fill pattern 1");
48 /* Display sample data */
49 for (i = 1; i <= 100 && GraceIsOpen(); i++) {
50 GracePrintf ("g0.s0 point %d, %d", i, i);
51 GracePrintf ("g0.s1 point %d, %d", i, i * i);
52 /* Update the Grace display after every ten steps */
53 if (i % 10 == 0) {
54 GracePrintf ("redraw");
55 /* Wait a second, just to simulate some time needed for
56 calculations. Your real application shouldn't wait. */
57 sleep (1);
61 if (GraceIsOpen()) {
62 /* Tell Grace to save the data */
63 GracePrintf ("saveall \"sample.agr\"");
65 /* Flush the output buffer and close Grace */
66 GraceClose();
68 /* We are done */
69 exit (EXIT_SUCCESS);
70 } else {
71 exit (EXIT_FAILURE);