MEDparameterCr.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 
00023 #include <string.h>
00024 #include <stdlib.h>
00025 
00037 med_err
00038 MEDparameterCr(const med_idt fid,
00039                const char * const paramname, 
00040                const med_parameter_type paramtype,
00041                const char* const description,
00042                const char * const dtunit
00043               )
00044 {
00045   med_err _ret=-1;
00046   med_idt _root=0,_datagroup1=0;
00047   med_access_mode _MED_ACCESS_MODE;
00048   char _datagroupname1    [MED_NAME_SIZE+1]="";
00049   med_int _paramtype = (med_int) paramtype;
00050 
00051 
00052  _MEDmodeErreurVerrouiller();
00053  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00054  if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00055    MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00056    goto ERROR;
00057  }
00058   
00059  if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
00060    MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00061    ISCRUTE_int(_MED_ACCESS_MODE);
00062    goto ERROR;
00063  }
00064 
00065   /*
00066    * Si le DataGroup MED_NUM_DATA n'existe pas, on le cree
00067    */
00068   if ((_root = _MEDdatagroupOuvrir(fid,MED_NUM_DATA)) < 0)
00069     if ((_root = _MEDdatagroupCreer(fid,MED_NUM_DATA)) < 0) {
00070      MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_NUM_DATA);
00071      goto ERROR;
00072     }
00073   NOFINALBLANK(paramname,ERROR); 
00074 
00075   /*
00076    * Si le Data Group "/NUM_DATA/<paramname>" n'existe pas, on le cree
00077    */
00078   if ((_datagroup1 = _MEDdatagroupOuvrir(_root,paramname)) < 0)
00079     if ((_datagroup1 = _MEDdatagroupCreer(_root,paramname)) < 0 ) {
00080       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,MED_NUM_DATA);
00081       SSCRUTE(paramname);goto ERROR;
00082     }
00083  
00084   /*
00085    * Ecriture des infos relatives au parametre : type, dtunit, description
00086    */
00087   if ( _MEDattributeIntWr(_datagroup1,MED_NOM_TYP,&_paramtype) < 0) {
00088     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_PARAM_MSG);
00089     SSCRUTE(paramname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_TYP);
00090     ISCRUTE(_paramtype);goto ERROR;
00091   }
00092   if ( _MEDattributeStringWr(_datagroup1,MED_NOM_DES,MED_COMMENT_SIZE,description) < 0) {
00093     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_PARAM_MSG);
00094     SSCRUTE(paramname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_DES);
00095     SSCRUTE(description);goto ERROR;
00096   }
00097   if ( _MEDattributeStringWr(_datagroup1,MED_NOM_UNT,MED_SNAME_SIZE,dtunit) < 0) {
00098     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_ERR_PARAM_MSG);
00099     SSCRUTE(paramname);SSCRUTE(_datagroupname1);SSCRUTE(MED_NOM_UNT);
00100     SSCRUTE(dtunit);goto ERROR;
00101   }
00102 
00103   _ret = 0;
00104  ERROR :
00105 
00106   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00107     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname1);
00108     ISCRUTE_id(_datagroup1);
00109   }
00110 
00111   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00112     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_NUM_DATA);
00113     ISCRUTE_id(_root);
00114   }
00115 
00116   return _ret;
00117 }

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