|
我想把输出的数据进行排序,当Zr=2,4,6,8,10时所对应的ref的最小值,以及所对应的daltf的值显示出来,求指导,谢谢,底下是我自己编的一个排序的子程序,可以运行,但是不能输出!
program tu11
implicit none
real*8 A,B,C,D,Z0,Zi
real*8 E,H,ref
real*8 A2,A3,A4,As,Al,A1
real,parameter::pi=3.14159
character(len=80)::filename="data.txt"
integer,parameter::fileid=10
real*8::Zr=0.0
integer k
real*8::daltf=0.0
integer i
integer,parameter::n=int(0.35/0.0001)
common /group1/Zi
common /group2/Z0
!!!!!!!!!
Z0=50.0
Zi=-3.0
!Zr=2.0
!!!!!!!!
open(10,file="data.txt")
do i=1,n
daltf=daltf+0.0001
do k=1,5
Zr=Zr+2.0
call Get_ref(daltf,A1,A2,A3,A4,Zr,E,H,ref)
write(*,"('Zr:'F8.5,'ref:'F8.5,'daltf:'F8.5)")Zr, ref,daltf
call selection_sort(ref,k,n)
write(*,"('Zr:'F8.5,'ref:'F8.5,'daltf:'F8.5)")Zr, ref,daltf
write(10,"('Zr:'F8.5,'ref:'F8.5,'daltf:'F8.5)")Zr,ref,daltf
end do
close(fileid)
stop
end
!!!paixu
subroutine selection_sort(ref,n)
implicit none
integer n
real*8 ref(n)
integer m,l
real*8 min
real*8 temp
do m=1,n
min=ref(m)
do l=m+1,n
if(min>ref(l)) then
temp=ref(l)
ref(m)=temp
min=ref(m)
end if
end do
end do
return
end
|
|