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

Coding in Fortran95

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

Reply
 
LinkBack Thread Tools Display Modes
Old   November 16, 2009, 17:59
Default Coding in Fortran95
  #1
New Member
 
Mohammad
Join Date: Jul 2009
Posts: 4
Rep Power: 8
Moradi is on a distinguished road
Hi,
I am doing coding. I use Fortran95.
I have some subroutines which contains optional arguments.
When I call them I can use "if () then" or "select case()" to choose whether assign data to these optional arguments or not. As I know even if I assign an undefined data (undefined array; e.g. an allocatable array which i not allocated) to these subroutines, program will not encounter any problem.
My question is: should I actually use a criterion (using "if" or "select case") when I assign data to these subroutines (for example: when I have an allocatable array I can use "if"; so, when the array is not allocated I will not assign it to the optional argument. But, is it necessary)?

Thanks so much.
Moradi is offline   Reply With Quote

Old   November 24, 2009, 13:31
Default
  #2
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 284
Rep Power: 9
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
generally, we set it to a default value ,such as 0 to avoid some zero.
ztdep is offline   Reply With Quote

Old   November 24, 2009, 13:53
Default Hi
  #3
New Member
 
Mohammad
Join Date: Jul 2009
Posts: 4
Rep Power: 8
Moradi is on a distinguished road
Quote:
Originally Posted by ztdep View Post
generally, we set it to a default value ,such as 0 to avoid some zero.

First of all, thanks for giving me some comments.
Yes, that is right. But, what if this variable (an array) is not allocated (if I can ignore allocation of an unnecessary array , I can save the memory[assume I am solving for laminnar flow. So, alocation of turbulence related variables will be unnecessary]). My question actually is about such cases.
Thanks so much Ztdep
Moradi is offline   Reply With Quote

Old   November 24, 2009, 20:57
Default
  #4
Senior Member
 
ztdep's Avatar
 
p ding
Join Date: Mar 2009
Posts: 284
Rep Power: 9
ztdep is on a distinguished road
Send a message via Yahoo to ztdep Send a message via Skype™ to ztdep
if(Solve Turbulent) then
Allocate( Turbulent related variables )
Else
Allocate( laminar flow related variables
endif
ztdep is offline   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
Varibales for user coding Tomo STAR-CCM+ 3 September 10, 2009 03:49
Help with coding James Main CFD Forum 2 May 18, 2005 05:12
Coding begineer of cfd Main CFD Forum 1 July 21, 2004 05:11
Ground coding enquiry Wenqing Zhang Phoenics 2 August 12, 2002 11:56
User coding on NT w2k Philip Jones CD-adapco 0 November 26, 2001 04:43


All times are GMT -4. The time now is 06:01.