00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 #include <med.h>
00019 #include <med_config.h>
00020 #include <med_outils.h>
00021 
00022 #include <string.h>
00023 #include <stdlib.h>
00024 
00025 med_err
00026 MEDgaussEcr(med_idt fid, med_geometrie_element type_geo, med_float *refcoo, med_mode_switch mode_coo,
00027             med_int ngauss, med_float *gscoo, med_float * wg, char * locname )
00028 {
00029   med_idt gid=0, chid=0;
00030   med_size dimd[1];
00031   med_err ret = -1;
00032   med_int typegeo = -1;
00033   char chemin[MED_TAILLE_GAUSS+1]="";
00034   med_mode_acces MED_MODE_ACCES;
00035 
00036   
00037 
00038 
00039   _MEDmodeErreurVerrouiller();
00040 if (MEDcheckVersion(fid) < 0) return -1;
00041 
00042 
00043   if ( (MED_MODE_ACCES = _MEDmodeAcces(fid) ) == MED_UNDEF_MODE_ACCES ) {
00044     MESSAGE("Impossible de déterminer le mode d'acces au fichier ");
00045     goto ERROR;
00046   }
00047 
00048   
00049 
00050 
00051   if (! strcmp(locname,MED_GAUSS_ELNO)) {
00052     MESSAGE("MED_GAUSS_ELNO est un mot cle reserve : points Gauss sur les noeuds de l'element");
00053     goto ERROR;   
00054    }
00055 
00056   
00057 
00058 
00059   strncpy(chemin,MED_GAUSS,MED_TAILLE_GAUSS-1);
00060   chemin[MED_TAILLE_GAUSS-1] = '\0';
00061   if ((gid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00062     if ((gid = _MEDdatagroupCreer(fid,chemin)) < 0) {
00063       MESSAGE("Impossible de creer le groupe MED_GAUSS : ");
00064       SSCRUTE(chemin); goto ERROR;
00065     }
00066   
00067   
00068 
00069 
00070 
00071   NOFINALBLANK(locname,ERROR);
00072 
00073   if ((chid = _MEDdatagroupOuvrir(gid,locname)) >= 0) {
00074     if ( MED_MODE_ACCES != MED_LECTURE_ECRITURE ) {
00075       MESSAGE("Le nom de localisation existe déjà : ");
00076       SSCRUTE(locname); goto ERROR;
00077     }
00078   } else
00079     if ((chid = _MEDdatagroupCreer(gid,locname)) < 0)
00080       goto ERROR;
00081 
00082   
00083 
00084 
00085   if (_MEDattrEntierEcrire(chid,MED_NOM_NBR,&ngauss) < 0) {
00086     MESSAGE("Erreur à l'écriture de l'attribut MED_NOM_NBR : ");
00087     ISCRUTE(ngauss);goto ERROR;
00088   };
00089 
00090   
00091 
00092 
00093   typegeo = (med_int) type_geo; 
00094   
00095 
00096 
00097 
00098 
00099 
00100   if (_MEDattrEntierEcrire(chid,MED_NOM_GEO,&typegeo) < 0) {
00101     MESSAGE("Erreur à l'écriture de l'attribut MED_NOM_GEO : ");
00102     ISCRUTE(type_geo);goto ERROR;
00103   };
00104 
00105 
00106   
00107 
00108 
00109 
00110   dimd[0] = (type_geo%100)*(type_geo/100);
00111   if ( _MEDdatasetNumEcrire(chid,MED_NOM_COO,MED_FLOAT64,mode_coo,(type_geo/100),MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00112                             (unsigned char*) refcoo)  < 0 ) {
00113     MESSAGE("Impossible d'ecrire le dataset : ");SSCRUTE(MED_NOM_COO);
00114     ISCRUTE_size(dimd[0]); goto ERROR;
00115   }
00116 
00117   
00118 
00119 
00120    
00121   dimd[0] = ngauss*(type_geo/100);
00122   if ( _MEDdatasetNumEcrire(chid,MED_NOM_GAU,MED_FLOAT64,mode_coo,(type_geo/100),MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00123                             (unsigned char*) gscoo)  < 0 ) {
00124     MESSAGE("Impossible d'ecrire le dataset : ");SSCRUTE(MED_NOM_GAU);
00125     ISCRUTE_size(dimd[0]); goto ERROR;
00126   }
00127   
00128   
00129 
00130 
00131    
00132   dimd[0] = ngauss; 
00133   if ( _MEDdatasetNumEcrire(chid,MED_NOM_VAL,MED_FLOAT64,mode_coo,1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00134                             (unsigned char*) wg)  < 0 ) {
00135     MESSAGE("Impossible d'ecrire le dataset : ");SSCRUTE(MED_NOM_VAL);
00136     ISCRUTE_size(dimd[0]); goto ERROR;
00137   }
00138 
00139 
00140   ret = 0;
00141 
00142  ERROR:
00143   
00144   
00145 
00146 
00147   
00148   if (chid>0)     if (_MEDdatagroupFermer(chid) < 0) {
00149     MESSAGE("Impossible de fermer le datagroup : ");
00150     ISCRUTE_id(chid); ret = -1; 
00151   }
00152 
00153   if (gid>0)     if (_MEDdatagroupFermer(gid) < 0) {
00154     MESSAGE("Impossible de fermer le datagroup : ");
00155     ISCRUTE_id(gid); ret = -1; 
00156   }
00157   
00158   return ret;
00159 }
00160