00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 #include <med.h>
00020 #include <med_config.h>
00021 #include <med_outils.h>
00022 #include <hdf5.h>
00023 #include <string.h>
00024 
00042 med_err
00043 MEDinterpCr(const med_idt                 fid,
00044             const char*             const interpname,
00045             const med_geometry_type       geotype,
00046             const med_bool                cellnode,
00047             const med_int                 nvariable,
00048             const med_int                 maxdegree,
00049             const med_int                 nmaxcoef
00050             )
00051 {
00052   med_access_mode   _MED_ACCESS_MODE;
00053   med_idt           _root=0,_interpid=0;
00054   med_int           _ret=-1;
00055   char              _path[MED_TAILLE_INTERP+MED_NAME_SIZE+1]=MED_INTERP;
00056   med_int           _cellnodes = cellnode;
00057   med_int           _geotype = geotype;
00058   
00059 
00060 
00061   _MEDmodeErreurVerrouiller();
00062  if (_MEDcheckVersion30(fid) < 0) goto ERROR;
00063 
00064   if ( (_MED_ACCESS_MODE = _MEDmodeAcces(fid) ) == MED_ACC_UNDEF ) {
00065     MED_ERR_(_ret,MED_ERR_UNRECOGNIZED,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00066     goto ERROR;
00067   }
00068 
00069   if ( _MED_ACCESS_MODE == MED_ACC_RDONLY) {
00070     MED_ERR_(_ret,MED_ERR_INVALID,MED_ERR_ACCESSMODE,MED_ERR_FILE_MSG);
00071     ISCRUTE_int(_MED_ACCESS_MODE);
00072     goto ERROR;
00073   }
00074 
00075   
00076 
00077 
00078   if ((_root = _MEDdatagroupOpen(fid,_path)) < 0)
00079     if ((_root = _MEDdatagroupCreer(fid,_path)) < 0) {
00080       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,_path);
00081      goto ERROR;
00082     }
00083 
00084   NOFINALBLANK(interpname,ERROR);
00085 
00086   
00087 
00088 
00089   if ((_interpid = _MEDdatagroupOpen(_root,interpname)) < 0)
00090     if ((_interpid = _MEDdatagroupCreer(_root,interpname)) < 0) {
00091       MED_ERR_(_ret,MED_ERR_CREATE,MED_ERR_DATAGROUP,interpname);
00092       SSCRUTE(_path);goto ERROR;
00093     }
00094 
00095   strcat(_path,interpname);
00096 
00097   
00098 
00099 
00100   if ( _MEDattributeIntWr(_interpid,MED_NOM_GEO,&_geotype) < 0 ) {
00101     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00102     SSCRUTE(MED_NOM_GEO);ISCRUTE(_geotype);
00103     goto ERROR;
00104   }
00105 
00106   
00107 
00108 
00109 
00110 
00111 
00112 
00113 
00114 
00115   
00116 
00117 
00118   if ( _MEDattributeIntWr(_interpid,MED_NOM_NBV,&nvariable) < 0 ) {
00119     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00120     SSCRUTE(MED_NOM_NBV);ISCRUTE(nvariable);
00121     goto ERROR;
00122   }
00123 
00124   
00125 
00126 
00127   if ( _MEDattributeIntWr(_interpid,MED_NOM_MDG,&maxdegree) < 0 ) {
00128     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00129     SSCRUTE(MED_NOM_MDG);ISCRUTE(maxdegree);
00130     goto ERROR;
00131   }
00132 
00133   
00134 
00135 
00136   if ( _MEDattributeIntWr(_interpid,MED_NOM_MCF,&nmaxcoef) < 0 ) {
00137     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00138     SSCRUTE(MED_NOM_MCF);ISCRUTE(nmaxcoef);
00139     goto ERROR;
00140   }
00141 
00142   
00143 
00144 
00145   if ( _MEDattributeIntWr(_interpid,MED_NOM_FCN,&_cellnodes) < 0 ) {
00146     MED_ERR_(_ret,MED_ERR_WRITE,MED_ERR_ATTRIBUTE,_path);
00147     SSCRUTE(MED_NOM_FCN);ISCRUTE(_cellnodes);
00148     goto ERROR;
00149   }
00150 
00151   _ret = 0;
00152 
00153  ERROR:
00154 
00155   if (_interpid>0)     if (_MEDdatagroupFermer(_interpid) < 0) {
00156     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,_path);
00157     ISCRUTE_id(_interpid);
00158   }
00159 
00160   if (_root>0)            if (_MEDdatagroupFermer(_root) < 0) {
00161     MED_ERR_(_ret,MED_ERR_CLOSE,MED_ERR_DATAGROUP,MED_INTERP);
00162     ISCRUTE_id(_root);
00163   }
00164 
00165   return _ret;
00166 
00167 }