      subroutine mapionexmm1c(fhts,qs,ayear,amn,ady)
C.....................................................May 2021
C W(tec) maps in geograf, coords. 15min
C.....................................................May 2018
C produce diurnal results in formal UPC_IONEX format 
C          for given YR, MN, DY, UT=00,01,...,23
C
	CHARACTER*65 INFILE,OUTFILE
	CHARACTER*2 AYR,AMN,ADY,AUT,CMN,amap,AMM
	CHARACTER*4 AYEAR
	CHARACTER*1 fhts,qs ! foF2=f, hmF2 =h,TEC =t, Tau =s 
	CHARACTER*20 start,enddesc,epoch
        CHARACTER*60 title1(16),tit1,tit2,tit3
	CHARACTER*20 title2(16),utend
	character*80 txt1(71),txt2(71),txt3(71),txt4(71)
	character*45 txt5(71)
	CHARACTER*3 tmon(12),rmon,doy
	dimension im(12)
C
	DATA  IM/31,28,31,30,31,30,31,31,30,31,30,31/
	DATA tmon/'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug'
	+,'Sep','Oct','Nov','Dec'/
      DATA title1/
     + '     1.0            IONOSPHERE MAPS     GPS                 '
	+,'GIM V3.0            UPC - IonSAT        11-Mar-2015 00:40   '
	+,'W-INDEX IONOSPHERE MAPS                                     '
	+,'Global ionosphere maps for day 076, 2015 (17-03-2015)       '
	+,'produced from UPC GIM-TEC IONEX MAP                         '
	+,'W values in index units, i.u. Hours, UT.                    '
	+,'  2015     3    18     0     0     0                        '
	+,'  2015     3    18    23    45     0                        '
	+,'  3600                                                      '
	+,'    96                                                      '
	+,'     2                                                      '
	+,'   450.0 450.0   0.0                                        '
	+,'    87.5 -87.5  -2.5                                        '
	+,'  -180.0 180.0   5.0                                        '
	+,'     0                                                      '
	+,'                                                            '/
      tit1=title1(16)
      tit2=tit1
      tit3=tit1
      DATA title2/
     + 'IONEX VERSION / TYPE','PGM / RUN BY / DATE '
	+,'COMMENT             ','COMMENT             '
	+,'COMMENT             ','COMMENT             '
	+,'EPOCH OF FIRST MAP  ','EPOCH OF LAST MAP   '
	+,'INTERVAL            ','# OF MAPS IN FILE   '
	+,'MAP DIMENSION       ','HGT1 / HGT2 / DHGT  '
	+,'LAT1 / LAT2 / DLAT  ','LON1 / LON2 / DLON  '
	+,'EXPONENT            ','END OF HEADER       '/
C
C
C?      enddesc='END OF HEADER       '
      start='START OF TEC MAP    '
	enddesc='END OF HEADER       '
	epoch='EPOCH OF CURRENT MAP'
      utend='END OF TEC MAP      ' 
C?	btxt='-180.0 180.0   5.0 450.0'
C
write(*,*) AYEAR
		ayr=ayear(3:4)
	read(ayr,*) ryr
	iyr=int(ryr)
	read(ayear,*) xyear
	IYYYY=int(xyear)
	read(ayr,*) ryr
	iyr=int(ryr)
	write(*,*) amn
	CMN=AMN
	if (CMN(1:1).eq.'0') CMN(1:1)=' '
	read(amn,*) xmn
	imn=int(xmn)
	rmon=tmon(imn)

C
		idayy=365
	      IM(2)=28
        if(iyr/4*4.eq.iyr) then
	  idayy=366
	   	 IM(2)=29
	  endif

	read(ady,*) xdy
	idy=int(xdy)
	lda=ndoy(iyr,imn,idy)
	call blet3(lda,doy)
c
Crem	infile='c:\web\dts\YR\MN\tcMNDDUT.jYR'
C	infile='c:\web\dws\YR\MN\woMNDDUT.jYR' !geomag
      infile='c:\web\graf\dwu\YR\MN\ut\wcMNDDUTMM.uYR'  !UPC
