- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the intrinsic function UBOUND to determine the size of an array, transferred as parameter to a subroutine. I am not able even to compile the code.
As far as I read the documentation, it should be possible the determine the upper bound of an assumed size array.
What am I dping wrong ????
Example:
As far as I read the documentation, it should be possible the determine the upper bound of an assumed size array.
What am I dping wrong ????
Example:
program bounds implicit none INTEGER(4), PARAMETER :: MXDIME=10 INTEGER(4) :: NXTEST,MXBOUN DIMENSION NXTEST(1:MXDIME) MXBOUN=LBOUND(NXTEST,DIM=1) WRITE(*,*) 'MAIN:LOWER BOUNDS:',MXBOUN MXBOUN=UBOUND(NXTEST,DIM=1) WRITE(*,*) 'MAIN:UPPER BOUNDS:',MXBOUN CALL XTESTS(NXTEST) end program bounds SUBROUTINE XTESTS(NYTEST) IMPLICIT NONE INTEGER(4) :: NYTEST,MXBOUN DIMENSION NYTEST(*) MXBOUN=LBOUND(NYTEST,DIM=1) WRITE(*,*) 'SUB:LOWER BOUNDS:',MXBOUN MXBOUN=UBOUND(NYTEST,DIM=1) WRITE(*,*) 'SUB:UPPER BOUNDS:',MXBOUN END
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The wording in the manual is "It can be an assumed-size array if DIM is present with a value less than the rank of ARRAY." (emphasis mine).
In your case, your array argument has rank 1, therefore there is no value of DIM that is acceptable. The idea is if you have a multi-dimensioned array, you can use UBOUND to get the bound of all but the last dimension, since only the last is permitted to have * as an upper bound.
Steve
In your case, your array argument has rank 1, therefore there is no value of DIM that is acceptable. The idea is if you have a multi-dimensioned array, you can use UBOUND to get the bound of all but the last dimension, since only the last is permitted to have * as an upper bound.
Steve

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page