Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

OPEN function failing in Japanese OS

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?

Sample Code:

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

 

0 Kudos
6 Replies
Highlighted
Moderator

Check the Intel Fortran

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

 

0 Kudos
Highlighted

Thanks for looking into this.

Thanks for looking into this. But in my case, names are already handled as Multibyte (not Unicode).

0 Kudos
Highlighted
Black Belt

I've seen issues in the past

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted

We are using 15.0.0127.12

We are using 15.0.0127.12

0 Kudos
Highlighted
Black Belt

Please try a newer version

Please try a newer version then. That is more than four years old and may still have the bug.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran
0 Kudos
Highlighted

I tried this in IVF 19.0 and

I tried this in IVF 19.0 and it is working correctly. Thanks.

0 Kudos