Initial revision
frigaut
16 years ago
0 | GNU GENERAL PUBLIC LICENSE | |
1 | Version 2, June 1991 | |
2 | ||
3 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. | |
4 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
5 | Everyone is permitted to copy and distribute verbatim copies | |
6 | of this license document, but changing it is not allowed. | |
7 | ||
8 | Preamble | |
9 | ||
10 | The licenses for most software are designed to take away your | |
11 | freedom to share and change it. By contrast, the GNU General Public | |
12 | License is intended to guarantee your freedom to share and change free | |
13 | software--to make sure the software is free for all its users. This | |
14 | General Public License applies to most of the Free Software | |
15 | Foundation's software and to any other program whose authors commit to | |
16 | using it. (Some other Free Software Foundation software is covered by | |
17 | the GNU Library General Public License instead.) You can apply it to | |
18 | your programs, too. | |
19 | ||
20 | When we speak of free software, we are referring to freedom, not | |
21 | price. Our General Public Licenses are designed to make sure that you | |
22 | have the freedom to distribute copies of free software (and charge for | |
23 | this service if you wish), that you receive source code or can get it | |
24 | if you want it, that you can change the software or use pieces of it | |
25 | in new free programs; and that you know you can do these things. | |
26 | ||
27 | To protect your rights, we need to make restrictions that forbid | |
28 | anyone to deny you these rights or to ask you to surrender the rights. | |
29 | These restrictions translate to certain responsibilities for you if you | |
30 | distribute copies of the software, or if you modify it. | |
31 | ||
32 | For example, if you distribute copies of such a program, whether | |
33 | gratis or for a fee, you must give the recipients all the rights that | |
34 | you have. You must make sure that they, too, receive or can get the | |
35 | source code. And you must show them these terms so they know their | |
36 | rights. | |
37 | ||
38 | We protect your rights with two steps: (1) copyright the software, and | |
39 | (2) offer you this license which gives you legal permission to copy, | |
40 | distribute and/or modify the software. | |
41 | ||
42 | Also, for each author's protection and ours, we want to make certain | |
43 | that everyone understands that there is no warranty for this free | |
44 | software. If the software is modified by someone else and passed on, we | |
45 | want its recipients to know that what they have is not the original, so | |
46 | that any problems introduced by others will not reflect on the original | |
47 | authors' reputations. | |
48 | ||
49 | Finally, any free program is threatened constantly by software | |
50 | patents. We wish to avoid the danger that redistributors of a free | |
51 | program will individually obtain patent licenses, in effect making the | |
52 | program proprietary. To prevent this, we have made it clear that any | |
53 | patent must be licensed for everyone's free use or not licensed at all. | |
54 | ||
55 | The precise terms and conditions for copying, distribution and | |
56 | modification follow. | |
57 | ||
58 | GNU GENERAL PUBLIC LICENSE | |
59 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
60 | ||
61 | 0. This License applies to any program or other work which contains | |
62 | a notice placed by the copyright holder saying it may be distributed | |
63 | under the terms of this General Public License. The "Program", below, | |
64 | refers to any such program or work, and a "work based on the Program" | |
65 | means either the Program or any derivative work under copyright law: | |
66 | that is to say, a work containing the Program or a portion of it, | |
67 | either verbatim or with modifications and/or translated into another | |
68 | language. (Hereinafter, translation is included without limitation in | |
69 | the term "modification".) Each licensee is addressed as "you". | |
70 | ||
71 | Activities other than copying, distribution and modification are not | |
72 | covered by this License; they are outside its scope. The act of | |
73 | running the Program is not restricted, and the output from the Program | |
74 | is covered only if its contents constitute a work based on the | |
75 | Program (independent of having been made by running the Program). | |
76 | Whether that is true depends on what the Program does. | |
77 | ||
78 | 1. You may copy and distribute verbatim copies of the Program's | |
79 | source code as you receive it, in any medium, provided that you | |
80 | conspicuously and appropriately publish on each copy an appropriate | |
81 | copyright notice and disclaimer of warranty; keep intact all the | |
82 | notices that refer to this License and to the absence of any warranty; | |
83 | and give any other recipients of the Program a copy of this License | |
84 | along with the Program. | |
85 | ||
86 | You may charge a fee for the physical act of transferring a copy, and | |
87 | you may at your option offer warranty protection in exchange for a fee. | |
88 | ||
89 | 2. You may modify your copy or copies of the Program or any portion | |
90 | of it, thus forming a work based on the Program, and copy and | |
91 | distribute such modifications or work under the terms of Section 1 | |
92 | above, provided that you also meet all of these conditions: | |
93 | ||
94 | a) You must cause the modified files to carry prominent notices | |
95 | stating that you changed the files and the date of any change. | |
96 | ||
97 | b) You must cause any work that you distribute or publish, that in | |
98 | whole or in part contains or is derived from the Program or any | |
99 | part thereof, to be licensed as a whole at no charge to all third | |
100 | parties under the terms of this License. | |
101 | ||
102 | c) If the modified program normally reads commands interactively | |
103 | when run, you must cause it, when started running for such | |
104 | interactive use in the most ordinary way, to print or display an | |
105 | announcement including an appropriate copyright notice and a | |
106 | notice that there is no warranty (or else, saying that you provide | |
107 | a warranty) and that users may redistribute the program under | |
108 | these conditions, and telling the user how to view a copy of this | |
109 | License. (Exception: if the Program itself is interactive but | |
110 | does not normally print such an announcement, your work based on | |
111 | the Program is not required to print an announcement.) | |
112 | ||
113 | These requirements apply to the modified work as a whole. If | |
114 | identifiable sections of that work are not derived from the Program, | |
115 | and can be reasonably considered independent and separate works in | |
116 | themselves, then this License, and its terms, do not apply to those | |
117 | sections when you distribute them as separate works. But when you | |
118 | distribute the same sections as part of a whole which is a work based | |
119 | on the Program, the distribution of the whole must be on the terms of | |
120 | this License, whose permissions for other licensees extend to the | |
121 | entire whole, and thus to each and every part regardless of who wrote it. | |
122 | ||
123 | Thus, it is not the intent of this section to claim rights or contest | |
124 | your rights to work written entirely by you; rather, the intent is to | |
125 | exercise the right to control the distribution of derivative or | |
126 | collective works based on the Program. | |
127 | ||
128 | In addition, mere aggregation of another work not based on the Program | |
129 | with the Program (or with a work based on the Program) on a volume of | |
130 | a storage or distribution medium does not bring the other work under | |
131 | the scope of this License. | |
132 | ||
133 | 3. You may copy and distribute the Program (or a work based on it, | |
134 | under Section 2) in object code or executable form under the terms of | |
135 | Sections 1 and 2 above provided that you also do one of the following: | |
136 | ||
137 | a) Accompany it with the complete corresponding machine-readable | |
138 | source code, which must be distributed under the terms of Sections | |
139 | 1 and 2 above on a medium customarily used for software interchange; or, | |
140 | ||
141 | b) Accompany it with a written offer, valid for at least three | |
142 | years, to give any third party, for a charge no more than your | |
143 | cost of physically performing source distribution, a complete | |
144 | machine-readable copy of the corresponding source code, to be | |
145 | distributed under the terms of Sections 1 and 2 above on a medium | |
146 | customarily used for software interchange; or, | |
147 | ||
148 | c) Accompany it with the information you received as to the offer | |
149 | to distribute corresponding source code. (This alternative is | |
150 | allowed only for noncommercial distribution and only if you | |
151 | received the program in object code or executable form with such | |
152 | an offer, in accord with Subsection b above.) | |
153 | ||
154 | The source code for a work means the preferred form of the work for | |
155 | making modifications to it. For an executable work, complete source | |
156 | code means all the source code for all modules it contains, plus any | |
157 | associated interface definition files, plus the scripts used to | |
158 | control compilation and installation of the executable. However, as a | |
159 | special exception, the source code distributed need not include | |
160 | anything that is normally distributed (in either source or binary | |
161 | form) with the major components (compiler, kernel, and so on) of the | |
162 | operating system on which the executable runs, unless that component | |
163 | itself accompanies the executable. | |
164 | ||
165 | If distribution of executable or object code is made by offering | |
166 | access to copy from a designated place, then offering equivalent | |
167 | access to copy the source code from the same place counts as | |
168 | distribution of the source code, even though third parties are not | |
169 | compelled to copy the source along with the object code. | |
170 | ||
171 | 4. You may not copy, modify, sublicense, or distribute the Program | |
172 | except as expressly provided under this License. Any attempt | |
173 | otherwise to copy, modify, sublicense or distribute the Program is | |
174 | void, and will automatically terminate your rights under this License. | |
175 | However, parties who have received copies, or rights, from you under | |
176 | this License will not have their licenses terminated so long as such | |
177 | parties remain in full compliance. | |
178 | ||
179 | 5. You are not required to accept this License, since you have not | |
180 | signed it. However, nothing else grants you permission to modify or | |
181 | distribute the Program or its derivative works. These actions are | |
182 | prohibited by law if you do not accept this License. Therefore, by | |
183 | modifying or distributing the Program (or any work based on the | |
184 | Program), you indicate your acceptance of this License to do so, and | |
185 | all its terms and conditions for copying, distributing or modifying | |
186 | the Program or works based on it. | |
187 | ||
188 | 6. Each time you redistribute the Program (or any work based on the | |
189 | Program), the recipient automatically receives a license from the | |
190 | original licensor to copy, distribute or modify the Program subject to | |
191 | these terms and conditions. You may not impose any further | |
192 | restrictions on the recipients' exercise of the rights granted herein. | |
193 | You are not responsible for enforcing compliance by third parties to | |
194 | this License. | |
195 | ||
196 | 7. If, as a consequence of a court judgment or allegation of patent | |
197 | infringement or for any other reason (not limited to patent issues), | |
198 | conditions are imposed on you (whether by court order, agreement or | |
199 | otherwise) that contradict the conditions of this License, they do not | |
200 | excuse you from the conditions of this License. If you cannot | |
201 | distribute so as to satisfy simultaneously your obligations under this | |
202 | License and any other pertinent obligations, then as a consequence you | |
203 | may not distribute the Program at all. For example, if a patent | |
204 | license would not permit royalty-free redistribution of the Program by | |
205 | all those who receive copies directly or indirectly through you, then | |
206 | the only way you could satisfy both it and this License would be to | |
207 | refrain entirely from distribution of the Program. | |
208 | ||
209 | If any portion of this section is held invalid or unenforceable under | |
210 | any particular circumstance, the balance of the section is intended to | |
211 | apply and the section as a whole is intended to apply in other | |
212 | circumstances. | |
213 | ||
214 | It is not the purpose of this section to induce you to infringe any | |
215 | patents or other property right claims or to contest validity of any | |
216 | such claims; this section has the sole purpose of protecting the | |
217 | integrity of the free software distribution system, which is | |
218 | implemented by public license practices. Many people have made | |
219 | generous contributions to the wide range of software distributed | |
220 | through that system in reliance on consistent application of that | |
221 | system; it is up to the author/donor to decide if he or she is willing | |
222 | to distribute software through any other system and a licensee cannot | |
223 | impose that choice. | |
224 | ||
225 | This section is intended to make thoroughly clear what is believed to | |
226 | be a consequence of the rest of this License. | |
227 | ||
228 | 8. If the distribution and/or use of the Program is restricted in | |
229 | certain countries either by patents or by copyrighted interfaces, the | |
230 | original copyright holder who places the Program under this License | |
231 | may add an explicit geographical distribution limitation excluding | |
232 | those countries, so that distribution is permitted only in or among | |
233 | countries not thus excluded. In such case, this License incorporates | |
234 | the limitation as if written in the body of this License. | |
235 | ||
236 | 9. The Free Software Foundation may publish revised and/or new versions | |
237 | of the General Public License from time to time. Such new versions will | |
238 | be similar in spirit to the present version, but may differ in detail to | |
239 | address new problems or concerns. | |
240 | ||
241 | Each version is given a distinguishing version number. If the Program | |
242 | specifies a version number of this License which applies to it and "any | |
243 | later version", you have the option of following the terms and conditions | |
244 | either of that version or of any later version published by the Free | |
245 | Software Foundation. If the Program does not specify a version number of | |
246 | this License, you may choose any version ever published by the Free Software | |
247 | Foundation. | |
248 | ||
249 | 10. If you wish to incorporate parts of the Program into other free | |
250 | programs whose distribution conditions are different, write to the author | |
251 | to ask for permission. For software which is copyrighted by the Free | |
252 | Software Foundation, write to the Free Software Foundation; we sometimes | |
253 | make exceptions for this. Our decision will be guided by the two goals | |
254 | of preserving the free status of all derivatives of our free software and | |
255 | of promoting the sharing and reuse of software generally. | |
256 | ||
257 | NO WARRANTY | |
258 | ||
259 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY | |
260 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN | |
261 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES | |
262 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED | |
263 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
264 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS | |
265 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE | |
266 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, | |
267 | REPAIR OR CORRECTION. | |
268 | ||
269 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING | |
270 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR | |
271 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, | |
272 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING | |
273 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED | |
274 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY | |
275 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER | |
276 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE | |
277 | POSSIBILITY OF SUCH DAMAGES. | |
278 | ||
279 | END OF TERMS AND CONDITIONS | |
280 | ||
281 | How to Apply These Terms to Your New Programs | |
282 | ||
283 | If you develop a new program, and you want it to be of the greatest | |
284 | possible use to the public, the best way to achieve this is to make it | |
285 | free software which everyone can redistribute and change under these terms. | |
286 | ||
287 | To do so, attach the following notices to the program. It is safest | |
288 | to attach them to the start of each source file to most effectively | |
289 | convey the exclusion of warranty; and each file should have at least | |
290 | the "copyright" line and a pointer to where the full notice is found. | |
291 | ||
292 | <one line to give the program's name and a brief idea of what it does.> | |
293 | Copyright (C) <year> <name of author> | |
294 | ||
295 | This program is free software; you can redistribute it and/or modify | |
296 | it under the terms of the GNU General Public License as published by | |
297 | the Free Software Foundation; either version 2 of the License, or | |
298 | (at your option) any later version. | |
299 | ||
300 | This program is distributed in the hope that it will be useful, | |
301 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
302 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
303 | GNU General Public License for more details. | |
304 | ||
305 | You should have received a copy of the GNU General Public License | |
306 | along with this program; if not, write to the Free Software | |
307 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
308 | ||
309 | ||
310 | Also add information on how to contact you by electronic and paper mail. | |
311 | ||
312 | If the program is interactive, make it output a short notice like this | |
313 | when it starts in an interactive mode: | |
314 | ||
315 | Gnomovision version 69, Copyright (C) year name of author | |
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. | |
317 | This is free software, and you are welcome to redistribute it | |
318 | under certain conditions; type `show c' for details. | |
319 | ||
320 | The hypothetical commands `show w' and `show c' should show the appropriate | |
321 | parts of the General Public License. Of course, the commands you use may | |
322 | be called something other than `show w' and `show c'; they could even be | |
323 | mouse-clicks or menu items--whatever suits your program. | |
324 | ||
325 | You should also get your employer (if you work as a programmer) or your | |
326 | school, if any, to sign a "copyright disclaimer" for the program, if | |
327 | necessary. Here is a sample; alter the names: | |
328 | ||
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program | |
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. | |
331 | ||
332 | <signature of Ty Coon>, 1 April 1989 | |
333 | Ty Coon, President of Vice | |
334 | ||
335 | This General Public License does not permit incorporating your program into | |
336 | proprietary programs. If your program is a subroutine library, you may | |
337 | consider it more useful to permit linking proprietary applications with the | |
338 | library. If this is what you want to do, use the GNU Library General | |
339 | Public License instead of this License. |
0 | # $Id: Makefile,v 1.1 2007-12-27 15:10:24 frigaut Exp $ | |
1 | Y_MAKEDIR=/usr/lib/yorick | |
2 | Y_EXE=/usr/lib/yorick/bin/yorick | |
3 | Y_EXE_PKGS= | |
4 | Y_EXE_HOME=/usr/lib/yorick | |
5 | Y_EXE_SITE=/usr/lib/yorick | |
6 | ||
7 | # ----------------------------------------------------- optimization flags | |
8 | ||
9 | COPT=$(COPT_DEFAULT) | |
10 | TGT=$(DEFAULT_TGT) | |
11 | ||
12 | # ------------------------------------------------ macros for this package | |
13 | ||
14 | PKG_NAME=hdf5 | |
15 | PKG_I=hdf5.i | |
16 | ||
17 | OBJS=hdf5.o | |
18 | ||
19 | # change to give the executable a name other than yorick | |
20 | PKG_EXENAME=yorick | |
21 | ||
22 | # PKG_DEPLIBS=-Lsomedir -lsomelib for dependencies of this package | |
23 | PKG_DEPLIBS=-lhdf5 -lz | |
24 | # set compiler or loader (rare) flags specific to this package | |
25 | PKG_CFLAGS= | |
26 | PKG_LDFLAGS= | |
27 | ||
28 | # list of additional package names you want in PKG_EXENAME | |
29 | # (typically Y_EXE_PKGS should be first here) | |
30 | EXTRA_PKGS=$(Y_EXE_PKGS) | |
31 | ||
32 | # list of additional files for clean | |
33 | PKG_CLEAN= | |
34 | ||
35 | # autoload file for this package, if any | |
36 | PKG_I_START=hdf5_start.i | |
37 | ||
38 | # -------------------------------- standard targets and rules (in Makepkg) | |
39 | ||
40 | # set macros Makepkg uses in target and dependency names | |
41 | # DLL_TARGETS, LIB_TARGETS, EXE_TARGETS | |
42 | # are any additional targets (defined below) prerequisite to | |
43 | # the plugin library, archive library, and executable, respectively | |
44 | PKG_I_DEPS=$(PKG_I) | |
45 | ||
46 | include $(Y_MAKEDIR)/Make.cfg | |
47 | include $(Y_MAKEDIR)/Makepkg | |
48 | include $(Y_MAKEDIR)/Make$(TGT) | |
49 | ||
50 | # override macros Makepkg sets for rules and other macros | |
51 | # Y_HOME and Y_SITE in Make.cfg may not be correct (e.g.- relocatable) | |
52 | Y_HOME=$(Y_EXE_HOME) | |
53 | Y_SITE=$(Y_EXE_SITE) | |
54 | ||
55 | # reduce chance of yorick-1.5 corrupting this Makefile | |
56 | MAKE_TEMPLATE = protect-against-1.5 | |
57 | ||
58 | # ------------------------------------- targets and rules for this package | |
59 | ||
60 | # simple example: | |
61 | #myfunc.o: myapi.h | |
62 | # more complex example (also consider using PKG_CFLAGS above): | |
63 | #myfunc.o: myapi.h myfunc.c | |
64 | # $(CC) $(CPPFLAGS) $(CFLAGS) -DMY_SWITCH -o $@ -c myfunc.c | |
65 | ||
66 | clean:: | |
67 | -rm -rf binaries | |
68 | ||
69 | # -------------------------------------------------------- end of Makefile | |
70 | ||
71 | ||
72 | # for the binary package production (add full path to lib*.a below): | |
73 | # macosx: | |
74 | PKG_DEPLIBS_STATIC=-lm -lz /usr/lib/libhdf5.a | |
75 | # linux: | |
76 | PKG_DEPLIBS_STATIC=-lm -lz -lhdf5 | |
77 | PKG_ARCH = $(OSTYPE)-$(MACHTYPE) | |
78 | # or linux or windows | |
79 | PKG_VERSION = $(shell (awk '{if ($$1=="Version:") print $$2}' $(PKG_NAME).info)) | |
80 | # .info might not exist, in which case he line above will exit in error. | |
81 | ||
82 | # packages or devel_pkgs: | |
83 | PKG_DEST_URL = packages | |
84 | ||
85 | package: | |
86 | $(MAKE) | |
87 | $(LD_DLL) -o $(PKG_NAME).so $(OBJS) ywrap.o $(PKG_DEPLIBS_STATIC) $(DLL_DEF) | |
88 | mkdir -p binaries/$(PKG_NAME)/dist/y_home/lib | |
89 | mkdir -p binaries/$(PKG_NAME)/dist/y_home/i-start | |
90 | mkdir -p binaries/$(PKG_NAME)/dist/y_site/i0 | |
91 | cp -p $(PKG_I) binaries/$(PKG_NAME)/dist/y_site/i0/ | |
92 | cp -p $(PKG_NAME).so binaries/$(PKG_NAME)/dist/y_home/lib/ | |
93 | if test -f "check.i"; then cp -p check.i binaries/$(PKG_NAME)/.; fi | |
94 | if test -n "$(PKG_I_START)"; then cp -p $(PKG_I_START) \ | |
95 | binaries/$(PKG_NAME)/dist/y_home/i-start/; fi | |
96 | cat $(PKG_NAME).info | sed -e 's/OS:/OS: $(PKG_ARCH)/' > tmp.info | |
97 | mv tmp.info binaries/$(PKG_NAME)/$(PKG_NAME).info | |
98 | cd binaries; tar zcvf $(PKG_NAME)-$(PKG_VERSION)-$(PKG_ARCH).tgz $(PKG_NAME) | |
99 | ||
100 | distbin: package | |
101 | if test -f "binaries/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_ARCH).tgz" ; then \ | |
102 | ncftpput -f $(HOME)/.ncftp/maumae www/yorick/$(PKG_DEST_URL)/$(PKG_ARCH)/tarballs/ \ | |
103 | binaries/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_ARCH).tgz; fi | |
104 | if test -f "binaries/$(PKG_NAME)/$(PKG_NAME).info" ; then \ | |
105 | ncftpput -f $(HOME)/.ncftp/maumae www/yorick/$(PKG_DEST_URL)/$(PKG_ARCH)/info/ \ | |
106 | binaries/$(PKG_NAME)/$(PKG_NAME).info; fi | |
107 | ||
108 | distsrc: | |
109 | make clean; rm -rf binaries | |
110 | cd ..; tar --exclude binaries --exclude .svn -zcvf \ | |
111 | $(PKG_NAME)-$(PKG_VERSION)-src.tgz yorick-$(PKG_NAME)-$(PKG_VERSION);\ | |
112 | ncftpput -f $(HOME)/.ncftp/maumae www/yorick/$(PKG_DEST_URL)/src/ \ | |
113 | $(PKG_NAME)-$(PKG_VERSION)-src.tgz | |
114 | cd ..; ncftpput -f $(HOME)/.ncftp/maumae www/yorick/contrib/ \ | |
115 | $(PKG_NAME)-$(PKG_VERSION)-src.tgz | |
116 | ||
117 | ||
118 | # -------------------------------------------------------- end of Makefile |
0 | // $Id: check.i,v 1.1 2007-12-27 15:10:25 frigaut Exp $ | |
1 | ||
2 | require,"hdf5.i"; | |
3 | require,"fits.i"; | |
4 | ||
5 | //plug_dir,"."; | |
6 | ||
7 | dfname = "data.h5"; | |
8 | ||
9 | func checkhdf5(notiming=,keep=) | |
10 | /* DOCUMENT checkhdf5(notiming=,keep=) | |
11 | keep=1 does not delete h5 files. | |
12 | SEE ALSO: | |
13 | */ | |
14 | { | |
15 | if (notiming==[]) notiming=1; | |
16 | d1 = span(0,60,100); | |
17 | d2 = random_n(100); | |
18 | d3 = 5.678; | |
19 | d4 = ["history list","written on 2005nov8"]; | |
20 | a1 = 20.6; | |
21 | a2 = "minutes"; | |
22 | a3 = [1,3,1,4,2,2]; | |
23 | c=["blue","red","cyan"]; | |
24 | ||
25 | // create file with data: | |
26 | write,"Creating data.h5 with data"; | |
27 | f = h5open(dfname,"w"); | |
28 | h5write,f,"/2005mar04/time",d1; | |
29 | h5write,f,"/2005mar04/data",d2; | |
30 | h5write,f,"/2005mar04/dewpoint",d3; | |
31 | h5write,f,"/2005mar04/firsthalf/21hr/dewpoint",d3; | |
32 | h5close,f; | |
33 | ||
34 | f = h5open(dfname,"a"); // check append | |
35 | h5write,f,"/2005mar04/comments",d4; | |
36 | h5write,f,"/2005mar05/name with blanks",8.97; | |
37 | write,"\nNow adding comment attributes"; | |
38 | h5awrite,f,"/2005mar04","Temp on this date",a1; | |
39 | h5awrite,f,"/2005mar04/time","Units",a2; | |
40 | h5awrite,f,"/2005mar04","cups of coffee",a3; | |
41 | h5awrite,f,"/2005mar04","colors",c; | |
42 | h5close,f; | |
43 | ||
44 | h5awrite,dfname,"/2005mar04/time","Units2",a2; | |
45 | ||
46 | write,"Reading attribute color"; | |
47 | c1=h5aread(dfname,"/2005mar04","colors"); | |
48 | if (!allof(c==c1)) error,"Read attribute data != written data"; | |
49 | write,"Deleting attribute color"; | |
50 | h5adelete,dfname,"/2005mar04","colors"; | |
51 | ||
52 | ||
53 | write,"\nRunning h5info"; | |
54 | h5info,dfname,att=1; | |
55 | ||
56 | ||
57 | write,"\nAdding soft and hard links"; | |
58 | h5link,dfname,"/bestdata","/2005mar04"; | |
59 | h5link,dfname,"/multiple/path/bestdata","/2005mar04"; | |
60 | h5link,dfname,"/21hr","/2005mar04/firsthalf/21hr"; | |
61 | h5link,dfname,"/HL","/2005mar04",0; | |
62 | h5info,dfname,att=1; | |
63 | ||
64 | write,"\nTesting reads"; | |
65 | d = h5read(dfname,"/2005mar04/time"); | |
66 | if (!allof(d==d1)) error,"Read data != written data"; | |
67 | d = h5read(dfname,"/2005mar04/data"); | |
68 | if (!allof(d==d2)) error,"Read data != written data"; | |
69 | d = h5read(dfname,"/2005mar04/dewpoint"); | |
70 | if (!allof(d==d3)) error,"Read data != written data"; | |
71 | d = h5read(dfname,"/2005mar04/comments"); | |
72 | if (!allof(d==d4)) error,"Read data != written data"; | |
73 | a = h5aread(dfname,"/2005mar04","Temp on this date"); | |
74 | if (!allof(a==a1)) error,"Read attribute != written attribute"; | |
75 | a = h5aread(dfname,"/2005mar04/time","Units"); | |
76 | if (!allof(a==a2)) error,"Read attribute != written attribute"; | |
77 | a = h5aread(dfname,"/2005mar04","cups of coffee"); | |
78 | if (!allof(a==a3)) error,"Read attribute != written attribute"; | |
79 | d = h5read(dfname,"/HL/time"); | |
80 | if (!allof(d==d1)) error,"Read data != written data for hard link"; | |
81 | d = h5read(dfname,"/bestdata/time"); | |
82 | if (!allof(d==d1)) error,"Read data != written data for soft link"; | |
83 | write,"all Read OK and identical to written data"; | |
84 | ||
85 | write,"\nTesting compression"; | |
86 | dim = 256; | |
87 | x= (indgen(dim)-dim)*array(1.0f,dim)(-,); | |
88 | y = transpose(x); | |
89 | ar=float(exp(-(sqrt(x^2.+y^2.)/12.))*20.); | |
90 | h5write,"zip.h5","/image",ar,zip=3; | |
91 | ar1=h5read("zip.h5","/image"); | |
92 | if (!allof(d==d1)) error,"Read data != written data for compression"; | |
93 | write,"Read Compressed OK and identical to written data"; | |
94 | h5write,"nozip.h5","/image",ar; | |
95 | ||
96 | write,"\nTesting writing strings"; | |
97 | s=["A fight is a contract that takes two people to honor.",\ | |
98 | "A combative stance means that you've accepted the contract.",\ | |
99 | "In which case, you deserve what you get.",\ | |
100 | " -- Professor Cheng Man-ch'ing"]; | |
101 | h5write,"strings.h5","/StringsEx",s; | |
102 | h5info,"strings.h5"; | |
103 | sr = h5read("strings.h5","/StringsEx"); | |
104 | if (!allof(s==sr)) error,"Read data != written data for string"; | |
105 | write,"Read OK and identical to written string data"; | |
106 | ||
107 | if (!notiming) { | |
108 | write,"\nTiming"; | |
109 | dim = 1024; | |
110 | x= (indgen(dim)-dim)*array(1.0f,dim)(-,); | |
111 | y = transpose(x); | |
112 | ar=float(exp(-(sqrt(x^2.+y^2.)/12.))*20.); | |
113 | write,"Writing..."; | |
114 | pause,100; | |
115 | tic;h5write,"nozip.h5","/image",ar;t=tac(); | |
116 | tic;h5write,"nozip.h5","/image",ar;t=tac(); | |
117 | write,format="hdf5 %d^2 float write: %fs\n",dim,t; | |
118 | pause,100; | |
119 | tic;fits_write,"nozip.fits",ar,overwrite=1;t=tac(); | |
120 | tic;fits_write,"nozip.fits",ar,overwrite=1;t=tac(); | |
121 | write,format="stock fits %d^2 float write: %fs\n",dim,t; | |
122 | write,"Reading..."; | |
123 | pause,100; | |
124 | tic;d=h5read("nozip.h5","/image");t=tac(); | |
125 | tic;d=h5read("nozip.h5","/image");t=tac(); | |
126 | write,format="hdf5 %d^2 float read: %fs\n",dim,t; | |
127 | pause,100; | |
128 | tic;d=fits_read("nozip.fits");t=tac(); | |
129 | tic;d=fits_read("nozip.fits");t=tac(); | |
130 | write,format="stock fits dim^2 float read: %fs\n",dim,t; | |
131 | } | |
132 | ||
133 | if (!keep) { | |
134 | remove,"data.h5"; | |
135 | remove,"strings.h5"; | |
136 | remove,"nozip.h5"; | |
137 | remove,"zip.h5"; | |
138 | } | |
139 | } | |
140 | checkhdf5; | |
141 | //if (!keep) system,"rm "+dfname+" zip.h5 nozip.h5 strings.h5"; | |
142 | ||
143 | func checkmemleaks | |
144 | { | |
145 | for (i=1;i<=10;i++) { | |
146 | checkhdf5,notiming=1; | |
147 | if (i==2) { | |
148 | ystats = yorick_stats(); | |
149 | ystats = yorick_stats(); | |
150 | } | |
151 | } | |
152 | if (nallof((ystats2=yorick_stats())==ystats)) { | |
153 | write,"memory leak?"; | |
154 | write,ystats; | |
155 | write,ystats2; | |
156 | } else write,"\nNo memory leaks detected"; | |
157 | } |
0 | /* | |
1 | * hdf5.c | |
2 | * wrapper routines for the hdf5 c library | |
3 | * | |
4 | * $Id: hdf5.c,v 1.1 2007-12-27 15:10:25 frigaut Exp $ | |
5 | * | |
6 | * Author: Francois Rigaut. | |
7 | * Written 2004 | |
8 | * last revision/addition: 2007dec26 | |
9 | * | |
10 | * Copyright (c) 2003, Francois RIGAUT (frigaut@gemini.edu, Gemini | |
11 | * Observatory, 670 N A'Ohoku Place, HILO HI-96720). | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or modify it | |
14 | * under the terms of the GNU General Public License as published by the | |
15 | * Free Software Foundation; either version 2 of the License, or (at your | |
16 | * option) any later version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, but | |
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | * General Public License for more details (to receive a copy of the GNU | |
22 | * General Public License, write to the Free Software Foundation, Inc., 675 | |
23 | * Mass Ave, Cambridge, MA 02139, USA). | |
24 | * | |
25 | * $Log: hdf5.c,v $ | |
26 | * Revision 1.1 2007-12-27 15:10:25 frigaut | |
27 | * Initial revision | |
28 | * | |
29 | */ | |
30 | ||
31 | #include <stdio.h> | |
32 | #include <string.h> /* For strcmp() */ | |
33 | #include <stdlib.h> /* For EXIT_FAILURE, EXIT_SUCCESS */ | |
34 | #include "hdf5.h" | |
35 | #include "ydata.h" | |
36 | #include "pstdlib.h" | |
37 | ||
38 | void Y__H5Eon() { H5Eset_auto((H5E_auto_t)H5Eprint,stderr); } | |
39 | void Y__H5Eoff() { H5Eset_auto(NULL,NULL); } | |
40 | void Y__H5close() { H5close(); } | |
41 | void Y__H5open() { H5open(); } | |
42 | ||
43 | void Y__H5version() | |
44 | { | |
45 | unsigned majnum,minnum,relnum; | |
46 | H5get_libversion ( &majnum, &minnum, &relnum); | |
47 | Array *a= PushDataBlock(NewArray(&longStruct, ynew_dim(3L, 0))); | |
48 | a->value.l[0]=(long)majnum; | |
49 | a->value.l[1]=(long)minnum; | |
50 | a->value.l[2]=(long)relnum; | |
51 | } | |
52 | ||
53 | ||
54 | ||
55 | void Y__H5Fcreate(int nArgs) | |
56 | { | |
57 | char *filename = YGetString(sp-nArgs+1); | |
58 | long mode = YGetInteger(sp-nArgs+2); | |
59 | long create_id = YGetInteger(sp-nArgs+3); | |
60 | long access_id = YGetInteger(sp-nArgs+4); | |
61 | int status; | |
62 | status=H5Fcreate(filename, (uint) mode, (hid_t) create_id, (hid_t) access_id); | |
63 | PushIntValue(status); | |
64 | } | |
65 | ||
66 | void Y__H5Fopen(int nArgs) | |
67 | { | |
68 | char *filename = YGetString(sp-nArgs+1); | |
69 | long flags = YGetInteger(sp-nArgs+2); | |
70 | long access_id = YGetInteger(sp-nArgs+3); | |
71 | int status; | |
72 | status=H5Fopen(filename, (uint) flags, (hid_t) access_id); | |
73 | PushIntValue(status); | |
74 | } | |
75 | ||
76 | void Y__H5Fclose(int nArgs) | |
77 | { | |
78 | long file_id = YGetInteger(sp-nArgs+1); | |
79 | int status; | |
80 | H5Fflush((hid_t) file_id, H5F_SCOPE_LOCAL); | |
81 | status=H5Fclose((hid_t) file_id); | |
82 | PushIntValue(status); | |
83 | } | |
84 | ||
85 | ||
86 | void Y__H5Areads(int nArgs) | |
87 | { | |
88 | long attid = YGetInteger(sp-nArgs+1); | |
89 | Dimension *strdims = 0; | |
90 | char **data= YGet_Q(sp-nArgs+2,0,&strdims); | |
91 | long nelem = YGetInteger(sp-nArgs+3); | |
92 | ||
93 | hid_t atype; | |
94 | void **buf[nelem]; | |
95 | int i; | |
96 | ||
97 | atype = H5Tcopy(H5T_C_S1); | |
98 | H5Tset_size(atype,H5T_VARIABLE); | |
99 | H5Tset_strpad(atype,H5T_STR_NULLTERM); | |
100 | H5Tset_cset(atype,H5T_CSET_ASCII); | |
101 | ||
102 | H5Aread(attid,atype,&buf); | |
103 | ||
104 | Array *a= PushDataBlock(NewArray(&stringStruct,strdims)); | |
105 | for (i=0;i<nelem;i++) a->value.q[i] = p_strcpy(buf[i]); | |
106 | ||
107 | //free(buf); | |
108 | ||
109 | PopTo(sp-nArgs-1); | |
110 | Drop(nArgs); | |
111 | } | |
112 | ||
113 | void Y__H5Dreads(int nArgs) | |
114 | { | |
115 | long did = YGetInteger(sp-nArgs+1); | |
116 | Dimension *strdims = 0; | |
117 | char **data= YGet_Q(sp-nArgs+2,0,&strdims); | |
118 | long nelem = YGetInteger(sp-nArgs+3); | |
119 | ||
120 | hid_t atype; | |
121 | void **buf[nelem]; | |
122 | int i; | |
123 | ||
124 | atype = H5Tcopy(H5T_C_S1); | |
125 | H5Tset_size(atype,H5T_VARIABLE); | |
126 | H5Tset_strpad(atype,H5T_STR_NULLTERM); | |
127 | H5Tset_cset(atype,H5T_CSET_ASCII); | |
128 | ||
129 | H5Dread(did,atype,0,0,0,&buf); | |
130 | ||
131 | Array *a= PushDataBlock(NewArray(&stringStruct,strdims)); | |
132 | for (i=0;i<nelem;i++) a->value.q[i] = p_strcpy(buf[i]); | |
133 | ||
134 | PopTo(sp-nArgs-1); | |
135 | Drop(nArgs); | |
136 | } | |
137 | ||
138 | ||
139 | void Y__H5Gget_linkval(int nArgs) | |
140 | { | |
141 | long loc_id = YGetInteger(sp-nArgs+1); | |
142 | char *gname = YGetString(sp-nArgs+2); | |
143 | long size = YGetInteger(sp-nArgs+3); | |
144 | char *value = YGetString(sp-nArgs+4); | |
145 | ||
146 | PushIntValue((long)H5Gget_linkval((hid_t) loc_id, gname, (size_t)size, value)); | |
147 | PopTo(sp-nArgs-1); | |
148 | Drop(nArgs); | |
149 | } | |
150 | ||
151 | void Y__H5Gopen(nArgs) | |
152 | { | |
153 | long loc_id = YGetInteger(sp-nArgs+1); | |
154 | char *gname = YGetString(sp-nArgs+2); | |
155 | ||
156 | PushIntValue((long)H5Gopen((hid_t)loc_id, gname)); | |
157 | PopTo(sp-nArgs-1); | |
158 | Drop(nArgs); | |
159 | } | |
160 | ||
161 | void Y__H5Gclose(nArgs) | |
162 | { | |
163 | long gid = YGetInteger(sp-nArgs+1); | |
164 | ||
165 | PushIntValue((long)H5Gclose((hid_t)gid)); | |
166 | PopTo(sp-nArgs-1); | |
167 | Drop(nArgs); | |
168 | } | |
169 | ||
170 | void Y__H5Gcreate(nArgs) | |
171 | { | |
172 | long loc_id = YGetInteger(sp-nArgs+1); | |
173 | char *gname = YGetString(sp-nArgs+2); | |
174 | long size_hint = YGetInteger(sp-nArgs+3); | |
175 | ||
176 | PushIntValue((long)H5Gcreate((hid_t)loc_id, gname, (size_t)size_hint)); | |
177 | PopTo(sp-nArgs-1); | |
178 | Drop(nArgs); | |
179 | } | |
180 | ||
181 | void Y__H5Gget_num_objs(nArgs) | |
182 | { | |
183 | long gid = YGetInteger(sp-nArgs+1); | |
184 | hsize_t num_obj=0; | |
185 | ||
186 | H5Gget_num_objs((hid_t)gid, &num_obj); | |
187 | PushIntValue((long)num_obj); | |
188 | PopTo(sp-nArgs-1); | |
189 | Drop(nArgs); | |
190 | } | |
191 | ||
192 | void Y__H5Gget_objname_by_idx(int nArgs) | |
193 | { | |
194 | long loc_id = YGetInteger(sp-nArgs+1); | |
195 | long idx = YGetInteger(sp-nArgs+2); | |
196 | char *name = YGetString(sp-nArgs+3); | |
197 | long size = YGetInteger(sp-nArgs+4); | |
198 | ||
199 | H5Gget_objname_by_idx((hid_t)loc_id, (hsize_t)idx,name,(size_t)size); | |
200 | Drop(nArgs); | |
201 | } | |
202 | ||
203 | ||
204 | void Y__H5Gget_objtype_by_idx(int nArgs) | |
205 | { | |
206 | long loc_id = YGetInteger(sp-nArgs+1); | |
207 | long idx = YGetInteger(sp-nArgs+2); | |
208 | ||
209 | PushIntValue((long)H5Gget_objtype_by_idx((hid_t)loc_id, (hsize_t)idx)); | |
210 | PopTo(sp-nArgs-1); | |
211 | Drop(nArgs); | |
212 | } | |
213 | ||
214 | void Y__H5Gget_objtype_by_name(int nArgs) | |
215 | { | |
216 | long loc_id = YGetInteger(sp-nArgs+1); | |
217 | char *name = YGetString(sp-nArgs+2); | |
218 | Dimension *dims = 0; | |
219 | long *objnum = YGet_L(sp-nArgs+3,0, &dims); | |
220 | ||
221 | H5G_stat_t statbuf; | |
222 | hbool_t followlink=0; | |
223 | H5Gget_objinfo((hid_t)loc_id,name,followlink,&statbuf); | |
224 | ||
225 | objnum[0] = statbuf.objno[0]; | |
226 | objnum[1] = statbuf.objno[1]; | |
227 | ||
228 | PushIntValue((long)statbuf.type); | |
229 | PopTo(sp-nArgs-1); | |
230 | Drop(nArgs); | |
231 | } | |
232 | ||
233 | void Y__H5Glink2(int nArgs) | |
234 | { | |
235 | long curr_loc_id = YGetInteger(sp-nArgs+1); | |
236 | char *curname = YGetString(sp-nArgs+2); | |
237 | long link_type = YGetInteger(sp-nArgs+3); | |
238 | long new_loc_id = YGetInteger(sp-nArgs+4); | |
239 | char *newname = YGetString(sp-nArgs+5); | |
240 | ||
241 | PushIntValue((long)H5Glink2((hid_t)curr_loc_id, curname, | |
242 | (H5G_link_t)link_type, (hid_t)new_loc_id, | |
243 | newname)); | |
244 | PopTo(sp-nArgs-1); | |
245 | Drop(nArgs); | |
246 | } | |
247 | ||
248 | void Y__H5Gunlink(int nArgs) | |
249 | { | |
250 | long loc_id = YGetInteger(sp-nArgs+1); | |
251 | char *name = YGetString(sp-nArgs+2); | |
252 | ||
253 | PushIntValue((long)H5Gunlink((hid_t)loc_id, name)); | |
254 | PopTo(sp-nArgs-1); | |
255 | Drop(nArgs); | |
256 | } | |
257 | ||
258 | void Y__H5Pcreate(int nArgs) | |
259 | { | |
260 | long cls_id = YGetInteger(sp-nArgs+1); | |
261 | ||
262 | PushIntValue((long)H5Pcreate((hid_t)cls_id)); | |
263 | PopTo(sp-nArgs-1); | |
264 | Drop(nArgs); | |
265 | } | |
266 | ||
267 | void Y__H5Pset_deflate(int nArgs) | |
268 | { | |
269 | long plist = YGetInteger(sp-nArgs+1); | |
270 | long level = YGetInteger(sp-nArgs+2); | |
271 | ||
272 | PushIntValue((long)H5Pset_deflate((hid_t)plist,(int)level)); | |
273 | PopTo(sp-nArgs-1); | |
274 | Drop(nArgs); | |
275 | } | |
276 | ||
277 | ||
278 | ||
279 | //herr_t H5Pset_chunk(hid_t plist, int ndims, const hsize_t * dim) | |
280 | ||
281 | void Y__H5Pset_chunk(int nArgs) | |
282 | { | |
283 | long plist=YGetInteger(sp-nArgs+1); | |
284 | long ndims=YGetInteger(sp-nArgs+2); | |
285 | Dimension *tmpdims = 0; | |
286 | long *dim=YGet_L(sp-nArgs+3,0,&tmpdims); | |
287 | ||
288 | hsize_t hdim[5]; | |
289 | ||
290 | long status,i; | |
291 | ||
292 | for (i=0;i<ndims;i++) hdim[i]=(hsize_t)dim[i]; | |
293 | ||
294 | status=(long)H5Pset_chunk((hid_t)plist,(int)ndims, hdim); | |
295 | ||
296 | PushIntValue(status); | |
297 | PopTo(sp-nArgs-1); | |
298 | Drop(nArgs); | |
299 | } | |
300 | ||
301 | //hid_t H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t create_plist) | |
302 | void Y__H5Acreate(int nArgs) | |
303 | { | |
304 | long loc_id=YGetInteger(sp-nArgs+1); | |
305 | char *name=YGetString(sp-nArgs+2); | |
306 | long type_id=YGetInteger(sp-nArgs+3); | |
307 | long space_id=YGetInteger(sp-nArgs+4); | |
308 | long create_plist=YGetInteger(sp-nArgs+5); | |
309 | ||
310 | long status; | |
311 | ||
312 | status=(long)H5Acreate((hid_t)loc_id, name, (hid_t)type_id, | |
313 | (hid_t)space_id,(hid_t)create_plist); | |
314 | ||
315 | PushIntValue(status); | |
316 | PopTo(sp-nArgs-1); | |
317 | Drop(nArgs); | |
318 | } | |
319 | ||
320 | //herr_t H5Adelete(hid_t loc_id, const char *name) | |
321 | ||
322 | void Y__H5Adelete(int nArgs) | |
323 | { | |
324 | long loc_id=YGetInteger(sp-nArgs+1); | |
325 | char *name=YGetString(sp-nArgs+2); | |
326 | ||
327 | long status; | |
328 | ||
329 | status=(long)H5Adelete((hid_t)loc_id, name); | |
330 | ||
331 | PushIntValue(status); | |
332 | PopTo(sp-nArgs-1); | |
333 | Drop(nArgs); | |
334 | } | |
335 | ||
336 | ||
337 | //int H5Aget_num_attrs(hid_t loc_id) | |
338 | ||
339 | void Y__H5Aget_num_attrs(int nArgs) | |
340 | { | |
341 | long loc_id=YGetInteger(sp-nArgs+1); | |
342 | ||
343 | long status; | |
344 | ||
345 | status=(long)H5Aget_num_attrs((hid_t)loc_id); | |
346 | ||
347 | PushIntValue(status); | |
348 | PopTo(sp-nArgs-1); | |
349 | Drop(nArgs); | |
350 | } | |
351 | ||
352 | //hid_t H5Aget_type(hid_t attr_id) | |
353 | ||
354 | void Y__H5Aget_type(int nArgs) | |
355 | { | |
356 | long attr_id=YGetInteger(sp-nArgs+1); | |
357 | ||
358 | long status; | |
359 | ||
360 | status=(long)H5Aget_type((hid_t)attr_id); | |
361 | ||
362 | PushIntValue(status); | |
363 | PopTo(sp-nArgs-1); | |
364 | Drop(nArgs); | |
365 | } | |
366 | ||
367 | //hid_t H5Aget_space(hid_t attr_id) | |
368 | ||
369 | void Y__H5Aget_space(int nArgs) | |
370 | { | |
371 | long attr_id=YGetInteger(sp-nArgs+1); | |
372 | ||
373 | long status; | |
374 | ||
375 | status=(long)H5Aget_space((hid_t)attr_id); | |
376 | ||
377 | PushIntValue(status); | |
378 | PopTo(sp-nArgs-1); | |
379 | Drop(nArgs); | |
380 | } | |
381 | ||
382 | void Y__H5Aget_name(int nArgs) | |
383 | { | |
384 | long attr_id=YGetInteger(sp-nArgs+1); | |
385 | long buf_size=YGetInteger(sp-nArgs+2); | |
386 | char *buf=YGetString(sp-nArgs+3); | |
387 | ||
388 | long status; | |
389 | ||
390 | status=(long)H5Aget_name((hid_t)attr_id, (size_t)buf_size, buf); | |
391 | ||
392 | PushIntValue(status); | |
393 | PopTo(sp-nArgs-1); | |
394 | Drop(nArgs); | |
395 | } | |
396 | ||
397 | //hid_t H5Aopen_idx(hid_t loc_id, unsigned int idx) | |
398 | ||
399 | void Y__H5Aopen_idx(int nArgs) | |
400 | { | |
401 | long loc_id=YGetInteger(sp-nArgs+1); | |
402 | long idx=YGetInteger(sp-nArgs+2); | |
403 | ||
404 | long status; | |
405 | ||
406 | status=(long)H5Aopen_idx((hid_t)loc_id, (unsigned int)idx); | |
407 | ||
408 | PushIntValue(status); | |
409 | PopTo(sp-nArgs-1); | |
410 | Drop(nArgs); | |
411 | } | |
412 | ||
413 | //hid_t H5Aopen_name(hid_t loc_id, const char *name) | |
414 | ||
415 | void Y__H5Aopen_name(int nArgs) | |
416 | { | |
417 | long loc_id=YGetInteger(sp-nArgs+1); | |
418 | char *name=YGetString(sp-nArgs+2); | |
419 | ||
420 | long status; | |
421 | ||
422 | status=(long)H5Aopen_name((hid_t)loc_id, name); | |
423 | ||
424 | PushIntValue(status); | |
425 | PopTo(sp-nArgs-1); | |
426 | Drop(nArgs); | |
427 | } | |
428 | ||
429 | //herr_t H5Aread(hid_t attr_id, hid_t mem_type_id, void *buf) | |
430 | ||
431 | void Y__H5Aread(int nArgs) | |
432 | { | |
433 | long attr_id=YGetInteger(sp-nArgs+1); | |
434 | long mem_type_id=YGetInteger(sp-nArgs+2); | |
435 | ||
436 | long status; | |
437 | ||
438 | status=(long)H5Aread((hid_t)attr_id, (hid_t)mem_type_id, yarg_sp(0)); | |
439 | ||
440 | PushIntValue(status); | |
441 | PopTo(sp-nArgs-1); | |
442 | Drop(nArgs); | |
443 | } | |
444 | ||
445 | void Y__H5Awrite(int nArgs) | |
446 | { | |
447 | long attr_id=YGetInteger(sp-nArgs+1); | |
448 | long mem_type_id=YGetInteger(sp-nArgs+2); | |
449 | ||
450 | long status; | |
451 | ||
452 | status=(long)H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, yarg_sp(0)); | |
453 | ||
454 | PushIntValue(status); | |
455 | PopTo(sp-nArgs-1); | |
456 | Drop(nArgs); | |
457 | } | |
458 | ||
459 | //herr_t H5Aclose(hid_t attr_id) | |
460 | ||
461 | void Y__H5Aclose(int nArgs) | |
462 | { | |
463 | long attr_id=YGetInteger(sp-nArgs+1); | |
464 | ||
465 | long status; | |
466 | ||
467 | status=(long)H5Aclose((hid_t)attr_id); | |
468 | ||
469 | PushIntValue(status); | |
470 | PopTo(sp-nArgs-1); | |
471 | Drop(nArgs); | |
472 | } | |
473 | ||
474 | //herr_t H5Dclose(hid_t dataset_id) | |
475 | ||
476 | void Y__H5Dclose(int nArgs) | |
477 | { | |
478 | long dataset_id=YGetInteger(sp-nArgs+1); | |
479 | ||
480 | long status; | |
481 | ||
482 | status=(long)H5Dclose((hid_t)dataset_id); | |
483 | ||
484 | PushIntValue(status); | |
485 | PopTo(sp-nArgs-1); | |
486 | Drop(nArgs); | |
487 | } | |
488 | ||
489 | //hid_t H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, | |
490 | // hid_t space_id, hid_t create_plist_id) | |
491 | ||
492 | void Y__H5Dcreate(int nArgs) | |
493 | { | |
494 | long loc_id=YGetInteger(sp-nArgs+1); | |
495 | char *name=YGetString(sp-nArgs+2); | |
496 | long type_id=YGetInteger(sp-nArgs+3); | |
497 | long space_id=YGetInteger(sp-nArgs+4); | |
498 | long create_plist_id=YGetInteger(sp-nArgs+5); | |
499 | ||
500 | long status; | |
501 | ||
502 | status=(long)H5Dcreate((hid_t)loc_id, name, (hid_t)type_id, | |
503 | (hid_t)space_id,(hid_t)create_plist_id); | |
504 | ||
505 | PushIntValue(status); | |
506 | PopTo(sp-nArgs-1); | |
507 | Drop(nArgs); | |
508 | } | |
509 | ||
510 | //hid_t H5Dopen(hid_t loc_id, const char *name) | |
511 | ||
512 | void Y__H5Dopen(int nArgs) | |
513 | { | |
514 | long loc_id=YGetInteger(sp-nArgs+1); | |
515 | char *name=YGetString(sp-nArgs+2); | |
516 | ||
517 | long status; | |
518 | ||
519 | status=(long)H5Dopen((hid_t)loc_id, name); | |
520 | ||
521 | PushIntValue(status); | |
522 | PopTo(sp-nArgs-1); | |
523 | Drop(nArgs); | |
524 | } | |
525 | ||
526 | //hid_t H5Dget_space(hid_t dataset_id) | |
527 | ||
528 | void Y__H5Dget_space(int nArgs) | |
529 | { | |
530 | long dataset_id=YGetInteger(sp-nArgs+1); | |
531 | ||
532 | long status; | |
533 | ||
534 | status=(long)H5Dget_space((hid_t)dataset_id); | |
535 | ||
536 | PushIntValue(status); | |
537 | PopTo(sp-nArgs-1); | |
538 | Drop(nArgs); | |
539 | } | |
540 | ||
541 | //hid_t H5Dget_type(hid_t dataset_id) | |
542 | ||
543 | void Y__H5Dget_type(int nArgs) | |
544 | { | |
545 | long dataset_id=YGetInteger(sp-nArgs+1); | |
546 | ||
547 | long status; | |
548 | ||
549 | status=(long)H5Dget_type((hid_t)dataset_id); | |
550 | ||
551 | PushIntValue(status); | |
552 | PopTo(sp-nArgs-1); | |
553 | Drop(nArgs); | |
554 | } | |
555 | ||
556 | //herr_t H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, | |
557 | // hid_t file_space_id, hid_t xfer_plist_id, void * buf) | |
558 | ||
559 | void Y__H5Dread(int nArgs) | |
560 | { | |
561 | long dataset_id=YGetInteger(sp-nArgs+1); | |
562 | long mem_type_id=YGetInteger(sp-nArgs+2); | |
563 | long mem_space_id=YGetInteger(sp-nArgs+3); | |
564 | long file_space_id=YGetInteger(sp-nArgs+4); | |
565 | long xfer_plist_id=YGetInteger(sp-nArgs+5); | |
566 | ||
567 | long status; | |
568 | ||
569 | status=(long)H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, | |
570 | (hid_t)mem_space_id, (hid_t)file_space_id, | |
571 | (hid_t)xfer_plist_id, yarg_sp(0)); | |
572 | ||
573 | PushIntValue(status); | |
574 | PopTo(sp-nArgs-1); | |
575 | Drop(nArgs); | |
576 | } | |
577 | ||
578 | //herr_t H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, | |
579 | // hid_t file_space_id, hid_t xfer_plist_id, const void * buf) | |
580 | ||
581 | void Y__H5Dwrite(int nArgs) | |
582 | { | |
583 | long dataset_id=YGetInteger(sp-nArgs+1); | |
584 | long mem_type_id=YGetInteger(sp-nArgs+2); | |
585 | long mem_space_id=YGetInteger(sp-nArgs+3); | |
586 | long file_space_id=YGetInteger(sp-nArgs+4); | |
587 | long xfer_plist_id=YGetInteger(sp-nArgs+5); | |
588 | ||
589 | long status; | |
590 | ||
591 | status=(long)H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, | |
592 | (hid_t)mem_space_id, (hid_t)file_space_id, | |
593 | (hid_t)xfer_plist_id, yarg_sp(0)); | |
594 | ||
595 | PushIntValue(status); | |
596 | PopTo(sp-nArgs-1); | |
597 | Drop(nArgs); | |
598 | } | |
599 | ||
600 | //herr_t H5Sclose(hid_t space_id) | |
601 | ||
602 | void Y__H5Sclose(int nArgs) | |
603 | { | |
604 | long space_id=YGetInteger(sp-nArgs+1); | |
605 | ||
606 | long status; | |
607 | ||
608 | status=(long)H5Sclose((hid_t)space_id); | |
609 | ||
610 | PushIntValue(status); | |
611 | PopTo(sp-nArgs-1); | |
612 | Drop(nArgs); | |
613 | } | |
614 | ||
615 | //hid_t H5Screate(H5S_class_t type) | |
616 | ||
617 | void Y__H5Screate(int nArgs) | |
618 | { | |
619 | long type=YGetInteger(sp-nArgs+1); | |
620 | ||
621 | long status; | |
622 | ||
623 | status=(long)H5Screate((H5S_class_t)type); | |
624 | ||
625 | PushIntValue(status); | |
626 | PopTo(sp-nArgs-1); | |
627 | Drop(nArgs); | |
628 | } | |
629 | ||
630 | //int H5Sget_simple_extent_ndims(hid_t space_id) | |
631 | ||
632 | void Y__H5Sget_simple_extent_ndims(int nArgs) | |
633 | { | |
634 | long space_id=YGetInteger(sp-nArgs+1); | |
635 | ||
636 | long status; | |
637 | ||
638 | status=(long)H5Sget_simple_extent_ndims((hid_t)space_id); | |
639 | ||
640 | PushIntValue(status); | |
641 | PopTo(sp-nArgs-1); | |
642 | Drop(nArgs); | |
643 | } | |
644 | ||
645 | //H5S_class_t H5Sget_simple_extent_type(hid_t space_id) | |
646 | ||
647 | void Y__H5Sget_simple_extent_type(int nArgs) | |
648 | { | |
649 | long space_id=YGetInteger(sp-nArgs+1); | |
650 | ||
651 | long status; | |
652 | ||
653 | status=(long)H5Sget_simple_extent_type((hid_t)space_id); | |
654 | ||
655 | PushIntValue(status); | |
656 | PopTo(sp-nArgs-1); | |
657 | Drop(nArgs); | |
658 | } | |
659 | ||
660 | ||
661 | //hid_t H5Screate_simple(int rank, const hsize_t * dims, | |
662 | // const hsize_t * maxdims) | |
663 | ||
664 | void Y__H5Screate_simple(int nArgs) | |
665 | { | |
666 | long rank=YGetInteger(sp-nArgs+1); | |
667 | Dimension *dimsdims = 0; | |
668 | long *dims=YGet_L(sp-nArgs+2,0,&dimsdims); | |
669 | long ismaxdims = YNotNil(sp-nArgs+2); | |
670 | Dimension *dimsmaxdims = 0; | |
671 | long *maxdims=YGet_L(sp-nArgs+2,1,&dimsmaxdims); | |
672 | ||
673 | hsize_t hdims[5]; | |
674 | hsize_t hmaxdims[5]; | |
675 | ||
676 | long status,i; | |
677 | ||
678 | for (i=0;i<rank;i++) { | |
679 | hdims[i] = (hsize_t)dims[i]; | |
680 | if (ismaxdims) { | |
681 | hmaxdims[i] = (hsize_t)maxdims[i]; | |
682 | } else { hmaxdims[i] = (hsize_t)0; } | |
683 | } | |
684 | ||
685 | status=(long)H5Screate_simple((int)rank, hdims, hmaxdims); | |
686 | ||
687 | PushIntValue(status); | |
688 | PopTo(sp-nArgs-1); | |
689 | Drop(nArgs); | |
690 | } | |
691 | ||
692 | ||
693 | //int H5Sget_simple_extent_dims(hid_t space_id, hsize_t *dims, | |
694 | // hsize_t *maxdims) | |
695 | ||
696 | void Y__H5Sget_simple_extent_dims(int nArgs) | |
697 | { | |
698 | long space_id=YGetInteger(sp-nArgs+1); | |
699 | Dimension *dimsdims = 0; | |
700 | long *dims=YGet_L(sp-nArgs+2,0,&dimsdims); | |
701 | long ismaxdims = YNotNil(sp-nArgs+2); | |
702 | Dimension *dimsmaxdims = 0; | |
703 | long *maxdims=YGet_L(sp-nArgs+3,1,&dimsmaxdims); | |
704 | ||
705 | hsize_t hdims[5]; | |
706 | hsize_t hmaxdims[5]; | |
707 | long status,i,rank; | |
708 | ||
709 | rank=(long)H5Sget_simple_extent_ndims((hid_t)space_id); | |
710 | ||
711 | if (rank<0) { | |
712 | PushIntValue(rank); | |
713 | PopTo(sp-nArgs-1); | |
714 | Drop(nArgs); | |
715 | } | |
716 | ||
717 | status=(long)H5Sget_simple_extent_dims((hid_t)space_id,hdims,hmaxdims); | |
718 | ||
719 | for (i=0;i<rank;i++) { | |
720 | dims[i] = (long)hdims[i]; | |
721 | if (ismaxdims) { | |
722 | maxdims[i] = (long)hmaxdims[i]; | |
723 | } else { maxdims[i] = (long)0; } | |
724 | } | |
725 | ||
726 | PushIntValue(status); | |
727 | PopTo(sp-nArgs-1); | |
728 | Drop(nArgs); | |
729 | } | |
730 | ||
731 | //hid_t H5Tcopy(hid_t type_id) | |
732 | ||
733 | void Y__H5Tcopy(int nArgs) | |
734 | { | |
735 | long type_id=YGetInteger(sp-nArgs+1); | |
736 | ||
737 | long status; | |
738 | ||
739 | status=(long)H5Tcopy((hid_t)type_id); | |
740 | ||
741 | PushIntValue(status); | |
742 | PopTo(sp-nArgs-1); | |
743 | Drop(nArgs); | |
744 | } | |
745 | ||
746 | ||
747 | //H5T_class_t H5Tget_class(hid_t type_id) | |
748 | ||
749 | void Y__H5Tget_class(int nArgs) | |
750 | { | |
751 | long type_id=YGetInteger(sp-nArgs+1); | |
752 | ||
753 | long status; | |
754 | ||
755 | status=(long)H5Tget_class((hid_t)type_id); | |
756 | ||
757 | PushIntValue(status); | |
758 | PopTo(sp-nArgs-1); | |
759 | Drop(nArgs); | |
760 | } | |
761 | ||
762 | //size_t H5Tget_size(hid_t type_id) | |
763 | ||
764 | void Y__H5Tget_size(int nArgs) | |
765 | { | |
766 | long type_id=YGetInteger(sp-nArgs+1); | |
767 | ||
768 | long status; | |
769 | ||
770 | status=(long)H5Tget_size((hid_t)type_id); | |
771 | ||
772 | PushIntValue(status); | |
773 | PopTo(sp-nArgs-1); | |
774 | Drop(nArgs); | |
775 | } | |
776 | ||
777 | ||
778 | //herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset) | |
779 | ||
780 | void Y__H5Tset_cset(int nArgs) | |
781 | { | |
782 | long type_id=YGetInteger(sp-nArgs+1); | |
783 | long cset=YGetInteger(sp-nArgs+2); | |
784 | ||
785 | long status; | |
786 | ||
787 | status=(long)H5Tset_cset((hid_t)type_id, (H5T_cset_t)cset); | |
788 | ||
789 | PushIntValue(status); | |
790 | PopTo(sp-nArgs-1); | |
791 | Drop(nArgs); | |
792 | } | |
793 | ||
794 | //herr_t H5Tset_size(hid_t type_id, size_tsize) | |
795 | ||
796 | void Y__H5Tset_size(int nArgs) | |
797 | { | |
798 | long type_id=YGetInteger(sp-nArgs+1); | |
799 | long size=YGetInteger(sp-nArgs+2); | |
800 | ||
801 | long status; | |
802 | ||
803 | status=(long)H5Tset_size((hid_t)type_id, (size_t)size); | |
804 | ||
805 | PushIntValue(status); | |
806 | PopTo(sp-nArgs-1); | |
807 | Drop(nArgs); | |
808 | } | |
809 | ||
810 | //herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad) | |
811 | ||
812 | void Y__H5Tset_strpad(int nArgs) | |
813 | { | |
814 | long type_id=YGetInteger(sp-nArgs+1); | |
815 | long strpad=YGetInteger(sp-nArgs+2); | |
816 | ||
817 | long status; | |
818 | ||
819 | status=(long)H5Tset_strpad((hid_t)type_id, (H5T_str_t)strpad); | |
820 | ||
821 | PushIntValue(status); | |
822 | PopTo(sp-nArgs-1); | |
823 | Drop(nArgs); | |
824 | } | |
825 | ||
826 | ||
827 | /************************************************************/ | |
828 | ||
829 | void Y__H5T_C_S1(int nArgs) | |
830 | { | |
831 | PushIntValue((long)H5T_C_S1); | |
832 | PopTo(sp-nArgs-1); | |
833 | Drop(nArgs); | |
834 | } | |
835 | void Y__H5T_NATIVE_CHAR(int nArgs) | |
836 | { | |
837 | PushIntValue((long)H5T_NATIVE_CHAR); | |
838 | PopTo(sp-nArgs-1); | |
839 | Drop(nArgs); | |
840 | } | |
841 | void Y__H5T_NATIVE_SHORT(int nArgs) | |
842 | { | |
843 | PushIntValue((long)H5T_NATIVE_SHORT); | |
844 | PopTo(sp-nArgs-1); | |
845 | Drop(nArgs); | |
846 | } | |
847 | void Y__H5T_NATIVE_INT(int nArgs) | |
848 | { | |
849 | PushIntValue((long)H5T_NATIVE_INT); | |
850 | PopTo(sp-nArgs-1); | |
851 | Drop(nArgs); | |
852 | } | |
853 | void Y__H5T_NATIVE_LONG(int nArgs) | |
854 | { | |
855 | PushIntValue((long)H5T_NATIVE_LONG); | |
856 | PopTo(sp-nArgs-1); | |
857 | Drop(nArgs); | |
858 | } | |
859 | void Y__H5T_NATIVE_FLOAT(int nArgs) | |
860 | { | |
861 | PushIntValue((long)H5T_NATIVE_FLOAT); | |
862 | PopTo(sp-nArgs-1); | |
863 | Drop(nArgs); | |
864 | } | |
865 | void Y__H5T_NATIVE_DOUBLE(int nArgs) | |
866 | { | |
867 | PushIntValue((long)H5T_NATIVE_DOUBLE); | |
868 | PopTo(sp-nArgs-1); | |
869 | Drop(nArgs); | |
870 | } | |
871 | void Y__H5T_IEEE_F32BE(int nArgs) | |
872 | { | |
873 | PushIntValue((long)H5T_IEEE_F32BE); | |
874 | PopTo(sp-nArgs-1); | |
875 | Drop(nArgs); | |
876 | } | |
877 | void Y__H5T_IEEE_F32LE(int nArgs) | |
878 | { | |
879 | PushIntValue((long)H5T_IEEE_F32LE); | |
880 | PopTo(sp-nArgs-1); | |
881 | Drop(nArgs); | |
882 | } | |
883 | void Y__H5T_IEEE_F64BE(int nArgs) | |
884 | { | |
885 | PushIntValue((long)H5T_IEEE_F64BE); | |
886 | PopTo(sp-nArgs-1); | |
887 | Drop(nArgs); | |
888 | } | |
889 | void Y__H5T_IEEE_F64LE(int nArgs) | |
890 | { | |
891 | PushIntValue((long)H5T_IEEE_F64LE); | |
892 | PopTo(sp-nArgs-1); | |
893 | Drop(nArgs); | |
894 | } | |
895 | void Y__H5T_STD_I8BE(int nArgs) | |
896 | { | |
897 | PushIntValue((long)H5T_STD_I8BE); | |
898 | PopTo(sp-nArgs-1); | |
899 | Drop(nArgs); | |
900 | } | |
901 | void Y__H5T_STD_I8LE(int nArgs) | |
902 | { | |
903 | PushIntValue((long)H5T_STD_I8LE); | |
904 | PopTo(sp-nArgs-1); | |
905 | Drop(nArgs); | |
906 | } | |
907 | void Y__H5T_STD_I16BE(int nArgs) | |
908 | { | |
909 | PushIntValue((long)H5T_STD_I16BE); | |
910 | PopTo(sp-nArgs-1); | |
911 | Drop(nArgs); | |
912 | } | |
913 | void Y__H5T_STD_I16LE(int nArgs) | |
914 | { | |
915 | PushIntValue((long)H5T_STD_I16LE); | |
916 | PopTo(sp-nArgs-1); | |
917 | Drop(nArgs); | |
918 | } | |
919 | void Y__H5T_STD_I32BE(int nArgs) | |
920 | { | |
921 | PushIntValue((long)H5T_STD_I32BE); | |
922 | PopTo(sp-nArgs-1); | |
923 | Drop(nArgs); | |
924 | } | |
925 | void Y__H5T_STD_I32LE(int nArgs) | |
926 | { | |
927 | PushIntValue((long)H5T_STD_I32LE); | |
928 | PopTo(sp-nArgs-1); | |
929 | Drop(nArgs); | |
930 | } | |
931 | void Y__H5T_STD_I64BE(int nArgs) | |
932 | { | |
933 | PushIntValue((long)H5T_STD_I64BE); | |
934 | PopTo(sp-nArgs-1); | |
935 | Drop(nArgs); | |
936 | } | |
937 | void Y__H5T_STD_I64LE(int nArgs) | |
938 | { | |
939 | PushIntValue((long)H5T_STD_I64LE); | |
940 | PopTo(sp-nArgs-1); | |
941 | Drop(nArgs); | |
942 | } | |
943 | void Y__H5T_STD_U8BE(int nArgs) | |
944 | { | |
945 | PushIntValue((long)H5T_STD_U8BE); | |
946 | PopTo(sp-nArgs-1); | |
947 | Drop(nArgs); | |
948 | } | |
949 | void Y__H5T_STD_U8LE(int nArgs) | |
950 | { | |
951 | PushIntValue((long)H5T_STD_U8LE); | |
952 | PopTo(sp-nArgs-1); | |
953 | Drop(nArgs); | |
954 | } | |
955 | void Y__H5T_STD_U16BE(int nArgs) | |
956 | { | |
957 | PushIntValue((long)H5T_STD_U16BE); | |
958 | PopTo(sp-nArgs-1); | |
959 | Drop(nArgs); | |
960 | } | |
961 | void Y__H5T_STD_U16LE(int nArgs) | |
962 | { | |
963 | PushIntValue((long)H5T_STD_U16LE); | |
964 | PopTo(sp-nArgs-1); | |
965 | Drop(nArgs); | |
966 | } | |
967 | void Y__H5T_STD_U32BE(int nArgs) | |
968 | { | |
969 | PushIntValue((long)H5T_STD_U32BE); | |
970 | PopTo(sp-nArgs-1); | |
971 | Drop(nArgs); | |
972 | } | |
973 | void Y__H5T_STD_U32LE(int nArgs) | |
974 | { | |
975 | PushIntValue((long)H5T_STD_U32LE); | |
976 | PopTo(sp-nArgs-1); | |
977 | Drop(nArgs); | |
978 | } | |
979 | void Y__H5T_STD_U64BE(int nArgs) | |
980 | { | |
981 | PushIntValue((long)H5T_STD_U64BE); | |
982 | PopTo(sp-nArgs-1); | |
983 | Drop(nArgs); | |
984 | } | |
985 | void Y__H5T_STD_U64LE(int nArgs) | |
986 | { | |
987 | PushIntValue((long)H5T_STD_U64LE); | |
988 | PopTo(sp-nArgs-1); | |
989 | Drop(nArgs); | |
990 | } | |
991 | void Y__H5T_STD_B8BE(int nArgs) | |
992 | { | |
993 | PushIntValue((long)H5T_STD_B8BE); | |
994 | PopTo(sp-nArgs-1); | |
995 | Drop(nArgs); | |
996 | } | |
997 | void Y__H5T_STD_B8LE(int nArgs) | |
998 | { | |
999 | PushIntValue((long)H5T_STD_B8LE); | |
1000 | PopTo(sp-nArgs-1); | |
1001 | Drop(nArgs); | |
1002 | } | |
1003 | void Y__H5T_STD_B16BE(int nArgs) | |
1004 | { | |
1005 | PushIntValue((long)H5T_STD_B16BE); | |
1006 | PopTo(sp-nArgs-1); | |
1007 | Drop(nArgs); | |
1008 | } | |
1009 | void Y__H5T_STD_B16LE(int nArgs) | |
1010 | { | |
1011 | PushIntValue((long)H5T_STD_B16LE); | |
1012 | PopTo(sp-nArgs-1); | |
1013 | Drop(nArgs); | |
1014 | } | |
1015 | void Y__H5T_STD_B32BE(int nArgs) | |
1016 | { | |
1017 | PushIntValue((long)H5T_STD_B32BE); | |
1018 | PopTo(sp-nArgs-1); | |
1019 | Drop(nArgs); | |
1020 | } | |
1021 | void Y__H5T_STD_B32LE(int nArgs) | |
1022 | { | |
1023 | PushIntValue((long)H5T_STD_B32LE); | |
1024 | PopTo(sp-nArgs-1); | |
1025 | Drop(nArgs); | |
1026 | } | |
1027 | void Y__H5T_STD_B64BE(int nArgs) | |
1028 | { | |
1029 | PushIntValue((long)H5T_STD_B64BE); | |
1030 | PopTo(sp-nArgs-1); | |
1031 | Drop(nArgs); | |
1032 | } | |
1033 | void Y__H5T_STD_B64LE(int nArgs) | |
1034 | { | |
1035 | PushIntValue((long)H5T_STD_B64LE); | |
1036 | PopTo(sp-nArgs-1); | |
1037 | Drop(nArgs); | |
1038 | } | |
1039 | void Y__H5T_STD_REF_OBJ(int nArgs) | |
1040 | { | |
1041 | PushIntValue((long)H5T_STD_REF_OBJ); | |
1042 | PopTo(sp-nArgs-1); | |
1043 | Drop(nArgs); | |
1044 | } | |
1045 | void Y__H5T_UNIX_D32BE(int nArgs) | |
1046 | { | |
1047 | PushIntValue((long)H5T_UNIX_D32BE); | |
1048 | PopTo(sp-nArgs-1); | |
1049 | Drop(nArgs); | |
1050 | } | |
1051 | void Y__H5T_UNIX_D32LE(int nArgs) | |
1052 | { | |
1053 | PushIntValue((long)H5T_UNIX_D32LE); | |
1054 | PopTo(sp-nArgs-1); | |
1055 | Drop(nArgs); | |
1056 | } | |
1057 | void Y__H5T_UNIX_D64BE(int nArgs) | |
1058 | { | |
1059 | PushIntValue((long)H5T_UNIX_D64BE); | |
1060 | PopTo(sp-nArgs-1); | |
1061 | Drop(nArgs); | |
1062 | } | |
1063 | void Y__H5T_UNIX_D64LE(int nArgs) | |
1064 | { | |
1065 | PushIntValue((long)H5T_UNIX_D64LE); | |
1066 | PopTo(sp-nArgs-1); | |
1067 | Drop(nArgs); | |
1068 | } | |
1069 | void Y__H5P_DATASET_CREATE(int nArgs) | |
1070 | { | |
1071 | PushIntValue((long)H5P_DATASET_CREATE); | |
1072 | PopTo(sp-nArgs-1); | |
1073 | Drop(nArgs); | |
1074 | } | |
1075 |
0 | HDF5_VERSION = "0.6.1"; | |
1 | ||
2 | /* HDF5 Yorick plugin, version 0.6 | |
3 | * | |
4 | * $Id: hdf5.i,v 1.1 2007-12-27 15:10:25 frigaut Exp $ | |
5 | * | |
6 | * Francois Rigaut, February 2005 | |
7 | * Created: 24 February 2005 | |
8 | * last revision/addition: | |
9 | * | |
10 | * 11 dec 2005, v0.6 | |
11 | * many hours of work on this plugin. | |
12 | * - the whole h5open/h5close is now much more robust. | |
13 | * - fixed many occurences where things were left open | |
14 | * - added 2 new functions: h5version, h5list_open | |
15 | * | |
16 | * 8 nov 2005 | |
17 | * fixed issue when reading large array of strings in hdf5.c | |
18 | * | |
19 | * 25 may 2005 | |
20 | * fixed a bug in creating multiple levels groups | |
21 | * | |
22 | * 24 february 2005 | |
23 | * initial revision | |
24 | * | |
25 | * $Log: hdf5.i,v $ | |
26 | * Revision 1.1 2007-12-27 15:10:25 frigaut | |
27 | * Initial revision | |
28 | * | |
29 | * | |
30 | * Copyright (c) 2005, Francois RIGAUT (frigaut@gemini.edu, Gemini | |
31 | * Observatory, 670 N A'Ohoku Place, HILO HI-96720). | |
32 | * | |
33 | * This program is free software; you can redistribute it and/or modify it | |
34 | * under the terms of the GNU General Public License as published by the | |
35 | * Free Software Foundation; either version 2 of the License, or (at your | |
36 | * option) any later version. | |
37 | * | |
38 | * This program is distributed in the hope that it will be useful, but | |
39 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
40 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41 | * General Public License for more details (to receive a copy of the GNU | |
42 | * General Public License, write to the Free Software Foundation, Inc., 675 | |
43 | * Mass Ave, Cambridge, MA 02139, USA). | |
44 | */ | |
45 | ||
46 | plug_in, "hdf5"; | |
47 | ||
48 | local hdf5; | |
49 | /* DOCUMENT HDF5 plugin: Simple HIERARCHICAL DATA FORMAT 5 wrappers. | |
50 | ||
51 | DATA I/O: | |
52 | h5read(fname,target) return data | |
53 | h5write,fname,fullpath,data,zip=,mode= write data | |
54 | h5open(filename,mode) return file handle | |
55 | h5close(filename) close file | |
56 | ||
57 | INFO, GROUP LINKING: | |
58 | h5info,fname,target,att= print out file info/structure | |
59 | h5link(fname,group,group2link2,linktype) link datasets | |
60 | h5delete,fname,object delete data | |
61 | ||
62 | ATTRIBUTE I/O: | |
63 | h5awrite(fname,object,aname,attdata) write an object attribute | |
64 | h5aread(fname,object,aname) read an object attribute | |
65 | h5adelete,fname,object,aname delete an object attribute | |
66 | ||
67 | MISC: | |
68 | h5list_open list open files | |
69 | h5version return linhdf5 version | |
70 | ||
71 | ERROR RECOVERY | |
72 | h5off close all reference to the | |
73 | h5 library (clean up). | |
74 | ||
75 | + Many of the atomic HDF5 functions are available (e.g. H5Fopen, H5Dopen) | |
76 | with mostly the same APIs. Many simple tasks can be done with the | |
77 | provided high level wrappers. Beware that programming an HDF5 custom | |
78 | wrapper is not trivial. Make sure you close every objects opened! | |
79 | ||
80 | This implementation supports reading of most of the HDF5 supported | |
81 | datatype. Only yorick datatype can be used for writes. Compression, soft | |
82 | and hard links, as well as support for attribute read/writes is provided. | |
83 | ||
84 | There is no support for hyperslabs, compound, enum or opaque datatype. | |
85 | Generally, there is very little support for datatype related | |
86 | functionalities. | |
87 | ||
88 | EXAMPLES: | |
89 | 1. simplest: | |
90 | h5write,"sinus.h5","/sin2t","sin(2*indgen(100)); | |
91 | ||
92 | 2. ex2: save 2 vectors | |
93 | fd1=h5open("sinus.h5","w"); // "w" start from scratch | |
94 | t = span(0.,2*pi,100); | |
95 | h5write,fd1,"/data/t",t; | |
96 | h5write,fd1,"/data/sin2t",sin(2*t); | |
97 | h5close,fd1; | |
98 | ||
99 | 3. ex3: append another vector and attribute | |
100 | h5write,"sinus.h5","/data/damped sin",sin(t)*exp(-0.7*t),mode="a"; | |
101 | h5awrite,"sinus.h5","/data/damped sin", \ | |
102 | "functional form","sin(t)*exp(-0.7t)"; | |
103 | ||
104 | 4. examine the content of the file | |
105 | h5info,"sinus.h5"; | |
106 | ||
107 | NOTE: HDF5_SAFE is a global flag that, if set, will prevent to open | |
108 | an existing file in mode "w". In this mode, if the file has indeed | |
109 | to be overwritten, it needs to be deleted prior to the call to | |
110 | h5open. | |
111 | ||
112 | SEE ALSO: | |
113 | */ | |
114 | ||
115 | //:::::::::::::::::::::::::::::::::::: | |
116 | ||
117 | HDF5_SAFE=0; | |
118 | // if set to 1, will prevent opening file that | |
119 | // already exist in mode "w". This can prevent | |
120 | // accidental deletion of important data, however | |
121 | // it can be a pain. | |
122 | ||
123 | //:::::::::::::::::::::::::::::::::::: | |
124 | ||
125 | struct _hdf5info { string name, objectType; pointer aname; }; | |
126 | struct _hdf5file_struct { string fname; long fd; long nref; string curmode; }; | |
127 | ||
128 | //:::::::::::::::::::::::::::::::::::: | |
129 | ||
130 | ||
131 | func h5info(file,target,att=,_recur=) | |
132 | /* DOCUMENT h5info,filename,target_group,att= | |
133 | Prints out the content of a HDF5 file (groups, datasets and links) | |
134 | ||
135 | filename: file name (string) or file descriptor (long) | |
136 | target_group: the root group at which to start scanning (default "/") | |
137 | att=1: print out objects attributes (to group and datasets only) | |
138 | ||
139 | SEE ALSO: h5read, h5write, h5link, h5delete | |
140 | */ | |
141 | { | |
142 | extern objnovec,objnoname,objectInfo; | |
143 | ||
144 | // initialize some variable at top of recursion | |
145 | if (!_recur) { | |
146 | objnovec=[]; | |
147 | objnoname=[]; | |
148 | objectInfo = []; | |
149 | } | |
150 | ||
151 | if (!target) target="/"; //default start group | |
152 | ||
153 | // Open file | |
154 | if (structof(file)==string) { | |
155 | has2bclose=1; | |
156 | file = h5open(file,"r"); | |
157 | } | |
158 | ||
159 | // Open group | |
160 | gid = _H5Gopen(file,target); | |
161 | if (gid<0) { | |
162 | if (has2bclose) h5close,file; | |
163 | error,"Unable to find group"; | |
164 | } | |
165 | ||
166 | if (target=="/") target=""; | |
167 | ||
168 | nobj = _H5Gget_num_objs(gid); | |
169 | ||
170 | if (!nobj) return; // empty group | |
171 | ||
172 | maxcar = 32; | |
173 | ||
174 | for (i=0;i<nobj;i++) { // loop on group objects | |
175 | grow,objectInfo,_hdf5info(); | |
176 | name = array(" ",128)(sum); | |
177 | size = _H5Gget_objname_by_idx(gid,i,name, 128n ); | |
178 | fullname = target+"/"+name; | |
179 | if (strlen(fullname)>maxcar) fullname="..."+ | |
180 | strpart(fullname,-(maxcar-4):0); | |
181 | write,format="%-"+swrite(format="%d",maxcar)+"s",fullname; | |
182 | ||
183 | objno=[0,0]; | |
184 | otype = _H5Gget_objtype_by_name(gid,fullname,objno); | |
185 | ||
186 | objectInfo(0).name=fullname; | |
187 | ||
188 | if (otype==H5G_GROUP) { | |
189 | // object is other group. we will enter recursion. | |
190 | if ((objnovec!=[])&&anyof((objno==objnovec)(sum,)==2)) { | |
191 | w = where((objno==objnovec)(sum,)==2)(1); | |
192 | link2 = objnoname(w); | |
193 | write,format=" %s -> %s\n","HARDLINK",link2; | |
194 | objectInfo(0).objectType="HARDLINK"; | |
195 | } else { | |
196 | write,format=" %-8s\n","GROUP"; | |
197 | objectInfo(0).objectType="GROUP"; | |
198 | if (att) { | |
199 | gid2 = _H5Gopen(file,fullname); | |
200 | natt = _H5Aget_num_attrs(gid2); | |
201 | tmp=[]; | |
202 | for (na=0;na<natt;na++) { | |
203 | attid = _H5Aopen_idx(gid2,na); | |
204 | str = array(" ",128)(sum); | |
205 | status= _H5Aget_name(attid,128,str); | |
206 | grow,tmp,str; | |
207 | write,format=array(" ",maxcar+1)(sum)+"ATTRIB(%d): %-30s\n",na, | |
208 | strpart(str,1:30); | |
209 | status= _H5Aclose(attid); | |
210 | } | |
211 | objectInfo(0).aname=&tmp; | |
212 | status = _H5Gclose(gid2); | |
213 | } | |
214 | grow,objnovec,[objno]; | |
215 | grow,objnoname,fullname; | |
216 | // call oneself one group down | |
217 | h5info,file,target+"/"+name,att=att,_recur=1; | |
218 | } | |
219 | ||
220 | } else if (otype==H5G_DATASET) { | |
221 | // object is dataset | |
222 | write,format=" %-8s ","DATASET"; | |
223 | objectInfo(0).objectType="DATASET"; | |
224 | ||
225 | dataset = _H5Dopen(file,target+"/"+name); | |
226 | // get dataspace id: | |
227 | dspid = _H5Dget_space(dataset); | |
228 | ||
229 | //get rank and dimensions: | |
230 | rank = _H5Sget_simple_extent_ndims(dspid); | |
231 | if (rank) { | |
232 | dims = maxdims = array(long,rank); | |
233 | status = _H5Sget_simple_extent_dims(dspid,dims,maxdims); | |
234 | } | |
235 | // get type: | |
236 | yt=yotype(_H5Dget_type(dataset)); | |
237 | if (yt != -1) { | |
238 | write,format=" %-6s ",strcase(1,typeof(yt)); | |
239 | } else { | |
240 | write,format=" %-6s ", | |
241 | "UNKNOWN"; | |
242 | } | |
243 | ||
244 | if (rank) { | |
245 | write,format=" DIMSOF()=[%d",rank; | |
246 | for (j=1;j<=rank;j++) write,format=",%d",dims(j); | |
247 | write,format="]%s\n",""; | |
248 | } else { | |
249 | write,format=" %sSCALAR\n",""; | |
250 | } | |
251 | ||
252 | if (att) { | |
253 | natt = _H5Aget_num_attrs(dataset); | |
254 | tmp=[]; | |
255 | for (na=0;na<natt;na++) { | |
256 | attid = _H5Aopen_idx(dataset,na); | |
257 | str = array(" ",128)(sum); | |
258 | status= _H5Aget_name(attid,128,str); | |
259 | grow,tmp,str; | |
260 | write,format=array(" ",maxcar+1)(sum)+"ATTRIB(%d): %-30s\n",na, | |
261 | strpart(str,1:30); | |
262 | status= _H5Aclose(attid); | |
263 | } | |
264 | objectInfo(0).aname=&tmp; | |
265 | } | |
266 | ||
267 | status=_H5Dclose(dataset); | |
268 | ||
269 | } else if (otype==H5G_LINK) { | |
270 | link2 = array(" ",128)(sum); | |
271 | status=_H5Gget_linkval(gid, fullname, 128l, link2 ); | |
272 | write,format=" %s -> %s\n","SOFTLINK",link2; | |
273 | objectInfo(0).objectType="SOFTLINK"; | |
274 | } else if (otype==H5G_TYPE) { | |
275 | write,format=" %s\n","DADATYPE"; | |
276 | objectInfo(0).objectType="DATATYPE"; | |
277 | } else { | |
278 | write,format=" %s\n","UNKNOWN OBJECT"; | |
279 | objectInfo(0).objectType="UNKNOWN OBJECT"; | |
280 | } | |
281 | } | |
282 | status=_H5Gclose(gid); | |
283 | if (has2bclose) h5close,file; | |
284 | // because of recursive aspect of function: | |
285 | // if(!_recur) _H5close; | |
286 | if (!_recur) return objectInfo; | |
287 | } | |
288 | ||
289 | ||
290 | //:::::::::::::::::::::::::::::::::::: | |
291 | ||
292 | ||
293 | func h5open(fname,mode) | |
294 | /* DOCUMENT func h5open(fname,mode) | |
295 | Open file for write, append or read access. | |
296 | ||
297 | filename: file name | |
298 | mode: access mode ("r"=read-only; "w"=write; "a"=append) | |
299 | ||
300 | Returns a file handle that can be used in further calls to HDF5 | |
301 | functions (e.g. h5read, h5write). | |
302 | ||
303 | If HDF5_SAFE=1, try to open in mode "w" an existing file will | |
304 | produce an error ( to prevent accidentaly overwritting the data). | |
305 | Delete the file prior to the h5open call if this is the case. | |
306 | ||
307 | SEE ALSO: h5close, h5list_open | |
308 | */ | |
309 | { | |
310 | extern _hdf5file; | |
311 | ||
312 | if (!fname||(fname=="")) error,"h5open takes at least one argument"; | |
313 | ||
314 | if (!mode) mode="a"; | |
315 | ||
316 | if (noneof(mode==["r","a","w"])) { | |
317 | error,"mode should be either \"r\",\"a\" or \"w\""; | |
318 | } | |
319 | ||
320 | // the following is to ensure we are not opening the file twice. | |
321 | // if the call was as a function, then we return the fd for the | |
322 | // already opened file. | |
323 | // in all case, we increment the # of open reference so that | |
324 | // when we open twice, we have to close twice (each open must | |
325 | // have its corresponding close | |
326 | // this will deal with case as: | |
327 | // 1. we explicitely open the file | |
328 | // 2. we call a function that open the file automatically | |
329 | // 3. this function will close the file, but | |
330 | // 4. the file must remain open as requested in (1), thus | |
331 | // has to be close by an explicit, balanced call to h5close | |
332 | // There is a catch to that: if the file is open in read-only, | |
333 | // we can't open it again in write or append, or vice-versa. | |
334 | ||
335 | if (_hdf5file!=[]) { | |
336 | if (anyof(_hdf5file.fname==fname)) { | |
337 | w = where(_hdf5file.fname==fname); | |
338 | if (numberof(w)) w=w(1); | |
339 | // error: file already open for reading | |
340 | if (((_hdf5file(w).curmode)=="r")&&(mode=="w")) { | |
341 | error,swrite(format="%s currently open for read-only",fname); | |
342 | } | |
343 | ||
344 | // error: file already open for writing | |
345 | if (((_hdf5file(w).curmode)=="w")&&(mode=="r")) { | |
346 | error,swrite(format="%s currently open for write-only",fname); | |
347 | } | |
348 | ||
349 | (_hdf5file(w).nref)++; | |
350 | return (_hdf5file(w).fd); | |
351 | } | |
352 | } | |
353 | ||
354 | // below we parse the input "fname" into a path and a file name. | |
355 | tok = strtok(fname,"/",20); | |
356 | tok = tok(where(tok)); | |
357 | if (numberof(tok)>1) { | |
358 | path = sum(tok(1:-1)+"/"); | |
359 | if (strpart(fname,1:1)=="/") path = "/"+path; | |
360 | path = strpart(path,1:-1); | |
361 | } else path="."; | |
362 | name=tok(0); | |
363 | ||
364 | // in case mode="r" or "a", file should already exist. check it. | |
365 | ctn = lsdir(path); | |
366 | if (anyof(mode==["a","r"])) { | |
367 | if (noneof(ctn==name)) | |
368 | error,swrite(format="File does not exist (mode=\"%s\")",mode); | |
369 | } else { // mode "w" | |
370 | if ((HDF5_SAFE)&&(anyof(ctn==name))) | |
371 | error,swrite(format="File already exist (mode=\"%s\") and HDF5_SAFE=1", | |
372 | mode); | |
373 | } | |
374 | ||
375 | // Open file | |
376 | if (mode=="r") { | |
377 | file=_H5Fopen(fname,H5F_ACC_RDONLY,0); | |
378 | if (file<0) { | |
379 | error,"Unable to open file (already open?)"; | |
380 | } | |
381 | } else { | |
382 | // does not exist, have to create: | |
383 | if (noneof(ctn==name)) mode="w"; | |
384 | if (mode=="a") { // open existing | |
385 | file = _H5Fopen(fname,H5F_ACC_RDWR,0); | |
386 | if (file<0) { | |
387 | error,"Unable to open file (already open?)"; | |
388 | } | |
389 | } else { // create: | |
390 | flags = H5F_ACC_TRUNC; | |
391 | file=_H5Fcreate(fname,H5F_ACC_TRUNC,0,0); | |
392 | if (file<0) { | |
393 | error,"Unable to create file (already open?)"; | |
394 | } | |
395 | } | |
396 | } | |
397 | // success. we can add the fname to the open file list: | |
398 | grow,_hdf5file,_hdf5file_struct(fname=fname,fd=file); | |
399 | w = where(_hdf5file.fname==fname)(1); | |
400 | _hdf5file(w).nref=1; | |
401 | _hdf5file(w).curmode=mode; | |
402 | ||
403 | return file; | |
404 | } | |
405 | ||
406 | ||
407 | //:::::::::::::::::::::::::::::::::::: | |
408 | ||
409 | ||
410 | func h5close(files) | |
411 | /* DOCUMENT func h5close(files) | |
412 | Close h5 access to file(s) (after a h5open) | |
413 | files: scalar or vector of file descriptor or file names | |
414 | Called without argument, this function closes all opened h5 files. | |
415 | */ | |
416 | { | |
417 | extern _hdf5file; | |
418 | ||
419 | if (files==[]) { | |
420 | // close all open files | |
421 | if (_hdf5file==[]) { | |
422 | write,format="%s\n","No file open"; | |
423 | return 0; | |
424 | } | |
425 | // select all files fd: | |
426 | files = _hdf5file.fd; | |
427 | // force nref to 1 so that close will happen | |
428 | _hdf5file.nref = _hdf5file.nref*0+1; | |
429 | } | |
430 | ||
431 | for (i=1;i<=numberof(files);i++) { // loop on input files | |
432 | if (!files(i)) continue; // could be 0 | |
433 | if (_hdf5file==[]) { | |
434 | write,format="%s\n","No file open"; | |
435 | return 0; | |
436 | } | |
437 | if (structof(files(i))==string) { | |
438 | // user passed file name, not file descriptor | |
439 | w = where(_hdf5file.fname==files(i)); | |
440 | wn = where(_hdf5file.fname!=files(i)); | |
441 | if (numberof(w)==0) | |
442 | error,swrite(format="%s does not exist. Can not close.",files(i)); | |
443 | fd = _hdf5file(w(1)).fd; | |
444 | } else { | |
445 | // user passed FD | |
446 | w = where(_hdf5file.fd==files(i)); | |
447 | wn = where(_hdf5file.fd!=files(i)); | |
448 | if (numberof(w)==0) | |
449 | error,swrite(format="File descriptor (%d) does not correspond"+ | |
450 | " to any open file. Can not close",files(i)); | |
451 | fd = files(i); | |
452 | } | |
453 | // see comment in h5open. If files has been opened several times, | |
454 | // we don't close it until the # opened reference is == 1 | |
455 | w=where(_hdf5file.fd==files(i))(1); | |
456 | if ((_hdf5file(w).nref)(1)>1) { | |
457 | (_hdf5file(w).nref)--; | |
458 | continue; | |
459 | } | |
460 | status = _H5Fclose(fd); | |
461 | if (status) error,swrite(format="Error closing file %s\n",_hdf5file(w).fname); | |
462 | // now suppress entry in _hdf5file: | |
463 | if (numberof(wn)==0) _hdf5file=[]; | |
464 | else _hdf5file=_hdf5file(wn); | |
465 | } | |
466 | return 0; | |
467 | } | |
468 | ||
469 | ||
470 | //:::::::::::::::::::::::::::::::::::: | |
471 | ||
472 | ||
473 | func h5list_open(void) | |
474 | /* DOCUMENT func h5list_open(void) | |
475 | Print (or return) a lit of open h5 files. | |
476 | SEE ALSO: h5open, h5close | |
477 | */ | |
478 | { | |
479 | extern _hdf5file; | |
480 | ||
481 | if (_hdf5file==[]) { | |
482 | write,format="%s\n","No file open"; | |
483 | return; | |
484 | } | |
485 | ||
486 | if (am_subroutine()) { | |
487 | write,format="%-20s mode \"%s\" (%d ref)\n",_hdf5file.fname, | |
488 | _hdf5file.curmode,_hdf5file.nref; | |
489 | } else { | |
490 | return _hdf5file.fname; | |
491 | } | |
492 | } | |
493 | ||
494 | ||
495 | //:::::::::::::::::::::::::::::::::::: | |
496 | ||
497 | ||
498 | func h5read(file,target) | |
499 | /* DOCUMENT data=h5read(file,target) | |
500 | Read content of one dataset in a HDF5 file and return the data | |
501 | ||
502 | file: h5 file name (string) or h5 file id (output from h5open) | |
503 | target: dataset name (string) | |
504 | ||
505 | This will read all data type but datatype will be casted to one | |
506 | of the yorick datatype (char,short,int,long,float,double,string). | |
507 | SEE ALSO: H5write, h5info, h5link, h5delete | |
508 | */ | |
509 | { | |
510 | if (structof(file)==string) { | |
511 | has2bclose=1; | |
512 | file = h5open(file,"r"); | |
513 | } | |
514 | ||
515 | // Open dataset | |
516 | dataset=_H5Dopen(file,target); | |
517 | if (dataset<0) { | |
518 | if (has2bclose) h5close,file; | |
519 | error,"Unable to find Dataset"; | |
520 | } | |
521 | ||
522 | // get dataspace id: | |
523 | dspid=_H5Dget_space(dataset); | |
524 | ||
525 | //get rank: | |
526 | rank = _H5Sget_simple_extent_ndims(dspid); | |
527 | if (rank) { | |
528 | dims = maxdims = array(long,rank); | |
529 | status = _H5Sget_simple_extent_dims(dspid,dims,maxdims); | |
530 | } else {dims=0;} | |
531 | ||
532 | ytype=yotype(_H5Dget_type(dataset),h5type); | |
533 | ||
534 | if (ytype==-1) error,"Unknown Datatype"; | |
535 | ||
536 | data = array(ytype,_(rank,dims)); | |
537 | if (structof(ytype)==string) { | |
538 | nelem = numberof(data); | |
539 | data=_H5Dreads(dataset,data,nelem); | |
540 | } else { | |
541 | status=_H5Dread(dataset,h5type,0,0,0,&data); | |
542 | } | |
543 | ||
544 | status=_H5Dclose(dataset); | |
545 | if (has2bclose) {h5close,file;} | |
546 | ||
547 | return data; | |
548 | } | |
549 | ||
550 | ||
551 | //:::::::::::::::::::::::::::::::::::: | |
552 | ||
553 | ||
554 | func h5write(file,fullpath,data,zip=,mode=) | |
555 | /* DOCUMENT h5write,file,fullpath,data,zip=,mode= | |
556 | Write data in a HDF5 file. | |
557 | fname: file name or file handle (from h5open) | |
558 | fullpath: full path to the dataset (string), including | |
559 | hierarchy (ex: "/g1/data"). If parent group(s) | |
560 | do not exist, they will be created. This function | |
561 | will refuse to overwrite an existing dataset. | |
562 | To do so, use delete the dataset with h5delete | |
563 | prior to the h5write. | |
564 | data: data. Any yorick valid data. Scalar or arrays. | |
565 | Any yorick type is accepted (from char to double, | |
566 | and strings). Strings are stored in H5T_VARIABLE, | |
567 | which is a variable length type in the HDF5 | |
568 | specification. | |
569 | zip=N will use compression (N=0-9). Larger N will | |
570 | compress more (but take longer). | |
571 | ||
572 | mode= "w"=write-only (erase previous content) or "a"=append | |
573 | ||
574 | Warning: If file is a string, then mode="w" is used, | |
575 | which means an existing file will be overwritten. | |
576 | To update an existing file, use a file handle | |
577 | with the h5open/h5write/h5close combination. | |
578 | ||
579 | SEE ALSO: h5read, h5info, h5link, h5delete | |
580 | */ | |
581 | { | |
582 | if (!mode) mode="w"; | |
583 | ||
584 | tmp = strpart(fullpath,strword(fullpath,"/",10)); | |
585 | tmp = tmp(where(tmp)); | |
586 | dataname = tmp(0); | |
587 | if (numberof(tmp)>1) { | |
588 | group = ("/"+tmp(1:-1))(sum); | |
589 | } else group="/"; | |
590 | ||
591 | ||
592 | // Open/Create FILE | |
593 | if (structof(file)==string) { | |
594 | has2bclose=1; | |
595 | // default to overwrite when using the simple | |
596 | // filename option | |
597 | file = h5open(file,mode); | |
598 | } | |
599 | ||
600 | if ((group!="/")&&(strpart(group,0:0)=="/")) group=strpart(group,1:-1); | |
601 | ||
602 | // Open/Create GROUP | |
603 | gid = _H5Gopen(file,group); | |
604 | if (gid<0) { //group does not exist, create: | |
605 | g = strpart(group,strword(group,"/",20)); | |
606 | g = g(where(g)); | |
607 | g = "/"+g; | |
608 | for (i=1;i<=numberof(g);i++) { | |
609 | gid = _H5Gopen(file,g(1:i)(sum)); | |
610 | if (gid<0) { | |
611 | gid = _H5Gcreate(file,g(1:i)(sum),0); | |
612 | status=_H5Gclose(gid); | |
613 | } | |
614 | if (gid<0) { | |
615 | if (has2bclose) h5close,file; | |
616 | error,"Unable to create group"; | |
617 | } | |
618 | status=_H5Gclose(gid); | |
619 | } | |
620 | gid = _H5Gopen(file,group); | |
621 | } | |
622 | ||
623 | // Determine dimsof() data | |
624 | rank = dimsof(data)(1); | |
625 | if (rank>0) { dims = dimsof(data)(2:); } | |
626 | ||
627 | if (rank==0) { | |
628 | dataspace = _H5Screate(H5S_SCALAR); | |
629 | } else { | |
630 | dataspace=_H5Screate_simple(rank,dims); | |
631 | if (dataspace<0) { | |
632 | status=_H5Gclose(gid); | |
633 | if (has2bclose) h5close,file; | |
634 | error,"Unable to create dataspace"; | |
635 | } | |
636 | } | |
637 | ||
638 | // Handle compression | |
639 | if ((zip!=[])&&(rank)) { | |
640 | plist = _H5Pcreate(H5P_DATASET_CREATE); | |
641 | rank = dimsof(data)(1); | |
642 | cdims = min(dimsof(data)(2:),20); | |
643 | status = _H5Pset_chunk(plist, 2, cdims); | |
644 | status = _H5Pset_deflate( plist, zip); | |
645 | } else plist=H5P_DEFAULT; | |
646 | ||
647 | if (structof(data)==char) htype=H5T_NATIVE_CHAR; | |
648 | if (structof(data)==short) htype=H5T_NATIVE_SHORT; | |
649 | if (structof(data)==int) htype=H5T_NATIVE_INT; | |
650 | if (structof(data)==long) htype=H5T_NATIVE_LONG; | |
651 | if (structof(data)==float) htype=H5T_NATIVE_FLOAT; | |
652 | if (structof(data)==double) htype=H5T_NATIVE_DOUBLE; | |
653 | if (structof(data)==string) { | |
654 | /* create a datatype for the text */ | |
655 | htype = _H5Tcopy(H5T_C_S1); | |
656 | /* set the total size for the datatype */ | |
657 | status = _H5Tset_size (htype,H5T_VARIABLE); | |
658 | plist = _H5Pcreate(H5P_DATASET_CREATE); | |
659 | } | |
660 | ||
661 | ||
662 | // Create dataset | |
663 | dataset=_H5Dcreate(file,group+"/"+dataname,htype,dataspace,plist); | |
664 | if (dataset<0) { | |
665 | status=_H5Sclose(dataspace); | |
666 | status=_H5Gclose(gid); | |
667 | if (has2bclose) h5close,file; | |
668 | error,"Unable to create dataset (already exist?)"; | |
669 | } | |
670 | ||
671 | // and finally, write data... | |
672 | swrite=_H5Dwrite(dataset,htype,0,0,0,&data); | |
673 | ||
674 | status=_H5Sclose(dataspace); | |
675 | status=_H5Dclose(dataset); | |
676 | status=_H5Gclose(gid); | |
677 | if (has2bclose) h5close,file; | |
678 | if (swrite<0) error,"Unable to write data"; | |
679 | } | |
680 | ||
681 | ||
682 | //:::::::::::::::::::::::::::::::::::: | |
683 | ||
684 | ||
685 | func h5adelete(file,object,aname) | |
686 | /* DOCUMENT h5adelete,file,object,aname | |
687 | Delete attribute "aname" in object "object" in HDF5 file "file" | |
688 | SEE ALSO: h5aread, h5awrite | |
689 | */ | |
690 | { | |
691 | // Open FILE | |
692 | if (structof(file)==string) { | |
693 | has2bclose=1; | |
694 | file = h5open(file,"a"); | |
695 | } | |
696 | ||
697 | oid=_H5Dopen(file,object); | |
698 | if (oid<0) { // may be a group? | |
699 | oid=_H5Gopen(file,object); | |
700 | isgroup=1; | |
701 | if (oid<0) { | |
702 | if (has2bclose) h5close,file; | |
703 | error,swrite(format="Unable to find object %s\n",object); | |
704 | } | |
705 | } | |
706 | ||
707 | if (structof(aname)==string) { | |
708 | // attribute name passed as a string | |
709 | // check attribute exist: | |
710 | attid = _H5Aopen_name(oid,aname); | |
711 | if (attid<0) { | |
712 | if (isgroup) status=_H5Gclose(oid); | |
713 | else status=_H5Dclose(oid); | |
714 | if (has2bclose) h5close,file; | |
715 | error,swrite(format="No such attribute \"%s\" in %s\n",aname,object); | |
716 | } | |
717 | // we can (have to) close it | |
718 | status = _H5Aclose(attid); | |
719 | } else if ((structof(aname)==int)||(structof(aname)==long)) { | |
720 | // attribute name passed as an index | |
721 | attid = _H5Aopen_idx(oid,aname); | |
722 | if (attid<0) { | |
723 | if (isgroup) status=_H5Gclose(oid); | |
724 | else status=_H5Dclose(oid); | |
725 | if (has2bclose) h5close,file; | |
726 | error,swrite(format="No such attribute #%d in %s\n",aname,object); | |
727 | } | |
728 | // if it exist, then get name: | |
729 | aname = array(" ",129)(sum); | |
730 | status= _H5Aget_name(attid,128,aname); | |
731 | } else { | |
732 | if (isgroup) status=_H5Gclose(oid); | |
733 | else status=_H5Dclose(oid); | |
734 | if (has2bclose) h5close,file; | |
735 | error,"Unknow attribute name type"; | |
736 | } | |
737 | ||
738 | status = _H5Adelete(oid,aname); | |
739 | ||
740 | if (isgroup) status=_H5Gclose(oid); | |
741 | else status=_H5Dclose(oid); | |
742 | ||
743 | if (has2bclose) h5close,file; | |
744 | } | |
745 | ||
746 | ||
747 | //:::::::::::::::::::::::::::::::::::: | |
748 | ||
749 | ||
750 | func h5aread(file,object,aname) | |
751 | /* DOCUMENT attrib = h5aread(file,object,aname) | |
752 | Read the value of an object attribute in a HDF5 file | |
753 | file: file name (string) or file handle (from h5open) | |
754 | object: object name (type GROUP or DATASET) (string) | |
755 | aname: attribute name (string) or id (int). | |
756 | If aname=[], then all attributes of the given object are read out | |
757 | and returned. | |
758 | SEE ALSO: h5awrite, h5adelete | |
759 | */ | |
760 | { | |
761 | // Open FILE | |
762 | if (structof(file)==string) { | |
763 | has2bclose=1; | |
764 | file = h5open(file,"r"); | |
765 | } | |
766 | ||
767 | // Open object | |
768 | oid=_H5Dopen(file,object); | |
769 | if (oid<0) { // may be a group? | |
770 | oid=_H5Gopen(file,object); | |
771 | isgroup=1; | |
772 | if (oid<0) { | |
773 | if (has2bclose) h5close,file; | |
774 | error,swrite(format="Unable to find object %s\n",object); | |
775 | } | |
776 | } | |
777 | ||
778 | if (structof(aname)==string) { | |
779 | attid = _H5Aopen_name(oid,aname); | |
780 | if (attid<0) { | |
781 | if (isgroup) status=_H5Gclose(oid); | |
782 | else status=_H5Dclose(oid); | |
783 | if (has2bclose) h5close,file; | |
784 | error,swrite(format="No such attribute \"%s\" in %s\n",aname,object); | |
785 | } | |
786 | } else if ((structof(aname)==int)||(structof(aname)==long)) { | |
787 | attid = _H5Aopen_idx(oid,aname); | |
788 | if (attid<0) { | |
789 | if (isgroup) status=_H5Gclose(oid); | |
790 | else status=_H5Dclose(oid); | |
791 | if (has2bclose) h5close,file; | |
792 | error,swrite(format="No such attribute #%d in %s\n",aname,object); | |
793 | } | |
794 | str = array(" ",128)(sum); | |
795 | status= _H5Aget_name(attid,128,str); | |
796 | //write,format="Retrieving Attribute %s\n",str; | |
797 | } else { | |
798 | if (isgroup) status=_H5Gclose(oid); | |
799 | else status=_H5Dclose(oid); | |
800 | if (has2bclose) h5close,file; | |
801 | error,"Unknow attribute name type"; | |
802 | } | |
803 | ||
804 | dspid = _H5Aget_space(attid); | |
805 | rank = _H5Sget_simple_extent_ndims(dspid); | |
806 | if (rank) { | |
807 | dims = maxdims = array(long,rank); | |
808 | status = _H5Sget_simple_extent_dims(dspid,dims,maxdims); | |
809 | } else {dims=0;} | |
810 | ||
811 | ytype=yotype(_H5Aget_type(attid),h5type); | |
812 | ||
813 | if (ytype==-1) error,"Unknow attribute data type"; | |
814 | ||
815 | data = array(ytype,_(rank,dims)); | |
816 | if (structof(ytype)==string) { | |
817 | nelem = numberof(data); | |
818 | data=_H5Areads(attid,data,nelem); | |
819 | } else { | |
820 | status=_H5Aread(attid,h5type,&data); | |
821 | } | |
822 | ||
823 | status=_H5Aclose(attid); | |
824 | if (isgroup) status=_H5Gclose(oid); | |
825 | else status=_H5Dclose(oid); | |
826 | if (has2bclose) h5close,file; | |
827 | ||
828 | if (numberof(data)==1) data=data(1); | |
829 | return data; | |
830 | } | |
831 | ||
832 | ||
833 | //:::::::::::::::::::::::::::::::::::: | |
834 | ||
835 | ||
836 | func h5awrite(file,object,aname,attdata) | |
837 | /* DOCUMENT h5awrite,file,object,aname,attdata | |
838 | Write an object attribute in a HDF5 file, attached to | |
839 | a group or a dataset. | |
840 | ||
841 | file: file name (string) or file handle (from h5open) | |
842 | object: object name (type GROUP or DATASET) (string) | |
843 | aname: attribute name (string) | |
844 | attdata: attribute value (data). Any yorick type. Can be scalar | |
845 | or an array. HDF5 limits length to about 1000 elements. | |
846 | SEE ALSO: h5aread, h5adelete | |
847 | */ | |
848 | { | |
849 | // Open FILE | |
850 | if (structof(file)==string) { | |
851 | has2bclose=1; | |
852 | file = h5open(file,"a"); | |
853 | } | |
854 | ||
855 | // open object | |
856 | oid=_H5Dopen(file,object); | |
857 | if (oid<0) { // may be a group? | |
858 | oid=_H5Gopen(file,object); | |
859 | isgroup=1; | |
860 | if (oid<0) { | |
861 | if (has2bclose) h5close,file; | |
862 | error,swrite(format="Unable to find object %s\n",object); | |
863 | } | |
864 | } | |
865 | ||
866 | ||
867 | props=H5T_DEFAULT; | |
868 | ||
869 | if (structof(attdata)==char) htype=H5T_NATIVE_CHAR; | |
870 | if (structof(attdata)==short) htype=H5T_NATIVE_SHORT; | |
871 | if (structof(attdata)==int) htype=H5T_NATIVE_INT; | |
872 | if (structof(attdata)==long) htype=H5T_NATIVE_LONG; | |
873 | if (structof(attdata)==float) htype=H5T_NATIVE_FLOAT; | |
874 | if (structof(attdata)==double) htype=H5T_NATIVE_DOUBLE; | |
875 | ||
876 | if (structof(attdata)==string) { | |
877 | /* create a datatype for the text */ | |
878 | htype = _H5Tcopy(H5T_C_S1); | |
879 | /* set the total size for the datatype */ | |
880 | status = _H5Tset_size (htype,H5T_VARIABLE); | |
881 | props = _H5Pcreate(H5P_DATASET_CREATE); | |
882 | } | |
883 | ||
884 | rank = dimsof(attdata)(1); | |
885 | if (rank>0) { | |
886 | dims = dimsof(attdata)(2:); | |
887 | } | |
888 | ||
889 | if (rank==0) { | |
890 | dataspace = _H5Screate(H5S_SCALAR); | |
891 | } else { | |
892 | dataspace=_H5Screate_simple(rank,dims); | |
893 | if (dataspace<0) { | |
894 | if (isgroup) status=_H5Gclose(oid); | |
895 | else status=_H5Dclose(oid); | |
896 | if (has2bclose) h5close,file; | |
897 | error,"Unable to create attribute dataspace"; | |
898 | } | |
899 | } | |
900 | ||
901 | /* Create a dataset attribute. */ | |
902 | attid = _H5Acreate(oid, aname, htype, dataspace, props); | |
903 | if (attid<0) { | |
904 | if (has2bclose) h5close,file; | |
905 | error,"Unable to create attribute (already exist?)"; | |
906 | } | |
907 | ||
908 | /* Write the attribute data. */ | |
909 | status = _H5Awrite(attid, htype, &attdata); | |
910 | ||
911 | /* Close the attribute. */ | |
912 | status = _H5Aclose(attid); | |
913 | ||
914 | status=_H5Sclose(dataspace); | |
915 | if (isgroup) status=_H5Gclose(oid); | |
916 | else status=_H5Dclose(oid); | |
917 | ||
918 | if (has2bclose) h5close,file; | |
919 | } | |
920 | ||
921 | ||
922 | //:::::::::::::::::::::::::::::::::::: | |
923 | ||
924 | ||
925 | func h5link(file,group,group2link2,linktype) | |
926 | /* DOCUMENT h5link,file,group,group2link2,linktype | |
927 | Create a SOFT or HARD link to a group in a HDF5 file | |
928 | ||
929 | file: file name (string) or file handle (from h5open) | |
930 | group: group to create that link to group2link2 | |
931 | Must not already exist. | |
932 | group2link2: group to link to. Must exist. Has to be a group, | |
933 | Can NOT be a dataset (error). | |
934 | linktype: link type. valid are: | |
935 | H5G_LINK_HARD or H5G_LINK_SOFT | |
936 | ||
937 | SEE ALSO: h5read, h5write, h5info, h5delete | |
938 | */ | |
939 | { | |
940 | if (linktype==[]) linktype=H5G_LINK_SOFT; | |
941 | if (noneof(linktype==[H5G_LINK_HARD,H5G_LINK_SOFT])) { | |
942 | error,"Unknow link type"; | |
943 | } | |
944 | ||
945 | // Open FILE | |
946 | if (structof(file)==string) { | |
947 | has2bclose=1; | |
948 | file = h5open(file,"a"); | |
949 | } | |
950 | ||
951 | if ((group!="/")&&(strpart(group,0:0)=="/")) group=strpart(group,1:-1); | |
952 | ||
953 | // Open/Create GROUP | |
954 | gid = _H5Gopen(file,group); | |
955 | if (gid>0) { | |
956 | // group already exist. it should not | |
957 | status=_H5Gclose(gid); | |
958 | if (has2bclose) h5close,file; | |
959 | error,"Group already exist"; | |
960 | } | |
961 | ||
962 | // we create up to group parent level, as final link group will be | |
963 | // created by the H5Glink2 call | |
964 | g = strpart(group,strword(group,"/",20)); | |
965 | g = g(where(g)); | |
966 | if (numberof(g)==1) { | |
967 | groupParent="/"; | |
968 | } else { | |
969 | groupParent = ("/"+g(1:-1))(sum); | |
970 | } | |
971 | ||
972 | gid = _H5Gopen(file,groupParent); | |
973 | if (gid<0) { //groupParent does not exist, create: | |
974 | g = strpart(groupParent,strword(groupParent,"/",20)); | |
975 | g = g(where(g)); | |
976 | g = "/"+g; | |
977 | gid2 = array(long,numberof(g)); | |
978 | for (i=1;i<=numberof(g);i++) { | |
979 | gid2(i) = _H5Gopen(file,g(1:i)(sum)); | |
980 | if (gid2(i)<0) gid2(i) = _H5Gcreate(file,g(1:i)(sum),0); | |
981 | if (gid2(i)<0) { | |
982 | for (j=1;j<=(i-1);j++) status = _H5Gclose(gid2(j)); | |
983 | if (has2bclose) h5close,file; | |
984 | error,"Unable to create groupParent (already exist?)"; | |
985 | } | |
986 | } | |
987 | gid = gid2(0); | |
988 | } | |
989 | ||
990 | // check that group2link2 exists | |
991 | ||
992 | gid2link2 = _H5Gopen(file,group2link2); | |
993 | if (gid2link2<0) { | |
994 | if (anyof(gid2)) { | |
995 | for (j=1;j<=numberof(gid2);j++) status = _H5Gclose(gid2(j)); | |
996 | } else status=_H5Gclose(gid); | |
997 | if (has2bclose) h5close,file; | |
998 | error,"Unable to open destination group (has to be a group, not dataset)"; | |
999 | } | |
1000 | ||
1001 | // now we can link | |
1002 | slink = _H5Glink2(gid2link2, group2link2, linktype, gid, group); | |
1003 | ||
1004 | if (anyof(gid2)) { | |
1005 | for (j=1;j<=numberof(gid2);j++) status = _H5Gclose(gid2(j)); | |
1006 | } else status=_H5Gclose(gid); | |
1007 | status=_H5Gclose(gid2link2); | |
1008 | if (has2bclose) h5close,file; | |
1009 | if (slink<0) error,"Unable to link groups"; | |
1010 | } | |
1011 | ||
1012 | ||
1013 | //:::::::::::::::::::::::::::::::::::: | |
1014 | ||
1015 | ||
1016 | func h5delete(file,object) | |
1017 | /* DOCUMENT h5delete,file,object | |
1018 | Unlink or delete an object in a HDF5 file. | |
1019 | ||
1020 | file: file name (string) or file handle (from h5open) | |
1021 | object: object name (string) | |
1022 | ||
1023 | SEE ALSO: h5write, h5read, h5link, h5info | |
1024 | */ | |
1025 | { | |
1026 | // Open FILE | |
1027 | if (structof(file)==string) { | |
1028 | has2bclose=1; | |
1029 | file = h5open(file,"a"); | |
1030 | } | |
1031 | ||
1032 | status=_H5Gunlink(file, object); | |
1033 | ||
1034 | if (has2bclose) h5close,file; | |
1035 | if (status<0) error,"Unable to link groups"; | |
1036 | } | |
1037 | h5unlink=h5delete; | |
1038 | ||
1039 | ||
1040 | //:::::::::::::::::::::::::::::::::::: | |
1041 | ||
1042 | ||
1043 | func h5version(void) | |
1044 | { | |
1045 | res = _H5version(); | |
1046 | if (am_subroutine()) { | |
1047 | write,format="libhdf5 version %d.%d.%d\n",res(1),res(2),res(3); | |
1048 | } else return res; | |
1049 | } | |
1050 | ||
1051 | ||
1052 | //:::::::::::::::::::::::::::::::::::: | |
1053 | //::::::UTILITY FUNCTIONS::::::::::::: | |
1054 | //:::::::::::::::::::::::::::::::::::: | |
1055 | ||
1056 | ||
1057 | func yotype(tid,&h5type) { | |
1058 | ||
1059 | tclass = _H5Tget_class(tid); | |
1060 | if (tclass < 0) { | |
1061 | write," Invalid datatype"; | |
1062 | } else { | |
1063 | ||
1064 | tsize=_H5Tget_size(tid); | |
1065 | ||
1066 | if (tclass == H5T_INTEGER) { | |
1067 | if (tsize==sizeof(long) ) {h5type=H5T_NATIVE_LONG; return 0l;} | |
1068 | if (tsize==sizeof(int) ) {h5type=H5T_NATIVE_INT; return 0n;} | |
1069 | if (tsize==sizeof(short)) {h5type=H5T_NATIVE_SHORT; return 0s;} | |
1070 | if (tsize==sizeof(char) ) {h5type=H5T_NATIVE_CHAR; return '0';} | |
1071 | } else if (tclass == H5T_FLOAT) { | |
1072 | if (tsize==sizeof(float)) {h5type=H5T_NATIVE_FLOAT; return 0.0f;} | |
1073 | if (tsize==sizeof(double)) {h5type=H5T_NATIVE_DOUBLE; return 0.0;} | |
1074 | } else if (tclass == H5T_STRING) { | |
1075 | h5type=H5T_C_S1; | |
1076 | return ""; | |
1077 | } else { | |
1078 | // print,"Unknown Datatype"; | |
1079 | return -1; | |
1080 | } | |
1081 | } | |
1082 | } | |
1083 | ||
1084 | ||
1085 | func h5off(void) | |
1086 | /* DOCUMENT h5ooff | |
1087 | Flushes all data to disk, closes file identifiers, and cleans up memory. | |
1088 | ||
1089 | SEE ALSO: | |
1090 | */ | |
1091 | { | |
1092 | extern _hdf5file; | |
1093 | _H5close; | |
1094 | _hdf5file=[]; | |
1095 | } | |
1096 | ||
1097 | /**********************************************/ | |
1098 | /* DEFINE BUILTINS AND EXTERNS H5 DEFINITIONS */ | |
1099 | /**********************************************/ | |
1100 | ||
1101 | extern _H5Eon; | |
1102 | extern _H5Eoff; | |
1103 | extern _H5open; | |
1104 | extern _H5close; | |
1105 | extern _H5version; | |
1106 | ||
1107 | // FILE APIs: | |
1108 | extern _H5Fcreate; | |
1109 | extern _H5Fopen; | |
1110 | extern _H5Fclose; | |
1111 | ||
1112 | // GROUP APIs: | |
1113 | extern _H5Gget_linkval; | |
1114 | extern _H5Gopen; | |
1115 | extern _H5Gclose; | |
1116 | extern _H5Gcreate; | |
1117 | extern _H5Gget_num_objs; // numobj = _H5Gget_num_objs(gid) | |
1118 | extern _H5Gget_objname_by_idx; | |
1119 | extern _H5Gget_objtype_by_idx; | |
1120 | extern _H5Gget_objtype_by_name; | |
1121 | extern _H5Glink2; | |
1122 | extern _H5Gunlink; | |
1123 | ||
1124 | // PROPERTY LIST APIs: | |
1125 | extern _H5Pcreate; //int H5Pcreate(int cls_id ) | |
1126 | extern _H5Pset_deflate; //int H5Pset_deflate(int plist, int level) | |
1127 | extern _H5Pset_chunk; | |
1128 | ||
1129 | // ATTRIBUTE APIs: | |
1130 | extern _H5Acreate; | |
1131 | extern _H5Adelete; | |
1132 | extern _H5Aget_num_attrs; | |
1133 | extern _H5Aget_type; | |
1134 | extern _H5Aget_space; | |
1135 | extern _H5Aget_name; | |
1136 | extern _H5Aopen_idx; | |
1137 | extern _H5Aopen_name; | |
1138 | extern _H5Aread; | |
1139 | extern _H5Awrite; | |
1140 | extern _H5Aclose; | |
1141 | ||
1142 | // DATASET API: | |
1143 | extern _H5Dclose; | |
1144 | extern _H5Dcreate; | |
1145 | extern _H5Dopen; | |
1146 | extern _H5Dget_space; | |
1147 | extern _H5Dget_type; | |
1148 | extern _H5Dwrite; | |
1149 | extern _H5Dread; | |
1150 | ||
1151 | // DATASPACE APIs: | |
1152 | ||
1153 | extern _H5Sclose | |
1154 | extern _H5Screate | |
1155 | extern _H5Sget_simple_extent_ndims; | |
1156 | extern _H5Sget_simple_extent_type; | |
1157 | extern _H5Screate_simple; | |
1158 | extern _H5Sget_simple_extent_dims; | |
1159 | ||
1160 | // Datatype APIs | |
1161 | //************** | |
1162 | extern _H5Tcopy; | |
1163 | extern _H5Tget_class; | |
1164 | extern _H5Tget_size; | |
1165 | extern _H5Tset_cset; | |
1166 | extern _H5Tset_size; | |
1167 | extern _H5Tset_strpad; | |
1168 | ||
1169 | ||
1170 | // special read function for Attributes and Dataset string reads: | |
1171 | extern _H5Areads; | |
1172 | extern _H5Dreads; | |
1173 | ||
1174 | ||
1175 | // The following types are dynamically assigned at the hdf5 library | |
1176 | // compile time, so I need to resort to function calls here. | |
1177 | extern _H5T_C_S1; H5T_C_S1=_H5T_C_S1(); | |
1178 | extern _H5T_NATIVE_CHAR; H5T_NATIVE_CHAR=_H5T_NATIVE_CHAR(); | |
1179 | extern _H5T_NATIVE_SHORT; H5T_NATIVE_SHORT=_H5T_NATIVE_SHORT(); | |
1180 | extern _H5T_NATIVE_INT; H5T_NATIVE_INT=_H5T_NATIVE_INT(); | |
1181 | extern _H5T_NATIVE_LONG; H5T_NATIVE_LONG=_H5T_NATIVE_LONG(); | |
1182 | extern _H5T_NATIVE_FLOAT; H5T_NATIVE_FLOAT=_H5T_NATIVE_FLOAT(); | |
1183 | extern _H5T_NATIVE_DOUBLE; H5T_NATIVE_DOUBLE=_H5T_NATIVE_DOUBLE(); | |
1184 | extern _H5T_IEEE_F32BE; H5T_IEEE_F32BE=_H5T_IEEE_F32BE(); | |
1185 | extern _H5T_IEEE_F32LE; H5T_IEEE_F32LE=_H5T_IEEE_F32LE(); | |
1186 | extern _H5T_IEEE_F64BE; H5T_IEEE_F64BE=_H5T_IEEE_F64BE(); | |
1187 | extern _H5T_IEEE_F64LE; H5T_IEEE_F64LE=_H5T_IEEE_F64LE(); | |
1188 | extern _H5T_STD_I8BE; H5T_STD_I8BE=_H5T_STD_I8BE(); | |
1189 | extern _H5T_STD_I8LE; H5T_STD_I8LE=_H5T_STD_I8LE(); | |
1190 | extern _H5T_STD_I16BE; H5T_STD_I16BE=_H5T_STD_I16BE(); | |
1191 | extern _H5T_STD_I16LE; H5T_STD_I16LE=_H5T_STD_I16LE(); | |
1192 | extern _H5T_STD_I32BE; H5T_STD_I32BE=_H5T_STD_I32BE(); | |
1193 | extern _H5T_STD_I32LE; H5T_STD_I32LE=_H5T_STD_I32LE(); | |
1194 | extern _H5T_STD_I64BE; H5T_STD_I64BE=_H5T_STD_I64BE(); | |
1195 | extern _H5T_STD_I64LE; H5T_STD_I64LE=_H5T_STD_I64LE(); | |
1196 | extern _H5T_STD_U8BE; H5T_STD_U8BE=_H5T_STD_U8BE(); | |
1197 | extern _H5T_STD_U8LE; H5T_STD_U8LE=_H5T_STD_U8LE(); | |
1198 | extern _H5T_STD_U16BE; H5T_STD_U16BE=_H5T_STD_U16BE(); | |
1199 | extern _H5T_STD_U16LE; H5T_STD_U16LE=_H5T_STD_U16LE(); | |
1200 | extern _H5T_STD_U32BE; H5T_STD_U32BE=_H5T_STD_U32BE(); | |
1201 | extern _H5T_STD_U32LE; H5T_STD_U32LE=_H5T_STD_U32LE(); | |
1202 | extern _H5T_STD_U64BE; H5T_STD_U64BE=_H5T_STD_U64BE(); | |
1203 | extern _H5T_STD_U64LE; H5T_STD_U64LE=_H5T_STD_U64LE(); | |
1204 | extern _H5T_STD_B8BE; H5T_STD_B8BE=_H5T_STD_B8BE(); | |
1205 | extern _H5T_STD_B8LE; H5T_STD_B8LE=_H5T_STD_B8LE(); | |
1206 | extern _H5T_STD_B16BE; H5T_STD_B16BE=_H5T_STD_B16BE(); | |
1207 | extern _H5T_STD_B16LE; H5T_STD_B16LE=_H5T_STD_B16LE(); | |
1208 | extern _H5T_STD_B32BE; H5T_STD_B32BE=_H5T_STD_B32BE(); | |
1209 | extern _H5T_STD_B32LE; H5T_STD_B32LE=_H5T_STD_B32LE(); | |
1210 | extern _H5T_STD_B64BE; H5T_STD_B64BE=_H5T_STD_B64BE(); | |
1211 | extern _H5T_STD_B64LE; H5T_STD_B64LE=_H5T_STD_B64LE(); | |
1212 | extern _H5T_STD_REF_OBJ; H5T_STD_REF_OBJ=_H5T_STD_REF_OBJ(); | |
1213 | extern _H5T_UNIX_D32BE; H5T_UNIX_D32BE=_H5T_UNIX_D32BE(); | |
1214 | extern _H5T_UNIX_D32LE; H5T_UNIX_D32LE=_H5T_UNIX_D32LE(); | |
1215 | extern _H5T_UNIX_D64BE; H5T_UNIX_D64BE=_H5T_UNIX_D64BE(); | |
1216 | extern _H5T_UNIX_D64LE; H5T_UNIX_D64LE=_H5T_UNIX_D64LE(); | |
1217 | extern _H5P_DATASET_CREATE; H5P_DATASET_CREATE=_H5P_DATASET_CREATE(); | |
1218 | ||
1219 | H5F_ACC_RDONLY = 0x0000; /* absence of rdwr => rd-only */ | |
1220 | H5F_ACC_RDWR = 0x0001; /* open for read and write */ | |
1221 | H5F_ACC_TRUNC = 0x0002; /* overwrite existing files */ | |
1222 | H5F_ACC_EXCL = 0x0004; /* fail if file already exists*/ | |
1223 | H5F_ACC_DEBUG = 0x0008; /* print debug info */ | |
1224 | H5F_ACC_CREAT = 0x0010; /* create non-existing files */ | |
1225 | ||
1226 | H5P_DEFAULT = 0; | |
1227 | H5T_DEFAULT = 0; | |
1228 | ||
1229 | H5S_NO_CLASS = -1; /* error */ | |
1230 | H5S_SCALAR = 0; /* scalar variable */ | |
1231 | H5S_SIMPLE = 1; /* simple data space */ | |
1232 | H5S_COMPLEX = 2; /* complex data space */ | |
1233 | ||
1234 | H5T_NO_CLASS = -1; /* error */ | |
1235 | H5T_INTEGER = 0; /* integer types */ | |
1236 | H5T_FLOAT = 1; /* floating-point types */ | |
1237 | H5T_TIME = 2; /* date and time types */ | |
1238 | H5T_STRING = 3; /* character string types */ | |
1239 | H5T_BITFIELD = 4; /* bit field types */ | |
1240 | H5T_OPAQUE = 5; /* opaque types */ | |
1241 | H5T_COMPOUND = 6; /* compound types */ | |
1242 | H5T_REFERENCE = 7; /* reference types */ | |
1243 | H5T_ENUM = 8; /* enumeration types */ | |
1244 | H5T_VLEN = 9; /* Variable-Length types */ | |
1245 | H5T_ARRAY = 10; /* Array types */ | |
1246 | ||
1247 | H5T_VARIABLE = -1; /* Indicate that a string is variable length (null- */ | |
1248 | /* terminated in C, instead of fixed length) */ | |
1249 | ||
1250 | H5G_UNKNOWN = -1; /* Unknown object type */ | |
1251 | H5G_LINK = 0; /* Object is a symbolic link */ | |
1252 | H5G_GROUP = 1; /* Object is a group */ | |
1253 | H5G_DATASET = 2; /* Object is a dataset */ | |
1254 | H5G_TYPE = 3; /* Object is a named data type */ | |
1255 | ||
1256 | H5G_LINK_ERROR = -1; /* link types used by H5Glink2 */ | |
1257 | H5G_LINK_HARD = 0; | |
1258 | H5G_LINK_SOFT = 1; | |
1259 | ||
1260 | H5T_STR_NULLTERM = 0; | |
1261 | ||
1262 | H5F_SCOPE_LOCAL = 0; /* specified file handle only */ | |
1263 | H5F_SCOPE_GLOBAL = 1; /* entire virtual file */ | |
1264 | ||
1265 | ||
1266 | _H5Eoff; /* Error reporting OFF by default */ |
0 | Package: hdf5 | |
1 | Kind: plugin | |
2 | Version: 0.6.1 | |
3 | Revision: 1 | |
4 | Description: Hierarchical Data Format 5 interface | |
5 | License: GPL | |
6 | Maintainer: Francois Rigaut <frigaut@users.sf.net> | |
7 | OS: | |
8 | Depends: yorick(>=1.6.02) | |
9 | Source: http://www.maumae.net/yorick/packages/%o/tarballs/hdf5-%v-%o.tgz | |
10 | Source-MD5: | |
11 | Source-Directory: contrib/hdf5 | |
12 | DocFiles: README | |
13 | Homepage: http://www.maumae.net/yorick/doc/plugins.php | |
14 | DescDetail: << | |
15 | HDF5 is the yorick interface plugin to the NCSA Hierarchical Data Format | |
16 | version 5. It includes function for reading, writing, updating, getting | |
17 | information on HDF5 files. | |
18 | ||
19 | man page: | |
20 | DATA I/O: | |
21 | h5read(fname,target) return data | |
22 | h5write,fname,fullpath,data,zip= write data | |
23 | h5open(filename,mode) return file handle | |
24 | h5close(filename) close file | |
25 | ||
26 | INFO, GROUP LINKING: | |
27 | h5info,fname,target,att= print out file info/structure | |
28 | h5link(fname,group,group2link2,linktype) link datasets | |
29 | h5delete,fname,object delete data | |
30 | ||
31 | ATTRIBUTE I/O: | |
32 | h5awrite(fname,object,aname,attdata) write an object attribute | |
33 | h5aread(fname,object,aname) read an object attribute | |
34 | h5adelete,fname,object,aname delete an object attribute | |
35 | ||
36 | MISC: | |
37 | h5list_open list open files | |
38 | h5version return linhdf5 version | |
39 | ||
40 | ERROR RECOVERY | |
41 | h5off close all reference to the h5 library. | |
42 | ||
43 | + Many of the atomic HDF5 functions are available (e.g. H5Fopen, H5Dopen) | |
44 | with mostly the same APIs. Many simple tasks can be done with the | |
45 | provided high level wrappers. Beware that programming an HDF5 custom | |
46 | wrapper is not trivial. Make sure you close every objects opened! | |
47 | ||
48 | This implementation supports reading of most of the HDF5 supported | |
49 | datatype. Only yorick datatype can be used for writes. Compression, soft | |
50 | and hard links, as well as support for attribute read/writes is provided. | |
51 | ||
52 | There is no support for hyperslabs, compound, enum or opaque datatype. | |
53 | Generally, there is very little support for datatype related | |
54 | functionalities. | |
55 | << | |
56 | DescUsage: << | |
57 | See packages/tarballs/hdf5/check.i for a test suite. Type | |
58 | "yorick -batch check.i" in a terminal to run it. | |
59 | << | |
60 | DescPort: << | |
61 | This package will compile Yorick only on MacOSX 10.3.4 or later, because | |
62 | of a bug in the system math library libm (part of /usr/lib/LibSystem.dylib) | |
63 | in earlier versions of MacOSX 10.3. | |
64 | << |
0 | autoload,"hdf5.i", h5info, h5read, h5write; | |
1 | autoload,"hdf5.i", h5link, h5delete; | |
2 | autoload,"hdf5.i", h5adelete, h5aread, h5awrite; |
0 | /* | |
1 | * hdf5doc.txt | |
2 | * documentation for the yorick hdf5 plugin | |
3 | * | |
4 | * $Id: hdf5doc.txt,v 1.1 2007-12-27 15:10:25 frigaut Exp $ | |
5 | * | |
6 | * Author: Francois Rigaut. | |
7 | * Written 2004 | |
8 | * last revision/addition: 2007dec26 | |
9 | * | |
10 | * Copyright (c) 2003, Francois RIGAUT (frigaut@gemini.edu, Gemini | |
11 | * Observatory, 670 N A'Ohoku Place, HILO HI-96720). | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or modify it | |
14 | * under the terms of the GNU General Public License as published by the | |
15 | * Free Software Foundation; either version 2 of the License, or (at your | |
16 | * option) any later version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, but | |
19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | * General Public License for more details (to receive a copy of the GNU | |
22 | * General Public License, write to the Free Software Foundation, Inc., 675 | |
23 | * Mass Ave, Cambridge, MA 02139, USA). | |
24 | * | |
25 | * $Log: hdf5doc.txt,v $ | |
26 | * Revision 1.1 2007-12-27 15:10:25 frigaut | |
27 | * Initial revision | |
28 | * | |
29 | */ | |
30 | ||
31 | HDF5 yorick plugin documentation | |
32 | ================================ | |
33 | ||
34 | ******************************** | |
35 | ******* DRAFT 2005dec11 ******** | |
36 | ******************************** | |
37 | ||
38 | 1. Overview | |
39 | ||
40 | This plugin uses libhdf5, version 1.6.4 or greater. It will probably | |
41 | work with slightly lesser version, but I haven't tested it. The | |
42 | current version avilable from the NSCA site is (dec2005) is 1.6.5. | |
43 | ||
44 | This plugin provide a minimal interface to HDF5 (Hierarchical Data | |
45 | Format 5). I am not going to expand on HDF5 here. Suffice to say that | |
46 | this format provides a way to store heterogeneous data in a single | |
47 | file entity. The data are stored under a hierarchical directory | |
48 | structure (hence the name), like: | |
49 | ||
50 | /header | |
51 | /header/date | |
52 | /header/time | |
53 | /header/author | |
54 | /2005mar25/data/raw/time_vector | |
55 | /2005mar25/data/raw/entropy | |
56 | etc... | |
57 | ||
58 | A directory (e.g. /header) is called a "Group". | |
59 | A scalar/vector/array of numbers/strings is called "Dataset". | |
60 | ||
61 | One can also set and store attribute to groups or datasets. | |
62 | ||
63 | Here is an example of a file as dumped by the h5info function: | |
64 | ||
65 | > h5info,"data.h5",att=1 | |
66 | /2005mar04 GROUP | |
67 | ATTRIB(0): Temp on this date | |
68 | ATTRIB(1): cups of coffee | |
69 | /2005mar04/comments DATASET STRING DIMSOF()=[1,2] | |
70 | /2005mar04/data DATASET DOUBLE DIMSOF()=[1,100] | |
71 | /2005mar04/dewpoint DATASET DOUBLE SCALAR | |
72 | /2005mar04/time DATASET DOUBLE DIMSOF()=[1,100] | |
73 | ATTRIB(0): Units | |
74 | ATTRIB(1): Units2 | |
75 | /2005mar05 GROUP | |
76 | /2005mar05/name with blanks DATASET DOUBLE SCALAR | |
77 | /HL HARDLINK -> /2005mar04 | |
78 | /bestdata SOFTLINK -> /2005mar04 | |
79 | > | |
80 | ||
81 | which is, I believe, pretty much self-explanatory. Note the hardlink | |
82 | and softlink references at the end (which are what they say they are: | |
83 | links to other groups in this file). | |
84 | ||
85 | ||
86 | ||
87 | 2. FUNCTION API | |
88 | ||
89 | As of v0.6, there are only a handfull of functions, but they should | |
90 | provide most of the functionality to save regular datas (with the | |
91 | exception of structure and pointers). These functions are: | |
92 | ||
93 | ||
94 | DATA I/O: | |
95 | h5read(fname,target) return data | |
96 | h5write,fname,fullpath,data,zip= write data | |
97 | h5open(filename,mode) return file handle | |
98 | h5close(filename) close file | |
99 | ||
100 | INFO, GROUP LINKING: | |
101 | h5info,fname,target,att= print out file info/structure | |
102 | h5link(fname,group,group2link2,linktype) link datasets | |
103 | h5delete,fname,object delete data | |
104 | ||
105 | ATTRIBUTE I/O: | |
106 | h5awrite(fname,object,aname,attdata) write an object attribute | |
107 | h5aread(fname,object,aname) read an object attribute | |
108 | h5adelete,fname,object,aname delete an object attribute | |
109 | ||
110 | MISC: | |
111 | h5list_open list open files | |
112 | h5version return linhdf5 version | |
113 | ||
114 | ERROR RECOVERY | |
115 | h5off close all reference to the | |
116 | h5 library (clean up). | |
117 | ||
118 | Each function is detailled below: | |
119 | ||
120 | ||
121 | 2.1 Data I/O: | |
122 | ||
123 | 2.1.1 h5open | |
124 | ||
125 | fd = h5open(filename,mode); | |
126 | ||
127 | Opens file "filename" in mode "mode". | |
128 | mode can be "r" (read-only), "w" (write-only) or "a" (append). | |
129 | ||
130 | This function returns a file descriptor fd that can be used until released by a call to h5close. fd can be used with h5read and h5open (see below). | |
131 | ||
132 | Warning: when a file is opened with h5open, it will have to be explicitely closed with h5close. If a file is open in read-only and one try to reopen it in write-only, it will cause a error (and vice-versa) | |
133 | ||
134 | ||
135 | 2.1.2 h5write | |
136 | ||
137 | h5write,filename,fullpath_to_dataset,data,zip=,mode= | |
138 | ||
139 | write "data" as object "fullpath" in file "fname". | |
140 | ||
141 | fname can be either a string (filename) or a file descriptor returned | |
142 | by h5open. | |
143 | ||
144 | The scalar string fullpath contains the full path to the dataset | |
145 | (/full/path/dataname). | |
146 | ||
147 | "data" are the data. Any yorick type is valid and will be saved as | |
148 | such. | |
149 | ||
150 | zip is a long 0-9. if set, data will be compressed (the larger the | |
151 | number, the more compression, and the larger the compression time). | |
152 | ||
153 | mode can be set here (when fname is a string). Use "a" it to append | |
154 | data to an existing file. Default is to overwrite ("w"). | |
155 | ||
156 | 2.1.3 h5read | |
157 | ||
158 | result = h5read(filename,dataset) | |
159 | ||
160 | return the data pointed to by the scalar string "dataset" in file | |
161 | "filename". | |
162 | ||
163 | 2.1.4 h5close | |
164 | ||
165 | h5close,file | |
166 | ||
167 | Close all references to the file pointed at by "file". File can either | |
168 | be a scalar string or a file descriptor (as the one returned by | |
169 | h5open()). | |
170 | ||
171 | ||
172 | to be continued... |
0 | %define name yorick-hdf5 | |
1 | %define version 0.6.01 | |
2 | %define release gemini2007dec07 | |
3 | ||
4 | Summary: yorick HDF5 plugin | |
5 | Name: %{name} | |
6 | Version: %{version} | |
7 | Release: %{release} | |
8 | Source0: %{name}-%{version}.tar.bz2 | |
9 | License: BSD | |
10 | Group: Development/Languages | |
11 | Packager: Francois Rigaut <frigaut@gemini.edu> | |
12 | Url: http://www.maumae.net/yorick/doc/plugins.php | |
13 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot | |
14 | Requires: yorick >= 2.1 hdf5 >= 1.5 | |
15 | ||
16 | ||
17 | %description | |
18 | HDF5 is the yorick interface plugin to the NCSA Hierarchical Data Format | |
19 | version 5. It includes function for reading, writing, updating, getting | |
20 | information on HDF5 files. | |
21 | ||
22 | man page: | |
23 | DATA I/O: | |
24 | h5read(fname,target) return data | |
25 | h5write,fname,fullpath,data,zip= write data | |
26 | h5open(filename,mode) return file handle | |
27 | h5close(filename) close file | |
28 | ||
29 | INFO, GROUP LINKING: | |
30 | h5info,fname,target,att= print out file info/structure | |
31 | h5link(fname,group,group2link2,linktype) link datasets | |
32 | h5delete,fname,object delete data | |
33 | ||
34 | ATTRIBUTE I/O: | |
35 | h5awrite(fname,object,aname,attdata) write an object attribute | |
36 | h5aread(fname,object,aname) read an object attribute | |
37 | h5adelete,fname,object,aname delete an object attribute | |
38 | ||
39 | MISC: | |
40 | h5list_open list open files | |
41 | h5version return linhdf5 version | |
42 | ||
43 | ERROR RECOVERY | |
44 | h5off close all reference to the h5 library. | |
45 | ||
46 | + Many of the atomic HDF5 functions are available (e.g. H5Fopen, H5Dopen) | |
47 | with mostly the same APIs. Many simple tasks can be done with the | |
48 | provided high level wrappers. Beware that programming an HDF5 custom | |
49 | wrapper is not trivial. Make sure you close every objects opened! | |
50 | ||
51 | This implementation supports reading of most of the HDF5 supported | |
52 | datatype. Only yorick datatype can be used for writes. Compression, soft | |
53 | and hard links, as well as support for attribute read/writes is provided. | |
54 | ||
55 | There is no support for hyperslabs, compound, enum or opaque datatype. | |
56 | Generally, there is very little support for datatype related | |
57 | functionalities. | |
58 | ||
59 | ||
60 | %prep | |
61 | %setup -q | |
62 | ||
63 | %build | |
64 | yorick -batch make.i | |
65 | make | |
66 | if [ -f check.i ] ; then | |
67 | mv check.i %{name}_check.i | |
68 | fi; | |
69 | ||
70 | %install | |
71 | rm -rf $RPM_BUILD_ROOT | |
72 | mkdir -p $RPM_BUILD_ROOT/usr/lib/yorick/lib | |
73 | mkdir -p $RPM_BUILD_ROOT/usr/lib/yorick/doc | |
74 | mkdir -p $RPM_BUILD_ROOT/usr/lib/yorick/i0 | |
75 | mkdir -p $RPM_BUILD_ROOT/usr/lib/yorick/i-start | |
76 | ||
77 | install -m 755 hdf5.so $RPM_BUILD_ROOT/usr/lib/yorick/lib | |
78 | install -m 644 hdf5doc.txt $RPM_BUILD_ROOT/usr/lib/yorick/doc | |
79 | install -m 644 *.i $RPM_BUILD_ROOT/usr/lib/yorick/i0 | |
80 | install -m 644 *_start.i $RPM_BUILD_ROOT/usr/lib/yorick/i-start | |
81 | ||
82 | rm $RPM_BUILD_ROOT/usr/lib/yorick/i0/*_start.i | |
83 | ||
84 | ||
85 | %clean | |
86 | rm -rf $RPM_BUILD_ROOT | |
87 | ||
88 | %files | |
89 | %defattr(-,root,root) | |
90 | /usr/lib/yorick/lib/hdf5.so | |
91 | /usr/lib/yorick/doc/hdf5doc.txt | |
92 | /usr/lib/yorick/i0/*.i | |
93 | /usr/lib/yorick/i-start/*_start.i | |
94 | ||
95 | %changelog |