      program extmaps
C..................................................................Mar. 2014
C for JPL data
C rms between two maps for 24 h UT
C
C fht='f', 'h', 't' for foF2, hmF2, TEC
C iyr,imn,idy -last available date-of-maps
	DIMENSION XMAP1(0:72,71),XMAP2(0:72,71) !GLON,GLAT
c-	+,IM(12)
     +,rx(0:72)
	CHARACTER*1 fht
	CHARACTER*48 INFILE1,INFILE2,OUTFILE  
c-		integer*2 IYR,IMN,IDY,IUT
c-	+,IDY1,kdy  ! 
c-	CHARACTER*2 AYR,AUT,AMN,ADY
c-            DATA IM/31,28,31,30,31,30,31,31,30,31,30,31/
C
crem	fht='t'          ! temp TEC maps
	fht='w'          ! temp TEC maps
	outfile='extmaps.txt'
	OPEN(110, file=outfile,access='APPEND')
	do k=0,72
	do n=1,71
	XMAP1(k,n)=0.
	XMAP2(k,n)=0.
	enddo
	enddo
	WRITE(*,*)' ENTER name of INPUT FILE 1=	'
	read(*,17) infile1
	WRITE(*,*)' ENTER name of INPUT FILE 2=	'
	read(*,17) infile2
c-	AYR='14'
   17 format (A48)
  107	FORMAT(73(1X,F4.0))	
c-	write(*,17) ' YR=',ayr
c-	read(AYR,*) ryr
c-	IYR=int(ryr)   ! current yr
C
c-	WRITE(*,*)' ENTER CURRENT MN'
c-	READ(*,13) IMN
c-	imn=02
   13 FORMAT(I2)
c-	call blet2(imn,amn)  ! current month
c-		write(*,*) AMN
C
c- 	WRITE(*,*)' ENTER IDY1'
c- 	READ(*,13) IDY1
c- 255	idy2=idy1


200   continue	  
c- 	if (iyr.lt.90) then
c- 	iyyyy=2000+iyr
c-	              else
c-	iyyyy=1900+iyr
c-	endif
c-	z1=iyyyy/4.0
c-      jz=int(z1)*4

c-      IF(jz.EQ.iyyyy) THEN
c-               IM(2)=29
c-	dnr=366.
c-        ELSE
c-                IM(2)=28
c-	  	dnr=365.
c-	       ENDIF
C
c- 	call blet2(iyr,ayr)  ! current year
c- 	call blet2(imn,amn)  ! current month
c- 	call blet2(idy,ady)  ! current day
C month:
c-  	 infile1='d:\web\dts\YY\MM\tcMMDDUT.jYY'   ! 
c-	infile1(9:9)=fht
c-	infile1(18:18)=fht
c- 	infile1(12:13)=ayr
c-	infile1(15:16)=amn
c- 	infile1(20:21)=amn
c-	infile1(28:29)=ayr
	 
c-	infile2='d:\web\graf\dtc\YY\MM\ut\tcMMDDUT.jYY'   ! 
c-	infile2(14:14)=fht
c-	infile2(26:26)=fht
c- 	infile2(17:18)=ayr
c-	infile2(20:21)=amn
c- 	infile2(28:29)=amn
c-	infile2(36:37)=ayr
C
C =======================================================
C
C Reading current month
  130	continue
   12 FORMAT(1X,3A2)
c- 	DO 78 kdy=idy1,idy2  ! 
c-		call blet2(kdy,ADY)
c- 	infile1(22:23)=ADY
c-	infile2(30:31)=ADY
c-	write(*,12) ayr,amn,ady
c-	write(110,12) ayr,amn,ady
      write(110,17) infile1
	write(110,17) infile2
 
C UT cycle
c-	DO 301 iut=0,23
c-	call blet2(iut,AUT)
c-	infile1(24:25)=aut
c-	infile2(32:33)=aut
	OPEN(111,FILE=INFILE1)	  ! 
C   reading map1 for  current month
C
cr	glat=-90.
	sum1=0.
 	DO ilat=1,71 	  ! < LAT-BY-LAT
cr	glat=glat+2.5
	READ (111,107,END=109,ERR=2) (rx(k),k=0,72)
C
cr	glon=-185.		! glon=-180,-175,...,180
	   do k=0,72		 !<<<<<<<<<<<<<<<<<<
cr	glon=glon+5.
cr	if (glon.lt.0.) glon=glon+360.
	xmap1(k,ilat)=rx(k)
	sum1=sum1+rx(k)
	enddo
	ENDDO
  109	close(unit=111)
	 sum1=sum1/5183.

	OPEN(112,FILE=INFILE2)	  ! 
C   reading map2 for  current month
C
cr	glat=-90.
	sum2=0.
	rms=0.
 	DO ilat=1,71 	  ! < LAT-BY-LAT
cr	glat=glat+2.5
	READ (112,107,END=110,ERR=2) (rx(k),k=0,72)
C
cr	glon=-185.		! glon=-180,-175,...,180
	   do k=0,72		 !<<<<<<<<<<<<<<<<<<
cr	glon=glon+5.
cr	if (glon.lt.0.) glon=glon+360.
	xmap2(k,ilat)=rx(k)
	sum2=sum2+rx(k)
	rms=rms+(xmap1(k,ilat)-rx(k))**2
	enddo
	ENDDO
  110	close(unit=112)
	sum2=sum2/5183.
	rms2=sqrt(rms/5183.)
	write(*,14) sum1,sum2,rms2
	write(110,14) sum1,sum2,rms2
  301	continue
  14  FORMAT(1X,3(1X,F7.3))
   78 continue
C - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 106	FORMAT(73(1X,I4))	

C
	close(unit=110)
C
	goto 98
   2	write(*,*) 'Error reading data file', infile1,infile2
  98	pause ' '
	stop
  	END
