Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs have moved to the Altera Community. Existing Intel Community members can sign in with their current credentials.

OPEN function failing in Japanese OS

Mohanasundaram__Bala
1,616 Views

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
Barbara_P_Intel
Employee
1,616 Views

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
Mohanasundaram__Bala
1,616 Views

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

0 Kudos
Steve_Lionel
Honored Contributor III
1,616 Views

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.

0 Kudos
Mohanasundaram__Bala
1,616 Views

We are using 15.0.0127.12

0 Kudos
Steve_Lionel
Honored Contributor III
1,616 Views

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

0 Kudos
Mohanasundaram__Bala
1,616 Views

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

0 Kudos
Reply