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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
C
C F77SIAP -- Fortran example task of VOClient interface
C
C M.Fitzpatrick, NOAO, Jul 2006
program f77siap
double precision ra, dec, size
character service*80, ffmt*80
integer maxim
C Initialize values. Note the VOClient library assumes all floating
C point values are double precision.
ra = 12.0d0
dec = 0.0d0
size = 0.5d0
C service = "http://envoy.cacr.caltech.edu:8080/questsiap/siap?band=JU&"
C service = "http://www-gsss.stsci.edu/gscvo/DSS2.jsp"
service = "http://skyview.gsfc.nasa.gov/cgi-bin/vo/sia.pl?"
ffmt = "image/fits"
maxim = 5
call siapservice (service, ra, dec, size, size, ffmt, maxim)
stop
end
C Simple test routine to call a Cone search service and summarize results.
subroutine siapservice (service, ra, dec, rasiz, decsiz, ffmt, maxim)
character*80 service, ffmt, fname
character*160 qstring, acref
integer nrec, nattr, len, ier, maxim, index, nloop
integer siap, query, qr, rec, v
double precision ra, dec, rasiz, decsiz
C Define VOClient interface constants we'll use.
C Initialize the VOClient
call vfinitvoclient ("", ier)
C Get a new connection to the named service and form a query.
call vfopensiapconnection (service, siap, ier)
call vfgetsiapquery (siap, ra, dec, rasiz, decsiz, ffmt, query)
C Print the query string we're about to execute.
index = 1
call vfgetquerystring (query, "siap", index, qstring, len)
print *, "Executing Query: "
print *, qstring
print *, ""
C Execute the query, get back a response handle 'qr'.
call vfexecquery (query, qr)
C Now summarize the response.
call vfgetrecordcount (qr, nrec)
if (nrec <= 0) then
print *, "No records matched"
return
endif
C Get a sample record so we can summarize columns.
call vfgetrecord (qr, 1, rec)
if (rec > 0) then
call vfgetattrcount (rec, nattr)
endif
print *, "# returns ", nrec, " records of ", nattr, " attrs"
print *, "#"
print *, "# --- Summary output ---"
print *, "#"
C Download the first 'maxim' images in the list. Note the results table
C is one-indexed in this interface. We also show how to catch an invalid
C record descriptor. To try this, change the starting index to 0 instead
C of 1.
nloop = min (maxim, nrec)
do i = 1, nloop, 1
C Get the row in the table and then select values to print.
call vfgetrecord (qr, i, rec)
if (rec < 0) then
write (*,'(a,i4)'), "Error getting record number: ", i
goto 100
endif
C Get the image access reference and download the file.
call vfgetattribute (rec, "AccessReference", v)
call vfstringvalue (v, acref, len)
write (*,'(a,a)'), "Downloading: ", acref
C Create a filename for the download.
call vfmkfname ("dataset%04d.fits", i, fname, len)
call vfgetdataset (rec, acref, fname, ier)
if (ier .eq. 0) then
write (*,'(a,a)'), " Saved to file: ",fname
else
write (*, '(a)'), " ERROR: Download failed...."
endif
enddo
100 continue
C Shut down the VOClient server.
call vfcloseconnection (siap)
call vfclosevoclient (1, ier)
return
end
|