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 MEDfamInfo(med_idt fid,char *maa,int indice, char *famille,
00028 med_int *numero,
00029 med_int *attr_ident, med_int *attr_val, char *attr_desc,
00030 med_int *n_attr, char *groupe ,med_int *n_groupe)
00031 {
00032 med_idt famid,datagroup;
00033 med_err ret;
00034 char chemin[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
00035 char stockage[MED_TAILLE_MAA+MED_TAILLE_FAS+MED_TAILLE_FAS_ENTITE+2*MED_TAILLE_NOM+1];
00036 int num;
00037 int nfamnoe,nfammai;
00038 int n_tmp;
00039 med_booleen _isfam0=MED_FAUX;
00040
00041
00042
00043
00044 _MEDmodeErreurVerrouiller();
00045 if (MEDcheckVersion(fid) < 0) return -1;
00046
00047
00048
00049
00050
00051 num = indice - 1;
00052 strcpy(famille,"");
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 strcpy(chemin,MED_MAA);
00064 strcat(chemin,maa);
00065 strcat(chemin,MED_FAS);
00066
00067 strcpy(stockage,chemin);
00068 strcat(stockage,MED_FAS_ELEME_NOM);
00069 nfammai = 0;
00070 n_tmp = 0;
00071 if ((ret =_MEDnObjets(fid,stockage,&n_tmp)) == 0)
00072 nfammai = (med_int ) n_tmp;
00073 strcat(stockage,"/");
00074
00075
00076 if (num == nfammai) {
00077 strcpy(stockage,chemin);
00078 strcpy(famille,FAMILLE_ZERO);
00079 }
00080
00081 if (num > nfammai) {
00082
00083 strcpy(stockage,chemin);
00084 strcat(stockage,MED_FAS_NOEUD_NOM);
00085 strcat(stockage,"/");
00086 num = num - nfammai - 1;
00087 }
00088
00089
00090
00091
00092
00093
00094 if (strcmp(famille,FAMILLE_ZERO)) {
00095 _isfam0=MED_FAUX;
00096 if ((ret = _MEDobjetIdentifier(fid,stockage,num, famille)) < 0)
00097 return -1;
00098 } else
00099 _isfam0=MED_VRAI;
00100
00101 strcat(stockage,famille);
00102 if ((famid = _MEDdatagroupOuvrir(fid,stockage)) < 0)
00103 return -1;
00104
00105
00106
00107
00108 if ((ret = _MEDattrEntierLire(famid,MED_NOM_NUM,numero)) < 0)
00109 return -1;
00110
00111
00112
00113
00114 if (!_isfam0) {
00115 if ((datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_GRO)) >= 0) {
00116
00117
00118
00119 if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_groupe)) < 0)
00120 return -1;
00121
00122
00123
00124
00125 if ((ret = _MEDdatasetStringLire(datagroup,MED_NOM_NOM,groupe)) < 0)
00126 return -1;
00127
00128
00129
00130
00131 if ((ret = _MEDdatagroupFermer(datagroup)) < 0) return -1;
00132 } else
00133 *n_groupe = 0;
00134 } else
00135 *n_groupe = 0;
00136
00137
00138
00139
00140
00141
00142 if (!_isfam0) {
00143 if ( (datagroup = _MEDdatagroupOuvrir(famid,MED_NOM_ATT)) >= 0) {
00144
00145
00146
00147 if ((ret = _MEDattrEntierLire(datagroup,MED_NOM_NBR,n_attr)) < 0)
00148 return -1;
00149
00150
00151
00152
00153 #if defined(HAVE_F77INT64)
00154 if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT64,
00155 MED_NO_INTERLACE,1,MED_ALL,
00156 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00157 (unsigned char*) attr_ident)) < 0)
00158 return -1;
00159 #else
00160 if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_IDE,MED_INT32,
00161 MED_NO_INTERLACE,1,MED_ALL,
00162 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00163 (unsigned char*) attr_ident)) < 0)
00164 return -1;
00165 #endif
00166
00167
00168
00169
00170 #if defined(HAVE_F77INT64)
00171 if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT64,
00172 MED_NO_INTERLACE,1,MED_ALL,
00173 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00174 (unsigned char *) attr_val)) < 0)
00175 return -1;
00176 #else
00177 if ((ret = _MEDdatasetNumLire(datagroup,MED_NOM_VAL,MED_INT32,
00178 MED_NO_INTERLACE,1,MED_ALL,
00179 MED_NOPF,MED_NO_PFLMOD,MED_PFL_NON_COMPACT,0,MED_NOPG,0,
00180 (unsigned char *) attr_val)) < 0)
00181 return -1;
00182 #endif
00183
00184
00185
00186
00187 ret = _MEDdatasetStringLire(datagroup,MED_NOM_DES,attr_desc);
00188
00189
00190
00191
00192 if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00193 return -1;
00194 } else
00195 *n_attr = 0;
00196 } else
00197 *n_attr = 0;
00198
00199
00200
00201
00202
00203 if ((ret = _MEDdatagroupFermer(famid)) < 0)
00204 return -1;
00205
00206 return 0;
00207 }
00208
00209
00210