cuikworldaxes.c
Go to the documentation of this file.
1 #include "world.h"
2 #include "error.h"
3 
4 
53 int main(int argc, char **arg)
54 {
55 
56  if (argc>2)
57  {
58  Tworld world;
59  Tparameters parameters;
60 
61  Tbox box;
62  int token;
63  unsigned int nvs;
64 
65  Tfilename faxes;
66  Tfilename fsols;
67  Tfilename fparam;
68 
69  FILE *fin,*fout;
70 
71  CreateFileName(NULL,arg[1],NULL,PARAM_EXT,&fparam);
72  fprintf(stderr,"Reading parameter file : %s\n",GetFileFullName(&fparam));
73  InitParametersFromFile(GetFileFullName(&fparam),&parameters);
74 
75  InitWorldFromFile(&parameters,FALSE,TRUE,arg[1],&world);
76 
77  nvs=GetWorldNumSystemVariables(&world);
78 
79  CreateFileName(NULL,arg[2],NULL,SOL_EXT,&fsols);
80  fprintf(stderr,"Reading solution file : %s\n",GetFileFullName(&fsols));
81  fin=fopen(GetFileFullName(&fsols),"r");
82  if (!fin)
83  Error("The file with the solution boxes can not be opened");
84 
85  CreateFileName(NULL,arg[2],NULL,AXES_EXT,&faxes);
86  fprintf(stderr,"Writing axes file : %s\n",GetFileFullName(&faxes));
87  fout=fopen(GetFileFullName(&faxes),"w");
88  if (!fout)
89  Error("The file for the axes can not be opened");
90 
91  do {
92  token=ReadBox(fin,&box);
93  if (token!=EOF)
94  {
95  if (nvs>GetBoxNIntervals(&box))
96  Error("Box size missmatch");
97  PrintWorldAxes(&parameters,fout,&box,&world);
98  DeleteBox(&box);
99  }
100  } while(token!=EOF);
101 
102  fclose(fin);
103  fclose(fout);
104 
105  DeleteFileName(&faxes);
106  DeleteFileName(&fsols);
107  DeleteFileName(&fparam);
108 
109  DeleteWorld(&world);
110  DeleteParameters(&parameters);
111  }
112  else
113  {
114  fprintf(stdout," Wrong number of parameters.\n");
115  fprintf(stdout," Use:\n");
116  fprintf(stdout," cuikworldaxes <world>.world <solutions>.sol\n");
117  fprintf(stdout," Where:\n");
118  fprintf(stdout," <world>: File describing the problem\n");
119  fprintf(stdout," <solutions>: Solutions for which to extract the axes.\n");
120  fprintf(stdout," File extensions are not required\n");
121  }
122 
123  return(EXIT_SUCCESS);
124 }