int main() { int i,j,k,gn=1; // int g[graph_scale][graph_scale]; char filename2[5]={'.','t','x','t','\0'}; char filename3[15]="frequency.txt"; initial1(); //初始记录频繁度的矩阵 // char filename1[10]; while(gn<=graph_num) { i=48+int(gn/100); j=48+(gn-int(gn/100)*100)/10; k=48+gn-int(gn/100)*100-(j-48)*10; char filename1[15]={i,j,k,'\0'}; strcat(filename1,filename2); //记事本文件名 initial3(); initial2(); //将图的关联矩阵初始化为0 generate1(); //生成图的关联矩阵行标和列标 generate2(); //将边注入关联矩阵中 txt_out1(filename1); //将图放到记事本中 if(g[0][31]>side) { side=g[0][31]; strcpy(sname,filename1); } if(g[31][0]>dot) { dot=g[31][0]; strcpy(dname,filename1); } gn++; } txt_out2(filename3); printf("Max sidesign is %c in %s.\n",side,sname); printf("Max potsign is %c in %s.\n",dot,dname); }
void GCMCoupler:: regrid_gcm_inputs_onroot( std::vector<giss::VectorSparseVector<int,double>> &gcm_ivals, // Root node only: Already-allocated space to put output values. Members as defined by the CouplingContract GCMCoupler::gcm_inputs unsigned int mask) { // This method is meant to be run only on the GCM root. if (!am_i_root()) return; printf("BEGIN GCMCoupler::regrid_gcm_inputs_onroot\n"); // (ONLY ON GCM ROOT) // =============== Regrid to the grid requested by the GCM // (ONLY ON GCM ROOT) // ----------- Create the MultiMatrix used to regrid to atmosphere (I -> A) MultiMatrix ice2atm; for (auto model = models.begin(); model != models.end(); ++model) { // Get matrix for this single ice model. giss::MapSparseVector<int,double> area1_m; int sheetno = model.key(); // IceSheet::index IceSheet *sheet = (*maker_full)[sheetno]; std::unique_ptr<giss::VectorSparseMatrix> M( sheet->iceinterp_to_projatm(area1_m, IceInterp::ICE)); // Add on correction for projection if (maker_full->correct_area1) { sheet->atm_proj_correct(area1_m, ProjCorrect::PROJ_TO_NATIVE); } // Store it away... ice2atm.add_matrix(std::move(M), area1_m); } // (ONLY ON GCM ROOT) // ------------ Regrid each GCM input from ice grid to whatever grid it needs. for (int var_ix=0; var_ix < gcm_inputs.size_nounit(); ++var_ix) { giss::CoupledField const &cf(gcm_inputs.field(var_ix)); if ((cf.flags & mask) != mask) continue; if ((cf.flags & contracts::GRID_BITS) == contracts::ATMOSPHERE) { // --- Assemble all inputs, to multiply by ice_to_hp matrix std::vector<blitz::Array<double, 1>> ival_I; for (auto model = models.begin(); model != models.end(); ++model) { // Assemble vector of the same GCM input variable from each ice model. ival_I.push_back(model->gcm_ivals_I[var_ix]); } ice2atm.multiply(ival_I, gcm_ivals[var_ix], true); gcm_ivals[var_ix].consolidate(); } else if ((cf.flags & contracts::GRID_BITS) == contracts::ELEVATION) { // --- Assemble all inputs, to send to Glint2 QP regridding std::map<int, blitz::Array<double,1>> f4s; for (auto model = models.begin(); model != models.end(); ++model) { int sheetno = model.key(); f4s.insert(std::make_pair(sheetno, model->gcm_ivals_I[var_ix])); } // Use previous return as our initial guess blitz::Array<double,1> initial3(maker_full->n3()); giss::to_blitz(gcm_ivals[var_ix], initial3); gcm_ivals[var_ix] = maker_full->iceinterp_to_hp( f4s, initial3, IceInterp::ICE, QPAlgorithm::SINGLE_QP); gcm_ivals[var_ix].consolidate(); } } // ----------------- Free Memory // (ONLY ON GCM ROOT) for (auto model = models.begin(); model != models.end(); ++model) { model->free_ovals_ivals_I(); } printf("END GCMCoupler::regrid_gcm_inputs_onroot\n"); }