usecases/c/UsesCase_MEDinterp_3.c
#include <med.h>
#define MESGERR 1
#include <med_utils.h>
#include <string.h>
int main (int argc, char **argv) {
  med_idt fid;
  char              interpname[MED_NAME_SIZE+1]="";
  med_int           ninterp                    =0;
  int               it                         =0;
  med_geometry_type geotype                    =MED_NONE;
  med_bool          cellnodes                  =MED_FALSE;
  med_int           nbasisfunc              =0;
  med_int           nvariable               =0;
  med_int           maxdegree                  =0;
  med_int           nmaxcoefficient            =0;
  int               basisfuncit                =0;
  int               powerit                    =0;
  med_int           ncoefficient            =0;
  med_int*          power                      =NULL;
  med_float*        coefficient                =NULL;
  int               coefficientit              =0;
  int ret=-1;
  
  fid = MEDfileOpen("UsesCase_MEDinterp_1.med",MED_ACC_RDONLY);
  if (fid < 0) {
    MESSAGE("ERROR : file creation ...");
    goto ERROR;
  }
 
  
  if ((ninterp = MEDnInterp(fid)) < 0) {
    MESSAGE("ERROR : read number of interpolation ...");
    goto ERROR;
  }
  
  
  for (it=1; it<= ninterp; it++) {
    if (MEDinterpInfo(fid,it,interpname,&geotype,&cellnodes,&nbasisfunc,
                      &nvariable,&maxdegree,&nmaxcoefficient) < 0) {
      MESSAGE("ERROR : interpolation function information ...");
      goto ERROR;
    }
    
    for ( basisfuncit=1; basisfuncit<= nbasisfunc; ++basisfuncit) {
      if ((ncoefficient = MEDinterpBaseFunctionCoefSize(fid,interpname,basisfuncit) ) <0 ) {
        MESSAGE("ERROR : read number of coefficient in the base function ...");
        goto ERROR;
      }
      
      coefficient = (med_float*) calloc(sizeof(med_float),ncoefficient);
      power       = (med_int*)   calloc(sizeof(med_int),nvariable*ncoefficient);
      
      if (MEDinterpBaseFunctionRd(fid,interpname,basisfuncit,&ncoefficient,power,coefficient) < 0) {
        MESSAGE("ERROR : read base function ...");
        free(coefficient); free(power);
        goto ERROR;
      }
      free(coefficient);
      free(power);
    }
  }
  ret=0;
 ERROR:
  
  
  if (MEDfileClose(fid) < 0) {
    MESSAGE("ERROR : close file ...");             
    ret=-1; 
  } 
  
  return ret;
}