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

Bug in pfxint8get() in ifort

James_B_14
Beginner
316 Views

Compiler Versions: 15.0.2, 17.0.0

OS: RHEL 6.8

Kernel: 2.6.32-642.4.2 64-bit

Compile lines:

Works fine:    ifort -O3 -o test1 mopen.F
Gives wierd results: ifort -check all -o test2 mopen.F

The test1 and test2 executables produce two completely different results.

 

 

The following code produces this error:

        program htemp
        use ifposix
        implicit none
        integer(8) islen
        character*16 myfile
        integer(4) lename,ipxflag,ipxmode,ipxfd,ipxerr,ipxlen4
        integer(4) :: jstat_h
        integer(8) :: ipxlen

! open the signal
        myfile="mopen.F"
        write(6,*)  'opening ',myfile
        ipxflag=IPXFCONST('O_RDONLY')
        ipxmode=0
        lename=len_trim(myfile)
        call PXFOPEN(myfile,lename,ipxflag,ipxmode,ipxfd,ipxerr)
        write(6,*)  'PXFOPEN returned ',ipxfd
        if(ipxerr.gt.0) stop

        call pxfstructcreate('stat',jstat_h,ipxerr) ! create stat structure
        call pxffstat(ipxfd,jstat_h,ipxerr)
        call pxfint8get(jstat_h,'st_size',ipxlen,ipxerr)
        write(6,*)  'pxfint8get returned st_size ',ipxlen
        call pxfintget(jstat_h,'st_size',ipxlen4,ipxerr)
        write(6,*)  'pxfintget  returned st_size ',ipxlen4

        call pxfstat(myfile,lename,jstat_h,ipxerr)
        call pxfint8get(jstat_h,'st_size',ipxlen,ipxerr)
        write(6,*)  'pxfint8get returned st_size ',ipxlen
        call pxfintget(jstat_h,'st_size',ipxlen4,ipxerr)
        write(6,*)  'pxfintget  returned st_size ',ipxlen4

        INQUIRE(file=myfile,size=islen)
        write(6,*)  'INQUIRE    returned         ',islen
        call pxfstructfree(jstat_h,ipxerr)
        contains


        end program htemp

 

0 Kudos
2 Replies
mecej4
Honored Contributor III
316 Views

I can see the problem on Windows, as well (versions 2015, 2016 and 2017). I think that the real problem is that pxfint8get() is returning the INT8 argument with only the lower 32 bits set. If I add 

             ipxlen=transfer(Z'BAADF00DDAABD00F',ipxlen)

before the call to pxfint8get(), the returned value is -4995072473058769535, or Z'BAADF00D00000581', instead of the correct value, 1409 or Z'0000000000000581'.

In effect, the upper 32 bits are undefined, so the value returned in those bits can be anything, and can be affected by changing compiler options.

Check if your "weird" results, when expressed in hex, are correct in the lower 8 nybbles.

0 Kudos
Xiaoping_D_Intel
Employee
316 Views

Thanks for reporting the error. I have reproduced it and opened a bug report for it. The bug ID is DPD200588804.

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos
Reply