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:

Proportional Font

LISTSERV Archives

LISTSERV Archives

COMP-FORTRAN-90 Home

COMP-FORTRAN-90 Home

COMP-FORTRAN-90  2000

COMP-FORTRAN-90 2000

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Re: Standards question

From:

Jan van Oosterwijk <[log in to unmask]>

Reply-To:

Jan van Oosterwijk <[log in to unmask]>

Date:

Tue, 07 Nov 2000 13:35:20 +0100

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (144 lines)


Hello,

At 15:10 06-11-2000 -0500, you wrote:
>
>Forwarded for a colleague:
>
>I have a question about what the F77/F90 standards say about making
>out of bounds references in arrays.  I have looked at them, but my
>problem seems to fall in a gray area.  From a client, I have a code
>which logically has no out of bounds indexing problems, but may
>actually not be standard conforming -- it's unclear to me.  Although I
>compile this code with several F95 compilers, it is really just an F77
>code.
>
>Here is an excerpt from the routine in question with extraneous lines
>deleted. 
>
>
>      subroutine nospin(z)
>
>      include 'size.h'
>:
! work around:
       integer :: QWERTY = 6
!...  Number of diamonds mapped to a local process (5 or 10):
      parameter(nd= 5)
! ..
      real z(0:nt,nt+1,nd,3,nr+1), s(6)
! Now z has dimension(  ,  ,  5 , 3 , )
>:
>:
>      do ir=1,nr+1
> 
>         s(3) = 0.
>         s(6) = 0.
> 
>         if(mynum.eq.0 .and. nd.eq.10) then
>            s(1) =  2.
>            s(2) =  2.
!            s(4) =  z(0,1,1,2,ir) - z(0,1,6,2,ir)       <== (line 671)
           s(4) =  z(0,1,1,2,ir) - z(0,1, QWERTY,2,ir)    <== (line 671.5)
  
  I did not try to look it up in the Standard, nor did I try
  this fragment on one of the available Fortran compilers, but ...
  I suppose that the compiler may consider this to be out of bounds 
  because constant 6  >  constant ND (=5).

>            s(5) =  z(0,1,6,1,ir) - z(0,1,1,1,ir)       <== (line 672)
>         elseif(mynum .eq. 0) then
>            s(1) =  1.
>            s(2) =  1.
>            s(4) =  z(0,1,1,2,ir)
>            s(5) = -z(0,1,1,1,ir)
>         elseif(mynum.eq.mproc .and. nd.le.5) then
>            s(1) =  1.
>            s(2) =  1.
>            s(4) = -z(0,1,1,2,ir)
>            s(5) =  z(0,1,1,1,ir)
>         else
>            s(1) =  0.
>            s(2) =  0.
>            s(4) =  0.
>            s(5) =  0.
>         endif
>:
>:
>
>Note that the declared dimensions of z are specified with Fortran
>parameters.  These are included through the file 'size.h' and listed
>at the bottom of this message.  In particular, note the third
>dimension specified by 'nd'.  That parameter is always set to either 5
>or 10 depending on the case to be run.  This code compiles and
>executes fine with the Cray F90, MIPSPro F90, and PGHPF (F95)
>compilers.  However, the NAG compiler "NAGWare Fortran 95 compiler
>Release 4.0a(341)" compiles and gives the following errors:
>
>Error: solver.cpp.f, line 671: Third subscript (6) is greater than upper
bound (5) for array Z
>Error: solver.cpp.f, line 672: Third subscript (6) is greater than upper
bound (5) for array Z
>
>It is true that the listed lines WOULD reference outside the bounds of
>z's third dimension, IF those lines were executed.  The if test
>explicitly prevents this by checking if 'nd' is 10 or not.  So
>logically and in execution, there is no problem.
>
>Does the standard say this is expressly illegal, that the behavior is
>undefined so vendor determined or does the code meet the standard?
>
>I'm not asking about style convention or ways to fix this.  As I said,
>several other compilers handle this code just fine.  I am interested
>because NAG gives an error rather than just a warning and I can find
>no way to disable it or lessen the severity.
>
>Thanks for your input.
>
>Spencer
>
>
>$> cat size.h
>c...  Number of grid intervals along icosahedral diamond edge:
>      parameter(mt= 32)
> 
>c...  Number of grid intervals along edge of local subdomain:
>      parameter(nt=16)
> 
>c...  Number of diamonds mapped to a local process (5 or 10):
>      parameter(nd= 5)
> 
>c...  Note: Number of processes is given by (mt/nt)**2*10/nd.
> 
>c...  Number of radial layers:
>      parameter(nr= mt/2)
> 
>c...  Number of diamonds dimension for opr array (1, 5 or 10):
>      parameter(ndo= nd)
>c...  Note:  If there is no lateral viscosity variation, ndo may
>c...         be set to 1; otherwise, it must be set equal to nd.
> 
>c...  Number of grid points (vertices) in local subdomain:
>      parameter(nv= (nt+1)**2*nd*(nr+1))


--

Meilleures Salutations,
Kindest Regards,
/---
Jan van Oosterwijk
Computing Centre
Delft University of Technology
Postbus    354
2600 AJ  Delft
Netherlands / Pays-Bas
mailto:[log in to unmask]
Phone: +31 15 27 85017
Fax:   +31 15 27 83787




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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