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 MEDglobalNumEcr(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_err ret=-1;
00031 med_idt root=0, maaid=0, entid=0, geoid=0, dataset=0;
00032 med_size dimd[1];
00033 char chemin [MED_TAILLE_MAA+MED_TAILLE_NOM+1];
00034 char nom_ent[MED_TAILLE_NOM_ENTITE+1];
00035 char nom_geo[MED_TAILLE_NOM_ENTITE+1];
00036 med_entite_maillage _type_ent=type_ent;
00037
00038 if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00039
00040
00041
00042
00043 _MEDmodeErreurVerrouiller();
00044 if (MEDcheckVersion(fid) < 0) return -1;
00045
00046
00047
00048
00049
00050 strcpy(chemin,MED_MAA);
00051 strcat(chemin,maa);
00052 if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00053 goto ERROR;
00054
00055
00056
00057
00058
00059 if ((ret = _MEDnomEntite(nom_ent,_type_ent)) < 0)
00060 goto ERROR;
00061
00062
00063
00064
00065 if ((entid = _MEDdatagroupOuvrir(maaid,nom_ent)) < 0)
00066 if ((entid = _MEDdatagroupCreer(maaid,nom_ent)) < 0)
00067 goto ERROR;
00068
00069
00070
00071
00072
00073 if ((_type_ent==MED_MAILLE)||(_type_ent==MED_FACE)||(_type_ent==MED_ARETE))
00074 {
00075 if ((ret = _MEDnomGeometrie(nom_geo,type_geo)) < 0)
00076 goto ERROR;
00077
00078 if ((geoid = _MEDdatagroupOuvrir(entid,nom_geo)) < 0)
00079 if ((geoid = _MEDdatagroupCreer(entid,nom_geo)) < 0)
00080 goto ERROR;
00081 }
00082 else
00083 geoid = -1;
00084
00085
00086
00087
00088 if (geoid == -1)
00089 root = entid;
00090 else
00091 root = geoid;
00092 dimd[0] = n;
00093 #if defined(HAVE_F77INT64)
00094 if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_GLB,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00095 (unsigned char*)num)) < 0)
00096 goto ERROR;
00097 #else
00098 if ((ret = _MEDdatasetNumEcrire(root,MED_NOM_GLB,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00099 (unsigned char*)num)) < 0)
00100 goto ERROR;
00101 #endif
00102
00103
00104
00105
00106 if ((dataset = _MEDdatasetOuvrir(root,MED_NOM_GLB)) < 0)
00107 goto ERROR;
00108 if ((ret = _MEDattrEntierEcrire(dataset,MED_NOM_NBR,&n)) < 0)
00109 goto ERROR;
00110
00111
00112
00113
00114
00115 ret = 0;
00116
00117 ERROR:
00118
00119 if (dataset>0) if (_MEDdatasetFermer(dataset) < 0) {
00120 MESSAGE("Impossible de fermer le datagroup : ");
00121 ISCRUTE_int(dataset); ret = -1;
00122 }
00123
00124 if (geoid>0) if (_MEDdatagroupFermer(geoid) < 0) {
00125 MESSAGE("Impossible de fermer le datagroup : ");
00126 ISCRUTE_int(geoid); ret = -1;
00127 }
00128
00129 if (entid>0) if (_MEDdatagroupFermer(entid) < 0) {
00130 MESSAGE("Impossible de fermer le datagroup : ");
00131 ISCRUTE_int(entid); ret = -1;
00132 }
00133
00134 if (maaid>0) if (_MEDdatagroupFermer(maaid) < 0) {
00135 MESSAGE("Impossible de fermer le datagroup : ");
00136 ISCRUTE_id(maaid); ret = -1;
00137 }
00138
00139 return ret;
00140 }
00141
00142
00143