Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: use module ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 19 Topic 8158 of 8767
Post > Topic >>

Re: use module to pass data between procedures

by nospam@[EMAIL PROTECTED] (Richard Maine) Apr 22, 2008 at 08:14 AM

Mike <SulfateIon@[EMAIL PROTECTED]
> wrote:

> On Apr 22, 5:03 pm, "Les" <l.neil...@[EMAIL PROTECTED]
> wrote:
> > "Mike" <Sulfate...@[EMAIL PROTECTED]
> wrote in message

> > > real,dimension(2) :: y
> >
> > You already have "y" available via the shared_data module
> > Remove this line.

> So I need to check every time, if I use a module to pass the data
> between procedures.  It's quite troublesome.
....
> But I think if I use named common to pass these data between
> procedures (I mean FCN), then I don't have to worry about if these
> data are declared twice.  Am I right?

No, you are not right. And I'm afraid I don't understand your comment
and objection to "needing to check". It is pretty much universally true
that you need to have some idea about what your variables are and where
they are comming from. You can't just put a declaration of y somewhere
and hope that will do something useful. No matter what mechanism you use
to communicate y, you need to know what mechanism you are using, and
then use that mechanism. I don't understand how that constitutes
"needing to check".

In any case, it is equally true of common that you can't declare the
same thing multiple times. If you have a common and all the associated
declarations (usually in an include file), then you can't go replicating
those declarations elsewhere in the same scope.

Modules are, in fact, far less error prone in this area. Note that you
got an error message from the compiler, and it pretty much said what was
wrong, albeit in a way that assumed the reader understood the issue. You
can't get the attributes of a variable from a module wrong. The fact
that you can't redeclare the attributes is exactly why you can't get
them wrong. All the attributes come from the module and the compiler
will ***** if you try to redeclare them.

With common, on the other hand, you have to redeclare them and there is
nothing to check that you got them right. In fact, there is the extra
debugging nastiness that getting one variable in a common wrong can
generate symptoms that show up in different variables. This is quite a
common problem (in both senses of "common") and is most often partly
addresed by putting all the declarations related to a common block in an
include file. But alas, even that doesn't protect you from all such
errors because there is no way to say that no other attributes can be
added outside of the include file. For example, if the variable is
supposed to be a scalar, there is nothing to keep a dimension statement
elsewhere from changing that, and the compiler won't be able to diagnose
the error in all such cases. (Having a personal policy against the use
of separate attribute specification statements like the dimension
statement would help, but the compiler won't enforce that.)

-- 
Richard Maine                    | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle           |  -- Mark Twain
 




 19 Posts in Topic:
use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-22 01:22:42 
Re: use module to pass data between procedures
Arjen Markus <arjen.ma  2008-04-22 01:36:33 
Re: use module to pass data between procedures
"A. Belli" <  2008-04-22 10:42:02 
Re: use module to pass data between procedures
"Les" <l.nei  2008-04-22 10:03:32 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-22 07:38:31 
Re: use module to pass data between procedures
nospam@[EMAIL PROTECTED]   2008-04-22 08:14:07 
Re: use module to pass data between procedures
"Les" <l.nei  2008-04-22 16:32:56 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-23 01:30:23 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-23 12:26:25 
Re: use module to pass data between procedures
nospam@[EMAIL PROTECTED]   2008-04-23 07:31:38 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-23 21:24:49 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 00:20:54 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 00:38:34 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-24 13:20:47 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-24 19:32:55 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-25 03:28:09 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-25 23:42:48 
Re: use module to pass data between procedures
Dave Seaman <dseaman@[  2008-04-26 15:13:03 
Re: use module to pass data between procedures
Mike <SulfateIon@[EMAI  2008-04-26 00:36:46 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Oct 11 12:47:52 CDT 2008.