When file is located inside a folder name with Japanese character, INQUIRE / OPEN fails when called only with file name. They work fine when using full path. This issue is only in Japanese OS. Chinese and other OS works fine. C calls are working fine (_access, CreateFile, etc.)
OS: Win 7 & 10 Japanese, System Locale: Japanese
Any suggestions to resolve this?
program ExampleFOR USE IFPORT implicit none CHARACTER(260) CMD, FName, FulPath INTEGER(4) ISTATUS LOGICAL exists ISTATUS = GETCWD(CMD) ! INQUIRE(DIRECTORY=CMD, EXIST=exists) ! PASS FNAME = 'A.TXT' INQUIRE(FILE=FNAME, EXIST=exists) ! FAIL FulPath = TRIM(CMD)//'\'//TRIM(FNAME) INQUIRE(FILE=FulPath, EXIST=exists) ! PASS end program ExampleFOR
Check the Intel Fortran compiler documentation on using the National Language Support Library. Your failure is probably due to the multi-byte character set needed for Japanese.
This sample routine demonstrates what you will need to do, I think.
subroutine test_file_open(filename,len) USE IFNLS integer :: len !DIR$ ATTRIBUTES VALUE :: len integer(2)::filename(len) ! array contains the Unicode file name integer(4):: res character*100:: ffname res = MBConvertUnicodeToMB(filename,ffname) ! do the conversion, return the result string length write(*,*) ffname(1:res) open (8, file=ffname(1:res), action='WRITE') ! pass result MB string to OPEN statement write (8,*) 'Testing file writing' close (8) end subroutine
I've seen issues in the past with the I/O library having difficulty with files in paths that have multibyte/Unicode characters. I thought that had been fixed a while ago - which compiler version are you using? If it is current (19.0.2), I recommend that you submit this through the Intel Online Service Center.
Please try a newer version then. That is more than four years old and may still have the bug.