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

findfileqq issue

acar
Beginner
1,042 Views
I'm having problems getting findfileqq to work as I understand from the documentation that it should. I have firstly created an environment variable AAAA which points to c:\\ and then run the following commands:
character(256)::path
integer::iret
iret=findfileqq("ifcom.lib","AAAA",path)
iret=findfileqq("acrord32.exe","AAAA",path)
iret=findfileqq("notepad.exe","AAAA",path)
The first call to findfileqq works fine and returns:
path=c:\\program files\\intel\\compiler\\11.1\\054\\lib\\ia32\\ifcom.lib
but the second call returns iret=0 indicating that no file has been found even though it does exist in the following location:
c:\\program files\\adobe\\reader 9.0\\reader\\acrord32.exe
The third call works fine as well. I've also tested the function out on other files under c:\\temp which exist but are not found.
Am I missing a trick?
0 Kudos
10 Replies
anthonyrichards
New Contributor III
1,042 Views
AAAA must be an environment variable that contains the path to be searched. Try using 'PATH'
0 Kudos
acar
Beginner
1,042 Views
Have done but no change - acrord32.exe not found and then ifcom.lib found?
0 Kudos
acar
Beginner
1,042 Views
I have defined AAAA as an environment variable pointing to c:\. Tried using PATH but got the same result?
0 Kudos
Les_Neilson
Valued Contributor II
1,042 Views
According to the help, the second argumentis the name of"an environment variable" containing the path to be searched.
So if your "AAAA" is not an environment variable then the file (first argument) wont be found.

Example

USE IFPORT
CHARACTER(256) pathname
INTEGER(4) pathlen
pathlen = FINDFILEQQ("libfmt.lib", "LIB", pathname)
WRITE (*,*) pathname
END


Les
0 Kudos
anthonyrichards
New Contributor III
1,042 Views
If you have defined a path environment variable AAAA, then your results indicate that it does not contain within it the folder where acrord32.exe exists, or acrord32.exe is not found.

Findfileqq would appear to be not much use in finding the file concerned, if indeed it does exist on your system, because for it to'work' you must already have an environment variable (here AAAA) that contains the folder where you expect to find the file.

What this means is findfileqq("filename.ext", "path", string) will only tell you whether or not "path" contains the folder in which "filename.ext" exists. not whether the 'filename.ext" file exists on your system.

Apparently, according to my tests, the windows system folder "c:\windows\system32" is automatically searched, even though it may not be explicitly specified in the environment variable "PATH". That is where "notepad.exe" is located and so it is likely always to be found.
0 Kudos
Les_Neilson
Valued Contributor II
1,042 Views
I don't think the search is recursive. So if the file is not int the C:\ (i.e. root) directory it still won't be found.

Note the environment variable can be a concatenated list of lib directories

e.g. LIB=c:\path1\lib;c:\path2\lib;c:\path3\subpath\lib

etc
Les
0 Kudos
acar
Beginner
1,042 Views
But I have created AAAA as a system environment variable pointing to c:\ via the Windows Control Panel. I've just done some testing and it seems that whatever I put into the second parameter (varname in the documentation) the ifcom.lib is found - I even made it null ("") and it worked. Seems very odd to me?
0 Kudos
GVautier
New Contributor III
1,042 Views
Check if the files that can be found are in a directory contained in the PATH.

May be the function search in the PATH AND the path defined in the given environment variable.
0 Kudos
anthonyrichards
New Contributor III
1,042 Views
On my system, the following console program:
[bash]
Program test
use dflib
character(256)::path, envpath
integer::iret
!
iret=getenvqq("path",envpath)
print *, "ENVIRONMENT PATH=",TRIM(ENVPATH)
!
iret=findfileqq("notepad.exe","path",path)
Print *,"FOUND PATH=", TRIM(path), " (found NOTEPAD.EXE folder OK, even though absent from PATH)"
Print *
!
! use default environment path
iret=findfileqq("ifcom.lib","path",path)
Print *,"FOUND PATH=", TRIM(path), " (did not find IFCOM.LIB folder...)"
!
! add to default path
iret=setenvqq("path=%path%;C:Program FilesIntelComposerXE-2011compilerlibia32")
iret=findfileqq("ifcom.lib","path",path)
Print *,"FOUND PATH=", TRIM(path), " (found IFCOM.LIB folder OK)"
Print *
!
! use default environment path
iret=findfileqq("acrobat.exe","path",path)
Print *,"FOUND PATH=", TRIM(path), " (did not find ACROBAT.EXE folder...)"
!
! add to default path
iret=setenvqq("path=%path%;C:Program Filesadobeacrobat 9.0acrobat")
iret=findfileqq("acrobat.exe","path",path)
Print *,"FOUND PATH=", TRIM(path), " (found ACROBAT.EXE folder OK)"
!
pause
end[/bash]
gives the following output

[bash] ENVIRONMENT PATH=
 C:Program FilesMicrosoft Visual StudioCommonMsdev98BIN;C:Program FilesIn
 telComposer XE 2011 SP1redistia32mkl;C:Program FilesCommon FilesIntelSh
 ared Librariesredistia32mpirt;C:Program FilesCommon FilesIntelShared Lib
 rariesredistia32
 FOUND PATH=C:WINDOWSsystem32notepad.exe
  (found NOTEPAD.EXE folder OK, even though absent from PATH)

 FOUND PATH=C:WINDOWSsystem32notepad.exe (did not find IFCOM.LIB folder...)
 FOUND PATH=C:Program FilesIntelComposerXE-2011compilerlibia32ifcom.lib
  (found IFCOM.LIB folder OK)

 FOUND PATH=C:Program FilesIntelComposerXE-2011compilerlibia32ifcom.lib
  (did not find ACROBAT.EXE folder...)
 FOUND PATH=C:Program Filesadobeacrobat 9.0acrobatacrobat.exe
  (found ACROBAT.EXE folder OK)
Fortran Pause - Enter command or  to continue.[/bash]
0 Kudos
acar
Beginner
1,042 Views
Thanks Anthony and Les. I was clearly misled by the function name - it does not find a file at all or, apparently, do anything remotely helpful. And there is seemingly a bug in the function and/or the documentation is not complete. I'll have to find another approach. I did have some code that used getfileinfoqq in a recursive manner to locate a specified file - looks like I'll have to resurrect it unless anyone knows of a simpler approach?
0 Kudos
Reply