_MEDmeshGridIndexCoordinateRd30.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 
00018 
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 #include <string.h>
00023 #include <stdlib.h>
00024 
00025 void _MEDmeshGridIndexCoordinateRd30(int dummy, ...) {
00026 
00027   va_list params;
00028   va_start(params,dummy);
00029 
00030   const med_idt               fid       = va_arg(params,const med_idt     );
00031   const char*  const          meshname  = va_arg(params,const char*  const);
00032   const med_int               numdt     = va_arg(params,const med_int     );
00033   const med_int               numit     = va_arg(params,const med_int     );
00034   const med_int               axis      = va_arg(params,const med_int     );
00035   med_float * const           gridindex = va_arg(params,med_float * const );
00036   med_err *                   fret      = va_arg(params,med_err *);
00037 
00038   med_idt         _meshid=0;
00039   med_err         _ret         = -1;
00040   med_data_type   _datatype    = MED_UNDEF_DATATYPE;
00041   med_grid_type   _gridtype    = MED_UNDEF_GRID_TYPE;
00042   med_int         _intgridtype = 0;
00043   med_int         _meshdim     = 0;
00044   char            _meshpath[MED_TAILLE_MAA+MED_NAME_SIZE+1]=MED_MAA;
00045   med_int  _intaxistype=0;
00046 
00047   /*
00048    * On inhibe le gestionnaire d'erreur HDF 5
00049    */
00050   _MEDmodeErreurVerrouiller();
00051 
00052   strcat(_meshpath,meshname);
00053   if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
00054     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00055     SSCRUTE(meshname);SSCRUTE(_meshpath); goto ERROR;
00056   }
00057 
00058   /*
00059    * Lecture du type de grille (attribut MED_NOM_GTY)
00060    */
00061   if (_MEDattrEntierLire(_meshid,MED_NOM_GTY,&_intgridtype) < 0) {
00062     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00063     SSCRUTE(meshname);SSCRUTE(MED_NOM_GTY);ISCRUTE(_intgridtype);goto ERROR;
00064   }
00065   _gridtype=(med_grid_type) _intgridtype;
00066 
00067   if ((_gridtype != MED_CARTESIAN_GRID) && (_gridtype != MED_POLAR_GRID)) {
00068     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GRIDTYPE,MED_ERR_MESH_MSG);
00069     SSCRUTE(meshname);ISCRUTE_int(_gridtype);goto ERROR;
00070   }
00071 
00072 
00073  /* Lecture de l'attribut MED_NOM_REP */
00074   if ( _MEDattrEntierLire(_meshid,MED_NOM_REP,&_intaxistype) < 0) {
00075     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00076     SSCRUTE(meshname);SSCRUTE(MED_NOM_REP);
00077     ISCRUTE(_intaxistype);goto ERROR;
00078   }
00079 
00080   if ((med_mesh_type)( _intaxistype) != MED_CARTESIAN ) {
00081     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_AXISTYPE,MED_ERR_MESH_MSG);
00082     SSCRUTE(meshname);ISCRUTE(_intaxistype);goto ERROR;
00083   }
00084 
00085   /* Lecture de l'attribut MED_NOM_DIM  */
00086   if (_MEDattrEntierLire(_meshid,MED_NOM_DIM,&_meshdim) < 0) {
00087     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00088     SSCRUTE(meshname);SSCRUTE(MED_NOM_DIM);ISCRUTE(_meshdim);goto ERROR;
00089   }
00090 
00091   if (axis > _meshdim ) {
00092     MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
00093     SSCRUTE(meshname);ISCRUTE(_meshdim);ISCRUTE(axis);goto ERROR;
00094   }
00095 
00096   /*
00097    * On ecrit le tableau d'indice dans un dataset HDF
00098    */
00099   switch(axis)
00100     {
00101     case 1 :
00102       _datatype = MED_COORDINATE_AXIS1;
00103       break;
00104     case 2 :
00105       _datatype = MED_COORDINATE_AXIS2;
00106       break;
00107     case 3 :
00108       _datatype = MED_COORDINATE_AXIS3;
00109       break;
00110     default :
00111       MED_ERR_(_ret,MED_ERR_RANGE,MED_ERR_GRIDTYPE,MED_ERR_MESH_MSG);
00112       SSCRUTE(meshname);ISCRUTE_int(_gridtype);goto ERROR;
00113     }
00114 
00115   if (_MEDmeshAdvancedRd(fid,
00116                          meshname,
00117                          _datatype,
00118                          MED_NO_NAME,
00119                          MED_INTERNAL_UNDEF,
00120                          numdt,
00121                          numit,
00122                          MED_NODE,
00123                          MED_NONE,
00124                          MED_NO_CMODE,
00125                          MED_UNDEF_PFLMODE,
00126                          MED_NO_PROFILE,
00127                          MED_FULL_INTERLACE,
00128                          MED_ALL_CONSTITUENT,
00129                          NULL,
00130                          (unsigned char *) gridindex) < 0 ) {
00131     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API,"_MEDmeshAdvancedRd");
00132     goto ERROR;
00133   }
00134 
00135   _ret = 0;
00136 
00137  ERROR:
00138 
00139   if (_meshid>0)            if (_MEDdatagroupFermer(_meshid) < 0) {
00140     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
00141     ISCRUTE_id(_meshid);
00142   }
00143 
00144 
00145   va_end(params);
00146   *fret = _ret;
00147   return;
00148 }

Généré le Mon May 16 17:10:22 2011 pour MED fichier par  doxygen 1.6.1