Fortran unknown aray size

I have two matrix lets say a(5,200) b(200,1) i want to calculate : c = (transpose(a))*a. And d = (transpose ((a))*b If i dont know the size of matrix c and d how i can declare them in the begining i have tried c(:,:) and d(:,:) but it doesnt work and the one in google is complicated . Explain to me pls

23rd Jun 2019, 9:44 PM
1 Answer
The problem you are trying to solve is fairly straightforward. If you do not know the size of the array at the start, you should use dynamically allocated array. real, dimension(:,:), allocatable :: c, d Later when you get to know the sizes of a and b, you allocate those arrays as integer clen = awidth integer cwidth = awidth integer dlen = alen integer dwithd = bwidth allocate( c (clen,cwidth) & ,d (dlen,dwidth) & ) and proceed with the calculations as planned.
9th Oct 2022, 11:11 PM
Honza Chylik
Honza Chylik - avatar