      subroutine subinterdias(syr,smn,sdy,sut,smm,cov)
C.................................................................Nov. 2020
C Extract dias maps foF2 & M3F2 to produce hmF2 dias map 
C
C Gulyaeva Tamara <gulyaeva@izmiran.ru>
C
C Subroutine to extract data from DIAS maps (foF2, M3F2) to produce hmF2 map
C Input : fm='f' means foF2
C		fm='m' means M3F2
C         syr - YEAR = '99' for 1999,'00' for 2000, etc.
C         smn - month
C         sdy - day of month
C         sut - hour, UT
C         smm - minute
C.................................................................
C Outpur file hmF2 map, hmF2 (km)
C 
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C Use fc,m3 from directories graf/Emap/ - update addresses for input file
C
	DIMENSION fodat(46),xmdat(46),hmdat(46)	  ! maps fcF2,hcF2,TEC
	+,fhdat(27,46)
c-	CHARACTER*1 fm
	CHARACTER*2 syr,smn,sdy,sut,smm
c-	CHARACTER(10) DDDD
c-	CHARACTER*4 TIMC 
c-	CHARACTER(5) ZZZ
      CHARACTER*120 infilef,infilem,outfileh,txt
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C
	read(syr,*) ryr
	iyr=int(ryr)
	read(sdy,*) rdy1
	 ndy1=int(rdy1)
	read(smn,*) rmn1
	imn1=int(rmn1)
	lda=ndoy(iyr,imn1,ndy1)
	read(sut,*) UT
		read(smm,*) rmin
  	imm=int(rmin)

C Use fc,hc predictions from directories dfc or dhc
	infilef='d:web\graf\Emap\YRMNDDUTMM.txt' !path and name of input file foF2
	infilef(17:18)=SYR
	infilef(19:20)=SMN
	infilef(21:22)=SDY
	infilef(23:24)=SUT
	infilef(25:26)=SMM
C infilem='d:\graf\Emap\YRMNDDUTMMm.txt' !path and name of input file M3F2
       infilem=infilef
	infilem(27:)='m.txt'
	outfileh=infilem
	outfileh(27:)='h.txt'
 204	format(46(1X,F5.1))
C
	OPEN(10,FILE=OUTFILEH)		
	OPEN(11,FILE=INFILEF,action='READ')		
	OPEN(12,FILE=INFILEM,action='READ')
	do ii=1,2
      read(11,*) txt   ! title lines
	write(10,*) txt
	read(12,*) txt
	enddo
C
	UT=ut+imm/60.
C Lati cycle
        glat=61.
		DO 120 ilat=1,27
	glat=glat-1.
	read(11,*,end=1204) (fodat(k),k=1,46)	
	read(12,*,end=1205) (xmdat(k),k=1,46)	
C Add calculation hmF2 from foF2,M3F2 (all stations but mos)
C
C//	glat=at%glat
C//	glon=at%glon
C
C Cycle on longi
        alon=-6.
        DO 121 ilon=1,46
	alon=alon+1.0
	glon=alon
	if (glon.lt.0.) glon=glon+360.
	af2=fodat(ilon)
	am3=xmdat(ilon)
c 1177 CONTINUE
	call subxhi(glat,glon,lda,ut,xhi,xhinon)
	abslat=abs(glat)
      FOE=FOEEDI(COV,XHI,XHINON,ABSLAT)
C-	fm=af2
	ah2=0.0
C-	ires(iut)=0
	if ((af2.gt.0.).and.(am3.gt.0.)) then
	       ah2=peakh(foE,af2,am3)
C??	if ((ah2.gt.450.).or.(ah2.lt.160.)) ah2=0.0
	endif
	hmdat(ilon)=ah2
	fhdat(ilon,ilat)=ah2
  121	CONTINUE  ! next ilong
      write(*,204) (hmdat(k),k=1,46)
	write(10,204) (hmdat(k),k=1,46)

  120	CONTINUE  ! next lati
1204	close(unit=11)
1205	close(unit=12)
1206	close(unit=10)
C
      RETURN
C      interpolate for glat,glon
C Linear Interpolation   
	aglat=-90.
	res=0.
	res11=0.
	res12=0.
	res21=0.
	res22=0.
	do 161 ilat=1,70 ! select pair of lats-lines (k) & (k+1)
c	aglat=-87.5,-85,...,87.5
	aglat=-90.+2.5*ilat
	aglat2=aglat+2.5
C
	if ((glat.ge.aglat).and.(glat.le.aglat2)) then  !   <<<<1
C Select pair of longs embracing glong
	 clon=-185.
	along=glon
	if (along.ge.180.) along=along-360.0
	do j=0,71 ! select pair of longs (j) & (j+1)
	clon=clon+5.
	clon2=clon+5.
	if ((along.ge.clon).and.(along.lt.clon2)) then  ! +++2
	res11=fhdat(j,ilat)
	res12=fhdat(j+1,ilat)
	res21=fhdat(j,ilat+1)
	res22=fhdat(j+1,ilat+1)
	res1=res11+(res12-res11)/5.*(along-clon)
	res2=res21+(res22-res21)/5.*(along-clon)
	res=res1+(res2-res1)/2.5*(glat-aglat)
	endif											 ! +++2
	enddo	! end select pair of longs (j) & (j+1)
	exit
	endif											 !   <<<<1
  161 continue		   ! interpolation end
C//	close(unit=10)
	RETURN
	END