is there any way to make the example below working??
Program Test Class(*), allocatable :: tmp(:,:) integer :: i integer, allocatable :: b(:,:) Allocate(integer::tmp(3,3)) open(50,file="tmp1.txt",action="read",status="old",iostat=i) if(i/=0) Then write(*,*) i End if Do i=1,3 Select Type(tmp) Type Is(Integer) read(50,*) tmp(i,:) End Select End Do Do i=1,3 Select Type(tmp) Type Is(Integer) write(*,*) tmp(i,:) End Select end Do Select Type(tmp) Type Is(Integer) call move_alloc(tmp,b) End Select End Program Test
While everything shakes out nicely, the "move_alloc" construct doesn't. I could circumvent it by using a source allocation, but that would double the memory usage until I deallocate tmp. If I haven't got it wrong move_alloc cannot be used because Select Type creates a pointer.
The purpose of the whole exercise is to have a generalized reading routine for rectangular arrays (without writing extra code and using an interface) where I just provide a keyword telling with what data type tmp should be allocated.