*=*=*=*= drsread.html =*=*=*=*
FUNCTION drsread

FUNCTION drsread


      FUNCTION drsread (unit,varname,var,it)
c=======================================================================
c   Objet:
c   ------
c   Lecture d'un champ du modele 2D ou 3D instantanne
c    dans un fichier DRS.
c   arguments:
c   ----------
c   entree:
c   -------
c   unit     INTEGER    unite logique pour la lecture DRS
c   varname  character*100 nom de la variable DRS
c   it       INTEGER    indice du temps a lire
c   sortie:
c   -------
c   var      REAL(surdimension) variable
c=======================================================================
      implicit none
#include  "dimensions.h"
      INTEGER drsread
      INTEGER imx,ijlmx
      parameter (ijlmx=(iim+1)*(jjm+1)*(llm+1))
      parameter (imx=1000000)
      REAL x (imx),var(ijlmx)
      CHARACTER varname*100
      INTEGER im

      INTEGER i
      INTEGER unit,it,getnd,ix

c    chaines de caratceres
      CHARACTER gtitre*100

#include "drsdef.h"
      INTEGER SETNAME, CLUVDB, INQDICT
      INTEGER GETCDIM, GETSLAB
      character dimname*16, dimtitle*80, dimunits*40
      INTEGER dimtype, numdim
      INTEGER vardim(4)

c dimfirst = tableau contenant les 1ers elements des dimensions
      REAL dimfirst(4)
c dimlast = tableau contenant les derniers elements des dimensions
      REAL dimlast(4)
c dimcycl = tableau contenant les periodes des dimensions
      REAL dimcycl(4)
c dimord = tableau contenant l'ordre de sortie des dimensions
      INTEGER dimord(4)
      data dimord /1,2,3,4/

c  initialisation
c  --------------

c     print*,'varname',varname
c     print*,'unit',unit
c     print*,'it',it

          do i=1,4
               vardim (i) = 0
          end do

c lecture de var
c -----------------

          drsread=0
          drsread=drsread+ CLUVDB()
          drsread=drsread+ SETNAME(' ',varname,' ',' ',' ')
          drsread=drsread+ INQDICT(unit, IDRS_GETFIRSTVAR)
          drsread=drsread+ getnd(numdim)
          do i=1, numdim
           im=0
               drsread=drsread+ GETCDIM(i,gtitre,dimname,dimtitle,
     &         dimunits,dimtype, imx,x,im)

               dimfirst(i)= x(1)
               dimlast(i) = x(im)
               dimcycl(i) = 0.
               vardim(i)=im

               if (dimname.eq.'temps') then
                 dimfirst(numdim)= x(it)
                 dimlast(numdim)= x(it)
                 dimcycl(numdim) = 0.
                 vardim(i)=1
               end if
          enddo
c         print*,'numdim',numdim
c         print*,'dimord',dimord
c         print*,'dimfirst',dimfirst
c         print*,'dimlast',dimlast
c         print*,'dimcycl',dimcycl
c         print*,'vardim',vardim
          drsread=drsread+ GETSLAB(unit, numdim, dimord, dimfirst
     &       ,dimlast, dimcycl, var, vardim)
      return
      END