Hello, I have programmed in Fortran in the past, but it is safe to say that I am very much a novice. My current goal is to write a function, or subroutine for that matter, that accepts an array of rank one as its argument, and determines it's size from within the function/subroutine. I figure that this way I wont have to pass the dimensions as arguments, making the function/subroutine more general.
It seems simple enough, however, I am getting rank mismatch issues when compiling with gfortran. More specifically, it complains at n = lbound(vec), saying that n has rank 0 while lbound(vec) has rank 1. I don't understand why these two would have different ranks? Do they have different ranks, or is this a gfortran-specific problem? Any and all help is much appreciated. Below is the code that I'm working with.
PROGRAM arrayarg
REAL, DIMENSION(10):: a
DO i = 1, 10
a(i) = i
END DO
CALL showsize(a)
END PROGRAM arrayarg
SUBROUTINE showsize(vec)
REAL, DIMENSION)::vec
INTEGER n
n = lbound(vec)
END SUBROUTINE showsize
Thanks,
Daniel
It seems simple enough, however, I am getting rank mismatch issues when compiling with gfortran. More specifically, it complains at n = lbound(vec), saying that n has rank 0 while lbound(vec) has rank 1. I don't understand why these two would have different ranks? Do they have different ranks, or is this a gfortran-specific problem? Any and all help is much appreciated. Below is the code that I'm working with.
PROGRAM arrayarg
REAL, DIMENSION(10):: a
DO i = 1, 10
a(i) = i
END DO
CALL showsize(a)
END PROGRAM arrayarg
SUBROUTINE showsize(vec)
REAL, DIMENSION)::vec
INTEGER n
n = lbound(vec)
END SUBROUTINE showsize
Thanks,
Daniel