50 likes | 76 Views
XML2EG (YAXFI). E. Giovannozzi. Yet Another XML Fortran Interface. It links to the standard XML2LIB library The parsing of the xml file is made by a standard free library. No needs of a schema. Use the overloading capability of FORTRAN to decide the type of a variable
E N D
XML2EG(YAXFI) E. Giovannozzi
Yet Another XML Fortran Interface • It links to the standard XML2LIB library • The parsing of the xml file is made by a standard free library. • No needs of a schema. • Use the overloading capability of FORTRAN to decide the type of a variable • Can read a file or a memory location (like codeparam)
XML file example <?xml version="1.0" encoding="UTF-8"?> <parameters> <pluto> <n> 3 </n> <r_real> 4.5 </r_real> <vector_real> 4.5, 56.6, 7.2 </vector_real> <more> <v_int> 1 , 2, 10 </v_int> </more> </pluto> </parameters>
Calling use xml2eg_mdl … type(document) :: doc integer :: n_points real :: a_real real :: vector_real(20) integer :: vint(40) … Or: call xml2eg_parse_file(‘general.xml', doc) Or:call xml2eg_parse_memory(cparameter%parameters, doc) … call xml2eg_get(doc, ‘pluto/n', n_points) call xml2eg_get(doc, ‘pluto/r_real', a_real) call xml2eg_get(doc, 'limiter/vector_real', vector_real) call xml2eg_get(doc, 'limiter/more/v_int', v_int)
Conclusion • The limit are those of the xml2lib library (in terms of thread safety and capability). • The library is mainly for reading parameters. There is a limit on the length of vectors, as it use a string buffer of fixed length (4096 char). • At the moment it does not read vectors of structure (but it can be extended as xml2lib can handle that).