[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-12 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

Jerry DeLisle  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #15 from Jerry DeLisle  ---
closing

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-12 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #14 from Jerry DeLisle  ---
Fixed on trunk.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-11 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #13 from Jerry DeLisle  ---
Author: jvdelisle
Date: Sat Mar 11 14:49:57 2017
New Revision: 246070

URL: https://gcc.gnu.org/viewcvs?rev=246070=gcc=rev
Log:
2017-03-11  Jerry DeLisle  

PR libgfortran/78854
* io/list_read.c (nml_get_obj_data): Stash internal unit for
later use by child procedures.
* io/write.c (nml_write_obj): Likewise.
* io/tranfer.c (data_transfer_init): Minor whitespace.
* io/unit.c (set_internal_uit): Look for the stashed internal
unit and use it if found.

* gfortran.dg/dtio_25.f90: New test.

Added:
trunk/gcc/testsuite/gfortran.dg/dtio_25.f90
Modified:
trunk/gcc/testsuite/ChangeLog
trunk/libgfortran/ChangeLog
trunk/libgfortran/io/list_read.c
trunk/libgfortran/io/transfer.c
trunk/libgfortran/io/unit.c
trunk/libgfortran/io/write.c

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-05 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #12 from Jerry DeLisle  ---
Here is a modified test case where I test the iotype and if its is NAMELIST, I
format the output to what would be expected.  Since there is no user defined
namelist read, it just uses default reading of the namelist.

MODULE m
  IMPLICIT NONE
  TYPE :: t
CHARACTER :: c
  CONTAINS
PROCEDURE :: write_formatted
GENERIC :: WRITE(FORMATTED) => write_formatted
  END TYPE
CONTAINS
  SUBROUTINE write_formatted(dtv, unit, iotype, v_list, iostat, iomsg)
CLASS(t), INTENT(IN) :: dtv
INTEGER, INTENT(IN) :: unit
CHARACTER(*), INTENT(IN) :: iotype
INTEGER, INTENT(IN) :: v_list(:)
INTEGER, INTENT(OUT) :: iostat
CHARACTER(*), INTENT(INOUT) :: iomsg
if (iotype.eq."NAMELIST") then
  WRITE (unit, '(a,a,a)') 'x%c="',dtv%c,'",'
else
  write (unit,*) dtv%c
end if
  END SUBROUTINE
END MODULE

PROGRAM p
  USE m
  IMPLICIT NONE
  character(len=50) :: buffer
  TYPE(t) :: x
  NAMELIST /nml/ x
  x = t('a')
  WRITE (buffer, nml)
  write(*,nml)
  print *, buffer
  x = t('x')
  print *, x%c
  READ (buffer, nml)
  print *, x%c
END

The output with the preliminary patch is:

$ ./a.out 

x%c="a",
 /
  x%c="a",  /  
 x
 a

So it appears the basic namelist to buffer I/O is working correctly.  The next
step will be to decide exactly how to format the namelist writes/reads.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-05 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #11 from Jerry DeLisle  ---
Created attachment 40885
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40885=edit
A preliminary patch. Any and all testing greatly appreciated.

I am regression testing this now. I wanted to get it out tonight so others can
be looking at it sooner.  Need to think of some test cases.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-03-03 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #10 from Jerry DeLisle  ---
We are not handling the internal unit check correctly in unit.c (get_unit) and
we return a NULL to the caller which is then interpreted as an error. I am
working on the fix now. (just a little head scratching)

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-02-16 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #9 from Jerry DeLisle  ---
(In reply to janus from comment #1)
> This essentially blocks PR 78661, for which it is very hard to write a
> proper test case as long as this bug is unfixed.

Janus, you could open a file with status scratch, right to it with namelist,
read back as lines of text and check the results that way, Then one could get
pr78661 out of the way.

Can you do that?

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2017-02-12 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #8 from Jerry DeLisle  ---
Sorry for the delay here. The unit number passed to the users dtio procedure is
0, so thats clearly wrong. I will see if I can fix that and see what happens.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #7 from Jerry DeLisle  ---
(In reply to janus from comment #2)
> I'm afraid I have too little knowledge of the I/O parts of libgfortran to
> fix, but I can at least give some pointers to where things appear to go
--- snip ---
>   if (is_internal_unit (dtp))
> ...

Internal units require special handling in many places and have a lot of corner
cases, as do namelists.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread jvdelisle at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

Jerry DeLisle  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |jvdelisle at gcc dot 
gnu.org

--- Comment #6 from Jerry DeLisle  ---
On my list

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread paul.richard.thomas at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #5 from paul.richard.thomas at gmail dot com  ---
Hi Janus,

Jerry is the expert here.

Cheers

Paul

On 19 December 2016 at 11:59, janus at gcc dot gnu.org
 wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854
>
> --- Comment #4 from janus at gcc dot gnu.org ---
> Another starting point could be the fact that DTIO procedures appear to work
> well on internal units, as long as no namelist output is involved. This case
> seems to be handled by "formatted_transfer_scalar_write"?
>
> --
> You are receiving this mail because:
> You are on the CC list for the bug.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #4 from janus at gcc dot gnu.org ---
Another starting point could be the fact that DTIO procedures appear to work
well on internal units, as long as no namelist output is involved. This case
seems to be handled by "formatted_transfer_scalar_write"?

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread dominiq at lps dot ens.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

Dominique d'Humieres  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2016-12-19
 Ever confirmed|0   |1

--- Comment #3 from Dominique d'Humieres  ---
Confirmed.

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-19 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

--- Comment #2 from janus at gcc dot gnu.org ---
I'm afraid I have too little knowledge of the I/O parts of libgfortran to fix,
but I can at least give some pointers to where things appear to go wrong ...

In the function "nml_write_obj" at line 2210 of write.c there is a block
starting with:


  if (obj->dtio_sub != NULL)
{
  int unit = dtp->u.p.current_unit->unit_number;


This whole block deals with calling DTIO procedures. Apparently the line above
that sets the unit is not enough to deal with internal units.

It seems that there is some code to deal with internal units e.g. in the
function "write_block" in transfer.c:

  if (is_internal_unit (dtp))
...

[Bug fortran/78854] [F03] DTIO namelist output not working on internal unit

2016-12-18 Thread janus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78854

janus at gcc dot gnu.org changed:

   What|Removed |Added

   Keywords||wrong-code
 CC||jvdelisle at gcc dot gnu.org,
   ||pault at gcc dot gnu.org
 Blocks||78661

--- Comment #1 from janus at gcc dot gnu.org ---
This essentially blocks PR 78661, for which it is very hard to write a proper
test case as long as this bug is unfixed.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78661
[Bug 78661] [OOP] Namelist output missing object designator under DTIO