1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #include "MEDMEM_MEDMEMprofilEcr.hxx"
24 * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier
25 * on intègre la correction ici.
33 fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ; \
37 # define ISCRUTE_MED(entier) { \
39 fprintf(stderr,"%s = %d\n",#entier,entier) ; \
43 # define SSCRUTE_MED(chaine) { \
45 fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ; \
48 # define MESSAGE_MED(chaine) { \
50 fprintf(stderr,"%s\n",chaine) ; \
54 extern void _MEDmodeErreurVerrouiller(void);
57 #include <med_outils.h>
63 MEDMEMprofilEcr(med_idt fid,med_int *pflval,med_int n,char *profilname)
68 char chemin[MED_TAILLE_PROFILS+1];
71 * On inhibe le gestionnaire d'erreur HDF 5
73 _MEDmodeErreurVerrouiller();
76 * Si le groupe "PROFILS" n'existe pas, on le cree
78 strncpy(chemin,MED_PROFILS,MED_TAILLE_PROFILS-1);
79 chemin[MED_TAILLE_PROFILS-1] = '\0';
80 if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
81 if ((gid = _MEDdatagroupCreer(fid,chemin)) < 0) {
82 MESSAGE_MED("Impossible de creer le groupe MED_PROFILS : ");
83 SSCRUTE_MED(chemin); goto ERROR;
87 * Si le groupe "profilname" n'existe pas, on le cree
90 if ((chid = _MEDdatagroupOuvrir(gid,profilname)) >= 0) {
91 if ( false )//MED_MODE_ACCES != MED_LECTURE_ECRITURE )
93 MESSAGE_MED("Le profil existe déjà : ");
94 SSCRUTE_MED(profilname); goto ERROR;
97 if ((chid = _MEDdatagroupCreer(gid,profilname)) < 0)
101 * On stocke "n" sous forme d'attribut
103 if ((ret = _MEDattrEntierEcrire(chid,MED_NOM_NBR,&n)) < 0) {
104 MESSAGE_MED("Erreur à l'écriture de l'attribut MED_NOM_NBR : ");
105 ISCRUTE_MED(n); goto ERROR;
109 * On stocke le profil dans un dataset
112 #if defined(F77INT64)
113 ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
114 (unsigned char*) pflval);
116 ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
117 (unsigned char*) pflval);
120 MESSAGE_MED("Impossible d'ecrire le dataset pflval de taille : ");
121 ISCRUTE_MED(n); goto ERROR;
129 if (chid>0) if (_MEDdatagroupFermer(chid) < 0) {
130 MESSAGE_MED("Impossible de fermer le datagroup : ");
131 ISCRUTE_MED(chid); ret = -1;
134 if (gid>0) if (_MEDdatagroupFermer(gid) < 0) {
135 MESSAGE_MED("Impossible de fermer le datagroup : ");
136 ISCRUTE_MED(gid); ret = -1;