114 xmlTextWriterPtr writer;
116 char isaacinfo[16] =
" I.S.A.A.C.S. v";
117 char xmlinfo[11]=
" XML file ";
118 const xmlChar intro[50]=
"";
124 writer = xmlNewTextWriterFilename(uri, 0);
125 if (writer == NULL)
return 0;
126 rc = xmlTextWriterSetIndent(writer, 1);
127 if (rc < 0)
return 0;
131 rc = xmlTextWriterStartDocument(writer, NULL,
MY_ENCODING, NULL);
132 if (rc < 0)
return 0;
135 strcpy((
char *)intro, isaacinfo);
136 strcat((
char *)intro,
"1.0");
137 strcat((
char *)intro, xmlinfo);
138 rc = xmlTextWriterWriteComment(writer, intro);
139 if (rc < 0)
return 0;
140 rc = xmlTextWriterStartElement(writer, BAD_CAST
"isaacs-xml");
141 if (rc < 0)
return 0;
150 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Data format and file containing the configuration(s) ");
151 if (rc < 0)
return 0;
152 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"data");
153 if (rc < 0)
return 0;
180 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"type",
"%s",
reg_types[reg]);
181 if (rc < 0)
return 0;
182 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"file",
"%s",
active_project -> coordfile);
183 if (rc < 0)
return 0;
184 rc = xmlTextWriterEndElement(writer);
185 if (rc < 0)
return 0;
205 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Chemistry information ");
206 if (rc < 0)
return 0;
207 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"chemistry");
208 if (rc < 0)
return 0;
209 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"atoms",
"%d",
active_project -> natomes);
210 if (rc < 0)
return 0;
211 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"species");
212 if (rc < 0)
return 0;
214 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"number", BAD_CAST
val);
216 if (rc < 0)
return 0;
219 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"label");
220 if (rc < 0)
return 0;
221 val=g_strdup_printf(
"%d",i);
222 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"id", BAD_CAST
val);
224 if (rc < 0)
return 0;
225 rc = xmlTextWriterWriteFormatString (writer,
"%s",
active_chem ->
label[i]);
226 if (rc < 0)
return 0;
227 rc = xmlTextWriterEndElement(writer);
228 if (rc < 0)
return 0;
230 rc = xmlTextWriterEndElement(writer);
231 if (rc < 0)
return 0;
234 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"element");
235 if (rc < 0)
return 0;
236 rc = xmlTextWriterWriteAttribute(writer, BAD_CAST (
const xmlChar *)
"symbol", BAD_CAST
active_chem ->
label[i]);
237 if (rc < 0)
return 0;
238 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"name",
"%s ",
active_chem ->
element[i]);
239 if (rc < 0)
return 0;
240 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"z",
"%d", (
int)
active_chem -> chem_prop[
CHEM_Z][i]);
241 if (rc < 0)
return 0;
242 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"mass",
"%f",
active_chem -> chem_prop[
CHEM_M][i]);
243 if (rc < 0)
return 0;
244 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"rad",
"%d", 0);
245 if (rc < 0)
return 0;
246 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"radius",
"%f",
active_chem -> chem_prop[
CHEM_R][i]);
247 if (rc < 0)
return 0;
248 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"nscatt",
"%f",
active_chem -> chem_prop[
CHEM_N][i]);
249 if (rc < 0)
return 0;
250 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"xscatt",
"%f",
active_chem -> chem_prop[
CHEM_Z][i]);
251 if (rc < 0)
return 0;
252 rc = xmlTextWriterEndElement(writer);
253 if (rc < 0)
return 0;
255 rc = xmlTextWriterEndElement(writer);
256 if (rc < 0)
return 0;
279 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Box information ");
280 if (rc < 0)
return 0;
281 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"box");
282 if (rc < 0)
return 0;
285 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"edges");
286 if (rc < 0)
return 0;
287 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a",
"%f",
active_box ->
param[0][0]);
288 if (rc < 0)
return 0;
289 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b",
"%f",
active_box ->
param[0][1]);
290 if (rc < 0)
return 0;
291 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c",
"%f",
active_box ->
param[0][2]);
292 if (rc < 0)
return 0;
293 rc = xmlTextWriterEndElement(writer);
294 if (rc < 0)
return 0;
295 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"angles");
296 if (rc < 0)
return 0;
297 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"alpha",
"%f",
active_box ->
param[1][0]);
298 if (rc < 0)
return 0;
299 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"beta",
"%f",
active_box ->
param[1][1]);
300 if (rc < 0)
return 0;
301 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"gamma",
"%f",
active_box ->
param[1][2]);
302 if (rc < 0)
return 0;
303 rc = xmlTextWriterEndElement(writer);
304 if (rc < 0)
return 0;
308 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"edges");
309 if (rc < 0)
return 0;
310 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a",
"%f", 0.0);
311 if (rc < 0)
return 0;
312 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b",
"%f", 0.0);
313 if (rc < 0)
return 0;
314 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c",
"%f", 0.0);
315 if (rc < 0)
return 0;
316 rc = xmlTextWriterEndElement(writer);
317 if (rc < 0)
return 0;
318 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"angles");
319 if (rc < 0)
return 0;
320 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"alpha",
"%f", 0.0);
321 if (rc < 0)
return 0;
322 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"beta",
"%f", 0.0);
323 if (rc < 0)
return 0;
324 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"gamma",
"%f", 0.0);
325 if (rc < 0)
return 0;
326 rc = xmlTextWriterEndElement(writer);
327 if (rc < 0)
return 0;
329 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"vectors");
330 if (rc < 0)
return 0;
333 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.x",
"%f",
active_box -> vect[0][0]);
334 if (rc < 0)
return 0;
335 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.y",
"%f",
active_box -> vect[0][1]);
336 if (rc < 0)
return 0;
337 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.z",
"%f",
active_box -> vect[0][2]);
338 if (rc < 0)
return 0;
339 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.x",
"%f",
active_box -> vect[1][0]);
340 if (rc < 0)
return 0;
341 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.y",
"%f",
active_box -> vect[1][1]);
342 if (rc < 0)
return 0;
343 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.z",
"%f",
active_box -> vect[1][2]);
344 if (rc < 0)
return 0;
345 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.x",
"%f",
active_box -> vect[2][0]);
346 if (rc < 0)
return 0;
347 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.y",
"%f",
active_box -> vect[2][1]);
348 if (rc < 0)
return 0;
349 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.z",
"%f",
active_box -> vect[2][2]);
350 if (rc < 0)
return 0;
354 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.x",
"%f", 0.0);
355 if (rc < 0)
return 0;
356 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.y",
"%f", 0.0);
357 if (rc < 0)
return 0;
358 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"a.z",
"%f", 0.0);
359 if (rc < 0)
return 0;
360 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.x",
"%f", 0.0);
361 if (rc < 0)
return 0;
362 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.y",
"%f", 0.0);
363 if (rc < 0)
return 0;
364 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"b.z",
"%f", 0.0);
365 if (rc < 0)
return 0;
366 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.x",
"%f", 0.0);
367 if (rc < 0)
return 0;
368 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.y",
"%f", 0.0);
369 if (rc < 0)
return 0;
370 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"c.z",
"%f", 0.0);
371 if (rc < 0)
return 0;
373 rc = xmlTextWriterEndElement(writer);
374 if (rc < 0)
return 0;
375 rc = xmlTextWriterEndElement(writer);
376 if (rc < 0)
return 0;
385 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" PBC information ");
386 if (rc < 0)
return 0;
387 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"pbc");
388 if (rc < 0)
return 0;
391 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"apply",
"%s",
"TRUE");
395 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"apply",
"%s",
"FALSE");
397 if (rc < 0)
return 0;
400 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractional",
"%s",
"TRUE");
404 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractional",
"%s",
"FALSE");
406 if (rc < 0)
return 0;
407 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"fractype",
"%d",
active_cell -> frac);
408 if (rc < 0)
return 0;
409 rc = xmlTextWriterEndElement(writer);
410 if (rc < 0)
return 0;
421 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Cutoffs information ");
422 if (rc < 0)
return 0;
423 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"cutoffs");
424 if (rc < 0)
return 0;
425 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"total",
"%f",
active_chem -> grtotcutoff);
426 if (rc < 0)
return 0;
427 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"partials");
428 if (rc < 0)
return 0;
435 ncut = g_malloc0 (lgt*
sizeof*ncut);
439 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST ncut,
"%f",
active_chem -> cutoffs[i][j]);
440 if (rc < 0)
return 0;
445 rc = xmlTextWriterEndElement(writer);
446 if (rc < 0)
return 0;
447 rc = xmlTextWriterEndElement(writer);
448 if (rc < 0)
return 0;
460 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Time series ");
461 if (rc < 0)
return 0;
462 rc = xmlTextWriterStartElement(writer, BAD_CAST (
const xmlChar *)
"time-series");
463 if (rc < 0)
return 0;
464 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"dt",
"%f", 0.0);
465 if (rc < 0)
return 0;
466 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"unit",
"t [%s]",
untime[
active_project -> tunit]);
467 if (rc < 0)
return 0;
468 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"ndt",
"%d", 1);
469 if (rc < 0)
return 0;
470 rc = xmlTextWriterEndElement(writer);
471 if (rc < 0)
return 0;
478 rc = xmlTextWriterWriteComment(writer, (
const xmlChar *)
" Apply project ");
479 if (rc < 0)
return 0;
482 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"project",
"%s",
"TRUE");
486 rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST (
const xmlChar *)
"project",
"%s",
"FALSE");
488 if (rc < 0)
return 0;
490 rc = xmlTextWriterEndElement(writer);
491 if (rc < 0)
return 0;
493 rc = xmlTextWriterEndDocument(writer);
494 if (rc < 0)
return 0;
496 xmlFreeTextWriter(writer);