1 /* ResultsAnalise.c */
2 /**********************************************************************************************************
3 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
4
5 Permission is hereby granted, free of gcharge, to any person obtaining a copy of this software and associated
6 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in all copies or substantial portions
11 of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 DEALINGS IN THE SOFTWARE.
18 ************************************************************************************************************/
19
20 #include "../../Config.h"
21 #include <math.h>
22 #include "../Common/Global.h"
23 #include "../Utils/UtilsInterface.h"
24 #include "../Utils/Utils.h"
25 #include "../Utils/Constants.h"
26 #include "../Geometry/ResultsAnalise.h"
27 #include "../Geometry/EnergiesCurves.h"
28 #include "../Common/Run.h"
29 #include "../Display/ViewOrb.h"
30
31 /*********************************************************************/
free_geom_conv(DataGeomConv GeomConv)32 DataGeomConv free_geom_conv(DataGeomConv GeomConv)
33 {
34 gint i,j;
35
36 for(i = 0;i<GeomConv.Ntype;i++)
37 if(GeomConv.TypeData[i])
38 g_free(GeomConv.TypeData[i]);
39
40 if(GeomConv.GeomFile)
41 g_free(GeomConv.GeomFile);
42 GeomConv.GeomFile = NULL;
43 if(GeomConv.TypeData)
44 g_free(GeomConv.TypeData);
45 GeomConv.TypeData = NULL;
46
47 if(GeomConv.TypeCalcul)
48 g_free(GeomConv.TypeCalcul);
49 GeomConv.TypeCalcul = NULL;
50
51 if( GeomConv.Npoint<1)
52 {
53 if(GeomConv.Data)
54 g_free(GeomConv.Data);
55 GeomConv.Data = NULL;
56 if(GeomConv.NumGeom)
57 g_free(GeomConv.NumGeom);
58 GeomConv.NumGeom = NULL;
59 return GeomConv;
60 }
61 for(j = 0;j<GeomConv.Ntype;j++)
62 {
63 if(GeomConv.Data[j])
64 for(i = 0;i<GeomConv.Npoint;i++)
65 if(GeomConv.Data[j][i])
66 g_free(GeomConv.Data[j][i]);
67
68 if(GeomConv.Data[j])
69 g_free(GeomConv.Data[j]);
70
71 GeomConv.Data[j] = NULL;
72 }
73 GeomConv.Npoint = 0;
74 GeomConv.Ntype = 0;
75
76 return GeomConv;
77 }
78 /*********************************************************************/
init_geom_dalton_conv(gchar * namefile)79 DataGeomConv init_geom_dalton_conv(gchar *namefile)
80 {
81 DataGeomConv GeomConv;
82 gint i;
83 GeomConv.Npoint = 0;
84 GeomConv.Ntype = 2;
85 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
86 GeomConv.fileType = GABEDIT_TYPEFILE_DALTON;
87 GeomConv.TypeData[0] = g_strdup(" Energy ");
88 GeomConv.TypeData[1] = g_strdup(" Norm Step ");
89 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
90 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
91 GeomConv.TypeCalcul = NULL;
92 GeomConv.NumGeom = NULL;
93 GeomConv.GeomFile = g_strdup(namefile);
94
95 return GeomConv;
96 }
97 /*********************************************************************/
init_geom_mopac_conv(gchar * namefile)98 DataGeomConv init_geom_mopac_conv(gchar *namefile)
99 {
100 DataGeomConv GeomConv;
101 gint i;
102 GeomConv.Npoint = 0;
103 GeomConv.Ntype = 2;
104 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
105 GeomConv.fileType = GABEDIT_TYPEFILE_MOPAC;
106 GeomConv.TypeData[0] = g_strdup(_(" Energy(KCal/Mol) "));
107 GeomConv.TypeData[1] = g_strdup(_(" Gradient "));
108 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
109 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
110 GeomConv.TypeCalcul = NULL;
111 GeomConv.NumGeom = NULL;
112 GeomConv.GeomFile = g_strdup(namefile);
113
114 return GeomConv;
115 }
116 /*********************************************************************/
find_energy_mopac_aux(gchar * NomFichier)117 gint find_energy_mopac_aux(gchar* NomFichier)
118 {
119 guint i=0;
120 guint j=0;
121 guint k=0;
122 gchar *temp = g_malloc(50*sizeof(gchar));
123 gchar *tmp = g_malloc(50*sizeof(gchar));
124 guint taille=BSIZE;
125 gchar *t;
126 FILE *fd;
127 gint Ncalculs = 0;
128 static DataGeomConv* GeomConv =NULL;
129 gboolean OK;
130
131
132 t=g_malloc(taille);
133 fd = FOpen(NomFichier, "rb");
134 if(!fd)
135 {
136 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
137 Message(t,_("Error"),TRUE);
138 if(t) g_free(t);
139 return -1;
140 }
141
142 OK = TRUE;
143 while(!feof(fd))
144 {
145 { gchar* e = fgets(t,taille,fd);}
146 if(strstr(t,"Geometry optimization") && strstr(t,"#") && Ncalculs <1)
147 {
148 Ncalculs = 1;
149 GeomConv = g_malloc(sizeof(DataGeomConv) );
150 GeomConv[Ncalculs-1] = init_geom_mopac_conv(NomFichier);
151 }
152 if(strstr(t,"Geometry optimization") && strstr(t,"#") )
153 {
154 OK = TRUE;
155 while(!feof(fd) && OK )
156 {
157 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
158 if(strstr(t,"####################################"))
159 {
160 OK = TRUE;
161 break;
162 }
163 }
164 }
165 if(!OK) break;
166 if(Ncalculs>0)
167 {
168
169 OK = TRUE;
170 while(!feof(fd) && OK )
171 {
172 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
173 if(strstr(t,"HEAT_OF_FORM_UPDATED"))
174 {
175 gchar* t1 = strstr(t,"=");
176 gint c;
177 for(c=0;c<strlen(t);c++) if(t[c]=='D'||t[c]=='d')t[c]='e';
178 if(t1) sscanf(t1+1,"%s",tmp); /* energy */
179 else { OK = FALSE; break; }
180 OK = TRUE;
181 break;
182 }
183 }
184 if(!OK) break;
185 OK = TRUE;
186 while(!feof(fd) && OK )
187 {
188 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
189 if(strstr(t,"GRADIENT_UPDATED"))
190 {
191 gchar* t1 = strstr(t,"=");
192 if(t1) sscanf(t1+1,"%s",temp); /* gradient */
193 else { OK = FALSE; break; }
194 OK = TRUE;
195 break;
196 }
197 }
198 if(!OK) break;
199
200 GeomConv[Ncalculs-1].Npoint++;
201 if(GeomConv[Ncalculs-1].Npoint == 1 )
202 {
203 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
204 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
205 }
206 else
207 {
208 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
209 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
210 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
211 }
212 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
213 {
214 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
215 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
216 }
217 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
218 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
219 sprintf(GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1], "%s",tmp);
220 sprintf(GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1], "%s",temp);
221 }
222 }
223 fclose(fd);
224
225 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
226 {
227 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
228 Ncalculs--;
229 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
230 else
231 {
232 g_free(GeomConv);
233 GeomConv = NULL;
234 }
235 }
236 k = 0;
237 for(i=0;(gint)i<Ncalculs;i++)
238 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
239 {
240 k++;
241 GeomConv[i].NumGeom[j] = k;
242 }
243 create_energies_curves(GeomConv,Ncalculs);
244 g_free(t);
245 g_free(temp);
246 g_free(tmp);
247 if( Ncalculs<=0) return 1;
248 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 1) return 1;
249 return 0;
250 }
251 /*********************************************************************/
init_geom_mopac_irc_conv(gchar * namefile)252 DataGeomConv init_geom_mopac_irc_conv(gchar *namefile)
253 {
254 DataGeomConv GeomConv;
255 gint i;
256 GeomConv.Npoint = 0;
257 GeomConv.Ntype = 3;
258 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
259 GeomConv.fileType = GABEDIT_TYPEFILE_MOPAC_IRC;
260 GeomConv.TypeData[0] = g_strdup(" Energy(KCal/Mol) ");
261 GeomConv.TypeData[1] = g_strdup(" Potential");
262 GeomConv.TypeData[2] = g_strdup(" Energy lost");
263 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
264 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
265 GeomConv.TypeCalcul = NULL;
266 GeomConv.NumGeom = NULL;
267 GeomConv.GeomFile = g_strdup(namefile);
268
269 return GeomConv;
270 }
271 /*********************************************************************/
find_energy_mopac_irc_output(gchar * NomFichier)272 void find_energy_mopac_irc_output(gchar* NomFichier)
273 {
274 guint i=0;
275 guint j=0;
276 guint k=0;
277 gchar dum[100];
278 gchar *elost = g_malloc(50*sizeof(gchar));
279 gchar *potential = g_malloc(50*sizeof(gchar));
280 gchar *e = g_malloc(50*sizeof(gchar));
281 guint taille=BSIZE;
282 gchar *t;
283 FILE *fd;
284 gint Ncalculs = 0;
285 static DataGeomConv* GeomConv =NULL;
286 gboolean OK;
287
288
289 t=g_malloc(taille*sizeof(gchar));
290 fd = FOpen(NomFichier, "rb");
291 if(!fd)
292 {
293 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
294 Message(t,_("Error"),TRUE);
295 if(t)
296 g_free(t);
297 return;
298 }
299
300 OK = TRUE;
301 while(!feof(fd))
302 {
303 if(!fgets(t,taille,fd))break;
304 if(strstr(t,"INTRINSIC REACTION COORDINATE") && Ncalculs <1)
305 {
306 Ncalculs = 1;
307 GeomConv = g_malloc(sizeof(DataGeomConv) );
308 GeomConv[Ncalculs-1] = init_geom_mopac_irc_conv(NomFichier);
309 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
310 break;
311 }
312 }
313 if(Ncalculs>0)
314 {
315 OK = TRUE;
316 while(!feof(fd) && OK )
317 {
318 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
319 if(
320 strstr(t,"POTENTIAL") &&
321 strstr(t,"LOST") &&
322 strstr(t,"TOTAL")
323 )
324 {
325 sprintf(elost," ");
326 sprintf(potential," ");
327 sprintf(e," ");
328 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
329 gint c;
330 for(c=0;c<strlen(t);c++) if(t[c]=='D'||t[c]=='d')t[c]='e';
331 if(4!=sscanf(t,"%s %s %s %s",dum,potential,elost,e))
332 { OK = FALSE; break; }
333 }
334 else continue;
335 GeomConv[Ncalculs-1].Npoint++;
336 if(GeomConv[Ncalculs-1].Npoint == 1 )
337 {
338 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
339 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
340 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
341 }
342 else
343 {
344 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
345 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
346 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
347 }
348 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(e);
349 GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(elost);
350 GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(potential);
351 }
352 }
353 fclose(fd);
354
355 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
356 {
357 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
358 Ncalculs--;
359 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
360 else
361 {
362 g_free(GeomConv);
363 GeomConv = NULL;
364 }
365 }
366 k = 0;
367 for(i=0;(gint)i<Ncalculs;i++)
368 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
369 {
370 k++;
371 GeomConv[i].NumGeom[j] = k;
372 }
373 create_energies_curves(GeomConv,Ncalculs);
374 g_free(t);
375 g_free(elost);
376 g_free(potential);
377 g_free(e);
378 }
379 /*********************************************************************/
init_geom_mopac_scan_conv(gchar * namefile)380 DataGeomConv init_geom_mopac_scan_conv(gchar *namefile)
381 {
382 DataGeomConv GeomConv;
383 gint i;
384 GeomConv.Npoint = 0;
385 GeomConv.Ntype = 3;
386 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
387 GeomConv.fileType = GABEDIT_TYPEFILE_MOPAC_SCAN;
388 GeomConv.TypeData[0] = g_strdup(" Energy(KCal/Mol) ");
389 GeomConv.TypeData[1] = g_strdup(" Variable 1");
390 GeomConv.TypeData[2] = g_strdup(" Variable 2");
391 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
392 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
393 GeomConv.TypeCalcul = NULL;
394 GeomConv.NumGeom = NULL;
395 GeomConv.GeomFile = g_strdup(namefile);
396
397 return GeomConv;
398 }
399 /*********************************************************************/
find_energy_mopac_scan_output(gchar * NomFichier)400 void find_energy_mopac_scan_output(gchar* NomFichier)
401 {
402 guint i=0;
403 guint j=0;
404 guint k=0;
405 gchar *var1 = g_malloc(50*sizeof(gchar));
406 gchar *var2 = g_malloc(50*sizeof(gchar));
407 gchar *e = g_malloc(50*sizeof(gchar));
408 guint taille=BSIZE;
409 gchar *t;
410 FILE *fd;
411 gint Ncalculs = 0;
412 static DataGeomConv* GeomConv =NULL;
413 gboolean OK;
414
415
416 t=g_malloc(taille*sizeof(gchar));
417 fd = FOpen(NomFichier, "rb");
418 if(!fd)
419 {
420 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
421 Message(t,_("Error"),TRUE);
422 if(t)
423 g_free(t);
424 return;
425 }
426
427 OK = TRUE;
428 while(!feof(fd))
429 {
430 if(!fgets(t,taille,fd))break;
431 if(strstr(t,"POINT") && (strstr(t,"NUMBER OF POINTS") || strstr(t,"NUMBER OF ROWS")) && Ncalculs <1)
432 {
433 Ncalculs = 1;
434 GeomConv = g_malloc(sizeof(DataGeomConv) );
435 GeomConv[Ncalculs-1] = init_geom_mopac_scan_conv(NomFichier);
436 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
437 break;
438 }
439 }
440 if(Ncalculs>0)
441 {
442 OK = TRUE;
443 while(!feof(fd) && OK )
444 {
445 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
446 if(strstr(t,"VARIABLE")&& strstr(t,"FUNCTION"))
447 {
448 sprintf(var1," ");
449 sprintf(var2," ");
450 sprintf(e," ");
451 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
452 gchar* t1 = strstr(t,":");
453 gint c;
454 for(c=0;c<strlen(t);c++) if(t[c]=='D'||t[c]=='d')t[c]='e';
455 if(t1)
456 {
457 if(3!=sscanf(t1+1,"%s%s%s",var1,var2,e))
458 {
459 sscanf(t1+1,"%s%s",var1,e);
460 sprintf(var2," ");
461 }
462 }
463 else { OK = FALSE; break; }
464 }
465 else continue;
466 GeomConv[Ncalculs-1].Npoint++;
467 if(GeomConv[Ncalculs-1].Npoint == 1 )
468 {
469 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
470 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
471 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
472 }
473 else
474 {
475 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
476 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
477 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
478 }
479 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(e);
480 GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(var1);
481 GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(var2);
482 }
483 }
484 fclose(fd);
485
486 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
487 {
488 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
489 Ncalculs--;
490 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
491 else
492 {
493 g_free(GeomConv);
494 GeomConv = NULL;
495 }
496 }
497 k = 0;
498 for(i=0;(gint)i<Ncalculs;i++)
499 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
500 {
501 k++;
502 GeomConv[i].NumGeom[j] = k;
503 }
504 create_energies_curves(GeomConv,Ncalculs);
505 g_free(t);
506 g_free(var1);
507 g_free(var2);
508 g_free(e);
509 }
510 /*********************************************************************/
init_geom_mpqc_conv(gchar * namefile)511 DataGeomConv init_geom_mpqc_conv(gchar *namefile)
512 {
513 DataGeomConv GeomConv;
514 gint i;
515 GeomConv.Npoint = 0;
516 GeomConv.Ntype = 3;
517 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
518 GeomConv.fileType = GABEDIT_TYPEFILE_MPQC;
519 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
520 GeomConv.TypeData[1] = g_strdup(_(" Max Gradient "));
521 GeomConv.TypeData[2] = g_strdup(_(" Max Displacement "));
522 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
523 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
524 GeomConv.TypeCalcul = NULL;
525 GeomConv.NumGeom = NULL;
526 GeomConv.GeomFile = g_strdup(namefile);
527
528 return GeomConv;
529 }
530 /*********************************************************************/
find_energy_mpqc_output(gchar * NomFichier)531 void find_energy_mpqc_output(gchar* NomFichier)
532 {
533 gchar *pdest;
534 guint i=0;
535 guint j=0;
536 guint k=0;
537 gchar *temp = g_malloc(50*sizeof(gchar));
538 guint taille=BSIZE;
539 gchar *t;
540 FILE *fd;
541 gint Ncalculs = 0;
542 static DataGeomConv* GeomConv =NULL;
543 gboolean newGeom = FALSE;
544 gboolean mp2 = FALSE;
545
546
547 Ncalculs++;
548 GeomConv = g_malloc(sizeof(DataGeomConv) );
549 GeomConv[Ncalculs-1] = init_geom_mpqc_conv(NomFichier);
550
551 t=g_malloc(taille);
552 fd = FOpen(NomFichier, "rb");
553 if(!fd)
554 {
555 g_free(t);
556 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
557 Message(t,_("Error"),TRUE);
558 if(t) g_free(t);
559 return;
560 }
561
562 while(!feof(fd))
563 {
564 pdest = NULL;
565 { gchar* e = fgets(t,taille,fd);}
566 /*
567 if( strlen(t)>2 && strstr(t,"changing atomic coordinates:") )
568 {
569 Ncalculs++;
570 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
571 GeomConv[Ncalculs-1] = init_geom_mpqc_conv(NomFichier);
572 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
573 sscanf(t,"%s",GeomConv[Ncalculs-1].TypeCalcul);
574 }
575 */
576 if(strstr(t,"changing atomic coordinates:"))
577 {
578 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
579 sscanf(t,"%s",GeomConv[Ncalculs-1].TypeCalcul);
580 newGeom = TRUE;
581 if(strstr(t,"MBPT2")) mp2 = TRUE;
582 }
583
584 if(newGeom && mp2)
585 {
586 pdest = NULL;
587 pdest = strstr( t,"MP2");
588 if(pdest)
589 {
590 if(strstr(t,"correlation")) pdest = NULL;
591 else pdest = strstr( t,"energy");
592 if( pdest != NULL ) pdest = strstr( t,":");
593 }
594 }
595 if(newGeom && !mp2)
596 {
597 pdest = NULL;
598 pdest = strstr( t,"total scf energy");
599 if( pdest != NULL ) pdest = strstr( t,"=");
600 }
601
602 if( pdest != NULL )
603 {
604 pdest++;
605 GeomConv[Ncalculs-1].Npoint++;
606 if(GeomConv[Ncalculs-1].Npoint == 1 )
607 {
608 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
609 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
610 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
611 }
612 else
613 {
614 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
615 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
616 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
617 }
618 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
619 {
620 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
621 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
622 }
623 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
624 sscanf(pdest,"%s", GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
625 }
626
627 pdest = NULL;
628 pdest = strstr( t,"Max Gradient");
629 if( pdest != NULL && GeomConv[Ncalculs-1].Npoint>0)
630 {
631 pdest = strstr( t,":");
632 if(pdest)
633 {
634 pdest++;
635 sscanf(pdest,"%s",GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1]);
636 }
637 }
638 pdest = strstr( t,"Max Displacement");
639 if( pdest != NULL && GeomConv[Ncalculs-1].Npoint>0)
640 {
641 pdest = strstr( t,":");
642 if(pdest)
643 {
644 pdest++;
645 sscanf(pdest,"%s",GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1]);
646 }
647 }
648 }
649
650 fclose(fd);
651
652 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
653 {
654 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
655 Ncalculs--;
656 if(Ncalculs>0)
657 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
658 else
659 {
660 g_free(GeomConv);
661 GeomConv = NULL;
662 }
663 }
664
665 /*
666 printf("Npoint = %d\n ",GeomConv[Ncalculs-1].Npoint);
667 printf("TypeCalcul = %s\n ",GeomConv[Ncalculs-1].TypeCalcul);
668 for(i=0;i<GeomConv[Ncalculs-1].Npoint;i++)
669 {
670 for(j=0;j<GeomConv[Ncalculs-1].Ntype;j++)
671 printf("%s ",GeomConv[Ncalculs-1].Data[j][i]);
672 printf("\n ");
673
674 }
675 */
676
677 k = 0;
678 for(i=0;(gint)i<Ncalculs;i++)
679 {
680 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
681 {
682 k++;
683 GeomConv[i].NumGeom[j] = k;
684 }
685 k++;
686 }
687 create_energies_curves(GeomConv,Ncalculs);
688 g_free(t);
689 g_free(temp);
690 }
691 /*********************************************************************/
init_geom_xyz_conv(gchar * namefile)692 DataGeomConv init_geom_xyz_conv(gchar *namefile)
693 {
694 DataGeomConv GeomConv;
695 GeomConv.Npoint = 0;
696 GeomConv.Ntype = 1;
697 GeomConv.fileType = GABEDIT_TYPEFILE_XYZ;
698 GeomConv.TypeCalcul = g_strdup(_("Geometries for an xyz file"));
699 GeomConv.NumGeom = NULL;
700 GeomConv.GeomFile = g_strdup(namefile);
701 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
702 GeomConv.TypeData[0] = g_strdup(_(" Geometry number "));
703 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
704 GeomConv.Data[0] = NULL;
705 return GeomConv;
706 }
707 /*********************************************************************/
find_energy_xyz(gchar * fileName)708 static void find_energy_xyz(gchar* fileName)
709 {
710 gint i=0;
711 gint j=0;
712 guint taille=BSIZE;
713 gchar t[BSIZE];
714 FILE *file;
715 gint Ncalculs = 0;
716 static DataGeomConv* GeomConv =NULL;
717 gint ne;
718 gint nAtoms;
719
720 GeomConv = NULL;
721
722 file = FOpen(fileName, "rb");
723 if(!file)
724 {
725 sprintf(t,_(" Error : I can not open file %s\n"),fileName);
726 Message(t,_("Error"),TRUE);
727 return;
728 }
729
730 while(!feof(file))
731 {
732 if(!fgets(t,taille,file))break;
733 ne = sscanf(t,"%d",&nAtoms);
734 if(ne==1 && nAtoms>0)
735 {
736 if(Ncalculs==0)
737 {
738 Ncalculs = 1;
739 GeomConv = g_malloc(sizeof(DataGeomConv) );
740 GeomConv[0] = init_geom_xyz_conv(fileName);
741 }
742 if(!fgets(t,taille,file)) break; /* title */
743 GeomConv[0].Npoint++;
744 for(i=0;i<nAtoms;i++)
745 if(!fgets(t,taille,file))break;
746 }
747 else
748 break;
749 }
750
751 fclose(file);
752
753 if(GeomConv)
754 {
755 if(GeomConv[0].Npoint == 0)
756 {
757 GeomConv[0] = free_geom_conv(GeomConv[0]);
758 g_free(GeomConv);
759 GeomConv = NULL;
760 Ncalculs = 0;
761 }
762 else
763 {
764 GeomConv[0].NumGeom = g_malloc(GeomConv[0].Npoint*sizeof(gint));
765 GeomConv[0].Data[0] = g_malloc(GeomConv[0].Npoint*sizeof(gchar*));
766 for(j=0;(gint)j<GeomConv[0].Npoint;j++)
767 {
768 GeomConv[0].NumGeom[j] = j+1;
769 GeomConv[0].Data[0][j] = g_strdup_printf("%d",j+1);
770 }
771 }
772 }
773 create_energies_curves(GeomConv,Ncalculs);
774 }
775 /*********************************************************************/
init_geom_gauss_conv(gchar * namefile)776 DataGeomConv init_geom_gauss_conv(gchar *namefile)
777 {
778 DataGeomConv GeomConv;
779 gint i;
780 GeomConv.Npoint = 0;
781 GeomConv.Ntype = 5;
782 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
783 GeomConv.fileType = GABEDIT_TYPEFILE_GAUSSIAN;
784 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
785 GeomConv.TypeData[1] = g_strdup(_(" Force Max "));
786 GeomConv.TypeData[2] = g_strdup(_(" Force RMS "));
787 GeomConv.TypeData[3] = g_strdup(_(" Dep. Max "));
788 GeomConv.TypeData[4] = g_strdup(_(" Dep. RMS "));
789 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
790 for(i = 0;i<GeomConv.Ntype;i++)
791 GeomConv.Data[i] = NULL;
792 GeomConv.TypeCalcul = NULL;
793 GeomConv.NumGeom = NULL;
794 GeomConv.GeomFile = g_strdup(namefile);
795
796 return GeomConv;
797 }
798 /*********************************************************************/
init_geom_molpro_conv(gchar * namefile)799 DataGeomConv init_geom_molpro_conv(gchar* namefile)
800 {
801 DataGeomConv GeomConv;
802 gint i;
803 GeomConv.Npoint = 0;
804 GeomConv.Ntype = 2;
805 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
806 GeomConv.fileType = GABEDIT_TYPEFILE_MOLPRO;
807 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
808 GeomConv.TypeData[1] = g_strdup(_(" Convergence "));
809 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
810 for(i = 0;i<GeomConv.Ntype;i++)
811 GeomConv.Data[i] = NULL;
812 GeomConv.TypeCalcul = NULL;
813 GeomConv.NumGeom = NULL;
814 GeomConv.GeomFile = g_strdup(namefile);
815 return GeomConv;
816 }
817 /*********************************************************************/
find_energy_dalton_output(gchar * NomFichier)818 void find_energy_dalton_output(gchar* NomFichier)
819 {
820 guint i=0;
821 guint j=0;
822 guint k=0;
823 gchar *temp = g_malloc(50*sizeof(gchar));
824 gchar *tmp = g_malloc(50*sizeof(gchar));
825 guint taille=BSIZE;
826 gchar *t;
827 FILE *fd;
828 gint Ncalculs = 0;
829 static DataGeomConv* GeomConv =NULL;
830 gboolean OK;
831
832
833 t=g_malloc(taille);
834 fd = FOpen(NomFichier, "rb");
835 if(!fd)
836 {
837 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
838 Message(t,_("Error"),TRUE);
839 if(t)
840 g_free(t);
841 return;
842 }
843
844 while(!feof(fd))
845 {
846 { gchar* e = fgets(t,taille,fd);}
847 if(strstr(t,"Optimization Control Center") && Ncalculs <1)
848 {
849 Ncalculs = 1;
850 GeomConv = g_malloc(sizeof(DataGeomConv) );
851 GeomConv[Ncalculs-1] = init_geom_dalton_conv(NomFichier);
852 }
853 if(strstr(t,"Optimization Control Center") )
854 {
855 OK = TRUE;
856 while(!feof(fd) && OK )
857 {
858 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
859 if(strstr(t,"Next geometry") || strstr(t,"Final geometry"))
860 {
861 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
862 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
863 OK = TRUE;
864 break;
865 }
866 }
867 if(!OK) break;
868
869 OK = TRUE;
870 while(!feof(fd) && OK )
871 {
872 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
873 if(strstr(t,"Energy at this geometry is"))
874 {
875 gchar* t1 = strstr(t,":");
876 if(t1) sscanf(t1+1,"%s",tmp); /* energy */
877 else { OK = FALSE; break; }
878 OK = TRUE;
879 break;
880 }
881 }
882 if(!OK) break;
883 OK = TRUE;
884 while(!feof(fd) && OK )
885 {
886 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
887 if(strstr(t,"Norm of step"))
888 {
889 gchar* t1 = strstr(t,":");
890 if(t1) sscanf(t1+1,"%s",temp); /* rmsStep */
891 else { OK = FALSE; break; }
892 OK = TRUE;
893 break;
894 }
895 }
896 if(!OK) break;
897
898 GeomConv[Ncalculs-1].Npoint++;
899 if(GeomConv[Ncalculs-1].Npoint == 1 )
900 {
901 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
902 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
903 }
904 else
905 {
906 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
907 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
908 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
909 }
910 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
911 {
912 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
913 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
914 }
915 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
916 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
917 sprintf(GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1], "%s", tmp);
918 sprintf(GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1], "%s", temp);
919 }
920 }
921 fclose(fd);
922
923 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
924 {
925 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
926 Ncalculs--;
927 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
928 else
929 {
930 g_free(GeomConv);
931 GeomConv = NULL;
932 }
933 }
934 k = 0;
935 for(i=0;(gint)i<Ncalculs;i++)
936 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
937 {
938 k++;
939 GeomConv[i].NumGeom[j] = k;
940 }
941 create_energies_curves(GeomConv,Ncalculs);
942 g_free(t);
943 g_free(temp);
944 g_free(tmp);
945 }
946 /*********************************************************************/
init_geom_gamess_conv(gchar * namefile)947 DataGeomConv init_geom_gamess_conv(gchar *namefile)
948 {
949 DataGeomConv GeomConv;
950 gint i;
951 GeomConv.Npoint = 0;
952 GeomConv.Ntype = 3;
953 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
954 GeomConv.fileType = GABEDIT_TYPEFILE_GAMESS;
955 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
956 GeomConv.TypeData[1] = g_strdup(_(" MAX Gradient "));
957 GeomConv.TypeData[2] = g_strdup(_(" RMS Gradient "));
958 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
959 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
960 GeomConv.TypeCalcul = NULL;
961 GeomConv.NumGeom = NULL;
962 GeomConv.GeomFile = g_strdup(namefile);
963
964 return GeomConv;
965 }
966 /*********************************************************************/
find_energy_gamess_output(gchar * NomFichier)967 void find_energy_gamess_output(gchar* NomFichier)
968 {
969 guint i=0;
970 guint j=0;
971 guint k=0;
972 gchar *maxgrad = g_malloc(50*sizeof(gchar));
973 gchar *rmsgrad = g_malloc(50*sizeof(gchar));
974 gchar *tmp = g_malloc(50*sizeof(gchar));
975 guint taille=BSIZE;
976 gchar *t;
977 FILE *fd;
978 gint Ncalculs = 0;
979 static DataGeomConv* GeomConv =NULL;
980 gboolean OK;
981
982
983 t=g_malloc(taille);
984 fd = FOpen(NomFichier, "rb");
985 if(!fd)
986 {
987 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
988 Message(t,_("Error"),TRUE);
989 if(t)
990 g_free(t);
991 return;
992 }
993
994 while(!feof(fd))
995 {
996 { gchar* e = fgets(t,taille,fd);}
997 if(strstr(t,"NSERCH= 0") && Ncalculs <1)
998 {
999 Ncalculs = 1;
1000 GeomConv = g_malloc(sizeof(DataGeomConv) );
1001 GeomConv[Ncalculs-1] = init_geom_gamess_conv(NomFichier);
1002 }
1003 if(strstr(t,"COORDINATES OF ALL ATOMS ARE (ANGS)") )
1004 {
1005 OK = TRUE;
1006 while(!feof(fd) && OK )
1007 {
1008 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
1009 if(strstr(t,"NSERCH") && strstr(t,"ENERGY="))
1010 {
1011 gchar* t1 = strstr(t,"ENERGY=");
1012 if(t1) sscanf(t1+7,"%s",tmp); /* energy */
1013 else { OK = FALSE; break; }
1014 OK = TRUE;
1015 break;
1016 }
1017 }
1018 if(!OK) break;
1019 OK = TRUE;
1020 while(!feof(fd) && OK )
1021 {
1022 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
1023 if(strstr(t,"MAXIMUM GRADIENT =")&& strstr(t,"RMS GRADIENT ="))
1024 {
1025 gchar* t1 = strstr(t,"MAXIMUM GRADIENT =");
1026 if(t1) sscanf(t1+19,"%s",maxgrad); /* maxGrad */
1027 else { OK = FALSE; break; }
1028 t1 = strstr(t,"RMS GRADIENT =");
1029 if(t1) sscanf(t1+15,"%s",rmsgrad); /* rmsGrad */
1030 else { OK = FALSE; break; }
1031 OK = TRUE;
1032 break;
1033 }
1034 }
1035 if(!OK) break;
1036
1037 GeomConv[Ncalculs-1].Npoint++;
1038 if(GeomConv[Ncalculs-1].Npoint == 1 )
1039 {
1040 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1041 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1042 }
1043 else
1044 {
1045 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1046 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1047 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1048 }
1049 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1050 {
1051 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1052 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1053 }
1054 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1055 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
1056 sprintf(GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1], "%s", tmp);
1057 sprintf(GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1], "%s", maxgrad);
1058 sprintf(GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1], "%s", rmsgrad);
1059 }
1060 }
1061 fclose(fd);
1062
1063 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1064 {
1065 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1066 Ncalculs--;
1067 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1068 else
1069 {
1070 g_free(GeomConv);
1071 GeomConv = NULL;
1072 }
1073 }
1074 k = 0;
1075 for(i=0;(gint)i<Ncalculs;i++)
1076 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1077 {
1078 k++;
1079 GeomConv[i].NumGeom[j] = k+1;
1080 }
1081 create_energies_curves(GeomConv,Ncalculs);
1082 g_free(t);
1083 g_free(tmp);
1084 g_free(maxgrad);
1085 g_free(rmsgrad);
1086 }
1087 /*********************************************************************/
find_energy_gamess_output_heat(gchar * NomFichier)1088 void find_energy_gamess_output_heat(gchar* NomFichier)
1089 {
1090 guint i=0;
1091 guint j=0;
1092 guint k=0;
1093 gchar *maxgrad = g_malloc(50*sizeof(gchar));
1094 gchar *rmsgrad = g_malloc(50*sizeof(gchar));
1095 gchar *tmp = g_malloc(50*sizeof(gchar));
1096 guint taille=BSIZE;
1097 gchar *t;
1098 FILE *fd;
1099 gint Ncalculs = 0;
1100 static DataGeomConv* GeomConv =NULL;
1101 gboolean OK;
1102 gchar* myStr = "HEAT OF FORMATION IS";
1103 gint lmyStr = strlen(myStr);
1104
1105
1106 t=g_malloc(taille);
1107 fd = FOpen(NomFichier, "rb");
1108 if(!fd)
1109 {
1110 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1111 Message(t,_("Error"),TRUE);
1112 if(t)
1113 g_free(t);
1114 return;
1115 }
1116
1117 while(!feof(fd))
1118 {
1119 { gchar* e = fgets(t,taille,fd);}
1120 if(strstr(t,"NSERCH= 0") && Ncalculs <1)
1121 {
1122 Ncalculs = 1;
1123 GeomConv = g_malloc(sizeof(DataGeomConv) );
1124 GeomConv[Ncalculs-1] = init_geom_gamess_conv(NomFichier);
1125 }
1126 if(strstr(t,"COORDINATES OF ALL ATOMS ARE (ANGS)") )
1127 {
1128 OK = TRUE;
1129 while(!feof(fd) && OK )
1130 {
1131 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
1132 if(strstr(t,myStr))
1133 {
1134 gchar* t1 = strstr(t,myStr);
1135 if(t1) sscanf(t1+lmyStr,"%s",tmp); /* energy */
1136 else { OK = FALSE; break; }
1137 OK = TRUE;
1138 break;
1139 }
1140 }
1141 if(!OK) break;
1142 OK = TRUE;
1143 while(!feof(fd) && OK )
1144 {
1145 if(!fgets(t, BSIZE,fd)) { OK = FALSE; break; }
1146 if(strstr(t,"MAXIMUM GRADIENT =")&& strstr(t,"RMS GRADIENT ="))
1147 {
1148 gchar* t1 = strstr(t,"MAXIMUM GRADIENT =");
1149 if(t1) sscanf(t1+19,"%s",maxgrad); /* maxGrad */
1150 else { OK = FALSE; break; }
1151 t1 = strstr(t,"RMS GRADIENT =");
1152 if(t1) sscanf(t1+15,"%s",rmsgrad); /* rmsGrad */
1153 else { OK = FALSE; break; }
1154 OK = TRUE;
1155 break;
1156 }
1157 }
1158 if(!OK) break;
1159
1160 GeomConv[Ncalculs-1].Npoint++;
1161 if(GeomConv[Ncalculs-1].Npoint == 1 )
1162 {
1163 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1164 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1165 }
1166 else
1167 {
1168 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1169 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1170 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1171 }
1172 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1173 {
1174 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1175 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1176 }
1177 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1178 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
1179 sprintf(GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1], "%s", tmp);
1180 sprintf(GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1], "%s", maxgrad);
1181 sprintf(GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1], "%s", rmsgrad);
1182 }
1183 }
1184 fclose(fd);
1185
1186 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1187 {
1188 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1189 Ncalculs--;
1190 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1191 else
1192 {
1193 g_free(GeomConv);
1194 GeomConv = NULL;
1195 }
1196 }
1197 k = 0;
1198 for(i=0;(gint)i<Ncalculs;i++)
1199 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1200 {
1201 k++;
1202 GeomConv[i].NumGeom[j] = k+1;
1203 }
1204 create_energies_curves(GeomConv,Ncalculs);
1205 g_free(t);
1206 g_free(tmp);
1207 g_free(maxgrad);
1208 g_free(rmsgrad);
1209 }
1210 /*********************************************************************/
init_geom_gamess_irc(gchar * namefile)1211 DataGeomConv init_geom_gamess_irc(gchar *namefile)
1212 {
1213 DataGeomConv GeomConv;
1214 gint i;
1215 GeomConv.Npoint = 0;
1216 GeomConv.Ntype = 1;
1217 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1218 GeomConv.fileType = GABEDIT_TYPEFILE_GAMESSIRC;
1219 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1220 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1221 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
1222 GeomConv.TypeCalcul = NULL;
1223 GeomConv.NumGeom = NULL;
1224 GeomConv.GeomFile = g_strdup(namefile);
1225
1226 return GeomConv;
1227 }
1228 /*********************************************************************/
find_energy_gamess_irc(gchar * NomFichier)1229 void find_energy_gamess_irc(gchar* NomFichier)
1230 {
1231 guint i=0;
1232 guint j=0;
1233 guint k=0;
1234 gchar *tmp = g_malloc(50*sizeof(gchar));
1235 guint taille=BSIZE;
1236 gchar *t;
1237 FILE *fd;
1238 gint Ncalculs = 0;
1239 static DataGeomConv* GeomConv =NULL;
1240
1241
1242 t=g_malloc(taille*sizeof(gchar));
1243 fd = FOpen(NomFichier, "rb");
1244 if(!fd)
1245 {
1246 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1247 Message(t,_("Error"),TRUE);
1248 if(t)
1249 g_free(t);
1250 return;
1251 }
1252
1253 while(!feof(fd))
1254 {
1255 if(!fgets(t,taille,fd))break;
1256 if(strstr(t,"POINT=") && Ncalculs <1)
1257 {
1258 Ncalculs = 1;
1259 GeomConv = g_malloc(sizeof(DataGeomConv) );
1260 GeomConv[Ncalculs-1] = init_geom_gamess_irc(NomFichier);
1261 }
1262 if(strstr(t,"POINT=") && strstr(t,"E=") )
1263 {
1264 gchar* t1 = strstr(t,"E=");
1265 sscanf(t1+2,"%s",tmp); /* energy */
1266 }
1267 else continue;
1268
1269 GeomConv[Ncalculs-1].Npoint++;
1270 if(GeomConv[Ncalculs-1].Npoint == 1 )
1271 {
1272 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1273 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1274 }
1275 else
1276 {
1277 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1278 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1279 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1280 }
1281 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1282 {
1283 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1284 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1285 }
1286 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1287 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
1288 sprintf(GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1], "%s", tmp);
1289 }
1290 fclose(fd);
1291
1292 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1293 {
1294 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1295 Ncalculs--;
1296 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1297 else
1298 {
1299 g_free(GeomConv);
1300 GeomConv = NULL;
1301 }
1302 }
1303 k = 0;
1304 for(i=0;(gint)i<Ncalculs;i++)
1305 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1306 {
1307 k++;
1308 GeomConv[i].NumGeom[j] = k;
1309 }
1310 create_energies_curves(GeomConv,Ncalculs);
1311 g_free(t);
1312 g_free(tmp);
1313 }
1314 /*********************************************************************/
find_energy_gauss_standard_output(gchar * NomFichier)1315 void find_energy_gauss_standard_output(gchar* NomFichier)
1316 {
1317 gchar* pdest = NULL;
1318 guint i=0;
1319 guint j=0;
1320 guint k=0;
1321 gchar *temp = g_malloc(50*sizeof(gchar));
1322 guint taille=BSIZE;
1323 gchar *t;
1324 FILE *fd;
1325 gint Ncalculs = 0;
1326 static DataGeomConv* GeomConv =NULL;
1327
1328
1329 Ncalculs++;
1330 /*
1331 if(GeomConv)
1332 *GeomConv = free_geom_conv(*GeomConv);
1333 else
1334 */
1335 GeomConv = g_malloc(sizeof(DataGeomConv) );
1336
1337 GeomConv[Ncalculs-1] = init_geom_gauss_conv(NomFichier);
1338
1339 t=g_malloc(taille);
1340 fd = FOpen(NomFichier, "rb");
1341 if(!fd)
1342 {
1343 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1344 Message(t,_("Error"),TRUE);
1345 if(t)
1346 g_free(t);
1347 return;
1348 }
1349
1350 while(!feof(fd))
1351 {
1352 { gchar* e = fgets(t,taille,fd);}
1353 if( strlen(t)>2 && strstr(t,"Normal termination of Gaussian") )
1354 {
1355 Ncalculs++;
1356 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1357 GeomConv[Ncalculs-1] = init_geom_gauss_conv(NomFichier);
1358 }
1359 uppercase(t);
1360 if( strlen(t)>2 && t[1] == '#' && !GeomConv[Ncalculs-1].TypeCalcul)
1361 {
1362 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
1363 sscanf(t,"%s %s", temp, GeomConv[Ncalculs-1].TypeCalcul);
1364 }
1365 pdest = strstr( t,"SCF DONE");
1366 if( pdest != NULL )
1367 {
1368 pdest = strstr( t,"=");
1369 }
1370 if(!pdest)
1371 {
1372 pdest = strstr( t,"ENERGY=");
1373 if(pdest && t[1] == 'E' )
1374 pdest = strstr( t,"=");
1375 else
1376 pdest = NULL;
1377
1378 }
1379
1380 if( pdest != NULL )
1381 {
1382 pdest++;
1383 GeomConv[Ncalculs-1].Npoint++;
1384 if(GeomConv[Ncalculs-1].Npoint == 1 )
1385 {
1386 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1387 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1388 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1389 }
1390 else
1391 {
1392 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1393 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1394 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1395 }
1396 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1397 {
1398 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1399 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1400 }
1401 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1402 sscanf(pdest,"%s", GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
1403 }
1404
1405 pdest = NULL;
1406 pdest = strstr( t,"CONVERGED?");
1407 if( pdest != NULL && GeomConv[Ncalculs-1].Npoint>0)
1408 {
1409 for(i=1;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1410 {
1411 { gchar* e = fgets(t,taille,fd);}
1412 sscanf(t,"%s %s %s", temp,temp,GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1]);
1413 }
1414 }
1415 }
1416
1417 fclose(fd);
1418
1419 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1420 {
1421 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1422 Ncalculs--;
1423 if(Ncalculs>0)
1424 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1425 else
1426 {
1427 g_free(GeomConv);
1428 GeomConv = NULL;
1429 }
1430 }
1431 /*
1432 printf("Npoint = %d\n ",GeomConv[Ncalculs-1].Npoint);
1433 printf("TypeCalcul = %s\n ",GeomConv[Ncalculs-1].TypeCalcul);
1434 for(i=0;i<GeomConv[Ncalculs-1].Npoint;i++)
1435 {
1436 for(j=0;j<GeomConv[Ncalculs-1].Ntype;j++)
1437 printf("%s ",GeomConv[Ncalculs-1].Data[j][i]);
1438 printf("\n ");
1439
1440 }
1441 */
1442 k = 0;
1443 for(i=0;(gint)i<Ncalculs;i++)
1444 {
1445 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1446 {
1447 k++;
1448 GeomConv[i].NumGeom[j] = k;
1449 }
1450 k++;
1451 }
1452 create_energies_curves(GeomConv,Ncalculs);
1453 g_free(t);
1454 g_free(temp);
1455 }
1456 /*********************************************************************/
init_geom_qchem_conv(gchar * namefile)1457 DataGeomConv init_geom_qchem_conv(gchar* namefile)
1458 {
1459 DataGeomConv GeomConv;
1460 gint i;
1461 GeomConv.Npoint = 0;
1462 GeomConv.Ntype = 3;
1463 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1464 GeomConv.fileType = GABEDIT_TYPEFILE_QCHEM;
1465
1466 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1467 GeomConv.TypeData[1] = g_strdup(_(" Gradient Max "));
1468 GeomConv.TypeData[2] = g_strdup(_(" Dep. Max "));
1469
1470 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1471 for(i = 0;i<GeomConv.Ntype;i++)
1472 GeomConv.Data[i] = NULL;
1473 GeomConv.TypeCalcul = NULL;
1474 GeomConv.NumGeom = NULL;
1475 GeomConv.GeomFile = g_strdup(namefile);
1476 return GeomConv;
1477 }
1478 /*********************************************************************/
init_geom_orca_conv(gchar * namefile)1479 DataGeomConv init_geom_orca_conv(gchar* namefile)
1480 {
1481 DataGeomConv GeomConv;
1482 gint i;
1483 GeomConv.Npoint = 0;
1484 GeomConv.Ntype = 3;
1485 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1486 GeomConv.fileType = GABEDIT_TYPEFILE_ORCA;
1487
1488 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1489 GeomConv.TypeData[1] = g_strdup(_(" RMS Gradient"));
1490 GeomConv.TypeData[2] = g_strdup(_(" MAX Gradient "));
1491
1492 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1493 for(i = 0;i<GeomConv.Ntype;i++)
1494 GeomConv.Data[i] = NULL;
1495 GeomConv.TypeCalcul = NULL;
1496 GeomConv.NumGeom = NULL;
1497 GeomConv.GeomFile = g_strdup(namefile);
1498 return GeomConv;
1499 }
1500 /*********************************************************************/
find_energy_orca_output(gchar * NomFichier)1501 void find_energy_orca_output(gchar* NomFichier)
1502 {
1503 gchar *pdest;
1504 guint i=0;
1505 guint j=0;
1506 guint k=0;
1507 gchar *temp = g_malloc(50*sizeof(gchar));
1508 guint taille=BSIZE;
1509 gchar *t;
1510 FILE *fd;
1511 gint Ncalculs = 0;
1512 static DataGeomConv* GeomConv =NULL;
1513 gboolean Ok = FALSE;
1514
1515
1516 t=g_malloc(taille*sizeof(gchar));
1517 fd = FOpen(NomFichier, "rb");
1518 if(!fd)
1519 {
1520 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1521 Message(t,_("Error"),TRUE);
1522 if(t) g_free(t);
1523 return;
1524 }
1525
1526 while(!feof(fd))
1527 {
1528 { gchar* e = fgets(t,taille,fd);}
1529 if(strstr(t,"ORCA OPTIMIZATION COORDINATE SETUP") )
1530 {
1531 Ncalculs++;
1532 if(Ncalculs == 1)
1533 GeomConv = g_malloc(sizeof(DataGeomConv) );
1534 else
1535 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1536 GeomConv[Ncalculs-1] = init_geom_orca_conv(NomFichier);
1537 }
1538 pdest = strstr( t,"GEOMETRY OPTIMIZATION CYCLE");
1539
1540 if( pdest != NULL && Ncalculs>0)
1541 {
1542 GeomConv[Ncalculs-1].Npoint++;
1543 if(GeomConv[Ncalculs-1].Npoint == 1 )
1544 {
1545 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1546 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1547 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1548 }
1549 else
1550 {
1551 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1552 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1553 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1554 }
1555 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1556 {
1557 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1558 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1559 }
1560
1561 Ok = TRUE;
1562 while(!feof(fd) && Ok )
1563 {
1564 if(!fgets(t,taille,fd))
1565 {
1566 Ok = FALSE;
1567 break;
1568 }
1569 else
1570 {
1571 if(strstr(t,"FINAL SINGLE POINT ENERGY"))
1572 {
1573 Ok = TRUE;
1574 break;
1575 }
1576
1577 }
1578 }
1579 if(!Ok) break;
1580 sscanf(t,"%s %s %s %s %s",temp,temp,temp,temp,GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
1581 uppercase(t);
1582 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
1583 do
1584 {
1585 if(!fgets(t,taille,fd))break;
1586 }while(strstr(t,"RMS gradient")==NULL && !feof(fd) ) ;
1587 if(strstr(t,"RMS gradient")!=NULL)
1588 {
1589 sscanf(t,"%s %s %s %s", temp,temp,temp,GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1]);
1590 if(!fgets(t,taille,fd))break;
1591 sscanf(t,"%s %s %s %s", temp,temp,temp,GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1]);
1592 }
1593 }
1594 }
1595
1596 fclose(fd);
1597
1598 if(!Ok && GeomConv && GeomConv[Ncalculs-1].Npoint>0) GeomConv[Ncalculs-1].Npoint--;
1599 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1600 {
1601 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1602 Ncalculs--;
1603 if(Ncalculs>0)
1604 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1605 else
1606 {
1607 g_free(GeomConv);
1608 GeomConv = NULL;
1609 }
1610 }
1611 k = 0;
1612 for(i=0;(gint)i<Ncalculs;i++)
1613 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1614 {
1615 k++;
1616 GeomConv[i].NumGeom[j] = k;
1617 }
1618 create_energies_curves(GeomConv,Ncalculs);
1619 g_free(t);
1620 g_free(temp);
1621 }
1622 /*********************************************************************/
init_geom_vasp_conv_outcar(gchar * namefile)1623 DataGeomConv init_geom_vasp_conv_outcar(gchar* namefile)
1624 {
1625 DataGeomConv GeomConv;
1626 gint i;
1627 GeomConv.Npoint = 0;
1628 GeomConv.Ntype = 4;
1629 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1630 GeomConv.fileType = GABEDIT_TYPEFILE_VASPOUTCAR;
1631
1632 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1633 GeomConv.TypeData[1] = g_strdup(_(" dX "));
1634 GeomConv.TypeData[2] = g_strdup(_(" dY "));
1635 GeomConv.TypeData[3] = g_strdup(_(" dZ "));
1636
1637 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1638 for(i = 0;i<GeomConv.Ntype;i++)
1639 GeomConv.Data[i] = NULL;
1640 GeomConv.TypeCalcul = NULL;
1641 GeomConv.NumGeom = NULL;
1642 GeomConv.GeomFile = g_strdup(namefile);
1643 return GeomConv;
1644 }
1645 /*********************************************************************/
find_energy_vasp_outcar(gchar * NomFichier)1646 void find_energy_vasp_outcar(gchar* NomFichier)
1647 {
1648 gchar *pdest;
1649 guint i=0;
1650 guint j=0;
1651 guint k=0;
1652 gchar *temp = g_malloc(50*sizeof(gchar));
1653 gchar *temp1 = g_malloc(50*sizeof(gchar));
1654 gchar *temp2 = g_malloc(50*sizeof(gchar));
1655 guint taille=BSIZE;
1656 gchar* tag = "energy without entropy=";
1657 gchar *t;
1658 FILE *fd;
1659 gint Ncalculs = 0;
1660 static DataGeomConv* GeomConv =NULL;
1661 gboolean Ok = FALSE;
1662
1663
1664 t=g_malloc(taille*sizeof(gchar));
1665 fd = FOpen(NomFichier, "rb");
1666 if(!fd)
1667 {
1668 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1669 Message(t,_("Error"),TRUE);
1670 if(t) g_free(t);
1671 return;
1672 }
1673 while(!feof(fd))
1674 {
1675 { gchar* e = fgets(t,taille,fd);}
1676 if(strstr(t,tag) )
1677 {
1678 Ncalculs++;
1679 if(Ncalculs == 1) GeomConv = g_malloc(sizeof(DataGeomConv) );
1680 else GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1681 GeomConv[Ncalculs-1] = init_geom_vasp_conv_outcar(NomFichier);
1682 break;
1683 }
1684 }
1685 rewind(fd);
1686
1687 while(!feof(fd))
1688 {
1689 { gchar* e = fgets(t,taille,fd);}
1690 pdest = strstr( t,tag);
1691 if( pdest != NULL && Ncalculs>0)
1692 {
1693 GeomConv[Ncalculs-1].Npoint++;
1694 if(GeomConv[Ncalculs-1].Npoint == 1 )
1695 {
1696 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1697 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1698 }
1699 else
1700 {
1701 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1702 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1703 }
1704 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1705 {
1706 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1707 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1708 }
1709 pdest = strstr(t,tag)+strlen(tag);
1710 sscanf(pdest,"%s",t);
1711 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_strdup_printf("%s",t);
1712
1713 Ok = TRUE;
1714 while(!feof(fd) && Ok )
1715 {
1716 if(!fgets(t,taille,fd))
1717 {
1718 Ok = FALSE;
1719 break;
1720 }
1721 else
1722 {
1723 if(strstr(t," total drift:"))
1724 {
1725 Ok = TRUE;
1726 break;
1727 }
1728
1729 }
1730 }
1731 if(!Ok) break;
1732 sscanf(t,"%s %s %s %s %s",temp,temp,temp,temp1,temp2);
1733 GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(temp);
1734 GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(temp1);
1735 GeomConv[Ncalculs-1].Data[3][GeomConv[Ncalculs-1].Npoint-1] = g_strdup(temp2);
1736 }
1737 }
1738
1739 fclose(fd);
1740
1741 if(!Ok && GeomConv && GeomConv[Ncalculs-1].Npoint>0) GeomConv[Ncalculs-1].Npoint--;
1742 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1743 {
1744 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1745 Ncalculs--;
1746 if(Ncalculs>0)
1747 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1748 else
1749 {
1750 g_free(GeomConv);
1751 GeomConv = NULL;
1752 }
1753 }
1754 k = 0;
1755 for(i=0;(gint)i<Ncalculs;i++)
1756 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1757 {
1758 k++;
1759 GeomConv[i].NumGeom[j] = k;
1760 }
1761 create_energies_curves(GeomConv,Ncalculs);
1762 g_free(t);
1763 g_free(temp);
1764 }
1765 /*********************************************************************/
init_geom_vasp_xml_conv(gchar * namefile)1766 DataGeomConv init_geom_vasp_xml_conv(gchar* namefile)
1767 {
1768 DataGeomConv GeomConv;
1769 gint i;
1770 GeomConv.Npoint = 0;
1771 GeomConv.Ntype = 4;
1772 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1773 GeomConv.fileType = GABEDIT_TYPEFILE_VASPXML;
1774
1775 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1776 GeomConv.TypeData[1] = g_strdup(_(" dX "));
1777 GeomConv.TypeData[2] = g_strdup(_(" dY "));
1778 GeomConv.TypeData[3] = g_strdup(_(" dZ "));
1779
1780 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1781 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
1782 GeomConv.TypeCalcul = NULL;
1783 GeomConv.NumGeom = NULL;
1784 GeomConv.GeomFile = g_strdup(namefile);
1785 return GeomConv;
1786 }
1787 /*********************************************************************/
find_energy_vasp_xml(gchar * NomFichier)1788 void find_energy_vasp_xml(gchar* NomFichier)
1789 {
1790 gchar *pdest;
1791 guint i=0;
1792 guint j=0;
1793 guint k=0;
1794 gchar* tag = "<structure>";
1795 gchar *t;
1796 FILE *fd;
1797 gint Ncalculs = 0;
1798 static DataGeomConv* GeomConv =NULL;
1799 gboolean Ok = FALSE;
1800 gint nf = 0;
1801 gdouble x,y,z;
1802 gdouble X,Y,Z;
1803 gdouble energy;
1804 gchar* pos;
1805
1806
1807 t=g_malloc(BSIZE*sizeof(gchar));
1808 fd = FOpen(NomFichier, "rb");
1809 if(!fd)
1810 {
1811 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1812 Message(t,_("Error"),TRUE);
1813 if(t) g_free(t);
1814 return;
1815 }
1816 while(!feof(fd))
1817 {
1818 { gchar* e = fgets(t,BSIZE,fd);}
1819 if(strstr(t,tag) )
1820 {
1821 Ncalculs++;
1822 if(Ncalculs == 1) GeomConv = g_malloc(sizeof(DataGeomConv) );
1823 else GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1824 GeomConv[Ncalculs-1] = init_geom_vasp_xml_conv(NomFichier);
1825 break;
1826 }
1827 }
1828 rewind(fd);
1829
1830 while(!feof(fd))
1831 {
1832 { gchar* e = fgets(t,BSIZE,fd);}
1833 pdest = strstr( t,tag);
1834 if( pdest != NULL && Ncalculs>0)
1835 {
1836 Ok = TRUE;
1837 GeomConv[Ncalculs-1].Npoint++;
1838 if(GeomConv[Ncalculs-1].Npoint == 1 )
1839 {
1840 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1841 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1842 }
1843 else
1844 {
1845 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1846 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++) GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
1847 }
1848 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
1849 {
1850 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
1851 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
1852 }
1853 while(!feof(fd))
1854 {
1855 if(!fgets(t,BSIZE,fd)) { Ok = FALSE; break; }
1856 if(strstr(t,"varray name") && strstr(t,"forces")) break;
1857 }
1858 if(!Ok) break;
1859 nf = 0;
1860 X = Y = Z = 0;
1861 while(!feof(fd))
1862 {
1863 if(!fgets(t,BSIZE,fd)) { Ok = FALSE; break; }
1864 if(strstr(t,"varray")) break;
1865 pos = strstr(t,">");
1866 if(!pos) break;
1867 if(3!=sscanf(pos+1,"%lf %lf %lf",&x,&y,&z)) { Ok = FALSE; break;}
1868 X += x*x; Y += y*y; Z += z*z;
1869 nf++;
1870 }
1871 if(!Ok) break;
1872 if(nf<1) { Ok = FALSE; break;}
1873 X = sqrt(X/nf);
1874 Y = sqrt(Y/nf);
1875 Z = sqrt(Z/nf);
1876
1877 while(!feof(fd))
1878 {
1879 if(!fgets(t,BSIZE,fd)) { Ok = FALSE; break; }
1880 if(strstr(t,"/energy")) { Ok = FALSE; break;}
1881 if(strstr(t,"e_fr_energy")) break;
1882 }
1883 if(!Ok) break;
1884 if(!strstr(t,"e_fr_energy")) { Ok = FALSE; break;}
1885 pos = strstr(t,">");
1886 if(!pos) { Ok = FALSE; break;}
1887 if(1!=sscanf(pos+1,"%lf",&energy)) { Ok = FALSE; break;}
1888 /* printf("energy = %f X = %f Y = %f Z = %f\n",energy,X,Y,Z);*/
1889 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_strdup_printf("%0.8f",energy);
1890 GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1] = g_strdup_printf("%0.6f",X);
1891 GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1] = g_strdup_printf("%0.6f",Y);
1892 GeomConv[Ncalculs-1].Data[3][GeomConv[Ncalculs-1].Npoint-1] = g_strdup_printf("%0.6f",Z);
1893 }
1894 }
1895 fclose(fd);
1896
1897 if(!Ok && GeomConv && GeomConv[Ncalculs-1].Npoint>0) GeomConv[Ncalculs-1].Npoint--;
1898 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
1899 {
1900 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
1901 Ncalculs--;
1902 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1903 else
1904 {
1905 g_free(GeomConv);
1906 GeomConv = NULL;
1907 }
1908 }
1909 k = 0;
1910 for(i=0;(gint)i<Ncalculs;i++)
1911 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
1912 {
1913 k++;
1914 GeomConv[i].NumGeom[j] = k;
1915 }
1916 create_energies_curves(GeomConv, Ncalculs);
1917 g_free(t);
1918 }
1919 /*************************************************************************************/
init_geom_molden_gabedit_conv(gchar * fileName,GabEditTypeFile type)1920 static DataGeomConv init_geom_molden_gabedit_conv(gchar *fileName, GabEditTypeFile type)
1921 {
1922 DataGeomConv GeomConv;
1923 gint i;
1924 GeomConv.Npoint = 0;
1925 GeomConv.Ntype = 5;
1926 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
1927 GeomConv.fileType = type;
1928 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
1929 GeomConv.TypeData[1] = g_strdup(_(" Force Max "));
1930 GeomConv.TypeData[2] = g_strdup(_(" Force RMS "));
1931 GeomConv.TypeData[3] = g_strdup(_(" Dep. Max "));
1932 GeomConv.TypeData[4] = g_strdup(_(" Dep. RMS "));
1933 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
1934 for(i = 0;i<GeomConv.Ntype;i++)
1935 GeomConv.Data[i] = NULL;
1936 GeomConv.TypeCalcul = NULL;
1937 GeomConv.NumGeom = NULL;
1938 GeomConv.GeomFile = g_strdup(fileName);
1939
1940 return GeomConv;
1941 }
1942 /*********************************************************************/
find_energy_molpro_log(gchar * NomFichier)1943 void find_energy_molpro_log(gchar* NomFichier)
1944 {
1945 gchar *pdest;
1946 guint i=0;
1947 guint j=0;
1948 guint k=0;
1949 gchar *temp = g_malloc(50*sizeof(gchar));
1950 guint taille=BSIZE;
1951 gchar *t;
1952 FILE *fd;
1953 gint Ncalculs = 0;
1954 static DataGeomConv* GeomConv =NULL;
1955 gboolean Ok;
1956
1957
1958 t=g_malloc(taille);
1959 fd = FOpen(NomFichier, "rb");
1960 if(!fd)
1961 {
1962 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
1963 Message(t,_("Error"),TRUE);
1964 if(t)
1965 g_free(t);
1966 return;
1967 }
1968
1969 while(!feof(fd))
1970 {
1971 { gchar* e = fgets(t,taille,fd);}
1972 if( strlen(t)>2 && strstr(t,"GEOMETRY OPTIMIZATION STEP 1") )
1973 {
1974 Ncalculs++;
1975 if(Ncalculs == 1)
1976 GeomConv = g_malloc(sizeof(DataGeomConv) );
1977 else
1978 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1979 GeomConv[Ncalculs-1] = init_geom_molpro_conv(NomFichier);
1980 }
1981 if( strlen(t)>2 && strstr(t,"Optimization point 1") && Ncalculs<1)
1982 {
1983 Ncalculs++;
1984 if(Ncalculs == 1)
1985 GeomConv = g_malloc(sizeof(DataGeomConv) );
1986 else
1987 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
1988 GeomConv[Ncalculs-1] = init_geom_molpro_conv(NomFichier);
1989 }
1990
1991 pdest = strstr( t,"Optimization point");
1992
1993 if( pdest != NULL && Ncalculs>0)
1994 {
1995 GeomConv[Ncalculs-1].Npoint++;
1996 if(GeomConv[Ncalculs-1].Npoint == 1 )
1997 {
1998 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
1999 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2000 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2001 }
2002 else
2003 {
2004 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2005 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2006 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2007 }
2008 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2009 {
2010 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2011 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2012 }
2013
2014 Ok = TRUE;
2015 while(!feof(fd) && Ok )
2016 {
2017 if(!fgets(t,taille,fd))
2018 {
2019 Ok = FALSE;
2020 break;
2021 }
2022 else
2023 {
2024 if(strstr(t,"(") && strstr(t,")"))
2025 {
2026 Ok = TRUE;
2027 break;
2028 }
2029
2030 }
2031 }
2032 if(!Ok) break;
2033 sscanf(t,"%s %s %s %s %s",temp,temp,temp,temp,GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
2034 uppercase(t);
2035 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
2036 pdest = strstr( t,"(");
2037 pdest++;
2038 sscanf(pdest,"%s)",GeomConv[Ncalculs-1].TypeCalcul);
2039 for(i=0;i<strlen(GeomConv[Ncalculs-1].TypeCalcul);i++)
2040 {
2041 if(GeomConv[Ncalculs-1].TypeCalcul[i] == ')')
2042 GeomConv[Ncalculs-1].TypeCalcul[i] = ' ';
2043 }
2044
2045 do
2046 {
2047 { gchar* e = fgets(t,taille,fd);}
2048 }while(strstr(t,"Convergence:")==NULL && !feof(fd) ) ;
2049 if(strstr(t,"Convergence:")!=NULL)
2050 sscanf(t,"%s %s %s %s %s ", temp,temp,temp,temp,GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1]);
2051 }
2052
2053 }
2054
2055 fclose(fd);
2056
2057 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2058 {
2059 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2060 Ncalculs--;
2061 if(Ncalculs>0)
2062 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2063 else
2064 {
2065 g_free(GeomConv);
2066 GeomConv = NULL;
2067 }
2068 }
2069 k = 0;
2070 for(i=0;(gint)i<Ncalculs;i++)
2071 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
2072 {
2073 k++;
2074 GeomConv[i].NumGeom[j] = k;
2075 }
2076 create_energies_curves(GeomConv,Ncalculs);
2077 g_free(t);
2078 g_free(temp);
2079 }
2080 /*********************************************************************/
find_energy_qchem_log(gchar * NomFichier)2081 void find_energy_qchem_log(gchar* NomFichier)
2082 {
2083 gchar *pdest;
2084 guint i=0;
2085 guint j=0;
2086 guint k=0;
2087 gchar *temp = g_malloc(50*sizeof(gchar));
2088 guint taille=BSIZE;
2089 gchar *t;
2090 FILE *fd;
2091 gint Ncalculs = 0;
2092 static DataGeomConv* GeomConv =NULL;
2093 gboolean Ok;
2094
2095
2096 t=g_malloc(taille);
2097 fd = FOpen(NomFichier, "rb");
2098 if(!fd)
2099 {
2100 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
2101 Message(t,_("Error"),TRUE);
2102 if(t)
2103 g_free(t);
2104 return;
2105 }
2106
2107 while(!feof(fd))
2108 {
2109 { gchar* e = fgets(t,taille,fd);}
2110 if( strlen(t)>2 && strstr(t,"Optimization Cycle: 1") )
2111 {
2112 Ncalculs++;
2113 if(Ncalculs == 1)
2114 GeomConv = g_malloc(sizeof(DataGeomConv) );
2115 else
2116 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2117 GeomConv[Ncalculs-1] = init_geom_qchem_conv(NomFichier);
2118 }
2119 pdest = strstr( t,"Optimization Cycle:");
2120
2121 if( pdest != NULL && Ncalculs>0)
2122 {
2123 GeomConv[Ncalculs-1].Npoint++;
2124 if(GeomConv[Ncalculs-1].Npoint == 1 )
2125 {
2126 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2127 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2128 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2129 }
2130 else
2131 {
2132 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2133 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2134 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2135 }
2136 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2137 {
2138 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2139 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2140 }
2141
2142 Ok = TRUE;
2143 while(!feof(fd) && Ok )
2144 {
2145 if(!fgets(t,taille,fd))
2146 {
2147 Ok = FALSE;
2148 break;
2149 }
2150 else
2151 {
2152 if(strstr(t,"Energy is"))
2153 {
2154 Ok = TRUE;
2155 break;
2156 }
2157
2158 }
2159 }
2160 if(!Ok) break;
2161 sscanf(t,"%s %s %s",temp,temp,GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
2162 uppercase(t);
2163 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
2164 do
2165 {
2166 if(!fgets(t,taille,fd))break;
2167 }while(strstr(t,"Cnvgd?")==NULL && !feof(fd) ) ;
2168 if(strstr(t,"Cnvgd?")!=NULL)
2169 {
2170 if(!fgets(t,taille,fd))break;
2171 sscanf(t,"%s %s", temp,GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1]);
2172 if(!fgets(t,taille,fd))break;
2173 sscanf(t,"%s %s", temp,GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1]);
2174 }
2175 }
2176
2177 }
2178
2179 fclose(fd);
2180
2181 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2182 {
2183 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2184 Ncalculs--;
2185 if(Ncalculs>0)
2186 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2187 else
2188 {
2189 g_free(GeomConv);
2190 GeomConv = NULL;
2191 }
2192 }
2193 k = 0;
2194 for(i=0;(gint)i<Ncalculs;i++)
2195 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
2196 {
2197 k++;
2198 GeomConv[i].NumGeom[j] = k;
2199 }
2200 create_energies_curves(GeomConv,Ncalculs);
2201 g_free(t);
2202 g_free(temp);
2203 }
2204 /*********************************************************************/
init_geom_nwchem_conv(gchar * namefile)2205 DataGeomConv init_geom_nwchem_conv(gchar* namefile)
2206 {
2207 DataGeomConv GeomConv;
2208 gint i;
2209 GeomConv.Npoint = 0;
2210 GeomConv.Ntype = 3;
2211 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
2212 GeomConv.fileType = GABEDIT_TYPEFILE_NWCHEM;
2213
2214 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
2215 GeomConv.TypeData[1] = g_strdup(_(" Gradient Max "));
2216 GeomConv.TypeData[2] = g_strdup(_(" Dep. Max "));
2217
2218 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
2219 for(i = 0;i<GeomConv.Ntype;i++)
2220 GeomConv.Data[i] = NULL;
2221 GeomConv.TypeCalcul = NULL;
2222 GeomConv.NumGeom = NULL;
2223 GeomConv.GeomFile = g_strdup(namefile);
2224 return GeomConv;
2225 }
2226 /*********************************************************************/
find_energy_nwchem_log(gchar * NomFichier)2227 void find_energy_nwchem_log(gchar* NomFichier)
2228 {
2229 gchar *pdest;
2230 guint i=0;
2231 guint j=0;
2232 guint k=0;
2233 gchar *temp = g_malloc(50*sizeof(gchar));
2234 guint taille=BSIZE;
2235 gchar *t;
2236 FILE *fd;
2237 gint Ncalculs = 0;
2238 static DataGeomConv* GeomConv =NULL;
2239 gboolean Ok = FALSE;
2240
2241
2242 t=g_malloc(taille);
2243 fd = FOpen(NomFichier, "rb");
2244 if(!fd)
2245 {
2246 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
2247 Message(t,_("Error"),TRUE);
2248 if(t)
2249 g_free(t);
2250 return;
2251 }
2252
2253 while(!feof(fd))
2254 {
2255 { gchar* e = fgets(t,taille,fd);}
2256 if(strstr(t,"Step 0") )
2257 {
2258 Ncalculs++;
2259 if(Ncalculs == 1)
2260 GeomConv = g_malloc(sizeof(DataGeomConv) );
2261 else
2262 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2263 GeomConv[Ncalculs-1] = init_geom_nwchem_conv(NomFichier);
2264 }
2265 pdest = NULL;
2266 if(strstr( t,"Step ") && !strstr(t,"Energy")) pdest = strstr( t,"Step ");
2267
2268 if( pdest != NULL && Ncalculs>0)
2269 {
2270 GeomConv[Ncalculs-1].Npoint++;
2271 if(GeomConv[Ncalculs-1].Npoint == 1 )
2272 {
2273 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2274 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2275 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2276 }
2277 else
2278 {
2279 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2280 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2281 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2282 }
2283 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2284 {
2285 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2286 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2287 }
2288
2289 Ok = TRUE;
2290 while(!feof(fd) && Ok )
2291 {
2292 if(!fgets(t,taille,fd))
2293 {
2294 Ok = FALSE;
2295 break;
2296 }
2297 else
2298 {
2299 if(strstr(t,"Step Energy Delta E Gmax Grms Xrms Xmax"))
2300 {
2301 Ok = TRUE;
2302 break;
2303 }
2304
2305 }
2306 }
2307 if(!Ok) break;
2308 if(!fgets(t,taille,fd)) break;
2309 if(!fgets(t,taille,fd)) break;
2310 sscanf(t,"%s %s %s %s %s %s %s %s",temp, temp,GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1],temp,GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1],temp,temp,GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1]);
2311 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
2312 }
2313
2314 }
2315 fclose(fd);
2316
2317 if(!Ok && Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0) GeomConv[Ncalculs-1].Npoint--;
2318 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2319 {
2320 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2321 Ncalculs--;
2322 if(Ncalculs>0)
2323 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2324 else
2325 {
2326 g_free(GeomConv);
2327 GeomConv = NULL;
2328 }
2329 }
2330 k = 0;
2331 for(i=0;(gint)i<Ncalculs;i++)
2332 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
2333 {
2334 k++;
2335 GeomConv[i].NumGeom[j] = k;
2336 }
2337 create_energies_curves(GeomConv,Ncalculs);
2338 g_free(t);
2339 g_free(temp);
2340 }
2341 /*********************************************************************/
init_geom_psicode_conv(gchar * namefile)2342 DataGeomConv init_geom_psicode_conv(gchar* namefile)
2343 {
2344 DataGeomConv GeomConv;
2345 gint i;
2346 GeomConv.Npoint = 0;
2347 GeomConv.Ntype = 5;
2348 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
2349 GeomConv.fileType = GABEDIT_TYPEFILE_PSICODE;
2350
2351 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
2352 GeomConv.TypeData[1] = g_strdup(_(" MAX Force "));
2353 GeomConv.TypeData[2] = g_strdup(_(" RMS Force "));
2354 GeomConv.TypeData[3] = g_strdup(_(" MAX Dsip. "));
2355 GeomConv.TypeData[4] = g_strdup(_(" RMS Disp. "));
2356
2357 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
2358 for(i = 0;i<GeomConv.Ntype;i++)
2359 GeomConv.Data[i] = NULL;
2360 GeomConv.TypeCalcul = NULL;
2361 GeomConv.NumGeom = NULL;
2362 GeomConv.GeomFile = g_strdup(namefile);
2363 return GeomConv;
2364 }
2365 /*********************************************************************/
find_energy_psicode_log(gchar * NomFichier)2366 void find_energy_psicode_log(gchar* NomFichier)
2367 {
2368 gchar *pdest;
2369 guint i=0;
2370 guint c=0;
2371 guint j=0;
2372 guint k=0;
2373 gchar *temp = g_malloc(50*sizeof(gchar));
2374 guint taille=BSIZE;
2375 gchar *t;
2376 FILE *fd;
2377 gint Ncalculs = 0;
2378 static DataGeomConv* GeomConv =NULL;
2379 gboolean Ok = FALSE;
2380
2381
2382 t=g_malloc(taille);
2383 fd = FOpen(NomFichier, "rb");
2384 if(!fd)
2385 {
2386 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
2387 Message(t,_("Error"),TRUE);
2388 if(t)
2389 g_free(t);
2390 return;
2391 }
2392
2393 while(!feof(fd))
2394 {
2395 { gchar* e = fgets(t,taille,fd);}
2396 if(strstr(t,"OPTKING") && Ncalculs == 0)
2397 {
2398 Ncalculs++;
2399 if(Ncalculs == 1)
2400 GeomConv = g_malloc(sizeof(DataGeomConv) );
2401 else
2402 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2403 GeomConv[Ncalculs-1] = init_geom_psicode_conv(NomFichier);
2404 }
2405 pdest = NULL;
2406 if(strstr( t,"Step ")
2407 && strstr(t,"Energy")
2408 && strstr(t,"MAX Force")
2409 && strstr(t,"RMS Force")
2410 && strstr(t,"MAX Disp")
2411 && strstr(t,"RMS Disp")
2412 )
2413 {
2414
2415 pdest = strstr( t,"Step ");
2416 }
2417
2418 if( pdest != NULL && Ncalculs>0)
2419 {
2420 GeomConv[Ncalculs-1].Npoint++;
2421 if(GeomConv[Ncalculs-1].Npoint == 1 )
2422 {
2423 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2424 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2425 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2426 }
2427 else
2428 {
2429 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2430 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2431 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2432 }
2433 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2434 {
2435 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2436 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2437 }
2438
2439 Ok = TRUE;
2440 while(!feof(fd) && Ok )
2441 {
2442 if(!fgets(t,taille,fd))
2443 {
2444 Ok = FALSE;
2445 break;
2446 }
2447 else
2448 {
2449 if(strstr(t,"Convergence Criteria"))
2450 {
2451 Ok = TRUE;
2452 break;
2453 }
2454
2455 }
2456 }
2457 if(!Ok) break;
2458 if(!fgets(t,taille,fd)) break;/* ---- */
2459 if(!fgets(t,taille,fd)) break;
2460 for(c=0;c<strlen(t);c++) if(t[c]=='*'||t[c]=='o')t[c]=' ';
2461 sscanf(t,"%s %s %s %s %s %s %s",
2462 temp,
2463 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1],
2464 temp,
2465 GeomConv[Ncalculs-1].Data[1][GeomConv[Ncalculs-1].Npoint-1],
2466 GeomConv[Ncalculs-1].Data[2][GeomConv[Ncalculs-1].Npoint-1],
2467 GeomConv[Ncalculs-1].Data[3][GeomConv[Ncalculs-1].Npoint-1],
2468 GeomConv[Ncalculs-1].Data[4][GeomConv[Ncalculs-1].Npoint-1]
2469 );
2470 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
2471 }
2472
2473 }
2474 fclose(fd);
2475
2476 if(!Ok && Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0) GeomConv[Ncalculs-1].Npoint--;
2477 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2478 {
2479 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2480 Ncalculs--;
2481 if(Ncalculs>0)
2482 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2483 else
2484 {
2485 g_free(GeomConv);
2486 GeomConv = NULL;
2487 }
2488 }
2489 k = 0;
2490 for(i=0;(gint)i<Ncalculs;i++)
2491 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
2492 {
2493 k++;
2494 GeomConv[i].NumGeom[j] = k;
2495 }
2496 create_energies_curves(GeomConv,Ncalculs);
2497 g_free(t);
2498 g_free(temp);
2499 }
2500 /*********************************************************************/
init_geom_gauss_scanOpt_conv(gchar * namefile)2501 DataGeomConv init_geom_gauss_scanOpt_conv(gchar *namefile)
2502 {
2503 DataGeomConv GeomConv;
2504 gint i;
2505 GeomConv.Npoint = 0;
2506 GeomConv.Ntype = 5;
2507 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
2508 GeomConv.fileType = GABEDIT_TYPEFILE_GAUSSIAN;
2509 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
2510 GeomConv.TypeData[1] = g_strdup(_(" Force Max "));
2511 GeomConv.TypeData[2] = g_strdup(_(" Force RMS "));
2512 GeomConv.TypeData[3] = g_strdup(_(" Dep. Max "));
2513 GeomConv.TypeData[4] = g_strdup(_(" Dep. RMS "));
2514 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
2515 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
2516 GeomConv.TypeCalcul = NULL;
2517 GeomConv.NumGeom = NULL;
2518 GeomConv.GeomFile = g_strdup(namefile);
2519 return GeomConv;
2520 }
2521 /*********************************************************************/
find_energy_gauss_scanOpt_output(gchar * NomFichier)2522 void find_energy_gauss_scanOpt_output(gchar* NomFichier)
2523 {
2524 gchar* pdest = NULL;
2525 guint i=0;
2526 guint j=0;
2527 guint k=0;
2528 gchar *temp = g_malloc(100*sizeof(gchar));
2529 gchar *t;
2530 FILE *fd;
2531 gint Ncalculs = 0;
2532 static DataGeomConv* GeomConv =NULL;
2533 gint numGeom = 0;
2534 gchar** props = NULL;
2535 gint nTypes = 0;
2536
2537
2538 Ncalculs++;
2539 GeomConv = g_malloc(sizeof(DataGeomConv) );
2540 GeomConv[Ncalculs-1] = init_geom_gauss_scanOpt_conv(NomFichier);
2541 props = g_malloc(GeomConv[Ncalculs-1].Ntype*sizeof(gchar*));
2542 nTypes = GeomConv[Ncalculs-1].Ntype;
2543 for(i=0;(gint)i<nTypes;i++) props[i] = g_malloc(100*sizeof(gchar));
2544
2545 t=g_malloc(BSIZE*sizeof(gchar));
2546 fd = FOpen(NomFichier, "rb");
2547 if(!fd)
2548 {
2549 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
2550 Message(t,_("Error"),TRUE);
2551 if(t) g_free(t);
2552 return;
2553 }
2554
2555 while(!feof(fd))
2556 {
2557 { gchar* e = fgets(t,BSIZE,fd);}
2558 if( strlen(t)>2 && strstr(t,"Normal termination of Gaussian") )
2559 {
2560 Ncalculs++;
2561 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2562 GeomConv[Ncalculs-1] = init_geom_gauss_scanOpt_conv(NomFichier);
2563 continue;
2564 }
2565 uppercase(t);
2566 if( strlen(t)>2 && t[1] == '#' && !GeomConv[Ncalculs-1].TypeCalcul)
2567 {
2568 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
2569 sscanf(t,"%s %s", temp, GeomConv[Ncalculs-1].TypeCalcul);
2570 }
2571 pdest = strstr( t,"SCF DONE");
2572 if( pdest != NULL ) pdest = strstr( t,"=");
2573 if(!pdest)
2574 {
2575 pdest = strstr( t,"ENERGY=");
2576 if(pdest && t[1] == 'E' ) pdest = strstr( t,"=");
2577 else pdest = NULL;
2578
2579 }
2580 if( pdest != NULL )
2581 {
2582 numGeom++;
2583 sscanf(pdest+1,"%s", props[0]);
2584 /*
2585 fprintf(stderr,"%s\n",t);
2586 fprintf(stderr,"%s\n",props[0]);
2587 */
2588 }
2589 pdest = NULL;
2590 pdest = strstr( t,"CONVERGED?");
2591 if( pdest != NULL)
2592 {
2593 for(i=1;(gint)i<nTypes;i++)
2594 {
2595 { gchar* e = fgets(t,BSIZE,fd);}
2596 sscanf(t,"%s %s %s", temp,temp,props[i]);
2597 }
2598 }
2599 pdest = NULL;
2600 pdest = strstr( t," STATIONARY POINT FOUND");
2601 if( pdest != NULL )
2602 {
2603 pdest++;
2604 GeomConv[Ncalculs-1].Npoint++;
2605 if(GeomConv[Ncalculs-1].Npoint == 1 )
2606 {
2607 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2608 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2609 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2610 }
2611 else
2612 {
2613 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2614 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2615 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2616 }
2617 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2618 {
2619 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(100*sizeof(gchar));
2620 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2621 }
2622 GeomConv[Ncalculs-1].NumGeom[GeomConv[Ncalculs-1].Npoint-1] = numGeom;
2623 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2624 sprintf( GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1], "%s", props[i]);
2625 }
2626 }
2627 fclose(fd);
2628 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2629 {
2630 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2631 Ncalculs--;
2632 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2633 else
2634 {
2635 g_free(GeomConv);
2636 GeomConv = NULL;
2637 }
2638 }
2639 /*
2640 {
2641 gint j;
2642 for( j=0;j<Ncalculs;j++)
2643 {
2644 gint np=GeomConv[j].Npoint;
2645 fprintf(stderr,"DEBUG Npoint = %d\n",np);
2646 gint i;
2647 for(i=0;i<np;i++)
2648 fprintf(stderr,"numGeom = %d\n",GeomConv[j].NumGeom[i]);
2649 }
2650 }
2651 */
2652 create_energies_curves(GeomConv,Ncalculs);
2653 g_free(t);
2654 g_free(temp);
2655 for(i=0;(gint)i<nTypes;i++) if(props[i]) g_free(props[i]);
2656 }
2657 /*********************************************************************/
init_geom_gauss_ircOpt_conv(gchar * namefile)2658 DataGeomConv init_geom_gauss_ircOpt_conv(gchar *namefile)
2659 {
2660 /* fprintf(stderr,"DEBUG init_geom_gauss_ircOpt_conv\n");*/
2661 DataGeomConv GeomConv;
2662 gint i;
2663 GeomConv.Npoint = 0;
2664 GeomConv.Ntype = 3;
2665 GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
2666 GeomConv.fileType = GABEDIT_TYPEFILE_GAUSSIAN;
2667 GeomConv.TypeData[0] = g_strdup(_(" Energy "));
2668 GeomConv.TypeData[1] = g_strdup(_(" Force Max "));
2669 GeomConv.TypeData[2] = g_strdup(_(" Force RMS "));
2670 GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
2671 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
2672 GeomConv.TypeCalcul = NULL;
2673 GeomConv.NumGeom = NULL;
2674 GeomConv.GeomFile = g_strdup(namefile);
2675 return GeomConv;
2676 }
2677 /*********************************************************************/
find_energy_gauss_ircOpt_output(gchar * NomFichier)2678 void find_energy_gauss_ircOpt_output(gchar* NomFichier)
2679 {
2680 gchar* pdest = NULL;
2681 guint i=0;
2682 guint j=0;
2683 guint k=0;
2684 gchar *temp = g_malloc(100*sizeof(gchar));
2685 gchar *t;
2686 FILE *fd;
2687 gint Ncalculs = 0;
2688 static DataGeomConv* GeomConv =NULL;
2689 gint numGeom = 0;
2690 gchar** props = NULL;
2691 gint nTypes = 0;
2692 gint oneDir = 0;
2693
2694
2695 Ncalculs++;
2696 GeomConv = g_malloc(sizeof(DataGeomConv) );
2697 GeomConv[Ncalculs-1] = init_geom_gauss_ircOpt_conv(NomFichier);
2698 props = g_malloc(GeomConv[Ncalculs-1].Ntype*sizeof(gchar*));
2699 nTypes = GeomConv[Ncalculs-1].Ntype;
2700 for(i=0;(gint)i<nTypes;i++) props[i] = g_malloc(100*sizeof(gchar));
2701
2702 t=g_malloc(BSIZE*sizeof(gchar));
2703 fd = FOpen(NomFichier, "rb");
2704 if(!fd)
2705 {
2706 t = g_strdup_printf(_(" Error : I can not open file %s\n"),NomFichier);
2707 Message(t,_("Error"),TRUE);
2708 if(t)
2709 g_free(t);
2710 return;
2711 }
2712
2713 while(!feof(fd))
2714 {
2715 { gchar* e = fgets(t,BSIZE,fd);}
2716 if( strlen(t)>2 && strstr(t,"Normal termination of Gaussian") )
2717 {
2718 Ncalculs++;
2719 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2720 GeomConv[Ncalculs-1] = init_geom_gauss_conv(NomFichier);
2721 }
2722 if(strstr(t,"path following direction ")) oneDir = 1;
2723 uppercase(t);
2724 if( strlen(t)>2 && t[1] == '#' && !GeomConv[Ncalculs-1].TypeCalcul)
2725 {
2726 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
2727 sscanf(t,"%s %s", temp, GeomConv[Ncalculs-1].TypeCalcul);
2728 }
2729 pdest = strstr( t,"SCF DONE");
2730 if( pdest != NULL ) pdest = strstr( t,"=");
2731 if(!pdest)
2732 {
2733 pdest = strstr( t,"ENERGY=");
2734 if(pdest && t[1] == 'E' ) pdest = strstr( t,"=");
2735 else pdest = NULL;
2736
2737 }
2738 if( pdest != NULL )
2739 {
2740 numGeom++;
2741 sscanf(pdest+1,"%s", props[0]);
2742 /*
2743 fprintf(stderr,"%s\n",t);
2744 fprintf(stderr,"%s\n",props[0]);
2745 */
2746 }
2747 pdest = NULL;
2748 if(strstr( t,"MAX ") && strstr( t,"RMS "))
2749 {
2750 pdest = strstr( t,"MAX ") + strlen("MAX ");
2751 sscanf(pdest,"%s", props[1]);
2752 pdest = strstr( t,"RMS ") + strlen("RMS ");
2753 sscanf(pdest,"%s", props[2]);
2754 }
2755 pdest = NULL;
2756 pdest = strstr( t," CONVERGENCE MET");
2757 if( pdest != NULL )
2758 {
2759 pdest++;
2760 GeomConv[Ncalculs-1].Npoint++;
2761 if(GeomConv[Ncalculs-1].Npoint == 1 )
2762 {
2763 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2764 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2765 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2766 }
2767 else
2768 {
2769 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2770 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2771 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2772 }
2773 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2774 {
2775 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(100*sizeof(gchar));
2776 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2777 }
2778 GeomConv[Ncalculs-1].NumGeom[GeomConv[Ncalculs-1].Npoint-1] = numGeom;
2779 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2780 sprintf( GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1], "%s", props[i]);
2781 }
2782 }
2783 fclose(fd);
2784 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2785 {
2786 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2787 Ncalculs--;
2788 if(Ncalculs>0) GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2789 else
2790 {
2791 g_free(GeomConv);
2792 GeomConv = NULL;
2793 }
2794 }
2795 if(oneDir==0)
2796 {
2797 /* sort */
2798 gint j;
2799 /* fprintf(stderr,"DEBUG sorting IRC\n");*/
2800 for( j=0;j<Ncalculs;j++)
2801 {
2802 gint n=GeomConv[j].Npoint/2;
2803 /*
2804 fprintf(stderr,"DEBUG n = %d\n",n);
2805 fprintf(stderr,"DEBUG Npoint = %d\n",GeomConv[j].Npoint);
2806 */
2807 gint i;
2808 gint k;
2809 for(i=0;(gint)i<GeomConv[j].Ntype;i++)
2810 for(k=0;k<n;k++)
2811 {
2812 gchar* data = GeomConv[j].Data[i][k];
2813 GeomConv[j].Data[i][k] = GeomConv[j].Data[i][n+k];
2814 GeomConv[j].Data[i][n+k] = data;
2815 gint numGeom = GeomConv[j].NumGeom[k];
2816 GeomConv[j].NumGeom[k] = GeomConv[j].NumGeom[n+k];
2817 GeomConv[j].NumGeom[n+k] = numGeom;
2818 }
2819 for(i=0;(gint)i<GeomConv[j].Ntype;i++)
2820 for(k=0;k<n/2;k++)
2821 {
2822 gchar* data = GeomConv[j].Data[i][k];
2823 GeomConv[j].Data[i][k] = GeomConv[j].Data[i][n-k-1];
2824 GeomConv[j].Data[i][n-k-1] = data;
2825 gint numGeom = GeomConv[j].NumGeom[k];
2826 GeomConv[j].NumGeom[k] = GeomConv[j].NumGeom[n-k-1];
2827 GeomConv[j].NumGeom[n-k-1] = numGeom;
2828 }
2829 }
2830 }
2831 create_energies_curves(GeomConv,Ncalculs);
2832 g_free(t);
2833 g_free(temp);
2834 for(i=0;(gint)i<nTypes;i++) if(props[i]) g_free(props[i]);
2835 }
2836 /*********************************************************************/
find_energy_molden_gabedit(gchar * FileName,GabEditTypeFile type)2837 void find_energy_molden_gabedit(gchar* FileName, GabEditTypeFile type)
2838 {
2839 guint i=0;
2840 guint j=0;
2841 guint k=0;
2842 guint taille=BSIZE;
2843 gchar temp[BSIZE];
2844 gchar t[BSIZE];
2845 FILE *fd;
2846 gint Ncalculs = 0;
2847 static DataGeomConv* GeomConv =NULL;
2848 gint nn = 0;
2849
2850 fd = FOpen(FileName, "rb");
2851 if(!fd)
2852 {
2853 sprintf(t,_(" Error : I can not open file %s\n"),FileName);
2854 Message(t,_("Error"),TRUE);
2855 return;
2856 }
2857
2858 { gchar* e = fgets(t,taille,fd);}
2859 while(!feof(fd))
2860 {
2861 uppercase(t);
2862 /*fprintf(stderr,"Ncalculs=%d\n",Ncalculs);*/
2863 /*fprintf(stderr,"%s\n",t);*/
2864 if(strstr(t,"[GEOCONV]") )
2865 {
2866 /* printf("OK GEOCONV %s\n",t);*/
2867 Ncalculs++;
2868 if(Ncalculs==1) GeomConv = g_malloc(sizeof(DataGeomConv) );
2869 else GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2870 GeomConv[Ncalculs-1] = init_geom_molden_gabedit_conv(FileName, type);
2871 GeomConv[Ncalculs-1].TypeCalcul = g_malloc(100*sizeof(gchar));
2872 GeomConv[Ncalculs-1].fileType = type;
2873 nn = sscanf(t,"%s %s", temp, GeomConv[Ncalculs-1].TypeCalcul);
2874 if(nn<2) sprintf(GeomConv[Ncalculs-1].TypeCalcul," ");
2875 if(!fgets(t,taille,fd)) break;
2876 uppercase(t);
2877 }
2878
2879 /* printf("%s\n",t);*/
2880
2881 if(Ncalculs>0 && strstr( t,"ENERGY"))
2882 {
2883 while(!feof(fd))
2884 {
2885 if(!fgets(t,taille,fd)) break;
2886
2887 str_delete_n(t);
2888 delete_last_spaces(t);
2889 delete_first_spaces(t);
2890 if(!isFloat(t))
2891 {
2892 /* printf("%s is not a real \n",t);*/
2893 break;
2894 }
2895 GeomConv[Ncalculs-1].Npoint++;
2896 if(GeomConv[Ncalculs-1].Npoint == 1 )
2897 {
2898 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2899 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2900 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2901 }
2902 else
2903 {
2904 GeomConv[Ncalculs-1].NumGeom = g_realloc(GeomConv[Ncalculs-1].NumGeom,GeomConv[Ncalculs-1].Npoint*sizeof(gint));
2905 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2906 GeomConv[Ncalculs-1].Data[i] = g_realloc(GeomConv[Ncalculs-1].Data[i],GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
2907 }
2908 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
2909 {
2910 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2911 GeomConv[Ncalculs-1].Data[i][GeomConv[Ncalculs-1].Npoint-1][0] = '\0';
2912 }
2913 GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1] = g_malloc(50*sizeof(gchar));
2914 sscanf(t,"%s", GeomConv[Ncalculs-1].Data[0][GeomConv[Ncalculs-1].Npoint-1]);
2915 }
2916 if(GeomConv[Ncalculs-1].Npoint<1) continue;
2917 }
2918 else if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0 && strstr( t,"MAX-FORCE"))
2919 {
2920 i = 0;
2921 while(!feof(fd))
2922 {
2923 if(!fgets(t,taille,fd)) break;
2924 if(i==GeomConv[Ncalculs-1].Npoint) break;
2925 str_delete_n(t);
2926 delete_last_spaces(t);
2927 delete_first_spaces(t);
2928 if(!isFloat(t)) break;
2929 sscanf(t,"%s", GeomConv[Ncalculs-1].Data[1][i]);
2930 i++;
2931 }
2932 GeomConv[Ncalculs-1].Npoint = i;
2933 }
2934 else if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0 && strstr( t,"RMS-FORCE"))
2935 {
2936 i = 0;
2937 while(!feof(fd))
2938 {
2939 if(!fgets(t,taille,fd)) break;
2940 if(i==GeomConv[Ncalculs-1].Npoint) break;
2941 str_delete_n(t);
2942 delete_last_spaces(t);
2943 delete_first_spaces(t);
2944 if(!isFloat(t)) break;
2945 sscanf(t,"%s", GeomConv[Ncalculs-1].Data[2][i]);
2946 i++;
2947 }
2948 GeomConv[Ncalculs-1].Npoint = i;
2949 }
2950 else if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0 && strstr( t,"MAX-STEP") )
2951 {
2952 i = 0;
2953 while(!feof(fd))
2954 {
2955 if(!fgets(t,taille,fd)) break;
2956 if(i==GeomConv[Ncalculs-1].Npoint) break;
2957 str_delete_n(t);
2958 delete_last_spaces(t);
2959 delete_first_spaces(t);
2960 if(!isFloat(t)) break;
2961 sscanf(t,"%s", GeomConv[Ncalculs-1].Data[3][i]);
2962 i++;
2963 }
2964 GeomConv[Ncalculs-1].Npoint = i;
2965 }
2966 else if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint>0 && strstr( t,"RMS-STEP"))
2967 {
2968 i = 0;
2969 while(!feof(fd))
2970 {
2971 if(!fgets(t,taille,fd)) break;
2972 if(i==GeomConv[Ncalculs-1].Npoint) break;
2973 str_delete_n(t);
2974 delete_last_spaces(t);
2975 delete_first_spaces(t);
2976 if(!isFloat(t)) break;
2977 sscanf(t,"%s", GeomConv[Ncalculs-1].Data[4][i]);
2978 i++;
2979 }
2980 GeomConv[Ncalculs-1].Npoint = i;
2981 }
2982 else if(!fgets(t,taille,fd)) break;
2983 }
2984
2985 fclose(fd);
2986
2987 if( Ncalculs>0 && GeomConv[Ncalculs-1].Npoint == 0)
2988 {
2989 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
2990 Ncalculs--;
2991 if(Ncalculs>0)
2992 GeomConv = g_realloc(GeomConv, Ncalculs*sizeof(DataGeomConv) );
2993 else
2994 {
2995 g_free(GeomConv);
2996 GeomConv = NULL;
2997 }
2998 }
2999 /*
3000 printf("Ncalculs = %d\n ",Ncalculs);
3001 if(Ncalculs>0)
3002 {
3003 printf("Npoint = %d\n ",GeomConv[Ncalculs-1].Npoint);
3004 printf("TypeCalcul = %s\n ",GeomConv[Ncalculs-1].TypeCalcul);
3005 for(i=0;i<GeomConv[Ncalculs-1].Npoint;i++)
3006 {
3007 for(j=0;j<GeomConv[Ncalculs-1].Ntype;j++)
3008 printf("%s ",GeomConv[Ncalculs-1].Data[j][i]);
3009 printf("\n ");
3010 }
3011 }
3012 */
3013
3014 k = 0;
3015 for(i=0;(gint)i<Ncalculs;i++)
3016 {
3017 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
3018 {
3019 k++;
3020 GeomConv[i].NumGeom[j] = k;
3021 }
3022 }
3023 create_energies_curves(GeomConv,Ncalculs);
3024 }
3025 /*************************************************************************************/
init_geom_gabedit_geoms(gchar * fileName,gint nLabels,gchar ** labels)3026 static DataGeomConv init_geom_gabedit_geoms(gchar *fileName, gint nLabels, gchar** labels)
3027 {
3028 DataGeomConv GeomConv;
3029 gint i;
3030 GeomConv.Npoint = 0;
3031 GeomConv.Ntype = nLabels;
3032 if(nLabels>0) GeomConv.TypeData = g_malloc(GeomConv.Ntype*sizeof(gchar*) );
3033 else GeomConv.TypeData = NULL;
3034 GeomConv.fileType = GABEDIT_TYPEFILE_GABEDIT;
3035 for(i=0;i<nLabels;i++) GeomConv.TypeData[i] = g_strdup(labels[i]);
3036 if(nLabels>0) GeomConv.Data = g_malloc(GeomConv.Ntype*sizeof(gchar**) );
3037 else GeomConv.Data = NULL;
3038 for(i = 0;i<GeomConv.Ntype;i++) GeomConv.Data[i] = NULL;
3039 GeomConv.TypeCalcul = NULL;
3040 GeomConv.NumGeom = NULL;
3041 GeomConv.GeomFile = g_strdup(fileName);
3042
3043 return GeomConv;
3044 }
3045 /*********************************************************************/
find_energy_gabedit_geoms(gchar * FileName)3046 static gint find_energy_gabedit_geoms(gchar* FileName)
3047 {
3048 guint i=0;
3049 guint j=0;
3050 guint k=0;
3051 gchar t[BSIZE];
3052 gchar dum1[BSIZE];
3053 gchar dum2[BSIZE];
3054 FILE *file;
3055 gint Ncalculs = 0;
3056 static DataGeomConv* GeomConv =NULL;
3057 gchar** labels = NULL;
3058 gint nGeometries = 0;
3059 gint nAtoms = 0;
3060 gint nLabels = 0;
3061 gboolean OK = FALSE;
3062 gchar* pdest = NULL;
3063
3064 file = FOpen(FileName, "rb");
3065 if(!file)
3066 {
3067 sprintf(t,_(" Error : I can not open file %s\n"),FileName);
3068 Message(t,_("Error"),TRUE);
3069 return -1;
3070 }
3071 OK = FALSE;
3072 while(!feof(file))
3073 {
3074 if(!fgets(t,BSIZE,file))break;
3075 pdest = strstr( t, "[GEOMS]");
3076 if (pdest)
3077 {
3078 if(!fgets(t,BSIZE,file))break;
3079 sscanf(t,"%d %d",&nGeometries, &nLabels);
3080 if(nGeometries<1)break;
3081 if(nLabels<1)break;
3082 labels = g_malloc(nLabels*sizeof(gchar*));
3083 for(i=0;i<nLabels;i++) labels[i] = NULL;
3084 for(i=0;i<nLabels;i++)
3085 {
3086 labels[i] = g_malloc(BSIZE*sizeof(gchar));
3087 if(!fgets(t,BSIZE,file))break;
3088 if(sscanf(t,"%s%s",dum1,dum2)!=2)break;
3089 sprintf(labels[i],"%s(%s)",dum1,dum2);
3090 }
3091 if(i!=nLabels)
3092 {
3093 for(i=0;i<nLabels;i++) if(labels[i]) g_free(labels[i]);
3094 if(labels) g_free(labels);
3095 break;
3096 }
3097 sscanf(labels[0],"%s",t);
3098 uppercase(t);
3099 if(!strstr(t,"ENERG"))
3100 {
3101 for(i=0;i<nLabels;i++) if(labels[i]) g_free(labels[i]);
3102 if(labels) g_free(labels);
3103 break;
3104 }
3105
3106 Ncalculs=1;
3107 GeomConv = g_malloc(sizeof(DataGeomConv) );
3108 GeomConv[Ncalculs-1] = init_geom_gabedit_geoms(FileName, nLabels,labels);
3109 for(i=0;i<nLabels;i++) if(labels[i]) g_free(labels[i]);
3110 if(labels) g_free(labels);
3111 GeomConv[Ncalculs-1].TypeCalcul = g_strdup(" ");
3112 GeomConv[Ncalculs-1].fileType = GABEDIT_TYPEFILE_GABEDIT;
3113 GeomConv[Ncalculs-1].Npoint = nGeometries;
3114 GeomConv[Ncalculs-1].NumGeom = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gint));
3115 for(i=0;(gint)i<GeomConv[Ncalculs-1].Ntype;i++)
3116 {
3117 GeomConv[Ncalculs-1].Data[i] = g_malloc(GeomConv[Ncalculs-1].Npoint*sizeof(gchar*));
3118 for(j=0;(gint)j<GeomConv[Ncalculs-1].Npoint;j++)
3119 GeomConv[Ncalculs-1].Data[i][j] = g_malloc(50*sizeof(gchar));
3120 }
3121 OK = TRUE;
3122 break;
3123 }
3124 }
3125 for(j=0;j<nGeometries;j++)
3126 {
3127 for(i=0;i<nLabels;i++)
3128 {
3129 if(!fgets(t,BSIZE,file))break;
3130 sscanf(t,"%s",GeomConv[Ncalculs-1].Data[i][j]);
3131 }
3132 if(i!=nLabels)
3133 {
3134 OK = FALSE;
3135 break;
3136 }
3137 if(!fgets(t,BSIZE,file))
3138 {
3139 OK = FALSE;
3140 break;
3141 }
3142 sscanf(t,"%d",&nAtoms);
3143
3144 for(i=0; i<nAtoms; i++)
3145 if(!fgets(t,BSIZE,file))break;
3146 if(i!=nAtoms)
3147 {
3148 OK = FALSE;
3149 break;
3150 }
3151 }
3152
3153 fclose(file);
3154 if(!OK)
3155 {
3156 if(Ncalculs>0)
3157 GeomConv[Ncalculs-1] = free_geom_conv(GeomConv[Ncalculs-1]);
3158 return 3;
3159 }
3160
3161 /*
3162 printf("Ncalculs = %d\n ",Ncalculs);
3163 if(Ncalculs>0)
3164 {
3165 printf("Npoint = %d\n ",GeomConv[Ncalculs-1].Npoint);
3166 printf("TypeCalcul = %s\n ",GeomConv[Ncalculs-1].TypeCalcul);
3167 for(i=0;i<GeomConv[Ncalculs-1].Npoint;i++)
3168 {
3169 for(j=0;j<GeomConv[Ncalculs-1].Ntype;j++)
3170 printf("%s ",GeomConv[Ncalculs-1].Data[j][i]);
3171 printf("\n ");
3172 }
3173 }
3174 */
3175
3176 k = 0;
3177 for(i=0;(gint)i<Ncalculs;i++)
3178 {
3179 for(j=0;(gint)j<GeomConv[i].Npoint;j++)
3180 {
3181 k++;
3182 GeomConv[i].NumGeom[j] = k;
3183 }
3184 }
3185 create_energies_curves(GeomConv,Ncalculs);
3186 return 0;
3187 }
3188 /*********************************************************************/
find_energy_molden(gchar * fileName)3189 void find_energy_molden(gchar* fileName)
3190 {
3191 find_energy_molden_gabedit(fileName,GABEDIT_TYPEFILE_MOLDEN);
3192 }
3193 /*********************************************************************/
find_energy_gabedit(gchar * fileName)3194 void find_energy_gabedit(gchar* fileName)
3195 {
3196 gint res = find_energy_gabedit_geoms(fileName);
3197 if(res == 0) return;
3198 if(res == -1) return;
3199 find_energy_molden_gabedit(fileName,GABEDIT_TYPEFILE_GABEDIT);
3200 }
3201 /*********************************************************************/
find_energy_gauss_output(gchar * fileName)3202 void find_energy_gauss_output(gchar* fileName)
3203 {
3204 GabEditTypeFile fileType = get_type_file(fileName);
3205 /* fprintf(stderr,"DEBUG : ktype = %d\n", fileType);*/
3206 if(fileType == GABEDIT_TYPEFILE_GAUSSIAN_SCANOPT) find_energy_gauss_scanOpt_output(fileName);
3207 else if(fileType == GABEDIT_TYPEFILE_GAUSSIAN_IRCOPT) find_energy_gauss_ircOpt_output(fileName);
3208 else find_energy_gauss_standard_output(fileName);
3209 }
3210 /*********************************************************************/
find_energy_all(GtkWidget * wid,gpointer data)3211 void find_energy_all(GtkWidget *wid,gpointer data)
3212 {
3213 gchar* fileName = g_strdup_printf("%s%s%s",fileopen.localdir,G_DIR_SEPARATOR_S,fileopen.logfile);
3214 if( iprogram == PROG_IS_GAMESS) find_energy_gamess_output(fileName);
3215 if( iprogram == PROG_IS_FIREFLY) find_energy_gamess_output(fileName);
3216 if( iprogram == PROG_IS_MPQC) find_energy_mpqc_output(fileName);
3217 if( iprogram == PROG_IS_MOLPRO) find_energy_molpro_log(fileName);
3218 if( iprogram == PROG_IS_ORCA) find_energy_orca_output(fileName);
3219 if( iprogram == PROG_IS_QCHEM) find_energy_qchem_log(fileName);
3220 if( iprogram == PROG_IS_NWCHEM) find_energy_nwchem_log(fileName);
3221 if( iprogram == PROG_IS_PSICODE) find_energy_psicode_log(fileName);
3222 if( iprogram == PROG_IS_DEMON)
3223 {
3224 gchar* fileName = g_strdup_printf("%s%s%s.molden",fileopen.localdir,G_DIR_SEPARATOR_S,fileopen.projectname);
3225 find_energy_molden(fileName);
3226 g_free(fileName);
3227 }
3228 if( iprogram == PROG_IS_MOPAC)
3229 {
3230 GabEditTypeFile fileType = GABEDIT_TYPEFILE_UNKNOWN;
3231 gint ng = 0;
3232 gchar* ext=strstr(fileName,".aux");
3233 ng = find_energy_mopac_aux(fileName);
3234 if(ng==1 && ext && strlen(ext)>=4)
3235 {
3236 ext[1]='o';
3237 ext[2]='u';
3238 ext[3]='t';
3239 fileType = get_type_file(fileName);
3240 if(fileType == GABEDIT_TYPEFILE_MOPAC_SCAN) find_energy_mopac_scan_output(fileName);
3241 if(fileType == GABEDIT_TYPEFILE_MOPAC_IRC) find_energy_mopac_irc_output(fileName);
3242 }
3243 }
3244 if( iprogram == PROG_IS_MOLCAS)
3245 {
3246 gchar* fileName = g_strdup_printf("%s%s%s.geo.molden",fileopen.localdir,G_DIR_SEPARATOR_S,fileopen.projectname);
3247 find_energy_molden(fileName);
3248 g_free(fileName);
3249 }
3250 if( iprogram == PROG_IS_GAUSS)
3251 {
3252 find_energy_gauss_output(fileName);
3253 }
3254 g_free(fileName);
3255 }
3256 /************************************************************************************/
read_geometries_conv_dalton(GabeditFileChooser * SelecFile,gint response_id)3257 void read_geometries_conv_dalton(GabeditFileChooser *SelecFile, gint response_id)
3258 {
3259 gchar *fileName;
3260
3261 if(response_id != GTK_RESPONSE_OK) return;
3262 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3263 if ((!fileName) || (strcmp(fileName,"") == 0))
3264 {
3265 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3266 return ;
3267 }
3268 find_energy_dalton_output(fileName);
3269 }
3270 /************************************************************************************/
read_geometries_conv_mopac(GabeditFileChooser * SelecFile,gint response_id)3271 void read_geometries_conv_mopac(GabeditFileChooser *SelecFile, gint response_id)
3272 {
3273 gchar *fileName;
3274
3275 if(response_id != GTK_RESPONSE_OK) return;
3276 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3277 if ((!fileName) || (strcmp(fileName,"") == 0))
3278 {
3279 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3280 return ;
3281 }
3282 find_energy_mopac_aux(fileName);
3283 }
3284 /************************************************************************************/
read_geometries_conv_mopac_irc(GabeditFileChooser * SelecFile,gint response_id)3285 void read_geometries_conv_mopac_irc(GabeditFileChooser *SelecFile, gint response_id)
3286 {
3287 gchar *fileName;
3288
3289 if(response_id != GTK_RESPONSE_OK) return;
3290 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3291 if ((!fileName) || (strcmp(fileName,"") == 0))
3292 {
3293 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3294 return ;
3295 }
3296 find_energy_mopac_irc_output(fileName);
3297 }
3298 /************************************************************************************/
read_geometries_conv_mopac_scan(GabeditFileChooser * SelecFile,gint response_id)3299 void read_geometries_conv_mopac_scan(GabeditFileChooser *SelecFile, gint response_id)
3300 {
3301 gchar *fileName;
3302
3303 if(response_id != GTK_RESPONSE_OK) return;
3304 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3305 if ((!fileName) || (strcmp(fileName,"") == 0))
3306 {
3307 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3308 return ;
3309 }
3310 find_energy_mopac_scan_output(fileName);
3311 }
3312 /************************************************************************************/
read_geometries_conv_gamess(GabeditFileChooser * SelecFile,gint response_id)3313 void read_geometries_conv_gamess(GabeditFileChooser *SelecFile, gint response_id)
3314 {
3315 gchar *fileName;
3316
3317 if(response_id != GTK_RESPONSE_OK) return;
3318 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3319 if ((!fileName) || (strcmp(fileName,"") == 0))
3320 {
3321 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3322 return ;
3323 }
3324 find_energy_gamess_output(fileName);
3325 }
3326 /************************************************************************************/
read_geometries_irc_gamess(GabeditFileChooser * SelecFile,gint response_id)3327 void read_geometries_irc_gamess(GabeditFileChooser *SelecFile, gint response_id)
3328 {
3329 gchar *fileName;
3330
3331 if(response_id != GTK_RESPONSE_OK) return;
3332 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3333 if ((!fileName) || (strcmp(fileName,"") == 0))
3334 {
3335 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3336 return ;
3337 }
3338 find_energy_gamess_irc(fileName);
3339 }
3340 /************************************************************************************/
read_geometries_conv_gaussian(GabeditFileChooser * SelecFile,gint response_id)3341 void read_geometries_conv_gaussian(GabeditFileChooser *SelecFile, gint response_id)
3342 {
3343 gchar *fileName;
3344
3345 if(response_id != GTK_RESPONSE_OK) return;
3346 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3347 if ((!fileName) || (strcmp(fileName,"") == 0))
3348 {
3349 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3350 return ;
3351 }
3352 find_energy_gauss_output(fileName);
3353 }
3354 /************************************************************************************/
read_geometries_conv_molpro(GabeditFileChooser * SelecFile,gint response_id)3355 void read_geometries_conv_molpro(GabeditFileChooser *SelecFile, gint response_id)
3356 {
3357 gchar *fileName;
3358
3359 if(response_id != GTK_RESPONSE_OK) return;
3360 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3361 if ((!fileName) || (strcmp(fileName,"") == 0))
3362 {
3363 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3364 return ;
3365 }
3366 find_energy_molpro_log(fileName);
3367 }
3368 /************************************************************************************/
read_geometries_conv_orca(GabeditFileChooser * SelecFile,gint response_id)3369 void read_geometries_conv_orca(GabeditFileChooser *SelecFile, gint response_id)
3370 {
3371 gchar *fileName;
3372
3373 if(response_id != GTK_RESPONSE_OK) return;
3374 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3375 if ((!fileName) || (strcmp(fileName,"") == 0))
3376 {
3377 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3378 return ;
3379 }
3380 find_energy_orca_output(fileName);
3381 }
3382 /************************************************************************************/
read_geometries_conv_vasp_outcar(GabeditFileChooser * SelecFile,gint response_id)3383 void read_geometries_conv_vasp_outcar(GabeditFileChooser *SelecFile, gint response_id)
3384 {
3385 gchar *fileName;
3386
3387 if(response_id != GTK_RESPONSE_OK) return;
3388 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3389 if ((!fileName) || (strcmp(fileName,"") == 0))
3390 {
3391 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3392 return ;
3393 }
3394 find_energy_vasp_outcar(fileName);
3395 }
3396 /************************************************************************************/
read_geometries_conv_vasp_xml(GabeditFileChooser * SelecFile,gint response_id)3397 void read_geometries_conv_vasp_xml(GabeditFileChooser *SelecFile, gint response_id)
3398 {
3399 gchar *fileName;
3400
3401 if(response_id != GTK_RESPONSE_OK) return;
3402 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3403 if ((!fileName) || (strcmp(fileName,"") == 0))
3404 {
3405 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3406 return ;
3407 }
3408 find_energy_vasp_xml(fileName);
3409 }
3410 /************************************************************************************/
read_geometries_conv_nwchem(GabeditFileChooser * SelecFile,gint response_id)3411 void read_geometries_conv_nwchem(GabeditFileChooser *SelecFile, gint response_id)
3412 {
3413 gchar *fileName;
3414
3415 if(response_id != GTK_RESPONSE_OK) return;
3416 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3417 if ((!fileName) || (strcmp(fileName,"") == 0))
3418 {
3419 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3420 return ;
3421 }
3422 find_energy_nwchem_log(fileName);
3423 }
3424 /************************************************************************************/
read_geometries_conv_psicode(GabeditFileChooser * SelecFile,gint response_id)3425 void read_geometries_conv_psicode(GabeditFileChooser *SelecFile, gint response_id)
3426 {
3427 gchar *fileName;
3428
3429 if(response_id != GTK_RESPONSE_OK) return;
3430 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3431 if ((!fileName) || (strcmp(fileName,"") == 0))
3432 {
3433 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3434 return ;
3435 }
3436 find_energy_psicode_log(fileName);
3437 }
3438 /************************************************************************************/
read_geometries_conv_qchem(GabeditFileChooser * SelecFile,gint response_id)3439 void read_geometries_conv_qchem(GabeditFileChooser *SelecFile, gint response_id)
3440 {
3441 gchar *fileName;
3442
3443 if(response_id != GTK_RESPONSE_OK) return;
3444 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3445 if ((!fileName) || (strcmp(fileName,"") == 0))
3446 {
3447 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3448 return ;
3449 }
3450 find_energy_qchem_log(fileName);
3451 }
3452 /*************************************************************************************/
read_geometries_conv_gabedit(GabeditFileChooser * SelecFile,gint response_id)3453 void read_geometries_conv_gabedit(GabeditFileChooser *SelecFile, gint response_id)
3454 {
3455 gchar *FileName;
3456
3457 if(response_id != GTK_RESPONSE_OK) return;
3458 FileName = gabedit_file_chooser_get_current_file(SelecFile);
3459 if ((!FileName) || (strcmp(FileName,"") == 0))
3460 {
3461 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3462 return ;
3463 }
3464 find_energy_gabedit(FileName);
3465 }
3466 /************************************************************************************/
read_geometries_conv_molden(GabeditFileChooser * SelecFile,gint response_id)3467 void read_geometries_conv_molden(GabeditFileChooser *SelecFile, gint response_id)
3468 {
3469 gchar *FileName;
3470
3471 if(response_id != GTK_RESPONSE_OK) return;
3472 FileName = gabedit_file_chooser_get_current_file(SelecFile);
3473 if ((!FileName) || (strcmp(FileName,"") == 0))
3474 {
3475 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3476 return ;
3477 }
3478 find_energy_molden(FileName);
3479 }
3480 /************************************************************************************/
read_geometries_conv_mpqc(GabeditFileChooser * SelecFile,gint response_id)3481 void read_geometries_conv_mpqc(GabeditFileChooser *SelecFile, gint response_id)
3482 {
3483 gchar *fileName;
3484
3485 if(response_id != GTK_RESPONSE_OK) return;
3486 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3487 if ((!fileName) || (strcmp(fileName,"") == 0))
3488 {
3489 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3490 return ;
3491 }
3492 find_energy_mpqc_output(fileName);
3493 }
3494 /************************************************************************************/
read_geometries_conv_xyz(GabeditFileChooser * SelecFile,gint response_id)3495 void read_geometries_conv_xyz(GabeditFileChooser *SelecFile, gint response_id)
3496 {
3497 gchar *fileName;
3498
3499 if(response_id != GTK_RESPONSE_OK) return;
3500 fileName = gabedit_file_chooser_get_current_file(SelecFile);
3501 if ((!fileName) || (strcmp(fileName,"") == 0))
3502 {
3503 Message(_("Sorry\n No selected file"),_("Error"),TRUE);
3504 return ;
3505 }
3506 find_energy_xyz(fileName);
3507 }
3508 /********************************************************************************/
3509 /********************************************************************************/
sensitive_password()3510 static void sensitive_password()
3511 {
3512 GtkWidget* Table;
3513 Table = g_object_get_data(G_OBJECT (ResultRemoteFrame), "PasswordTable");
3514 if(fileopen.netWorkProtocol==GABEDIT_NETWORK_FTP_RSH)
3515 gtk_widget_show(Table);
3516 else
3517 {
3518 #ifdef G_OS_WIN32
3519 gtk_widget_show(Table);
3520 #else
3521 gtk_widget_hide(Table);
3522 #endif
3523 }
3524 }
3525 /********************************************************************************/
sensitive_buttons_false()3526 static void sensitive_buttons_false()
3527 {
3528 sensitive_password();
3529 gtk_widget_set_sensitive(ResultRemoteFrame, FALSE);
3530 }
3531 /********************************************************************************/
sensitive_buttons_true()3532 static void sensitive_buttons_true()
3533 {
3534 sensitive_password();
3535 gtk_widget_set_sensitive(ResultRemoteFrame, TRUE);
3536 if(
3537 fileopen.remotehost && !this_is_a_backspace(fileopen.remotehost) &&
3538 fileopen.remoteuser && !this_is_a_backspace(fileopen.remoteuser)
3539 )
3540 {
3541 if(iprogram == PROG_IS_GAUSS)
3542 {
3543 GtkWidget* button = g_object_get_data(G_OBJECT(ResultRemoteFrame), "OutButton");
3544 gtk_widget_set_sensitive(button, FALSE);
3545 button = g_object_get_data(G_OBJECT(ResultRemoteFrame),"AuxButton");
3546 gtk_widget_set_sensitive(button, FALSE);
3547 }
3548 else
3549 {
3550 GtkWidget* button = g_object_get_data(G_OBJECT(ResultRemoteFrame),"OutButton");
3551 gtk_widget_set_sensitive(button, TRUE);
3552 button = g_object_get_data(G_OBJECT(ResultRemoteFrame),"AuxButton");
3553 gtk_widget_set_sensitive(button, TRUE);
3554 }
3555 }
3556 else
3557 gtk_widget_set_sensitive(ResultRemoteFrame, FALSE);
3558
3559
3560 }
3561 /*********************************************************************/
set_sensitive_remote_frame(gboolean sensitive)3562 void set_sensitive_remote_frame(gboolean sensitive)
3563 {
3564 if(sensitive)
3565 sensitive_buttons_true();
3566 else
3567 sensitive_buttons_false();
3568 }
3569 /*********************************************************************/
create_bar_result(GtkWidget * Vbox)3570 void create_bar_result(GtkWidget* Vbox)
3571 {
3572 GtkWidget *Button;
3573 GtkWidget *vboxframe;
3574 GtkWidget *frame;
3575 GtkWidget *handlebox;
3576 GtkWidget *vbox;
3577 GtkWidget *Table;
3578 /* GtkWidget *Label;*/
3579 GtkWidget *hseparator;
3580 static gint log = LOGFILE;
3581 static gint out = OUTFILE;
3582 static gint mol = MOLDENFILE;
3583 static gint all = ALLFILES;
3584
3585 /* here init_geom_gauss_conv();
3586 */
3587
3588 handlebox =gtk_handle_box_new ();
3589 g_object_ref (handlebox);
3590 gtk_container_add( GTK_CONTAINER (Vbox), handlebox);
3591 gtk_handle_box_set_shadow_type (GTK_HANDLE_BOX(handlebox),GTK_SHADOW_IN);
3592 /*
3593 GTK_SHADOW_NONE,
3594 GTK_SHADOW_IN,
3595 GTK_SHADOW_OUT,
3596 GTK_SHADOW_ETCHED_IN,
3597 GTK_SHADOW_ETCHED_OUT
3598 */
3599 gtk_handle_box_set_handle_position (GTK_HANDLE_BOX(handlebox),GTK_POS_TOP);
3600 gtk_widget_show (handlebox);
3601
3602 vbox = gtk_vbox_new (FALSE, 2);
3603 gtk_container_add( GTK_CONTAINER(handlebox), vbox);
3604 gtk_widget_show (vbox);
3605
3606 frame = gtk_frame_new ("Local");
3607 gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
3608 gtk_frame_set_shadow_type( GTK_FRAME(frame),GTK_SHADOW_ETCHED_OUT);
3609 gtk_box_pack_start (GTK_BOX(vbox), frame, FALSE, TRUE, 2);
3610 gtk_widget_show (frame);
3611
3612
3613 vboxframe = create_vbox(frame);
3614 ResultLocalFrame = frame;
3615
3616
3617
3618 /* The Update Button */
3619 Button = create_button(Fenetre,_("Update"));
3620 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3621 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3622 gtk_widget_grab_default(Button);
3623 gtk_widget_show(Button);
3624 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)view_result,NULL);
3625
3626 Button = create_button(Fenetre,_("Go to end"));
3627 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)goto_end_result,NULL);
3628 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3629 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3630 gtk_widget_show(Button);
3631
3632 Button = create_button(Fenetre,_("Update/end"));
3633 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)view_result_end,NULL);
3634 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3635 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3636 gtk_widget_show(Button);
3637
3638 Button = create_button(Fenetre,_("Geom. Conv."));
3639 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)find_energy_all,NULL);
3640 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3641 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3642 gtk_widget_show(Button);
3643
3644 Button = create_button(Fenetre,_("Dens. Orb."));
3645 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)draw_density_orbitals_gamess_or_gauss_or_molcas_or_molpro,NULL);
3646 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3647 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3648 gtk_widget_show(Button);
3649
3650 frame = gtk_frame_new (_("Remote"));
3651 gtk_container_set_border_width (GTK_CONTAINER (frame), 2);
3652 gtk_frame_set_shadow_type( GTK_FRAME(frame),GTK_SHADOW_ETCHED_OUT);
3653 gtk_box_pack_start (GTK_BOX(vbox), frame, FALSE, TRUE, 2);
3654 gtk_widget_show (frame);
3655 vboxframe = create_vbox(frame);
3656
3657 Table = gtk_table_new(3,1,FALSE);
3658 gtk_container_add(GTK_CONTAINER(vboxframe),Table);
3659 gtk_widget_show_all(vboxframe);
3660 /* Label = add_label_table(Table,_("Password : "),0,0);*/
3661 add_label_table(Table,_("Password : "),0,0);
3662 ResultEntryPass = gtk_entry_new();
3663 gtk_entry_set_max_length (GTK_ENTRY(ResultEntryPass),15);
3664 gtk_widget_set_size_request (ResultEntryPass,(gint)(ScreenHeight*0.05),-1);
3665 gtk_entry_set_visibility(GTK_ENTRY (ResultEntryPass),FALSE);
3666
3667 gtk_table_attach(GTK_TABLE(Table),ResultEntryPass,0,1,1,2,
3668 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
3669 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
3670 1,1);
3671 hseparator = gtk_hseparator_new ();
3672 gtk_table_attach(GTK_TABLE(Table),hseparator,0,1,2,3,
3673 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
3674 (GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
3675 1,1);
3676
3677
3678 ResultRemoteFrame = frame;
3679 gtk_widget_set_sensitive(ResultRemoteFrame, FALSE);
3680 g_object_set_data(G_OBJECT (ResultRemoteFrame), "PasswordTable",Table);
3681
3682 Button = create_button(Fenetre,_("Get All files"));
3683 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)get_file_frome_remote_host,&all);
3684 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3685 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3686 gtk_widget_show(Button);
3687 g_object_set_data(G_OBJECT (ResultRemoteFrame), "AllButton",Button);
3688 g_signal_connect_swapped(G_OBJECT (ResultEntryPass), "activate",
3689 (GCallback) gtk_button_clicked,
3690 GTK_OBJECT (Button));
3691
3692 Button = create_button(Fenetre,_("Get log file"));
3693 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)get_file_frome_remote_host,&log);
3694 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3695 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3696 gtk_widget_show(Button);
3697 g_object_set_data(G_OBJECT (ResultRemoteFrame), "LogButton",Button);
3698
3699 Button = create_button(Fenetre,_("Get out file"));
3700 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)get_file_frome_remote_host,&out);
3701
3702 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3703 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3704 gtk_widget_show(Button);
3705 g_object_set_data(G_OBJECT (ResultRemoteFrame), "OutButton",Button);
3706
3707 Button = create_button(Fenetre,_("Get aux. files"));
3708 g_signal_connect(G_OBJECT(Button), "clicked",(GCallback)get_file_frome_remote_host,&mol);
3709
3710 gtk_box_pack_start (GTK_BOX(vboxframe ), Button, FALSE, TRUE, 2);
3711 GTK_WIDGET_SET_FLAGS(Button, GTK_CAN_DEFAULT);
3712 gtk_widget_show(Button);
3713 g_object_set_data(G_OBJECT (ResultRemoteFrame), "AuxButton",Button);
3714 }
3715
3716