- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a DLL that calls routines from a second DLL. I know I can use THREADPRIVATE to make each threads call to the first DLL use different datasets. But can have the second DLL that is called from the first DLL have different code for each thread? I really want to be able to compile a different set of source on the fly, for each thread, and have it use the dll created in that thread use the newly created source.
Each thread should also be able to use the same unit numbers for different input and output files.
Anyone done this, or is it not possible?
Thanks!
Dave
Each thread should also be able to use the same unit numbers for different input and output files.
Anyone done this, or is it not possible?
Thanks!
Dave
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For different code in the one DLL just have a different procedure. perhaps selected via a procedure pointer or a SELECT CASE construct, but...
You are not going to be able to compile to a DLL that is already loaded on the fly - the operating system locks the files that back an executable module (a DLL or EXE') when the module is loaded. You would either need to unload the DLL (which means no threads can be executing code in the DLL), recompile it, then reload it. This sounds like a nightmare with multiple threads.
A "better" option might be to compile to a differently named DLL - each thread has its own uniquely named DLL. Then each thread can compile/load/unload without worrying what other threads are up to.
Your requirement for unit numbers means that you'd effectively need to have separate instances of the fortran runtime for each DLL (and another one for the parent EXE/DLL). This is another source of chaos. I think a better idea would be to have centrally coordinated assignment of unit numbers for each thread and then have the relevant unit numbers passed down as arguments to procedure calls.
You are not going to be able to compile to a DLL that is already loaded on the fly - the operating system locks the files that back an executable module (a DLL or EXE') when the module is loaded. You would either need to unload the DLL (which means no threads can be executing code in the DLL), recompile it, then reload it. This sounds like a nightmare with multiple threads.
A "better" option might be to compile to a differently named DLL - each thread has its own uniquely named DLL. Then each thread can compile/load/unload without worrying what other threads are up to.
Your requirement for unit numbers means that you'd effectively need to have separate instances of the fortran runtime for each DLL (and another one for the parent EXE/DLL). This is another source of chaos. I think a better idea would be to have centrally coordinated assignment of unit numbers for each thread and then have the relevant unit numbers passed down as arguments to procedure calls.

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