Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using modules 1

Status
Not open for further replies.

dozer

Structural
Apr 9, 2001
502
US
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.

 
Replies continue below

Recommended for you

Try putting USE MAXIMUMS into your SI Module. That should fix your problem so you can use both.
 
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.
 
Thanks, Dan. I'll be able to sleep at night now.[thumbsup]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top