00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <med.h>
00026 #define MESGERR 1
00027 #include <med_utils.h>
00028 #include <string.h>
00029
00030 #ifdef DEF_LECT_ECR
00031 #define MODE_ACCES MED_ACC_RDWR
00032 #elif DEF_LECT_AJOUT
00033 #define MODE_ACCES MED_ACC_RDEXT
00034 #else
00035 #define MODE_ACCES MED_ACC_CREAT
00036 #endif
00037
00038 int main (int argc, char **argv)
00039
00040 {
00041 med_err ret=0;
00042 med_idt fid=0;
00043 char des[MED_COMMENT_SIZE+1]="";
00044 med_bool hdfok=MED_FALSE, medok=MED_FALSE;
00045 char axisname[3*MED_SNAME_SIZE+1]="";
00046 char axisunit[3*MED_SNAME_SIZE+1]="";
00047
00048 strcat(axisname,"x ");
00049 strcat(axisname,"y ");
00050 strcat(axisname,"z ");
00051 strcat(axisunit,"cm ");
00052 strcat(axisunit,"cm ");
00053 strcat(axisunit,"cm ");
00054
00055
00056 ret = MEDfileCompatibility("test1.med",&hdfok,&medok);
00057 if (!hdfok) {
00058 MESSAGE("Format HDF non conforme ou fichier inexistant");
00059 return -1;
00060 }
00061 if (!medok) {
00062 MESSAGE("Format MED non conforme ou fichier inexistant");
00063 return -1;
00064 }
00065
00066
00067 fid = MEDfileOpen("test1.med",MED_ACC_RDONLY);
00068 if (fid < 0) {
00069 MESSAGE("Erreur a l'ouverture du fichier test1.med en mode MED_LECTURE");
00070 return -1;
00071 }
00072
00073
00074 ret = MEDfileCommentRd(fid, des);
00075 if (ret == 0)
00076 printf("En-tete du fichier test1.med : %s\n",des);
00077 else {
00078 MESSAGE("Erreur a la lecture de l'en-tete du fichier test1.med");
00079 ret = -1;
00080 }
00081
00082
00083 ret = MEDfileClose(fid);
00084 if (ret < 0) {
00085 MESSAGE("Erreur a la fermeture du fichier test1.med");
00086 return -1;
00087 }
00088
00089
00090 fid = MEDfileOpen("test2.med",MODE_ACCES);
00091 if (fid < 0) {
00092 MESSAGE("Erreur a la creation du fichier test2.med");
00093 return -1;
00094 }
00095
00096
00097
00098 if (MEDmeshCr(fid,"maa1",3,3,MED_UNSTRUCTURED_MESH,
00099 "un premier maillage","s",MED_SORT_DTIT,
00100 MED_CARTESIAN,axisname,axisunit) < 0) {
00101 MESSAGE("Erreur a la creation du maillage maa1");
00102 ret = -1;
00103 }
00104
00105
00106 if (MEDmeshUniversalNameWr(fid,"maa1") < 0) {
00107 MESSAGE("Erreur a la creation du nom universel de maa1");
00108 ret = -1;
00109 }
00110
00111 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00112 MED_NO_DT,MED_NO_IT,0) < 0) {
00113 MESSAGE("Erreur a la creation du premier pas de temps du maillage maa1");
00114
00115 }
00116
00117 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00118 1,3,1.1) < 0) {
00119 MESSAGE("Erreur a la creation du second pas de temps du maillage maa1");
00120
00121 }
00122
00123 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00124 0,0,1.1) < 0) {
00125 MESSAGE("Erreur a la creation du second pas de temps du maillage maa1");
00126
00127 }
00128
00129 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00130 0,-1,1.1) < 0) {
00131 MESSAGE("Erreur a la creation du second pas de temps du maillage maa1");
00132
00133 }
00134
00135 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00136 -1,20,1.1) < 0) {
00137 MESSAGE("Erreur a la creation du second pas de temps du maillage maa1");
00138
00139 }
00140
00141 if ( MEDmeshComputationStepCr(fid,"maa1",MED_NO_DT,MED_NO_IT,
00142 20,-1,1.1) < 0) {
00143 MESSAGE("Erreur a la creation du second pas de temps du maillage maa1");
00144
00145 }
00146
00147
00148
00149
00150 if (MEDmeshCr(fid,"maa2",3,2,MED_UNSTRUCTURED_MESH,
00151 "un second maillage","s",MED_SORT_DTIT,
00152 MED_CARTESIAN,axisname,axisunit) < 0) {
00153 MESSAGE("Erreur a la creation du maillage maa2");
00154 ret = -1;
00155 }
00156
00157
00158
00159 if (MEDmeshCr(fid,"maa3",3,1,MED_UNSTRUCTURED_MESH,
00160 "un troisieme maillage","s",MED_SORT_DTIT,
00161 MED_CARTESIAN,axisname,axisunit) < 0) {
00162 MESSAGE("Erreur a la creation du maillage maa3");
00163 ret = -1;
00164 }
00165
00166
00167 if ( MEDfileClose(fid) < 0) {
00168 MESSAGE("Erreur a la fermeture du fichier");
00169 return -1;
00170 }
00171
00172 return ret;
00173 }
00174
00175
00176
00177