	CHARACTER*5 daystr
	CHARACTER*23 filestr
        CHARACTER*32 itoa
        CHARACTER*80 SPECHAR

        DIMENSION INTMON(12),INTEXT(12)
        DIMENSION P1(288),P2(288),P3(288),P4(288),P5(288),P6(288),
     *  PH1(1),PH2(1),PH3(1),PH4(1),PH5(1),PH6(1),
     *  F0(3),E0(3),IHOUR(24)

	 DATA INTMON/31,29,31,30,31,30,31,31,30,31,30,31/

	 DATA INTEXT/69,71,69,70,69,70,69,69,70,69,70,69/

	 INTSTR = 80100

	 IDAY = 0

	 DO 1100 IM=1,12
	    DO 1200 JD=1,31

		  INTSTR = INTSTR + 1
		  IDAY = IDAY + 1

		  daystr = itoa(INTSTR)
		  print *,' im=',im,' jd=',jd,' intstr=',intstr,
     *  ' iday=',iday
          print *,' daystr=',daystr
	  filestr = '200'//daystr//'_G11part_5m.txt'
	  print *,' filestr=',filestr

	  open(unit=1,name=filestr,status='old',err=555)

	  print*,'file ',filestr,' is opened!!!!!!!!'

        DO 140 II=1,26
        READ(1,100)SPECHAR
c       WRITE(6,100)SPECHAR
100     FORMAT(A80)
 140    CONTINUE

        DO 505 I=1,1
           PH1(i)=0.0E0
           PH2(i)=0.0E0
           PH3(i)=0.0E0
           PH4(i)=0.0E0
           PH5(i)=0.0E0
           PH6(i)=0.0E0
           yindx1=0.0E0
           yindx2=0.0E0
           yindx3=0.0E0
           yindx4=0.0E0
           yindx5=0.0E0
           yindx6=0.0E0

	   JITOP=288
	   if(IM .eq. 5 .and. JD .eq. 6)JITOP=144
           DO 510 J=1,JITOP
C   READ IN TIME, VALUES OF PROTON FLUX, P1, P2, P3, P4, P5, P6
        READ(1,201)IYR,IMON,IDAYRE,IHOUR(I),P1(J),P2(J),P3(J),
     *  P4(J),P5(J),P6(J)
c       print *,' j=',j,' p1=',p1(j),' p2=',p2(j)
201     FORMAT(I4,I3,I3,I4,18X,6E10.2)
C  P1 = > 1 MeV
C  P2 = > 5 MeV
C  P3 = > 10 MeV
C  P4 = > 30 MeV
C  P5 = > 50 MeV
C  P6 = > 100 MeV

        if(p1(j) .gt. 0.0e0)then
           PH1(i)=ph1(i)+p1(j)
           yindx1=yindx1 + 1.0E0
           endif

        if(p2(j) .gt. 0.0e0)then
           PH2(i)=ph2(i)+p2(j)
           yindx2=yindx2 + 1.0E0
           endif

        if(p3(j) .gt. 0.0e0)then
           PH3(i)=ph3(i)+p3(j)
           yindx3=yindx3 + 1.0E0
           endif

        if(p4(j) .gt. 0.0e0)then
           PH4(i)=ph4(i)+p4(j)
           yindx4=yindx4 + 1.0E0
           endif

        if(p5(j) .gt. 0.0e0)then
           PH5(i)=ph5(i)+p5(j)
           yindx5=yindx5 + 1.0E0
           endif

        if(p6(j) .gt. 0.0e0)then
           PH6(i)=ph6(i)+p6(j)
           yindx6=yindx6 + 1.0E0
           endif

 510       CONTINUE
           PH1(i)=ph1(i)/yindx1
           PH2(i)=ph2(i)/yindx2
           PH3(i)=ph3(i)/yindx3
           PH4(i)=ph4(i)/yindx4
           PH5(i)=ph5(i)/yindx5
           PH6(i)=ph6(i)/yindx6
c          print *,' i=',i,' ph1=',ph1(i),' ph2=',ph2(i)
c          if(1.gt.0)stop
505     CONTINUE

        IDAYOUT=IDAY

        FF = 0.0E0

        DO 700 I=1,1

        E0(1)=(5.-1.)/ALOG(PH1(I)/PH2(I))
        F0(1)=(PH1(I)*ALOG(PH1(I)/PH2(I)))/(5.-1.)/
     *    EXP(-(1.)*ALOG(PH1(I)/PH2(I))/(5.-1.))
c       if(i.ge.14)print *,' ph1=',ph1(i),' ph2=',ph2(i)
c       if(i.ge.14)print *,' i=',i,' e01=',e0(1),' phi1=',f0(1)
        IF(E0(1) .LE. 0.0E0)F0(1)=F0(1)*1.E-10
        IF(E0(1) .LE. 0.0E0)E0(1)=-E0(1)

        E0(2)=(30.-10.)/ALOG(PH3(I)/PH4(I))
        F0(2)=(PH3(I)*ALOG(PH3(I)/PH4(I)))/(30.-10.)/
     *    EXP(-(10.)*ALOG(PH3(I)/PH4(I))/(30.-10.))
        IF(E0(2) .LE. 0.0E0)F0(2)=F0(2)*1.E-10
        IF(E0(2) .LE. 0.0E0)E0(2)=-E0(2)

        E0(3)=(100.-50.)/ALOG(PH5(I)/PH6(I))
        F0(3)=(PH5(I)*ALOG(PH5(I)/PH6(I)))/(100.-50.)/
     *    EXP(-(50.)*ALOG(PH5(I)/PH6(I))/(100.-50.))
        IF(E0(3) .LE. 0.0E0)F0(3)=F0(3)*1.E-10
        IF(E0(3) .LE. 0.0E0)E0(3)=-E0(3)

        WRITE(2,2020)F0(1),E0(1),FF,F0(2),E0(2),FF,IDAYOUT
        WRITE(2,2022)F0(3),E0(3),FF,IDAYOUT

        WRITE(6,2020)F0(1),E0(1),FF,F0(2),E0(2),FF,IDAYOUT
        WRITE(6,2022)F0(3),E0(3),FF,IDAYOUT

2020    FORMAT(6E12.3,I4,I3)
 2022   FORMAT(3E12.3,36X,I4,I3)
700     CONTINUE

 1331	if(jd .eq. intmon(im))then
		  INTSTR = INTSTR + INTEXT(IM)
		  GO TO 1100
		  endif

 1200		  CONTINUE
 1100		  CONTINUE
		  if(1.gt.0)stop
 555		  print *,' error'
        STOP
        END



