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 <string.h>
00022 #include <stdlib.h>
00023 #include <med_outils.h>
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038  
00039 
00040 med_int 
00041 MEDnVal(med_idt fid, char *cha, med_entite_maillage type_ent, 
00042         med_geometrie_element type_geo,med_int numdt, med_int numo, char * maa, med_mode_profil pflmod)
00043 {
00044   med_int n=-1, ngauss=0, pfluse=0;
00045   med_idt datagroup3=0;
00046   char nomdatagroup1[2*MED_TAILLE_NOM_ENTITE+2]="";
00047   char nomdatagroup2[2*MED_MAX_PARA+1]="";
00048   char tmp1   [MED_TAILLE_NOM_ENTITE+1]="";
00049   char chemin [MED_TAILLE_CHA+(MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";
00050   char chemin_i [MED_TAILLE_CHA+(MED_TAILLE_NOM+1)+(2*MED_TAILLE_NOM_ENTITE+2)+(2*MED_MAX_PARA+1)+(MED_TAILLE_NOM)+1]="";  
00051   char pfltmp[MED_TAILLE_NOM+1]="";
00052   char maa_i [MED_TAILLE_NOM+1]="";
00053   med_int   psize=0;
00054   
00055   
00056 
00057 
00058   _MEDmodeErreurVerrouiller();
00059 if (MEDcheckVersion(fid) < 0) return -1;
00060 
00061 
00062   
00063 
00064 
00065   strcpy(chemin,MED_CHA);
00066   strcat(chemin,cha);
00067   strcat(chemin,"/");
00068 
00069   
00070   
00071   
00072   if ( _MEDnomEntite(nomdatagroup1,type_ent) < 0 )
00073     goto ERROR;
00074   if ((type_ent != MED_NOEUD)) {
00075     if ( _MEDnomGeometrie30(tmp1,type_geo) < 0)
00076       goto ERROR;
00077     strcat(nomdatagroup1,".");
00078     strcat(nomdatagroup1,tmp1);
00079   }
00080   strcat(chemin,nomdatagroup1);
00081   strcat(chemin,"/");
00082 
00083   
00084   sprintf(nomdatagroup2,"%*li%*li",MED_MAX_PARA,(long ) numdt,MED_MAX_PARA,(long ) numo);
00085   strcat(chemin,nomdatagroup2);
00086   strcat(chemin,"/");
00087 
00088   
00089   if ( strcmp(maa,MED_NOREF) ) 
00090     strcat(chemin,maa);
00091   else {
00092     strcpy(chemin_i,chemin);
00093 
00094     if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin_i)) < 0) return 0;
00095 
00096     if (_MEDattrStringLire(datagroup3,MED_NOM_MAI,MED_TAILLE_NOM,maa_i) < 0)
00097       goto ERROR;
00098 
00099     strcat(chemin,maa_i);
00100 
00101     if ( _MEDdatagroupFermer(datagroup3) < 0) {
00102       MESSAGE("Impossible de fermer le datagroup : ");
00103       ISCRUTE_int(datagroup3); goto ERROR;
00104     }
00105   }
00106 
00107   
00108 
00109 
00110   if ((datagroup3 = _MEDdatagroupOuvrir(fid,chemin)) < 0) 
00111     return 0;
00112 
00113   switch(pflmod) {
00114     
00115   case MED_GLOBAL :
00116     
00117     if ( _MEDattrEntierLire(datagroup3,MED_NOM_NBR,&n) < 0) {
00118       MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NBR : ");
00119       ISCRUTE(n);goto ERROR;
00120     };    
00121     break;
00122     
00123   case MED_COMPACT :
00124  
00125     
00126     
00127     if (_MEDattrStringLire(datagroup3,MED_NOM_PFL,MED_TAILLE_NOM,pfltmp) < 0){
00128       MESSAGE("Erreur à la lecture de l'attribut MED_NOM_PFL : ");
00129       SSCRUTE(pfltmp);goto ERROR;
00130     };   
00131 
00132     
00133     
00134     if ( (pfluse = (strcmp(pfltmp,MED_NOPFLi) && strcmp(pfltmp,"")) ) ) {
00135       if ( (psize = MEDnValProfil(fid,pfltmp)) < 0 ) {
00136         MESSAGE("Erreur à l'appel de MEDnValProfil : ");
00137         SSCRUTE(pfltmp);goto ERROR;
00138       };
00139     } else {
00140       if ( _MEDattrEntierLire(datagroup3,MED_NOM_NBR,&n) < 0) {
00141         MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NBR : ");
00142         ISCRUTE(n);goto ERROR;
00143       };    
00144        break;     
00145     };
00146     
00147     
00148     if (_MEDattrEntierLire(datagroup3,MED_NOM_NGA,&ngauss) < 0) {
00149       MESSAGE("Erreur à la lecture de l'attribut MED_NOM_NGA : ");
00150       ISCRUTE(ngauss);goto ERROR;
00151     };   
00152 
00153     
00154     if (type_ent == MED_NOEUD_MAILLE )
00155       ngauss = type_geo % 100;
00156 
00157     n= ngauss * psize;
00158     
00159     break;
00160     
00161   default :
00162       MESSAGE("Erreur : <pflmod> doit etre positionné soit à MED_GLOBAL soit à MED_COMPACT ");
00163     break;
00164     
00165   }
00166   
00167   ERROR :
00168     
00169     if (datagroup3>0) 
00170       if ( _MEDdatagroupFermer(datagroup3) < 0) {
00171         MESSAGE("Impossible de fermer le datagroup : ");
00172         ISCRUTE_int(datagroup3); n = -1; 
00173       } 
00174   
00175   return n;
00176 }
00177 
00178 
00179