[patch, fortran]PR25829 Add support for F2003 I/O features

Jerry DeLisle jvdelisle@verizon.net
Sat Apr 5 07:49:00 GMT 2008


On Thu, 2008-04-03 at 10:26 +0200, Tobias Burnus wrote:
> Jerry DeLisle wrote:
> > On Tue, 2008-04-01 at 13:47 +0200, Tobias Burnus wrote:
> >   
> >> Jerry DeLisle wrote:
> >>     
> >>> The attached updated patch incorporates all constraints and checks
> >>> listed above in the front end.  It also implements the DP and DC format
> >>> specifiers.  
> >>>       
> >> Thanks. Some more issues and remarks. I will try to review the patch later.
> >>     
> > OK, I will work through these. The checks in place now are for EXPR_CONSTANT and not addressing the broader case.
> >   
> 
> Probably something not yet implemented, but the example from PR 28655 
> still fails. (See also references in links in there).
> 
> program iotests
>   implicit none
>   character(len=45) :: a
>   real, parameter :: pi = 3.14159265358979323846
> !  write(*,'(f10.3,s,f10.3,sp,f10.3,ss,f10.3)',SIGN='PLUS') pi, pi, pi, pi
> !  write(*,'(f10.3,dc,f10.3,dp,f10.3)',DECIMAL='COMMA') pi, pi, pi
> !  write(6,*,delim='quote') 'Hello'
>   open(99,file='test.dat',form='formatted',status='new')
>   write(99,'(a)') 'hello'
>   close(99)
>   open(99,file="test.dat",form='formatted',status='old', &
>        PAD='YES',BLANK='NULL',ENCODING='DEFAULT')
>   read(99,*,PAD='NO',BLANK='NULL') a
>   close(99)
> end program iotests
> 
> 
> 
>   read(99,*,PAD='NO',BLANK='NULL') a
>                                    1
> Error: BLANK specifier in READ statement at (1) has invalid value 'NULL'
> 
> Which is invalid as 'ZERO' and 'NULL' are allowed. (By the way German 
> "null" is English "zero", which makes the option a bit funny; "null" 
> comes from Latin "nullus" none; 'blank'/'zero' would have been better in 
> my opinion.)
> 
> (However, note: "C912 (R913) A BLANK=, PAD=, END=, EOR=, or SIZE= 
> specifier shall not appear in a write-stmt.")
> 
>  * * *
> 
> For completeness, the following edit descriptors are still unsupported 
> in the FE / library: ss, sp, s (10.7.4) for sign; ru, rd, rz, rn, rc, rp 
> for round; bn, bz for blank. (dc and dp for decimal already fully work :-)

I have implemented all of this and then sime. BLANK=, SIGN=, FMT=
s,ss,sp, dp, dc.

The patch is getting too big so i do not want to add any more until we
get this in trunk,

With that said, I have attached the latest patch and 7 new test cases.

Regression tested on x86-64-linux-gnu. I will update the ChangeLog from
the original submit.

OK for trunk.

Jerry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003_io_1.f90
Type: text/x-fortran
Size: 824 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003_io_2.f90
Type: text/x-fortran
Size: 508 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003_io_3.f90
Type: text/x-fortran
Size: 537 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003_io_4.f90
Type: text/x-fortran
Size: 706 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003_io_5.f90
Type: text/x-fortran
Size: 714 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment-0004.bin>
-------------- next part --------------
! { dg-do run }
! Test case prepared by Jerry DeLisle  <jvdelisle@gcc.gnu.org>
! Test of decimal="comma" in namelist, checks separators
implicit none
integer :: i
real :: a(6) = 0.0
character(len=30) :: str = '&nm a = 1,3; 4, 5; 5; 7; /'
namelist /nm/ a
read(str,nml=nm,decimal='comma')
if (any(a.ne.[ 1.3, 4.0, 5.0, 5.0, 7.0, 0.0 ])) call abort
end
-------------- next part --------------
! { dg-do run }
! Test case prepared by Jerry DeLisle  <jvdelisle@gcc.gnu.org>
! Test of sign=, decimal=, and blank= .
program iotests
  implicit none
  character(len=45) :: a
  character(len=4) :: mode = "what"
  real, parameter :: pi = 3.14159265358979323846
  real(kind=8), dimension(3) :: b
  !
  write(a,'(f10.3,s,f10.3,sp,f10.3,ss,f10.3)',SIGN='PLUS') pi, pi, pi, pi
  if (a /= "    +3.142     3.142    +3.142     3.142") call abort
  !
  open(8,sign="plus")
  write(8,'(f10.3,dc,f10.3,dp,f10.3)',DECIMAL='COMMA',&
        & sign="suppress") pi, pi, pi
  rewind(8)
  read(8,'(a)') a
  if (a /= "     3,142     3,142     3.142") call abort
  close(8,status="delete")
  !
  !              "123456789 123456789  12345678901
  write(a,'(a)') "53 256.84, 2 2 2.  ; 33.3 3   1  "
  read(a, '(f9.2,1x,f8.2,2x,f11.7)', blank="zero") b(1),b(2),b(3)
  if (any(abs(b - [530256.84, 20202.00, 33.3030001]) > .03)) call abort
end program iotests

-------------- next part --------------
A non-text attachment was scrubbed...
Name: f2003-io-RevG.diff
Type: text/x-patch
Size: 81523 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080405/8869032b/attachment-0005.bin>


More information about the Fortran mailing list