×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Using modules

Using modules

Using modules

(OP)
I'm want to incorporate a parameter declared in one module in another module.  Here's a code snippet then I'll explain more.

MODULE MAXIMUMS
    INTEGER, PARAMETER :: MAXSTRUTS = 8000
END MODULE

MODULE SI
  TYPE STRUT_INFO
    INTEGER HUB_POSITION
    REAL SS(2)
  END TYPE
END MODULE

PROGRAM EXAMPLE

USE MAXIMUMS
USE SI
TYPE(STRUT_INFO), DIMENSION(MAXSTRUTS) :: ST ! I would like to put this in MODULE SI but since it uses "MAXSTRUTS" the compiler complains.
.
.
.
END EXAMPLE

I would like to just say "USE SI" and have the derived type ST be declared within that module. Is there anyway I can do this? Before you say just meld MAXIMUMS and SI together in one module you need to understand that I use MAXIMUMS all over the place (and it's actually has a lot more parameters in it, I just shortened it for this example) and I use SI in only a few places.

Yes, I can leave it as is but I'm basically lazy.  Every time I say USE SI and don't want to have to remember to declare ST.

Any ideas would be appreciated.

RE: Using modules

Try putting USE MAXIMUMS into your SI Module.  That should fix your problem so you can use both.  

RE: Using modules

(OP)
Thanks writhziden.  I wrongly assumed that since MAXIMUMS was defined first, I could use parameters declared in it in subsequent modules.  That, as I said, didn't work.

Your tip did the trick though.  It's so obvious now that I see it that I feel kind of silly.

Here's another question. If I put USE MAXIMUMS in the SI module and then in a program unit I say:

USE MAXIMUMS
USE SI

Is any harm done since you've essentially told it to use MAXIMUMS twice? I tried it with a simple program that assigned a value to st(1)%ss(1) and then printed it and it worked fine.

RE: Using modules

That should work just fine.

Dan   

RE: Using modules

(OP)
Thanks, Dan.  I'll be able to sleep at night now.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close