void nest::music_cont_in_proxy::calibrate() { // only publish the port once if ( !S_.published_ ) { MUSIC::Setup* s = kernel().music_manager.get_music_setup(); if ( s == 0 ) throw MUSICSimulationHasRun( get_name() ); V_.MP_ = s->publishContInput( P_.port_name_ ); if ( !V_.MP_->isConnected() ) throw MUSICPortUnconnected( get_name(), P_.port_name_ ); if ( !V_.MP_->hasWidth() ) throw MUSICPortHasNoWidth( get_name(), P_.port_name_ ); S_.port_width_ = V_.MP_->width(); B_.data_ = std::vector< double >( S_.port_width_ ); MUSIC::ArrayData data_map( static_cast< void* >( &( B_.data_[ 0 ] ) ), MPI::DOUBLE, 0, S_.port_width_ ); V_.MP_->map( &data_map ); S_.published_ = true; std::string msg = String::compose( "Mapping MUSIC input port '%1' with width=%2.", P_.port_name_, S_.port_width_ ); LOG( M_INFO, "music_cont_in_proxy::calibrate()", msg.c_str() ); } }
void ConnectAdapter::initMUSIC(int argc, char** argv) { MUSIC::Setup* setup = new MUSIC::Setup (argc, argv); setup->config("stoptime", &stoptime); setup->config("music_timestep", ×tep); setup->config("weights_filename", &weights_filename); port_in = setup->publishContInput("in"); port_out = setup->publishContOutput("out"); comm = setup->communicator (); int rank = comm.Get_rank (); int nProcesses = comm.Get_size (); if (nProcesses > 1) { std::cout << "ERROR: num processes (np) not equal 1" << std::endl; comm.Abort(1); } // get dimensions of data if (port_in->hasWidth() && port_out->hasWidth()) { size_data_in = port_in->width(); size_data_out = port_out->width(); } else { std::cout << "ERROR: Port-width not defined" << std::endl; comm.Abort(1); } data_in = new double[size_data_in]; for (int i = 0; i < size_data_in; ++i) { data_in[i] = 0.; } vec_data_in = gsl_vector_view_array(data_in, size_data_in); data_out = new double[size_data_out]; for (int i = 0; i < size_data_out; ++i) { data_out[i] = 0.; } vec_data_out = gsl_vector_view_array(data_out, size_data_out); weights = new double[size_data_out * size_data_in]; for (int i = 0; i < size_data_out * size_data_in; ++i) { weights[i] = 0.; } mat_weights = gsl_matrix_view_array(weights, size_data_out, size_data_in); // Declare where in memory to put command_data MUSIC::ArrayData dmap_in(data_in, MPI::DOUBLE, 0, size_data_in); port_in->map (&dmap_in, 0., 1, false); MUSIC::ArrayData dmap_out(data_out, MPI::DOUBLE, 0, size_data_out); port_out ->map (&dmap_out, 1); MPI::COMM_WORLD.Barrier(); runtime = new MUSIC::Runtime (setup, timestep); }