- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you give me a hint on how to open a file in the MODULE in order to share a content of the file as the constants through the USE?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not sure what you want to do - would you please try to explain it a different way or in more detail? Feel free to show a fake program that tries to do what you want.
You can open a file in a module procedure and perhaps read the contents into a module variable that can be made available by USE, but you would have to write the procedure that does this - there isn't a way to automatically turn file contents into variables or especially constants.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know that the following code is not correct. But it’s as an example of what I want. I am looking for a hint on how to do something like that. I would not like to use the COMMON blocks and the OPEN statements in the subroutines. I was trying to make my question clear.
MODULE BIO_CONSTANTS
OPEN(UNIT=10 ...) BIO ...
...
END MODULE BIO_CONSTANTS
PROGRAM BIOTA
SUBROUTINE ABIOTA (...)
USE BIO_CONSTANTS
...
SUBROUTINE BBIOTA (...)
USE BIO_CONSTANTS
...
SUBROUTINE CBIOTA (...)
USE BIO_CONSTANTS
...
SUBROUTINE DBIOTA (...)
USE BIO_CONSTANTS
...
...
END PROGRAM BIOTA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You would have to write a procedure in the module that opens the file and reads the values into module variables. Then the subroutines could USE the module and access the variables. You would also have to add a call to the new procedure at the start of the program. Note that these would not be "constants" - they would be ordinary variables. You could give the variables the PROTECTED attribute that would make it difficult for the subroutines to modify the data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. I will try to do it.

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