Assuming that in a subroutine we use a matrix named as VOL(IDI,IDI).
Instead of declaring IDI in PARAMETER command, i.e: PARAMETER (IDI=10), is it possible to declare it at the input file, so the matrix dimensions whould change depending on the input file?
Depends on which version of Fortran you are using. F77 no, F90 onwards yes.
Code:
real, dimension(:,:), allocatable:: vol
integer:: idi, status
...
! to get the value of idi
read(channel, *) idi
! to allocate the space
allocate(vol(idi,idi))
...
! when you've finished with it
deallocate(vol, stat = status)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.