UsesCase_MEDinterp_3.c
Aller à la documentation de ce fichier.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #include <med.h>
00025 #define MESGERR 1
00026 #include <med_utils.h>
00027 
00028 #include <string.h>
00029 
00030 int main (int argc, char **argv) {
00031   med_idt fid;
00032   char              interpname[MED_NAME_SIZE+1]="";
00033   med_int           ninterp                    =0;
00034   int               it                         =0;
00035   med_geometry_type geotype                    =MED_NONE;
00036   med_bool          cellnodes                  =MED_FALSE;
00037   med_int           nbasisfunc              =0;
00038   med_int           nvariable               =0;
00039   med_int           maxdegree                  =0;
00040   med_int           nmaxcoefficient            =0;
00041   int               basisfuncit                =0;
00042   int               powerit                    =0;
00043   med_int           ncoefficient            =0;
00044   med_int*          power                      =NULL;
00045   med_float*        coefficient                =NULL;
00046   int               coefficientit              =0;
00047   int ret=-1;
00048 
00049 
00050   
00051   fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY);
00052   if (fid < 0) {
00053     MESSAGE("ERROR : file creation ...");
00054     goto ERROR;
00055   }
00056  
00057   
00058   if ((ninterp = MEDnInterp(fid)) < 0) {
00059     MESSAGE("ERROR : read number of interpolation ...");
00060     goto ERROR;
00061   }
00062 
00063   
00064   
00065   for (it=1; it<= ninterp; it++) {
00066 
00067     if (MEDinterpInfo(fid,it,interpname,&geotype,&cellnodes,&nbasisfunc,
00068                       &nvariable,&maxdegree,&nmaxcoefficient) < 0) {
00069       MESSAGE("ERROR : interpolation function information ...");
00070       goto ERROR;
00071     }
00072 
00073     
00074     for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) {
00075       if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) {
00076         MESSAGE("ERROR : read number of coefficient in the base function ...");
00077         goto ERROR;
00078       }
00079       
00080       coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient);
00081       power       = (med_int*)   calloc(sizeof(med_int),nvariable*ncoefficient);
00082       
00083       if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) {
00084         MESSAGE("ERROR : read base function ...");
00085         free(coefficient); free(power);
00086         goto ERROR;
00087       }
00088 
00089       free(coefficient);
00090       free(power);
00091     }
00092 
00093   }
00094 
00095   ret=0;
00096  ERROR:
00097   
00098   
00099   if (MEDfileClose(fid) < 0) {
00100     MESSAGE("ERROR : close file ...");             
00101     ret=-1; 
00102   } 
00103   
00104   return ret;
00105 }