ContiguousArrayManager::ContiguousArrayManager(const sip::SipTables& sip_tables, setup::SetupReader& setup_reader) : sip_tables_(sip_tables), setup_reader_(setup_reader) { //create static arrays in sial program. All static arrays are allocated a startup int num_arrays = sip_tables_.num_arrays(); for (int i = 0; i < num_arrays; ++i) { if (sip_tables_.is_contiguous(i) && sip_tables_.array_rank(i) > 0) { //check whether array has been predefined // FIXME TODO HACK - Check current program number. // The assumption is that only the first program reads predefined arrays from the // initialization data. The following ones dont. if (sip_tables_.is_predefined(i)) { SIP_LOG( std::cout << "Array " << sip_tables_.array_name(i)<< " is predefined..." << std::endl); Block::BlockPtr block = NULL; std::string name = sip_tables_.array_name(i); setup::SetupReader::NamePredefinedContiguousArrayMapIterator b = setup_reader_.name_to_predefined_contiguous_array_map_.find( name); if (b != setup_reader_.name_to_predefined_contiguous_array_map_.end()){ //array is predefined and in setup reader block = b->second.second; insert_contiguous_array(i, block); } else { //is predefined, but not in setreader. Set to zero, insert into setup_reader map so it "owns" it and deletes it. SIP_MASTER(check_and_warn(false, "No data for predefined static array " + name);) block = create_contiguous_array(i); int block_rank = sip_tables_.array_rank(i); std::pair<int, Block::BlockPtr> zeroed_block_pair = std::make_pair(i, block); setup_reader_.name_to_predefined_contiguous_array_map_.insert(make_pair(name, zeroed_block_pair)); } } else { //not predefined, just create it
/** * Delete blocks being managed by the block manager. */ BlockManager::~BlockManager() { check_and_warn(temp_block_list_stack_.size() == 0, "temp_block_list_stack not empty when destroying block manager!"); // Free up all blocks managed by this block manager. for (int i = 0; i < sip_tables_.num_arrays(); ++i) delete_per_array_map_and_blocks(i); }
bool sial_warn(bool condition, std::string m, int line){ return check_and_warn(condition, "POSSIBLY ERRONEOUS SIAL PROGRAM: " + m, line); }
bool input_warn(bool condition, std::string m, int line){ return check_and_warn(condition, "INVALID SETUP OR SIAL PROGRAM: " + m, line); }