Demo entry 6647004

f90

   

Submitted by xie on Oct 18, 2017 at 17:44
Language: Fortran. Code size: 1.5 kB.

program main
implicit none
    real(kind=8):: eps=1e-10,vt
    integer :: i,j,k=1
    real,dimension(3,3):: a
    real,dimension(3,1):: v0
    real,dimension(100,3):: v,vv        !vvÊý×éÖдæ·Åvi/v(i-1)µÄÖµ
    real,dimension(3):: vveps           !vvepsÊý×éÖдæ·Åvvi-vv(i-1)µÄÖµ£¬ÓÃÒÔ¼ì²éÊÕÁ²¹ý³Ì
    data a /1,1,0.5,1,1,0.25,0.5,0.25,2/
    data v0 /1,1,1/
    data v /300*0/
    data vv /300*0/
    data vveps /3*100/
    do while((vveps(1)>eps).or.(vveps(2)>eps).or.(vveps(3)>eps).or.(k<101))
        do i=1,3
            do j=1,3
                v(k,i)=v(k,i)+a(i,j)*v0(j,1)
            end do
        end do
        do i=1,3
            v0(i,1)=v(k,i)
        end do
        if(k>=2)then
            do i=1,3
                vv(k,i)=v(k,i)/v(k-1,i)
            end do
        end if
        if(k>=3)then
            do i=1,3
                vveps(i)=vv(k,i)-v(k-1,i)
            end do
        end if          !Èç¹ûÒ»Ö±ÕâÑùËãÏÂÈ¥£¬»áÒòΪvÊý×éÀïÃæµÄֵ̫´ó¶ø·¢ÉúÒç³ö£¬ËùÒÔÒª½øÐйæÒ»»¯´¦Àí
        if(max(v0(1,1),v0(2,1),v0(3,1))>10000)then  !½øÐйæÒ»»¯´¦Àí£¬·ÀÖ¹Êýֵ̫´ó·¢ÉúÒç³ö£»k=29µÄʱºòµÃµ½ÁË×îºóµÄ½á¹û
            vt=max(v0(1,1),v0(2,1),v0(3,1))
            v0(1,1)=v0(1,1)/vt
            v0(2,1)=v0(2,1)/vt
            v0(3,1)=v0(3,1)/vt
        end if
        k=k+1
    end do

    do i=1,k-1
        write(*,*) i
        write(*,*) v(i,1),v(i,2),v(i,3)
        write(*,*) vv(i,1),vv(i,2),vv(i,3)
    end do

end program

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).