The repeat-count on a format specifier in an I/O statement is not necessarily the dimension of an array in the data-list. It is entirely legal for several distinct data items to correspond to a single repeated format specifier like:
write(unit,'(3f5.1)') x,y,z
or for an array to correspond to several different format specifiers:
real::a(3)
write(unit,'(f5.1,f10.2,f5.1)') a
And if there are more format specifiers than needed for the data-list (which can be variable using dynamic bounds and/or implied-do), including but not limited to repeated specifiers, the extra are ignored. Thus the traditional way (back to F66 at least) to handle a variable number of data items (in one dimension) is to use a 'huge' repeat count that is at least as large as the data ever is.
Your arrays are of complex
elements, so each element is actually two values and the format repeat must be at least twice the number of elements.
Since F77 the format can be a character variable and you can set the value of that (or any other) character variable with an 'internal' WRITE, which allows constructing and using a data-dependent format. This method allows you to tailor the format for a 2-D array to one (exact) dimension.
An example showing both of these methods for your case:
program SO43482939
integer,parameter::dimx=2,dimy=3,dim=4
complex,allocatable::mata(:,:),vecb(:)
character(len=80)::fmt
integer i,j
allocate (mata(dimx,dimy),vecb(dim))
do i=1,dimx
do j=1,dimy
mata(i,j)=complex(i*10+j,i*10+j)
end do
end do
do i=1,dim
vecb(i)=complex(i*10+j,i*10+j)
end do
write(*,'(999f5.1)') vecb
write(fmt,'(a,i5,a)') '(',2*dimx,'f5.1)'
write(*,'(a)') fmt
write(*,fmt) mata
end program
OUTPUT
14.0 14.0 24.0 24.0 34.0 34.0 44.0 44.0
( 4f5.1)
11.0 11.0 21.0 21.0
12.0 12.0 22.0 22.0
13.0 13.0 23.0 23.0