Example #1
0
int read_snapshot(
		   bodyptr *btab_ptr,	     /* gets particle array */
		   int *nobj_ptr,	     /* gets number of bodies */
		   stream instr              /* stream to read from */
		   )
{
  int nobj, cs, i;
  real *mbuf, *mp, *pbuf, *pp;
  bodyptr bp;

  for(;;) {                        /* loop until done or proper snapshot */
    if (!get_tag_ok(instr,SnapShotTag))
        return 0;
    get_set(instr, SnapShotTag);
    if (!get_tag_ok(instr,ParametersTag)) {
    	get_tes(instr,SnapShotTag);
        continue;
    }
    get_set(instr, ParametersTag);
    get_data(instr, NobjTag, IntType, &nobj, 0);
    if (nobj < 1)
	error("read_snapshot: %s = %d  is absurd", NobjTag, nobj);
    if (get_tag_ok(instr,TimeTag))
        get_data(instr,TimeTag, RealType, &tsnap, 0);
    else {
        dprintf(0,"No time tag: time=0.0 assumed\n");
        tsnap = 0.0;
    }
    get_tes(instr, ParametersTag);
    if (!get_tag_ok(instr,ParticlesTag)) {
    	get_tes(instr,SnapShotTag);
        continue;
    }
    get_set(instr, ParticlesTag);
    get_data(instr, CoordSystemTag, IntType, &cs, 0);
    if (cs != CSCode(Cartesian, NDIM, 2))
	error("read_snapshot: cannot handle %s = %d", CoordSystemTag, cs);
    mbuf = mp = (real *) allocate(nobj * sizeof(real));
    pbuf = pp = (real *) allocate(nobj * 2 * NDIM * sizeof(real));
    get_data(instr, MassTag, RealType, mbuf, nobj, 0);
    get_data(instr, PhaseSpaceTag, RealType, pbuf, nobj, 2, NDIM, 0);
    get_tes(instr, ParticlesTag);
    get_tes(instr, SnapShotTag);
    *btab_ptr = bp = (bodyptr) allocate(nobj * sizeof(body));
    for (i = 0; i < nobj; i++) {
	Type(bp) = BODY;
	Mass(bp) = *mp++;
	SETV(Pos(bp), pp);
	pp += NDIM;
	SETV(Vel(bp), pp);
	pp += NDIM;
	bp++;
    }
    free(mbuf);
    free(pbuf);
    *nobj_ptr = nobj;
    return 1;
  }
}
void FuncMemory::alloc( uint64 addr)
{
    uint8*** set = &memory[get_set(addr)];
    if ( *set == NULL)
    {
        *set = new uint8* [1 << page_bits];
    	memset(*set, 0, sizeof(uint8*) * (1 << page_bits));
    }
    uint8** page = &memory[get_set(addr)][get_page(addr)];
    if ( *page == NULL)
    {
        *page = new uint8 [1 << offset_bits];
    	memset(*page, 0, sizeof(uint8) * (1 << offset_bits));
    }
}
Example #3
0
void print_item(string tag)
{
    string type, stag;
    int *dims;

    type = get_type(instr, tag);
    if (streq(type, SetType)) {
	get_set(instr, tag);
	print_set(tag);
	while ((stag = next_item_tag(instr)) != NULL) {
	    print_item(stag);
	    free(stag);
	}
	get_tes(instr, tag);
	print_tes(tag);
    } else {
	dims = get_dimensions(instr, tag);
	print_head(tag, type, dims);
	print_data(tag, type, dims);
	endline();
	if (dims != NULL)
	    free(dims);
    }
    free(type);
}
Example #4
0
CacheMESI L1Cache
::queryInv(uint64_t addr)
{
	unsigned int t_set_index = get_set(addr);
	L1Set* t_set;
	CacheMESI t_mesi;

	assert(t_set_index<m_set_num);
	
	t_set = m_tag_array[t_set_index];

	for(unsigned int i=0;i<m_way_num;i++)
	{
		if(t_set->m_tag[i].m_mesi == I)
		{
			continue;
		}
		
		if(t_set->m_tag[i].m_tag == get_tag(addr))//hit
		{
			t_mesi = t_set->m_tag[i].m_mesi;

			t_set->m_tag[i].m_mesi = I;

			t_set->deleteLRUEntry(&t_set->m_tag[i]);

			t_set->m_free_way_que.push_back(i);
			return t_mesi;
		}
	}
	assert(false);
}
Example #5
0
CacheMESI L1Cache
::query(uint64_t addr)
{
	unsigned int t_set_index = get_set(addr);
	L1Set* t_set;
	CacheMESI t_mesi;

	assert(t_set_index<m_set_num);
	
	t_set = m_tag_array[t_set_index];

	for(unsigned int i=0;i<m_way_num;i++)
	{
		if(t_set->m_tag[i].m_mesi == I)
		{
			continue;
		}
		
		if(t_set->m_tag[i].m_tag == get_tag(addr))//hit
		{
			t_mesi = t_set->m_tag[i].m_mesi;

			t_set->m_tag[i].m_mesi = S;

			return t_mesi;
		}
	}
	assert(false);
}
Example #6
0
void print_item(string tag)
{
    string type, *tags, *tp;
    int *dims;

    type = get_type(instr, tag);
    if (streq(type, SetType)) {
	get_set(instr, tag);
	print_set(tag);
	tags = list_tags(instr);
	for (tp = tags; *tp != NULL; tp++)
	    print_item(*tp);
	get_tes(instr, tag);
	print_tes(tag);
	for (tp = tags; *tp != NULL; tp++)
	    free(*tp);
	free((char *)tags);
    } else {
	dims = get_dims(instr, tag);
	print_header(tag, type, dims);
	(void) outstr(" ");
	print_data(tag, type, dims);
	end_line();
	if (dims != NULL)
	    free((char *)dims);
    }
    free(type);
}
Example #7
0
GLuint
image_render_set_get_image(char *name, int cur_tick)
{
    int ind = get_set(name);
    if(ind < 0)
    {
        ERROR("attempting to grab an image from a nonexistant render_set \"%s\"\n", name);
        return 0;
    }

    GLuint result;

    /* hack to skip loop if only one frame */
    if(set[ind].num_frames > 1)
    {
        int frame = 0;
        int skip_frames = 0;

        while(cur_tick >= 0)
        {
            cur_tick -= set[ind].frames[frame]->num_ticks;
            skip_frames++;
        }

        --skip_frames;

        frame = (frame + skip_frames) % set[ind].num_frames;
        
        result = set[ind].frames[frame]->texture;
    } else {
        result = set[ind].frames[0]->texture;
    }

    return result;
}
Example #8
0
iterator* info_base::first(char* col_nm, c_code_t code)
{
   handler* x = get_set(col_nm);

   if ( x == 0 ) {
      handler* x = get_list(col_nm);
   }

   if ( x == 0 ) {
      throw(stringException("unknown collection name"));
   }

   page_storage *s = (page_storage*)(x -> its_store());

   if ( s == 0 ) {
      throw(stringException("collection has no store"));
   }

   if ( s -> my_oid().ccode() != PAGE_STORAGE_CODE ) {
      throw(stringException("non page store no supported"));
   }

   iterator* it = new iterator(x, code);

   it -> ind = s -> first_loc();

   if ( managers::template_mgr -> peek_slot(s, it->ind) != code ) {
      this -> next(*it);
   }

   return it;
}
Example #9
0
 int get_set(std::vector<int>& a, int i)
 {
     if (i == a[i])
         return i;
     a[i] = get_set(a, a[i]);
     return a[i];
 }
