On 4=D4=C223=C8=D5, =CF=C2=CE=E74=CA=B155=B7=D6, wangning16...@[EMAIL PROTECTED]
> I had already produce an open file with data in the main program, but
> I want to use the data in the file in the subroutine. However,it seems
> didn't use when I call it. I don't know what's wrong,please help me!
> Thank you very much!
>
> subroutine get_trio
>
> .......
>
> open(111, file=3D"surf_111_3.dat")
> open(112, file=3D"random.dat")
>
> do i=3D1,200
> read (111,*) k, posx(i),
> posy(i)
> end do
>
> read(111,*) a
> do i =3D1, 25
> write (112,"(25( i3,f6.1,f6.1))") a(i), posx(a(i)), posy(a(i))
> end do
>
> .......
> do i =3D 1, n
> do j =3D i + 1, n
> rxij =3D posx(a(i)) - posx(a(j))
> if (abs(rxij) .gt. l/2) then
> rxij =3D l - abs(rxij)
> end if
> ryij =3D posy(a(i)) - posy(a(j))
> if (abs(ryij) .gt. l/2) then
> ryij =3D l - abs(ryij)
> end if
> disij =3D sqrt(rxij**2 + ryij**2)
> ......
> It said that a scalar-valued expression is required in this context.
I think it is better to write like this:
Module Constants
implicit none
public
integer,parameter:: file_handle=3D11,file_handle2=3D12 ! you can add more
parameter file handle here
character(len=3D*), parameter :: file_name, file_name2 ! you can add
more parameter names here
End module Constants
!------------------------
program main
implicit none
=2E...
open(unit=3Dfile_handle,file=3Dfile_name)
open(unit=3Dfile_handle2,file=3Dfile_name2)
=2E..
call subr()
=2E..
close(file_handle)
close(file_handle2)
end
!--------------------
subroutine subr(a,b,...)
implicit none
=2E..
=2E..
write(unit=3Dfile_handle,fmt=3D...)a,b.....
=2E...
End subroutine subr


|