_MEDlocalizationRd30.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 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00026 void
00027 _MEDlocalizationRd30(int dummy, ...) {
00028 
00029   va_list params;
00030   va_start(params,dummy);
00031 
00032   const med_idt                 fid               = va_arg(params,const med_idt                  );
00033   const char*            const  localizationname  = va_arg(params,const char*            const   );
00034   const med_switch_mode         switchmode        = va_arg(params,const med_switch_mode          );
00035         med_float*       const  elementcoordinate = va_arg(params,      med_float*       const   );
00036         med_float*       const  ipointcoordinate  = va_arg(params,      med_float*       const   );
00037         med_float*       const  weight            = va_arg(params,      med_float*       const   );
00038   med_err *                     fret              = va_arg(params,      med_err *         );
00039 
00040   med_err _ret = -1;
00041   med_idt _lzid=0, _root=0;
00042   med_int _nentity=0,_nbofipoint=0,_spacedimension=0;
00043   med_int _intgeotype = -1;
00044   char    _path[MED_TAILLE_GAUSS+MED_NAME_SIZE+1]=MED_GAUSS;
00045   med_filter     _filter        = MED_FILTER_INIT;
00046 
00047   /*
00048    * On inhibe le gestionnaire d'erreur HDF 5
00049    */
00050   _MEDmodeErreurVerrouiller();
00051 
00052   /*
00053    * MED_GAUSS_ELNO est un mot cle reserve
00054    */
00055   if (! strcmp(localizationname,MED_GAUSS_ELNO)) {
00056     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_LOCALIZATION,localizationname);
00057     goto ERROR;
00058   }
00059 
00060   /*
00061    * Ouverture du dataGroup /GAUSS/
00062    */
00063   if ((_root = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00064     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00065     goto ERROR;
00066   }
00067 
00068   NOFINALBLANK(localizationname,ERROR);
00069   /*
00070    * Ouverture du dataGroup  /GAUSS/<localizationname>
00071    */
00072   if ((_lzid = _MEDdatagroupOuvrir(_root,localizationname)) < 0) {
00073     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,localizationname);
00074     SSCRUTE(_path);goto ERROR;
00075   }
00076 
00077   strcat(_path,localizationname);
00078 
00079 
00080   /*
00081    * On lit <nbofipoint> sous forme d'attribut
00082    */
00083   if (_MEDattrEntierLire(_lzid,MED_NOM_NBR,&_nbofipoint) < 0) {
00084     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00085     SSCRUTE(localizationname);SSCRUTE(MED_NOM_NBR);ISCRUTE(_nbofipoint);
00086     goto ERROR;
00087   }
00088 
00089   /*
00090    * On lit <typgeo> sous forme d'attribut
00091    */
00092   /* sizeof(enum) tjrs = sizeof(int) en C, or
00093      sur machines 64 bits par d�faut med_int==long,
00094      du coup sur  machines 64 bits _MEDattributeIntWr utilise 
00095      le type hdf NATIVE_LONG, ce qui pose un probl�me qd on passe
00096      un enum.
00097   */
00098   if (_MEDattrEntierLire(_lzid,MED_NOM_GEO,&_intgeotype) < 0) {
00099     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00100     SSCRUTE(localizationname);SSCRUTE(MED_NOM_GEO);ISCRUTE(_intgeotype);
00101     goto ERROR;
00102   };
00103 
00104   /*
00105    * On lit <spacedimension>
00106    */
00107   if (_MEDattrEntierLire(_lzid,MED_NOM_DIM,&_spacedimension) < 0) {
00108     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_LOCALIZATION_MSG);
00109     SSCRUTE(localizationname);SSCRUTE(MED_NOM_DIM);ISCRUTE(_spacedimension);
00110     goto ERROR;
00111   };
00112 
00113 
00114   /*
00115    * On lit les coordonn�es de r�f�rence dans un dataset
00116    */
00117   if ( ! ((_intgeotype > MED_STRUCT_GEO_INTERNAL    ) &&
00118           (_intgeotype < MED_STRUCT_GEO_SUP_INTERNAL)    ) ) {
00119 
00120     _nentity = (_intgeotype%100);
00121 
00122     if ( MEDfilterEntityCr(fid,_nentity, 1, _spacedimension, MED_ALL_CONSTITUENT,
00123                            switchmode,MED_UNDEF_PFLMODE,
00124                            MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00125       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00126       goto ERROR;
00127     }
00128 
00129     if ( _MEDdatasetRd(_lzid,MED_NOM_COO,MED_INTERNAL_FLOAT64,&_filter,
00130                        (unsigned char *) elementcoordinate) < 0) {
00131       MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_COO);SSCRUTE(_path);
00132       goto ERROR;
00133     }
00134 
00135     if ( MEDfilterClose(&_filter) < 0 ) {
00136       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00137       goto ERROR;
00138     }
00139   }
00140 
00141   /*
00142    * On stocke les points d'int�gration dans un dataset
00143    */
00144 
00145   _nentity = _nbofipoint;
00146   if ( MEDfilterEntityCr(fid,_nentity, 1, _spacedimension, MED_ALL_CONSTITUENT,
00147                          switchmode,MED_UNDEF_PFLMODE,
00148                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00149     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00150     goto ERROR;
00151   }
00152 
00153 #ifdef _DEBUG_
00154     ISCRUTE((_filter).nbofentity              );
00155     ISCRUTE((_filter).nbofvaluesperentity     );
00156     ISCRUTE((_filter).nbofconstituentpervalue );
00157     ISCRUTE((_filter).constituentselect       );
00158     ISCRUTE_int((_filter).switchmode              );
00159     ISCRUTE((_filter).filterarraysize         );
00160     ISCRUTE((_filter).profilearraysize        );
00161     ISCRUTE_int((_filter).storagemode             );
00162     SSCRUTE((_filter).profilename             );
00163 #endif
00164 
00165   if ( _MEDdatasetRd(_lzid,MED_NOM_GAU,MED_INTERNAL_FLOAT64,&_filter, 
00166                      (unsigned char *)  ipointcoordinate) < 0) {
00167     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_GAU);SSCRUTE(_path);
00168     goto ERROR;
00169   }
00170 
00171   if ( MEDfilterClose(&_filter) < 0 ) {
00172     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00173     goto ERROR;
00174   }
00175 
00176   /*
00177    * On stocke les poids dans un dataset
00178    */
00179 
00180   _nentity = _nbofipoint;
00181   if ( MEDfilterEntityCr(fid,_nentity, 1, 1, MED_ALL_CONSTITUENT,
00182                          switchmode,MED_UNDEF_PFLMODE,
00183                          MED_NO_PROFILE, MED_UNDEF_SIZE, NULL, &_filter) < 0 ) {
00184     MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_FILTER,MED_ERR_INTERNAL_MSG);
00185     goto ERROR;
00186   }
00187 
00188   if ( _MEDdatasetRd(_lzid,MED_NOM_VAL,MED_INTERNAL_FLOAT64,&_filter,
00189                      (unsigned char *) weight) < 0) {
00190     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_DATASET,MED_NOM_VAL);SSCRUTE(_path);
00191     goto ERROR;
00192   }
00193 
00194   if ( MEDfilterClose(&_filter) < 0 ) {
00195     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_FILTER,MED_ERR_LOCALIZATION_MSG); SSCRUTE(_path);
00196     goto ERROR;
00197   }
00198 
00199 
00200   _ret = 0;
00201 
00202  ERROR:
00203 
00204   if (_lzid>0)            if (_MEDdatagroupFermer(_lzid) < 0) {
00205     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,localizationname);
00206     ISCRUTE_id(_lzid);
00207   }
00208 
00209   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00210     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_GAUSS);
00211     ISCRUTE_id(_root);
00212   }
00213 
00214   va_end(params);
00215   *fret = _ret;
00216 
00217   return;
00218 }

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