Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* f77 -convert big_endian broken?
@ 1993-09-09 14:27 Keith Refson
  1993-09-10 20:34 ` Jeff Donsbach
  1993-09-12  3:06 ` Fred Velijanian
  0 siblings, 2 replies; 5+ messages in thread
From: Keith Refson @ 1993-09-09 14:27 UTC (permalink / raw)



I just discovered to my dismay that the "-convert big_endian" option
to f77 doesn't work as expected.  If I am reading the manual page
correctly, it ought to produce binary unformatted files compatible
with the Sun machines.  

However it doesn't seem to convert floating point data, only integer.
Here's the test program.

      program fin
      real a(10)
      data a/1,2,3,4,5,6,7,8,9,0/
      write(7) a
      stop
      end

which when compiled without any -convert options writes the data:


Dump: fort.7

Offset:    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789abcdef

00000000: 28 00 00 00 00 00 80 3f 00 00 00 40 00 00 40 40 | (......?...@..@@ |
00000010: 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 | ...@...@...@...@ |
00000020: 00 00 00 41 00 00 10 41 00 00 00 00 28 00 00 00 | ...A...A....(... |

With -convert big_endian I get:

Dump: fort.7

Offset:    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789abcdef

00000000: 00 00 00 28 00 00 80 3f 00 00 00 40 00 00 40 40 | ...(...?...@..@@ |
00000010: 00 00 80 40 00 00 a0 40 00 00 c0 40 00 00 e0 40 | ...@...@...@...@ |
00000020: 00 00 00 41 00 00 10 41 00 00 00 00 00 00 00 28 | ...A...A.......( |

Notice that it has done nothing with the fp data and only byte-swapped
the record length words.  However the following program

      program fin
      real a(10)
      integer x(10)
      equivalence (x,a)
      data a/1,2,3,4,5,6,7,8,9,0/
      write(7) x
      stop
      end

produces this output:
Dump: fort.7

Offset:    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f   0123456789abcdef

00000000: 00 00 00 28 3f 80 00 00 40 00 00 00 40 40 00 00 | ...(?...@...@@.. |
00000010: 40 80 00 00 40 a0 00 00 40 c0 00 00 40 e0 00 00 | @...@...@...@... |
00000020: 41 00 00 00 41 10 00 00 00 00 00 00 00 00 00 28 | A...A..........( |

which *is* byte-swapped, and in fact reads in correctly on Sun
machines.

I am running OSF/1 v1.2.  Is this fixed in 1.3?

Keith Refson

--
------------------------------------------------------------------------------
|  Email   : keith@earth.ox.ac.uk       |   Dr Keith   Refson                |
|  UUCP    : ...!mcsun!uknet!ed!K.Refson|   Department of Earth Sciences     |
| PHONE(FAX): +44 865 272026 (272072)   |   Parks Road, Oxford OX1 3PR, UK   |
------------------------------------------------------------------------------


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: f77 -convert big_endian broken?
  1993-09-09 14:27 f77 -convert big_endian broken? Keith Refson
@ 1993-09-10 20:34 ` Jeff Donsbach
  1993-09-12  3:06 ` Fred Velijanian
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Donsbach @ 1993-09-10 20:34 UTC (permalink / raw)


Keith Refson (keith@rahman.earth.ox.ac.uk) wrote:

<stuff about -convert big_endian deleted>

: I am running OSF/1 v1.2.  Is this fixed in 1.3?

according to our DEC contact, it HAS been fixed in 1.3, although
I haven't had time to try it yet (probably next week)...

-Jeff

--
=========================
Jeff Donsbach
Molecular Simulations,Inc., 16 New England Executive Park, Burlington, MA 01803
Internet Email: jdonsbac@MSI.Com            "10 bucks is 10 bucks" - Geddy Lee


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: f77 -convert big_endian broken?
  1993-09-09 14:27 f77 -convert big_endian broken? Keith Refson
  1993-09-10 20:34 ` Jeff Donsbach
@ 1993-09-12  3:06 ` Fred Velijanian
  1993-09-24 13:40   ` Janet Jackson
  1 sibling, 1 reply; 5+ messages in thread
From: Fred Velijanian @ 1993-09-12  3:06 UTC (permalink / raw)


In article <KEITH.93Sep9152702@rahman.earth.ox.ac.uk>,
Keith Refson <keith@rahman.earth.ox.ac.uk> wrote:
>
>I just discovered to my dismay that the "-convert big_endian" option
>to f77 doesn't work as expected.  If I am reading the manual page
>correctly, it ought to produce binary unformatted files compatible
>with the Sun machines.  

[STUFF DELETED]

I just tried your code using DEC Fortran 3.3.2 and it works correctly.
There were several big-endian related bugs with 3.3 and 3.3.1, but
3.3.2 seems to have fixed all of our problems. I don't know if this
version is on the CDROM distribution, I got ours via a tape from the CSC.

Fred Velijanian
UC Irvine
fredv@uci.edu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: f77 -convert big_endian broken?
  1993-09-12  3:06 ` Fred Velijanian
@ 1993-09-24 13:40   ` Janet Jackson
  1993-09-24 18:40     ` Mark Bartelt
  0 siblings, 1 reply; 5+ messages in thread
From: Janet Jackson @ 1993-09-24 13:40 UTC (permalink / raw)


In <2C929234.20628@news.service.uci.edu> fredv@abba.acs.uci.edu (Fred Velijanian) writes:

>In article <KEITH.93Sep9152702@rahman.earth.ox.ac.uk>,
>Keith Refson <keith@rahman.earth.ox.ac.uk> wrote:
>>
>>I just discovered to my dismay that the "-convert big_endian" option
>>to f77 doesn't work as expected.  If I am reading the manual page
>>correctly, it ought to produce binary unformatted files compatible
>>with the Sun machines.  

That's right.

>[STUFF DELETED]
>
>I just tried your code using DEC Fortran 3.3.2 and it works correctly.
>There were several big-endian related bugs with 3.3 and 3.3.1, but
>3.3.2 seems to have fixed all of our problems. I don't know if this
>version is on the CDROM distribution, I got ours via a tape from the CSC.

My Fortran users also report that 3.3.2, which I, too, got on a tape from
DEC support, fixes it.  They were quite prompt with it.  Log a call.

Janet Jackson
<jackson@cwr.uwa.edu.au>
Systems Manager
Centre for Water Research
The University of Western Australia


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: f77 -convert big_endian broken?
  1993-09-24 13:40   ` Janet Jackson
@ 1993-09-24 18:40     ` Mark Bartelt
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Bartelt @ 1993-09-24 18:40 UTC (permalink / raw)


[ Fred Velijanian ]

| There were several big-endian related bugs with 3.3 and 3.3.1, but
| 3.3.2 seems to have fixed all of our problems. I don't know if this
| version is on the CDROM distribution, I got ours via a tape from the CSC.

[ Janet Jackson ]

| My Fortran users also report that 3.3.2, which I, too, got on a tape from
| DEC support, fixes it.  They were quite prompt with it.  Log a call.

Well, after installing the 3.3.2 update DEC sent us, things did seem
OK, but soon afterward I found that the "-convert big_endian" problem
is *almost* fixed, but not quite totally.  Specifically, it seems to
work OK for integers (both scalars and arrays), for real scalars, and
for real arrays with explicit subscript limits.  But it fails on real
arrays with implicit subscript limits.  Unlike the previous problems
(which affected output but not input, I believe), this one hits both
input and output.  Take a look at the following four short programs;
the first three work, the fourth doesn't.  A workaround for whatever
programs break because of this bug is obvious, but it could be a bit
a nuisance to implement it in a really gigantic program ...

moose> cat ww1.f
	program w1
	real x1,x2
	data x1,x2/1.0,2.0/
	open(unit=1,file='spam',status='new',form='unformatted')
	write (1) x1,x2
	close(unit=1)
	call exit
	end
moose> 
moose> cat ww2.f
	program w2
	real x(2)
	data x/1.0,2.0/
	open(unit=1,file='spam',status='new',form='unformatted')
	write (1) x(1),x(2)
	close(unit=1)
	call exit
	end
moose> 
moose> cat ww3.f
	program w3
	real x(2)
	data x/1.0,2.0/
	open(unit=1,file='spam',status='new',form='unformatted')
	write (1) (x(i),i=1,2)
	close(unit=1)
	call exit
	end
moose> 
moose> cat ww4.f
	program w4
	real x(2)
	data x/1.0,2.0/
	open(unit=1,file='spam',status='new',form='unformatted')
	write (1) x
	close(unit=1)
	call exit
	end
moose> 
moose> for x in 1 2 3 4; do
moose>> f77 -convert big_endian -o ww$x ww$x.f
moose>> rm -f spam
moose>> ww$x
moose>> od -x spam
moose>> done
0000000  0000 0800 803f 0000 0040 0000 0000 0800
0000020
0000000  0000 0800 803f 0000 0040 0000 0000 0800
0000020
0000000  0000 0800 803f 0000 0040 0000 0000 0800
0000020
0000000  0000 0800 0000 3f80 0000 4000 0000 0800
0000020

Mark Bartelt                                                416/978-5619
Canadian Institute for                             mark@cita.toronto.edu
Theoretical Astrophysics                           mark@cita.utoronto.ca

"Clothes not busy being worn are busy drying."  -  Dylan, on laundry day
          [ singing "It's all right, ma (I'm only bleaching)" ]


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1993-09-24 18:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-09-09 14:27 f77 -convert big_endian broken? Keith Refson
1993-09-10 20:34 ` Jeff Donsbach
1993-09-12  3:06 ` Fred Velijanian
1993-09-24 13:40   ` Janet Jackson
1993-09-24 18:40     ` Mark Bartelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox