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.
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
RE: Using modules
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
Dan
RE: Using modules