From 902282b54e7a13f2705ba459ef8672e6f9585291 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Sat, 4 Mar 2017 00:21:55 -0600 Subject: [PATCH] Address some @wbinventor comments on #814 --- docs/source/devguide/user-input.rst | 11 +++++++ src/pugixml/pugixml_f.F90 | 48 ++++++++++++++--------------- src/xml_interface.F90 | 14 ++++++--- 3 files changed, 44 insertions(+), 29 deletions(-) diff --git a/docs/source/devguide/user-input.rst b/docs/source/devguide/user-input.rst index 0612dbe0c4..3e1ea1c380 100644 --- a/docs/source/devguide/user-input.rst +++ b/docs/source/devguide/user-input.rst @@ -49,6 +49,14 @@ following steps should be followed to make changes to user input: written out to the statepoint or summary files and that the :class:`openmc.StatePoint` and :class:`openmc.Summary` classes read them in. +7. Finally, a set of `RELAX NG`_ schemas exists that enables validation of input + files. You should modify the RELAX NG schema for the file you changed. The + easiest way to do this is to change the `compact syntax`_ file + (e.g. ``src/relaxng/geometry.rnc``) and then convert it to regular XML syntax + using trang_:: + + trang geometry.rnc geometry.rng + For most user input additions and changes, it is simple enough to follow a "monkey see, monkey do" approach. When in doubt, contact your nearest OpenMC developer or send a message to the `developers mailing list`_. @@ -59,4 +67,7 @@ developer or send a message to the `developers mailing list`_. .. _boolean: http://www.w3.org/TR/xmlschema-2/#boolean .. _xml_interface module: https://github.com/mit-crpg/openmc/blob/develop/src/xml_interface.F90 .. _input_xml module: https://github.com/mit-crpg/openmc/blob/develop/src/input_xml.F90 +.. _RELAX NG: http://relaxng.org/ +.. _compact syntax: http://relaxng.org/compact-tutorial-20030326.html +.. _trang: http://www.thaiopensource.com/relaxng/trang.html .. _developers mailing list: https://groups.google.com/forum/?fromgroups=#!forum/openmc-dev diff --git a/src/pugixml/pugixml_f.F90 b/src/pugixml/pugixml_f.F90 index 883a45cf68..bb45b79c23 100644 --- a/src/pugixml/pugixml_f.F90 +++ b/src/pugixml/pugixml_f.F90 @@ -224,7 +224,7 @@ contains integer(C_SIZE_T) :: i type(C_PTR) :: name_ptr - name_ptr = xml_node_name(this%ptr) + name_ptr = xml_node_name(this % ptr) size_string = strlen(name_ptr) call c_f_pointer(name_ptr, string, [size_string]) allocate(character(len=size_string, kind=C_CHAR) :: name) @@ -248,9 +248,9 @@ contains string(i:i) = name(i:i) end do string(n+1:n+1) = C_NULL_CHAR - child%ptr = xml_node_child(this%ptr, c_loc(string)) + child % ptr = xml_node_child(this % ptr, c_loc(string)) else - child%ptr = xml_node_child(this%ptr, C_NULL_PTR) + child % ptr = xml_node_child(this % ptr, C_NULL_PTR) end if end function xmlnode_child @@ -269,9 +269,9 @@ contains string(i:i) = name(i:i) end do string(n+1:n+1) = C_NULL_CHAR - next%ptr = xml_node_next_sibling(this%ptr, c_loc(string)) + next % ptr = xml_node_next_sibling(this % ptr, c_loc(string)) else - next%ptr = xml_node_next_sibling(this%ptr, C_NULL_PTR) + next % ptr = xml_node_next_sibling(this % ptr, C_NULL_PTR) end if end function xmlnode_next_sibling @@ -288,7 +288,7 @@ contains string(i) = name(i:i) end do string(n+1) = C_NULL_CHAR - attribute%ptr = xml_node_attribute(this%ptr, c_loc(string)) + attribute % ptr = xml_node_attribute(this % ptr, c_loc(string)) end function xmlnode_attribute function xmlnode_child_value(this) result(val) @@ -300,7 +300,7 @@ contains integer(C_SIZE_T) :: i type(C_PTR) :: text - text = xml_node_child_value(this%ptr) + text = xml_node_child_value(this % ptr) size_string = strlen(text) call c_f_pointer(text, string, [size_string]) allocate(character(len=size_string, kind=C_CHAR) :: val) @@ -313,13 +313,13 @@ contains class(XMLNode), intent(in) :: this type(XMLText) :: text - text%ptr = xml_node_text(this%ptr) + text % ptr = xml_node_text(this % ptr) end function xmlnode_text logical function xmlnode_associated(this) class(XMLNode), intent(in) :: this - xmlnode_associated = c_associated(this%ptr) + xmlnode_associated = c_associated(this % ptr) end function xmlnode_associated !============================================================================= @@ -334,7 +334,7 @@ contains integer(C_SIZE_T) :: i type(C_PTR) :: name_ptr - name_ptr = xml_attribute_name(this%ptr) + name_ptr = xml_attribute_name(this % ptr) size_string = strlen(name_ptr) call c_f_pointer(name_ptr, string, [size_string]) allocate(character(len=size_string, kind=C_CHAR) :: name) @@ -352,7 +352,7 @@ contains integer(C_SIZE_T) :: i type(C_PTR) :: val_ptr - val_ptr = xml_attribute_value(this%ptr) + val_ptr = xml_attribute_value(this % ptr) size_string = strlen(val_ptr) call c_f_pointer(val_ptr, string, [size_string]) allocate(character(len=size_string, kind=C_CHAR) :: val) @@ -365,33 +365,33 @@ contains class(XMLAttribute), intent(in) :: this type(XMLAttribute) :: next - next%ptr = xml_attribute_next_attribute(this%ptr) + next % ptr = xml_attribute_next_attribute(this % ptr) end function xmlattribute_next_attribute logical(C_BOOL) function xmlattribute_as_bool(this) class(XMLAttribute), intent(in) :: this - xmlattribute_as_bool = xml_attribute_as_bool(this%ptr) + xmlattribute_as_bool = xml_attribute_as_bool(this % ptr) end function xmlattribute_as_bool integer(C_INT) function xmlattribute_as_int(this) class(XMLAttribute), intent(in) :: this - xmlattribute_as_int = xml_attribute_as_int(this%ptr) + xmlattribute_as_int = xml_attribute_as_int(this % ptr) end function xmlattribute_as_int integer(C_LONG_LONG) function xmlattribute_as_llong(this) class(XMLAttribute), intent(in) :: this - xmlattribute_as_llong = xml_attribute_as_llong(this%ptr) + xmlattribute_as_llong = xml_attribute_as_llong(this % ptr) end function xmlattribute_as_llong real(C_DOUBLE) function xmlattribute_as_double(this) class(XMLAttribute), intent(in) :: this - xmlattribute_as_double = xml_attribute_as_double(this%ptr) + xmlattribute_as_double = xml_attribute_as_double(this % ptr) end function xmlattribute_as_double logical function xmlattribute_associated(this) class(XMLAttribute), intent(in) :: this - xmlattribute_associated = c_associated(this%ptr) + xmlattribute_associated = c_associated(this % ptr) end function xmlattribute_associated !============================================================================= @@ -399,22 +399,22 @@ contains logical(C_BOOL) function xmltext_as_bool(this) class(XMLText), intent(in) :: this - xmltext_as_bool = xml_text_as_bool(this%ptr) + xmltext_as_bool = xml_text_as_bool(this % ptr) end function xmltext_as_bool integer(C_INT) function xmltext_as_int(this) class(XMLText), intent(in) :: this - xmltext_as_int = xml_text_as_int(this%ptr) + xmltext_as_int = xml_text_as_int(this % ptr) end function xmltext_as_int integer(C_LONG_LONG) function xmltext_as_llong(this) class(XMLText), intent(in) :: this - xmltext_as_llong = xml_text_as_llong(this%ptr) + xmltext_as_llong = xml_text_as_llong(this % ptr) end function xmltext_as_llong real(C_DOUBLE) function xmltext_as_double(this) class(XMLText), intent(in) :: this - xmltext_as_double = xml_text_as_double(this%ptr) + xmltext_as_double = xml_text_as_double(this % ptr) end function xmltext_as_double !============================================================================= @@ -432,20 +432,20 @@ contains string(i) = filename(i:i) end do string(n+1) = C_NULL_CHAR - this%ptr = xml_document_load_file(c_loc(string)) + this % ptr = xml_document_load_file(c_loc(string)) end subroutine xmldocument_load_file function xmldocument_document_element(this) result(node) class(XMLDocument), intent(in) :: this type(XMLNode) :: node - node%ptr = xml_document_document_element(this%ptr) + node % ptr = xml_document_document_element(this % ptr) end function xmldocument_document_element subroutine xmldocument_clear(this) class(XMLDocument), intent(inout) :: this - call xml_document_clear(this%ptr) + call xml_document_clear(this % ptr) end subroutine xmldocument_clear end module pugixml diff --git a/src/xml_interface.F90 b/src/xml_interface.F90 index b8bc0fb5e6..a9dc5224bc 100644 --- a/src/xml_interface.F90 +++ b/src/xml_interface.F90 @@ -47,12 +47,12 @@ contains type(XMLNode) :: child ! Check if an attribute or exists - attr = node%attribute(name) - if (attr%associated()) then + attr = node % attribute(name) + if (attr % associated()) then found = .true. else - child = node%child(name) - if (child%associated()) then + child = node % child(name) + if (child % associated()) then found = .true. else found = .false. @@ -200,7 +200,7 @@ contains end subroutine get_node_value_double !=============================================================================== -! GET_NODE_VALUE_STRING returns a single string from attr. or node +! NODE_VALUE_STRING returns a single string from attr. or node !=============================================================================== function node_value_string(node, name) result(val) @@ -224,6 +224,10 @@ contains end if end function node_value_string +!=============================================================================== +! GET_NODE_VALUE_STRING returns a single string from attr. or node +!=============================================================================== + subroutine get_node_value_string(node, name, val) type(XMLNode), intent(in) :: node character(*), intent(in) :: name