CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Main CFD Forum

F90-question

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 21, 2001, 12:41
Default F90-question
  #1
Matthias
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
  Reply With Quote

Old   November 21, 2001, 15:10
Default Re: F90-question
  #2
peter
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

  Reply With Quote

Old   November 22, 2001, 02:36
Default Re: F90-question
  #3
Matthias
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
  Reply With Quote

Old   November 22, 2001, 03:09
Default Re: F90-question
  #4
Markus Lummer
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
  Reply With Quote

Old   November 22, 2001, 03:23
Default Re: F90-question
  #5
Matthias
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
  Reply With Quote

Old   November 22, 2001, 04:12
Default Re: F90-question
  #6
Markus Lummer
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

  Reply With Quote

Old   November 22, 2001, 04:18
Default Re: F90-question
  #7
Matthias
Guest
 
Posts: n/a
That looks fine !

Thanks Matthias
  Reply With Quote

Old   November 22, 2001, 09:21
Default Re: F90-question
  #8
J. Keays
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.
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 CD-adapco 1 March 29, 2000 04:57


All times are GMT -4. The time now is 16:49.