# MEDmeshGridStructRd.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 <string.h>
    00023 #include <stdlib.h>
    00024
    00036 med_err
    00037 MEDmeshGridStructRd(const med_idt               fid,
    00038                     const char*  const          meshname,
    00039                     const med_int               numdt,
    00040                     const med_int               numit,
    00041                     med_int * const             gridstruct)
    00042 {
    00043   med_idt         _meshid=0;
    00044   med_err         _ret         = -1;
    00045   med_data_type   _datatype    = MED_UNDEF_DATATYPE;
    00046   med_grid_type   _gridtype    = MED_UNDEF_GRID_TYPE;
    00047   med_int         _intgridtype = 0;
    00048   med_int         _meshdim     = 0;
    00049   char            _meshpath[MED_TAILLE_MAA+MED_NAME_SIZE+1]=MED_MAA;
    00050   int             _i=0;
    00051
    00052   med_int * _ptr;
    00053
    00054   /*
    00055    * On inhibe le gestionnaire d'erreur HDF 5
    00056    */
    00057   _MEDmodeErreurVerrouiller();
    00058
    00059
    00060   strcat(_meshpath,meshname);
    00061   if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
    00062     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
    00063     SSCRUTE(meshname);SSCRUTE(_meshpath); goto ERROR;
    00064   }
    00065
    00066   /* Lecture de l'attribut MED_NOM_DIM  */
    00067   if (_MEDattrEntierLire(_meshid,MED_NOM_DIM,&_meshdim) < 0) {
    00068     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00069     SSCRUTE(meshname);SSCRUTE(MED_NOM_DIM);ISCRUTE(_meshdim);goto ERROR;
    00070   }
    00071
    00072   /*
    00073    * Lecture du type de grille (attribut MED_NOM_GTY)
    00074    */
    00075   if (_MEDattrEntierLire(_meshid,MED_NOM_GTY,&_intgridtype) < 0) {
    00076     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00077     SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);ISCRUTE(_intgridtype);goto ERROR;
    00078   }
    00079   _gridtype=(med_grid_type) _intgridtype;
    00080
    00081   if (_gridtype != MED_CURVILINEAR_GRID) {
    00082     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GRIDTYPE,MED_ERR_MESH_MSG);
    00083     SSCRUTE(meshname);ISCRUTE_int(_gridtype);goto ERROR;
    00084   }
    00085
    00086
    00087   /*
    00088    * Attribut NBR (taille du tableau d'indices)
    00089    */
    00090   for (_i=0;_i<_meshdim;++_i) {
    00091
    00092     switch(_i) {
    00093      case 0 :
    00094       _datatype = MED_COORDINATE_AXIS1;
    00095       break;
    00096     case 1 :
    00097       _datatype = MED_COORDINATE_AXIS2;
    00098       break;
    00099     case 2 :
    00100       _datatype = MED_COORDINATE_AXIS3;
    00101       break;
    00102     default :
    00103       MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GRIDTYPE,MED_ERR_MESH_MSG);
    00104       SSCRUTE(meshname);ISCRUTE_int(_gridtype);goto ERROR;
    00105     }
    00106
    00107     _ptr=gridstruct+_i;
    00108     if (_MEDmeshAdvancedRd(fid,
    00109                            meshname,
    00110                            _datatype,
    00111                            MED_NO_NAME,
    00112                            MED_INT,
    00113                            numdt,
    00114                            numit,
    00115                            MED_NODE,
    00116                            MED_NONE,
    00117                            MED_NO_CMODE,
    00118                            MED_UNDEF_PFLMODE,
    00119                            MED_NO_PROFILE,
    00120                            MED_FULL_INTERLACE,
    00121                            MED_ALL_CONSTITUENT,
    00122                            NULL,
    00123                            (unsigned char* const) (_ptr)) < 0 ) {
    00124       MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedRd");
    00125       goto ERROR;
    00126     }
    00127
    00128   }
    00129
    00130  _ret = 0;
    00131
    00132  ERROR:
    00133
    00134   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
    00135     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
    00136     ISCRUTE_id(_meshid);
    00137   }
    00138
    00139   return _ret;
    00140
    00141 }