I have a constant array that I would like to use, but I would prefer not to have to use an initialization call to set it up, rather it would be preferable to have it be a parameter. However, I haven't been able to figure out the correct syntax, assuming that it is possible, or to confirm that it is not possible.
Example code below. Is it possible?
module mymod
implicit none
private
public initmymod, printinit
integer, parameter :: n=11
real, parameter :: startval=10.,stopval=20.,step=(stopval-startval)/(n-1)
! would rather use something like this parameter statement than a protected array, is it possible?
! real, parameter :: vals_p(n) = startval+(i-1)*step,i,1,10
! using this, along with the initmymod setup. Works, but would prefer to use a parameter array
real, dimension(n), protected :: vals
contains
subroutine initmymod()
integer :: i
do i = 1,n
vals(i) = startval+(i-1)*step
end do
end subroutine
subroutine printinit()
print *, vals
end subroutine
end module
program main
use mymod
implicit none
call initmymod
call printinit
end program main