source: trunk/bindings/idl/read_test.pro @ 1822

Revision 1176, 8.5 KB checked in by Mark Koennecke, 3 years ago (diff)
  • Imporved printing on long attributes though the specification of a format string to idl's print statement, refs #151
Line 
1pro read_test, argument
2        ;new_dlm_file = '/home/scratch/lns/kauppila/temp/IDLNeXus-API/NeXusIDL-API.dlm'
3        ;new_dlm_file =  'C:\temp\dlm\dlm\testmodule.dlm'
4        ;DLM_REGISTER, new_dlm_file
5
6        filename = 'nothing'
7
8        if (N_PARAMS() GE 1) then begin
9
10                if(strcmp(argument, 'hdf5') EQ 1) then begin
11                        filename = 'NXtest.h5'
12                        print, 'Opening file: ', filename
13                        endif
14
15                if(strcmp(argument, 'hdf4') EQ 1) then begin
16                        filename = 'NXtest.hdf'
17                        print, 'Opening file: ', filename
18                endif
19
20                if(strcmp(argument, 'xml') EQ 1) then begin
21                        filename = 'NXtest.xml'
22                        print, 'Opening file: ', filename
23                endif
24        endif
25
26        if (strcmp(filename, 'nothing') EQ 1) then begin
27                filename = 'NXtest.h5'
28                print, 'Default, Opening file: ', filename
29
30       endif
31
32
33
34
35        nx_char = 4
36        nx_float32 = 5
37        nx_float64 = 6
38        nx_int8 = 20
39        nx_uint8 = 21
40        nx_int16 = 22
41        nx_Uint16 = 23
42        nx_int32 = 24
43        nx_Uint32 = 25
44
45        S = nxopen(filename,"NXACC_RDWR",fileid)
46        print, 'nxopen status: ',S
47
48        S = nxinquirefile(fileid, filename, 20)
49        print, 'nxinquirefile status: ', S
50        if (S EQ 1) then begin
51                print, 'nxinquirefile found: ',  filename
52        endif
53
54        S = nxgetattrinfo(fileid, numberofattr)
55        print, 'nxgetattrinfo status:',S
56
57        if (numberofattr GT 0) then print, 'Number of global attributes: ', numberofattr
58
59        repeat begin
60                attr_status = NXgetnextattr (fileid, attrname, lenght,attr_type)
61                print, ''
62                print, 'NXgetnextattr status: ', attr_status
63                print, ''
64                if (attr_status EQ 1) then begin
65                        S = nxgetattr(fileid, attrname, value, lenght,attr_type)
66                        print, 'attribute name: ', attrname
67                        ;print, 'attrubute lenght: ', lenght
68                        ;print, 'attribute type: ', attr_type
69                        print, format='("attribute value: ",A)', value
70                endif
71        endrep until (attr_status NE 1)
72
73        S = nxopengroup(fileid,"entry","NXentry")
74        print, 'nxopengroup status:',S
75
76        S = nxgetattrinfo(fileid, numberofattr)
77        print, 'nxgetattrinfo status:',S
78        print, 'Number of group attributes: ', numberofattr
79
80        repeat begin
81                attr_status = NXgetnextattr (fileid, attrname, lenght, attr_type)
82                print, 'NXgetnextattr status: ', attr_status
83                if (attr_status EQ 1) then begin
84                        S = nxgetattr(fileid, attrname, value, lenght,attr_type)
85                        print, 'nxgetattr status', S
86                        print, 'attribute name: ', attrname
87                        print, 'attrubute lenght: ', lenght
88                        print, 'attribute type: ', attr_type
89                        print, 'attribute value: ', value
90                        print, ''
91                endif
92        endrep until (attr_status NE 1)
93
94         S = nxgetgroupinfo(fileid, item_number, group_name, group_class)
95       print, 'nxgetgroupinfo status', S
96
97                print, 'current group name: ', group_name
98                print, 'current group class: ', group_class
99                print, 'number of items in group: ', item_number
100                print, ''
101
102        repeat begin
103                entry_status = nxgetnextentry(fileid, name, class, data_type)
104                print, 'nxgetnextentry status: ', entry_status
105                if(entry_status NE -1) then begin
106                        print, 'nxgetnextentry name: ', name
107                        print, 'nxgetnextentry class: ', class
108                        print, 'nxgetnextentry data_type', data_type;                   
109                        print, ''
110                end
111
112                if(strcmp(class, 'SDS')) then begin
113                        print, 'opening data: ', name
114                        S = nxopendata(fileid, name)
115                        print, 'nxopendata status: ',S
116                        print, ''
117
118                        S = nxgetinfo(fileid, rank, di, datatype)
119                        print, 'nxgetinfo Status:', S
120                        print, 'Rank:', rank
121                        for i = 0,rank-1 DO print, 'Dim [',i,']:', di[i]
122                        print, 'Data Type:', datatype
123                        print, ''
124
125                        if(datatype EQ nx_char) then begin
126                                S = nxgetdata(fileid, data)
127                                print, 'nxget data status: ', S
128                                print, 'data :'
129                                print,  data;                           
130                                print, ''
131                        endif else begin;                               
132                                slabstart = [0L,0L]
133                                slabsize = [1L,4L]
134
135                                S = nxgetslab(fileid, data, slabstart, slabsize)
136                                print, 'nxgetslab status: ', S
137                                print, 'data :'
138                                print, data
139                                print, ''
140
141                                slabstart[0] = 1
142                                S = nxgetslab(fileid, data, slabstart, slabsize)
143                                print, 'nxgetslab status: ', S
144                                print, 'data :'
145                                print, data
146                                print, ''
147
148                                slabstart[0] = 2
149                                S = nxgetslab(fileid, data, slabstart, slabsize)
150                                print, 'nxgetslab status: ', S
151                                print, 'data :'
152                                print, data
153                                print, ''
154
155                                slabstart[0] = 3
156                                S = nxgetslab(fileid, data, slabstart, slabsize)
157                                print, 'nxgetslab status: ', S
158                                print, 'data :'
159                                print, data
160                                print, ''
161                        endelse
162
163                        S = nxgetattrinfo(fileid, numberofattr)
164                        print, 'nxgetattrinfo status:',S
165                        print, 'Number of group attributes: ', numberofattr
166                        if (numberofattr GT 0) then print, 'Number of global attributes: ', numberofattr
167
168                        repeat begin
169                                attr_status = NXgetnextattr (fileid, attrname, lenght, attr_type)
170                                print, 'nxgetnextattr status: ', attr_status
171                                if (attr_status EQ 1) then begin
172                                        S = nxgetattr(fileid, attrname, value, lenght,attr_type)
173                                        print, 'nxgetattr status', S
174                                        print, 'attribute name: ', attrname
175                                        print, 'attribute value: ', value
176                                        print, ''
177                                endif
178                        endrep until (attr_status NE 1)
179
180                        S = nxclosedata(fileid)
181                        print, "nxclosedata status: ", S
182                endif
183
184        endrep until (entry_status NE 1)
185        S = nxclosegroup(fileid)
186        print, 'nxclosegroup status: ', S
187
188        print, ''
189        print, '#######################  Checking Links ###########################'
190        print, ''
191
192        S = nxopengroup(fileid,"entry","NXentry")
193        print, 'nxopengroup status:',S
194        print, ''
195
196        S = nxopengroup(fileid,"sample","NXsample")
197        print, 'nxopengroup status:',S
198        print, ''
199
200                S = nxgetgroupid(fileid, groupid1)
201                print, 'nxgetgroupid status: ', S
202                print, 'groupid handle: ', groupid1
203                print, ''
204
205        S = nxclosegroup(fileid)
206        print, 'nxclosegroup status: ', S
207        print, ''
208
209        S = nxopengroup(fileid,"data","NXdata")
210        print, 'nxopengroup status:',S
211        print, ''
212
213                S = nxopendata(fileid, 'r8_data')
214                print, 'nxopendata status: ',S
215                print, ''
216
217                        S = nxgetdataid(fileid, dataid1)
218                        print, 'nxgetdataid status: ', S
219                        ;print, 'dataid handle: ', dataid
220
221                S = nxclosedata(fileid)
222                print, 'nxclosedata status: ', S
223
224        S = nxclosegroup(fileid)
225        print, 'nxclosegroup status: ', S
226        print, ''
227
228        S = nxopendata(fileid, 'r8_data')
229        print, 'nxopendata status: ',S
230        print, ''
231
232                S = nxgetdataid(fileid, dataid2)
233                print, 'nxgetdataid status: ', S
234                ;print, 'dataid handle: ', dataid
235
236        S = nxclosedata(fileid)
237        print, 'nxclosedata status: ', S
238
239        print, 'debug'
240        S = nxsameid(fileid, dataid1, dataid2)
241        print, 'nxsamid status: ', S
242        if(S EQ 1) then begin
243        print, 'Data id: Link check succesfull'
244        endif else begin
245                print, 'Data id: Link check FAILED (sample)'
246        endelse
247
248        S = nxclosegroup(fileid)
249        print, 'nxclosegroup status: ', S
250        print, ''
251
252        S = nxopengroup(fileid,'link','NXentry')
253        print, 'nxopengroup status:',S
254        print, ''
255
256        S = nxopengroup(fileid,"sample","NXsample")
257        print, 'nxopengroup status:',S
258        print, ''
259
260                S = nxgetgroupid(fileid, groupid2)
261                print, 'nxgetgroupid status: ', S
262                ;print, 'groupid handle: ', groupid2
263                print, ''
264
265        S = nxsameid(fileid, groupid1, groupid2)
266        if(S EQ 1) then begin
267        print, 'Group Id: Link check succesfull'
268        endif else begin
269                print, 'Group Id: Link check FAILED (sample)'; 
270        endelse
271
272        S = nxclosegroup(fileid)
273        print, 'nxclosegroup status: ', S
274        print, ''
275
276        S = nxopengroup(fileid,"renLinkGroup","NXsample")
277        print, 'nxopengroup status:',S
278        print, ''
279
280                S = nxgetgroupid(fileid, groupid_named)
281                print, 'nxgetgroupid status: ', S
282                ;print, 'groupid handle: ', groupid2
283                print, ''
284
285                S = nxsameid(fileid, groupid1, groupid_named)
286                if(S EQ 1) then begin
287                print, 'Group Id Named: Link check succesfull'
288                endif else begin
289                print, 'Group Id Named: Link check FAILED (sample)';
290                endelse
291
292
293        print, ''
294        S = nxclosegroup(fileid)
295        print, 'nxclosegroup status: ', S
296        print, ''
297
298        S = nxopendata(fileid, 'renLinkData')
299        print, 'nxopendata status: ',S
300        print, ''
301
302                S = nxgetdataid(fileid, dataid_named)
303                print, 'nxgetdataid status: ', S
304                ;print, 'dataid handle: ', dataid
305
306
307                S = nxsameid(fileid, dataid1, dataid_named)
308                if(S EQ 1) then begin
309                print, 'Data Id Named: Link check succesfull'
310                endif else begin
311                print, 'Data Id Named: Link check FAILED (sample)'
312                endelse
313
314        S = nxclosedata(fileid)
315        print, 'nxclosedata status: ', S
316
317        ;nxopenpath tests
318
319        S = nxopenpath(fileid, '/entry/data/comp_data')
320        if(S EQ 1) then begin
321        print, 'Openpath succesfull (/entry/data/comp_data)'
322        endif else begin
323                print, 'Openpath FAILED (/entry/data/comp_data)'
324        endelse
325
326        S = nxopenpath(fileid, '../r8_data')
327        if(S EQ 1) then begin
328        print, 'Openpath on a relative path  (../r8_data) succesfull'
329        endif else begin
330                print, 'Openpath on a relative path FAILED (../r8_data)'
331        endelse
332
333        S = nxclose(fileid)
334        print, 'nxclose status: ',S
335
336end
Note: See TracBrowser for help on using the repository browser.