void tl_set_handler(tl_timer * timer, void (*handler) (void *), void *ud) { timer->handler = handler; timer->userdata = ud; if (timer->group == asyncgroup) update_async(); }
void tl_set_interval(tl_timer * timer, int interval) { if (timer->interval <= 0) { tl_reset_timer(timer); } timer->interval = interval; if (timer->group == asyncgroup) update_async(); }
void tl_remove_timer(tl_timer * timer) { tl_group *g = timer->group; timer->previous->next = timer->next; if (timer->next != NULL) timer->next->previous = timer->previous; timer->group = NULL; if (g == asyncgroup) update_async(); }
void tl_set_interval(tl_timer * timer, int interval) { if (timer->interval > 0 && timer->wait > 0) timer->wait += interval - timer->interval; else timer->wait = interval; timer->interval = interval; if (timer->group == asyncgroup) update_async(); }
void tl_add_timer(tl_group * group, tl_timer * timer) { if (timer->group) tl_remove_timer(timer); timer->previous = group; timer->next = group->next; timer->group = group; group->next = timer; if (timer->group == asyncgroup) update_async(); }
static void alarmhandler(int a) { if(!intimer) { #ifdef __DJGPP__ /* asm volatile ("sti");*/ /* outportb(0x20,0x20);*/ #endif intimer=1; update_async(); signal(SIGALRM, alarmhandler); intimer=0; } }
int main (int args, char* argv[]) { double length = LENGTH; //Axial length of vessel to simulate (in micrometers). double diameter= DIAMETER; double pi = 3.1415; //Steady state diameter of the simulated vessel (in micrometers). double hx_smc = HX_SMC; double hy_smc = HY_SMC; double hx_ec = HX_EC; double hy_ec = HY_EC; double new_length = (rint (length/hx_ec) ) * hx_ec; if (( (int)(new_length) % (int) (hx_smc) )!=0) hx_smc = new_length / (rint (new_length/hx_smc)) ; double new_circ= (rint (diameter * pi /hy_smc) ) * hy_smc; if (( (int)(new_circ) % (int) (hy_ec) )!=0) hy_ec = new_circ / (rint (new_circ/hy_ec)) ; grid.neq_smc = 26; grid.neq_ec = 4; grid.nodes_smc = (int) (length/hx_smc); grid.layers_smc = (int) (new_circ/hy_smc); grid.nodes_ec = (int) (length/hx_ec); grid.layers_ec = (int) (new_circ/hy_ec); grid.m = grid.nodes_smc*grid.layers_smc; grid.n = grid.nodes_ec *grid.layers_ec ; MPI_Init(&args, &argv); int tasks, myRank; MPI_Status status1,stat1,stat2,stat3,stat4; MPI_Request req1,req2,req3,req4; MPI_Comm_size(MPI_COMM_WORLD,&tasks); MPI_Comm_rank(MPI_COMM_WORLD,&myRank); FILE *errPT; char filename[10];int n; int kB=1024, MB= 1024*1024; sprintf(filename,"err.%d.txt",myRank); errPT = fopen(filename,"w+"); int n_smc,n_ec; if (myRank ==0) { printf("LENGTH = %2.5f\t\tDIAMETER(requested)= %2.5f\t\tDIAMETER(corrected)= %2.5f\t\tCIRCUMFERENCE = %2.5f\n\n",length,diameter,(new_circ/pi),new_circ); printf("SMC GRID INFO:\nNodes = %d\nLayers = %d\nHX = %f,HY = %f\nTotal cells = %d\n",grid.nodes_smc,grid.layers_smc,hx_smc,hy_smc,grid.m); printf("EC GRID INFO:\nNodes = %d\nLayers = %d\nHX = %f,HY = %f\nTotal cells = %d\n",grid.nodes_ec,grid.layers_ec,hx_ec,hy_ec,grid.n); //EC bit int r = grid.nodes_ec%tasks; if (r ==0) { n_ec = grid.nodes_ec/tasks; grid.n_ec= n_ec; for (int i=1;i<tasks;i++) MPI_Send(&n_ec,1,MPI_INT,i,000,MPI_COMM_WORLD); } else{ n_ec = (grid.nodes_ec - r )/tasks; grid.n_ec= n_ec; for (int i=1;i<tasks-1;i++) MPI_Send(&n_ec,1,MPI_INT,i,000,MPI_COMM_WORLD); n_ec=n_ec+r; MPI_Send(&n_ec,1,MPI_INT,(tasks-1),000,MPI_COMM_WORLD); } } else MPI_Recv(&grid.n_ec,1,MPI_INT,MASTER,000,MPI_COMM_WORLD,&status1); grid.n_smc = 13*grid.n_ec; //Each should perform this bit locally celltype1* smc_base; celltype2* ec_base; smc_base = (celltype1*) malloc((grid.layers_smc *grid.n_smc) * sizeof(celltype1)); if(smc_base==NULL){ fprintf(errPT,"Allocation failed for smc_base\n"); MPI_Abort(MPI_COMM_WORLD,100); } ec_base = (celltype2*) malloc((grid.layers_ec *grid.n_ec) * sizeof(celltype2)); if(ec_base==NULL){ fprintf(errPT,"Allocation failed for ec_base\n"); MPI_Abort(MPI_COMM_WORLD,100); } smc = (celltype1**) malloc(grid.layers_smc * sizeof(celltype1*)); if(smc==NULL){ fprintf(errPT,"Allocation failed for smc row dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } for (int i=0; i<grid.layers_smc; i++){ smc[i]= (celltype1*) malloc(grid.n_smc * sizeof(celltype1)); if(smc[i]==NULL){ fprintf(errPT,"Allocation failed for smc row # %d dimension\n",i); MPI_Abort(MPI_COMM_WORLD,100); } smc[i]= smc_base+(i*grid.n_smc); } ec = (celltype2**) malloc(grid.layers_ec * sizeof(celltype2*)); if(smc==NULL){ fprintf(errPT,"Allocation failed for smc row dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } for (int i=0; i<grid.layers_ec; i++){ ec[i]= (celltype2*) malloc(grid.n_ec * sizeof(celltype2)); if(ec[i]==NULL){ fprintf(errPT,"Allocation failed for ec row # %d dimension\n",i); MPI_Abort(MPI_COMM_WORLD,100); } ec[i]= ec_base+(i*grid.n_ec); } nn.sbuf_left = (double*)malloc( 3*(grid.layers_smc+grid.layers_ec) * sizeof(double)); if(nn.sbuf_left==NULL){ fprintf(errPT,"Allocation failed for nn.sbuf_left dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.sbuf_right = (double*)malloc( 3*(grid.layers_smc+grid.layers_ec) * sizeof(double)); if(nn.sbuf_right==NULL){ fprintf(errPT,"Allocation failed for nn.sbuf_right dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.rbuf_left = (double*)malloc( 3*(grid.layers_smc+grid.layers_ec) * sizeof(double)); if(nn.rbuf_left==NULL){ fprintf(errPT,"Allocation failed for nn.rbuf_left dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.rbuf_right = (double*)malloc( 3*(grid.layers_smc+grid.layers_ec) * sizeof(double)); if(nn.rbuf_right==NULL){ fprintf(errPT,"Allocation failed for nn.rbuf_right dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_smc_c = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.left_smc_c==NULL){ fprintf(errPT,"Allocation failed for nn.left_smc_c dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_smc_c = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.right_smc_c==NULL){ fprintf(errPT,"Allocation failed for nn.right_smc_c dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_ec_c = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.left_ec_c==NULL){ fprintf(errPT,"Allocation failed for nn.left_ec_c dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_ec_c = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.right_ec_c==NULL){ fprintf(errPT,"Allocation failed for nn.right_ec_c dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_smc_v = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.left_smc_v==NULL){ fprintf(errPT,"Allocation failed for nn.left_smc_v dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_smc_v = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.right_smc_v==NULL){ fprintf(errPT,"Allocation failed for nn.right_smc_v dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_ec_v = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.left_ec_v==NULL){ fprintf(errPT,"Allocation failed for nn.left_ec_v dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_ec_v = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.right_ec_v==NULL){ fprintf(errPT,"Allocation failed for nn.right_ec_v dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_smc_I = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.left_smc_I==NULL){ fprintf(errPT,"Allocation failed for nn.left_smc_I dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_smc_I = (double*)malloc( grid.layers_smc * sizeof(double)); if(nn.right_smc_I==NULL){ fprintf(errPT,"Allocation failed for nn.right_smc_I dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.left_ec_I = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.left_ec_I==NULL){ fprintf(errPT,"Allocation failed for nn.left_ec_I dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } nn.right_ec_I = (double*)malloc( grid.layers_ec * sizeof(double)); if(nn.right_ec_I==NULL){ fprintf(errPT,"Allocation failed for nn.right_ec_I dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } //Lodaing the information of rows and cols of each cell and allocating memory for various flux equations for(int i=0; i<grid.layers_smc; i++) { for (int j=0;j<grid.n_smc;j++) { smc[i][j].row = i; smc[i][j].col = j; /* smc[i][j].A = (double*) malloc(12*sizeof(double)); if(smc[i][j].A==NULL){ fprintf(errPT,"Allocation failed for smc[i][j].A dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } smc[i][j].B = (double*) malloc(3*sizeof(double)); if(smc[i][j].B==NULL){ fprintf(errPT,"Allocation failed for smc[i][j].B dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } smc[i][j].C = (double*) malloc(3*sizeof(double)); if(smc[i][j].C==NULL){ fprintf(errPT,"Allocation failed for smc[i][j].C dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); }*/ } } for(int i=0; i<grid.layers_ec; i++) { for (int j=0;j<grid.n_ec;j++) { ec[i][j].row = i; ec[i][j].col = j; /* ec[i][j].A = (double*) malloc(12*sizeof(double)); if(ec[i][j].A==NULL){ fprintf(errPT,"Allocation failed for ec[i][j].A dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } ec[i][j].B = (double*) malloc(3*sizeof(double)); if(ec[i][j].B==NULL){ fprintf(errPT,"Allocation failed for ec[i][j].B dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); } ec[i][j].C = (double*) malloc(3*sizeof(double)); if(ec[i][j].C==NULL){ fprintf(errPT,"Allocation failed for ec[i][j].C dimension\n"); MPI_Abort(MPI_COMM_WORLD,100); }*/ } } int total = (grid.neq_smc * grid.n_smc * grid.layers_smc) + (grid.neq_ec * grid.n_ec * grid.layers_ec); //Initialize and use the solver here RKSUITE rksuite; //Time variables double tfinal = TFINAL; double tnow = 0.0; double interval= INTERVAL; //File written every 1 second int file_write_per_unit_time=(int)(1/interval); //Error control variables double TOL = 1e-7; double thres[total]; for (int i= 0; i<total; i++) thres[i] = 1e-7; //Variables holding new and old values double* y = (double*) malloc (total * sizeof(double)); /***** INITIALIZATION SECTION ******/ int offset = 0; Initialize_tsoukias_smc(offset,y); offset = grid.n_smc*grid.layers_smc * grid.neq_smc; Initialize_koeingsberger_ec(offset, y); int i,j,k; for(i=0;i< grid.layers_smc; i++) { for (j=0;j<grid.n_smc;j++) { if (i>0) k=(i*grid.n_smc*grid.neq_smc); else if (i==0) k=0; smc[i][j].p = &y[k+(j*grid.neq_smc)+0]; } } offset = grid.n_smc*grid.layers_smc * grid.neq_smc; for(i=0;i< grid.layers_ec; i++) { for (j=0;j<grid.n_ec;j++) { if (i>0) k= offset+i*grid.n_ec*grid.neq_ec ; else if (i==0) k=offset+0; ec[i][j].q = &y[k+(j*grid.neq_ec)+0]; } } for(i=0;i< grid.layers_smc; i++) { for (j=0;j<grid.n_smc;j++) { smc[i][j].NE = 0.0; smc[i][j].NO = 0.0; smc[i][j].I_stim= 0.0; } } /***************************************************************/ double* yp= (double*) malloc (total * sizeof(double)); //Solver method int method = 2; //RK(4,5) //Statistics int totf,stpcst,acptstp; double waste,hnext; //Error Flag int cflag = 0, uflag =0; //Error extent monitor, to select best constant step of tolerances double* ymax = (double*) malloc(total * sizeof(double)); int state = couplingParms(CASE); if (myRank==0) printf("\n Step Size=%2.10lf\nUnit time in file write=%lf\n",interval,(double)file_write_per_unit_time*interval ); //Output file management FILE *time,*Task_info, *ci,*cj, *si,*sj, *vi,*vj, *Ii,*Ij, *cpv_i,*cpc_i,*cpi_i, *cpv_j,*cpc_j,*cpi_j; n=sprintf(filename,"t%d.txt",myRank); time = fopen(filename,"w+"); n=sprintf(filename,"Task_info%d.txt",myRank); Task_info= fopen(filename,"w+"); n=sprintf(filename,"smc_c%d.txt",myRank); ci = fopen(filename,"w+"); n=sprintf(filename,"ec_c%d.txt",myRank); cj = fopen(filename,"w+"); n=sprintf(filename,"ec_s%d.txt",myRank); sj = fopen(filename,"w+"); n=sprintf(filename,"smc_v%d.txt",myRank); vi = fopen(filename,"w+"); n=sprintf(filename,"ec_v%d.txt",myRank); vj = fopen(filename,"w+"); n=sprintf(filename,"smc_I%d.txt",myRank); Ii = fopen(filename,"w+"); n=sprintf(filename,"ec_I%d.txt",myRank); Ij = fopen(filename,"w+"); n=sprintf(filename,"cpv_i%d.txt",myRank); cpv_i = fopen(filename,"w+"); n=sprintf(filename,"cpc_i%d.txt",myRank); cpc_i = fopen(filename,"w+"); n=sprintf(filename,"cpi_i%d.txt",myRank); cpi_i = fopen(filename,"w+"); n=sprintf(filename,"cpc_j%d.txt",myRank); cpc_j = fopen(filename,"w+"); n=sprintf(filename,"cpv_j%d.txt",myRank); cpv_j = fopen(filename,"w+"); n=sprintf(filename,"cpi_j%d.txt",myRank); cpi_j = fopen(filename,"w+"); int count = 3*(grid.layers_smc+grid.layers_ec), buf_offset = 3*grid.layers_smc; int iteration=0; double Per_MPI_time_t1,Per_MPI_time_t2, Per_step_compute_time_t1,Per_step_compute_time_t2; double t1 = MPI_Wtime(); /********************************************************************/ for(int i=0; i<grid.layers_smc;i++) update_send_buffers_smc(myRank,tasks,i); for(int i=0; i<grid.layers_ec;i++) update_send_buffers_ec(myRank,tasks,i); my_boundary(myRank); update_async(myRank,tasks); retrive_recv_buffers_smc(myRank,tasks); retrive_recv_buffers_ec(myRank,tasks); /************************************************************************/ /*********************SOLVER SECTION*************************/ /************************************************************************/ tend = interval; rksuite.setup(total, tnow, y, tend, TOL, thres, method, "CT", false, 1e-5, false ); while (tnow <=10.00) { // the ct() function does not guarantee to advance all the // way to the stop time. Keep stepping until it does. do { computeDerivatives( tnow, y, yp ); rksuite.ct(computeDerivatives, tnow, y, yp, cflag ); if (cflag >= 5) { printf("RKSUITE error %d\n", cflag ); MPI_Abort(MPI_COMM_WORLD,1000); return false; break; } } while (tnow < tend); iteration++; /************************************************/ /* Communication Block */ /************************************************/ update_async(myRank,tasks); MPI_Barrier(MPI_COMM_WORLD); if (iteration==5){ fprintf(Task_info,"COUPLING COEFFICIENTS\n\n"); fprintf(Task_info,"g_hm_smc=\t%6.2lf\ng_hm_ec=\t%6.2lf\np_hm_smc=\t%6.2lf\np_hm_ec=\t%6.2lf\npIP_hm_smc=\t%6.2lf\npIP_hm_ec=\t%6.2lf\ng_ht_smc=\t%6.2lf\tg_ht_ec=\t%6.2lf\np_ht_smc=\t%6.2lf\tp_ht_ec=\t%6.2lf\npIP_ht_smc=\t%6.2lf\tpIP_ht_ec=\t%6.2lf\n", cpl_cef.g_hm_smc,cpl_cef.g_hm_ec,cpl_cef.p_hm_smc,cpl_cef.p_hm_ec,cpl_cef.pIP_hm_smc,cpl_cef.pIP_hm_ec,cpl_cef.g_ht_smc,cpl_cef.g_ht_ec,cpl_cef.p_ht_smc,cpl_cef.p_ht_ec, cpl_cef.pIP_ht_smc,cpl_cef.pIP_ht_ec); fprintf(Task_info,"\nSpatial Gradient info:\nMinimum JPLC\t=\t=%lf\nMaximum JPLC\t=\t=%lf\nGradient\t=\t=%lf\n" ,grid.min_jplc,grid.max_jplc,grid.gradient); fprintf(Task_info,"\nTotal Tasks=%d\tMyRank=%d\n\n",tasks,myRank); fprintf(Task_info,"LENGTH = %2.5f\nREQUESTED DIAMETER = %2.5f\nCORRECTED CIRCUMFERENCE = %2.5f\nTotal layers=%d\nTotal nodes=%d\n\n",length,diameter,new_circ,grid.layers_smc,grid.nodes_smc); fprintf(Task_info,"SMC GRID INFO:\nNodes = %d\nLayers = %d\nHX = %lf,HY = %lf\nTotal cells = %d\n\n",grid.n_smc,grid.layers_smc,hx_smc,hy_smc,grid.m); fprintf(Task_info,"EC GRID INFO:\nNodes = %d\nLayers = %d\nHX = %lf,HY = %lf\nTotal cells = %d\n\n",grid.n_ec,grid.layers_ec,hx_ec,hy_ec,grid.n); fprintf(Task_info,"JPLC (at t<100 seconds) in axial direction per EC\n"); for (int p=0; p<grid.n_ec; p++) fprintf(Task_info,"[%d]\t%lf\n",p,ec[0][p].JPLC); } if ((iteration==1)||(iteration % file_write_per_unit_time==0)) { fprintf(time,"%lf\n",tnow); for (int row=0; row<grid.layers_smc;row++) { for (int col=0; col<grid.n_smc; col++) { fprintf(ci,"%2.10lf",smc[row][col].p[smc_Ca_i]); fprintf(vi,"%2.10lf",smc[row][col].p[smc_V_m]); fprintf(Ii,"%2.10lf",smc[row][col].p[smc_IP3]); if (col<(grid.n_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } } if (row<(grid.layers_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } else if (row==(grid.layers_smc-1)){ fprintf(ci,"\n"); fprintf(vi,"\n"); fprintf(Ii,"\n"); } } for (int row=0; row<grid.layers_ec;row++) { for (int col=0; col<grid.n_ec; col++) { fprintf(cj,"%2.10lf\t",ec[row][col].q[ec_Ca]); fprintf(sj,"%2.10lf\t",ec[row][col].q[ec_SR]); fprintf(vj,"%2.10lf\t",ec[row][col].q[ec_Vm]); fprintf(Ij,"%2.10lf\t",ec[row][col].q[ec_IP3]); } if (row<(grid.layers_ec-1)){ fprintf(cj,"\t"); fprintf(sj,"\t"); fprintf(vj,"\t"); fprintf(Ij,"\t"); } else if (row==(grid.layers_ec-1)){ fprintf(cj,"\n"); fprintf(sj,"\n"); fprintf(vj,"\n"); fprintf(Ij,"\n"); } } fflush(time);fflush(Task_info);fflush(errPT); //fflush(MPI_stat); fflush(ci);fflush(cj); fflush(sj); fflush(vi);fflush(vj); fflush(Ii);fflush(Ij); fflush(cpv_i); fflush(cpc_i);fflush(cpi_i); fflush(cpv_j);fflush(cpc_j); fflush(cpi_j); } tend += interval; rksuite.reset(tend); } //end while() /****////////*******////////**************** /************************************************************************/ /*********************AFTER 10.00 seconds*************************/ /************************************************************************/ tend = tnow + interval; rksuite.setup(total, tnow, y, tend, TOL, thres, method, "CT", false, 1e-5, false ); while (tnow <=100.00) { // the ct() function does not guarantee to advance all the // way to the stop time. Keep stepping until it does. do { computeDerivatives( tnow, y, yp ); rksuite.ct(computeDerivatives, tnow, y, yp, cflag ); if (cflag >= 5) { printf("RKSUITE error %d\n", cflag ); MPI_Abort(MPI_COMM_WORLD,1000); return false; break; } } while (tnow < tend); iteration++; /************************************************/ /* Communication Block */ /************************************************/ update_async(myRank,tasks); MPI_Barrier(MPI_COMM_WORLD); if (iteration==5e3){ fprintf(Task_info,"JPLC (at 10<t<100 seconds) in axial direction per EC\n"); for (int p=0; p<grid.n_ec; p++) fprintf(Task_info,"[%d]\t%lf\n",p,ec[0][p].JPLC); } if (iteration % file_write_per_unit_time==0) { fprintf(time,"%lf\n",tnow); for (int row=0; row<grid.layers_smc;row++) { for (int col=0; col<grid.n_smc; col++) { fprintf(ci,"%2.10lf",smc[row][col].p[smc_Ca_i]); fprintf(vi,"%2.10lf",smc[row][col].p[smc_V_m]); fprintf(Ii,"%2.10lf",smc[row][col].p[smc_IP3]); if (col<(grid.n_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } } if (row<(grid.layers_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } else if (row==(grid.layers_smc-1)){ fprintf(ci,"\n"); fprintf(vi,"\n"); fprintf(Ii,"\n"); } } for (int row=0; row<grid.layers_ec;row++) { for (int col=0; col<grid.n_ec; col++) { fprintf(cj,"%2.10lf\t",ec[row][col].q[ec_Ca]); fprintf(sj,"%2.10lf\t",ec[row][col].q[ec_SR]); fprintf(vj,"%2.10lf\t",ec[row][col].q[ec_Vm]); fprintf(Ij,"%2.10lf\t",ec[row][col].q[ec_IP3]); } if (row<(grid.layers_ec-1)){ fprintf(cj,"\t"); fprintf(sj,"\t"); fprintf(vj,"\t"); fprintf(Ij,"\t"); } else if (row==(grid.layers_ec-1)){ fprintf(cj,"\n"); fprintf(sj,"\n"); fprintf(vj,"\n"); fprintf(Ij,"\n"); } } fflush(time);fflush(Task_info);fflush(errPT); //fflush(MPI_stat); fflush(ci);fflush(cj); fflush(sj); fflush(vi);fflush(vj); fflush(Ii);fflush(Ij); fflush(cpv_i); fflush(cpc_i);fflush(cpi_i); fflush(cpv_j);fflush(cpc_j); fflush(cpi_j); } tend += interval; rksuite.reset(tend); } //end while() /****////////*******////////**************** /************************************************************************/ /*** After 100 seconds ****/ /************************************************************************/ tend = tnow+interval; rksuite.setup(total, tnow, y, tend, TOL, thres, method, "CT", false, 1e-6, false ); while (tnow <=tfinal) { // the ct() function does not guarantee to advance all the // way to the stop time. Keep stepping until it does. do { computeDerivatives( tnow, y, yp ); rksuite.ct(computeDerivatives, tnow, y, yp, cflag ); if (cflag >= 5) { printf("RKSUITE error %d\n", cflag ); MPI_Abort(MPI_COMM_WORLD,1000); return false; break; } } while (tnow < tend); iteration++; /************************************************/ /* Communication Block */ /************************************************/ update_async(myRank,tasks); MPI_Barrier(MPI_COMM_WORLD); if (iteration==1e5) { fprintf(Task_info,"JPLC (at t>100 seconds) in axial direction per EC\n"); for (int p=0; p<grid.n_ec; p++) fprintf(Task_info,"[%d]\t%lf\n",p,ec[0][p].JPLC); } if (iteration % file_write_per_unit_time==0) { fprintf(time,"%lf\n",tnow); for (int row=0; row<grid.layers_smc;row++) { for (int col=0; col<grid.n_smc; col++) { fprintf(ci,"%2.10lf",smc[row][col].p[smc_Ca_i]); fprintf(vi,"%2.10lf",smc[row][col].p[smc_V_m]); fprintf(Ii,"%2.10lf",smc[row][col].p[smc_IP3]); if (col<(grid.n_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } } if (row<(grid.layers_smc-1)){ fprintf(ci,"\t"); fprintf(vi,"\t"); fprintf(Ii,"\t"); } else if (row==(grid.layers_smc-1)){ fprintf(ci,"\n"); fprintf(vi,"\n"); fprintf(Ii,"\n"); } } for (int row=0; row<grid.layers_ec;row++) { for (int col=0; col<grid.n_ec; col++) { fprintf(cj,"%2.10lf\t",ec[row][col].q[ec_Ca]); fprintf(sj,"%2.10lf\t",ec[row][col].q[ec_SR]); fprintf(vj,"%2.10lf\t",ec[row][col].q[ec_Vm]); fprintf(Ij,"%2.10lf\t",ec[row][col].q[ec_IP3]); } if (row<(grid.layers_ec-1)){ fprintf(cj,"\t"); fprintf(sj,"\t"); fprintf(vj,"\t"); fprintf(Ij,"\t"); } else if (row==(grid.layers_ec-1)){ fprintf(cj,"\n"); fprintf(sj,"\n"); fprintf(vj,"\n"); fprintf(Ij,"\n"); } } fflush(time);fflush(Task_info);fflush(errPT); //fflush(MPI_stat); fflush(ci);fflush(cj); fflush(sj); fflush(vi);fflush(vj); fflush(Ii);fflush(Ij); fflush(cpv_i); fflush(cpc_i);fflush(cpi_i); fflush(cpv_j);fflush(cpc_j); fflush(cpi_j); } tend += interval; rksuite.reset(tend); } //end while() /****////////*******////////**************** /************************************************************************/ double t2 = MPI_Wtime(); //printf("[%d] : Elapsed time = %lf\nMPI size=%d\ttfinal=%lf\tStep size=%lf\tcount=%d\n",myRank,(t2-t1),tasks,tfinal,interval,cnt2); fprintf(Task_info,"Elapsed time = %lf\ntfinal=%lf\nStep size=%lf\n",(t2-t1),tasks,tfinal,interval); MPI_Barrier(MPI_COMM_WORLD); if (myRank==0) printf("\nEND OF PROGRAM\n"); free(smc);free(smc_base); free(ec);free(ec_base); free(nn.sbuf_left); free(nn.sbuf_right); free(nn.rbuf_left); free(nn.rbuf_right); free(nn.left_smc_c); free(nn.right_smc_c); free(nn.left_ec_c); free(nn.right_ec_c); free(nn.left_smc_v); free(nn.right_smc_v); free(nn.left_ec_v); free(nn.right_ec_v); free(nn.left_smc_I); free(nn.right_smc_I); free(nn.left_ec_I); free(nn.right_ec_I); free(y); free(yp); free(ymax); fclose(time);fclose(Task_info); fclose(errPT); fclose(ci);fclose(cj); fclose(sj); fclose(vi);fclose(vj); fclose(Ii);fclose(Ij); fclose(cpv_i); fclose(cpc_i);fclose(cpi_i); fclose(cpv_j);fclose(cpc_j); fclose(cpi_j); MPI_Finalize(); }
static void alarmhandler(int a) { update_async(); signal(SIGALRM, alarmhandler); }
void tl_set_multihandler(tl_timer * timer, void (*handler) (int)) { timer->multihandler = handler; if (timer->group == asyncgroup) update_async(); }
void tl_set_handler(tl_timer * timer, void (*handler) (void)) { timer->handler = handler; if (timer->group == asyncgroup) update_async(); }