# MEDinterpCr.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 #include <hdf5.h>
    00023 #include <string.h>
    00024
    00042 med_err
    00043 MEDinterpCr(const med_idt                 fid,
    00044             const char*             const interpname,
    00045             const med_geometry_type       geotype,
    00046             const med_bool                cellnode,
    00047             const med_int                 nvariable,
    00048             const med_int                 maxdegree,
    00049             const med_int                 nmaxcoef
    00050             )
    00051 {
    00052   med_access_mode   _MED_ACCESS_MODE;
    00053   med_idt           _root=0,_interpid=0;
    00054   med_int           _ret=-1;
    00055   char              _path[MED_TAILLE_INTERP+MED_NAME_SIZE+1]=MED_INTERP;
    00056   med_int           _cellnodes = cellnode;
    00057   med_int           _geotype = geotype;
    00058   /*
    00059    * On inhibe le gestionnaire d'erreur
    00060    */
    00061   _MEDmodeErreurVerrouiller();
    00062  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
    00063
    00064   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    00065     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00066     goto ERROR;
    00067   }
    00068
    00069   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    00070     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00071     ISCRUTE_int(_MED_ACCESS_MODE);
    00072     goto ERROR;
    00073   }
    00074
    00075   /*
    00076    * Si le DataGroup /INTERP/ n'existe pas, on le cree
    00077    */
    00078   if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
    00079     if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
    00080       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
    00081      goto ERROR;
    00082     }
    00083
    00084   NOFINALBLANK(interpname,ERROR);
    00085
    00086   /*
    00087    * Si le DataGroup /INTERP/<interpname> n'existe pas, on le cree
    00088    */
    00089   if ((_interpid = _MEDdatagroupOpen(_root,interpname)) < 0)
    00090     if ((_interpid = _MEDdatagroupCreer(_root,interpname)) < 0) {
    00091       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,interpname);
    00092       SSCRUTE(_path);goto ERROR;
    00093     }
    00094
    00095   strcat(_path,interpname);
    00096
    00097   /*
    00098    * Creation/Ecriture de l'attribut MED_NOM_GEO
    00099    */
    00100   if ( _MEDattributeIntWr(_interpid,MED_NOM_GEO,&_geotype) < 0 ) {
    00101     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    00102     SSCRUTE(MED_NOM_GEO);ISCRUTE(_geotype);
    00103     goto ERROR;
    00104   }
    00105
    00106   /*
    00107    * Creation/Ecriture de l'attribut MED_NOM_NBB
    00108    */
    00109 /*   if ( _MEDattributeIntWr(_interpid,MED_NOM_NBB,&nbasisfunc) < 0 ) { */
    00110 /*     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path); */
    00111 /*     SSCRUTE(MED_NOM_NBB);ISCRUTE(nbasisfunc); */
    00112 /*     goto ERROR; */
    00113 /*   } */
    00114
    00115   /*
    00116    * Creation/Ecriture de l'attribut MED_NOM_NBV
    00117    */
    00118   if ( _MEDattributeIntWr(_interpid,MED_NOM_NBV,&nvariable) < 0 ) {
    00119     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    00120     SSCRUTE(MED_NOM_NBV);ISCRUTE(nvariable);
    00121     goto ERROR;
    00122   }
    00123
    00124   /*
    00125    * Creation/Ecriture de l'attribut MED_NOM_MDG
    00126    */
    00127   if ( _MEDattributeIntWr(_interpid,MED_NOM_MDG,&maxdegree) < 0 ) {
    00128     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    00129     SSCRUTE(MED_NOM_MDG);ISCRUTE(maxdegree);
    00130     goto ERROR;
    00131   }
    00132
    00133   /*
    00134    * Creation/Ecriture de l'attribut MED_NOM_MCF
    00135    */
    00136   if ( _MEDattributeIntWr(_interpid,MED_NOM_MCF,&nmaxcoef) < 0 ) {
    00137     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    00138     SSCRUTE(MED_NOM_MCF);ISCRUTE(nmaxcoef);
    00139     goto ERROR;
    00140   }
    00141
    00142   /*
    00143    * Creation/Ecriture de l'attribut MED_NOM_FCN
    00144    */
    00145   if ( _MEDattributeIntWr(_interpid,MED_NOM_FCN,&_cellnodes) < 0 ) {
    00146     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
    00147     SSCRUTE(MED_NOM_FCN);ISCRUTE(_cellnodes);
    00148     goto ERROR;
    00149   }
    00150
    00151   _ret = 0;
    00152
    00153  ERROR:
    00154
    00155   if (_interpid>0)     if (_MEDdatagroupFermer(_interpid) < 0) {
    00156     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00157     ISCRUTE_id(_interpid);
    00158   }
    00159
    00160   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
    00161     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_INTERP);
    00162     ISCRUTE_id(_root);
    00163   }
    00164
    00165   return _ret;
    00166
    00167 }