C******************** START FILE MOMIND.FOR ; GROUP MOMIND *************
C---------------------------------------------------------------------
C  MOMIND
C   GIVEN THE TIME INDEX RETURN THE INDICES TO: THE 0TH R MOMENT
C     THE 1ST R MOMENT AND THE 1ST Y MOMENT OF THE BDY MOMENTS
C     FOURIER EXPANSION.
C
C   (BACKGROUND)
C     THE PLASMA BDY IS REPRESENTED AS A FOURIER MOMENTS EXPANSION
C   THE TIME DEPENDENT MOMENTS ARE READ BY TRDAT IN 3 UFILES (OR
C   TIME INDEPENDENT BDY MOMENTS SPECIFIED BY NAMELIST).
C     THIS DATA IS INTERPOLATED TO A FIXED TIME GRID COVERING THE
C   ACTUAL TIME OF EXPERIMENT TO BE ANALYZED BY TRANSP.  THE
C   INTERPOLATED DATA IS STORED IN TRANSP COMMON ARRAY DATBUF.
C   TRDAT WRITES OUT AN IMAGE OF THE COMMON BLOCK CONTAINING DATBUF
C   WHICH IS READ BY TRANSP TO MAKE AN ACTUAL RUN
C
C     THIS ROUTINE HELPS LOOK UP THE INTERPOLATED MOMENTS DATA.
C
      SUBROUTINE MOMIND(d, IT,IR0,IR1,IY1)
C
      use trdatbuf_obj
      IMPLICIT NONE
      type (trdatbuf) :: d
C
C  PASSED INPUT-- IT= DESIRED TIME INDEX
C  COMMON INPUT:
C   DATBUF  DATA BUFFER
C     MOMENTS DATA STORED TIME CONTIGUOUS, I.E.
C     0TH MOMENT AT ALL TIMES, THEN 1ST MOMENT AT ALL TIME, ETC.
C   NMOMD  NUMBER OF MOMENTS STORED IN DATBUF
C   NTIME2  NUMBER OF TIME PTS FOR MOMENTS AND 2D DATA IN DATBUF
C   LMOMD  ADDRESS OF FIRST WORD OF MOMENTS DATA IN DATBUF
C
C  PASSED OUTPUT
C   IR0    ADDRESS OF 0TH R MOMENT
C   IR1    ADDRESS OF 1ST R MOMENT
C          (IR1+1 ADDRESS TO 2ND R MOMENT, ...)
C   IY1    ADDRESS OF 1ST R MOMENT
C          (IY1+1 ADDRESS TO 2ND Y MOMENT, ...)
C
C---------------------------------
C
!============
! idecl:  explicitize implicit INTEGER declarations:
      INTEGER ir0,ir1,iy1,it,itm1
!============
      ITM1=IT-1
C
      IR0=D%LMOMD+ITM1
      IR1=IR0+D%NTIME2
      IY1=IR1+D%NMOMD*D%NTIME2
C
      RETURN
      END
C******************** END FILE MOMIND.FOR ; GROUP MOMIND ***************
! 19jan2003 fgtok -s r8_precision.sub all.sub "r8con.csh conversion"