Example #10
0
void tcp_acceptor::update() {
	//std::thread t(..., n.get_engine());
	//t.join();

	// accept requests
	if (readyfd(sockfd)) {
		sockaddr_in cli_addr;
		int newfd = acceptfd(cli_addr);
		if (newfd >= 0) {
			std::string name = get_name() + "-" + std::to_string(next_sock_id++);
			sockets.emplace_back(std::make_unique<tcp_socket>(get_set(), newfd, name, cli_addr));
			sockets.back()->channel_copy_all(this);
		}
	}

	sockets.erase(
		std::remove_if(
			sockets.begin(),
			sockets.end(),
			[](std::unique_ptr<tcp_socket> &s) {
				return !s->is_open();
			}),
		sockets.end()
	);
}
wxArrayString ArrayVariableProperty::get_valid(const wxArrayString& val) {
	std::set<wxString> set = get_set(dataset_vars_);
	wxArrayString ret;
	for (wxArrayString::const_iterator it = val.begin(); it != val.end(); it++)
		if (set.find(*it) != set.end()) ret.Add(*it);
	return ret;
}
Example #12
0
int			ft_env(t_list *cmd_l, t_list *env_l)
{
	t_list	*env_c;
	char	**arg;
	t_list	*unset;
	int		i;
	int		illegal;

	i = 1;
	illegal = 0;
	if (!(start_env(env_l, &env_c, &arg, cmd_l)))
		return (1);
	if (!(no_arg_env(arg, &env_c, i)))
		return (help_env(&env_c));
	unset = checkout(arg, &i, env_c, &illegal);
	if (!(unset_it(unset, &env_c)))
		return (help_env(&env_c));
	get_set(arg, &i, &env_c);
	if (arg[i])
		execute(arg + i, &env_c);
	else if (!illegal)
		print_lst(env_c);
	ft_lstdel(&unset, (void(*)(void*, size_t))del_content);
	free_tab2d(arg);
	ft_lstdel(&env_c, (void(*)(void*, size_t))del_content);
	return (1);
}
Example #13
0
void generator::get_representative_of_subset_orbit(
	INT *set, INT size, INT local_orbit_no, 
	strong_generators *&Strong_gens, 
	INT verbose_level)
{
	INT f_v = (verbose_level >= 1);
	INT f_vv = (verbose_level >= 2);
	INT fst, node, sz;
	oracle *O;

	if (f_v) {
		cout << "generator::get_representative_of_subset_orbit verbose_level=" << verbose_level << endl;
		}
	fst = first_oracle_node_at_level[size];
	node = fst + local_orbit_no;
	if (f_vv) {
		cout << "generator::get_representative_of_subset_orbit before get_set" << endl;
		}
	get_set(node, set, sz);
	if (sz != size) {
		cout << "get_representative_of_subset_orbit: sz != size" << endl;
		exit(1);
		}
	O = root + node;
	if (f_vv) {
		cout << "generator::get_representative_of_subset_orbit before get_stabilizer_generators" << endl;
		}
	O->get_stabilizer_generators(this, Strong_gens, 0);
	if (f_v) {
		cout << "generator::get_representative_of_subset_orbit done" << endl;
		}
}
Example #14
0
Float RefinedPairsPairScore::evaluate_index(kernel::Model *m,
                                            const kernel::ParticleIndexPair &p,
                                            DerivativeAccumulator *da) const {
  kernel::ParticlesTemp ps[2] = {get_set(m->get_particle(p[0]), r_),
                                 get_set(m->get_particle(p[1]), r_)};
  double ret = 0;
  for (unsigned int i = 0; i < ps[0].size(); ++i) {
    for (unsigned int j = 0; j < ps[1].size(); ++j) {
      ret +=
          f_->evaluate_index(ps[0][0]->get_model(),
                             kernel::ParticleIndexPair(ps[0][i]->get_index(),
                                                       ps[1][j]->get_index()),
                             da);
    }
  }
  return ret;
}
Example #15
0
int count_set(int *l, int type){ /* count number of elements in the sets */
  int* dup = dup_set(l,type);
  int result = 0;
  while (get_set(dup,type)!=-1){
    result++;
  }
  return result;
}
bool ArrayVariableProperty::ValidateValue(wxVariant& value,
		wxPGValidationInfo& validationinfo) const {
	wxArrayString dataset_vars = get_dataset_vars();
	std::set<wxString> set = get_set(dataset_vars);
	wxArrayString tmp = value.GetArrayString();
	for (wxArrayString::const_iterator it = tmp.begin(); it != tmp.end(); it++)
		if (set.find(*it) == set.end()) return false;
	return true;
}
Example #17
0
ModelObjectsTemp RefinedPairsPairScore::do_get_inputs(
    kernel::Model *m, const kernel::ParticleIndexes &pis) const {
  kernel::ParticleIndexes ps;
  for (unsigned int i = 0; i < pis.size(); ++i) {
    ps += get_indexes(get_set(m->get_particle(pis[i]), r_));
  }
  kernel::ModelObjectsTemp ret;
  ret += f_->get_inputs(m, ps);
  ret += r_->get_inputs(m, ps);
  return ret;
}
Example #18
0
bool
cql::cql_row_t::get_set(const std::string& column,
                        cql::cql_set_t& output) const
{
    int i = 0;
    if (_metadata.get_index(column, i))
    {
        return get_set(i, output);
    }
    return false;
}
Example #19
0
int info_base::num_of_docs()
{
// the implementation is temp. It should take
// a hint as where to obtain the information.
// like from a set named so and so.

   cset_handler* x = get_set("doc");
   if (x) {
      return (*x) -> count();
   } else {
      return 0;
   }
}
Example #20
0
void L2Cache::
dump_addr(unsigned int addr)
{
	unsigned int set_index = get_set(addr);
	L2Set* t_set = m_tag_array[set_index];
	
	cout<<"---- "<<" set["<<dec<<set_index<<"]: ";
	for(unsigned int i=0;i<m_way_num;i++)
	{
		cout<<"0x"<<hex<<t_set->m_tag[i].m_tag<<"|"<<((t_set->m_tag[i].m_mesi==I)?"0":"1")
			<<((i == m_way_num-1)?" ":", ");
	}
	cout<<endl;
}
Example #21
0
void L2Cache::
evict(unsigned int l1_id, uint64_t addr, bool dirty)
{
	unsigned int t_set_index = get_set(addr);
	L2Set* t_set;
	assert(t_set_index<m_set_num);
	
	t_set = m_tag_array[t_set_index];
	
	for(unsigned int i=0;i<m_way_num;i++)
	{
		if(t_set->m_tag[i].m_mesi == I)
		{
			continue;
		}
		
		if(t_set->m_tag[i].m_tag == get_tag(addr))//hit
		{
			if(!dirty)//clean
			{
				for(unsigned int j=0;j<t_set->m_tag[i].m_vld_l1_que.size();j++)
				{
					if(t_set->m_tag[i].m_vld_l1_que[j] == l1_id)
					{
						t_set->m_tag[i].m_vld_l1_que.erase(
								t_set->m_tag[i].m_vld_l1_que.begin()+j);
						return;
					}
				}
				assert(false);
			}
			else//dirty
			{
				assert(t_set->m_tag[i].m_vld_l1_que.size() == 1);
				t_set->m_tag[i].m_vld_l1_que.clear();

				t_set->m_tag[i].m_mesi = M;

				return;
			}
		}
	}

	cout<<" Error, evict addr 0x"<<hex<<addr
		<<", in L2 set["<<dec<<t_set_index<<"]"
		<<endl;

	assert(false);//can not miss
}
Example #22
0
int main (int argc, char *argv[]) {
  char *file_name = "/dev/query";
  int fd;
  enum {
    e_get = 0,
    e_clr,
    e_set,
  } option;
  
  if (argc == 1)
    option = e_get;
  else if (argc == 2) {
    if (strcmp(argv[1], "-g") == 0) {
      option = e_get;
    } else if (strcmp(argv[1], "-c") == 0) {
      option = e_clr;
    } else if (strcmp(argv[1], "-s") == 0) {
      option = e_set;
    } else {
      fprintf (stderr, "Usage: %s [-g | -c | -s]\n", argv[0]);
      return -1;
      }
  } else {
    fprintf (stderr, "Usage: %s [-g | -c | -s] \n", argv[0]);
    return -1;
  }
  if (fd == -1) {
    perror ("query_apss open");
    return 2;
  }

  switch (option) {
  case e_get :
    get_vars (fd);
    break;
  case e_clr :
    clr_vars (fd);
    break;
  case e_set :
    get_set (fd);
    break;
  default:
    break;
  }
  close (fd);
  return 0;
}
Example #23
0
void generator::find_automorphism_group_of_order(INT level, INT order)
{
	INT nb_nodes, node, i, j, elt_order;
	longinteger_object ago;
	INT set[300];
	
	nb_nodes = nb_orbits_at_level(level);
	for (i = 0; i < nb_nodes; i++) {
		node = first_oracle_node_at_level[level] + i;
		if (root[node].nb_strong_generators == 0) {
			ago.create(1);
			}
		else {
			ago.create_product(A->base_len, root[node].tl);
			}
		if (ago.as_INT() == order) {
			cout << "found a node whose automorphism group is order " << order << endl;
			cout << "the node is # " << i << " at level " << level << endl;
			get_set(first_oracle_node_at_level[level] + i, set, level);
			INT_vec_print(cout, set, level);
			cout << endl;
			
			strong_generators *Strong_gens;
			
			get_stabilizer_generators(Strong_gens,  
				level, i, 0  /* verbose_level */);
				
			for (j = 0; j < Strong_gens->gens->len; j++) {
				elt_order = A->element_order(Strong_gens->gens->ith(j));
				cout << "generator " << j << " of order" << elt_order << ":" << endl;
				if (order == elt_order) {
					cout << "CYCLIC" << endl;
					}
				A->element_print(Strong_gens->gens->ith(j), cout);
				A->element_print_as_permutation(Strong_gens->gens->ith(j), cout);
				}
			delete Strong_gens;
			}
		}
}
Example #24
0
gsprof *get_gsprof(stream istr)
{
    string gsptag = "GeneralSphericalProfile";
    gsprof *gsp;

    if (get_tag_ok(istr, "FiniteSphericalProfile"))	/* old-style file?  */
	gsptag = "FiniteSphericalProfile";		/* use old tag      */
    gsp = (gsprof *) allocate(sizeof(gsprof));
    get_set(istr, gsptag);
    get_data(istr, "Npoint", IntType, &gsp->npoint, 0);
    gsp->radius = (real *) allocate(gsp->npoint * sizeof(real));
    gsp->density = (real *) allocate(gsp->npoint * sizeof(real));
    gsp->mass = (real *) allocate(gsp->npoint * sizeof(real));
    get_data(istr, "Radius", RealType, gsp->radius, gsp->npoint, 0);
    get_data(istr, "Density", RealType, gsp->density, gsp->npoint, 0);
    get_data(istr, "Mass", RealType, gsp->mass, gsp->npoint, 0);
    get_data(istr, "Alpha", RealType, &gsp->alpha, 0);
    get_data(istr, "Beta", RealType, &gsp->beta, 0);
    get_data(istr, "Mtot", RealType, &gsp->mtot, 0);
    get_tes(istr, gsptag);
    return (gsp);
}
Example #25
0
// do cache operation in this funciton
void operate_cache(Cache *cache,char identifier,int address,int size)
{
	int set = get_set(address,s,b);
	int tag = get_tag(address,s,b);
	//load store or modify
	switch (identifier){
		case 'L':
			operate_load(cache,set,tag);
			break;
			
		case 'S':
			operate_store(cache,set,tag);
			break;
			
		case 'M' :
			operate_modify(cache,set,tag);
			break;
			
		default:
            printf("Illegal operation argument.\n");
            exit(0);
	}
}
Example #26
0
void
image_render_set_add(char *name, char *image_name, int num_ticks)
{
    int ind = get_set(name);
    if(ind < 0)
    {
        ERROR("attempt to add to nonexistant render_set \"%s\"\n", name);
        return;
    }
    
    set[ind].frames = 
        memory_grow_to_size(set[ind].frames,
                            sizeof(*set[ind].frames),
                            &set[ind].cap_frames,
                            set[ind].num_frames + 1);

    GLuint texture = image_loader_get(image_name);
    struct keyframe *frame = malloc(sizeof(*frame));
    frame->texture = texture;
    frame->num_ticks = num_ticks;
    LOG("assigning texture at id %d\n", texture);
    set[ind].frames[set[ind].num_frames++] = frame;
    LOG("adding %d frames of %s to %s\n", num_ticks, image_name, name);
}
Example #27
0
void nemo_main()
{
    stream instr, outstr, out2str;
    string hl;
    real *fbuf, *mbuf, tsnap, mass0, mass1, mass2;
    bool Qswap = getbparam("swap");
    bool Qhead = getbparam("header");
    bool Qmass = FALSE;
    long nread;
    int nbody, i, nbad;
    int cs = CSCode(Cartesian, NDIM, 2);
    int ipar[5];
    float rpar[5], posvel[6];
    

    instr = stropen(getparam("in"),"r");
    outstr = stropen(getparam("out"),"w");


    /* read snapshot */

    get_history(instr);
    hl = ask_headline();
    get_set(instr,SnapShotTag);
      get_set(instr,ParametersTag);
       get_data(instr, NobjTag, IntType, &nbody, 0);
       get_data_coerced(instr, TimeTag, RealType, &tsnap, 0);
      get_tes(instr,ParametersTag);

      fbuf = (real *) allocate(nbody*6*sizeof(real)); 
      mbuf = (real *) allocate(nbody*sizeof(real));   

      get_set(instr,ParticlesTag);
        get_data(instr,CoordSystemTag, IntType, &cs, 0);
	if (Qmass)
	  get_data_coerced(instr,MassTag,RealType,mbuf,nbody,0);
        get_data_coerced(instr,PhaseSpaceTag,RealType,fbuf,nbody,2,NDIM,0);
      get_tes(instr,ParticlesTag);
    get_tes(instr,SnapShotTag);


    ipar[0] = nbody;
    ipar[1] = 0;
    ipar[2] = 0;
    /* ipar[3,4] still unused */


    mass1 = mbuf[0];
    mass0 = mass1*nbody;
    rpar[0] = mass0;
    rpar[1] = tsnap;
    rpar[2] = 0;
    /* rpar[3,4] still unused */
    for (i=0, nbad=0, mass2=0.0; i<nbody; i++) {
      mass2 += mbuf[i];
      if (mbuf[i] != mass1) nbad++;
    }
    if (nbad) 
      warning("Found %d masses not equal to first one; total=%g, expected %g",
	      nbad, mass2, mass0);
			      

    if (Qhead) {
      nread = unfwrite(outstr, (char *)ipar, 5*sizeof(int));
      nread = unfwrite(outstr, (char *)rpar, 5*sizeof(float));
    }

    for (i=0; i<nbody; i++) {
      mbuf[i] = mass1;                              
      nread = unfwrite(outstr, (char *) &fbuf[i*6], 6*sizeof(real)); 
      if (nread<1) error("Early EOF for i=%d",i);
    }
    
    strclose(instr);
    strclose(outstr);

    if (hasvalue("out2")) {
      outstr = stropen(getparam("out2"),"w");
      put_history(outstr);
      strclose(outstr);
    }
}
Example #28
0
File: image.c Project: jobovy/nemo
int read_image (stream instr, imageptr *iptr)
{
    string read_matdef;
    int nx=0, ny=0, nz=0;
    size_t  nxyz;

    get_history(instr);         /* accumulate history */

    if (!get_tag_ok (instr,ImageTag))
        return 0;			/* not an image available */
        
    if (*iptr==NULL) {		/* allocate image if neccessary */
    	*iptr = (imageptr ) allocate(sizeof(image));
	dprintf (DLEV,"Allocated image @ %d ",*iptr);
    } else {
        nx = Nx(*iptr);
        ny = Ny(*iptr);
        nz = Nz(*iptr);
    	dprintf (DLEV,"Image %dx%dx%d already allocated @ %d\n",
		 nx,ny,nz,*iptr);
    }
    	
    get_set (instr,ImageTag);
        get_set (instr,ParametersTag);
            get_data (instr,NxTag,IntType, &(Nx(*iptr)), 0);
            get_data (instr,NyTag,IntType, &(Ny(*iptr)), 0);
            get_data (instr,NzTag,IntType, &(Nz(*iptr)), 0);
	    if ((nx>0 || ny>0 || nz>0) &&
		(nx != Nx(*iptr) || ny != Ny(*iptr) || nz != Nz(*iptr)))
	      error("Cannot read different sized images in old pointer yet");
	    if (get_tag_ok(instr,AxisTag))
	      get_data (instr,AxisTag,IntType, &(Axis(*iptr)), 0);
	    else
	      Axis(*iptr) = 0;
	    if (Axis(*iptr) == 1) {
	      get_data_coerced (instr,XrefTag,RealType, &(Xref(*iptr)), 0);
	      get_data_coerced (instr,YrefTag,RealType, &(Yref(*iptr)), 0);
	      get_data_coerced (instr,ZrefTag,RealType, &(Zref(*iptr)), 0);
	    } else {
	      Xref(*iptr) = 0.0;
	      Yref(*iptr) = 0.0;
	      Zref(*iptr) = 0.0;
	    }

            get_data_coerced (instr,XminTag,RealType, &(Xmin(*iptr)), 0);
            get_data_coerced (instr,YminTag,RealType, &(Ymin(*iptr)), 0);
            get_data_coerced (instr,ZminTag,RealType, &(Zmin(*iptr)), 0);
            get_data_coerced (instr,DxTag,RealType, &(Dx(*iptr)), 0);
            get_data_coerced (instr,DyTag,RealType, &(Dy(*iptr)), 0);
            get_data_coerced (instr,DzTag,RealType, &(Dz(*iptr)), 0);
	    get_data_coerced (instr,MapMinTag, RealType, &(MapMin(*iptr)), 0);
	    get_data_coerced (instr,MapMaxTag, RealType, &(MapMax(*iptr)), 0);
	    get_data (instr,BeamTypeTag, IntType, &(BeamType(*iptr)), 0);
	    get_data_coerced (instr,BeamxTag, RealType, &(Beamx(*iptr)), 0);
	    get_data_coerced (instr,BeamyTag, RealType, &(Beamy(*iptr)), 0);
	    get_data_coerced (instr,BeamzTag, RealType, &(Beamz(*iptr)), 0);
            if (get_tag_ok(instr,NamexTag))             /* X-axis name */
                Namex(*iptr) = get_string(instr,NamexTag);
            else
                Namex(*iptr) = NULL;
            if (get_tag_ok(instr,NameyTag))             /* Y-axis name */
                Namey(*iptr) = get_string(instr,NameyTag);
            else
                Namey(*iptr) = NULL;
            if (get_tag_ok(instr,NamezTag))             /* Z-axis name */
                Namez(*iptr) = get_string(instr,NamezTag);
            else
                Namez(*iptr) = NULL;
            if (get_tag_ok(instr,UnitTag))             /* units  */
                Unit(*iptr) = get_string(instr,UnitTag);
            else
                Unit(*iptr) = NULL;
            if (get_tag_ok(instr,TimeTag))             /* time  */
   	    	get_data_coerced (instr,TimeTag, RealType, &(Time(*iptr)), 0);
   	    else
   	    	Time(*iptr) = 0.0;
            read_matdef = get_string(instr,StorageTag);
	    if (!streq(read_matdef,matdef[idef]))
                dprintf(0,"read_image: StorageTag = %s, compiled with %s\n",
		        read_matdef, matdef[idef]);
         get_tes (instr,ParametersTag);

         get_set (instr,MapTag);
            if (Frame(*iptr)==NULL) {        /* check if allocated */
	        nxyz = Nx(*iptr)*Ny(*iptr)*Nz(*iptr);
                Frame(*iptr) = (real *) allocate(nxyz * sizeof(real));
                dprintf (DLEV,"Frame allocated @ %d ",Frame(*iptr));
            } else
                dprintf (DLEV,"Frame already allocated @ %d\n",Frame(*iptr));
	    if (Nz(*iptr)==1)
                get_data_coerced (instr,MapValuesTag,RealType, Frame(*iptr), 
                                Nx(*iptr), Ny(*iptr), 0);
            else
                get_data_coerced (instr,MapValuesTag,RealType, Frame(*iptr),
                                Nx(*iptr), Ny(*iptr), Nz(*iptr), 0);
         get_tes (instr,MapTag);
      get_tes (instr,ImageTag);

      set_iarray(*iptr);

      dprintf (DLEV,"Frame size %d * %d \n",Nx(*iptr), Ny(*iptr));
      
      return 1;		/* succes return code  */
}
Example #29
0
cset_handlerPtr info_base::get_set(const char* set_nm)
{
//MESSAGE(cerr, "in info_base::get_set()");
   return get_set(get_set_pos(set_nm));
}
Example #30
0
bool scansnap(void)
{
    bool success;
    int i;
    real *pptr, *xptr;
    

    success = FALSE;
    while (! success) {
	get_history(instr);
	if (! get_tag_ok(instr, SnapShotTag))
	    return (FALSE);
	get_set(instr, SnapShotTag);
	get_set(instr, ParametersTag);
	if (get_tag_ok(instr, TimeTag)) {
	    if (timeptr == NULL)
		timeptr = (real *) allocate(sizeof(real));
	    get_data_coerced(instr, TimeTag, RealType, timeptr, 0);
	}
	if (get_tag_ok(instr, NobjTag))
	    get_data(instr, NobjTag, IntType, &nbody, 0);
	get_tes(instr, ParametersTag);
	if (get_tag_ok(instr, ParticlesTag) &&
	      (timeptr == NULL || streq(times, "all") ||
	         within(*timeptr, times, TIMEFUZZ))) {
	    get_set(instr, ParticlesTag);
	    if (get_tag_ok(instr, MassTag)) {
		if (massptr == NULL)
		    massptr = (real *) allocate(sizeof(real) * nbody);
		get_data_coerced(instr, MassTag, RealType, massptr,
				 nbody, 0);
	    }
	    if (get_tag_ok(instr, PhaseSpaceTag)) {
		if (phaseptr == NULL)
		    phaseptr = (real *) allocate(sizeof(real) * 2*NDIM * nbody);
		get_data_coerced(instr, PhaseSpaceTag, RealType, phaseptr,
				 nbody, 2, NDIM, 0);
		success = TRUE;
	    } else if (get_tag_ok(instr, PosTag)) {
	        real *ptmp = (real *) allocate(sizeof(real)*nbody*NDIM);
		if (phaseptr == NULL)
		    phaseptr = (real *) allocate(sizeof(real) * 2*NDIM * nbody);
		get_data_coerced(instr, PosTag, RealType, ptmp, nbody, NDIM, 0);

		for (i=0, pptr=phaseptr, xptr=ptmp; i<nbody; i++) {
		  *pptr++ = *xptr++;
		  *pptr++ = *xptr++;
		  if (NDIM==3) *pptr++ = *xptr++;
		  pptr += NDIM;
		}
		get_data_coerced(instr, VelTag, RealType, ptmp, nbody, NDIM, 0);
		for (i=0, pptr=phaseptr+NDIM, xptr=ptmp; i<nbody; i++) {
		  *pptr++ = *xptr++;
		  *pptr++ = *xptr++;
		  if (NDIM==3) *pptr++ = *xptr++;
		  pptr += NDIM;
		}
		free(ptmp);
		success = TRUE;
	    }
	    if (get_tag_ok(instr, PotentialTag)) {
		if (phiptr == NULL)
		    phiptr = (real *) allocate(sizeof(real) * nbody);
		get_data_coerced(instr, PotentialTag, RealType, phiptr,
				 nbody, 0);
	    }
	    if (get_tag_ok(instr, AccelerationTag)) {
		if (accptr == NULL)
		    accptr = (real *) allocate(sizeof(real) * NDIM * nbody);
		get_data_coerced(instr, AccelerationTag, RealType, accptr,
				 nbody, NDIM, 0);
	    }
	    if (get_tag_ok(instr, AuxTag)) {
		if (auxptr == NULL)
		    auxptr = (real *) allocate(sizeof(real) * nbody);
		get_data_coerced(instr, AuxTag, RealType, auxptr,
				 nbody, 0);
	    }
	    get_tes(instr, ParticlesTag);
	    xpnt = (float *) allocate(sizeof(float)*nbody);
	    ypnt = (float *) allocate(sizeof(float)*nbody);
	    zpnt = (float *) allocate(sizeof(float)*nbody);
	}
	get_tes(instr, SnapShotTag);
    }
    return TRUE;
}