SUBROUTINE INDAT290
!use consts
use global
implicit none  
    
real(DP) :: amin,amax,aminr,a1,timo1,timo2,bla,x
integer :: i,j
save


      AMIN=RLAMR(1)/CR(1)
      AMAX=RLAMR(1)/CR(1)
      AMINR=AMIN
      DO 100 I=2,NLAYST
        A1=RLAMR(I)/CR(I)
        IF(A1.LT.AMINR) AMINR=A1
  100 CONTINUE

      DO 102 I=1,ILAY
        A1=RLAML(I)/CL(I)
        IF(A1.GT.AMAX) AMAX=A1
        IF(A1.LT.AMIN) AMIN=A1
  102 CONTINUE
  
      TIMO3=31536000.*TIMO3
      TIMO1=2000.
      
! TIMO1=172800 old original value. Then TIMO1=80 has been chosen fitting the hourly records from
! Vaulruz storage (CH); it results in smaller grid near the pipe wall to be able to follow better hourly performance.
! The value TIMO1=2000 is chosen for borehole (radius R0>0.05m), thus saving significant
! execution time when NLoc>1. Relatively to TIMO1=80, a simulation example showed that
! the yearly stored and recovered energy differed by less than 2%.

      TIMO2=3.*86400.
      HEIGHT=DEEP-DEPTH
      RADIUS=SQRT(VOLUME/(PI*HEIGHT))
      RIST=0.
      
      IF(RISLAM.NE.0) RIST=THISO/RISLAM
      
      RISS=RIST
      RISB=0.
      BLA=RADIUS*RADIUS/RBORE
      R1=SQRT(BLA)
      DISPIP=R1/0.525
!-----DP OCT 1996
      DRRMIN=SQRT(4.*AMINR*TIMO1/12.)
!-----END DP OCT 1996
      DRMIN=SQRT(4.*AMIN*TIMO2)
      DRMAX=SQRT(4.*AMAX*TIMO3)
      ZDMIN=SQRT(AMAX*31536000./PI)
      FAC=2.
      FACL=1.4

      CALL MESH90

      IMAX1=IMAX+1
      JMAX1=JMAX+1

      CALL THEPRO90

      DTOKAY=3.*86400.
      IF(R(2).EQ.0.) R(2)=1.E-10*R(3)
      
      RM(1)=R(2)
      
      DO 309 I=1,IMAX1
      DO 309 J=1,JMAX1
      X=TSTARG+ZM(J)*TGRAD
      T(I,J)=X
  309 TOLD(I,J)=X

RETURN
END subroutine indat290