- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes you can.
Note, however, that passing data as argument do NOT involve any copy of the memory (with some exceptions).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much!
How should I modify the following program?
module test
contains
subroutine readdata(n, x, y)
implicit none
integer n
real*8 x(n), y(n)
call outputdata(n, x, y)
end subroutine
subroutine outputdata(n, x, y)
implicit none
integer n
real*8 x(n), y(n)
integer i
do i=1, n
write(*, *) x(i), y(i)
enddo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As is, that does not make much sense, because it does notever define x and y.But for example:
module test
private
integer:: n
real(8), allocatable:: x(:), y(:)
public readdata
public outputdata
contains
!--------------------------------
subroutine readdata(sfilename)
implicit none
character(*):: sfilename
integer:: i
open(11,file=sfilename,action='read')
read(11, "(i4)") n
allocate(x(n), y(n))
do i=1,n
read(11,"(2f10.0)") x(i), y(i)
end do
close(11)
end subroutine readdata
!--------------------------------
subroutine outputdata()
implicit none
integer i
do i=1, n
write(*, *) x(i), y(i)
enddo
!--------------------------------
program
character(100):: sfilename
call getarg(1, sfilename)
call outputdata()
Message Edited by JugoslavDujic on 06-28-2004 02:01 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you again!
I know the data can be passed by file, but when the size of arrays is up to several million or more, it will waste much time to write and read data. Is there any way to make it possible to define an entrance for the module, then data passed from the entrance and shared by the module?
Sincerely,
Zhanghong Tang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, yes. I was just writing an illustration.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page