1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
C
C F77POS -- Fortran example task to extract position columns from a votable.
C
C M.Fitzpatrick, NOAO, Aug 2009
program f77pos
character ra*16, dec*16, ucd*30
integer vot, res, tab, data, tdata, field
integer i, ncols, nrows
integer ra_col, dec_col
C Declare the libvotable functions we'll be using.
C
integer vf_openvotable, vf_getresource, vf_gettable
integer vf_getdata, vf_gettabledata, vf_getnext
integer vf_getfield, vf_getnrows, vf_getncols
C Parse the table.
C
vot = vf_openvotable ("sample.xml")
res = vf_getresource (vot)
tab = vf_gettable (res)
data = vf_getdata (tab)
tdata = vf_gettabledata (data)
C Get some useful values.
C
nrows = vf_getnrows (tdata)
ncols = vf_getncols (tdata)
print *, nrows, " ", ncols
C Get the RA and DEC columns by matching the UCD.
C
field = vf_getfield (tab)
do 90 i = 1, ncols
C Get the UCD for this FIELD
call vf_getattr (field, "ucd", ucd, 30)
if (ucd .eq. "POS_EQ_RA_MAIN") ra_col = i
if (ucd .eq. "POS_EQ_DEC_MAIN") dec_col = i
C Get the next FIELD (i.e. column) in the table.
field = vf_getnext (field)
90 continue
C Loop through the data table and print the selected columns.
C
do 91 i = 1, nrows
C Get the value of the cell
call vf_gettablecell (tdata, i, ra_col, ra, 16)
call vf_gettablecell (tdata, i, dec_col, dec, 16)
print *, ra, " ", dec
91 continue
stop
end
|