Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Question!


Name: kardgar
Title:
  simple
Question:
result for this program is just nan
Answers:

Name: and this is it
program hello
   Print *, "Hello World!"
   implicit none
        real  di1,di2,di3,dis,fx,fy,fz,x(1000,2),y(1000,2)
        real teta(1000,2),rand1,rand2,rand3,rand4,rand5,rand6,z(1000,2)
        real r(1000,2),sx,sy,sz
        integer j,s,o,i
        sx=0
        sy=0
        sz=0
        do i=1,1000
          do o=1,2
            call random_number(rand1)
            call random_number(rand2)
            call random_number(rand3)
            call random_number(rand4)
            call random_number(rand5)
            call random_number(rand6)
            z(i,o)=rand1*0.2
            r(i,o)=(rand2*0.04) 0.01
            teta(i,o)=rand3
            x(i,o)=r(i,o)*cos(teta(i,o)*6.28)
            y(i,o)=r(i,o)*sin(teta(i,o)*6.28)
            !vx(i,o)=rand4
            !vy(i,o)=rand5
           ! vy(i,o)=rand6
           !print*,x(i,o),y(i,o),z(i,o)
          end do
        end do
          print*,'start'
          
            do j=1,1000
                do s=1,2


                  if(i/=j .or. 1/=s)then
                    di1=(x(1,1)-x(j,s))**2
                    di2=(y(1,1)-y(j,s))**2
                    di3=(z(1,1)-z(j,s))**2
                    dis=(di1 di2 di3)
                    !print*,di1,di2,di3,dis
                    if(s==1)then
                      fx=(di1**0.5)/(dis**1.5)
                      fy=(di2**0.5)/(dis**1.5)
                      fz=(di3**0.5)/(dis**1.5)
                    else
                      fx=-(di1**0.5)/(dis**1.5)
                      fy=-(di2**0.5)/(dis**1.5)
                      fz=-(di3**0.5)/(dis**1.5)
                    endif
                    !print*,fx,fy,fz
                    sx=sx fx
                    sy=sy fy
                    sz=sz fz
                    print*,sx,sy,sz
                  endif
                  !print*,sx,sy,sz

                end do
              end do
              !print*,sx,sy,sz
              print*,'end'
end program Hello