# Test_MEDfieldInterpInfo.c

Aller à la documentation de ce fichier.

    00001 /*  This file is part of MED.
    00002  *
    00003  *  COPYRIGHT (C) 1999 - 2011  EDF R&D, CEA/DEN
    00004  *  MED is free software: you can redistribute it and/or modify
    00005  *  it under the terms of the GNU Lesser General Public License as published by
    00006  *  the Free Software Foundation, either version 3 of the License, or
    00007  *  (at your option) any later version.
    00008  *
    00009  *  MED is distributed in the hope that it will be useful,
    00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *  GNU Lesser General Public License for more details.
    00013  *
    00014  *  You should have received a copy of the GNU Lesser General Public License
    00015  *  along with MED.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018 #include <med.h>
    00019 #define MESGERR 1
    00020 #include <med_utils.h>
    00021 #include <string.h>
    00022
    00023 #ifdef DEF_LECT_ECR
    00024 #define MODE_ACCES MED_ACC_RDWR
    00025 #elif DEF_LECT_AJOUT
    00026 #define MODE_ACCES MED_ACC_RDEXT
    00027 #else
    00028 #define MODE_ACCES MED_ACC_CREAT
    00029 #endif
    00030
    00031 int main (int argc, char **argv)
    00032
    00033 {
    00034   med_err           _ret=0;
    00035   med_idt           _fid=0;
    00036
    00037   char    _fieldname1[MED_NAME_SIZE+1]  = "champ reel";
    00038   char    _interpname[MED_NAME_SIZE+1]  = "";
    00039   med_int _ninterp  = 0;
    00040   int     _interpit=0;
    00041
    00042
    00043   /* Ouverture en mode creation du fichier "current.med" */
    00044   _fid = MEDfileOpen("current.med",MED_ACC_RDONLY);
    00045   if (_fid < 0) {
    00046     MESSAGE("Erreur a la creation du fichier current.med");
    00047     return -1;
    00048   }
    00049
    00050   if ( (_ninterp =  MEDfieldnInterp(_fid,
    00051                                     _fieldname1
    00052                                     )  ) < 0 ) {
    00053     MESSAGE("Erreur à la lecture du nombre de fonctions d'interpolation  sur le champ : ");
    00054     SSCRUTE(_fieldname1);_ret=_ninterp; goto ERROR;
    00055   }
    00056
    00057   for (_interpit=0;_interpit < _ninterp; ++_interpit ) {
    00058     if ( (_ret =        MEDfieldInterpInfo(_fid,
    00059                                            _fieldname1,
    00060                                            _interpit+1,
    00061                                            _interpname ) <0) ) {
    00062     MESSAGE("Erreur à la lecture des informations de la fonction d'interpolation n° :");
    00063     ISCRUTE(_interpit);SSCRUTE("sur le champ : ");SSCRUTE(_fieldname1);
    00064     goto ERROR;
    00065     }
    00066     else
    00067       fprintf(stdout,"Le nom de la fonction d'interpolation n°%d du champ %s est %s\n",
    00068               _interpit+1,_fieldname1,_interpname);
    00069
    00070   }
    00071
    00072  ERROR:
    00073   if (MEDfileClose(_fid) < 0) {
    00074     MESSAGE("ERROR : file closing");
    00075     return -1;
    00076   }
    00077
    00078   return _ret;
    00079
    00080 }
    00081