1  C*************************************************************************
  2  C COPYRIGHT (C) 1999 - 2003  EDF R&D
  3  C THIS LIBRARY IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
  4  C IT UNDER THE TERMS OF THE GNU LESSER GENERAL PUBLIC LICENSE 
  5  C AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
  6  C EITHER VERSION 2.1 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
  7  C
  8  C THIS LIBRARY IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
  9  C WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
 10  C MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
 11  C LESSER GENERAL PUBLIC LICENSE FOR MORE DETAILS.
 12  C
 13  C YOU SHOULD HAVE RECEIVED A COPY OF THE GNU LESSER GENERAL PUBLIC LICENSE
 14  C ALONG WITH THIS LIBRARY; IF NOT, WRITE TO THE FREE SOFTWARE FOUNDATION,
 15  C INC., 59 TEMPLE PLACE, SUITE 330, BOSTON, MA 02111-1307 USA
 16  C
 17  C**************************************************************************
 18
 19  C******************************************************************************
 20  C* - Nom du fichier : test22.f
 21  C*
 22  C* - Description : lecture des valeurs scalaires numeriques dans un fichier MED
 23  C ******************************************************************************
 24        program test22
 25  C     
 26        implicit none
 27        include 'med.hf'
 28  C
 29        integer fid,cret
 30        character*16 dtunit
 31        character*32 nom
 32        character*200 desc
 33        integer vali
 34        real*8 valr,dt
 35        integer n,npdt,i,j,type,numdt,numo
 36  C     
 37  C     Ouverture du fichier test21.med en lecture seule
 38  C
 39        call efouvr(fid,'test21.med',MED_LECTURE,cret)
 40        print *,cret
 41        print *,'Ouverture du fichier test21.med'
 42  C
 43  C     Lecture du nombre de variable scalaire
 44  C
 45        if (cret .eq. 0) then
 46           call efnsca(fid,n,cret)
 47           print *,cret
 48           print *,'Nombre de variables scalaires : ',n
 49        endif
 50  C
 51  C     Lecture des infos (type,description) propres 
 52  C     a chaque variable
 53  C
 54        if (cret .eq.0) then
 55  C
 56           do 10 i=1,n
 57              if (cret .eq. 0) then
 58                 call efscai(fid,i,nom,type,desc,cret)
 59                 print *,cret
 60                 print *,'- Scalaire de nom : ',nom
 61                 if (type .eq. MED_FLOAT64) then
 62                    print *,'  de type flottant'
 63                 else
 64                    print *,'  de type entier'
 65                 endif
 66                 print *,'  Description associee : ',desc
 67              endif
 68  C
 69  C     Pour chaque scalaire, on regarde les valeurs associees
 70  C     eventuellement a un pas de temps et/ou un numero d'ordre 
 71  C
 72              if (cret .eq. 0) then
 73                 call efnspd(fid,nom,npdt,cret)
 74                 print *,cret
 75                 print *,'  Nombre de valeurs : ',npdt
 76              endif
 77  C
 78              if (cret .eq. 0) then
 79                 do 20 j=1,npdt
 80                    call efspdi(fid,nom,j,numdt,dtunit,dt,numo,cret)
 81                    print *,'   Valeur ', j
 82                    if (numdt .eq. MED_NOPDT) then
 83                       print *,'     - Aucun pas de temps'
 84                    else
 85                       print *,'     - Pas de temps de numero ',numdt
 86                       print *,'      de valeur : ',dt
 87                       print *,'      unite : ',dtunit
 88                    endif
 89                    if (numo .eq. MED_NONOR) then
 90                       print *,'     - Aucun numero ordre'
 91                    else
 92                       print *,'     - Numero ordre : ',numo
 93                    endif
 94  C
 95                    if (cret .eq. 0) then
 96                       if (type .eq. MED_FLOAT64) then
 97  C                       ** Lecture de la valeur flottante associee 
 98  C                       ** au pas de temps
 99                          call efscfl(fid,nom,valr,numdt,numo,cret)
100                          print *,cret
101                          print *,'     - Valeur : ',valr
102                       else
103  C                       ** Lecture de la valeur entiere associee 
104  C                       ** au pas de temps
105                          call efscel(fid,nom,vali,numdt,numo,cret)
106                          print *,cret
107                          print *,'     - Valeur : ',vali
108                       endif
109                    endif
110  C
111   20            continue
112              endif
113  C
114   10      continue
115  C
116        endif
117  C
118  C     Fermeture du fichier      
119  C
120        call efferm(fid,cret)
121        print *,cret
122        print *,'Fermeture du fichier test21.med'
123  C
124        end
125  C