- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
You certainly can use one derived type in another.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page