MEDnumLire.c
Aller à la documentation de ce fichier.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
00023 #include <stdlib.h>
00024 #include <string.h>
00025
00026 med_err
00027 MEDnumLire(med_idt fid,char *maa, med_int *num, med_int n,
00028 med_entite_maillage type_ent,med_geometrie_element type_geo)
00029 {
00030 med_idt root;
00031 med_idt maaid = 0;
00032 med_idt geoid = 0;
00033 med_idt entid = 0;
00034 med_err ret = -1;
00035 char chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00036 char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00037 char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00038 med_entite_maillage _type_ent=type_ent;
00039
00040 if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00041
00042
00043
00044
00045 _MEDmodeErreurVerrouiller();
00046 if (MEDcheckVersion(fid) < 0) return -1;
00047
00048
00049
00050
00051
00052 strcpy(chemin,MED_MAA);
00053 strcat(chemin,maa);
00054 if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
00055 MESSAGE("Impossible d'acceder au maillage");
00056 SSCRUTE(chemin);
00057 goto ERREUR;
00058 }
00059
00060
00061
00062
00063
00064 if (_MEDnomEntite(nom_ent,_type_ent) < 0) {
00065 MESSAGE("L'entité demandée n'est pas une entité <med_entite_maillage> : ");
00066 SSCRUTE(nom_ent);
00067 ISCRUTE(_type_ent);
00068 goto ERREUR;
00069 }
00070
00071
00072
00073
00074 if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0) {
00075 MESSAGE("Impossible d'accéder au groupe des entités : ");
00076 SSCRUTE(nom_ent);
00077 ISCRUTE(_type_ent);
00078 goto ERREUR;
00079 }
00080
00081
00082
00083
00084
00085 if ((_type_ent==MED_MAILLE)||(_type_ent==MED_FACE)||(_type_ent==MED_ARETE))
00086 {
00087 if (_MEDnomGeometrie30(nom_geo,type_geo) < 0) {
00088 MESSAGE("L'entité demandée n'est pas un élément <med_geometrie_element> : ");
00089 SSCRUTE(nom_geo);
00090 ISCRUTE(type_geo);
00091 goto ERREUR;
00092 }
00093 if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0) {
00094 MESSAGE("Impossible d'accéder au groupe des éléments géométriques : ");
00095 SSCRUTE(nom_geo);
00096 ISCRUTE(type_geo);
00097 goto ERREUR;
00098 }
00099 }
00100 else
00101 geoid = -1;
00102
00103
00104
00105
00106
00107
00108 if (geoid == -1)
00109 root = entid;
00110 else
00111 root = geoid;
00112 #if defined(HAVE_F77INT64)
00113 if (_MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT64,
00114 MED_NO_INTERLACE,1,MED_ALL,
00115 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00116 (unsigned char*) num) < 0)
00117 goto ERREUR;
00118 #else
00119 if (_MEDdatasetNumLire(root,MED_NOM_NUM,MED_INT32,
00120 MED_NO_INTERLACE,1,MED_ALL,
00121 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00122 (unsigned char*) num) < 0)
00123 goto ERREUR;
00124 #endif
00125
00126
00127
00128
00129 ret = 0;
00130
00131
00132
00133
00134 ERREUR:
00135 if (geoid > 0)
00136 if (_MEDdatagroupFermer(geoid) < 0)
00137 return -1;
00138 if (entid > 0)
00139 if (_MEDdatagroupFermer(entid) < 0)
00140 return -1;
00141 if (maaid > 0)
00142 if (_MEDdatagroupFermer(maaid) < 0)
00143 return -1;
00144
00145
00146
00147
00148
00149 return (ret);
00150 }