#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

if($in_partitioned) {
  AF = federated(addresses=list($in_A1, $in_A2), ranges=list(list(0, 0), list($rows, $cols), list($rows, 0), list($rows * 2, $cols)));
  BF = federated(addresses=list($in_B1, $in_B2), ranges=list(list(0, 0), list($rows, $cols), list($rows, 0), list($rows * 2, $cols)));
  B = rbind(read($in_B1_local), read($in_B2_local));
  while(FALSE) { }
}
else {
  AF = federated(addresses=list($in_A1), ranges=list(list(0, 0), list($rows, $cols)))
  BF = federated(addresses=list($in_B1), ranges=list(list(0, 0), list($rows, $cols)))
  B = read($in_B1_local);
}

R_FF_misaligned = rbind(AF, AF);
C_FF_aligned = cbind(AF, AF);
R_FF = rbind(AF, BF)
C_FF = cbind(AF, BF)
R_FL = rbind(AF, B)
C_FL = cbind(AF, B)
R_LF = rbind(B, AF)
C_LF = cbind(B, AF)

write(R_FF_misaligned, $out_R_FF_misaligned);
write(C_FF_aligned, $out_C_FF_aligned);

write(R_FF, $out_R_FF)
write(R_FL, $out_R_FL)
write(R_LF, $out_R_LF)

write(C_FF, $out_C_FF)
write(C_FL, $out_C_FL)
write(C_LF, $out_C_LF)
