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

Problem with DLLs writing to the same file

jb1011
Beginner
468 Views
I built twoDLLs in Compaq Visual Fortran. The first DLL opensa file (e.g., open unit=12, file='out.txt') and writes several lines of text to it. The file out.txt is infact created and contains the correct output. The first DLL then calls the second DLL whichalso writes to unit 12.Instead of writing to out.txt as I would like,it creates/writes to a file named fort.12. Is there a way to ensure that when eachDLL writes tounit 12 they are writing to the same file (out.txt)?
Thanks in advance
Jean
0 Kudos
3 Replies
durisinm
Novice
468 Views
I don't think that the two DLLs are automatically aware of the files that each of them has open for I/O. Your second DLL may have to execute the same OPEN statement as the first one. Perhaps you could pass the logical unit number from the first to the second.

Mike D.
0 Kudos
Steven_L_Intel1
Employee
468 Views
You need to make sure that both DLLs are linked to the DLL form of the Fortran run-time libraries. (/libs:dll if you're using the command line.) Then it will work as you want.
0 Kudos
jb1011
Beginner
468 Views
Thanks Steve. I did verify that I was usingthe Fortran run-time libraries. Turns out that I had two problems: 1) mixing single- and multi-threaded DLLs, and 2) MCLS. Iwasbuilding the two DLLs separately - which seemed like the thing to do - and then have the first DLL use the second DLL. The problem was thateach DLLwas linked to the sameC library.In mycase, I wasableto combinethe two DLLs into one and now all of the output is written to the same file.
Jean
0 Kudos
Reply