1 /*************************************************************************
2 * COPYRIGHT (C) 1999 - 2002 EDF R&D
3 * THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
4 * IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE
5 * AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
6 * EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
8 * THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
9 * WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
10 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
11 * LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
13 * YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
14 * ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
15 * INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
17 *************************************************************************/
21 #include "med_outils.hxx"
24 * - Nom de la fonction : _MEDattrNumEcrire
25 * - Description : ecriture d'un attribut entier
27 * - pere (IN) : l'ID de l'objet HDF pere ou placer l'attribut
28 * - type (IN) : le type du champ {MED_REEL64,MED_INT}
29 * - nom (IN) : le nom de l'attribut
30 * - val (IN) : la valeur de l'attribut
31 * - Resultat : 0 en cas de succes, -1 sinon
37 _MEDattrNumEcrire(med_idt pere,med_type_champ type,char *nom,unsigned char *val,
47 /* 1) IA32 is LE but due to an (?HDF convertion BUG?) when using H5T_NATIVE_DOUBLE/MED_REEL64? under PCLINUX
48 the file read under SGI is incorrect
49 2) Compaq OSF/1 is LE, since we force SGI64,SUN4SOL2,HP to write double in LE even if they are BE, mips OSF/1 must be BE
50 REM : Be careful of compatibility between MED files when changing this (med2.2) */
51 #if defined(PCLINUX) || defined(OSF1)
52 type_hdf = H5T_IEEE_F64BE;
54 type_hdf = H5T_IEEE_F64LE;
59 #if defined(IRIX64) || defined(OSF1)
60 type_hdf = H5T_NATIVE_LONG;
61 #elif defined(PCLINUX)
62 /* This explicit convertion avoid a core dump between in HDF&ASTER when reading on SGI
63 a file written under a PCLINUX system (in founction H5Tconvert),
64 we don't know yet if it is an HDF bug or an ASTER one */
65 /* The problem seems to be in convertion process between INT32LE->INT32BE ? */
66 type_hdf = H5T_STD_I32BE;
67 if ((H5Tconvert(H5T_NATIVE_INT,H5T_STD_I32BE,1,(void *)val,NULL,NULL)) < 0)
70 type_hdf = H5T_NATIVE_INT;
78 if ((aid = H5Screate(H5S_SCALAR)) < 0)
81 if ( ((attr = H5Aopen_name(pere,nom)) > 0) && (mode != MED_REMP) )
85 if ((attr = H5Acreate(pere,nom,type_hdf,aid,H5P_DEFAULT)) < 0) return -1;
87 if ((ret = H5Awrite(attr,type_hdf,val)) < 0)
91 if ((ret = H5Sclose(aid)) < 0)
93 if ((ret = H5Aclose(attr)) < 0)
97 /* This explicit convertion cancel the previous on which avoid a mysterious bug between HDF&ASTER when reading
98 a file written under a PCLINUX system, we don't know yet if it is an HDF bug or an ASTER one */
100 if ((H5Tconvert(H5T_STD_I32BE,H5T_NATIVE_INT,1,(void *)val,NULL,NULL)) < 0)