<html lang="en"> <head> <title>GFORTRAN_CONVERT_UNIT - The GNU Fortran Compiler</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="The GNU Fortran Compiler"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Runtime.html#Runtime" title="Runtime"> <link rel="prev" href="GFORTRAN_005fLIST_005fSEPARATOR.html#GFORTRAN_005fLIST_005fSEPARATOR" title="GFORTRAN_LIST_SEPARATOR"> <link rel="next" href="GFORTRAN_005fERROR_005fDUMPCORE.html#GFORTRAN_005fERROR_005fDUMPCORE" title="GFORTRAN_ERROR_DUMPCORE"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Funding Free Software'', the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="GFORTRAN_CONVERT_UNIT"></a> <a name="GFORTRAN_005fCONVERT_005fUNIT"></a> <p> Next: <a rel="next" accesskey="n" href="GFORTRAN_005fERROR_005fDUMPCORE.html#GFORTRAN_005fERROR_005fDUMPCORE">GFORTRAN_ERROR_DUMPCORE</a>, Previous: <a rel="previous" accesskey="p" href="GFORTRAN_005fLIST_005fSEPARATOR.html#GFORTRAN_005fLIST_005fSEPARATOR">GFORTRAN_LIST_SEPARATOR</a>, Up: <a rel="up" accesskey="u" href="Runtime.html#Runtime">Runtime</a> <hr> </div> <h3 class="section">3.12 <samp><span class="env">GFORTRAN_CONVERT_UNIT</span></samp>—Set endianness for unformatted I/O</h3> <p>By setting the <samp><span class="env">GFORTRAN_CONVERT_UNIT</span></samp> variable, it is possible to change the representation of data for unformatted files. The syntax for the <samp><span class="env">GFORTRAN_CONVERT_UNIT</span></samp> variable is: <pre class="smallexample"> GFORTRAN_CONVERT_UNIT: mode | mode ';' exception | exception ; mode: 'native' | 'swap' | 'big_endian' | 'little_endian' ; exception: mode ':' unit_list | unit_list ; unit_list: unit_spec | unit_list unit_spec ; unit_spec: INTEGER | INTEGER '-' INTEGER ; </pre> <p>The variable consists of an optional default mode, followed by a list of optional exceptions, which are separated by semicolons from the preceding default and each other. Each exception consists of a format and a comma-separated list of units. Valid values for the modes are the same as for the <code>CONVERT</code> specifier: <ul> <li><code>NATIVE</code> Use the native format. This is the default. <li><code>SWAP</code> Swap between little- and big-endian. <li><code>LITTLE_ENDIAN</code> Use the little-endian format for unformatted files. <li><code>BIG_ENDIAN</code> Use the big-endian format for unformatted files. </ul> A missing mode for an exception is taken to mean <code>BIG_ENDIAN</code>. Examples of values for <samp><span class="env">GFORTRAN_CONVERT_UNIT</span></samp> are: <ul> <li><code>'big_endian'</code> Do all unformatted I/O in big_endian mode. <li><code>'little_endian;native:10-20,25'</code> Do all unformatted I/O in little_endian mode, except for units 10 to 20 and 25, which are in native format. <li><code>'10-20'</code> Units 10 to 20 are big-endian, the rest is native. </ul> <p>Setting the environment variables should be done on the command line or via the <samp><span class="command">export</span></samp> command for <samp><span class="command">sh</span></samp>-compatible shells and via <samp><span class="command">setenv</span></samp> for <samp><span class="command">csh</span></samp>-compatible shells. <p>Example for <samp><span class="command">sh</span></samp>: <pre class="smallexample"> $ gfortran foo.f90 $ GFORTRAN_CONVERT_UNIT='big_endian;native:10-20' ./a.out </pre> <p>Example code for <samp><span class="command">csh</span></samp>: <pre class="smallexample"> % gfortran foo.f90 % setenv GFORTRAN_CONVERT_UNIT 'big_endian;native:10-20' % ./a.out </pre> <p>Using anything but the native representation for unformatted data carries a significant speed overhead. If speed in this area matters to you, it is best if you use this only for data that needs to be portable. <p>See <a href="CONVERT-specifier.html#CONVERT-specifier">CONVERT specifier</a>, for an alternative way to specify the data representation for unformatted files. See <a href="Runtime-Options.html#Runtime-Options">Runtime Options</a>, for setting a default data representation for the whole program. The <code>CONVERT</code> specifier overrides the <samp><span class="option">-fconvert</span></samp> compile options. <p><em>Note that the values specified via the GFORTRAN_CONVERT_UNIT environment variable will override the CONVERT specifier in the open statement</em>. This is to give control over data formats to users who do not have the source code of their program available. </body></html>