# MEDequivalenceCr.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  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
    00018
    00019 #include <med.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022
    00023 #include <string.h>
    00024 #include <stdlib.h>
    00025
    00036 med_err
    00037 MEDequivalenceCr(const med_idt      fid,
    00038                  const char * const meshname,
    00039                  const char * const equivname,
    00040                  const char * const description)
    00041 {
    00042   med_access_mode _MED_ACCESS_MODE;
    00043   med_idt        _root=0,_eqid=0,_meshid=0;
    00044   med_err        _ret=-1;
    00045   char           _path[MED_TAILLE_EQS+MED_NAME_SIZE+1]=MED_EQS;
    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 DataGroup /EQS/ n'existe pas, on le cree
    00066    */
    00067   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0)
    00068     if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
    00069       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
    00070      goto ERROR;
    00071     }
    00072
    00073   NOFINALBLANK(meshname,ERROR);
    00074
    00075   /*
    00076    * Si le DataGroup /EQS/<meshname> n'existe pas, on le cree
    00077    */
    00078   if ((_meshid = _MEDdatagroupOuvrir(_root,meshname)) < 0)
    00079     if ((_meshid = _MEDdatagroupCreer(_root,meshname)) < 0) {
    00080       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,meshname);
    00081       SSCRUTE(_path);goto ERROR;
    00082     }
    00083
    00084   strcat(_path,meshname);
    00085   NOFINALBLANK(equivname,ERROR);
    00086
    00087   /*
    00088    * Si le Data Group "/EQS/<meshname>/<equivname>" n'existe pas, on le cree
    00089    */
    00090   if ((_eqid = _MEDdatagroupOuvrir(_meshid,equivname)) < 0)
    00091     if ((_eqid = _MEDdatagroupCreer(_meshid,equivname)) < 0 ) {
    00092       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,equivname);
    00093       SSCRUTE(_path);goto ERROR;
    00094     }
    00095
    00096  /*  if ( (_eqid = _MEDmeshAssociatedGroupCr(fid, */
    00097 /*                                        MED_EQS_NOM, */
    00098 /*                                        meshname, */
    00099 /*                                        numdt, */
    00100 /*                                        numit, */
    00101 /*                                        -1, */
    00102 /*                                        MED_FALSE, */
    00103 /*                                        equivalencename ) ) < 0)  { */
    00104 /*     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAssociatedGroupCr"); */
    00105 /*     SSCRUTE(MED_EQS_NOM);SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt); */
    00106 /*     SSCRUTE(equivalencename); */
    00107 /*     goto ERROR; */
    00108 /*   } */
    00109
    00110   /*
    00111    * L'attribut "DES"
    00112    */
    00113   if ((_ret = _MEDattributeStringWr(_eqid,MED_NOM_DES,MED_COMMENT_SIZE,
    00114                                    description)) < 0) {
    00115     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_EQUIVALENCE_MSG);
    00116     SSCRUTE(equivname);SSCRUTE(description);
    00117
    00118     goto ERROR;
    00119   }
    00120
    00121
    00122   _ret=0;
    00123  ERROR:
    00124
    00125   if (_eqid>0)            if (_MEDdatagroupFermer(_eqid) < 0) {
    00126     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,equivname);
    00127     ISCRUTE_id(_eqid);SSCRUTE(_path);
    00128   }
    00129
    00130   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
    00131     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00132     ISCRUTE_id(_eqid);
    00133   }
    00134
    00135   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    00136     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_EQS);
    00137     ISCRUTE_id(_eqid);
    00138   }
    00139
    00140   return _ret;
    00141 }
    00142
    00143
    00144