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

SETENVQQ in C++/CLI/Fortran program

Nick2
New Contributor I
716 Views
I'm just curious - how does SETENVQQ work? What interests me in particular is callingSETENVQQ("FOR_DISABLE_DIAGNOSTIC_DISPLAY=T") frommy Fortran DLL.

The important piece of info is that I'm using C++/CLI in VS2008to interface with the Fortran dll - there seems to be quite a few problems with this combo.

If I use SETENVQQ in a x64 configuration, it works great.

If I use SETENVQQ in a Win32 configuration, it doesn't work. Instead, I have to do this:

[cpp]	int iRetVal;
	iRetVal=_wputenv_s(L"FOR_DIAGNOSTIC_LOG_FILE",szTracebackFile); //iRetVal 0 means OK
	iRetVal=_wputenv_s(L"FOR_DISABLE_DIAGNOSTIC_DISPLAY",L"T"); //iRetVal 0 means OK
	//_wputenv_s(L"TBK_ENABLE_VERBOSE_STACK_TRACE",L"F");
	iRetVal=SetEnvironmentVariableW(L"FOR_DIAGNOSTIC_LOG_FILE",szTracebackFile); //iRetVal 0 means not OK
	iRetVal=SetEnvironmentVariableW(L"FOR_DISABLE_DIAGNOSTIC_DISPLAY",L"T"); //iRetVal 0 means not OK
[/cpp]


Then I load my .dll, which in turn loads the Intel libraries. This works evenif I don't subsequently callSETENVQQ. (For the sakes of completeness, I've been testing with divide-by-zero crashes, after setting the appropriate FPflags).
0 Kudos
3 Replies
Steven_L_Intel1
Employee
716 Views
As far as I know, it just calls C's "setenv" to set the variable in the current process. If the Fortran support library DLL loads before you call SETENVQQ, then it may not have the effect you desire.
0 Kudos
Nick2
New Contributor I
716 Views

I did call SETENVQQ from the Fortran .dll, so the Fortran library would have to beloaded when I called SETENVQQ.

One unusual thing I noticed though, 2 hours into stepping through Win32(dis)assembly - it seemed like Fortran runtime had its own copy of the _environstrings. Does that sound right?

0 Kudos
Steven_L_Intel1
Employee
716 Views
I am not familiar with the internals of the C++ libraries, but this might make sense. The Fortran DLL libraries statically link the C++ libraries - we had to do this to make it work with all three VS versions.
0 Kudos
Reply