text: /*
   * Copyright (c) 2009, NSF Cloud and Autonomic Computing Center, Rutgers University
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * - Redistributions of source code must retain the above copyright notice, this list of conditions and
   * the following disclaimer.
   * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
   * the following disclaimer in the documentation and/or other materials provided with the distribution.
   * - Neither the name of the NSF Cloud and Autonomic Computing Center, Rutgers University, nor the names of its
   * contributors may be used to endorse or promote products derived from this software without specific prior
   * written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
   * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
   * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   * POSSIBILITY OF SUCH DAMAGE.
   *
   */
  
  /*
  *  Fan Zhang (2013)  TASSL Rutgers University
  *  zhangfan@cac.rutgers.edu
  *  Qian Sun (2014)  TASSL Rutgers University
  *  qiansun@cac.rutgers.edu
  *  Yubo Qin (2018) RDI2 Rutgers University
  *  yubo.qin@rutgers.edu
  */
  
  #include <stdio.h>
  #include <stdint.h>
  
  #include "debug.h"
  #include "common.h"
  
  #include "mpi.h"
  
  
  
  extern int test_put_run_noinit(enum transport_type, int npapp, int dims, 
  	int* npdim, uint64_t *spdim, int timestep, int appid, 
  	size_t elem_size, int num_vars, int* vars_name, MPI_Comm gcomm, int lock_num, int p_lev);
  
  extern int test_get_run_noinit(enum transport_type, int npapp, int dims, 
  	int* npdim, uint64_t *spdim, int timestep, int appid, 
  	size_t elem_size, int num_vars, int* vars_name, MPI_Comm gcomm, int lock_num, int p_lev);
  
  int main(int argc, char **argv)
  {
  	int err;
  	int nprocs, rank;
  	MPI_Comm gcomm;
  
      // Usage: ./test_writer type npapp dims np[0] ... np[dims-1] sp[0] ... sp[dims-1] timestep appid elem_size num_vars
      // Command line arguments
      enum transport_type type; // DATASPACES or DIMES
      int npapp; // number of application processes
      int np[10] = {0};	//number of processes in each dimension
      uint64_t sp[10] = {0}; //block size per process in each dimesion
      int timestep; // number of iterations
      int appid; // application id
      int dims; // number of dimensions
      size_t elem_size; // Optional: size of one element in the global array. Default value is 8 (bytes).
      int num_vars; // Optional: number of variables to be shared in the testing. Default value is 1.
      //Yubo
      int vars_name[16] = {1}; //variable names, enable multiple variables
      int lock_num = 1; //locker number
      int p_lev = 0; //priority level information
  
      //Yubo
  	if (parse_args(argc, argv, &type, &npapp, &dims, np, sp,
      		&timestep, &appid, &elem_size, &num_vars) != 0) {
  		goto err_out;
  	}
  
  	// Using SPMD style programming
  	MPI_Init(&argc, &argv);
  	MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
  	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  	MPI_Barrier(MPI_COMM_WORLD);
  	gcomm = MPI_COMM_WORLD;
  
      int color = 4;
  	MPI_Comm_split(MPI_COMM_WORLD, color, rank, &gcomm);
  
  	common_init(npapp, appid, &gcomm, NULL);
  	//common_get_transport_type_str(type, transport_type_str_);
  
  
  	num_vars = 1;
  	vars_name[0] = 1;
  	lock_num = 1;
  	p_lev = 0;
  
  	// Run as data reader
  	test_get_run_noinit(type, npapp, dims, np,
  		sp, timestep, appid, elem_size, num_vars, vars_name, gcomm, lock_num, p_lev);
  
  	num_vars = 1;
  	vars_name[0] = 3;
  	lock_num = 3;
  	p_lev = 0;
  
  	// Run as data reader
  	test_get_run_noinit(type, npapp, dims, np,
  		sp, timestep, appid, elem_size, num_vars, vars_name, gcomm, lock_num, p_lev);
  
  	MPI_Barrier(gcomm);
  
  	uloga("test_lev3 DONE\n");
  
  	MPI_Finalize();
  
  	return 0;	
  err_out:
  	uloga("error out!\n");
  	return -1;	
  }
  
  