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

getfileinfoqq trnucates the file name at 34 characters

John_David
Beginner
771 Views

255 should be the limit, given the file$infoi8 definition

0 Kudos
5 Replies
Paul_Curtis
Valued Contributor I
771 Views

[bash]!     TYPE T_WIN32_FIND_DATA
!     SEQUENCE
!       integer(DWORD)		dwFileAttributes	! knowns    DWORD 
!       TYPE (T_FILETIME)	ftCreationTime		! typedefs  FILETIME 
!       TYPE (T_FILETIME)	ftLastAccessTime	! typedefs  FILETIME 
!       TYPE (T_FILETIME)	ftLastWriteTime		! typedefs  FILETIME 
!       integer(DWORD)		nFileSizeHigh		! knowns    DWORD 
!       integer(DWORD)		nFileSizeLow		! knowns    DWORD 
!       integer(DWORD)		dwReserved0			! knowns    DWORD 
!       integer(DWORD)		dwReserved1			! knowns    DWORD 
!       character(260)		cFileName
!       character(14)		cAlternateFileName
!    END TYPE

RECURSIVE FUNCTION file_exists (fname) RESULT (size)
	IMPLICIT NONE
	TYPE(T_WIN32_FIND_DATA)			:: fdata
	CHARACTER(LEN=*),INTENT(IN)		:: fname  ! full pathname, null-terminated
	INTEGER(HANDLE)                 :: ihandl
	INTEGER							:: size, rval
	size = -1
	ihandl = FindFirstFile (fname, fdata)
	IF (ihandl /= INVALID_HANDLE_VALUE) THEN
		
		!   retrieve file data components	
		size = fdata%nFileSizeLow
		
		!   clean up
		rval = FindClose (ihandl)
	ENDIF
END FUNCTION file_exists[/bash]
0 Kudos
Steven_L_Intel1
Employee
771 Views
John,

I can't see the problem you describe. Example, please.

[fxfortran]use ifport
type (FILE$INFO) :: info
integer(int_ptr_kind()) :: handle

handle = FILE$FIRST
iret = GETFILEINFOQQ('*.test', info, handle)

print *, trim(info%name)
end[/fxfortran]

C:\Projects>notepad thisisaverylongfilenamewhoselengthislongerthan34chars.test

C:\Projects>ifort getfileinfoqq.f90
Intel Visual Fortran Compiler Professional for applications running on IA-32,
Version 11.1 Build 20100414 Package ID: w_cprof_p_11.1.065
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

Microsoft Incremental Linker Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:getfileinfoqq.exe
-subsystem:console
getfileinfoqq.obj

C:\Projects>getfileinfoqq.exe
thisisaverylongfilenamewhoselengthislongerthan34chars.test
0 Kudos
John_David
Beginner
771 Views
Steve,

After a good night's sleep,(something that had been lacking for a few days)the problem became apparent as an erroron my part. The returned file length was not being updated after the first call to getfileinfoqq... Sorry for the bother. Any chance the next version of ifort will allow branches into if blocks?

John
0 Kudos
Steven_L_Intel1
Employee
771 Views
Um, no. Not a chance at all. Why would you even ask for such a thing?
0 Kudos
Craig_Dedo
New Contributor I
771 Views
John David,
I understand Steve Lionel's answer to your question. Transferring control into a block from outside it is strictly prohibited by the Fortran Standard, and has been since blocks were first introduced in FORTRAN 77. This prohibition applies to all blocks, not just IF blocks.

Section 8.1.1 of the Fortran 2003 Standard contains rules governing blocks. Section 8.1.1.2, "Control flow in blocks", says:
[Begin quote]
Transfer of control to the interior of a block from outside the block is prohibited. Transfers within a block and transfers from the interior of a block to outside the block may occur.

Subroutine and function references (12.4.2, 12.4.3) may appear in a block.
[End of quote]
0 Kudos
Reply