Intel® Fortran Libraries Reference

Intel® Fortran Libraries Reference Intel® Fortran Libraries Reference

h.eng.cam.ac.uk
from h.eng.cam.ac.uk More from this publisher
12.07.2015 Views

2 Intel Fortran Libraries ReferenceExampleUSE IFPORTinteger(4) statarray(12), istatOPEN (unit=1,file='datfile.dat')ISTAT = FSTAT (1, statarray)if (.NOT. istat) thenprint *, statarrayend ifFTELL, FTELLI8Portability Functions: Return the current position of a file.Module: USE IFPORTSyntaxresult = FTELL (lunit)result = FTELLI8 (lunit)lunit(Input) INTEGER(4). External unit number of a file.Results:The result type is INTEGER(4) for FTELL; INTEGER(8) for FTELLI8. The result is the offset,in bytes, from the beginning of the file. A negative value indicates an error, which is the negationof the IERRNO error code. The following is an example of an error code:EINVAL: lunit is not a valid unit number, or is not open.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS LIBFULLPATHQQPortability Function: Returns the full path for a specified file or directory.Module: USE IFPORTSyntaxresult = FULLPATHQQ (name, pathbuf)2-94

Descriptions of the Library Routines 2name(Input) Character*(*). Item for which you want the full path. Can be the name of a file in thecurrent directory, a relative directory or file name, or a network uniform naming convention(UNC) path.pathbuf(Output) Character*(*). Buffer to receive full path of the item specified in name.Results:The result type is INTEGER(4). The result is the length of the full path in bytes, or 0 if thefunction fails (usually for an invalid name).The length of the full path depends upon how deeply the directories are nested on the drive you areusing. If the full path is longer than the character buffer provided to return it (pathbuf),FULLPATHQQ returns only that portion of the path that fits into the buffer.Check the length of the path before using the string returned in pathbuf. If the longest full path youare likely to encounter does not fit into the buffer you are using, allocate a larger character buffer.You can allocate the largest possible path buffer with the following statements:USE IFPORTCHARACTER($MAXPATH) pathbuf$MAXPATH is a symbolic constant defined in IFQWIN.F90 as 260.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS LIBSee Also: “SPLITPATHQQ”ExampleUSE IFPORTUSE IFCORECHARACTER($MAXPATH) bufCHARACTER(3) driveCHARACTER(256) dirCHARACTER(256) nameCHARACTER(256) extCHARACTER(256) fileINTEGER(4)lenDO WHILE (.TRUE.)WRITE (*,*)2-95

Descriptions of the Library Routines 2name(Input) Character*(*). Item for which you want the full path. Can be the name of a file in thecurrent directory, a relative directory or file name, or a network uniform naming convention(UNC) path.pathbuf(Output) Character*(*). Buffer to receive full path of the item specified in name.Results:The result type is INTEGER(4). The result is the length of the full path in bytes, or 0 if thefunction fails (usually for an invalid name).The length of the full path depends upon how deeply the directories are nested on the drive you areusing. If the full path is longer than the character buffer provided to return it (pathbuf),FULLPATHQQ returns only that portion of the path that fits into the buffer.Check the length of the path before using the string returned in pathbuf. If the longest full path youare likely to encounter does not fit into the buffer you are using, allocate a larger character buffer.You can allocate the largest possible path buffer with the following statements:USE IFPORTCHARACTER($MAXPATH) pathbuf$MAXPATH is a symbolic constant defined in IFQWIN.F90 as 260.CompatibilityCONSOLE STANDARD GRAPHICS QUICKWIN GRAPHICS WINDOWS LIBSee Also: “SPLITPATHQQ”ExampleUSE IFPORTUSE IFCORECHARACTER($MAXPATH) bufCHARACTER(3) driveCHARACTER(256) dirCHARACTER(256) nameCHARACTER(256) extCHARACTER(256) fileINTEGER(4)lenDO WHILE (.TRUE.)WRITE (*,*)2-95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!