fortran - Bin data read differently in AIX vs Linux -
i have .bin file contains slopes , intercepts. i'm using fortran read values , i'm getting different values on machines running aix , linux. believe linux data accurate. have stack size or endians?
for example, aix max value is: 0.3401589687e+39 while linux max value is: 6.031288
program read_bin_files real :: slope(2500,1250) integer :: recl=2500*1250*4 open(unit=8, file='modis_avhrr_years_slope.bin', action='read', access='direct', form='unformatted', recl=recl, iostat=iostat) read(unit=8, rec = 1, iostat = iostat) slope print *, "max slope value is:", maxval(slope) close(8) end
aix runs (these days) on power cpus, usually big-endian, whereas linux usually run on x86es, little-endian. correct suspect endianness may problem. report result of running this program
program read_bin_files integer*4 :: slope(2500,1250) integer :: recl=2500*1250*4 open(unit=8, file='modis_avhrr_years_slope.bin', action='read', & access='direct', form='unformatted', recl=recl) read(unit=8, rec = 1) slope = 1, 10 write(*, '(z8.8)') slope(1, i) end close(8) end
is following. ("aix" , "linux" in quotes in column headers because it's cpu matters here, not operating system.)
"linux" | "aix" ------------+------------ 3e c2 61 8f | 8f 61 c2 3e 3e f5 64 52 | 52 64 f5 3e bc f3 e0 7e | 7e e0 f3 bc bf b9 71 0d | 0d 71 b9 bf 3e f5 b9 73 | 73 b9 f5 3e 3f 29 3c 2f | 2f 3c 29 3f 3e dc c2 09 | 09 c2 dc 3e 3f 66 86 89 | 89 86 66 3f 3e 5b 91 a9 | a9 91 5b 3e 3f 67 73 25 | 25 73 67 3f
in each row, right-hand half mirror image of left-hand half. demonstrates issue is endianness. still don't know byte order correct. answer question "the byte order used cpu ran program generated file."
if using gnu fortran, the convert specifier open should solve problem, provided can figure out way around data supposed interpreted. however, think that's extension. in general case, don't know enough fortran tell do.
if have control on process generating these data files, can avoid entire problem in future switching both sides self-describing data format, such hdf.
Comments
Post a Comment