subroutine writeNCLascii(cptz1, lrtz1, cptz2, lrtz2, dim1, dim2)
    implicit none
    integer, intent(in) :: dim1, dim2
    real, intent(in) :: cptz1(dim1), lrtz1(dim1), cptz2(dim2), lrtz2(dim2)
    integer :: i, dim

    if (dim1 >= dim2) then
      dim = dim2
    else
      dim = dim1
    endif

  
    open (11, file = "cptz.txt")
    open (21, file = "lrtz.txt")

    do i = 1, dim
      write(11, "(2f8.4)") cptz1(i), cptz2(i)
      write(21, "(2f8.4)") lrtz1(i), lrtz2(i)
    end do
    close(11)
    close(21)
  
end subroutine writeNCLascii

