102 MODULE PROCEDURE append_i4_v_s, append_i4_v_v, append_i4_m_m, &
103 append_i4_3d, append_i8_v_s, append_i8_v_v, &
104 append_i8_m_m, append_i8_3d, &
105 append_sp_v_s, append_sp_v_v, append_sp_m_m, &
107 append_dp_v_s, append_dp_v_v, append_dp_m_m, &
108 append_dp_3d, append_dp_4d, &
109 append_char_v_s, append_char_v_v, append_char_m_m, &
111 append_lgt_v_s, append_lgt_v_v, append_lgt_m_m, &
112 append_lgt_3d, append_lgt_4d
169 MODULE PROCEDURE paste_i4_m_s, paste_i4_m_v, paste_i4_m_m, &
170 paste_i8_m_s, paste_i8_m_v, paste_i8_m_m, &
171 paste_sp_m_s, paste_sp_m_v, paste_sp_m_m, &
172 paste_dp_m_s, paste_dp_m_v, paste_dp_m_m, &
173 paste_char_m_s, paste_char_m_v, paste_char_m_m, &
174 paste_lgt_m_s, paste_lgt_m_v, paste_lgt_m_m, &
175 paste_dp_3d, paste_dp_4d, paste_i4_3d, paste_i4_4d
211 module procedure add_nodata_slice_dp_2d, add_nodata_slice_dp_3d, add_nodata_slice_dp_4d, &
212 add_nodata_slice_i4_2d, add_nodata_slice_i4_3d, add_nodata_slice_i4_4d
225 SUBROUTINE append_i4_v_s(vec1, sca2)
229 integer(i4),
dimension(:),
allocatable,
intent(inout) :: vec1
230 integer(i4),
intent(in) :: sca2
233 integer(i4) :: n1, n2
234 integer(i4),
dimension(:),
allocatable :: tmp
238 if (
allocated(vec1))
then
241 call move_alloc(vec1, tmp)
243 allocate(vec1(n1+n2))
244 vec1(1:n1) = tmp(1:n1)
253 END SUBROUTINE append_i4_v_s
255 SUBROUTINE append_i4_v_v(vec1, vec2)
259 integer(i4),
dimension(:),
allocatable,
intent(inout) :: vec1
260 integer(i4),
dimension(:),
intent(in) :: vec2
263 integer(i4) :: n1, n2
264 integer(i4),
dimension(:),
allocatable :: tmp
268 if (
allocated(vec1))
then
271 call move_alloc(vec1, tmp)
273 allocate(vec1(n1+n2))
274 vec1(1:n1) = tmp(1:n1)
275 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
280 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
283 END SUBROUTINE append_i4_v_v
285 SUBROUTINE append_i4_m_m(mat1, mat2, fill_value)
289 integer(i4),
dimension(:,:),
allocatable,
intent(inout) :: mat1
290 integer(i4),
dimension(:,:),
intent(in) :: mat2
291 integer(i4),
optional,
intent(in) :: fill_value
294 integer(i4) :: m1, m2
295 integer(i4) :: n1, n2
296 integer(i4),
dimension(:,:),
allocatable :: tmp
301 if (
allocated(mat1))
then
305 if ((n1 /= n2) .and. .not.
present(fill_value) )
then
306 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
311 call move_alloc(mat1, tmp)
314 allocate(mat1(m1+m2,n1))
315 mat1(1:m1,:) = tmp(1:m1,:)
316 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
320 allocate(mat1(m1+m2,n1))
321 mat1(1:m1,:) = tmp(1:m1,:)
322 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
323 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
327 allocate(mat1(m1+m2,n2))
328 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
329 mat1( 1:m1, n1+1:n2) = fill_value
330 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
336 allocate(mat1(m2,n2))
340 END SUBROUTINE append_i4_m_m
342 SUBROUTINE append_i4_3d(mat1, mat2, fill_value)
346 integer(i4),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
347 integer(i4),
dimension(:,:,:),
intent(in) :: mat2
348 integer(i4),
optional,
intent(in) :: fill_value
351 integer(i4) :: m1, m2
352 integer(i4) :: n1, n2
353 integer(i4) :: j1, j2
354 integer(i4),
dimension(:,:,:),
allocatable :: tmp
356 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_i4_3d'
362 if (
allocated(mat1))
then
367 if ((n1 /= n2) .or. (j1 /= j2) )
then
368 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
369 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
374 call move_alloc(mat1, tmp)
376 allocate(mat1(m1+m2,n1,j1))
377 mat1(1:m1,:,:) = tmp(1:m1,:,:)
378 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
382 allocate(mat1(m2,n2,j2))
387 END SUBROUTINE append_i4_3d
389 SUBROUTINE append_i8_v_s(vec1, sca2)
393 integer(i8),
dimension(:),
allocatable,
intent(inout) :: vec1
394 integer(i8),
intent(in) :: sca2
397 integer(i4) :: n1, n2
398 integer(i8),
dimension(:),
allocatable :: tmp
402 if (
allocated(vec1))
then
405 call move_alloc(vec1, tmp)
407 allocate(vec1(n1+n2))
408 vec1(1:n1) = tmp(1:n1)
417 END SUBROUTINE append_i8_v_s
419 SUBROUTINE append_i8_v_v(vec1, vec2)
423 integer(i8),
dimension(:),
allocatable,
intent(inout) :: vec1
424 integer(i8),
dimension(:),
intent(in) :: vec2
427 integer(i4) :: n1, n2
428 integer(i8),
dimension(:),
allocatable :: tmp
432 if (
allocated(vec1))
then
435 call move_alloc(vec1, tmp)
437 allocate(vec1(n1+n2))
438 vec1(1:n1) = tmp(1:n1)
439 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
444 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
447 END SUBROUTINE append_i8_v_v
449 SUBROUTINE append_i8_m_m(mat1, mat2, fill_value)
453 integer(i8),
dimension(:,:),
allocatable,
intent(inout) :: mat1
454 integer(i8),
dimension(:,:),
intent(in) :: mat2
455 integer(i8),
optional,
intent(in) :: fill_value
458 integer(i4) :: m1, m2
459 integer(i4) :: n1, n2
460 integer(i8),
dimension(:,:),
allocatable :: tmp
465 if (
allocated(mat1))
then
469 if ((n1 /= n2) .and. .not.
present(fill_value) )
then
470 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
475 call move_alloc(mat1, tmp)
478 allocate(mat1(m1+m2,n1))
479 mat1(1:m1,:) = tmp(1:m1,:)
480 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
484 allocate(mat1(m1+m2,n1))
485 mat1(1:m1,:) = tmp(1:m1,:)
486 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
487 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
491 allocate(mat1(m1+m2,n2))
492 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
493 mat1( 1:m1, n1+1:n2) = fill_value
494 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
500 allocate(mat1(m2,n2))
504 END SUBROUTINE append_i8_m_m
506 SUBROUTINE append_i8_3d(mat1, mat2, fill_value)
510 integer(i8),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
511 integer(i8),
dimension(:,:,:),
intent(in) :: mat2
512 integer(i8),
optional,
intent(in) :: fill_value
515 integer(i4) :: m1, m2
516 integer(i4) :: n1, n2
517 integer(i4) :: j1, j2
518 integer(i8),
dimension(:,:,:),
allocatable :: tmp
520 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_i8_3d'
526 if (
allocated(mat1))
then
531 if ((n1 /= n2) .or. (j1 /= j2) )
then
532 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
533 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
538 call move_alloc(mat1, tmp)
540 allocate(mat1(m1+m2,n1,j1))
541 mat1(1:m1,:,:) = tmp(1:m1,:,:)
542 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
546 allocate(mat1(m2,n2,j2))
551 END SUBROUTINE append_i8_3d
553 SUBROUTINE append_sp_v_s(vec1, sca2)
557 real(sp),
dimension(:),
allocatable,
intent(inout) :: vec1
558 real(sp),
intent(in) :: sca2
561 integer(i4) :: n1, n2
562 real(sp),
dimension(:),
allocatable :: tmp
566 if (
allocated(vec1))
then
569 call move_alloc(vec1, tmp)
571 allocate(vec1(n1+n2))
572 vec1(1:n1) = tmp(1:n1)
581 END SUBROUTINE append_sp_v_s
583 SUBROUTINE append_sp_v_v(vec1, vec2)
587 real(sp),
dimension(:),
allocatable,
intent(inout) :: vec1
588 real(sp),
dimension(:),
intent(in) :: vec2
591 integer(i4) :: n1, n2
592 real(sp),
dimension(:),
allocatable :: tmp
596 if (
allocated(vec1))
then
599 call move_alloc(vec1, tmp)
601 allocate(vec1(n1+n2))
602 vec1(1:n1) = tmp(1:n1)
603 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
608 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
611 END SUBROUTINE append_sp_v_v
613 SUBROUTINE append_sp_m_m(mat1, mat2, fill_value)
617 real(sp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
618 real(sp),
dimension(:,:),
intent(in) :: mat2
619 real(sp),
optional,
intent(in) :: fill_value
622 integer(i4) :: m1, m2
623 integer(i4) :: n1, n2
624 real(sp),
dimension(:,:),
allocatable :: tmp
629 if (
allocated(mat1))
then
633 if ((n1 /= n2) .and. .not.
present(fill_value) )
then
634 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
639 call move_alloc(mat1, tmp)
642 allocate(mat1(m1+m2,n1))
643 mat1(1:m1,:) = tmp(1:m1,:)
644 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
648 allocate(mat1(m1+m2,n1))
649 mat1(1:m1,:) = tmp(1:m1,:)
650 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
651 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
655 allocate(mat1(m1+m2,n2))
656 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
657 mat1( 1:m1, n1+1:n2) = fill_value
658 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
664 allocate(mat1(m2,n2))
668 END SUBROUTINE append_sp_m_m
670 SUBROUTINE append_sp_3d(mat1, mat2, fill_value)
674 real(sp),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
675 real(sp),
dimension(:,:,:),
intent(in) :: mat2
676 real(sp),
optional,
intent(in) :: fill_value
679 integer(i4) :: m1, m2
680 integer(i4) :: n1, n2
681 integer(i4) :: j1, j2
682 real(sp),
dimension(:,:,:),
allocatable :: tmp
684 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_sp_3d'
690 if (
allocated(mat1))
then
695 if ((n1 /= n2) .or. (j1 /= j2) )
then
696 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
697 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
702 call move_alloc(mat1, tmp)
704 allocate(mat1(m1+m2,n1,j1))
705 mat1(1:m1,:,:) = tmp(1:m1,:,:)
706 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
710 allocate(mat1(m2,n2,j2))
715 END SUBROUTINE append_sp_3d
717 SUBROUTINE append_dp_v_s(vec1, sca2)
721 real(dp),
dimension(:),
allocatable,
intent(inout) :: vec1
722 real(dp),
intent(in) :: sca2
725 integer(i4) :: n1, n2
726 real(dp),
dimension(:),
allocatable :: tmp
730 if (
allocated(vec1))
then
733 call move_alloc(vec1, tmp)
735 allocate(vec1(n1+n2))
736 vec1(1:n1) = tmp(1:n1)
745 END SUBROUTINE append_dp_v_s
747 SUBROUTINE append_dp_v_v(vec1, vec2)
751 real(dp),
dimension(:),
allocatable,
intent(inout) :: vec1
752 real(dp),
dimension(:),
intent(in) :: vec2
755 integer(i4) :: n1, n2
756 real(dp),
dimension(:),
allocatable :: tmp
760 if (
allocated(vec1))
then
763 call move_alloc(vec1, tmp)
765 allocate(vec1(n1+n2))
766 vec1(1:n1) = tmp(1:n1)
767 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
772 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
775 END SUBROUTINE append_dp_v_v
777 SUBROUTINE append_dp_m_m(mat1, mat2, fill_value, idim)
781 real(dp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
782 real(dp),
dimension(:,:),
intent(in) :: mat2
783 real(dp),
optional,
intent(in) :: fill_value
784 integer(i4),
optional,
intent(in) :: idim
787 integer(i4) :: m1, m2
788 integer(i4) :: n1, n2
790 real(dp),
dimension(:,:),
allocatable :: tmp
793 if (
present(idim)) dd = idim
795 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 2'
803 if (
allocated(mat1))
then
807 if (
present(idim))
then
810 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
815 call move_alloc(mat1, tmp)
817 allocate(mat1(m1+m2,n1))
818 mat1(1:m1,:) = tmp(1:m1,:)
819 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
821 else if (dd == 2)
then
824 print*,
'append: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
829 call move_alloc(mat1, tmp)
831 allocate(mat1(m1,n1 + n2))
832 mat1(:,1:n1) = tmp(:,1:n1)
833 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
839 if ((n1 /= n2) .and. .not.
present(fill_value) )
then
840 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
845 call move_alloc(mat1, tmp)
848 allocate(mat1(m1+m2,n1))
849 mat1(1:m1,:) = tmp(1:m1,:)
850 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
854 allocate(mat1(m1+m2,n1))
855 mat1(1:m1,:) = tmp(1:m1,:)
856 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
857 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
861 allocate(mat1(m1+m2,n2))
862 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
863 mat1( 1:m1, n1+1:n2) = fill_value
864 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
869 allocate(mat1(m2,n2))
873 END SUBROUTINE append_dp_m_m
875 SUBROUTINE append_dp_3d(mat1, mat2, fill_value, idim)
879 real(dp),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
880 real(dp),
dimension(:,:,:),
intent(in) :: mat2
881 real(dp),
optional,
intent(in) :: fill_value
882 integer(i4),
optional,
intent(in) :: idim
885 integer(i4) :: m1, m2
886 integer(i4) :: n1, n2
887 integer(i4) :: j1, j2
889 real(dp),
dimension(:,:,:),
allocatable :: tmp
891 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_dp_3d'
894 if (
present(idim)) dd = idim
896 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 3'
904 if (
allocated(mat1))
then
910 if ((n1 /= n2) .or. (j1 /= j2) )
then
911 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
912 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
917 call move_alloc(mat1, tmp)
919 allocate(mat1(m1+m2,n1,j1))
920 mat1(1:m1,:,:) = tmp(1:m1,:,:)
921 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
922 else if (dd == 2)
then
923 if ((m1 /= m2) .or. (j1 /= j2) )
then
924 print*,
'append: size mismatch: dim 1 and 3 of matrix1 and matrix2 are unequal : ' &
925 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
930 call move_alloc(mat1, tmp)
932 allocate(mat1(m1,n1 + n2,j1))
933 mat1(:,1:n1,:) = tmp(:,1:n1,:)
934 mat1(:,n1+1_i4:n1+n2,:) = mat2(:,1:n2,:)
935 else if (dd == 3)
then
936 if ((m1 /= m2) .or. (n1 /= n2) )
then
937 print*,
'append: size mismatch: dim 1 and 2 of matrix1 and matrix2 are unequal : ' &
938 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
943 call move_alloc(mat1, tmp)
945 allocate(mat1(m1,n1,j1 + j2))
946 mat1(:,:,1:j1) = tmp(:,:,1:j1)
947 mat1(:,:,j1+1_i4:j1+j2) = mat2(:,:,1:j2)
952 allocate(mat1(m2,n2,j2))
957 END SUBROUTINE append_dp_3d
959 SUBROUTINE append_dp_4d(mat1, mat2, fill_value, idim)
963 real(dp),
dimension(:,:,:,:),
allocatable,
intent(inout) :: mat1
964 real(dp),
dimension(:,:,:,:),
intent(in) :: mat2
965 real(dp),
optional,
intent(in) :: fill_value
966 integer(i4),
optional,
intent(in) :: idim
969 integer(i4) :: m1, m2
970 integer(i4) :: n1, n2
971 integer(i4) :: j1, j2
972 integer(i4) :: i1, i2
974 real(dp),
allocatable :: tmp(:,:,:,:)
976 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_dp_3d'
979 if (
present(idim)) dd = idim
981 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 4'
990 if (
allocated(mat1))
then
997 if ((n1 /= n2) .or. (j1 /= j2) .or. (i1 /= i2))
then
998 print*,
'append: size mismatch: dim 2, 3, and 4 of matrix1 and matrix2 are unequal : ' &
999 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1004 call move_alloc(mat1, tmp)
1006 allocate(mat1(m1+m2,n1,j1,i1))
1007 mat1(1:m1,:,:,:) = tmp(1:m1,:,:,:)
1008 mat1(m1+1_i4:m1+m2,:,:,:) = mat2(1:m2,:,:,:)
1009 else if (dd == 2)
then
1010 if ((m1 /= m2) .or. (j1 /= j2) .or. (i1 /= i2))
then
1011 print*,
'append: size mismatch: dim 1, 3, and 4 of matrix1 and matrix2 are unequal : ' &
1012 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1017 call move_alloc(mat1, tmp)
1019 allocate(mat1(m1,n1 + n2,j1,i1))
1020 mat1(:,1:n1,:,:) = tmp(:,1:n1,:,:)
1021 mat1(:,n1+1_i4:n1+n2,:,:) = mat2(:,1:n2,:,:)
1022 else if (dd == 3)
then
1023 if ((m1 /= m2) .or. (n1 /= n2) .or. (i1 /= i2))
then
1024 print*,
'append: size mismatch: dim 1, 2, and 4 of matrix1 and matrix2 are unequal : ' &
1025 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1030 allocate(tmp(m1,n1,j1,i1))
1034 allocate(mat1(m1,n1,j1 + j2,i1))
1035 mat1(:,:,1:j1,:) = tmp(:,:,1:j1,:)
1036 mat1(:,:,j1+1_i4:j1+j2,:) = mat2(:,:,1:j2,:)
1037 else if (dd == 4)
then
1038 if ((m1 /= m2) .or. (n1 /= n2) .or. (j1 /= j2))
then
1039 print*,
'append: size mismatch: dim 1, 2, and 3 of matrix1 and matrix2 are unequal : ' &
1040 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1045 call move_alloc(mat1, tmp)
1047 allocate(mat1(m1,n1,j1,i1 + i2))
1048 mat1(:,:,:,1:i1) = tmp(:,:,:,1:i1)
1049 mat1(:,:,:,i1+1_i4:i1+i2) = mat2(:,:,:,1:i2)
1054 allocate(mat1(m2,n2,j2,i2))
1059 END SUBROUTINE append_dp_4d
1061 SUBROUTINE append_char_v_s(vec1, sca2)
1065 character(len=*),
dimension(:),
allocatable,
intent(inout) :: vec1
1066 character(len=*),
intent(in) :: sca2
1069 integer(i4) :: n1, n2
1070 character(len(vec1)),
dimension(:),
allocatable :: tmp
1074 if (
allocated(vec1))
then
1077 call move_alloc(vec1, tmp)
1079 allocate(vec1(n1+n2))
1080 vec1(1:n1) = tmp(1:n1)
1081 vec1(n1+1_i4) = sca2
1089 END SUBROUTINE append_char_v_s
1091 SUBROUTINE append_char_v_v(vec1, vec2)
1093 character(len=*),
dimension(:),
allocatable,
intent(inout) :: vec1
1094 character(len=*),
dimension(:),
intent(in) :: vec2
1097 integer(i4) :: n1, n2
1098 character(len(vec1)),
dimension(:),
allocatable :: tmp
1102 if (
allocated(vec1))
then
1105 call move_alloc(vec1, tmp)
1107 allocate(vec1(n1+n2))
1108 vec1(1:n1) = tmp(1:n1)
1109 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
1114 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
1117 END SUBROUTINE append_char_v_v
1119 SUBROUTINE append_char_m_m(mat1, mat2, fill_value)
1123 character(len=*),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1124 character(len=*),
dimension(:,:),
intent(in) :: mat2
1125 character(len=*),
optional,
intent(in) :: fill_value
1128 integer(i4) :: m1, m2
1129 integer(i4) :: n1, n2
1130 character(len(mat1)),
dimension(:,:),
allocatable :: tmp
1135 if (
allocated(mat1))
then
1139 if ((n1 /= n2) .and. .not.
present(fill_value) )
then
1140 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1145 call move_alloc(mat1, tmp)
1147 if ( n1 == n2 )
then
1148 allocate(mat1(m1+m2,n1))
1149 mat1(1:m1,:) = tmp(1:m1,:)
1150 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
1154 allocate(mat1(m1+m2,n1))
1155 mat1(1:m1,:) = tmp(1:m1,:)
1156 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
1157 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
1161 allocate(mat1(m1+m2,n2))
1162 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
1163 mat1( 1:m1, n1+1:n2) = fill_value
1164 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
1170 allocate(mat1(m2,n2))
1174 END SUBROUTINE append_char_m_m
1176 SUBROUTINE append_char_3d(mat1, mat2, fill_value)
1180 character(len=*),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
1181 character(len=*),
dimension(:,:,:),
intent(in) :: mat2
1182 character(len=*),
optional,
intent(in) :: fill_value
1185 integer(i4) :: m1, m2
1186 integer(i4) :: n1, n2
1187 integer(i4) :: j1, j2
1188 character(len(mat1)),
dimension(:,:,:),
allocatable :: tmp
1190 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_i8_3d'
1196 if (
allocated(mat1))
then
1201 if ((n1 /= n2) .or. (j1 /= j2) )
then
1202 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
1203 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
1208 call move_alloc(mat1, tmp)
1210 allocate(mat1(m1+m2,n1,j1))
1211 mat1(1:m1,:,:) = tmp(1:m1,:,:)
1212 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
1216 allocate(mat1(m2,n2,j2))
1221 END SUBROUTINE append_char_3d
1223 SUBROUTINE append_lgt_v_s(vec1, sca2)
1227 logical,
dimension(:),
allocatable,
intent(inout) :: vec1
1228 logical,
intent(in) :: sca2
1231 integer(i4) :: n1, n2
1232 logical,
dimension(:),
allocatable :: tmp
1236 if (
allocated(vec1))
then
1239 call move_alloc(vec1, tmp)
1241 allocate(vec1(n1+n2))
1242 vec1(1:n1) = tmp(1:n1)
1243 vec1(n1+1_i4) = sca2
1251 END SUBROUTINE append_lgt_v_s
1253 SUBROUTINE append_lgt_v_v(vec1, vec2)
1257 logical,
dimension(:),
allocatable,
intent(inout) :: vec1
1258 logical,
dimension(:),
intent(in) :: vec2
1261 integer(i4) :: n1, n2
1262 logical,
dimension(:),
allocatable :: tmp
1266 if (
allocated(vec1))
then
1269 call move_alloc(vec1, tmp)
1271 allocate(vec1(n1+n2))
1272 vec1(1:n1) = tmp(1:n1)
1273 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
1278 vec1(n1+1_i4:n1+n2) = vec2(1:n2)
1281 END SUBROUTINE append_lgt_v_v
1283 SUBROUTINE append_lgt_m_m(mat1, mat2, fill_value, idim)
1287 logical,
dimension(:,:),
allocatable,
intent(inout) :: mat1
1288 logical,
dimension(:,:),
intent(in) :: mat2
1289 logical,
optional,
intent(in) :: fill_value
1290 integer(i4),
optional,
intent(in) :: idim
1293 integer(i4) :: m1, m2
1294 integer(i4) :: n1, n2
1296 logical,
dimension(:,:),
allocatable :: tmp
1299 if (
present(idim)) dd = idim
1301 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 3'
1308 if (
allocated(mat1))
then
1312 if (
present(idim))
then
1315 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1320 call move_alloc(mat1, tmp)
1322 allocate(mat1(m1+m2,n1))
1323 mat1(1:m1,:) = tmp(1:m1,:)
1324 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
1326 else if (dd == 2)
then
1329 print*,
'append: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1334 call move_alloc(mat1, tmp)
1336 allocate(mat1(m1,n1 + n2))
1337 mat1(:,1:n1) = tmp(:,1:n1)
1338 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1343 if ( (n1 /= n2) .and. .not.
present(fill_value) )
then
1344 print*,
'append: columns of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1349 call move_alloc(mat1, tmp)
1351 if ( n1 == n2 )
then
1352 allocate(mat1(m1+m2,n1))
1353 mat1(1:m1,:) = tmp(1:m1,:)
1354 mat1(m1+1_i4:m1+m2,:) = mat2(1:m2,:)
1358 allocate(mat1(m1+m2,n1))
1359 mat1(1:m1,:) = tmp(1:m1,:)
1360 mat1(m1+1_i4:m1+m2, 1:n2) = mat2(1:m2,:)
1361 mat1(m1+1_i4:m1+m2,n2+1:n1) = fill_value
1365 allocate(mat1(m1+m2,n2))
1366 mat1( 1:m1, 1:n1) = tmp(1:m1,:)
1367 mat1( 1:m1, n1+1:n2) = fill_value
1368 mat1(m1+1_i4:m1+m2, : ) = mat2(1:m2,:)
1375 allocate(mat1(m2,n2))
1379 END SUBROUTINE append_lgt_m_m
1381 SUBROUTINE append_lgt_3d(mat1, mat2, fill_value, idim)
1385 logical,
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
1386 logical,
dimension(:,:,:),
intent(in) :: mat2
1387 logical,
optional,
intent(in) :: fill_value
1388 integer(i4),
optional :: idim
1391 integer(i4) :: m1, m2
1392 integer(i4) :: n1, n2
1393 integer(i4) :: j1, j2
1395 logical,
dimension(:,:,:),
allocatable :: tmp
1397 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_i8_3d'
1400 if (
present(idim)) dd = idim
1402 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 3'
1410 if (
allocated(mat1))
then
1416 if ((n1 /= n2) .or. (j1 /= j2) )
then
1417 print*,
'append: size mismatch: dim 2 and 3 of matrix1 and matrix2 are unequal : ' &
1418 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
1423 call move_alloc(mat1, tmp)
1425 allocate(mat1(m1+m2,n1,j1))
1426 mat1(1:m1,:,:) = tmp(1:m1,:,:)
1427 mat1(m1+1_i4:m1+m2,:,:) = mat2(1:m2,:,:)
1428 else if (dd == 2)
then
1429 if ((m1 /= m2) .or. (j1 /= j2) )
then
1430 print*,
'append: size mismatch: dim 1 and 3 of matrix1 and matrix2 are unequal : ' &
1431 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
1436 call move_alloc(mat1, tmp)
1438 allocate(mat1(m1,n1 + n2,j1))
1439 mat1(:,1:n1,:) = tmp(:,1:n1,:)
1440 mat1(:,n1+1_i4:n1+n2,:) = mat2(:,1:n2,:)
1441 else if (dd == 3)
then
1442 if ((m1 /= m2) .or. (n1 /= n2) )
then
1443 print*,
'append: size mismatch: dim 1 and 2 of matrix1 and matrix2 are unequal : ' &
1444 //
'(',m1,
',',n1,
',',j1,
') and (',m2,
',',n2,
',',j2,
')'
1449 call move_alloc(mat1, tmp)
1451 allocate(mat1(m1,n1,j1 + j2))
1452 mat1(:,:,1:j1) = tmp(:,:,1:j1)
1453 mat1(:,:,j1+1_i4:j1+j2) = mat2(:,:,1:j2)
1458 allocate(mat1(m2,n2,j2))
1463 END SUBROUTINE append_lgt_3d
1465 SUBROUTINE append_lgt_4d(mat1, mat2, fill_value, idim)
1469 logical,
dimension(:,:,:,:),
allocatable,
intent(inout) :: mat1
1470 logical,
dimension(:,:,:,:),
intent(in) :: mat2
1471 logical,
optional,
intent(in) :: fill_value
1472 integer(i4),
optional,
intent(in) :: idim
1475 integer(i4) :: m1, m2
1476 integer(i4) :: n1, n2
1477 integer(i4) :: j1, j2
1478 integer(i4) :: i1, i2
1480 logical,
allocatable :: tmp(:,:,:,:)
1482 if (
present(fill_value)) print*,
'***warning: fill_value is ignored in append_lgt_4d'
1485 if (
present(idim)) dd = idim
1487 print*,
'append: dd is : (',dd,
') and greater than number of dimensions : 4'
1496 if (
allocated(mat1))
then
1503 if ((n1 /= n2) .or. (j1 /= j2) .or. (i1 /= i2))
then
1504 print*,
'append: size mismatch: dim 2, 3, and 4 of matrix1 and matrix2 are unequal : ' &
1505 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1510 call move_alloc(mat1, tmp)
1512 allocate(mat1(m1+m2,n1,j1,i1))
1513 mat1(1:m1,:,:,:) = tmp(1:m1,:,:,:)
1514 mat1(m1+1_i4:m1+m2,:,:,:) = mat2(1:m2,:,:,:)
1515 else if (dd == 2)
then
1516 if ((m1 /= m2) .or. (j1 /= j2) .or. (i1 /= i2))
then
1517 print*,
'append: size mismatch: dim 1, 3, and 4 of matrix1 and matrix2 are unequal : ' &
1518 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1523 call move_alloc(mat1, tmp)
1525 allocate(mat1(m1,n1 + n2,j1,i1))
1526 mat1(:,1:n1,:,:) = tmp(:,1:n1,:,:)
1527 mat1(:,n1+1_i4:n1+n2,:,:) = mat2(:,1:n2,:,:)
1528 else if (dd == 3)
then
1529 if ((m1 /= m2) .or. (n1 /= n2) .or. (i1 /= i2))
then
1530 print*,
'append: size mismatch: dim 1, 2, and 4 of matrix1 and matrix2 are unequal : ' &
1531 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1536 call move_alloc(mat1, tmp)
1538 allocate(mat1(m1,n1,j1 + j2,i1))
1539 mat1(:,:,1:j1,:) = tmp(:,:,1:j1,:)
1540 mat1(:,:,j1+1_i4:j1+j2,:) = mat2(:,:,1:j2,:)
1541 else if (dd == 4)
then
1542 if ((m1 /= m2) .or. (n1 /= n2) .or. (j1 /= j2))
then
1543 print*,
'append: size mismatch: dim 1, 2, and 3 of matrix1 and matrix2 are unequal : ' &
1544 //
'(',m1,
',',n1,
',',j1,
',',i1,
') and (',m2,
',',n2,
',',j2,
',',i2,
')'
1549 call move_alloc(mat1, tmp)
1551 allocate(mat1(m1,n1,j1,i1 + i2))
1552 mat1(:,:,:,1:i1) = tmp(:,:,:,1:i1)
1553 mat1(:,:,:,i1+1_i4:i1+i2) = mat2(:,:,:,1:i2)
1558 allocate(mat1(m2,n2,j2,i2))
1563 END SUBROUTINE append_lgt_4d
1567 SUBROUTINE paste_i4_m_s(mat1, sca2)
1571 integer(i4),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1572 integer(i4),
intent(in) :: sca2
1577 integer(i4),
dimension(:,:),
allocatable :: tmp
1579 if (
allocated(mat1))
then
1582 if (m1 /= 1_i4)
then
1583 print*,
'paste: scalar paste to matrix only works with one-line matrix'
1587 call move_alloc(mat1, tmp)
1589 allocate(mat1(1_i4,n1+1_i4))
1590 mat1(1,1:n1) = tmp(1,1:n1)
1591 mat1(1,n1+1_i4) = sca2
1593 allocate(mat1(1_i4,1_i4))
1597 END SUBROUTINE paste_i4_m_s
1599 SUBROUTINE paste_i4_m_v(mat1, vec2, fill_value)
1603 integer(i4),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1604 integer(i4),
dimension(:),
intent(in) :: vec2
1605 integer(i4),
optional,
intent(in) :: fill_value
1608 integer(i4) :: m1, m2
1609 integer(i4) :: n1, n2
1610 integer(i4),
dimension(:,:),
allocatable :: tmp
1615 if (
allocated(mat1))
then
1618 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1619 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1623 call move_alloc(mat1, tmp)
1625 if ( m1 == m2 )
then
1626 allocate(mat1(m1,n1+n2))
1627 mat1(1:m1,1:n1) = tmp(:,1:n1)
1628 mat1(1:m2,n1+n2) = vec2(1:m2)
1632 allocate(mat1(m1,n1+n2))
1633 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1634 mat1( 1:m2,n1+n2) = vec2(1:m2)
1635 mat1(m2+1:m1,n1+n2) = fill_value
1639 allocate(mat1(m2,n1+n2))
1640 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1641 mat1(m1+1:m2,1:n1) = fill_value
1642 mat1( 1:m2,n1+n2) = vec2(1:m2)
1649 allocate(mat1(m2,n2))
1650 mat1(1:m2,n1+n2) = vec2(1:m2)
1653 END SUBROUTINE paste_i4_m_v
1655 SUBROUTINE paste_i4_m_m(mat1, mat2, fill_value)
1659 integer(i4),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1660 integer(i4),
dimension(:,:),
intent(in) :: mat2
1661 integer(i4),
optional,
intent(in) :: fill_value
1664 integer(i4) :: m1, m2
1665 integer(i4) :: n1, n2
1666 integer(i4),
dimension(:,:),
allocatable :: tmp
1671 if (
allocated(mat1))
then
1674 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1675 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1679 call move_alloc(mat1, tmp)
1681 if ( m1 == m2 )
then
1682 allocate(mat1(m1,n1+n2))
1683 mat1(:,1:n1) = tmp(:,1:n1)
1684 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1688 allocate(mat1(m1,n1+n2))
1689 mat1( : ,1:n1) = tmp(:,1:n1)
1690 mat1( 1:m2,n1+1_i4:n1+n2) = mat2(:,1:n2)
1691 mat1(m2+1:m1,n1+1_i4:n1+n2) = fill_value
1695 allocate(mat1(m2,n1+n2))
1696 mat1( 1:m1, 1:n1 ) = tmp(:,1:n1)
1697 mat1(m1+1:m2, 1:n1 ) = fill_value
1698 mat1( : ,n1+1_i4:n1+n2) = mat2(:,1:n2)
1705 allocate(mat1(m2,n2))
1706 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1709 END SUBROUTINE paste_i4_m_m
1711 SUBROUTINE paste_i8_m_s(mat1, sca2)
1715 integer(i8),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1716 integer(i8),
intent(in) :: sca2
1721 integer(i8),
dimension(:,:),
allocatable :: tmp
1723 if (
allocated(mat1))
then
1726 if (m1 /= 1_i4)
then
1727 print*,
'paste: scalar paste to matrix only works with one-line matrix'
1731 call move_alloc(mat1, tmp)
1733 allocate(mat1(1_i4,n1+1_i4))
1734 mat1(1,1:n1) = tmp(1,1:n1)
1735 mat1(1,n1+1_i4) = sca2
1737 allocate(mat1(1_i4,1_i4))
1741 END SUBROUTINE paste_i8_m_s
1743 SUBROUTINE paste_i8_m_v(mat1, vec2, fill_value)
1747 integer(i8),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1748 integer(i8),
dimension(:),
intent(in) :: vec2
1749 integer(i8),
optional,
intent(in) :: fill_value
1752 integer(i4) :: m1, m2
1753 integer(i4) :: n1, n2
1754 integer(i8),
dimension(:,:),
allocatable :: tmp
1759 if (
allocated(mat1))
then
1762 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1763 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1767 call move_alloc(mat1, tmp)
1769 if ( m1 == m2 )
then
1770 allocate(mat1(m1,n1+n2))
1771 mat1(1:m1,1:n1) = tmp(:,1:n1)
1772 mat1(1:m2,n1+n2) = vec2(1:m2)
1776 allocate(mat1(m1,n1+n2))
1777 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1778 mat1( 1:m2,n1+n2) = vec2(1:m2)
1779 mat1(m2+1:m1,n1+n2) = fill_value
1783 allocate(mat1(m2,n1+n2))
1784 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1785 mat1(m1+1:m2,1:n1) = fill_value
1786 mat1( 1:m2,n1+n2) = vec2(1:m2)
1793 allocate(mat1(m2,n2))
1794 mat1(1:m2,n1+n2) = vec2(1:m2)
1797 END SUBROUTINE paste_i8_m_v
1799 SUBROUTINE paste_i8_m_m(mat1, mat2, fill_value)
1803 integer(i8),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1804 integer(i8),
dimension(:,:),
intent(in) :: mat2
1805 integer(i8),
optional,
intent(in) :: fill_value
1808 integer(i4) :: m1, m2
1809 integer(i4) :: n1, n2
1810 integer(i8),
dimension(:,:),
allocatable :: tmp
1815 if (
allocated(mat1))
then
1818 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1819 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1823 call move_alloc(mat1, tmp)
1825 if ( m1 == m2 )
then
1826 allocate(mat1(m1,n1+n2))
1827 mat1(:,1:n1) = tmp(:,1:n1)
1828 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1832 allocate(mat1(m1,n1+n2))
1833 mat1( : ,1:n1) = tmp(:,1:n1)
1834 mat1( 1:m2,n1+1_i4:n1+n2) = mat2(:,1:n2)
1835 mat1(m2+1:m1,n1+1_i4:n1+n2) = fill_value
1839 allocate(mat1(m2,n1+n2))
1840 mat1( 1:m1, 1:n1 ) = tmp(:,1:n1)
1841 mat1(m1+1:m2, 1:n1 ) = fill_value
1842 mat1( : ,n1+1_i4:n1+n2) = mat2(:,1:n2)
1849 allocate(mat1(m2,n2))
1850 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1853 END SUBROUTINE paste_i8_m_m
1855 SUBROUTINE paste_sp_m_s(mat1, sca2)
1859 real(sp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1860 real(sp),
intent(in) :: sca2
1865 real(sp),
dimension(:,:),
allocatable :: tmp
1867 if (
allocated(mat1))
then
1870 if (m1 /= 1_i4)
then
1871 print*,
'paste: scalar paste to matrix only works with one-line matrix'
1875 call move_alloc(mat1, tmp)
1877 allocate(mat1(1_i4,n1+1_i4))
1878 mat1(1,1:n1) = tmp(1,1:n1)
1879 mat1(1,n1+1_i4) = sca2
1881 allocate(mat1(1_i4,1_i4))
1885 END SUBROUTINE paste_sp_m_s
1887 SUBROUTINE paste_sp_m_v(mat1, vec2, fill_value)
1891 real(sp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1892 real(sp),
dimension(:),
intent(in) :: vec2
1893 real(sp),
optional,
intent(in) :: fill_value
1896 integer(i4) :: m1, m2
1897 integer(i4) :: n1, n2
1898 real(sp),
dimension(:,:),
allocatable :: tmp
1903 if (
allocated(mat1))
then
1906 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1907 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1911 call move_alloc(mat1, tmp)
1913 if ( m1 == m2 )
then
1914 allocate(mat1(m1,n1+n2))
1915 mat1(1:m1,1:n1) = tmp(:,1:n1)
1916 mat1(1:m2,n1+n2) = vec2(1:m2)
1920 allocate(mat1(m1,n1+n2))
1921 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1922 mat1( 1:m2,n1+n2) = vec2(1:m2)
1923 mat1(m2+1:m1,n1+n2) = fill_value
1927 allocate(mat1(m2,n1+n2))
1928 mat1( 1:m1,1:n1) = tmp(:,1:n1)
1929 mat1(m1+1:m2,1:n1) = fill_value
1930 mat1( 1:m2,n1+n2) = vec2(1:m2)
1937 allocate(mat1(m2,n2))
1938 mat1(1:m2,n1+n2) = vec2(1:m2)
1941 END SUBROUTINE paste_sp_m_v
1943 SUBROUTINE paste_sp_m_m(mat1, mat2, fill_value)
1947 real(sp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
1948 real(sp),
dimension(:,:),
intent(in) :: mat2
1949 real(sp),
optional,
intent(in) :: fill_value
1952 integer(i4) :: m1, m2
1953 integer(i4) :: n1, n2
1954 real(sp),
dimension(:,:),
allocatable :: tmp
1959 if (
allocated(mat1))
then
1962 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
1963 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
1967 call move_alloc(mat1, tmp)
1969 if ( m1 == m2 )
then
1970 allocate(mat1(m1,n1+n2))
1971 mat1(:,1:n1) = tmp(:,1:n1)
1972 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1976 allocate(mat1(m1,n1+n2))
1977 mat1( : ,1:n1) = tmp(:,1:n1)
1978 mat1( 1:m2,n1+1_i4:n1+n2) = mat2(:,1:n2)
1979 mat1(m2+1:m1,n1+1_i4:n1+n2) = fill_value
1983 allocate(mat1(m2,n1+n2))
1984 mat1( 1:m1, 1:n1 ) = tmp(:,1:n1)
1985 mat1(m1+1:m2, 1:n1 ) = fill_value
1986 mat1( : ,n1+1_i4:n1+n2) = mat2(:,1:n2)
1994 allocate(mat1(m2,n2))
1995 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
1998 END SUBROUTINE paste_sp_m_m
2000 SUBROUTINE paste_dp_m_s(mat1, sca2)
2004 real(dp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2005 real(dp),
intent(in) :: sca2
2010 real(dp),
dimension(:,:),
allocatable :: tmp
2012 if (
allocated(mat1))
then
2015 if (m1 /= 1_i4)
then
2016 print*,
'paste: scalar paste to matrix only works with one-line matrix'
2020 call move_alloc(mat1, tmp)
2022 allocate(mat1(1_i4,n1+1_i4))
2023 mat1(1,1:n1) = tmp(1,1:n1)
2024 mat1(1,n1+1_i4) = sca2
2026 allocate(mat1(1_i4,1_i4))
2030 END SUBROUTINE paste_dp_m_s
2032 SUBROUTINE paste_dp_m_v(mat1, vec2, fill_value)
2036 real(dp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2037 real(dp),
dimension(:),
intent(in) :: vec2
2038 real(dp),
optional,
intent(in) :: fill_value
2041 integer(i4) :: m1, m2
2042 integer(i4) :: n1, n2
2043 real(dp),
dimension(:,:),
allocatable :: tmp
2048 if (
allocated(mat1))
then
2051 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
2052 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2056 call move_alloc(mat1, tmp)
2058 if ( m1 == m2 )
then
2059 allocate(mat1(m1,n1+n2))
2060 mat1(1:m1,1:n1) = tmp(:,1:n1)
2061 mat1(1:m2,n1+n2) = vec2(1:m2)
2065 allocate(mat1(m1,n1+n2))
2066 mat1( 1:m1,1:n1) = tmp(:,1:n1)
2067 mat1( 1:m2,n1+n2) = vec2(1:m2)
2068 mat1(m2+1:m1,n1+n2) = fill_value
2072 allocate(mat1(m2,n1+n2))
2073 mat1( 1:m1,1:n1) = tmp(:,1:n1)
2074 mat1(m1+1:m2,1:n1) = fill_value
2075 mat1( 1:m2,n1+n2) = vec2(1:m2)
2082 allocate(mat1(m2,n2))
2083 mat1(1:m2,n1+n2) = vec2(1:m2)
2086 END SUBROUTINE paste_dp_m_v
2088 SUBROUTINE paste_dp_m_m(mat1, mat2, fill_value)
2092 real(dp),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2093 real(dp),
dimension(:,:),
intent(in) :: mat2
2094 real(dp),
optional,
intent(in) :: fill_value
2097 integer(i4) :: m1, m2
2098 integer(i4) :: n1, n2
2099 real(dp),
dimension(:,:),
allocatable :: tmp
2104 if (
allocated(mat1))
then
2107 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
2108 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2112 call move_alloc(mat1, tmp)
2114 if ( m1 == m2 )
then
2115 allocate(mat1(m1,n1+n2))
2116 mat1(:,1:n1) = tmp(:,1:n1)
2117 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2121 allocate(mat1(m1,n1+n2))
2122 mat1( : ,1:n1) = tmp(:,1:n1)
2123 mat1( 1:m2,n1+1_i4:n1+n2) = mat2(:,1:n2)
2124 mat1(m2+1:m1,n1+1_i4:n1+n2) = fill_value
2128 allocate(mat1(m2,n1+n2))
2129 mat1( 1:m1, 1:n1 ) = tmp(:,1:n1)
2130 mat1(m1+1:m2, 1:n1 ) = fill_value
2131 mat1( : ,n1+1_i4:n1+n2) = mat2(:,1:n2)
2138 allocate(mat1(m2,n2))
2139 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2142 END SUBROUTINE paste_dp_m_m
2144 SUBROUTINE paste_dp_3d(mat1, mat2)
2146 real(dp),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
2147 real(dp),
dimension(:,:,:),
intent(in) :: mat2
2150 integer(i4) :: m1, m2
2151 integer(i4) :: n1, n2
2152 integer(i4) :: o1, o2
2153 real(dp),
dimension(:,:,:),
allocatable :: tmp
2159 if (
allocated(mat1))
then
2163 if ( (m1 /= m2))
then
2164 print*,
'paste: rows of array1 and array2 are unequal : (',m1,
') and (',m2,
')'
2166 else if ( (n1 /= n2))
then
2167 print*,
'paste: columns of array1 and array2 are unequal : (',n1,
') and (',n2,
')'
2171 call move_alloc(mat1, tmp)
2173 allocate(mat1(m1,n1,o1+o2))
2174 mat1(:,:,1:o1) = tmp(:,:,:)
2175 mat1(:,:,o1+1_i4:o1+o2) = mat2(:,:,:)
2178 allocate(mat1(m2,n2,o2))
2179 mat1(:,:,:) = mat2(:,:,:)
2182 END SUBROUTINE paste_dp_3d
2184 SUBROUTINE paste_dp_4d(mat1, mat2)
2186 real(dp),
dimension(:,:,:,:),
allocatable,
intent(inout) :: mat1
2187 real(dp),
dimension(:,:,:,:),
intent(in) :: mat2
2190 integer(i4) :: m1, m2
2191 integer(i4) :: n1, n2
2192 integer(i4) :: o1, o2
2193 integer(i4) :: p1, p2
2194 real(dp),
dimension(:,:,:,:),
allocatable :: tmp
2201 if (
allocated(mat1))
then
2206 if ( (m1 /= m2))
then
2207 print*,
'paste: rows of array1 and array2 are unequal : (',m1,
') and (',m2,
')'
2209 else if ( (n1 /= n2))
then
2210 print*,
'paste: columns of array1 and array2 are unequal : (',n1,
') and (',n2,
')'
2212 else if ( (o1 /= o2))
then
2213 print*,
'paste: columns of array1 and array2 are unequal : (',o1,
') and (',o2,
')'
2217 call move_alloc(mat1, tmp)
2219 allocate(mat1(m1,n1,o1,p1+p2))
2220 mat1(:,:,:,1:p1) = tmp(:,:,:,:)
2221 mat1(:,:,:,p1+1_i4:p1+p2) = mat2(:,:,:,:)
2224 allocate(mat1(m2,n2,o2,p2))
2225 mat1(:,:,:,:) = mat2(:,:,:,:)
2228 END SUBROUTINE paste_dp_4d
2230 SUBROUTINE paste_i4_3d(mat1, mat2)
2232 integer(i4),
dimension(:,:,:),
allocatable,
intent(inout) :: mat1
2233 integer(i4),
dimension(:,:,:),
intent(in) :: mat2
2236 integer(i4) :: m1, m2
2237 integer(i4) :: n1, n2
2238 integer(i4) :: o1, o2
2239 integer(i4),
dimension(:,:,:),
allocatable :: tmp
2245 if (
allocated(mat1))
then
2249 if ( (m1 /= m2))
then
2250 print*,
'paste: rows of array1 and array2 are unequal : (',m1,
') and (',m2,
')'
2252 else if ( (n1 /= n2))
then
2253 print*,
'paste: columns of array1 and array2 are unequal : (',n1,
') and (',n2,
')'
2257 call move_alloc(mat1, tmp)
2259 allocate(mat1(m1,n1,o1+o2))
2260 mat1(:,:,1:o1) = tmp(:,:,:)
2261 mat1(:,:,o1+1_i4:o1+o2) = mat2(:,:,:)
2264 allocate(mat1(m2,n2,o2))
2265 mat1(:,:,:) = mat2(:,:,:)
2268 END SUBROUTINE paste_i4_3d
2270 SUBROUTINE paste_i4_4d(mat1, mat2)
2272 integer(i4),
dimension(:,:,:,:),
allocatable,
intent(inout) :: mat1
2273 integer(i4),
dimension(:,:,:,:),
intent(in) :: mat2
2276 integer(i4) :: m1, m2
2277 integer(i4) :: n1, n2
2278 integer(i4) :: o1, o2
2279 integer(i4) :: p1, p2
2280 integer(i4),
dimension(:,:,:,:),
allocatable :: tmp
2287 if (
allocated(mat1))
then
2292 if ( (m1 /= m2))
then
2293 print*,
'paste: rows of array1 and array2 are unequal : (',m1,
') and (',m2,
')'
2295 else if ( (n1 /= n2))
then
2296 print*,
'paste: columns of array1 and array2 are unequal : (',n1,
') and (',n2,
')'
2298 else if ( (o1 /= o2))
then
2299 print*,
'paste: columns of array1 and array2 are unequal : (',o1,
') and (',o2,
')'
2303 call move_alloc(mat1, tmp)
2305 allocate(mat1(m1,n1,o1,p1+p2))
2306 mat1(:,:,:,1:p1) = tmp(:,:,:,:)
2307 mat1(:,:,:,p1+1_i4:p1+p2) = mat2(:,:,:,:)
2310 allocate(mat1(m2,n2,o2,p2))
2311 mat1(:,:,:,:) = mat2(:,:,:,:)
2314 END SUBROUTINE paste_i4_4d
2316 SUBROUTINE paste_char_m_s(mat1, sca2)
2320 character(len=*),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2321 character(len=*),
intent(in) :: sca2
2326 character(len(mat1)),
dimension(:,:),
allocatable :: tmp
2328 if (
allocated(mat1))
then
2331 if (m1 /= 1_i4)
then
2332 print*,
'paste: scalar paste to matrix only works with one-line matrix'
2336 call move_alloc(mat1, tmp)
2338 allocate(mat1(1_i4,n1+1_i4))
2339 mat1(1,1:n1) = tmp(1,1:n1)
2340 mat1(1,n1+1_i4) = sca2
2342 allocate(mat1(1_i4,1_i4))
2346 END SUBROUTINE paste_char_m_s
2348 SUBROUTINE paste_char_m_v(mat1, vec2, fill_value)
2352 character(len=*),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2353 character(len=*),
dimension(:),
intent(in) :: vec2
2354 character(len=*),
optional,
intent(in) :: fill_value
2357 integer(i4) :: m1, m2
2358 integer(i4) :: n1, n2
2359 character(len(mat1)),
dimension(:,:),
allocatable :: tmp
2364 if (
allocated(mat1))
then
2367 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
2368 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2372 call move_alloc(mat1, tmp)
2374 if ( m1 == m2 )
then
2375 allocate(mat1(m1,n1+n2))
2376 mat1(1:m1,1:n1) = tmp(:,1:n1)
2377 mat1(1:m2,n1+n2) = vec2(1:m2)
2381 allocate(mat1(m1,n1+n2))
2382 mat1( 1:m1,1:n1) = tmp(:,1:n1)
2383 mat1( 1:m2,n1+n2) = vec2(1:m2)
2384 mat1(m2+1:m1,n1+n2) = fill_value
2388 allocate(mat1(m2,n1+n2))
2389 mat1( 1:m1,1:n1) = tmp(:,1:n1)
2390 mat1(m1+1:m2,1:n1) = fill_value
2391 mat1( 1:m2,n1+n2) = vec2(1:m2)
2398 allocate(mat1(m2,n2))
2399 mat1(1:m2,n1+n2) = vec2(1:m2)
2402 END SUBROUTINE paste_char_m_v
2404 SUBROUTINE paste_char_m_m(mat1, mat2, fill_value)
2408 character(len=*),
dimension(:,:),
allocatable,
intent(inout) :: mat1
2409 character(len=*),
dimension(:,:),
intent(in) :: mat2
2410 character(len=*),
optional,
intent(in) :: fill_value
2413 integer(i4) :: m1, m2
2414 integer(i4) :: n1, n2
2415 character(len(mat1)),
dimension(:,:),
allocatable :: tmp
2420 if (
allocated(mat1))
then
2423 if ( (m1 /= m2) .and. .not.
present( fill_value ) )
then
2424 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2428 call move_alloc(mat1, tmp)
2430 if ( m1 == m2 )
then
2431 allocate(mat1(m1,n1+n2))
2432 mat1(:,1:n1) = tmp(:,1:n1)
2433 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2437 allocate(mat1(m1,n1+n2))
2438 mat1( : ,1:n1) = tmp(:,1:n1)
2439 mat1( 1:m2,n1+1_i4:n1+n2) = mat2(:,1:n2)
2440 mat1(m2+1:m1,n1+1_i4:n1+n2) = fill_value
2444 allocate(mat1(m2,n1+n2))
2445 mat1( 1:m1, 1:n1 ) = tmp(:,1:n1)
2446 mat1(m1+1:m2, 1:n1 ) = fill_value
2447 mat1( : ,n1+1_i4:n1+n2) = mat2(:,1:n2)
2454 allocate(mat1(m2,n2))
2455 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2458 END SUBROUTINE paste_char_m_m
2460 SUBROUTINE paste_lgt_m_s(mat1, sca2)
2464 logical,
dimension(:,:),
allocatable,
intent(inout) :: mat1
2465 logical,
intent(in) :: sca2
2470 logical,
dimension(:,:),
allocatable :: tmp
2472 if (
allocated(mat1))
then
2475 if (m1 /= 1_i4)
then
2476 print*,
'paste: scalar paste to matrix only works with one-line matrix'
2480 call move_alloc(mat1, tmp)
2482 allocate(mat1(1_i4,n1+1_i4))
2483 mat1(1,1:n1) = tmp(1,1:n1)
2484 mat1(1,n1+1_i4) = sca2
2486 allocate(mat1(1_i4,1_i4))
2490 END SUBROUTINE paste_lgt_m_s
2492 SUBROUTINE paste_lgt_m_v(mat1, vec2)
2496 logical,
dimension(:,:),
allocatable,
intent(inout) :: mat1
2497 logical,
dimension(:),
intent(in) :: vec2
2500 integer(i4) :: m1, m2
2501 integer(i4) :: n1, n2
2502 logical,
dimension(:,:),
allocatable :: tmp
2507 if (
allocated(mat1))
then
2511 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2515 call move_alloc(mat1, tmp)
2517 allocate(mat1(m1,n1+n2))
2518 mat1(:,1:n1) = tmp(:,1:n1)
2519 mat1(1:m2,n1+n2) = vec2(1:m2)
2524 allocate(mat1(m2,n2))
2525 mat1(1:m2,n1+n2) = vec2(1:m2)
2528 END SUBROUTINE paste_lgt_m_v
2530 SUBROUTINE paste_lgt_m_m(mat1, mat2)
2534 logical,
dimension(:,:),
allocatable,
intent(inout) :: mat1
2535 logical,
dimension(:,:),
intent(in) :: mat2
2538 integer(i4) :: m1, m2
2539 integer(i4) :: n1, n2
2540 logical,
dimension(:,:),
allocatable :: tmp
2545 if (
allocated(mat1))
then
2549 print*,
'paste: rows of matrix1 and matrix2 are unequal : (',m1,
',',n1,
') and (',m2,
',',n2,
')'
2553 call move_alloc(mat1, tmp)
2555 allocate(mat1(m1,n1+n2))
2556 mat1(:,1:n1) = tmp(:,1:n1)
2557 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2562 allocate(mat1(m2,n2))
2563 mat1(:,n1+1_i4:n1+n2) = mat2(:,1:n2)
2566 END SUBROUTINE paste_lgt_m_m
2568 subroutine add_nodata_slice_dp_2d(array, nAdd, noDataValue)
2569 real(dp),
dimension(:, :),
intent(inout),
allocatable :: array
2570 integer(i4),
intent(in) :: nAdd
2571 real(dp),
intent(in) :: noDataValue
2573 real(dp),
dimension(size(array, 1), nAdd) :: dummy
2575 if (nadd > 0_i4)
then
2577 call paste(array, dummy)
2580 end subroutine add_nodata_slice_dp_2d
2582 subroutine add_nodata_slice_dp_3d(array, nAdd, noDataValue)
2583 real(dp),
dimension(:, :, :),
intent(inout),
allocatable :: array
2584 integer(i4),
intent(in) :: nAdd
2585 real(dp),
intent(in) :: noDataValue
2587 real(dp),
dimension(size(array, 1), size(array, 2), nAdd) :: dummy
2589 if (nadd > 0_i4)
then
2591 call paste(array, dummy)
2594 end subroutine add_nodata_slice_dp_3d
2596 subroutine add_nodata_slice_dp_4d(array, nAdd, noDataValue)
2597 real(dp),
dimension(:, :, :, :),
intent(inout),
allocatable :: array
2598 integer(i4),
intent(in) :: nAdd
2599 real(dp),
intent(in) :: noDataValue
2601 real(dp),
dimension(size(array, 1), size(array, 2), size(array, 3), nAdd):: dummy
2603 if (nadd > 0_i4)
then
2605 call paste(array, dummy)
2608 end subroutine add_nodata_slice_dp_4d
2610 subroutine add_nodata_slice_i4_2d(array, nAdd, noDataValue)
2611 integer(i4),
dimension(:, :),
intent(inout),
allocatable :: array
2612 integer(i4),
intent(in) :: nAdd
2613 integer(i4),
intent(in) :: noDataValue
2615 integer(i4),
dimension(size(array, 1), nAdd) :: dummy
2617 if (nadd > 0_i4)
then
2619 call paste(array, dummy)
2622 end subroutine add_nodata_slice_i4_2d
2624 subroutine add_nodata_slice_i4_3d(array, nAdd, noDataValue)
2625 integer(i4),
dimension(:, :, :),
intent(inout),
allocatable :: array
2626 integer(i4),
intent(in) :: nAdd
2627 integer(i4),
intent(in) :: noDataValue
2629 integer(i4),
dimension(size(array, 1), size(array, 2), nAdd) :: dummy
2631 if (nadd > 0_i4)
then
2633 call paste(array, dummy)
2636 end subroutine add_nodata_slice_i4_3d
2638 subroutine add_nodata_slice_i4_4d(array, nAdd, noDataValue)
2639 integer(i4),
dimension(:, :, :, :),
intent(inout),
allocatable :: array
2640 integer(i4),
intent(in) :: nAdd
2641 integer(i4),
intent(in) :: noDataValue
2643 integer(i4),
dimension(size(array, 1), size(array, 2), size(array, 3), nAdd):: dummy
2645 if (nadd > 0_i4)
then
2647 call paste(array, dummy)
2650 end subroutine add_nodata_slice_i4_4d
Paste a matrix of ones times a value onto an existing matrix.
Append (rows) scalars, vectors, and matrixes onto existing array.
Paste (columns) scalars, vectors, and matrixes onto existing array.
Append values on existing arrays.
Define number representations.
integer, parameter sp
Single Precision Real Kind.
integer, parameter i4
4 Byte Integer Kind
integer, parameter i8
8 Byte Integer Kind
integer, parameter dp
Double Precision Real Kind.