Assignment of Allocatables of Different Shapes in Fortran [duplicate]
问题 This question already has an answer here : Allocatable array valued function. gfortran vs ifort (1 answer) Closed 2 years ago . Please look at the following code: program test implicit none integer, allocatable :: v1(:, :) integer, allocatable :: v2(:, :) allocate(v1(2, 4)) allocate(v2(2, 3)) v1(:, :) = reshape([11, 12, 13, 14, 15, 16, 17, 18], [2, 4]) v2(:, :) = reshape([21, 22, 23, 24, 25, 26], [2, 3]) print *, v1 print *, 'shape(v1): ', shape(v1) print * print *, v2 print *, 'shape(v2): ',