# MEDfieldComputingStepMeshWr.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2012  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
    00035 med_err
    00036 MEDfieldComputingStepMeshWr(const med_idt fid,
    00037                             const char * const fieldname,
    00038                             med_int numdt,
    00039                             med_int numit,
    00040                             med_int meshnumdt,
    00041                             med_int meshnumit) {
    00042
    00043   med_access_mode  _MED_ACCESS_MODE;
    00044   med_err          _ret=-1;
    00045   med_idt          _gid=0;
    00046   char    _path          [(MED_TAILLE_CHA+MED_NAME_SIZE+1)+2*MED_MAX_PARA+1]=MED_CHA;
    00047
    00048   /*   char    _datagroupname1[2*MED_MAX_PARA+1]=""; */
    00049   /*   char    _cstpname[2*MED_MAX_PARA+1]=""; */
    00050
    00051   /*
    00052    * On inhibe le gestionnaire d'erreur HDF 5
    00053    */
    00054   _MEDmodeErreurVerrouiller();
    00055 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
    00056
    00057   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
    00058     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00059     goto ERROR;
    00060   }
    00061
    00062   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
    00063     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
    00064     ISCRUTE_int(_MED_ACCESS_MODE);
    00065     goto ERROR;
    00066   }
    00067
    00068   /*
    00069    * On construit le nom du datagroup
    00070    */
    00071   strcat(_path,fieldname);
    00072   strcat(_path,"/");
    00073   _MEDgetComputationStepName(MED_SORT_DTIT,numdt,numit,&_path[strlen(_path)]);
    00074
    00075
    00076   if ((_gid = _MEDdatagroupOuvrir(fid,_path)) < 0) {
    00077     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,_path);
    00078     goto ERROR;
    00079   }
    00080
    00081
    00082   /*
    00083    * Ecriture des attributs
    00084    */
    00085
    00086   if (_MEDattributeIntWr(_gid,MED_NOM_RDT,  &meshnumdt) < 0) {
    00087     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_RDT);
    00088     SSCRUTE(_path);ISCRUTE(meshnumdt);goto ERROR;
    00089   }
    00090
    00091   if (_MEDattributeIntWr(_gid,MED_NOM_ROR, &meshnumit) < 0) {
    00092     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,MED_NOM_ROR);
    00093     SSCRUTE(_path);ISCRUTE(meshnumit);goto ERROR;
    00094   }
    00095
    00096
    00097   _ret = 0;
    00098
    00099  ERROR:
    00100
    00101
    00102   if (_gid>0)            if (_MEDdatagroupFermer(_gid) < 0) {
    00103     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
    00104     ISCRUTE_id(_gid);
    00105   }
    00106
    00107   return _ret;
    00108 }