xmlf_read_xml_scalar.inc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ! Part of XML-Fortran library:
  2. !
  3. ! $Id: read_xml_scalar.inc,v 1.3 2007/02/26 20:33:38 arjenmarkus Exp $
  4. !
  5. type(XML_PARSE), intent(inout) :: info
  6. character(len=*), intent(in) :: tag
  7. logical, intent(inout) :: endtag
  8. character(len=*), dimension(:,:), intent(in) :: attribs
  9. integer, intent(in) :: noattribs
  10. character(len=*), dimension(:), intent(in) :: data
  11. integer, intent(in) :: nodata
  12. logical, intent(inout) :: has_var
  13. integer, intent(out) :: status
  14. character(len=len(attribs(1,1))) :: buffer
  15. integer :: idx
  16. !
  17. ! The value can be stored in an attribute value="..." or in
  18. ! the data
  19. !
  20. has_var = .false.
  21. idx = xml_find_attrib( attribs, noattribs, 'value', buffer )
  22. if ( idx .gt. 0 ) then
  23. read( buffer, *, iostat=status ) var
  24. has_var = .true.
  25. else
  26. do idx = 1,nodata
  27. if ( data(idx) .ne. ' ' ) then
  28. read( data(idx), *, iostat=status ) var
  29. has_var = .true.
  30. exit
  31. endif
  32. enddo
  33. endif
  34. if ( status .ne. 0 ) then
  35. write(*,*) 'Error reading variable - tag = ', trim(tag)
  36. has_var = .false.
  37. endif