1 | program example |
---|
2 | |
---|
3 | use flib_wxml |
---|
4 | use flib_cml |
---|
5 | |
---|
6 | integer, parameter :: sp = selected_real_kind(6,30) |
---|
7 | integer, parameter :: dp = selected_real_kind(14,100) |
---|
8 | ! |
---|
9 | ! NB normally you will be writting to the xml file |
---|
10 | ! from mulitple fortran files/subroutines, therefore |
---|
11 | ! type(xmlf_t) :: myfile (below) |
---|
12 | ! would normally need to be treated as a global |
---|
13 | ! variable, either in a module or a common block. |
---|
14 | ! |
---|
15 | type(xmlf_t) :: myfile |
---|
16 | ! |
---|
17 | |
---|
18 | integer :: num, na |
---|
19 | character(len=10) :: jon |
---|
20 | character(len=2) :: elements(3) |
---|
21 | real(kind=dp) :: coords(3,3) |
---|
22 | real(kind=dp) :: adp |
---|
23 | |
---|
24 | data coords(1:3,1)/0.0, 0.0, 0.0/ |
---|
25 | data coords(1:3,2)/0.5, 0.5, 0.5/ |
---|
26 | data coords(1:3,3)/0.4, 0.4, 0.4/ |
---|
27 | |
---|
28 | adp=1.234567890 |
---|
29 | na=3 |
---|
30 | elements(1) = 'Ca' |
---|
31 | elements(2) = 'Si' |
---|
32 | elements(3) = 'O' |
---|
33 | num = 20 |
---|
34 | jon = ' jon' |
---|
35 | |
---|
36 | call xml_OpenFile('output.xml', myfile, indent=.true.) |
---|
37 | |
---|
38 | ! Start element |
---|
39 | call xml_NewElement(myfile, 'foo') |
---|
40 | |
---|
41 | ! Add molecule |
---|
42 | call cmlAddMolecule(xf=myfile, natoms=na,elements=elements,coords=coords) |
---|
43 | |
---|
44 | ! Add molecule output in short style |
---|
45 | call cmlAddMolecule(xf=myfile, natoms=na,elements=elements,coords=coords, style='xyz3') |
---|
46 | |
---|
47 | ! Add molecule output in short style in user supplied format |
---|
48 | call cmlAddMolecule(xf=myfile, natoms=na,elements=elements,coords=coords, style='xyz3', fmt='(f12.6)') |
---|
49 | |
---|
50 | ! End and Close |
---|
51 | call xml_EndElement(myfile, 'foo') |
---|
52 | call xml_Close(myfile) |
---|
53 | |
---|
54 | end program example |
---|