112 xmlTextWriterPtr writer;
119 writer = xmlNewTextWriterFilename(uri, 0);
120 if (writer == NULL)
return 0;
121 rc = xmlTextWriterSetIndent(writer, 1);
122 if (rc < 0)
return 0;
126 rc = xmlTextWriterStartDocument(writer, NULL,
MY_ENCODING, NULL);
127 if (rc < 0)
return 0;
129 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" I.S.A.A.C.S. v1.0 XML file "));
130 if (rc < 0)
return 0;
131 rc = xmlTextWriterStartElement(writer, BAD_CAST
"isaacs-xml");
132 if (rc < 0)
return 0;
141 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Data format and file containing the configuration(s) "));
142 if (rc < 0)
return 0;
143 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"data");
144 if (rc < 0)
return 0;
171 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"type",
"%s",
reg_types[reg]);
172 if (rc < 0)
return 0;
173 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"file",
"%s",
active_project -> coordfile);
174 if (rc < 0)
return 0;
175 rc = xmlTextWriterEndElement(writer);
176 if (rc < 0)
return 0;
196 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Chemistry information "));
197 if (rc < 0)
return 0;
198 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"chemistry");
199 if (rc < 0)
return 0;
200 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"atoms",
"%d",
active_project -> natomes);
201 if (rc < 0)
return 0;
202 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"species");
203 if (rc < 0)
return 0;
205 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"number", BAD_CAST
val);
207 if (rc < 0)
return 0;
210 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"label");
211 if (rc < 0)
return 0;
212 val = g_strdup_printf(
"%d",i);
213 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"id", BAD_CAST
val);
215 if (rc < 0)
return 0;
216 rc = xmlTextWriterWriteFormatString (writer,
"%s",
active_chem -> label[i]);
217 if (rc < 0)
return 0;
218 rc = xmlTextWriterEndElement(writer);
219 if (rc < 0)
return 0;
221 rc = xmlTextWriterEndElement(writer);
222 if (rc < 0)
return 0;
225 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"element");
226 if (rc < 0)
return 0;
227 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"symbol", BAD_CAST
active_chem -> label[i]);
228 if (rc < 0)
return 0;
229 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"name",
"%s ",
active_chem ->
element[i]);
230 if (rc < 0)
return 0;
231 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"z",
"%d", (
int)
active_chem -> chem_prop[
CHEM_Z][i]);
232 if (rc < 0)
return 0;
233 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"mass",
"%f",
active_chem -> chem_prop[
CHEM_M][i]);
234 if (rc < 0)
return 0;
235 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"rad",
"%d", 0);
236 if (rc < 0)
return 0;
237 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"radius",
"%f",
active_chem -> chem_prop[
CHEM_R][i]);
238 if (rc < 0)
return 0;
239 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"nscatt",
"%f",
active_chem -> chem_prop[
CHEM_N][i]);
240 if (rc < 0)
return 0;
241 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"xscatt",
"%f",
active_chem -> chem_prop[
CHEM_Z][i]);
242 if (rc < 0)
return 0;
243 rc = xmlTextWriterEndElement(writer);
244 if (rc < 0)
return 0;
246 rc = xmlTextWriterEndElement(writer);
247 if (rc < 0)
return 0;
270 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Box information "));
271 if (rc < 0)
return 0;
272 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"box");
273 if (rc < 0)
return 0;
276 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"edges");
277 if (rc < 0)
return 0;
278 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a",
"%f",
active_box ->
param[0][0]);
279 if (rc < 0)
return 0;
280 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b",
"%f",
active_box ->
param[0][1]);
281 if (rc < 0)
return 0;
282 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c",
"%f",
active_box ->
param[0][2]);
283 if (rc < 0)
return 0;
284 rc = xmlTextWriterEndElement(writer);
285 if (rc < 0)
return 0;
286 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"angles");
287 if (rc < 0)
return 0;
288 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"alpha",
"%f",
active_box ->
param[1][0]);
289 if (rc < 0)
return 0;
290 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"beta",
"%f",
active_box ->
param[1][1]);
291 if (rc < 0)
return 0;
292 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"gamma",
"%f",
active_box ->
param[1][2]);
293 if (rc < 0)
return 0;
294 rc = xmlTextWriterEndElement(writer);
295 if (rc < 0)
return 0;
299 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"edges");
300 if (rc < 0)
return 0;
301 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a",
"%f", 0.0);
302 if (rc < 0)
return 0;
303 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b",
"%f", 0.0);
304 if (rc < 0)
return 0;
305 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c",
"%f", 0.0);
306 if (rc < 0)
return 0;
307 rc = xmlTextWriterEndElement(writer);
308 if (rc < 0)
return 0;
309 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"angles");
310 if (rc < 0)
return 0;
311 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"alpha",
"%f", 0.0);
312 if (rc < 0)
return 0;
313 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"beta",
"%f", 0.0);
314 if (rc < 0)
return 0;
315 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"gamma",
"%f", 0.0);
316 if (rc < 0)
return 0;
317 rc = xmlTextWriterEndElement(writer);
318 if (rc < 0)
return 0;
320 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"vectors");
321 if (rc < 0)
return 0;
324 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.x",
"%f",
active_box -> vect[0][0]);
325 if (rc < 0)
return 0;
326 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.y",
"%f",
active_box -> vect[0][1]);
327 if (rc < 0)
return 0;
328 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.z",
"%f",
active_box -> vect[0][2]);
329 if (rc < 0)
return 0;
330 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.x",
"%f",
active_box -> vect[1][0]);
331 if (rc < 0)
return 0;
332 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.y",
"%f",
active_box -> vect[1][1]);
333 if (rc < 0)
return 0;
334 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.z",
"%f",
active_box -> vect[1][2]);
335 if (rc < 0)
return 0;
336 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.x",
"%f",
active_box -> vect[2][0]);
337 if (rc < 0)
return 0;
338 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.y",
"%f",
active_box -> vect[2][1]);
339 if (rc < 0)
return 0;
340 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.z",
"%f",
active_box -> vect[2][2]);
341 if (rc < 0)
return 0;
345 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.x",
"%f", 0.0);
346 if (rc < 0)
return 0;
347 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.y",
"%f", 0.0);
348 if (rc < 0)
return 0;
349 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.z",
"%f", 0.0);
350 if (rc < 0)
return 0;
351 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.x",
"%f", 0.0);
352 if (rc < 0)
return 0;
353 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.y",
"%f", 0.0);
354 if (rc < 0)
return 0;
355 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.z",
"%f", 0.0);
356 if (rc < 0)
return 0;
357 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.x",
"%f", 0.0);
358 if (rc < 0)
return 0;
359 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.y",
"%f", 0.0);
360 if (rc < 0)
return 0;
361 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.z",
"%f", 0.0);
362 if (rc < 0)
return 0;
364 rc = xmlTextWriterEndElement(writer);
365 if (rc < 0)
return 0;
366 rc = xmlTextWriterEndElement(writer);
367 if (rc < 0)
return 0;
376 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" PBC information "));
377 if (rc < 0)
return 0;
378 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"pbc");
379 if (rc < 0)
return 0;
382 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"apply",
"%s",
"TRUE");
386 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"apply",
"%s",
"FALSE");
388 if (rc < 0)
return 0;
391 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractional",
"%s",
"TRUE");
395 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractional",
"%s",
"FALSE");
397 if (rc < 0)
return 0;
398 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractype",
"%d",
active_cell -> frac);
399 if (rc < 0)
return 0;
400 rc = xmlTextWriterEndElement(writer);
401 if (rc < 0)
return 0;
412 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Cutoffs information "));
413 if (rc < 0)
return 0;
414 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"cutoffs");
415 if (rc < 0)
return 0;
416 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"total",
"%f",
active_chem -> grtotcutoff);
417 if (rc < 0)
return 0;
418 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"partials");
419 if (rc < 0)
return 0;
426 ncut = g_malloc0(lgt*
sizeof*ncut);
430 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST ncut,
"%f",
active_chem -> cutoffs[i][j]);
431 if (rc < 0)
return 0;
436 rc = xmlTextWriterEndElement(writer);
437 if (rc < 0)
return 0;
438 rc = xmlTextWriterEndElement(writer);
439 if (rc < 0)
return 0;
451 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Time series "));
452 if (rc < 0)
return 0;
453 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"time-series");
454 if (rc < 0)
return 0;
455 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"dt",
"%f", 0.0);
456 if (rc < 0)
return 0;
457 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"unit",
"t [%s]",
untime[
active_project -> tunit]);
458 if (rc < 0)
return 0;
459 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"ndt",
"%d", 1);
460 if (rc < 0)
return 0;
461 rc = xmlTextWriterEndElement(writer);
462 if (rc < 0)
return 0;
469 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)_(
" Apply project "));
470 if (rc < 0)
return 0;
473 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"project",
"%s",
"TRUE");
477 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"project",
"%s",
"FALSE");
479 if (rc < 0)
return 0;
481 rc = xmlTextWriterEndElement(writer);
482 if (rc < 0)
return 0;
484 rc = xmlTextWriterEndDocument(writer);
485 if (rc < 0)
return 0;
487 xmlFreeTextWriter(writer);