- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a FORTRAN DLL application that performs a prolonged series of calculations. To give feedback to the user, we opened a console screen and printed messages on the routines progress. This code has worked great under Windows 7 but now under Windows 10, we're having an issue with the data files remaining locked after the DLL routine finishes.
After the DLL routine finishes, data files that are accessed by the DLL remain locked and can't be opened by the program used to call the DLL. The parent program is an old VB6 application. If we get rid of the console calls in the DLL, then the files are not locked and the parent program can access them just fine.
The code we used to start the console, write data, and close it was adapted from your article: "Code Samples for Console Use", e.g.:
USE IFWIN
! Allocate a console
status = AllocConsole() ! get a console window of the currently set size
fhandle = GetStdHandle(STD_OUTPUT_HANDLE)
! Executable code to set console window size
sr.top = 0
sr.left = 0
sr.bottom = 23 ! <= console buffer height -1
sr.right = 80 ! <= console buffer width -1
lstat = SetConsoleWindowInfo(fhandle, .TRUE., sr)
! Set a console buffer bigger than the console window. This provides
! scroll bars on the console window to scroll through the console buffer
! Set buffer size variables
lengthCON = 80
lines = 25
wpos.x = lengthCON ! must be >= currently set console window line length
wpos.y = lines ! must be >= currently set console window number of lines
lstat = SetConsoleScreenBufferSize(fhandle, wpos)
etc...
CLOSE(11,ERR=9199,IOSTAT=IOstat11)
CALL SLEEPQQ(1500)
status = FreeConsole()
RETURN !******* Normal Return for Quick Solution
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried this type of stuff years ago and just got frustrated - why not just do a screen write every few seconds to let them know it is going
a good on is '.' and let it progress across the screen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't reproduce this. I used the attached sources, and tested it first without the close so I could see the error. I then put the close back in. Runs fine on Win7 and Win10.
ifort /dll fdll.f90
ifort /winapp /libs:dll U611586.f90 fdll.lib
U611586.exe
Please provide a small but complete test case I can use.

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