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

getenv

jansson
Beginner
1,080 Views

Hi,

I use Windows 7 x64 and Intel CPU.

When I use getenv or getenvqq to "read" enviromental variables I get the same answer if I use

iret=GETENVQQ('programfiles(x86)',line2)

and

iret=GETENVQQ('programfiles',line2)

but if I check my settings with "set" in the cmd.exe I see both

ProgramFiles=C:\\Program Files
ProgramFiles(x86)=C:\\Program Files (x86)

How do I find the 64 bit folder?

Cheers

Magnus

0 Kudos
4 Replies
jansson
Beginner
1,080 Views

Here is a exampel:

file foo.for

--

program foo
use ifport
integer length
parameter(length=100)
character*(length) line,line2
! check if programfiles set
line=' '
call getenv('ProgramFiles',line)
write(*,*)'ProgramFiles=',line
! check if programfiles(x86) set
line2=' '
call getenv('ProgramFiles(x86)',line2)
write(*,*)'ProgramFiles(x86)=',line2
end program foo

--

I compile like this:

cmd.exe->"c:\Program Files (x86)\Intel\Compiler\11.0\075\fortran\bin\IA32\ifort" foo.for /out:foo.exe

my output running this program.

cmd.exe>foo.exe
ProgramFiles=
C:\Program Files (x86)


ProgramFiles(x86)=
C:\Program Files (x86)

Cheers/Magnus

0 Kudos
Steven_L_Intel1
Employee
1,080 Views
You will see that only if running a 64-bit application.
0 Kudos
jansson
Beginner
1,080 Views

Thanks Steve. I compiled for intel64 and got what I expected.

cmd.exe->foo.exe
ProgramFiles=
C:\Program Files


ProgramFiles(x86)=
C:\Program Files (x86)

What is the rationale behind this I wonder. Making it harder to call/find/run 64bit programs from 32bit ones.

Cheers/Magnus

0 Kudos
Steven_L_Intel1
Employee
1,080 Views
This is the way Windows does it. For the "WoW" environment where 32-bit programs run on an x64 system, there is an entire "hidden" registrty tree for environment variables. The idea is to make 32-bit programs believe that they are on a 32-bit system. There may be another way to do this with Win32 API calls.
0 Kudos
Reply