# Fortran建構函式

spread(source, dim, ncopies) 它返回相同型別作為引數源與秩增加一個陣列。引數dim 和ncopies都是整數。如果ncopies是負則用零值來代替。如果source是一個標量，然後擴散變得所有具有相同值 ncopies 元素的向量。引數dim 指示哪個索引將被延長。它必須是範圍為1和1+(源級)中，如果 source 是一個標量，dim 必須是1。引數 ncopies 是在新的尺寸元素的數量。

```program arrayConstruction
implicit none
interface
subroutine write_array (a)
real :: a(:,:)
end subroutine write_array

subroutine write_l_array (a)
logical :: a(:,:)
end subroutine write_l_array
end interface

real, dimension(2,3) :: tsource, fsource, result

tsource = reshape( (/ 35, 23, 18, 28, 26, 39 /), &
(/ 2, 3 /) )
fsource = reshape( (/ -35, -23, -18, -28, -26, -39 /), &
(/ 2,3 /) )
mask = reshape( (/ .true., .false., .false., .true., &
.false., .false. /), (/ 2,3 /) )

call write_array(tsource)
call write_array(fsource)
call write_array(result)

end program arrayConstruction

subroutine write_array (a)

real :: a(:,:)
do i = lbound(a,1), ubound(a,1)
write(*,*) (a(i, j), j = lbound(a,2), ubound(a,2) )
end do
return

end subroutine write_array

subroutine write_l_array (a)

logical :: a(:,:)
do i = lbound(a,1), ubound(a,1)
write(*,*) (a(i, j), j= lbound(a,2), ubound(a,2))
end do
return

end subroutine write_l_array```

```35.0000000   18.0000000   26.0000000
23.0000000   28.0000000   39.0000000
-35.0000000  -18.0000000  -26.0000000
-23.0000000  -28.0000000  -39.0000000
T F F
F T F
35.0000000   -18.0000000  -26.0000000
-23.0000000  28.0000000   -39.0000000  ```