public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/18022] New: problem with structure and calling a function
@ 2004-10-15 19:01 gruel at astro dot ufl dot edu
  2004-10-21 19:27 ` [Bug fortran/18022] " tobi at gcc dot gnu dot org
                   ` (20 more replies)
  0 siblings, 21 replies; 27+ messages in thread
From: gruel at astro dot ufl dot edu @ 2004-10-15 19:01 UTC (permalink / raw)
  To: gcc-bugs

there are a bug when you mix structure and function. Only the first part of the
structure seems to act correctly. The best thing is to try this sample:

The tab and the pts must be equal in their components and it's not the case.

I saw another things I don't like (even if I think that the norm required
nothing), it's the initial value of a tab: the majorities of the value are 0 but
sometimes it's random, I'll prefer to have all the value random (you have no
choice to initialize all you're variable) or (better I think) to have all the
value equal at 0.

Thanks,

 
Nicolas

program test_bug

  implicit none

  character(len=20), dimension(4,2) :: tab_c
  real,dimension(4,2) :: tab
  integer :: i,j
  
  type :: point
     real :: x,y
  end type point
  type(point), dimension(4) :: pts
  
  tab_c(:,1)(:) = (/'1','2','3','4'/)
  tab_c(:,2)(:) = (/'2','3','4','5'/)

  print*, tab_c

  do i=1,2
     tab(:,i) = char2real_1d(tab_c(:,i))
  end do

  pts%x =  char2real_1d(tab_c(:,1))
  pts%y =  char2real_1d(tab_c(:,2))

  print*, "pts ",pts
  print*, "tab ", tab

contains
  function char2real_1d (tab_c,error) result (tab_r)
    character(len=*), dimension(:), intent(in) :: tab_c
    real, intent(in), optional :: error 

    real, dimension(size(tab_c)) :: tab_r

    integer :: i
    real:: err

    if (.not. (present(error))) then
       err = 9999.99
    else
       err = error
    end if
    do i=1,size(tab_c)       
       if (verify(trim(tab_c(i)),"0123456789-+.Ee " ) == 0) then
          read (unit=tab_c(i),fmt=*) tab_r(i)
       else
          tab_r (i) = err
       end if
    end do
  end function char2real_1d

end program test_bug

-- 
           Summary: problem with structure and calling a function
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gruel at astro dot ufl dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18022


^ permalink raw reply	[flat|nested] 27+ messages in thread
[parent not found: <bug-18022-9317@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2005-10-23 22:55 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-15 19:01 [Bug fortran/18022] New: problem with structure and calling a function gruel at astro dot ufl dot edu
2004-10-21 19:27 ` [Bug fortran/18022] " tobi at gcc dot gnu dot org
2005-07-05 14:52 ` gruel at astro dot ufl dot edu
2005-07-08  9:38 ` paulthomas2 at wanadoo dot fr
2005-07-08 13:02 ` paulthomas2 at wanadoo dot fr
2005-07-08 13:34 ` gruel at astro dot ufl dot edu
2005-07-09  0:29 ` tobi at gcc dot gnu dot org
2005-07-09 11:39 ` tobi at gcc dot gnu dot org
2005-07-09 11:47 ` tobi at gcc dot gnu dot org
2005-07-09 11:52 ` tobi at gcc dot gnu dot org
2005-07-09 12:04 ` tobi at gcc dot gnu dot org
2005-07-09 12:14 ` tobi at gcc dot gnu dot org
2005-07-09 13:14 ` paulthomas2 at wanadoo dot fr
2005-07-09 14:39 ` paulthomas2 at wanadoo dot fr
2005-07-09 15:12 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2005-07-09 17:50 ` tobi at gcc dot gnu dot org
2005-07-10 17:22 ` tobi at gcc dot gnu dot org
2005-07-10 17:25 ` paulthomas2 at wanadoo dot fr
2005-07-10 17:37 ` paulthomas2 at wanadoo dot fr
2005-07-10 17:52 ` Tobias dot Schlueter at physik dot uni-muenchen dot de
2005-07-10 18:09 ` paulthomas2 at wanadoo dot fr
2005-08-03 10:01 ` paulthomas2 at wanadoo dot fr
     [not found] <bug-18022-9317@http.gcc.gnu.org/bugzilla/>
2005-10-13  4:48 ` pault at gcc dot gnu dot org
2005-10-23  6:59 ` cvs-commit at gcc dot gnu dot org
2005-10-23 15:46 ` cvs-commit at gcc dot gnu dot org
2005-10-23 16:26 ` pault at gcc dot gnu dot org
2005-10-23 22:55 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).