[patch, libgfortran] PR24224 Generalized internal array IO not implemented.

Paul Thomas paulthomas2@wanadoo.fr
Mon Oct 17 19:40:00 GMT 2005


Jerry,

This is OK once you have responded to a few niggles and a question on 
the functioning of the patch:

>  
>+   array_loop_spec *ls;  /* For traversing arrays */
>
I know that this is in keeping with the originator's style but could you 
start to set comments above and aligned with the line of code.

>
>!             carry = 1;
>!             record = 0;
>!             rank = GFC_DESCRIPTOR_RANK(ioparm.internal_unit_desc);
>!             ls = current_unit->ls;
>!             for (i = 0; i < rank; i++)
>!               {
>!                 if (carry)
>!                   {
>!                     ls[i].idx++;
>!                     if (ls[i].idx > ls[i].end)
>!                       {
>!                         ls[i].idx = ls[i].start;
>!                         carry = 1;
>!                       }
>!                     else
>!                       carry = 0;
>!                   }
>!                 record = record + (ls[i].idx - 1) * ls[i].step;
>!               }
>
I think that it is worthwhile to break this out into a separate function 
while you are about it.  I think that this section now appears four 
times between list_read.c and transfer.c?

>
>!   
>!   for (i=0; i<rank; ++i)
>      {
>!       /* Initialize the loop specification */
>        
>!       internal_unit.ls[i].idx = 1;
>!       internal_unit.ls[i].start = desc->dim[i].lbound;
>!       internal_unit.ls[i].end = desc->dim[i].ubound;
>!       internal_unit.ls[i].step = desc->dim[i].stride;
>!       
>!       /* Determine the number of records */
>!       
>!       record_count += (desc->dim[i].ubound - desc->dim[i].lbound)
>!                       * desc->dim[i].stride;
>      }
>    return record_count;
>
...and this too.  This will make both this and the namelist code look a 
lot tidier.

Now for the question: I wonder if this behaves as it should?

[prt@localhost mytests]# cat arrayio_test.f90
character*4, dimension(8) :: abuf = (/"0123","4567","89AB","CDEF", &
  "0123","4567","89AB","CDEF"/)
character*4, dimension(2,4) :: buf
character*8 :: a
equivalence (buf,abuf)
read(buf(2, 1:3:2), '(a)') a
print *,a
end

[prt@localhost mytests]# ./a.out
 456789AB

g95 and ifc yield

 4567          ie. the end of record is acted upon.

Paul







More information about the Fortran mailing list