# MEDmeshAttributeWr.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00029 #include <med.h>
    00030 #include <med_config.h>
    00031 #include <med_outils.h>
    00032 #include <string.h>
    00033
    00034 med_err
    00035 MEDmeshAttributeWr(const med_idt fid,
    00036                    const char * const meshname,
    00037                    const med_int isolatednodes,
    00038                    const med_int verticesnodes,
    00039                    const med_int cellmaxnodes)
    00040 {
    00041   med_access_mode _MED_ACCESS_MODE;
    00042   med_err _ret=-1;
    00043   med_idt _meshid=0;
    00044   char    _path [MED_TAILLE_MAA+MED_NAME_SIZE+1]=MED_MAA;
    00045
    00046
    00047   /*
    00048    * On inhibe le gestionnaire d'erreur
    00049    */
    00050   _MEDmodeErreurVerrouiller();
    00051  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
    00052
    00053   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    00054     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00055     goto ERROR;
    00056   }
    00057
    00058   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    00059     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00060     ISCRUTE_int(_MED_ACCESS_MODE);
    00061     goto ERROR;
    00062   }
    00063
    00064   /*
    00065    * Si le maillage n'existe pas => erreur
    00066    */
    00067   strcat(_path,meshname);
    00068   if ((_meshid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    00069     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    00070     ISCRUTE_id(_meshid);goto ERROR;
    00071   }
    00072
    00073
    00074   /*
    00075    * Creation de l'attribut "Nombre de Noeuds Isoles"
    00076    */
    00077   if ( _MEDattributeIntWr(_meshid,MED_NOM_NNI,&isolatednodes) < 0 ) {
    00078     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00079     SSCRUTE(meshname);SSCRUTE(MED_NOM_NNI);ISCRUTE(isolatednodes);goto ERROR;
    00080   }
    00081
    00082   /*
    00083    * Creation de l'attribut "Nombre de Noeuds Sommets"
    00084    */
    00085   if ( _MEDattributeIntWr(_meshid,MED_NOM_NNS,&verticesnodes) < 0 ) {
    00086     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00087     SSCRUTE(meshname);SSCRUTE(MED_NOM_NNS);ISCRUTE(verticesnodes);goto ERROR;
    00088   }
    00089
    00090
    00091   /*
    00092    * Creation de l'attribut "Nombre de Noeuds Max par maille"
    00093    */
    00094   if ( _MEDattributeIntWr(_meshid,MED_NOM_NNM,&cellmaxnodes) < 0 ) {
    00095     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00096     SSCRUTE(meshname);SSCRUTE(MED_NOM_NNM);ISCRUTE(cellmaxnodes);goto ERROR;
    00097   }
    00098
    00099
    00100   _ret = 0;
    00101  ERROR:
    00102
    00103   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
    00104     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00105     ISCRUTE_id(_meshid);
    00106   }
    00107
    00108   return _ret;
    00109 }
    00110