C+++
      if (qs.eq.'q') then
	infile(15:15)='u'
	else
	infile(15:15)='a'
	endif

Crem      outfile='c:\web\dts\YR\YRMNDYw.txt'
      outfile='c:\web\graf\dwu\YR\YRMNDYw_15m.txt'
C+++
      if (qs.eq.'q') then
	outfile(15:15)='u'
	else
	outfile(15:15)='a'
	endif
C
C
C      infile='c:\web\graf\dwu\YR\MN\ut\wcMNDDUTMM.uYR'  !UPC
	infile(17:18)=AYR
		infile(20:21)=AMN
		infile(28:29)=AMN
		infile(30:31)=ADY
		infile(38:39)=AYR
	
	outfile(17:18)=AYR
	outfile(20:21)=AYR
	outfile(22:23)=AMN
	outfile(24:25)=ADY

	OPEN(10,file=outfile)
C
C write title lines
C
	DO nn=1,16
	tit1=title1(nn)
	if (nn.eq.2) then
	tit1(41:42)=ADY
	tit1(44:46)=rmon
	tit1(48:51)=AYEAR
	endif
	if ((nn.eq.3).or.(nn.eq.6)) then
	tit1(1:1)=fhts
	endif
	if (nn.eq.4) then
	tit1(32:34)=doy
	tit1(37:40)=AYEAR
	tit1(43:44)=ADY
	tit1(46:47)=AMN
	endif
	if ((nn.eq.7).or.(nn.eq.8)) then
	tit1(3:6)=AYEAR
	tit1(11:12)=CMN
	tit1(17:18)=ADY
	endif
	write(*,202) tit1,title2(nn)
	write(10,202) tit1,title2(nn)
	ENDDO
  202 format(A60,A20)
  107 format(4(A80),A45)
 1071 format(A80)
 1072 format(A45)
 1073 format(3X,F5.1,'-180.0 180.0   5.0 450.0',28X
     +,'LAT/LON1/LON2/DLON/H')
C
      tit3(3:6)=AYEAR
	tit3(11:12)=AMN
	tit3(17:18)=ADY
C-	tit3(29:30)='00' ! min
	tit3(35:36)='00' ! sec
C
C cycle	UT
       imap=0
C
        DO 100 iut=0,23
	call blet2(iut,AUT)
	infile(32:33)=AUT
C
C		imap=iut+1
C
C cycle 15 min
C
       DO	110 imm=0,45,15
	call blet2(imm,AMM)
	infile(34:35)=AMM
	imap=imap+1
 	call blet2(imap,amap)
	tit2(5:6)=AMAP
	write(*,202) tit2,start
	write(10,202) tit2,start
C
	tit3(23:24)=AUT
	tit3(29:30)=AMM ! min
	write(*,202) tit3,epoch
	write(10,202) tit3,epoch
C
	OPEN(11,file=infile,action='READ')
C =========================================
c
	do i=1,71
	i1=72-i
	READ (11,107,END=99,ERR=2) TXT1(i1),txt2(i1),txt3(i1),txt4(i1)
	+,txt5(i1) !map lines LATi(71)=(-87.5),...,LATI(1)=(+87.5)
	enddo
	glat=90.0
	do i=1,71
	glat=glat-2.5
C	write(*,1073) glat	  !Temp
	write(10,1073) glat
	write(10,1071) TXT1(i)
	write(10,1071) TXT2(i)
	write(10,1071) TXT3(i)
	write(10,1071) TXT4(i)
	write(10,1072) TXT5(i)
	enddo
  99	close(unit=11)
C
C Write 'END OF TEC MAP'
		write(*,202) tit2,utend
		write(10,202) tit2,utend
  110	continue   ! end min cycle
  100	continue   ! end ut cycle
        close(unit=10)
       GOTO 33
c==	endif
    2 CONTINUE
       write(*,*) 'INPUT FILE IS NOT IN YOUR DIRECTORY '
 	pause ' '
	goto 34
   33	continue
      write(*,*) infile,outfile
   34  RETURN
       END
