_MEDmeshAssociatedGroupCr.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 /* Crée ou ouvre une structure de la forme
00026   /<meddatatypename>/<meshname>/<PDT,IT|DEFAULT>/<groupname>/
00027 */
00028 
00029 med_idt
00030 _MEDmeshAssociatedGroupCr(const med_idt               fid,
00031                           const char*  const          rootname,
00032                           const char*  const          meshname,
00033                           const med_int               numdt,
00034                           const med_int               numit,
00035                           const med_float             dt,
00036                           const med_bool              justopen,
00037                           const char*  const          datagroupname )
00038 
00039 {
00040   med_access_mode       _MED_ACCESS_MODE;
00041   med_idt               _ret=-1;
00042   med_idt               _root=0,_meshid=0,_datagroup1=0,_datagroup2=0,_datagroup3=0;
00043   char                  _datagroupname2   [2*MED_MAX_PARA+1]="";
00044   med_sorting_type      _sortingtype=0;
00045   med_bool              _datagp3created = MED_FALSE;
00046 
00047  /*
00048    * On inhibe le gestionnaire d'erreur HDF 5
00049    */
00050   _MEDmodeErreurVerrouiller();
00051 if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00052 
00053   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00054     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00055     goto ERROR;
00056   }
00057 
00058   if (! justopen) {
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   /*
00067    * Récupère l'ordre de tri des séquences de calcul
00068    * Si le DataGroup MED_MAA/<meshname> n'existe pas => erreur
00069    * il doit être crée par MEDmeshCr
00070    */
00071   NOFINALBLANK(meshname,ERROR);
00072   NOFINALBLANK(datagroupname,ERROR);
00073 
00074   if ( MEDmeshSortingTypeRd(fid,meshname,&_sortingtype) < 0 ) {
00075     MED_ERR_(_ret,MED_ERR_CALL,MED_ERR_API," MEDmeshSortingTypeRd");
00076     SSCRUTE(meshname);goto ERROR;
00077   }
00078 
00079   /*
00080    * Ouverture du DataGroup rootname
00081    */
00082 
00083   if ((_root = _MEDdatagroupOuvrir(fid,rootname)) < 0) {
00084     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,rootname);
00085     goto ERROR;
00086   }
00087 
00088   /*
00089    * Si le Data Group <meshname> n'existe pas, on le cree
00090    */
00091   if ((_datagroup1 = _MEDdatagroupOuvrir(_root,meshname)) < 0) {
00092     MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,meshname);
00093     goto ERROR;
00094   }
00095 
00096   _MEDgetComputationStepName(_sortingtype,numdt,numit,_datagroupname2);
00097 
00098   /*
00099    * Creation/Ouverture du datagroup <numdt>.<numit>
00100    */
00101   if ( (_datagroup2 = _MEDdatagroupOuvrir(_datagroup1,_datagroupname2)) < 0 ) {
00102     if (justopen) {
00103       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_COMPUTINGSTEP,MED_ERR_MESH_MSG);
00104       SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);goto ERROR;
00105     }
00106     if ( MEDmeshComputationStepCr(fid,meshname,numdt,numit,numdt,numit,dt) < 0 ) {
00107       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_COMPUTINGSTEP,MED_ERR_MESH_MSG);
00108       SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);goto ERROR;
00109     } else {
00110       if ( (_datagroup2 = _MEDdatagroupOuvrir(_datagroup1,_datagroupname2)) < 0 ) {
00111         MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00112         SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);
00113         ISCRUTE_id(_datagroup2);goto ERROR;
00114       }
00115     }
00116   }
00117 
00118   /*
00119    * Si le Data Group <datagroupname> n'existe pas, on le cree
00120    */
00121   if ((_datagroup3 = _MEDdatagroupOuvrir(_datagroup2,datagroupname)) < 0) {
00122     if (justopen) {
00123       MED_ERR_(_ret,MED_ERR_OPEN,MED_ERR_DATAGROUP,MED_ERR_MESH_MSG);
00124       SSCRUTE(meshname);ISCRUTE(numit);ISCRUTE(numdt);SSCRUTE(datagroupname);
00125       goto ERROR;
00126     }
00127     if ((_datagroup3 = _MEDdatagroupCreer(_datagroup2,datagroupname)) < 0 ) {
00128       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,datagroupname);
00129       goto ERROR;
00130     }
00131     else
00132       _datagp3created = MED_TRUE;
00133   }
00134 
00135   _ret = _datagroup3;
00136 
00137  ERROR:
00138 
00139   if ( (_datagroup3 >0) && ( _datagp3created ) )
00140     if (_MEDdatagroupFermer(_datagroup3) < 0) {
00141       MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,datagroupname);
00142       ISCRUTE_id(_datagroup3);
00143     }
00144 
00145   if (_datagroup2>0)     if (_MEDdatagroupFermer(_datagroup2) < 0) {
00146     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_datagroupname2);
00147     ISCRUTE_id(_datagroup2);
00148   }
00149 
00150   if (_datagroup1>0)     if (_MEDdatagroupFermer(_datagroup1) < 0) {
00151     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,meshname);
00152     ISCRUTE_id(_datagroup1);
00153   }
00154 
00155   if (_root>0)     if (_MEDdatagroupFermer(_root) < 0) {
00156     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,rootname);
00157     ISCRUTE_id(_root);
00158   }
00159 
00160 
00161   return _ret;
00162 
00163 }

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