JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for COMP-FORTRAN-90 Archives


COMP-FORTRAN-90 Archives

COMP-FORTRAN-90 Archives


COMP-FORTRAN-90@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2003

COMP-FORTRAN-90 2003

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Can you call a subroutine with arguments like this?

From:

Richard Maine <[log in to unmask]>

Reply-To:

Fortran 90 List <[log in to unmask]>

Date:

Thu, 1 May 2003 11:39:23 -0700

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (110 lines)

P Suckling writes:
 > If someone has a moment to spare could they confirm something for me please? I
 > am not sure if I am interpreting a point in the standard correctly.
 >
 > Does section 16.5.7 point (10), regarding a variable with the INTENT(IN)
 > attribute mentioned in section 5.1.2.7 of the current standard mean that the
 > following (admittedly almost completely pointless) code is not allowed?

I assume you are looking at one of the f2k drafts, since there isn't
any section 16 in f90 or f95. Note that in quoting from f2k drafts,
one needs to specify which dfaft, because it is still changing. For
instance, I can't tell whether you are quoting from the CD or from the
new internal working draft that just came out on Friday. (It's only
an internal working draft - definitely not yet ready for the next
public review). For this question it doesn't matter, but for other
questions, it would.

The code in question is illegal, but not for reasons directly related
to that section. That section defines a term (variable definition
context) that is used in some places to express *SYNTACTIC*
constraints. All the places where it gets used really are syntactic
(and this compile-time checkable). When it talks about the appearance
of a variable, it means the syntactic appearance of that variable. It
is not talking about other things that might happen to be associated
with the variable for one reason or other.

The code is illegal for the following reasons (none of them related to
16.5.7).


1. 12.4.1.7(1) of the f2k CD (12.4.1.6(1) in f95).

   While actual_type%bob is associated with a dummy argument
   (i.e. while asub_sub is executing), there is action that
   affects its value (i.e. the assignment in the subroutine),
   and that action is taken other than through the dummy argument
   that actual_type%bob is associated. (It is taken through the
   other dummy argument).

   Yes, I know that particular bit of standard-speak is hard to
   read.

2. 12.4.1.7(2) of the f2k CD (12.4.1.6(2) in f95).

   This is closely related to item 1, but the code here does
   manage to violate both item 1 and item 2.

   The value of actual_type is affected in the subroutine through
   the dummy argument dummy_ttype. The value of actual type is also
   referenced in the subroutine other than through that dummy
   (it is referenced through the other dummy).

3. Neither of the above have anything to do with INTENT. If we throw
   INTENT into the stew, then I'd say the code also violates the first
   sentence after the constraints in 5.1.2.7 (F2k CD) or 5.1.2.3 (F95).
   Not the constraints themselves - those are syntactic and are what
   reference the the term "variable definition context". That sentence
   of text, however, is far more broad. It says that any way you might
   come up with to redefine the INTENT(IN) variable is illegal - no
   matter how devious a way it might be. Well, you've shown a slightly
   devious way (which also violates the rules in section 12, but ignore
   that for now).

Note that none of the above things you've violated are constraints.
The compiler is not required to detect the errors. In some cases,
most compilers almost certainly will not catch the errors. In this
case, with the subroutine in question being an internal one, the
compiler does at least have a reasonable chance of diagnosing it, but
is not required to. (And the vendor has a pretty obvious cost/benefit
tradeoff in terms of whether it is worth the development effort to
catch the cases like this vs the question of what fraction of user
errors this actually will find).


 > PROGRAM test_sub_call_prog
 >
 > IMPLICIT NONE
 >
 > TYPE test_type
 > INTEGER :: bob=0
 > END TYPE test_type
 >
 > TYPE(test_type) :: actual_ttype
 >
 > actual_ttype%bob=2
 >
 > CALL asub_sub(actual_ttype,actual_ttype%bob)
 >
 > PRINT *,'actual_ttype%bob: ',actual_ttype%bob
 >
 > CONTAINS
 >
 > SUBROUTINE asub_sub(dummy_ttype,dummy_bob)
 >
 > IMPLICIT NONE
 >
 > TYPE(test_type), INTENT(INOUT) :: dummy_ttype
 > INTEGER, INTENT(IN) :: dummy_bob
 >
 > dummy_ttype%bob=dummy_bob
 >
 > END SUBROUTINE asub_sub
 >
 > END PROGRAM test_sub_call_prog

--
Richard Maine | Good judgment comes from experience;
[log in to unmask] | experience comes from bad judgment.
                             | -- Mark Twain

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

December 2023
February 2023
November 2022
September 2022
February 2022
January 2022
June 2021
November 2020
September 2020
June 2020
May 2020
April 2020
December 2019
October 2019
September 2019
March 2019
February 2019
January 2019
November 2018
October 2018
September 2018
August 2018
July 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
August 2015
June 2015
April 2015
March 2015
January 2015
December 2014
November 2014
October 2014
August 2014
July 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
July 2013
June 2013
May 2013
April 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
August 2010
July 2010
June 2010
March 2010
February 2010
January 2010
December 2009
October 2009
August 2009
July 2009
June 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998
1997


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager