Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring matrix dimensions from an input file

Status
Not open for further replies.

dimis414

Programmer
Jul 14, 2014
2
GR
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)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top