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

Redirecting Fortran DLL's output to an external file

ale_a
Beginner
584 Views
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
0 Kudos
4 Replies
Steven_L_Intel1
Employee
584 Views
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.
0 Kudos
ale_a
Beginner
584 Views
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
0 Kudos
Steven_L_Intel1
Employee
584 Views
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.
0 Kudos
ale_a
Beginner
584 Views
I will see if I can manage to go this way.

Thanks a lot for your excellent support.

Alessio
0 Kudos
Reply