Bug 31917 - [4.1 only] GFORTRAN_CONVERT_UNIT is ignored
Summary: [4.1 only] GFORTRAN_CONVERT_UNIT is ignored
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.2.1
Assignee: Tobias Burnus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-14 08:04 UTC by Tobias Burnus
Modified: 2007-05-23 08:44 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0 4.1.2
Known to fail: 4.2.0
Last reconfirmed: 2007-05-14 20:07:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-05-14 08:04:16 UTC
http://gcc.gnu.org/onlinedocs/gfortran/GFORTRAN_005fCONVERT_005fUNIT.html

Result (on x86_64/Linux):

GFORTRAN_CONVERT_UNIT set to ""
default:"LITTLE_ENDIAN"
native:"LITTLE_ENDIAN"
swap:"BIG_ENDIAN"
little_endian:"LITTLE_ENDIAN"
big_endian:"BIG_ENDIAN"

GFORTRAN_CONVERT_UNIT set to "BIG_ENDIAN"  ! same with "big_endian"
default:"LITTLE_ENDIAN"
native:"LITTLE_ENDIAN"
swap:"BIG_ENDIAN"
little_endian:"LITTLE_ENDIAN"
big_endian:"BIG_ENDIAN"


Test program

program conv
  implicit none
  character(20) :: ch
  CALL GET_ENVIRONMENT_VARIABLE('GFORTRAN_CONVERT_UNIT', ch)
  print '(3a)', 'GFORTRAN_CONVERT_UNIT set to "',trim(ch),'"'
  open(11,form='unformatted'); inquire(11,convert=ch)
  print '(3a)', 'default:"',trim(ch),'"'; close(11,status='delete')
  open(12,form='unformatted',convert="native")
  inquire(12,convert=ch)
  print '(3a)', 'native:"',trim(ch),'"'; close(12,status='delete')
  open(13,form='unformatted',convert="swap")
  inquire(13,convert=ch)
  print '(3a)', 'swap:"',trim(ch),'"'; close(13,status='delete')
  open(14,form='unformatted',convert="little_endian")
  inquire(14,convert=ch)
  print '(3a)', 'little_endian:"',trim(ch),'"'; close(14,status='delete')
  open(15,form='unformatted',convert="big_endian")
  inquire(15,convert=ch)
  print '(3a)', 'big_endian:"',trim(ch),'"'; close(15,status='delete')
end program conv
Comment 1 Dominique d'Humieres 2007-05-14 08:52:30 UTC
On PPC/darwin7 I get

[karma] f90/bug% a.out 
GFORTRAN_CONVERT_UNIT set to ""
default:"BIG_ENDIAN"
native:"BIG_ENDIAN"
swap:"LITTLE_ENDIAN"
little_endian:"LITTLE_ENDIAN"
big_endian:"BIG_ENDIAN"
[karma] f90/bug% setenv GFORTRAN_CONVERT_UNIT LITTLE_ENDIAN
[karma] f90/bug% a.out
GFORTRAN_CONVERT_UNIT set to "LITTLE_ENDIAN"
default:"BIG_ENDIAN"
native:"BIG_ENDIAN"
swap:"LITTLE_ENDIAN"
little_endian:"LITTLE_ENDIAN"
big_endian:"BIG_ENDIAN"

However I am confused about what to expect from this test:
should the default change or not?
Comment 2 Tobias Burnus 2007-05-14 09:38:10 UTC
> GFORTRAN_CONVERT_UNIT set to ""
> default:"BIG_ENDIAN"

> GFORTRAN_CONVERT_UNIT set to "LITTLE_ENDIAN"
> default:"BIG_ENDIAN"

> However I am confused about what to expect from this test:
> should the default change or not?

I would expect that the default changes depending on the environment variable. But according to the documentation all should change:

"Note that the values specified via the GFORTRAN_CONVERT_UNIT environment variable will override the CONVERT specifier in the open statement. This is to give control over data formats to users who do not have the source code of their program available."

Documentation "bug": Such a statement is missing for GFORTRAN_CONVERT_UNIT section; it is only present in the CONVERT specifier section:
http://gcc.gnu.org/onlinedocs/gfortran/CONVERT-specifier.html
Comment 3 patchapp@dberlin.org 2007-05-14 20:05:45 UTC
Subject: Bug number PR31917

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00900.html
Comment 4 Tobias Burnus 2007-05-17 09:39:48 UTC
Subject: Bug 31917

Author: burnus
Date: Thu May 17 08:39:32 2007
New Revision: 124787

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124787
Log:
2007-05-14  Tobias Burnus <burnus@net-b.de>

        PR fortran/31917
        * runtime/environ.c (mark_range): Fix setting default convert unit.


Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/runtime/environ.c

Comment 5 Thomas Koenig 2007-05-22 21:04:34 UTC
Do you plan a backport?  If not, we should close this.
Comment 6 Tobias Burnus 2007-05-23 08:44:17 UTC
> Do you plan a backport?  If not, we should close this.
I decided to backport it in the basis that the failures are difficult to track as there is not any feedback whether the environment are in effect or not. Additionally, the fix is very localized.

Fixed.
Comment 7 Tobias Burnus 2007-05-23 08:44:51 UTC
Subject: Bug 31917

Author: burnus
Date: Wed May 23 07:44:23 2007
New Revision: 124984

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124984
Log:
2007-05-23  Tobias Burnus <burnus@net-b.de>

        PR fortran/31917
        Backport from trunk.
        * runtime/environ.c (mark_range): Fix setting default convert unit.


Modified:
    branches/gcc-4_2-branch/libgfortran/ChangeLog
    branches/gcc-4_2-branch/libgfortran/runtime/environ.c