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 MEDjointEcr (med_idt fid, char *maa, char *jn, med_int *corrtab, med_int n,
00030 med_entite_maillage type_ent_local, med_geometrie_element typ_geo_local,
00031 med_entite_maillage type_ent_distant, med_geometrie_element typ_geo_distant)
00032
00033 {
00034 med_entite_maillage _type_ent_local = (med_entite_maillage) ( (int)(type_ent_local) % 10 );
00035 med_entite_maillage _type_ent_distant = (med_entite_maillage) ( (int)(type_ent_distant) % 10 );
00036
00037 med_idt corrid, datagroup;
00038 med_err ret;
00039 char chemin[MED_TAILLE_MAA+MED_TAILLE_JNT+2*MED_TAILLE_NOM+1];
00040 char nomdatagroup[MED_TAILLE_NOM+1+MED_TAILLE_NOM+1];
00041 char tmp[MED_TAILLE_NOM_ENTITE+1];
00042 med_size dimd[1];
00043 med_mode_acces MED_MODE_ACCES;
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 _MEDmodeErreurVerrouiller();
00059 if (MEDcheckVersion(fid) < 0) return -1;
00060
00061
00062 if ( (MED_MODE_ACCES = _MEDmodeAcces(fid) ) == MED_UNDEF_MODE_ACCES ) {
00063 MESSAGE("Impossible de déterminer le mode d'acces au fichier ");
00064 return -1;
00065 }
00066
00067
00068
00069
00070 strcpy(chemin,MED_MAA);
00071 strcat(chemin,maa);
00072 strcat(chemin,MED_JNT);
00073 strcat(chemin,jn);
00074 if ((corrid = _MEDdatagroupOuvrir(fid,chemin)) < 0) {
00075 MESSAGE(chemin);
00076 return -1;
00077 }
00078
00079
00080
00081
00082
00083 if ((ret = _MEDnomEntite(nomdatagroup,_type_ent_local)) < 0)
00084 return -1;
00085 if ((_type_ent_local != MED_NOEUD))
00086 {
00087 if ((ret = _MEDnomGeometrie(tmp,typ_geo_local)) < 0)
00088 return -1;
00089 strcat(nomdatagroup,".");
00090 strcat(nomdatagroup,tmp);
00091 }
00092
00093
00094
00095 if ((ret = _MEDnomEntite(tmp,_type_ent_distant)) < 0)
00096 return -1;
00097 strcat(nomdatagroup,".");
00098 strcat(nomdatagroup,tmp);
00099 if ((_type_ent_distant != MED_NOEUD))
00100 {
00101 if ((ret = _MEDnomGeometrie(tmp,typ_geo_distant)) < 0)
00102 return -1;
00103 strcat(nomdatagroup,".");
00104 strcat(nomdatagroup,tmp);
00105 }
00106
00107 datagroup = 0;
00108
00109
00110
00111
00112
00113
00114
00115 if (((datagroup = _MEDdatagroupOuvrir(corrid,nomdatagroup)) > 0) &&
00116 ( MED_MODE_ACCES == MED_LECTURE_AJOUT))
00117 return -1;
00118 else
00119 if (datagroup > 0)
00120 _MEDdatagroupFermer(datagroup);
00121
00122 if ((datagroup = _MEDdatagroupCreer(corrid,nomdatagroup)) < 0)
00123 return -1;
00124
00125
00126
00127
00128
00129 if ((ret = _MEDattrEntierEcrire(datagroup,MED_NOM_NBR,&n)) < 0)
00130 return -1;
00131
00132
00133 dimd[0] = 2*n;
00134
00135 #if defined(HAVE_F77INT64)
00136 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,
00137 (unsigned char*) corrtab)) < 0)
00138 return -1;
00139 #else
00140 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,
00141 (unsigned char*) corrtab)) < 0)
00142 return -1;
00143 #endif
00144
00145
00146
00147
00148 if ((ret = _MEDdatagroupFermer(datagroup)) < 0)
00149 return -1;
00150 if ((ret = _MEDdatagroupFermer(corrid)) < 0)
00151 return -1;
00152
00153 return 0;
00154 }
00155
00156
00157