RosettaCodeData/Task/Array-concatenation/Fortran/array-concatenation.f

18 lines
445 B
FortranFixed
Raw Permalink Normal View History

2018-06-22 20:57:24 +00:00
program Concat_Arrays
2019-09-12 10:33:56 -07:00
implicit none
2018-06-22 20:57:24 +00:00
! Note: in Fortran 90 you must use the old array delimiters (/ , /)
integer, dimension(3) :: a = [1, 2, 3] ! (/1, 2, 3/)
integer, dimension(3) :: b = [4, 5, 6] ! (/4, 5, 6/)
integer, dimension(:), allocatable :: c, d
allocate(c(size(a)+size(b)))
c(1 : size(a)) = a
c(size(a)+1 : size(a)+size(b)) = b
2019-09-12 10:33:56 -07:00
print*, c
2018-06-22 20:57:24 +00:00
! alternative
d = [a, b] ! (/a, b/)
2019-09-12 10:33:56 -07:00
print*, d
2018-06-22 20:57:24 +00:00
end program Concat_Arrays