32 use sufr_constants
, only: set_sufr_constants
33 use sufr_system
, only: find_free_io_unit, quit_program_error, syntax_quit
34 use sufr_text
, only: replace_substring, remove_substring
37 integer,
parameter :: maxcol=199
38 integer :: verbose, status, ip, ln, i1,i2, coli,ncol,colnr, strlen, ntabs
40 character :: infile*(99), line*(999), colnames(maxcol)*(99), values(maxcol)*(99)
45 call set_sufr_constants()
47 if(command_argument_count().eq.1)
then
48 call get_command_argument(1, infile)
50 call syntax_quit(
'<xml file>', 0)
58 call find_free_io_unit(ip)
59 open(unit=ip,form=
'formatted',status=
'old',action=
'read',position=
'rewind',file=trim(infile),iostat=status)
60 if(status.ne.0) call quit_program_error(
'Error opening '//trim(infile)//
', aborting...', 0)
69 read(ip,
'(A)', iostat=status) line
72 write(0,
'(A,I4,A,/)')
' Error reading '//trim(infile)//
', line',ln,
' aborting...'
83 if(index(line,
'</Stream>').ne.0) instream = .false.
85 if(index(line,
'<Table ').ne.0)
then
87 call remove_substring(line,
'<Table Name="')
88 call remove_substring(line,
':table')
89 call remove_substring(line,
'">')
90 call replace_substring(line,
':',
' - ')
94 write(*,
'(A)')
'##########################################################################################################'
95 write(*,
'(A)')
' Table: '//trim(line)
96 write(*,
'(A)')
'##########################################################################################################'
100 if(index(line,
'<Column').ne.0)
then
101 call remove_substring(line,
'<Column Name="')
102 call remove_substring(line,
'processgroup:process:')
103 call remove_substring(line,
'process_paramsgroup:process_params:')
104 call remove_substring(line,
'sim_inspiralgroup:sim_inspiral:')
105 i1 = index(line,
'<Column Name="', back=.false.)
106 i2 = index(line,
' Type="', back=.true.) - 2
108 if(verbose.gt.0) print*,i1,i2,line(1:i2)
110 colnames(colnr) = line(1:i2)
114 strlen = len_trim(line)
115 call replace_substring(line,
' ',
'_')
116 line(strlen+1:) =
' '
117 call replace_substring(line,
',',
' ')
119 if(verbose.gt.0) print*,
'Stream: ',trim(line)
120 read(line,*, iostat=status) values
123 write(0,
'(A,I4,A,/)')
' Error reading stream value column',coli,
' aborting...'
131 if(len_trim(values(coli)).ne.0 .or. len_trim(colnames(coli)).ne.0)
then
133 if(mod(coli,10).eq.1)
write(*,*)
134 write(*,
'(I5,2A50)') coli,trim(colnames(coli)),trim(values(coli))
153 write(*,
'(/,A,2(I0,A))')
' Found: ',colnr,
' column titles, ',ncol,
' column values.'
154 if(colnr.ne.ncol)
write(0,
'(//,A,2(I0,A),//)')
' *** Warning: the number of column titles (',colnr, &
155 ') is not equal to the number of column values (',ncol,
'). Please verify the output.'
158 if(index(line,
'<Stream ').ne.0) instream = .true.
167 write(*,
'(/,A,I0,A)')
' Found: ',ntabs,
' tables.'
program gw_ligo_xml2screen
Print the contents of a LIGO/Virgo injection.xml file to screen.