# MEDcoordLire.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
    00019 #include <med.h>
    00020 #include <med_config.h>
    00021 #include <med_outils.h>
    00022
    00023 #include <string.h>
    00024 #include <stdlib.h>
    00025
    00026 extern int mode_interlace;
    00027
    00028 med_err
    00029 MEDcoordLire(med_idt fid, char *maa, med_int mdim, med_float *coo,
    00030              med_mode_switch mode_coo,med_int numco,
    00031              med_int * pfltabtmp, med_size psize, med_repere *type_rep, char *nom, char *unit)
    00032 {
    00033   med_idt   maaid, noeid, dataset;
    00034   med_err   ret;
    00035   char      chemin[MED_TAILLE_MAA+MED_TAILLE_NOM+1];
    00036   int       i,j;
    00037   med_float *new_coo;
    00038   med_int   type_rep_int;
    00039   med_size * pfltab;
    00040
    00041   /*
    00042    * On inhibe le gestionnaire d'erreur
    00043    */
    00044   _MEDmodeErreurVerrouiller();
    00045 if (MEDcheckVersion(fid) < 0) return -1;
    00046
    00047
    00048   /*
    00049    * Si le maillage n'existe pas => erreur
    00050    * Sinon on recupere sa dimension au passage
    00051    */
    00052   strcpy(chemin,MED_MAA);
    00053   strcat(chemin,maa);
    00054   if ((maaid = _MEDdatagroupOuvrir(fid,chemin)) < 0)
    00055       return -1;
    00056
    00057   /*
    00058    * Si le Data Group "NOE" n'existe pas => erreur
    00059    */
    00060   if ((noeid = _MEDdatagroupOuvrir(maaid,MED_NOM_NOE)) < 0)
    00061       return -1;
    00062
    00063   /*
    00064    * Convertion de med_int en med_size
    00065    */
    00066   if ( psize != MED_NOPF ) {
    00067     pfltab = (med_size *) malloc (sizeof(med_size)*psize);
    00068     for (i=0;i<psize;i++)
    00069       pfltab[i] = (med_size) pfltabtmp[i];
    00070   }
    00071
    00072   /*
    00073    * Lecture du Data Set "COO"
    00074    */
    00075   if ((ret = _MEDdatasetNumLire(noeid,MED_NOM_COO,MED_FLOAT64,
    00076                                 mode_coo,mdim,numco,
    00077                                 psize,MED_COMPACT,MED_PFL_NON_COMPACT,pfltab,MED_NOPG,0,
    00078                                 (unsigned char*) coo)) < 0)
    00079     return -1;
    00080
    00081
    00082   /*
    00083    * On re-ouvre le Data Set "COO" pour y lire des attributs
    00084    */
    00085   if ((dataset = _MEDdatasetOuvrir(noeid,MED_NOM_COO)) < 0)
    00086     return -1;
    00087
    00088   /*
    00089    * L'attribut "REP"
    00090    */
    00091   if ((ret = _MEDattrEntierLire(dataset,MED_NOM_REP,&type_rep_int)) < 0)
    00092     return -1;
    00093   else
    00094     *type_rep = (med_repere) type_rep_int;
    00095
    00096   /*
    00097    * Attribut "NOM"
    00098    */
    00099   if ((ret = _MEDattrStringLire(dataset,MED_NOM_NOM,mdim*MED_TAILLE_PNOM,
    00100                                 nom)) < 0)
    00101     return -1;
    00102
    00103   /*
    00104    * Attribut "UNI"
    00105    */
    00106   if ((ret = _MEDattrStringLire(dataset,MED_NOM_UNI,mdim*MED_TAILLE_PNOM,
    00107                                 unit)) < 0)
    00108     return -1;
    00109
    00110   /*
    00111    * On ferme tout
    00112    */
    00113   if ( psize != MED_NOPF ) free(pfltab);
    00114
    00115   if ((ret = _MEDdatasetFermer(dataset)) < 0)
    00116     return -1;
    00117   if ((ret = _MEDdatagroupFermer(noeid)) < 0)
    00118     return -1;
    00119   if ((ret = _MEDdatagroupFermer(maaid)) < 0)
    00120     return -1;
    00121
    00122   return 0;
    00123 }