atomes 1.3.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
open_p.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2026 by CNRS and University of Strasbourg */
15
21
22/*
23* This file: 'open_p.c'
24*
25* Contains:
26*
27
28 - The functions to start the reading of an atomes project file
29
30*
31* List of functions:
32
33 int read_analysis (FILE * fp, project * this_proj, atomes_analysis * this_analysis, int wid);
34 int open_project (FILE * fp, int wid);
35
36 char * read_string (int i, FILE * fp);
37
38 gchar * read_this_string (FILE * fp);
39
40 void initcnames (project * this_proj, int rid);
41 void allocatoms (project * this_proj);
42 void alloc_proj_data (project * this_proj, int cid);
43
44 chemical_data * alloc_chem_data (int spec);
45
46*/
47
48#include "global.h"
49#include "bind.h"
50#include "interface.h"
51#include "callbacks.h"
52#include "project.h"
53#include "curve.h"
54#include "glview.h"
55#include "movie.h"
56#include "preferences.h"
57
58extern void init_box_calc ();
59extern void set_color_map_sensitive (glwin * view);
60extern void init_gr (project * this_proj, int rdf);
61extern void init_sq (project * this_proj, int sqk);
62extern void init_bond (project * this_proj);
63extern void init_ang (project * this_proj);
64extern void init_ring (project * this_proj);
65extern void init_chain (project * this_proj);
66extern void init_msd (project * this_proj);
67extern void init_sph (project * this_proj, int opening);
68extern void init_skt (project * this_proj, int opening);
69extern void alloc_analysis_curves (int pid, atomes_analysis * this_analysis);
70extern void add_curve_widgets (project * this_proj, int rid);
71
72extern G_MODULE_EXPORT void run_render_image (GtkDialog * info, gint response_id, gpointer data);
73
80
89char * read_string (int i, FILE * fp)
90{
91 char * tmp = NULL;
92 tmp = g_malloc0(i*sizeof*tmp);
93 int j;
94 for (j=0; j<i; j++)
95 {
96 tmp[j] = fgetc(fp);
97 }
98 //return fgets (tmp, i+1, fp);
99 return tmp;
100}
101
109gchar * read_this_string (FILE * fp)
110{
111 int i;
112 if (fread (& i, sizeof(int), 1, fp) != 1) return NULL;
113 if (i > 0)
114 {
115 gchar * str = read_string (i, fp);
116 return str;
117 }
118 return NULL;
119}
120
121
130void initcnames (project * this_proj, int rid)
131{
132 switch (rid)
133 {
134 case GDR:
135 init_gr (this_proj, rid);
136 break;
137 case SQD:
138 init_sq (this_proj, rid);
139 break;
140 case SKD:
141 init_sq (this_proj, rid);
142 break;
143 case GDK:
144 init_gr (this_proj, rid);
145 break;
146 case BND:
147 init_bond (this_proj);
148 break;
149 case ANG:
150 init_ang (this_proj);
151 break;
152 case RIN:
153 init_ring (this_proj);
154 break;
155 case CHA:
156 init_chain (this_proj);
157 break;
158 case SPH:
159 init_sph (this_proj, 1);
160 break;
161 case MSD:
162 init_msd (this_proj);
163 break;
164 case SKT:
165 init_skt (this_proj, 1);
166 break;
167 }
168}
169
177void allocatoms (project * this_proj)
178{
179 int i, j;
180 if (this_proj -> atoms != NULL)
181 {
182 g_free (this_proj -> atoms);
183 this_proj -> atoms = NULL;
184 }
185 this_proj -> atoms = g_malloc0(this_proj -> steps*sizeof*this_proj -> atoms);
186 for (i=0; i < this_proj -> steps; i++)
187 {
188 this_proj -> atoms[i] = g_malloc0(this_proj -> natomes*sizeof*this_proj -> atoms[i]);
189 for (j=0; j<this_proj -> natomes; j++)
190 {
191 this_proj -> atoms[i][j].style = NONE;
192 }
193 }
194}
195
204{
205 chemical_data * chem = g_malloc0(sizeof*chem);
206 chem -> label = g_malloc0(spec*sizeof*chem -> label);
207 chem -> element = g_malloc0(spec*sizeof*chem -> element);
208 chem -> nsps = allocint (spec);
209 chem -> formula = allocint (spec);
210 chem -> grtotcutoff = default_totcut;
211 chem -> cutoffs = allocddouble (spec, spec);
212 chem -> chem_prop = allocddouble (CHEM_PARAMS, spec);
213 return chem;
214}
215
224void alloc_proj_data (project * this_proj, int cid)
225{
226 if (cid) this_proj -> chemistry = alloc_chem_data (this_proj -> nspec);
227 allocatoms (this_proj);
228}
229
240int read_analysis (FILE * fp, project * this_proj, atomes_analysis * this_analysis, int wid)
241{
242 int i, j;
243 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
244 if (i != this_analysis -> aid)
245 {
246 // This is not supposed to happen
247 return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
248 }
249 this_analysis -> name = read_this_string (fp);
250 if (! this_analysis -> name) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
251 if (fread (& this_analysis -> avail_ok, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
252 if (fread (& this_analysis -> init_ok, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
253 if (fread (& this_analysis -> calc_ok, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
254 if (fread (& this_analysis -> requires_md, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
255 if (fread (& this_analysis -> num_delta, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
256 if (fread (& this_analysis -> delta, sizeof(double), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
257 if (fread (& this_analysis -> min, sizeof(double), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
258 if (fread (& this_analysis -> max, sizeof(double), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
259 if (fread (& this_analysis -> fact, sizeof(double), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
260 if (fread (& this_analysis -> graph_res, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
261 if (this_analysis -> graph_res)
262 {
263 if (fread (& this_analysis -> numc, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
264 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
265 if (i != this_analysis -> c_sets)
266 {
267 // This is not supposed to happen
268 return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
269 }
270 if (fread (this_analysis -> compat_id, sizeof(int), this_analysis -> c_sets, fp) != this_analysis -> c_sets) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
271 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
272 if (i)
273 {
274 this_analysis -> x_title = read_this_string (fp);
275 if (! this_analysis -> x_title) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
276 }
277 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_ANA);
278 if (i)
279 {
280 initcnames (this_proj, this_analysis -> aid);
281 for (j=0; j<i; j++)
282 {
283 // g_debug ("Reading :: analysis= %s, aid= %d, j= %d", this_analysis -> name, this_analysis -> aid, j);
284 if (read_project_curve (fp, wid, this_proj -> id) != OK)
285 {
286 update_error_trace (__FILE__, __func__, __LINE__-2);
287 // g_debug ("Error :: analysis= %s, aid= %d, j= %d", this_analysis -> name, this_analysis -> aid, j);
288 return ERROR_CURVE;
289 }
290 if (this_analysis -> aid == SPH)
291 {
292 init_curve_title (this_proj, SPH, j);
293 }
294 }
295 }
296 }
297 return OK;
298}
299
308int open_project (FILE * fp, int wid)
309{
310 int i, j, k;
311 gchar * version;
312
313 version = read_this_string (fp);
314 if (! version) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
315
317 if (sscanf(version, "%*[^0-9]%f", & project_file_version) != 1)
318 {
319 return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
320 }
321 version_2_6_and_above = FALSE;
322 version_2_7_and_above = FALSE;
323 version_2_8_and_above = FALSE;
324 version_2_9_and_above = FALSE;
325
326 int calcs_to_read;
327
328 // Start version related tests
329 if (g_strcmp0(version, "%\n% project file v-2.6\n%\n") == 0)
330 {
332 }
333 else if (g_strcmp0(version, "%\n% project file v-2.7\n%\n") == 0)
334 {
337 }
338 else if (g_strcmp0(version, "%\n% project file v-2.8\n%\n") == 0)
339 {
343 }
344 else if (g_strcmp0(version, "%\n% project file v-2.9\n%\n") == 0)
345 {
350 }
351 // End version related tests
352
353 // Ensure file compatibility with STEP_LIMIT for atomes version < 1.3.0
355 // Temporary buffers for version compatibility < 2.9
356 gboolean * tmp_avail, * tmp_init, * tmp_calc;
357 int * tmp_num_delta;
358 double * tmp_delta;
359 double * tmp_min;
360 double * tmp_max;
361
362 #ifdef DEBUG
363 g_debug ("%s", version);
364 #endif // DEBUG
365 g_free (version);
366
367 // After that we read the data
369 if (active_project -> name == NULL) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
370#ifdef DEBUG
371 g_debug ("OPEN_PROJECT: Project name= %s",active_project -> name);
372#endif
373 if (fread (& active_project -> tfile, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
374 if (active_project -> tfile > -1)
375 {
376 active_project -> coordfile = read_this_string (fp);
377 if (active_project -> coordfile == NULL) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
378 }
379 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
380 if (i > -1)
381 {
382 active_project -> bondfile = read_this_string (fp);
383 if (active_project -> bondfile == NULL) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
384 }
386 {
387 if (fread (& calcs_to_read, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
388 }
389 else
390 {
391 // NCALCS was first set to 10
392 calcs_to_read = 10;
393 // We need temporary buffers to read this data
394 tmp_avail = allocbool (calcs_to_read);
395 tmp_init = allocbool (calcs_to_read);
396 tmp_calc = allocbool (calcs_to_read);
397 if (fread (tmp_avail, sizeof(gboolean), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
398 if (fread (tmp_init, sizeof(gboolean), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
399 if (fread (tmp_calc, sizeof(gboolean), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
400 }
401 if (fread (& active_project -> nspec, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
402 if (fread (& active_project -> natomes, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
403 if (fread (& active_project -> steps, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
404 if (fread (& active_cell -> pbc, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
405 if (fread (& active_cell -> frac, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
406 if (fread (& active_cell -> ltype, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
407 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
408 if (i > 1 && i != active_project -> steps) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
409 if (i > 1) active_cell -> npt = TRUE;
410 active_cell -> box = g_malloc0(i*sizeof*active_cell -> box);
411 active_box = & active_cell -> box[0];
412 for (j=0; j<i; j++)
413 {
414 for (k=0; k<3; k++)
415 {
416 if (fread (active_cell -> box[j].vect[k], sizeof(double), 3, fp) != 3) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
417 }
418 if (fread (active_cell -> box[j].param[0], sizeof(double), 3, fp) != 3) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
419 if (fread (active_cell -> box[j].param[1], sizeof(double), 3, fp) != 3) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
420 }
421 if (fread (& active_cell -> crystal, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
422 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
423 if (active_cell -> crystal && i)
424 {
425 active_cell -> sp_group = g_malloc0(sizeof*active_cell -> sp_group);
426 active_cell -> sp_group -> id = i;
427 active_cell -> sp_group -> bravais = read_this_string (fp);
428 if (! active_cell -> sp_group -> bravais) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
429 active_cell -> sp_group -> hms = read_this_string (fp);
430 if (! active_cell -> sp_group -> hms) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
431 active_cell -> sp_group -> setting = read_this_string (fp);
432 if (! active_cell -> sp_group -> setting) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
433 }
434 if (fread (& active_project -> run, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
435 if (fread (& active_project -> initgl, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
436 if (fread (active_project -> tmp_pixels, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
439 {
440 // Temporary buffers again
441 tmp_num_delta = allocint (calcs_to_read);
442 tmp_delta = allocdouble (calcs_to_read);
443 if (fread (tmp_num_delta, sizeof(int), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
444 if (fread (tmp_delta, sizeof(double), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
445 }
446 else
447 {
448 // Analysis data for k-points sampling
449 for (i=0; i<2; i++)
450 {
451 if (fread (active_project -> sk_advanced[i], sizeof(double), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
452 }
453 }
454 if (fread (active_project -> rsearch, sizeof(int), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
455 for (i=0; i<5; i++)
456 {
457 if (fread (active_project -> rsparam[i], sizeof(int), 6, fp) != 6) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
458 if (fread (active_project -> rsdata[i], sizeof(double), 5, fp) != 5) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
459 }
460 if (fread (& active_project -> csearch, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
461 if (fread (active_project -> csparam, sizeof(int), 7, fp) != 7) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
462 if (fread (active_project -> csdata, sizeof(double), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
464 {
465 // Temporary buffers again
466 tmp_min = allocdouble (calcs_to_read);
467 tmp_max = allocdouble (calcs_to_read);
468 if (fread (tmp_min, sizeof(double), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
469 if (fread (tmp_max, sizeof(double), calcs_to_read, fp) != calcs_to_read) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
470 }
471 if (fread (& active_project -> tunit, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
473 {
474 if (active_project -> steps)
475 {
476 if (fread (& active_project -> skt_corr_threshold, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
477 if (fread (& active_project -> skt_all_sets, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
479 {
480 if (fread (& active_project -> skt_n_data_sets, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
481 if (active_project -> skt_n_data_sets)
482 {
483 active_project -> skt_step_id = allocint (active_project -> skt_n_data_sets);
484 if (fread (active_project -> skt_step_id, sizeof(int), active_project -> skt_n_data_sets, fp) != active_project -> skt_n_data_sets) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
485 }
486 }
487 if (fread (& active_project -> sqw_n_data_sets, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
488 if (active_project -> sqw_n_data_sets)
489 {
490 active_project -> sqw_q_id = allocdouble (active_project -> sqw_n_data_sets);
491 if (fread (active_project -> sqw_q_id, sizeof(double), active_project -> sqw_n_data_sets, fp) != active_project -> sqw_n_data_sets) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
492 }
493 if (fread (& active_project -> sqw_freq, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
494 }
495 }
496 if (! active_project -> natomes || ! active_project -> nspec)
497 {
498 return signal_error (__FILE__, __func__, __LINE__-2, ERROR_NO_WAY);
499 }
500 else
501 {
505 {
506 for (i=0; i<active_project -> nspec; i++)
507 {
508 active_chem -> label[i] = read_this_string (fp);
509 if (! active_chem -> label[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
511 if (! active_chem -> element[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
512 }
513 }
514 if (fread (active_chem -> nsps, sizeof(int), active_project -> nspec, fp) != active_project -> nspec) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
515 if (fread (active_chem -> formula, sizeof(int), active_project -> nspec, fp) != active_project -> nspec) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
516 j = 0;
517 for (i=0; i<active_project -> nspec; i++) j+= active_chem -> nsps[i];
518 if (j != active_project -> natomes) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
519 for (i=0; i<CHEM_PARAMS; i++)
520 {
521 if (fread (active_chem -> chem_prop[i], sizeof(double), active_project -> nspec, fp) != active_project -> nspec) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
522 }
524 {
525 for (i=0; i<active_project -> nspec; i++)
526 {
527 active_chem -> chem_prop[CHEM_X][i] = active_chem -> chem_prop[CHEM_Z][i];
528 }
529 }
530 if (fread (& active_chem -> grtotcutoff, sizeof(double), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
531 for ( i = 0 ; i < active_project -> nspec ; i ++ )
532 {
533 if (fread (active_chem -> cutoffs[i], sizeof(double), active_project -> nspec, fp) != active_project -> nspec) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
534 }
535 for (i=0; i<active_project -> steps; i++)
536 {
537 for (j=0; j< active_project -> natomes; j++)
538 {
539 if (read_atom_a (fp, active_project, i, j) != OK)
540 {
541 update_error_trace (__FILE__, __func__, __LINE__-2);
542 return ERROR_ATOM_A;
543 }
544 }
545 }
546 init_box_calc ();
547 if (active_project -> run)
548 {
549#ifdef DEBUG
550 g_debug ("OPEN_PROJECT:: So far so good ... still");
551 g_debug ("OPEN_PROJECT:: RUN PROJECT\n");
552#endif
553 i = alloc_data_ (& active_project -> natomes,
554 & active_project -> nspec,
555 & active_project -> steps);
556 if (i == 1)
557 {
559 {
560 j = 1;
561 prep_spec_ (active_chem -> chem_prop[CHEM_Z], active_chem -> nsps, & j);
562 }
563 // Read curves
566 {
567 for (i=0; i<calcs_to_read; i++)
568 {
569 if (active_project -> analysis[i])
570 {
571 if (read_analysis (fp, active_project, active_project -> analysis[i], wid) != OK)
572 {
573 update_error_trace (__FILE__, __func__, __LINE__-2);
574 return ERROR_ANA;
575 }
576 }
577 }
578 }
579 else
580 {
581 for (i=0; i<calcs_to_read; i++)
582 {
583 if (active_project -> analysis[i])
584 {
585 active_project -> analysis[i] -> avail_ok = tmp_avail[i];
586 active_project -> analysis[i] -> init_ok = tmp_init[i];
587 active_project -> analysis[i] -> calc_ok = tmp_calc[i];
588 active_project -> analysis[i] -> delta = tmp_delta[i];
589 active_project -> analysis[i] -> num_delta = tmp_num_delta[i];
590 active_project -> analysis[i] -> min = tmp_min[i];
591 active_project -> analysis[i] -> max = tmp_max[i];
592 if (active_project -> analysis[i] -> init_ok)
593 {
595 }
596 }
597 }
598 g_free (tmp_avail);
599 g_free (tmp_init);
600 g_free (tmp_calc);
601 g_free (tmp_delta);
602 g_free (tmp_num_delta);
603 g_free (tmp_min);
604 g_free (tmp_max);
605 if (fread (& i, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
606#ifdef DEBUG
607 g_debug ("\n**********************************************\n curves to read= %d\n**********************************************\n", i);
608#endif
609 if (i != 0)
610 {
611 j = 0;
612 if (fread (& j, sizeof(int), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
613 if (j)
614 {
615 active_project -> analysis[SPH] -> numc = j;
618 active_project -> analysis[SPH] -> avail_ok = TRUE;
619 for (k=0; k<j; k++)
620 {
621 active_project -> analysis[SPH] -> curves[k] -> name = read_this_string (fp);
622 if (active_project -> analysis[SPH] -> curves[k] -> name == NULL) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
623 }
624 }
625 for (j=0; j<i; j++)
626 {
627 if (read_project_curve (fp, wid, activep) != OK)
628 {
629 update_error_trace (__FILE__, __func__, __LINE__-2);
630 return ERROR_CURVE;
631 }
632 }
633 }
634 }
636 }
637 else
638 {
639 return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
640 }
641 }
642 }
643#ifdef DEBUG
644 // debugioproj (active_project, "READ INIT");
645#endif
646 if (update_project() != 1)
647 {
648 update_error_trace (__FILE__, __func__, __LINE__-3);
649 return ERROR_UPDATE;
650 }
651 else
652 {
653 if (active_project -> initgl)
654 {
655 gboolean tmp_bonding;
656 if (fread (& tmp_bonding, sizeof(gboolean), 1, fp) != 1) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
657 if (fread (tmp_adv_bonding, sizeof(gboolean), 2, fp) != 2) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
658 apply_project (TRUE);
660 int tmpcoord[10];
661 if (fread (tmpcoord, sizeof(int), 10, fp) != 10) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
662 if (active_glwin -> bonding)
663 {
664 // for (i=0; i<10; i++) g_debug ("READING :: i= %d, tmpcoord[%d]= %d, active_coord -> totcoord[%d]= %d", i, i, tmpcoord[i], i, active_coord -> totcoord[i]);
665 for (i=0; i<2; i++) if (tmpcoord[i] != active_coord -> totcoord[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
666 for (i=2; i<4; i++)
667 {
668 if (active_glwin -> adv_bonding[i-2])
669 {
670 if (tmpcoord[i] != active_coord -> totcoord[i]) return signal_error (__FILE__, __func__, __LINE__, ERROR_PROJECT);
671 }
672 }
673 }
674 for (i=0; i<10; i++) active_coord -> totcoord[i] = tmpcoord[i];
675 // Read molecule info
676 if ((active_project -> natomes > ATOM_LIMIT || active_project -> steps > reading_step_limit) && tmp_adv_bonding[1])
677 {
678 if (read_mol (fp) != OK)
679 {
680 update_error_trace (__FILE__, __func__, __LINE__-2);
681 return ERROR_MOL;
682 }
683 }
684 for (i=0; i<2; i++) active_glwin -> adv_bonding[i] = tmp_adv_bonding[i];
685 active_glwin -> bonding = tmp_bonding;
686
687 if (read_bonding (fp) != OK)
688 {
689 update_error_trace (__FILE__, __func__, __LINE__-2);
690 return ERROR_COORD;
691 }
692
693 if (read_opengl_image (fp, active_project, active_glwin -> anim -> last -> img, active_project -> nspec) != OK)
694 {
695 update_error_trace (__FILE__, __func__, __LINE__-2);
696 return ERROR_IMAGE;
697 }
698
700 {
701 update_error_trace (__FILE__, __func__, __LINE__-2);
702 return ERROR_FIELD;
703 }
705 {
706 update_error_trace (__FILE__, __func__, __LINE__-2);
707 return ERROR_FIELD;
708 }
709
710 for (i=0; i<2; i++)
711 {
712 if (read_cpmd_data (fp, i, active_project) != OK)
713 {
714 update_error_trace (__FILE__, __func__, __LINE__-2);
715 return ERROR_QM;
716 }
717 }
718 for (i=0; i<2; i++)
719 {
720 if (read_cp2k_data (fp, i, active_project) != OK)
721 {
722 update_error_trace (__FILE__, __func__, __LINE__-2);
723 return ERROR_QM;
724 }
725 }
726#ifdef GTK3
727 // GTK3 Menu Action To Check
729#endif
730 return OK;
731 }
732 return OK;
733 }
734}
Binding to the Fortran90 subroutines.
void prep_spec_(double *, int *, int *)
int alloc_data_(int *, int *, int *)
integer(kind=c_int) function bonding(scf, sbf, adv, bdist, bmin, delt_ij, sfil)
Definition bonds.F90:22
void apply_project(gboolean showtools)
get project ready for calculation and initialize the OpenGL window
Definition callbacks.c:794
Callback declarations for main window.
void fill_tool_model()
fill the tool window tree model
Definition tools.c:91
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
gchar * param[2]
Variable declarations for the curve widget Functions for interactions with the curve widget.
void init_curve_title(project *this_proj, int rid, int cid)
init curve title and axis titles
Definition cwidget.c:260
int atoms[NUM_STYLES][2]
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:547
FILE * fp
int activep
Definition global.c:162
gboolean * allocbool(int val)
allocate a gboolean * pointer
Definition global.c:241
gboolean tmp_adv_bonding[2]
Definition global.c:187
double ** allocddouble(int xal, int yal)
allocate a double ** pointer
Definition global.c:462
double * allocdouble(int val)
allocate a double * pointer
Definition global.c:446
gboolean atomes_render_image
Definition global.c:196
int * allocint(int val)
allocate an int * pointer
Definition global.c:301
int reading_step_limit
Definition global.c:172
int tmp_pixels[2]
Definition global.c:177
Global variable declarations Global convenience function declarations Global data structure defin...
#define SKT
Definition global.h:347
int signal_error(const char *file, const char *func, int error_line, int error_id)
Definition callbacks.c:182
glwin * active_glwin
Definition project.c:53
#define SQD
Definition global.h:338
#define ATOM_LIMIT
atom number limit to compute fragment(s) and molecule(s) analysis automatically
coord_info * active_coord
Definition project.c:49
cell_info * active_cell
Definition project.c:50
#define RIN
Definition global.h:343
#define ERROR_UPDATE
Definition global.h:302
chemical_data * active_chem
Definition project.c:48
#define SPH
Definition global.h:345
#define ERROR_CURVE
Definition global.h:298
#define STEP_LIMIT
Definition global.h:293
#define ERROR_PROJECT
Definition global.h:297
#define ERROR_FIELD
#define CHEM_PARAMS
Definition global.h:315
box_info * active_box
Definition project.c:51
#define ANG
Definition global.h:342
#define ERROR_IMAGE
Definition global.h:299
#define CHA
Definition global.h:344
#define SKD
Definition global.h:339
#define ERROR_ATOM_A
Definition global.h:300
#define BND
Definition global.h:341
#define OK
Definition global.h:295
#define min(a, b)
Definition global.h:93
#define ERROR_COORD
Definition global.h:304
#define ERROR_MOL
Definition global.h:307
#define CHEM_X
Definition global.h:320
#define ERROR_ANA
Definition global.h:308
#define CHEM_Z
Definition global.h:316
void update_error_trace(const char *file, const char *func, int trace_line)
Definition callbacks.c:200
#define GDK
Definition global.h:340
project * active_project
Definition project.c:47
#define ERROR_QM
Definition global.h:309
#define MSD
Definition global.h:346
#define GDR
Definition global.h:337
#define ERROR_NO_WAY
Definition global.h:303
#define max(a, b)
Definition global.h:92
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
@ NONE
Definition glview.h:181
int * render_image_pixels
Definition image.c:88
void init_atomes_analysis(project *this_proj, gboolean apply_defaults)
initialize analysis data structures for atomes
Definition initc.c:223
Messaging function declarations.
Data structure declarations for movie encoding Function declarations for movie encoding.
void init_chain(project *this_proj)
initialize the curve widgets for the chains statistics calculation
Definition chainscall.c:70
void initcnames(project *this_proj, int rid)
initialize curve names
Definition open_p.c:130
gboolean version_2_8_and_above
Definition open_p.c:78
void set_color_map_sensitive(glwin *view)
char * read_string(int i, FILE *fp)
read a string from a file
Definition open_p.c:89
void init_ang(project *this_proj)
initialize the curve widgets for the angle distribution
Definition bdcall.c:170
gchar * read_this_string(FILE *fp)
is there a string to read in this file ? yes do it
Definition open_p.c:109
void add_curve_widgets(project *this_proj, int rid)
add curve widgets to the project
Definition cwidget.c:283
float project_file_version
Definition open_p.c:74
void init_gr(project *this_proj, int rdf)
initialize the curve widgets for the g(r)/g(k)
Definition grcall.c:66
int open_project(FILE *fp, int wid)
open atomes project file
Definition open_p.c:308
void init_skt(project *this_proj, int opening)
initialize the curve widgets for the s(k,t) and s(q,w) calculations
Definition sktcall.c:158
G_MODULE_EXPORT void run_render_image(GtkDialog *info, gint response_id, gpointer data)
render an image from the OpenGL window - running the dialog
Definition image.c:114
chemical_data * alloc_chem_data(int spec)
allocate chemistry data
Definition open_p.c:203
void init_sph(project *this_proj, int opening)
initialize the curve widgets for the spherical harmonics
Definition spcall.c:59
gboolean version_2_9_and_above
Definition open_p.c:79
gboolean version_2_7_and_above
Definition open_p.c:77
void init_box_calc()
initialize calculation possibilities based the periodicity
Definition edit_menu.c:541
void allocatoms(project *this_proj)
allocate project data
Definition open_p.c:177
void alloc_analysis_curves(int pid, atomes_analysis *this_analysis)
allocating analysis curve data
Definition initc.c:134
gboolean version_2_5_and_bellow
Definition open_p.c:75
gboolean version_2_6_and_above
Definition open_p.c:76
void alloc_proj_data(project *this_proj, int cid)
allocate data
Definition open_p.c:224
void init_bond(project *this_proj)
initialize the curve widgets for the bond distribution
Definition bdcall.c:146
void init_msd(project *this_proj)
initialize the curve widgets for the MSD
Definition msdcall.c:59
void init_sq(project *this_proj, int sqk)
initialize the curve widgets for the s(q) / s(k) calculation
Definition sqcall.c:61
void init_ring(project *this_proj)
initialize the curve widgets for the ring statistics
Definition ringscall.c:83
int read_analysis(FILE *fp, project *this_proj, atomes_analysis *this_analysis, int wid)
saving analysis parameter(s) and result(s) to project file
Definition open_p.c:240
int * tmp_num_delta
double default_totcut
Preference variable declarations.
Function declarations for reading atomes project file Function declarations for saving atomes proje...
int read_dlp_field_data(FILE *fp, project *this_proj)
read force field data from file
Definition read_field.c:496
int read_mol(FILE *fp)
read molecule(s) information from file
Definition read_mol.c:92
int read_lmp_field_data(FILE *fp, project *this_proj)
read LAMMPS field data from file
Definition read_field.c:627
int read_project_curve(FILE *fp, int wid, int pid)
read a project curve from file
Definition read_curve.c:77
int read_opengl_image(FILE *fp, project *this_proj, image *img, int sid)
read OpenGL image properties from file
int update_project()
update project: send data to Fortran90, and update calculation interactors
Definition update_p.c:162
int read_cpmd_data(FILE *fp, int cid, project *this_proj)
read CPMD data from file
Definition read_qm.c:133
int read_atom_a(FILE *fp, project *this_proj, int s, int a)
read atom properties from file (a)
Definition read_opengl.c:62
int read_bonding(FILE *fp)
read bonding information from file
Definition read_bond.c:52
int read_cp2k_data(FILE *fp, int cid, project *this_proj)
read CP2K data from file
Definition read_qm.c:225
gboolean skt_all_sets
Definition glwin.h:350
Definition glwin.h:967
int element
Definition w_periodic.c:61
atom_search * csearch
Definition w_search.c:2719
GtkWidget * img
Definition workspace.c:70