|
[Sponsors] |
November 21, 2001, 11:41 |
F90-question
|
#1 |
Guest
Posts: n/a
|
Dear all,
I have a question concerning F90, I hope, I it is allowed to answer such a question in this forum. I have the following simple program: module mytest implicit none integer,private :: n contains subroutine test print*,'test === ',n end subroutine test end module mytest C%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% program main use mytest implicit none integer :: n n = 10 print*,'main === ',n call test end program main How can I communicate n = 10 from the main program to the module? Is there an easy way to do this. I won't use a common block for n. Thaks in advance |
|
November 21, 2001, 14:10 |
Re: F90-question
|
#2 |
Guest
Posts: n/a
|
module mytest
implicit none !integer,private :: n contains subroutine test (n) integer, intent(in) :: n print*,'test === ',n end subroutine test end module mytest !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% program main use mytest implicit none integer :: n n = 10 print*,'main === ',n call test (n) end program main |
|
November 22, 2001, 01:36 |
Re: F90-question
|
#3 |
Guest
Posts: n/a
|
Thanks Peter
but this is not what I ment, In you suggestion the variabe n in the module is only known in the subroutine test. What I' d like to get is that n will be known in the whole module mytest. Matthias |
|
November 22, 2001, 02:09 |
Re: F90-question
|
#4 |
Guest
Posts: n/a
|
Write a subroutine set in module mytest:
subroutine set(nn) integer, intent(in) :: nn n=nn end subroutine set Hope this helps. Markus |
|
November 22, 2001, 02:23 |
Re: F90-question
|
#5 |
Guest
Posts: n/a
|
Thanks,
easy solution , but what happens if I have more than only one (say 100) of such variable to communicate from the program main to the module. There I need a subroutine set with a very long data exchange header Is this the only one solution? regards Matthias |
|
November 22, 2001, 03:12 |
Re: F90-question
|
#6 |
Guest
Posts: n/a
|
You could use an array or a type, e.g.:
type TestData integer :: par1,par2,par3 end type TestData subroutine set(data) type (TestData), intent(in) :: data par1 = data%par1 par2 = data%par2 par3 = data%par3 end subroutine set |
|
November 22, 2001, 03:18 |
Re: F90-question
|
#7 |
Guest
Posts: n/a
|
That looks fine !
Thanks Matthias |
|
November 22, 2001, 08:21 |
Re: F90-question
|
#8 |
Guest
Posts: n/a
|
Hi,
While I am here, does anyone know of an online forum that deals with fortran related questions for fluid flow problems or problems in general? Thanks. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Unanswered question | niklas | OpenFOAM | 2 | July 31, 2013 16:03 |
Hexadecimal and F90 | ganesh | Main CFD Forum | 0 | August 4, 2010 09:24 |
Makefile for f90 under unix | Jinwon | Main CFD Forum | 1 | September 22, 2007 05:10 |
CHANNEL FLOW: a question and a request | Carlos | Main CFD Forum | 4 | August 23, 2002 05:55 |
question | K.L.Huang | Siemens | 1 | March 29, 2000 04:57 |