      program mapinter3
C..................................................................Apr.2012
C IONEX grids -87.5:2,5:87.5; -180:5:180;
C Add maps ec....uYR
C
C Interpolate maps t, f, h from 2h to 1h maps
C .................................................................Dec 2011
C
	dimension ires(0:72),XX(0:72),YY(0:72),ZZ(0:72)
	CHARACTER*128 INFILE1,INFILE2,OUTFILE
	character*2 ayr,amn,ady,aut1,aut2,aut3
	integer*2 iyr,imn,idy,ii1,ii2,ii3
	character*1 fht
	infile1='d:\web\dfc\yr\mn\fcmndyut.uyr'
c//	WRITE(*,*) 'Check YEAR and month for input: '
c//	pause ' '
	ayr='12'	 !temp
	amn='07'	 !temp
	iyr=12		 !temp
	imn=07		 !temp
	write(*,23) ayr,amn
   23	format(1X,A2,1X,A2)
		WRITE(*,*) 'Enter ndy1, ndy2 for input: '
 	read(*,*) ndy1,ndy2
c-		fht='f'
c-	fht='h'
   24	WRITE(*,*) 'Enter <lettter> for input: '
	read(*,25) fht
   25 format(A1)	 
crem       	fht='t'
	infile1(9:9)=fht
	infile1(10:10)='c'
	if (fht.eq.'e') infile1(9:10)='te'
	infile1(18:18)=fht
CNOT	infile1(27:27)=fht
	infile1(12:13)=ayr
	infile1(15:16)=amn
	infile1(20:21)=amn
	infile1(28:29)=ayr
  100	format(73(1X,F4.0))
  101	format(73(1X,I4))
C
C day-to-day cycle
      DO 70 idy=ndy1,ndy2
	call blet2(idy,ady)
	infile1(22:23)=ady
	infile2=infile1
	outfile=infile1
C ut-cycle
	ii=0
	do iut=0,23,2
	ii1=iut
	ii2=ii1+1
	ii3=ii2+1
	call blet2(ii1,aut1)
	call blet2(ii2,aut2)
	call blet2(ii3,aut3)
	infile1(24:25)=aut1
	outfile(24:25)=aut2
	infile2(24:25)=aut3
		OPEN(11,FILE=INFILE1)
		OPEN(12,FILE=OUTFILE)
		OPEN(13,FILE=INFILE2)
C
	do kk=1,71
	read(11,100,END=9,ERR=2) (xx(i),i=0,72)
	read(13,100,END=19,ERR=2) (yy(i),i=0,72)
	do k=0,72
	zz(k)=(xx(k)+yy(k))/2.
	ires(k)=nint(zz(k))
	enddo
		write(12,101) (ires(k),k=0,72)
crem	write(*,101) (ires(k),k=0,72)
	enddo			! end latis
C
    9	close(unit=11)
   19	close(unit=13)
      close(unit=12)

	enddo  ! end ut cycle
   70	continue ! end day-to-day cycle
	goto 33
    2	write(*,*) 'Error reading data file',infile1,infile2
	pause ' '
   33	continue
	if (fht.eq.'e') then
	goto 31
	             else
	goto 24
	endif
   31	stop
	end


