program PWREFIND C Calculating averages integer RD,rns,runs,ILAT,ILON,kgit,nvar PARAMETER (runs=10) PARAMETER (ILAT=36) PARAMETER (ILON=64) parameter (kgit=56) parameter (nvar=3) real, dimension(ILAT,ILON,kgit,nvar)::aus,rea real, dimension(runs,ILAT,ILON,kgit,nvar)::aus1 character fileout*80 integer prog CHARACTER*1 jfilein(10) c=========================input file & computing area==================================== fileout = 'test.dat' open(20,file=fileout) DATA jfilein/'0','1','2','3','4','5' &,'6','7','8','9'/ c================== DATA OUTPUT ================================= open (71,status='unknown',form='unformatted',file= + 'uvt400_Mar_eQBO.dx', access='direct', + recl=nvar*ILON*ILAT*kgit*4) do rns = 1,runs RD = rns+20 OPEN(RD,FILE= &"../../Muam_Mar_eQBO/" //jfilein(rns)// "/uvt400_Mar_eQBO.dx", $ form='unformatted', $ access='direct', status='old',recl=nvar*ILON*ILAT*kgit*4) print*,"open: ../" //jfilein(rns)// "/uvt400_Mar_eQBO.dx" end do DO prog = 1,1201 print*,"step: ", prog c================== INPUT ================================= do rns = 1,runs RD = rns+20 read(RD,rec=prog) rea do p=1,nvar do j=1,ILAT do h=1,kgit do i=1,ILON aus1(rns,j,i,h,p)=rea(j,i,h,p) end do end do end do end do enddo c================================================================ do p=1,nvar do j=1,ILAT do h=1,kgit do i=1,ILON do rns = 1,runs aus(j,i,h,p)=aus(j,i,h,p)+aus1(rns,j,i,h,p)/runs end do end do end do end do end do write(71,rec=prog) aus do p=1,nvar do j=1,ILAT do h=1,kgit do i=1,ILON aus(j,i,h,p)=0. do rns = 1,runs aus1(rns,j,i,h,p)=0. end do end do end do end do end do END DO c============reset all, close all etc ============================== do rns = 1,runs RD = rns+20 close(RD) end do close(71) print*,'Processing completed! ' print*,'Open your output files! ' STOP END *************************************************************************