program Sort_N_data implicit none integer :: N , a , I , J real , allocatable , dimension (:) :: di_date(:) real*8 :: data1 , temp character(50) :: filename write(*,*) " OPEN File Name =? EX.(date.dat, ... etc) " read(*,*) filename open (unit=20 ,file=filename,status='OLD') open (unit=30 ,file='date3.dat',status='REPLACE') read(20,*) N write(30,*)N write(*,*)N allocate(di_date(N)) a=1 do a = 1 , N read(20,*) data1 di_date(a)=data1 end do do I=N-1 , 1 , -1 do J= 1, I if (di_date(J) < di_date(J+1)) then temp=di_date(J) di_date(J)=di_date(J+1) di_date(J+1)=temp end if end do end do I=1 do I =1, N write(*,*) di_date(I) write(30,*) di_date(I) end do deallocate (di_date) close(20) close(30) write(*,*)"SAVE in 'date3,dat' " stop end program Sort_N_data