Salome HOME
DCQ : Merge with Ecole Ete a6.
[modules/med.git] / src / MEDMEM / INTERPOLATION / create_mesh_interpolation.c
1 #include <med.h>
2 #include <string.h>
3
4 /*****************************************************************************************************/
5
6 void affiche_noeuds(med_float * nodes,int nnpl)
7 {
8   int nbr_nodes=nnpl*nnpl*nnpl;
9   int i;
10
11   for (i=0;i<nbr_nodes;i++)
12     printf("Noeud %d : ( %4.5f ; %4.5f ; %4.5f )\n",i,nodes[3*i],nodes[3*i+1],
13            nodes[3*i+2]);
14 }
15
16 void cree_nodes(med_float * coord_nodes,int nnpl, int flag)
17 {
18   int i,j,k;
19   int nbr_nodes=nnpl*nnpl*nnpl;
20   int num_noeud;
21   int diviseur=nnpl-1+flag;
22         
23   /*coord_nodes=(med_float *) malloc(3*nbr_nodes*sizeof(med_float));*/
24         
25   for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++) 
26     {
27       num_noeud=i+nnpl*j+nnpl*nnpl*k;
28
29       if (3*num_noeud  >=3*nbr_nodes)
30         {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
31       if (3*num_noeud+1>=3*nbr_nodes)
32         {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
33       if (3*num_noeud+2>=3*nbr_nodes)
34         {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);}
35
36       coord_nodes[3*num_noeud  ]= (double) (i+flag)/diviseur;
37       coord_nodes[3*num_noeud+1]= (double) (j+flag)/diviseur;
38       coord_nodes[3*num_noeud+2]= (double) (k+flag)/diviseur;
39     }
40                 
41   affiche_noeuds(coord_nodes,nnpl);
42   
43 }
44
45 void cree_num_nodes(med_int * num_nodes,int nnpl)
46 {
47   int nbr_nodes=nnpl*nnpl*nnpl;
48   int i;
49   /*num_nodes=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
50   for (i=0;i<nbr_nodes;i++) num_nodes[i]=i+1;//nbr_nodes+i;
51 }
52
53 void cree_Hexa8(med_int * conn_hexa8, int nnpl,med_int * num_nodes)
54 {
55   int i,j,k;
56   int i0,j0,k0,i1,j1,k1;
57   int nbr_nodes=nnpl*nnpl*nnpl;
58   int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
59   int num_hexa8;
60         
61   /*conn_hexa8=(med_int *) malloc(8*nbr_hexa8*sizeof(med_int));*/
62         
63   for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++) 
64     {
65       i0=i;j0=j;k0=k;
66       i1=i+1;j1=j+1;k1=k+1;
67                 
68       num_hexa8=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
69                 
70       if (8*num_hexa8  >=8*nbr_hexa8)
71         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
72       if (8*num_hexa8+1>=8*nbr_hexa8)
73         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
74       if (8*num_hexa8+2>=8*nbr_hexa8)
75         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
76       if (8*num_hexa8+3>=8*nbr_hexa8)
77         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
78       if (8*num_hexa8+4>=8*nbr_hexa8)
79         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
80       if (8*num_hexa8+5>=8*nbr_hexa8)
81         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
82       if (8*num_hexa8+6>=8*nbr_hexa8)
83         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
84       if (8*num_hexa8+7>=8*nbr_hexa8)
85         {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);}
86                 
87       conn_hexa8[8*num_hexa8  ] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k1 ]; 
88       conn_hexa8[8*num_hexa8+1] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k1 ]; 
89       conn_hexa8[8*num_hexa8+2] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k1 ]; 
90       conn_hexa8[8*num_hexa8+3] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k1 ]; 
91       conn_hexa8[8*num_hexa8+4] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k0 ]; 
92       conn_hexa8[8*num_hexa8+5] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k0 ]; 
93       conn_hexa8[8*num_hexa8+6] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k0 ]; 
94       conn_hexa8[8*num_hexa8+7] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k0 ]; 
95                 
96                 
97     }
98                 
99   for (num_hexa8=0;num_hexa8<nbr_hexa8;num_hexa8++)
100     {           
101       printf("Maille numéro %4d :",num_hexa8);          
102       printf("%4d ",conn_hexa8[8*num_hexa8  ]);
103       printf("%4d ",conn_hexa8[8*num_hexa8+1]);
104       printf("%4d ",conn_hexa8[8*num_hexa8+2]);
105       printf("%4d ",conn_hexa8[8*num_hexa8+3]);
106       printf("%4d ",conn_hexa8[8*num_hexa8+4]);
107       printf("%4d ",conn_hexa8[8*num_hexa8+5]);
108       printf("%4d ",conn_hexa8[8*num_hexa8+6]);
109       printf("%4d ",conn_hexa8[8*num_hexa8+7]);
110       printf("\n");
111     }
112 }       
113
114 void cree_noms_mailles(char * noms, int nnpl)
115 {
116   int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);     
117   int i;
118   char pnom[MED_TAILLE_PNOM+1]="hexa            ";
119         
120   /*noms=(char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char));*/
121         
122   for (i=0;i<nbr_hexa8;i++) strncpy(&noms[i*MED_TAILLE_PNOM],pnom,MED_TAILLE_PNOM);
123         
124   noms[nbr_hexa8*MED_TAILLE_PNOM]='\n';
125 }
126
127 void cree_num_mailles(med_int * num_mailles,int nnpl)
128 {
129   int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);     
130   int i;
131   
132   /*num_mailles=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
133   
134   for (i=0;i<nbr_hexa8;i++) num_mailles[i]=i+1;
135 }
136
137 void cree_fam_nodes(med_int * fam,int nnpl)
138 {
139   int nbr_nodes=nnpl*nnpl*nnpl;
140   int i;
141   
142   /*fam=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/
143   
144   for (i=0;i<nbr_nodes;i++) fam[i]=0;
145 }
146
147 void cree_fam_mailles(med_int * fam,int nnpl)
148 {
149   int nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);     
150   int i;
151   
152   /*fam=(med_int *) malloc(nbr_hexa8*sizeof(med_int));*/
153   
154   for (i=0;i<nbr_hexa8;i++) fam[i]=0;
155 }
156
157 void cree_valeurs_champ_node(med_float * val,int nnpl)
158 {
159   int i,j,k;
160   int nbr_nodes=nnpl*nnpl*nnpl;
161   int num_noeud;
162   int diviseur=3*(nnpl-1);
163   
164   /*val=(med_float *) malloc(nbr_nodes*sizeof(med_float));*/
165         
166   for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++) 
167     {
168       num_noeud=i+nnpl*j+nnpl*nnpl*k;
169       val[num_noeud] = (med_float) (i+j+k)/diviseur;
170     }
171   for (num_noeud=0;num_noeud<nbr_nodes;num_noeud++)
172     printf("Valeur Scalaire noeud %5d : %4.5f\n",num_noeud,val[num_noeud]);
173 }
174
175 void cree_valeurs_champ_vector_node(med_float * val,int nnpl)
176 {
177   int i,j,k;
178   int nbr_nodes=nnpl*nnpl*nnpl;
179   int num_noeud;
180         
181   /*val=(med_float *) malloc(nbr_nodes*sizeof(med_float));*/
182         
183   for (i=0;i<nnpl;i++) for (j=0;j<nnpl;j++) for (k=0;k<nnpl;k++) 
184     {
185       num_noeud=i+nnpl*j+nnpl*nnpl*k;
186       val[3*num_noeud  ] = (med_float) 0;
187       val[3*num_noeud+1] = (med_float) 1;
188       val[3*num_noeud+2] = (med_float) 2;
189     }
190   for (num_noeud=0;num_noeud<nbr_nodes;num_noeud++)
191     printf("Valeur Vectorielle noeud %5d : %4.5f %4.5f %4.5f \n ",num_noeud,
192            val[3*num_noeud],val[3*num_noeud+1],val[3*num_noeud+2]);
193 }
194
195 void cree_valeurs_champ_cell(med_float * val,int nnpl)
196 {
197   int i,j,k;
198   int nbr_cells=(nnpl-1)*(nnpl-1)*(nnpl-1);     
199   int num_cell;
200         
201   med_float diviseur=3*(nnpl-2);
202         
203   /*val=(med_float *) malloc(3*nbr_cells*sizeof(med_float));*/
204         
205   for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++) 
206     {
207       num_cell=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
208       val[num_cell  ] =  (med_float) (i+j+k)/diviseur;
209     }
210   for (num_cell=0;num_cell<nbr_cells;num_cell++)
211     printf("Valeur scalaire maille %5d : %4.5f\n ",num_cell,val[num_cell]);
212 }       
213
214 void cree_valeurs_champ_vector_cell(med_float * val,int nnpl)
215 {
216   int i,j,k;
217   int nbr_cells=(nnpl-1)*(nnpl-1)*(nnpl-1);     
218   int num_cell;
219   
220   /*val=(med_float *) malloc(3*nbr_cells*sizeof(med_float));*/
221   
222   for (i=0;i<nnpl-1;i++) for (j=0;j<nnpl-1;j++) for (k=0;k<nnpl-1;k++) 
223     {
224       num_cell=i+(nnpl-1)*j+(nnpl-1)*(nnpl-1)*k;
225       val[3*num_cell  ] = (med_float) 0;
226       val[3*num_cell+1] = (med_float) 1;
227       val[3*num_cell+2] = (med_float) 2;           
228     }
229   for (num_cell=0;num_cell<nbr_cells;num_cell++)
230     printf("Valeur Vectorielle maille %5d : %4.5f %4.5f %4.5f \n ",num_cell,
231            val[3*num_cell],val[3*num_cell+1],val[3*num_cell+2]);
232 }
233
234         
235 /*****************************************************************************************************/
236         
237 int main (int argc, char **argv)
238 {
239                 
240   int i,j,k;
241   
242   int nnpl;
243   
244   int nbr_nodes, nbr_hexa8;
245   
246   med_err ret;
247   med_idt fromfid;
248   med_idt tofid;
249   char frommaa[MED_TAILLE_NOM+1] = "fromMesh";
250   char frommaadesc[MED_TAILLE_DESC+1] = "First 3D non-structured mesh example for the Interpolation module in Med Memory";
251   char tomaa[MED_TAILLE_NOM+1]   = "toMesh";
252   char tomaadesc[MED_TAILLE_DESC+1] = "Second 3D non-structured mesh example for the Interpolation module in Med Memory";
253   const med_int mdim = 3;
254   med_int fromnnoe;
255   med_int   tonnoe;
256   
257   med_float * tocoo;                   
258   med_float * fromcoo;                 
259   
260   char nomcoo[3*MED_TAILLE_PNOM+1] = "x             y               z               ";
261   char unicoo[3*MED_TAILLE_PNOM+1] = "cm              cm              cm              ";
262   
263   char * nomnoe = NULL ;
264   
265   med_int  * fromnumnoe;              
266   med_int  * fromnufano;              
267   
268   med_int  * tonumnoe;                
269   med_int  * tonufano;                
270   
271   med_int fromnhexa8;
272   med_int  * fromhexa8;                                          
273   
274   med_int tonhexa8;
275   med_int  * tohexa8;                                          
276   
277   
278   char  * fromnomhexa8;             
279   med_int * fromnumhexa8;                                              
280   med_int * fromnufahexa8;                                             
281   
282   char  * tonomhexa8;             
283   med_int * tonumhexa8;                                              
284   med_int * tonufahexa8;                                             
285   
286   /*****************************************************************************************************/
287
288   char nomfam[MED_TAILLE_NOM+1];
289   med_int numfam;
290   char attdes[MED_TAILLE_DESC+1];
291   med_int natt;
292   med_int attide;
293   med_int attval;
294   med_int ngro;
295   char gro[MED_TAILLE_LNOM+1];
296   char gro2[MED_TAILLE_LNOM*2+1];
297   char gro3[MED_TAILLE_LNOM*3+1];
298   int nfame = 1; 
299   int nfamn = 1;
300   
301   /*****************************************************************************************************/
302
303   /* Some fields : one on nodes : double , one on cells : double */
304
305   char champnode[MED_TAILLE_NOM+1]="fieldnodedouble" ;
306   char champnode_comp[MED_TAILLE_PNOM+1]="X+Y+Z           " ;
307   char champnode_unit[MED_TAILLE_PNOM+1]="X+Y+Z           " ;
308   med_float   * fieldnodedouble;
309
310   char champnodevector[MED_TAILLE_NOM+1]="fieldnodedoublevector" ;
311   char champnodevector_comp[MED_TAILLE_PNOM*3+1]="0             1               2               " ;
312   char champnodevector_unit[MED_TAILLE_PNOM*3+1]="O             1               2               " ;
313   med_float   * fieldnodedoublevector;
314
315   char champcellscalar[MED_TAILLE_NOM+1]="fieldcelldouble" ;
316   char champcellscalar_comp[MED_TAILLE_PNOM+1]="X+Y+Z           " ;
317   char champcellscalar_unit[MED_TAILLE_PNOM+1]="X+Y+Z           " ;
318   med_float   * fieldcelldouble;
319
320   char champcell[MED_TAILLE_NOM+1]="fieldcelldoublevector" ;
321   char champcell_comp[MED_TAILLE_PNOM*3+1]="0               1               2               " ;
322   char champcell_unit[MED_TAILLE_PNOM*3+1]="0               1               2               " ;
323   med_float   * fieldcelldoublevector;
324
325   /*****************************************************************************************************/
326
327   if (argc!=2) 
328     {
329       printf("Il manque un paramètre : le nombre de point par ligne\n");
330       exit(-1);
331     }
332   
333   sscanf(argv[1],"%d",&nnpl);
334         
335   printf("VERSION 2.0\n");
336   printf("Traitement avec %d noeuds par ligne\n",nnpl);
337
338   fromnnoe   = nnpl*nnpl*nnpl             ;
339   fromnhexa8 = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
340   tonnoe     = (nnpl-1)*(nnpl-1)*(nnpl-1) ;
341   tonhexa8   = (nnpl-2)*(nnpl-2)*(nnpl-2) ;
342   
343   nbr_nodes=nnpl*nnpl*nnpl;
344   nbr_hexa8=(nnpl-1)*(nnpl-1)*(nnpl-1);
345
346   fromcoo       = (med_float *) malloc(3*nbr_nodes*sizeof(med_float));
347   cree_nodes        ( fromcoo       , nnpl, 0 );
348
349   fromnumnoe    = (med_int *) malloc(nbr_nodes*sizeof(med_int));
350   cree_num_nodes    ( fromnumnoe    , nnpl );
351
352   fromnufano    = (med_int *) malloc(nbr_nodes*sizeof(med_int));
353   cree_fam_nodes    ( fromnufano    , nnpl );
354
355   fromhexa8     = (med_int *) malloc(8*nbr_hexa8*sizeof(med_int));
356   cree_Hexa8        ( fromhexa8     , nnpl ,fromnumnoe);
357
358   fromnomhexa8  = (char *)  malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char));
359   cree_noms_mailles ( fromnomhexa8  , nnpl );
360
361   fromnumhexa8  = (med_int *)   malloc(nbr_hexa8*sizeof(med_int));
362   cree_num_mailles  ( fromnumhexa8  , nnpl );
363
364   fromnufahexa8 = (med_int *)   malloc(nbr_hexa8*sizeof(med_int));
365   cree_fam_mailles  ( fromnufahexa8 , nnpl );
366
367   fieldnodedouble       = (med_float *) malloc(nbr_nodes*sizeof(med_float));
368   cree_valeurs_champ_node          ( fieldnodedouble       , nnpl );
369
370   fieldnodedoublevector = (med_float *) malloc(3*nbr_nodes*sizeof(med_float));
371   cree_valeurs_champ_vector_node ( fieldnodedoublevector , nnpl );
372
373   fieldcelldouble       = (med_float *) malloc(nbr_hexa8*sizeof(med_float));
374   cree_valeurs_champ_cell          ( fieldcelldouble       , nnpl );
375
376   fieldcelldoublevector = (med_float *) malloc(3*nbr_hexa8*sizeof(med_float));
377   cree_valeurs_champ_vector_cell ( fieldcelldoublevector , nnpl );
378         
379   nbr_nodes=(nnpl-1)*(nnpl-1)*(nnpl-1);
380   nbr_hexa8=(nnpl-2)*(nnpl-2)*(nnpl-2);
381
382   tocoo       = (med_float *) malloc(3*nbr_nodes*sizeof(med_float));
383   cree_nodes      ( tocoo       , nnpl-1, 1 );
384
385   tonumnoe    = (med_int *)   malloc(nbr_nodes*sizeof(med_int));
386   cree_num_nodes    ( tonumnoe    , nnpl-1 );
387
388   tonufano    = (med_int *)   malloc(nbr_nodes*sizeof(med_int));
389   cree_fam_nodes    ( tonufano    , nnpl-1 );
390
391   tohexa8     = (med_int *)   malloc(8*nbr_hexa8*sizeof(med_int));
392   cree_Hexa8      ( tohexa8     , nnpl-1 ,tonumnoe);
393
394   tonomhexa8 = (char *) malloc((nbr_hexa8*MED_TAILLE_PNOM+1)*sizeof(char));
395   cree_noms_mailles ( tonomhexa8  , nnpl-1 );
396
397   tonumhexa8  = (med_int *)   malloc(nbr_hexa8*sizeof(med_int));
398   cree_num_mailles  ( tonumhexa8  , nnpl-1 );
399
400   tonufahexa8 = (med_int *)   malloc(nbr_hexa8*sizeof(med_int));
401   cree_fam_mailles  ( tonufahexa8 , nnpl-1 );
402
403         
404   /*****************************************************************************************************/
405   fromfid = MEDouvrir("fromMesh.med",MED_LECTURE_ECRITURE);
406
407   if (fromfid < 0)
408     ret = -1;
409   else
410     ret = 0;
411
412   printf("MEDouvrir : %d\n",ret);
413   /*****************************************************************************************************/
414   tofid = MEDouvrir("toMesh.med",MED_LECTURE_ECRITURE);
415
416   if (tofid < 0)
417     ret = -1;
418   else
419     ret = 0;
420
421   printf("MEDouvrir : %d\n",ret);
422   /*****************************************************************************************************/
423   if (ret == 0)
424     ret = MEDmaaCr(fromfid,frommaa,mdim,MED_NON_STRUCTURE,frommaadesc);
425
426   printf("MEDmaaCr : %d\n",ret);
427   /*****************************************************************************************************/
428   if (ret == 0)
429     ret = MEDmaaCr(tofid,tomaa,mdim,MED_NON_STRUCTURE,tomaadesc);
430
431   printf("MEDmaaCr : %d\n",ret);
432   /*****************************************************************************************************/
433   if (ret == 0)
434     ret = MEDnoeudsEcr(fromfid,frommaa,mdim,fromcoo,MED_FULL_INTERLACE,
435                        MED_CART,nomcoo,unicoo,nomnoe,MED_FAUX,fromnumnoe,
436                        MED_FAUX,fromnufano,fromnnoe);
437
438   printf("MEDnoeudsEcr : %d\n",ret);
439   /*****************************************************************************************************/
440   if (ret == 0)
441     ret = MEDnoeudsEcr(tofid,tomaa,mdim,tocoo,MED_FULL_INTERLACE,MED_CART,
442                        nomcoo,unicoo,nomnoe,MED_FAUX,tonumnoe,MED_FAUX,
443                        tonufano,tonnoe);
444
445   printf("MEDnoeudsEcr : %d\n",ret);  
446
447   /*****************************************************************************************************/
448   /* ecriture des mailles MED_HEXA8 :
449      - connectivite
450      - noms (optionnel) 
451      - numeros (optionnel)
452      - numeros des familles */
453
454   if (ret == 0) 
455     ret = MEDelementsEcr(fromfid,frommaa,mdim,fromhexa8,MED_FULL_INTERLACE,
456                          fromnomhexa8,MED_FAUX,fromnumhexa8,MED_VRAI,
457                          fromnufahexa8,fromnhexa8,MED_MAILLE,
458                          MED_HEXA8,MED_NOD);
459
460   printf("MEDelementsEcr : %d \n",ret);
461   /*****************************************************************************************************/
462 /* ecriture des mailles MED_HEXA8 :
463    - connectivite
464    - noms (optionnel) 
465    - numeros (optionnel)
466    - numeros des familles */
467
468   if (ret == 0) 
469     ret = MEDelementsEcr(tofid,tomaa,mdim,tohexa8,MED_FULL_INTERLACE,
470                          tonomhexa8,MED_FAUX,tonumhexa8,MED_VRAI,tonufahexa8,
471                          tonhexa8,MED_MAILLE,MED_HEXA8,MED_NOD);
472
473   printf("MEDelementsEcr : %d \n",ret);
474   /*****************************************************************************************************/
475   /* ecriture des familles */
476   /* Conventions :
477      - toujours creer une famille de numero 0 ne comportant aucun attribut
478      ni groupe (famille de reference pour les noeuds ou les elements
479      qui ne sont rattaches a aucun groupe ni attribut)
480      - les numeros de familles de noeuds sont > 0
481      - les numeros de familles des elements sont < 0
482    - rien d'imposer sur les noms de familles
483   */ 
484
485   /* la famille 0 */
486
487   if (ret == 0)
488     {
489       strcpy(nomfam,"FAMILLE_0");
490       numfam = 0;
491       ret = MEDfamCr(fromfid,frommaa,nomfam,numfam,&attide,&attval,attdes,0,
492                      gro,0);
493     }
494
495   printf("MEDfamCr : %d \n",ret);
496   /*****************************************************************************************************/
497   if (ret == 0)
498     {
499       strcpy(nomfam,"FAMILLE_0");
500       numfam = 0;
501       ret = MEDfamCr(tofid,tomaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0);
502     }
503
504   printf("MEDfamCr : %d \n",ret);
505   /*****************************************************************************************************/
506   /* Les champs */
507
508   if (ret == 0)
509     {
510       ret = MEDchampCr(fromfid,champnode,MED_FLOAT64,champnode_comp,
511                        champnode_unit,1); 
512
513       printf("MEDchampCr : %d \n",ret); 
514
515       if (ret == 0) 
516         {
517           ret = MEDchampEcr(fromfid, frommaa, champnode,
518                             (unsigned char *)fieldnodedouble,
519                             MED_FULL_INTERLACE, fromnnoe, MED_NOGAUSS,
520                             MED_ALL, MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 0,
521                             MED_NOPDT,"        ", 0. , MED_NONOR);
522
523           printf("MEDchampEcr : %d \n",ret);
524         }
525     }
526
527   if (ret == 0)
528     {
529       ret = MEDchampCr(fromfid,champcell,MED_FLOAT64,champcell_comp,
530                        champcell_unit,3);
531
532       printf("MEDchampCr : %d \n",ret);
533
534       if (ret == 0) 
535         {
536           ret = MEDchampEcr(fromfid, frommaa, champcell,
537                             (unsigned char *)fieldcelldoublevector,
538                             MED_FULL_INTERLACE, fromnhexa8, MED_NOGAUSS,
539                             MED_ALL, MED_NOPFL, MED_NO_PFLMOD, MED_MAILLE,
540                             MED_HEXA8, MED_NOPDT,"        ", 0., MED_NONOR);
541
542           printf("MEDchampEcr : %d \n",ret);
543         }
544     }
545   
546   if (ret == 0)
547     {
548       ret = MEDchampCr(fromfid,champcellscalar,MED_FLOAT64,
549                        champcellscalar_comp,champcellscalar_unit,1); 
550
551       printf("MEDchampCr : %d \n",ret); 
552
553       if (ret == 0) 
554         {
555           ret = MEDchampEcr(fromfid, frommaa, champcellscalar,
556                             (unsigned char *)fieldcelldouble,
557                             MED_FULL_INTERLACE, fromnhexa8, MED_NOGAUSS,
558                             MED_ALL, MED_NOPFL, MED_NO_PFLMOD, MED_MAILLE, 
559                             MED_HEXA8, MED_NOPDT,"        ", 0., MED_NONOR);
560
561           printf("MEDchampEcr : %d \n",ret);
562         }
563     }
564   
565   if (ret == 0)
566     {
567       ret = MEDchampCr(fromfid,champnodevector,MED_FLOAT64,
568                        champnodevector_comp,champnodevector_unit,3);
569       printf("MEDchampCr : %d \n",ret);
570
571       if (ret == 0) 
572         {
573           ret = MEDchampEcr(fromfid, frommaa, champnodevector,
574                             (unsigned char *)fieldnodedoublevector,
575                             MED_FULL_INTERLACE, fromnnoe, MED_NOGAUSS,
576                             MED_ALL, MED_NOPFL, MED_NO_PFLMOD, MED_NOEUD, 
577                             0, MED_NOPDT,"        ", 0. , MED_NONOR);
578
579           printf("MEDchampEcr : %d \n",ret);
580         }
581     }
582   
583   
584   /***************************************************************************/
585   ret = MEDfermer(fromfid);
586
587   printf("MEDfermer : %d\n",ret);
588   /***************************************************************************/
589   ret = MEDfermer(tofid);
590
591   printf("MEDfermer : %d\n",ret);
592
593   return 0;
594 }
595