Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Using modules

Bill_Doss
Beginner
490 Views
I hope this is the okay place to ask this. (As I mentioned in another thread I'm relearning Fortran after many years of coding in other languages.)

I have a question about using modules. I'm translating code from Matlab to Fortran. The original Matlab code has several structures ("struct") that lend themselves to being encapsulated in Fortran modules. Some of these structs have fields that are other structs. I know that one module can "use" another. Are there any concerns, issues, gotcha's etc. when doing this?

Thanks times a million!!

Bill

0 Kudos
2 Replies
Steven_L_Intel1
Employee
490 Views
No - other than you can't change the attributes of something declared in a module you USE. Wouldn't it make more sense to group all of the "structs" (derived types in Fortran-speak) in as single module? It would be unnatural to have many modules each with only one or two declarations in it, not to mention as maintenance nightmare.

You certainly can use one derived type in another.
0 Kudos
Bill_Doss
Beginner
490 Views
Thanks Steve ... I will try to keep the number of modules to a minimum. Really the only reason that I would have more than one is that I'd want to separate derived types in terms of their function or their place in the overall process (e.g. input or output related derived types, derived types associated with process step 1, ...)
Bill
0 Kudos
Reply