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 <string.h>
00024 #include <stdlib.h>
00025
00026 extern int mode_interlace;
00027
00028 med_err
00029 MEDequivEcr(med_idt fid, char *maa, char *eq, med_int *corr, med_int n,
00030 med_entite_maillage type_ent, med_geometrie_element typ_geo)
00031 {
00032 med_idt eqid, datagroup;
00033 med_err ret;
00034 char chemin[MED_TAILLE_MAA+MED_TAILLE_EQS+2*MED_TAILLE_NOM+1];
00035 char nomdatagroup[MED_TAILLE_NOM+1];
00036 char tmp[MED_TAILLE_NOM_ENTITE+1];
00037 med_size dimd[1];
00038 med_mode_acces MED_MODE_ACCES;
00039 med_entite_maillage _type_ent=type_ent;
00040
00041 if ( type_ent == MED_NOEUD_MAILLE ) _type_ent=MED_NOEUD ;
00042
00043 if (typ_geo == MED_TETRA4 || typ_geo == MED_TETRA10 ||
00044 typ_geo == MED_HEXA8 || typ_geo == MED_HEXA20 ||
00045 typ_geo == MED_PENTA6 || typ_geo == MED_PENTA15 ||
00046 typ_geo == MED_PYRA5 || typ_geo == MED_PYRA13)
00047 return -1;
00048
00049
00050
00051
00052 _MEDmodeErreurVerrouiller();
00053 if (MEDcheckVersion(fid) < 0) return -1;
00054
00055
00056 if ( (MED_MODE_ACCES = _MEDmodeAcces(fid) ) == MED_UNDEF_MODE_ACCES ) {
00057 MESSAGE("Impossible de déterminer le mode d'acces au fichier ");
00058 return -1;
00059 }
00060
00061
00062
00063
00064 strcpy(chemin,MED_MAA);
00065 strcat(chemin,maa);
00066 strcat(chemin,MED_EQS);
00067 strcat(chemin,eq);
00068 if ((eqid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
00069 return -1;
00070
00071
00072
00073
00074 if ((ret = _MEDnomEntite(nomdatagroup,_type_ent)) < 0)
00075 return -1;
00076 if ((_type_ent != MED_NOEUD))
00077 {
00078 if ((ret = _MEDnomGeometrie(tmp,typ_geo)) < 0)
00079 return -1;
00080 strcat(nomdatagroup,".");
00081 strcat(nomdatagroup,tmp);
00082 }
00083 datagroup = 0;
00084 if (((datagroup = _MEDdatagroupOuvrir(eqid,nomdatagroup)) > 0) &&
00085 ( MED_MODE_ACCES == MED_LECTURE_AJOUT))
00086 return -1;
00087 else
00088 if (datagroup > 0)
00089 _MEDdatagroupFermer(datagroup);
00090
00091 if ((datagroup = _MEDdatagroupCreer(eqid,nomdatagroup)) < 0)
00092 return -1;
00093
00094 if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n)) < 0)
00095 return -1;
00096
00097 dimd[0] = 2*n;
00098
00099 #if defined(HAVE_F77INT64)
00100 if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT64,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00101 (unsigned char*) corr)) < 0)
00102 return -1;
00103 #else
00104 if ((ret = _MEDdatasetNumEcrire(datagroup,MED_NOM_COR,MED_INT32,MED_NO_INTERLACE,MED_DIM1,MED_ALL,MED_NOPF,MED_NO_PFLMOD,0,0,MED_NOPG,dimd,
00105 (unsigned char*) corr)) < 0)
00106 return -1;
00107 #endif
00108
00109
00110
00111
00112 if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00113 return -1;
00114 if ((ret = _MEDdatagroupFermer(eqid)) < 0)
00115 return -1;
00116
00117 return 0;
00118 }
00119
00120
00121