|
From: John on 16 Apr 2008 08:42 Is the below code standard conforming? I have one group saying it is and another saying it isn't. Both are very knowledgeable about Fortran. One compiler compiles with no errors, but another flags an error. Of course, you can always move the "real :: z(t%n)" below the "type (tt) :: t" to avoid any problem, but I am concerned about the order shown. Thanks, John module test_module implicit none type tt integer :: n end type tt contains !========================== subroutine test_sub_1(z,t) implicit none real :: z(t%n) type (tt) :: t end subroutine test_sub_1 !========================== end module test_module
From: Craig Dedo on 16 Apr 2008 09:11 "John" <gh14tq5(a)yahoo.com> wrote in message news:fu4ru9$dbi$1(a)aioe.org... > Is the below code standard conforming? I have one group saying it is and > another saying it isn't. Both are very knowledgeable about Fortran. One > compiler compiles with no errors, but another flags an error. Of course, you > can always move the "real :: z(t%n)" below the "type (tt) :: t" to avoid any > problem, but I am concerned about the order shown. > > Thanks, > John No, it is not standard conforming. Using the name of a derived type before it is defined explicitly violates the rules in section 5.1.1.1 of Fortran 2003. Here is the relevant text: [Begin quote] 5.1.1.1 TYPE A TYPE specifier is used to declare entities of a derived type. Where a data entity id declared explicitly using the TYPE specifier, the derived type shall have been defined previously in the scoping unit or be accessible there by use or host association. [End of quote] There is an exception later in the paragraph for function results. > module test_module > implicit none > > type tt > integer :: n > end type tt > > contains > !========================== > subroutine test_sub_1(z,t) > implicit none > > real :: z(t%n) > type (tt) :: t > > end subroutine test_sub_1 > !========================== > end module test_module -- Craig Dedo 17130 W. Burleigh Place P. O. Box 423 Brookfield, WI 53008-0423 Voice: (262) 783-5869 Fax: (262) 783-5928 Mobile: (414) 412-5869 E-mail: <cdedo(a)wi.rr.com> or <craig(a)ctdedo.com>
From: Michael Metcalf on 16 Apr 2008 09:11 "John" <gh14tq5(a)yahoo.com> wrote in message news:fu4ru9$dbi$1(a)aioe.org... > Is the below code standard conforming? I have one group saying it is and > another saying it isn't. Both are very knowledgeable about Fortran. One > compiler compiles with no errors, but another flags an error. Of course, > you can always move the "real :: z(t%n)" below the "type (tt) :: t" to > avoid any problem, but I am concerned about the order shown. > The code is not legal. Any variable referenced in a specification expression must have its type specified earlier in the sequence ("Fortran 95/2003 Explained", Section 7.14). Regards, Mike Metcalf
From: Richard Maine on 16 Apr 2008 11:32 Craig Dedo <cdedo(a)wi.rr.com> wrote: > "John" <gh14tq5(a)yahoo.com> wrote in message > news:fu4ru9$dbi$1(a)aioe.org... > > Is the below code standard conforming?.. > No, it is not standard conforming. Using the name of a derived type > before it is defined explicitly violates the rules in section 5.1.1.1 of > Fortran 2003. While I agree that the code is illegal, this isn't the reason. See Michael's post for the relevant citation. The code in question does not use the name of a derived type before it is defined. The name of the derived type is "acessible there by use or host association", which your citation specifically says is ok. The code uses the name of a *VARIABLE* before that variable is defined, which is a diferent thing. The variable happens to be of derived type, but that's not directly relevant to the problem. -- Richard Maine | Good judgement comes from experience; email: last name at domain . net | experience comes from bad judgement. domain: summertriangle | -- Mark Twain
From: Craig Dedo on 16 Apr 2008 11:50 "Richard Maine" <nospam(a)see.signature> wrote in message news:1ifhe06.1tbdnqwxbkkN%nospam(a)see.signature... > Craig Dedo <cdedo(a)wi.rr.com> wrote: > >> "John" <gh14tq5(a)yahoo.com> wrote in message >> news:fu4ru9$dbi$1(a)aioe.org... >> > Is the below code standard conforming?.. > >> No, it is not standard conforming. Using the name of a derived type >> before it is defined explicitly violates the rules in section 5.1.1.1 of >> Fortran 2003. > > While I agree that the code is illegal, this isn't the reason. See > Michael's post for the relevant citation. > > The code in question does not use the name of a derived type before it > is defined. The name of the derived type is "acessible there by use or > host association", which your citation specifically says is ok. The code > uses the name of a *VARIABLE* before that variable is defined, which is > a diferent thing. The variable happens to be of derived type, but that's > not directly relevant to the problem. > > -- > Richard Maine | Good judgement comes from experience; > email: last name at domain . net | experience comes from bad judgement. > domain: summertriangle | -- Mark Twain Oops. My bad. Thanks for the correction. -- Craig Dedo 17130 W. Burleigh Place P. O. Box 423 Brookfield, WI 53008-0423 Voice: (262) 783-5869 Fax: (262) 783-5928 Mobile: (414) 412-5869 E-mail: <cdedo(a)wi.rr.com> or <craig(a)ctdedo.com>
|
Next
|
Last
Pages: 1 2 Prev: Fortran templates Next: Dalai Lama: your smiles charm but your actions harm |