Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Derived typ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 13 of 26 Topic 8212 of 8908
Post > Topic >>

Re: Derived types and allocatable

by "James Van Buskirk" <not_valid@[EMAIL PROTECTED] > May 14, 2008 at 11:03 AM

"James Giles" <jamesgiles@[EMAIL PROTECTED]
> wrote in message 
news:_2rVj.186212$D_3.46099@[EMAIL PROTECTED]
> Some people might read the above as implying that there's an
> incompatibility between F95 and F2003.  That's not quite right.  The
> syntax and semantics of those cases allowed by the old standard
> are identical in the new standard.  However, the new standard
> provides a meaning for cases the older standard explicitly prohibited.
> No standard conforming F95 program should behave any differently
> under F2003.

Yes, but a standard conforming f03 program may be interpreted as
an f95 program with extensions.

C:\gfortran\clf\confusion>type confusion.f90
module mod
   implicit none
   contains
      subroutine sub(x,label)
         integer x(:,:)
         character(*) label
         character(80) fmt

         write(*,'(a)') label//' ='
         write(fmt,'(a,i0,a)') '(',size(x,2),'i3)'
         write(*,fmt) transpose(x)
      end subroutine sub
end module mod

program confusion
   use mod
   implicit none
   integer, allocatable :: x1(:,:)
   integer, allocatable :: y1(:,:)
   integer, allocatable :: x2(:,:)
   integer, allocatable :: y2(:,:)
   integer i

   allocate(x1(2,3))
   x1 = reshape([(i,i=1,size(x1))],shape(x1))
   allocate(y1(3,2))
   y1 = 1
   allocate(x2(3,2))
   allocate(y2(2,3))
   x2 = x1
   y2 = y1
   call sub(x1,'x1')
   call sub(x2,'x2')
   call sub(y1,'y1')
   call sub(y2,'y2')
   call sub(matmul(x2,y2),'matmul(x2,y2)')
end program confusion

C:\gfortran\clf\confusion>gfortran confusion.f90 -oconfusion

C:\gfortran\clf\confusion>confusion
x1 =
  1  3  5
  2  4  6
x2 =
  1  3
  2  4
  3  6
y1 =
  1  1
  1  1
  1  1
y2 =
  1  1  1
  1  1  6
matmul(x2,y2) =
  4  4 19
  6  6 26
  9  9 39

C:\gfortran\clf\confusion>ifort /check:bounds confusion.f90
Intel(R) Fortran Compiler for Intel(R) EM64T-based applications, Version
9.1
Build 20061104
Copyright (C) 1985-2006 Intel Cor****ation.  All rights reserved.

Microsoft (R) Incremental Linker Version 8.00.40310.39
Copyright (C) Microsoft Cor****ation.  All rights reserved.

-out:confusion.exe
-subsystem:console
confusion.obj

C:\gfortran\clf\confusion>confusion
x1 =
  1  3  5
  2  4  6
x2 =
  1  3
  2  4
  3  5
y1 =
  1  1
  1  1
  1  1
y2 =
  1  1***
  1  1***
matmul(x2,y2) =
  4  4***
  6  6***
  8  8***

We see the f03 behavior in neither compiler.

-- 
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end
 




 26 Posts in Topic:
Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 16:01:28 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:09:36 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:41:26 
Re: Derived types and allocatable
Steven Correll <steven  2008-05-06 07:08:11 
Re: Derived types and allocatable
"James Giles" &  2008-05-11 00:26:34 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-14 12:07:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:30:39 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 12:39:38 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 20:49:59 
Re: Derived types and allocatable
glen herrmannsfeldt <g  2008-05-14 13:27:46 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 21:40:48 
Re: Derived types and allocatable
=?ISO-8859-15?Q?Jan_Vorbr  2008-05-15 11:14:13 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-14 11:03:21 
Re: Derived types and allocatable
"James Giles" &  2008-05-14 19:37:02 
Re: Derived types and allocatable
"Kurt Kallblad"  2008-05-07 07:56:49 
Re: Derived types and allocatable
nospam@[EMAIL PROTECTED]   2008-05-07 00:15:43 
Re: Derived types and allocatable
Gib Bogle <bogle@[EMAI  2008-05-08 08:35:27 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-07 12:03:34 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-07 15:33:13 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 09:05:09 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-08 12:52:00 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-08 19:56:55 
Re: Derived types and allocatable
Steve Lionel <Steve.Li  2008-05-09 14:11:34 
Re: Derived types and allocatable
Damian <damian@[EMAIL   2008-05-09 12:15:07 
Re: Derived types and allocatable
"James Van Buskirk&q  2008-05-06 00:11:29 
Re: Derived types and allocatable
Gib Bogle <g.bogle@[EM  2008-05-06 18:39:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 7:50:42 CST 2008.