# MEDmeshComputationStepDtRd.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
    00026 med_err
    00027 MEDmeshComputationStepDtRd(const med_idt fid,
    00028                            const char * const meshname,
    00029                            const med_int numdt,
    00030                            const med_int numit,
    00031                            med_float * dt )
    00032 {
    00033
    00034   med_err  _ret=-1;
    00035   med_idt  _meshid=0,_datagroup1=0;
    00036   char     _meshpath[MED_TAILLE_MAA+MED_NAME_SIZE+1+2*MED_MAX_PARA+1+1]=MED_MAA;
    00037   char     _datagroupname1[2*MED_MAX_PARA+1]="";
    00038   med_sorting_type _sortingtype;
    00039   med_int          _intsortingtype;
    00040
    00041   /*
    00042    * On inhibe le gestionnaire d'erreur
    00043    */
    00044   _MEDmodeErreurVerrouiller();
    00045
    00046
    00047   strcat( _meshpath, meshname);
    00048   if ((_meshid = _MEDdatagroupOuvrir(fid,_meshpath)) < 0) {
    00049     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_meshpath);
    00050     ISCRUTE_id(_meshid);goto ERROR;
    00051   }
    00052
    00053   if ( _MEDattrEntierLire(_meshid,MED_NOM_SRT,&_intsortingtype) < 0) {
    00054    MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00055     SSCRUTE(meshname);SSCRUTE(MED_NOM_SRT);
    00056     ISCRUTE(_intsortingtype);goto ERROR;
    00057   }
    00058   _sortingtype = (med_sorting_type) (_intsortingtype);
    00059
    00060   _MEDgetComputationStepName(_sortingtype,numdt,numit,_datagroupname1);
    00061
    00062   if ( (_datagroup1 = _MEDdatagroupOuvrir(_meshid,_datagroupname1)) < 0 ) {
    00063       MED_ERR_(_ret,MED_ERR_DOESNTEXIST,MED_ERR_COMPUTINGSTEP,_datagroupname1);
    00064       SSCRUTE(meshname);goto ERROR;
    00065   }
    00066
    00067
    00068   /*Cree ou ouvre l'attribut MED_NOM_NDT pour lecture */
    00069   if ( _MEDattrEntierLire(_datagroup1,MED_NOM_NDT,&numdt) < 0) {
    00070     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00071     SSCRUTE(meshname);SSCRUTE(_meshpath);SSCRUTE(MED_NOM_NDT);
    00072     ISCRUTE(numdt);goto ERROR;
    00073   }
    00074
    00075   /*Cree ou ouvre l'attribut MED_NOM_PDT pour lecture */
    00076   if ( _MEDattrFloatLire(_datagroup1,MED_NOM_PDT,&dt) < 0) {
    00077     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00078     SSCRUTE(meshname);SSCRUTE(_meshpath);SSCRUTE(MED_NOM_PDT);
    00079     RSCRUTE(*dt);goto ERROR;
    00080   }
    00081
    00082   /*Cree ou ouvre l'attribut MED_NOM_NOR pour lecture */
    00083   if ( _MEDattrEntierLire(_datagroup1,MED_NOM_NOR,&numit) < 0) {
    00084     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_ERR_MESH_MSG);
    00085     SSCRUTE(meshname);SSCRUTE(_meshpath);SSCRUTE(MED_NOM_NOR);
    00086     ISCRUTE(numit); goto ERROR;
    00087   }
    00088
    00089   _ret = 0;
    00090  ERROR:
    00091
    00092   if (_meshid>0)     if (_MEDdatagroupFermer(_meshid) < 0) {
    00093     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
    00094     ISCRUTE_id(_meshid);
    00095   }
    00096
    00097   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
    00098     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_meshpath);
    00099     SSCRUTE(_datagroupname1);ISCRUTE_id(_datagroup1);
    00100   }
    00101
    00102   return _ret;
    00103 }