tags:

views:

53

answers:

1

how to globalize a dummy argument from a function call?

I have below code in fortran

A(a,b)  // here a and b are the values filling from function call but they are not declared any where
.
.
.
B(a.b) // same variable passing again to this function call also.

here the problem is the values from a and b are not maintaining for second call. its returning a garbage. Even i tried this using common but its not accepting to globalize dummy arguments. how to do it?

Thanks in advance

+1  A: 

You say that "a and b are the values filling from function call but they are not declared anywhere" - even though I'm still trying to figure out exactly what you're trying to do, this statement throws up all sorts of red flags. This is Fortran - you need to declare them (see note).

I'm not clear on what you're trying to accomplish - chances are, though, "globalize" isn't what you want to do - we should be striving to eliminate global variables in our code.

Note: Yes, Fortran (or really, FORTRAN) supports implicit declaration of variables. However, this is a relic from the days of punch cards and dumb terminals. Do Not use implicit typing anywhere - your code should always include implicit none, and you should declare your variables appropriately.

Tim Whitcomb
They dropped the all caps spelling sometime around Fortran 77.
dmckee
Yes they did - what I was trying to say is that even though more modern Fortran might still support implicit declaration, it's linked in my mind to the obsolete style. All-caps spelling is for older versions of the language - so is fixed-formatting, computed GOTO statements, and implicit declarations.
Tim Whitcomb