module myfuncts

    contains
subroutine aver3d(a,avg)
real, intent(in) :: a(:,:,:)
real, intent(out) :: avg
integer lba(3),uba(3)
lba=lbound(a)
uba=ubound(a)
print *,"3 d u b=",uba
print *,"3 d l b=",lba
avg = sum(a)
print *,"sum 3d=",avg
na=size(a)
print *,"size 3d=",na
avg=avg/real(na)
end subroutine aver3d

subroutine aver2d(a,avg)

real, intent(in) :: a(:,:)

real, intent(out) :: avg
integer lba(2),uba(2)
lba=lbound(a)
uba=ubound(a)
print *,"2 d u b=",uba
print *,"2 d l b=",lba
avg = sum(a)
print *,"sum 2d=",avg
na=size(a)
print *,"size 2d=",na
avg=avg/real(na)
end subroutine aver2d

subroutine aver1d(a,avg)

real, intent(in) :: a(:)

real, intent(out) :: avg
integer lba,uba
! lba=lbound(a) ! this crashes
! uba=ubound(a) ! so does this
lba=lbound(a,1)
uba=ubound(a,1)
print *,"bounds=",lba,uba

avg = sum(a)
print *,"sum 1d=",avg
na=size(a)
print *,"size 1d=",na
avg=avg/real(na)

end subroutine aver1d

end module
