	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)
	dimension time(1464),pt1(1464),pt2(1464),pt3(1464),pt4(1464),
     *  pt5(1464),pt6(1464)

	 DATA INTMON/31,28,31,30,31,30,31,31,30,31,30,31/
	 DATA INTEXT/69,72,69,70,69,70,69,69,70,69,70,69/

	 INTSTR = 31000

	 IDAY = 0
	 time0=274. - (.5/24.)
	 iprot=1
	 DO 1100 IM=10,11

	    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
	  if(im.le.5)go to 1331
	  if(im.eq.6 .and. jd.le.18)go to 1331
	  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,24
           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=12
c	   IF(INTSTR.EQ.30109)JITOP=277
           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
           Pt1(iprot)=ph1(i)/yindx1
           Pt2(iprot)=ph2(i)/yindx2
           Pt3(iprot)=ph3(i)/yindx3
           Pt4(iprot)=ph4(i)/yindx4
           Pt5(iprot)=ph5(i)/yindx5
           Pt6(iprot)=ph6(i)/yindx6

	 if(iprot.eq.1)time(iprot)=time0 + (1./24.)
	 if(iprot.ne.1)time(iprot)=time(iprot-1) + (1./24.)
	 iprot=iprot+1
c          print *,' i=',i,' ph1=',ph1(i),' ph2=',ph2(i)
c          if(1.gt.0)stop
505     CONTINUE

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

 1200		  CONTINUE
 1100		  CONTINUE
c		  if(1.gt.0)stop
 555		  print *,' error'
		  print *,' Now do the writes'

		  write(3)time
		  write(3)pt1
		  write(3)pt2
		  write(3)pt3
		  write(3)pt4
		  write(3)pt5
		  write(3)pt6

        STOP
        END




