MEDparameterComputationStepInfo.c

Aller à la documentation de ce fichier.
00001 /*  This file is part of MED.
00002  *
00003  *  COPYRIGHT (C) 1999 - 2015  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 
00037 med_err
00038 MEDparameterComputationStepInfo(const med_idt      fid,
00039                                 const char * const paramname,
00040                                 const int          csit,
00041                                 med_int * const    numdt,
00042                                 med_int * const    numit,
00043                                 med_float * const  dt )
00044 {
00045   med_err _ret = -1, _err = -1;
00046   med_idt _cpstidt = 0;
00047   char    _path[(MED_TAILLE_NUM_DATA+MED_NAME_SIZE+1)+2*MED_MAX_PARA+1]=MED_NUM_DATA;
00048   int     _num=csit-1;
00049   char    _cstpname[2*MED_MAX_PARA+1]="";
00050 
00051   _MEDmodeErreurVerrouiller();
00052   
00053   /* On recupere le nom du pas de temps */
00054   strcat(_path, paramname);
00055   if ( _MEDobjectGetName(fid, _path ,_num, _cstpname) < 0 ) {
00056     MED_ERR_(_ret,MED_ERR_ACCESS,MED_ERR_DATAGROUP,_path);ISCRUTE_int(_num);
00057     goto ERROR;
00058   }
00059 
00060   /* on ouvre le groupe HDF correspondant */
00061   strcat(_path,"/");
00062   strcat(_path,_cstpname);
00063   if ((_cpstidt = _MEDdatagroupOuvrir(fid,_path)) < 0) {
00064     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
00065     goto ERROR;
00066   }
00067 
00068   /* Lecture des attributs */
00069   if (_MEDattrEntierLire(_cpstidt, MED_NOM_NDT, (med_int*) numdt) < 0) {
00070     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NDT);
00071     SSCRUTE(_path);ISCRUTE(*numdt);goto ERROR;
00072   }
00073   if (_MEDattrFloatLire(_cpstidt, MED_NOM_PDT, (med_float*) dt) < 0) {
00074     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_PDT);
00075     SSCRUTE(_path);RSCRUTE(*dt);goto ERROR;
00076   }
00077   if (_MEDattrEntierLire(_cpstidt, MED_NOM_NOR, (med_int*) numit) < 0) {
00078     MED_ERR_(_ret,MED_ERR_READ,MED_ERR_ATTRIBUTE,MED_NOM_NOR);
00079     SSCRUTE(_path);ISCRUTE(*numit);goto ERROR;
00080   }
00081 
00082   _ret = 0;
00083  ERROR:
00084 
00085   /* on ferme tout */
00086   if (_cpstidt > 0)            
00087     if (_MEDdatagroupFermer(_cpstidt) < 0) {
00088       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00089       ISCRUTE_id(_cpstidt);
00090     }
00091 
00092   return _ret;
00093 }

Généré le Thu Oct 8 14:26:16 2015 pour MED fichier par  doxygen 1.6.1