USWAP(1)

πŸ“¦ version 0, in fedora 43, fedora 44

πŸ’« USWAP β€” bestie edition πŸ’«

So like, <rainbow>uswap</rainbow> is a lil cutie from the General Commands Manual (section 1, obvs) and honestly? It's giving ✨endianness fairy✨.


🌸 NAME 🌸

uswap β€” converts the endianness of a Fortran unformatted file πŸ¦‹


✨ SYNOPSIS ✨

uswap [ -x ] [ -csfde.....  ] [ -i infile ] [ -o outfile ]

πŸ’– DESCRIPTION πŸ’–

okay so here's the tea πŸ«– β€” uswap converts the endianness of a file that was written with Fortran's unformatted write command. So basically a dump file written on a big endian machine can be converted so it can be read on a little endian machine. Bestie, it's a whole long-distance relationship and uswap is the matchmaker πŸ’…

The input and output files may be named, but if you don't name them? No worries, standard input and standard output get read from and written to instead. Iconic default behaviour honestly.

By default the records are assumed to contain data of 4 bytes size, like the default integer, logical, complex and real types. But you can set the size of the records right on the command line, no cap:

  • -c β€” character data πŸŽ€
  • -s β€” short data (eg: integer*2, logical*2)
  • -f β€” float data (eg: integer, real, logical, complex)
  • -d β€” double precision data (eg: integer*8, real*8, double precision, double complex).
  • -e β€” extended precision data (eg: real*16, extended precision).

The following examples shows how a data file containing a character record, a double precision record, and a number of single precision records can be converted:

uswap -cdf -i infile -o outfile

See uread(1) to read the number of records in a Fortran unformatted data file, and to guess the record contents. πŸ‘‘ (she's the sister tool, go say hi.)

By default uswap will byte swap a file written on the host machine. But to byte swap a file written on a foreign machine with opposite endianness? Use the -x flag. that's it, that's the flag πŸ¦‹


⚠️ NOTE ⚠️

The error message

uswap: data larger than file length

often indicates that the file being read has the opposite byte "sex" to the platform uread is being run on. (yes, the manpage says "sex", we're keeping it, it's a classic πŸ’€)

Try using the -x flag to see if this is the case. lowkey this solves like 90% of your problems, fr fr.


πŸ”₯ SEE ALSO πŸ”₯

uread(1), ustrip(1)


πŸ’œ AUTHOR πŸ’œ

S.E. Norris s.norris@auckland.ac.nz


and that's the whole page bestie, <rainbow>USWAP(1)</rainbow> out β€” shoutout to S.E. Norris for the authoring and to the General Commands Manual for the home, no date on this one so we're just sending it with love 🫢✨ periodt.

πŸ“¦ where this page comes from