allocatable-array

Fortran: Choosing the rank of an allocatable array

删除回忆录丶 提交于 2019-11-28 06:38:30
问题 I am trying to write a program where I want the allocatable array A to be of either rank 1, 2, or 3, depending on my input at run-time. I want to do this since the subsequent operations on A are similar, and I have defined in a module an interface work with module procedures that when acted on A , gives the desired result. What I am doing currently is this: program main implicit none integer :: rank,n=10 real*8, allocatable :: A1(:) real*8, allocatable :: A2(:,:) read (*,*) rank if (rank.eq.1