1 // Copyright (C) 2007-2012 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
23 #include "MEDMEM_MEDMEMprofilEcr.hxx"
25 * En attendant une correction de la gestion du mode d'accès au fichier dans MEDfichier
26 * on intègre la correction ici.
34 fprintf(stderr, "%s [%d] : " , __FILE__ , __LINE__ ) ; \
38 # define ISCRUTE_MED(entier) { \
40 fprintf(stderr,"%s = %d\n",#entier,entier) ; \
44 # define SSCRUTE_MED(chaine) { \
46 fprintf(stderr,"%s = \"%s\"\n",#chaine,chaine) ; \
49 # define MESSAGE_MED(chaine) { \
51 fprintf(stderr,"%s\n",chaine) ; \
55 extern void _MEDmodeErreurVerrouiller(void);
58 #include <med_outils.h>
64 MEDMEMprofilEcr(med_idt fid,med_int *pflval,med_int n,char *profilname)
69 char chemin[MED_TAILLE_PROFILS+1];
72 * On inhibe le gestionnaire d'erreur HDF 5
74 _MEDmodeErreurVerrouiller();
77 * Si le groupe "PROFILS" n'existe pas, on le cree
79 strncpy(chemin,MED_PROFILS,MED_TAILLE_PROFILS-1);
80 chemin[MED_TAILLE_PROFILS-1] = '\0';
81 if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
82 if ((gid = _MEDdatagroupCreer(fid,chemin)) < 0) {
83 MESSAGE_MED("Impossible de creer le groupe MED_PROFILS : ");
84 SSCRUTE_MED(chemin); goto ERROR;
88 * Si le groupe "profilname" n'existe pas, on le cree
91 if ((chid = _MEDdatagroupOuvrir(gid,profilname)) >= 0) {
92 if ( false )//MED_MODE_ACCES != MED_LECTURE_ECRITURE )
94 MESSAGE_MED("Le profil existe déjà : ");
95 SSCRUTE_MED(profilname); goto ERROR;
98 if ((chid = _MEDdatagroupCreer(gid,profilname)) < 0)
102 * On stocke "n" sous forme d'attribut
104 if ((ret = _MEDattrEntierEcrire(chid,MED_NOM_NBR,&n)) < 0) {
105 MESSAGE_MED("Erreur à l'écriture de l'attribut MED_NOM_NBR : ");
106 ISCRUTE_MED(n); goto ERROR;
110 * On stocke le profil dans un dataset
113 #if defined(F77INT64)
114 ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
115 (unsigned char*) pflval);
117 ret = _MEDdatasetNumEcrire(chid,MED_NOM_PFL,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,MED_NOPG,dimd,
118 (unsigned char*) pflval);
121 MESSAGE_MED("Impossible d'ecrire le dataset pflval de taille : ");
122 ISCRUTE_MED(n); goto ERROR;
130 if (chid>0) if (_MEDdatagroupFermer(chid) < 0) {
131 MESSAGE_MED("Impossible de fermer le datagroup : ");
132 ISCRUTE_MED(chid); ret = -1;
135 if (gid>0) if (_MEDdatagroupFermer(gid) < 0) {
136 MESSAGE_MED("Impossible de fermer le datagroup : ");
137 ISCRUTE_MED(gid); ret = -1;