Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Reading sun binaries on DEC-Alpha f77?
@ 1998-08-12  4:00 Joerg Lippmann
  1998-08-19  4:00 ` James W. Caldwell
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Joerg Lippmann @ 1998-08-12  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 494 bytes --]


Hi!

Is there an easy way to read sun binary data files with DEC-Alpha
f77-programs?

J�rg

-- 
   ``If you can't make it good, at least make it look good.'' - BILL GATES
-- 
   who  : J�rg Lippmann                 Institut f�r Meereskunde, CAU Kiel  
   email: jlippmann@ifm.uni-kiel.de             Theoretische Ozeanographie  
   tel. : +49-(0)431/597-3886                        D�sternbrooker Weg 20  
   priv.: +49-(0)431/30 53 270                         24105 Kiel, Germany  



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

* Re: Reading sun binaries on DEC-Alpha f77?
  1998-08-12  4:00 Reading sun binaries on DEC-Alpha f77? Joerg Lippmann
@ 1998-08-19  4:00 ` James W. Caldwell
  1998-08-20  4:00   ` Mike Iglesias
  1998-08-20  4:00 ` Mark Taylor
  1998-08-20  4:00 ` Petrie L M
  2 siblings, 1 reply; 5+ messages in thread
From: James W. Caldwell @ 1998-08-19  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 806 bytes --]


You probably can do it if you recompile your fortran 
program using the "-convert big_endian" flag.  

DEC decided years ago to use the "little endidan" format
for storing binary information whereas the rest of the 
world chose "big endian".

jim

Joerg Lippmann <jlippmann@ifm.uni-kiel.de> writes:


>Hi!

>Is there an easy way to read sun binary data files with DEC-Alpha
>f77-programs?

>J�rg

>-- 
>   ``If you can't make it good, at least make it look good.'' - BILL GATES
>-- 
>   who  : J�rg Lippmann                 Institut f�r Meereskunde, CAU Kiel  
>   email: jlippmann@ifm.uni-kiel.de             Theoretische Ozeanographie  
>   tel. : +49-(0)431/597-3886                        D�sternbrooker Weg 20  
>   priv.: +49-(0)431/30 53 270                         24105 Kiel, Germany  



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

* Re: Reading sun binaries on DEC-Alpha f77?
  1998-08-19  4:00 ` James W. Caldwell
@ 1998-08-20  4:00   ` Mike Iglesias
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Iglesias @ 1998-08-20  4:00 UTC (permalink / raw)


In article <caldwell.903550310@cgl.ucsf.edu>,
James W. Caldwell <caldwell@cgl.ucsf.edu> wrote:
>DEC decided years ago to use the "little endidan" format
>for storing binary information whereas the rest of the 
>world chose "big endian".

The "rest of the world" minus the "small" part using Intel x86 type 
processors.


-- 
Mike Iglesias                        Internet:    iglesias@draco.acs.uci.edu
University of California, Irvine     phone:       949-824-6926
Office of Academic Computing         FAX:         949-824-2069



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

* Re: Reading sun binaries on DEC-Alpha f77?
  1998-08-12  4:00 Reading sun binaries on DEC-Alpha f77? Joerg Lippmann
  1998-08-19  4:00 ` James W. Caldwell
@ 1998-08-20  4:00 ` Mark Taylor
  1998-08-20  4:00 ` Petrie L M
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Taylor @ 1998-08-20  4:00 UTC (permalink / raw)


Joerg Lippmann (jlippmann@ifm.uni-kiel.de) wrote:

: Hi!

: Is there an easy way to read sun binary data files with DEC-Alpha
: f77-programs?

I knocked up the following short C program to convert files from 
little-endian to big-endian or the other way round.
Note it will only work if the file has nothing but 4-byte words in
(e.g. all REALs or INTEGERs).

#include <stdio.h>


 /*  This is a very simple program to swap 4-byte words from 
  *  big-endian to little-endian (or vice versa).
  *  Useful, e.g., for moving REALs or INTEGERS between Suns and DECs.
  *  Note that this only works in virtue of the fact that both
  *  use the same representation for REALs and INTEGERs - at least 
  *  this is true at Digital Unix 4.0c and Solaris 2.6.  
  *  However there is no guarantee that this will hold for arbitrary
  *  operating systems with differing byte-order.  For a more general
  *  solution one should use XDR or something.
  */

int main (int argc, char *argv[]) {
   char buf[4], buf2[4];
   size_t b;
   FILE *in, *out;


   if ((argc > 3) || (argc > 1 && *argv[1] == '-')) {
      printf ("Usage:  %s [ infile [ outfile ] ]\n", argv[0]);
      exit (1);
   }

   in  = (argc >= 2) ? fopen (argv[1], "rb") : fdopen (0, "rb");
   if (!in) {
      perror (argv[0]);
      exit (1);
   }

   out = (argc == 3) ? fopen (argv[2], "wb") : fdopen (1, "wb");
   if (!out) {
      perror (argv[0]);
      exit (1);
   }

   while (fread (buf, 4, 1, in) == 1) {
      buf2[0] = buf[3];
      buf2[1] = buf[2];
      buf2[2] = buf[1];
      buf2[3] = buf[0];
      if (fwrite (buf2, 4, 1, out) != 1) {
          printf ("%s:  Error writing output file\n", argv[0]);
          exit (1);
      }
   }
   if (ferror(in) != 0) {
      printf ("%s:  Error reading input file\n", argv[0]);
      exit(1);
   }
}

---------------------------------------------------------------------------
| Mark Taylor                       Institute of Astronomy, Cambridge, UK |
| mbt@ast.cam.ac.uk    http://dougal.chm.bris.ac.uk/~mbt/    01223 337535 |
---------------------------------------------------------------------------



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

* Re: Reading sun binaries on DEC-Alpha f77?
  1998-08-12  4:00 Reading sun binaries on DEC-Alpha f77? Joerg Lippmann
  1998-08-19  4:00 ` James W. Caldwell
  1998-08-20  4:00 ` Mark Taylor
@ 1998-08-20  4:00 ` Petrie L M
  2 siblings, 0 replies; 5+ messages in thread
From: Petrie L M @ 1998-08-20  4:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

According to Joerg Lippmann  <jlippmann@ifm.uni-kiel.de>:
-->
-->Hi!
-->
-->Is there an easy way to read sun binary data files with DEC-Alpha
-->f77-programs?
-->
-->J�rg
-->

Yes. set an environment variable FORT_CONVERTnn to "BIG_ENDIAN",
where nn is the logical unit number in fortran used to read 
(or write) the file, before running your program. You can use
as many nn's as needed. This does depend on the program reading
the data into the correct data type. 

-- 
Lester M. Petrie                                       Email: (lmp@ornl.gov)
Computational Physics and Engineering Division         Phone: (423) 574-5259
Oak Ridge National Laboratory,                         FAX:   (423) 576-3513
P. O. Box 2008  MS-6370, Oak Ridge, TN 37831-6370



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

end of thread, other threads:[~1998-08-20  4:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-08-12  4:00 Reading sun binaries on DEC-Alpha f77? Joerg Lippmann
1998-08-19  4:00 ` James W. Caldwell
1998-08-20  4:00   ` Mike Iglesias
1998-08-20  4:00 ` Mark Taylor
1998-08-20  4:00 ` Petrie L M

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