- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
please see the following lines.
This is what I get as output on my screen
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
Why is the output not the same? I stumbled over this in an other
program and wrote these lines just for demonstration. I really
would like to use derived type structures as the real data files I
want to read have various repeating integer headers and no fixed
length data records with real numbers. I tried the same without
convert = 'BIG_ENDIAN' and it works fine but the data I have
to read is big endian.
I am using the intel fortran compiler 11.1.059 on a suse 11.2 64bit
machine and I hope one of you can help me with an idea how to use
the derived type structure and read the values correctly.
Thanks in advance.
greets
Eide
please see the following lines.
[fortran] program dttest !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! check derived type structure ! compile -> ifort dttest.f90 -o xdttest !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! implicit none !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! integer (kind = 2) :: aone,atwo integer (kind = 4) :: athree,afour,afive real (kind = 4) :: asix integer (kind = 2) :: bone,btwo integer (kind = 4) :: bthree,bfour,bfive real (kind = 4) :: bsix ! type construct type teststruct integer (kind = 2) :: cone integer (kind = 2) :: ctwo integer (kind = 4) :: cthree integer (kind = 4) :: cfour integer (kind = 4) :: cfive real (kind = 4) :: csix end type teststruct ! type(teststruct) :: bintest !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! initial values aone = 2 atwo = 4 athree = 1024 afour = 161257 afive = 752161 asix = 12.3456 ! open(convert = 'BIG_ENDIAN', unit = 10, file = 'test.bin', form = 'binary') ! write testdata write(10)aone,atwo,athree,afour,afive,asix write(10)aone,atwo,athree,afour,afive,asix write(10)aone,atwo,athree,afour,afive,asix write(10)aone,atwo,athree,afour,afive,asix close(10) ! open(convert = 'BIG_ENDIAN', unit = 11, file = 'test.bin', form = 'binary') ! read testdata read(11)bone,btwo,bthree,bfour,bfive,bsix print*,bone,btwo,bthree,bfour,bfive,bsix read(11)bone,btwo,bthree,bfour,bfive,bsix print*,bone,btwo,bthree,bfour,bfive,bsix read(11)bone,btwo,bthree,bfour,bfive,bsix print*,bone,btwo,bthree,bfour,bfive,bsix read(11)bone,btwo,bthree,bfour,bfive,bsix print*,bone,btwo,bthree,bfour,bfive,bsix close(11) ! open(convert = 'BIG_ENDIAN', unit = 12, file = 'test.bin', form = 'binary') ! read testdata read(12)bintest print*,bintest read(12)bintest print*,bintest read(12)bintest print*,bintest read(12)bintest print*,bintest close(12) end program dttest[/fortran]The program compiles and runs without a problem.
This is what I get as output on my screen
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
2 4 1024 161257 752161 12.34560
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
512 1024 262144 -378207744 561646336 -1.3658832E-26
Why is the output not the same? I stumbled over this in an other
program and wrote these lines just for demonstration. I really
would like to use derived type structures as the real data files I
want to read have various repeating integer headers and no fixed
length data records with real numbers. I tried the same without
convert = 'BIG_ENDIAN' and it works fine but the data I have
to read is big endian.
I am using the intel fortran compiler 11.1.059 on a suse 11.2 64bit
machine and I hope one of you can help me with an idea how to use
the derived type structure and read the values correctly.
Thanks in advance.
greets
Eide
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe Steve posted in another thread that CONVERT='BIG_ENDIAN' is not applied to user-defined types, only intrinsic types.
-Kurt
-Kurt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Kurt,
I found the thread you mentioned. Seems like there was no change to it since 2008. The possibilty to use derived type structures would really simplify and speed up the file reading.
Eide
I found the thread you mentioned. Seems like there was no change to it since 2008. The possibilty to use derived type structures would really simplify and speed up the file reading.
Eide

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page