- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I don't know how to solve the following problem:
In the main program I call a subroutine contained in a Fortran DLL ('HAPauto'), which in turn calls another DLL that performs calculations and prints a lot of data to the screen (command-line console).
I'd like to redirect its output to an external file. I have tried to set the FOR_PRINT environmental variable (see commented statements below), but it doesn't affect the DLL's behavior. Here is my basic code:
PROGRAM main
!DEC$ ATTRIBUTES DLLIMPORT :: HAPauto
!DEC$ ATTRIBUTES ALIAS:'HAPauto' :: HAPauto
! USE IFPORT
! LOGICAL res
! res = SETENVQQ('FOR_PRINT=HAPresults.dat')
CALL HAPauto
END PROGRAM MAIN
Thank you very much for any suggestions.
Alessio
P.S. Intel Visual Fortran Compiler Version 10.1.011
I don't know how to solve the following problem:
In the main program I call a subroutine contained in a Fortran DLL ('HAPauto'), which in turn calls another DLL that performs calculations and prints a lot of data to the screen (command-line console).
I'd like to redirect its output to an external file. I have tried to set the FOR_PRINT environmental variable (see commented statements below), but it doesn't affect the DLL's behavior. Here is my basic code:
PROGRAM main
!DEC$ ATTRIBUTES DLLIMPORT :: HAPauto
!DEC$ ATTRIBUTES ALIAS:'HAPauto' :: HAPauto
! USE IFPORT
! LOGICAL res
! res = SETENVQQ('FOR_PRINT=HAPresults.dat')
CALL HAPauto
END PROGRAM MAIN
Thank you very much for any suggestions.
Alessio
P.S. Intel Visual Fortran Compiler Version 10.1.011
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Most likely the fix is to set the main program project property Fortran > Libraries > Use Runtime Library to "Multithreaded DLL". If you don't do this, opening a file in the main program won't be recognized in the DLL.
However... If the DLL does PRINT, you can't, in 10.1, open the unit for PRINT, so that may not help. I think that the FOR_PRINT test happens before your main program runs.
Can you change the DLL to WRITE to unit 6? Then you can open unit 6 and the DLL will use it.
However... If the DLL does PRINT, you can't, in 10.1, open the unit for PRINT, so that may not help. I think that the FOR_PRINT test happens before your main program runs.
Can you change the DLL to WRITE to unit 6? Then you can open unit 6 and the DLL will use it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Steve,
thank you for your prompt reply. I have tried to use the "Multithreaded DLL" option, but unfortunately your prediction was correct: it didn't help.
I cannot change the DLL to WRITE to unit 6. It's legacy code that I was given, so I guess I don't have any other viable options, right...?
Which compiler version should I have to be able to open the unit for PRINT?
Thank you again.
Alessio
thank you for your prompt reply. I have tried to use the "Multithreaded DLL" option, but unfortunately your prediction was correct: it didn't help.
I cannot change the DLL to WRITE to unit 6. It's legacy code that I was given, so I guess I don't have any other viable options, right...?
Which compiler version should I have to be able to open the unit for PRINT?
Thank you again.
Alessio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you rebuild the DLL using 11.1? If you can, and add /assume:noold_unit_star, then if you open unit 6 in the main program, the DLL will use unit 6 for the PRINT. You will need to build the main with Multithreaded DLL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I will see if I can manage to go this way.
Thanks a lot for your excellent support.
Alessio
Thanks a lot for your excellent support.
Alessio

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