static bool_t rstat_reply(caddr_t replyp, struct sockaddr_in *raddrp) { struct tm *tmp_time; struct tm host_time; struct tm host_uptime; char days_buf[16]; char hours_buf[16]; struct hostent *hp; char *host; statstime *host_stat = (statstime *)replyp; time_t tmp_time_t; if (search_host(raddrp->sin_addr)) return(0); hp = gethostbyaddr(&raddrp->sin_addr.s_addr, sizeof(struct in_addr), AF_INET); if (hp) host = hp->h_name; else host = inet_ntoa(raddrp->sin_addr); /* truncate hostname to fit nicely into field */ if (strlen(host) > HOST_WIDTH) host[HOST_WIDTH] = '\0'; printf("%-*s\t", HOST_WIDTH, host); if (sizeof(time_t) == sizeof(host_stat->curtime.tv_sec)) { tmp_time = localtime((time_t *)&host_stat->curtime.tv_sec); host_time = *tmp_time; host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; tmp_time = gmtime((time_t *)&host_stat->curtime.tv_sec); host_uptime = *tmp_time; } else { /* non-32-bit time_t */ tmp_time_t = host_stat->curtime.tv_sec; tmp_time = localtime(&tmp_time_t); host_time = *tmp_time; host_stat->curtime.tv_sec -= host_stat->boottime.tv_sec; tmp_time_t = host_stat->curtime.tv_sec; tmp_time = gmtime(&tmp_time_t); host_uptime = *tmp_time; } #define updays (host_stat->curtime.tv_sec / 86400) if (host_uptime.tm_yday != 0) snprintf(days_buf, sizeof days_buf, "%3d day%s, ", updays, (updays > 1) ? "s" : ""); else days_buf[0] = '\0'; if (host_uptime.tm_hour != 0) snprintf(hours_buf, sizeof hours_buf, "%2d:%02d, ", host_uptime.tm_hour, host_uptime.tm_min); else if (host_uptime.tm_min != 0) snprintf(hours_buf, sizeof hours_buf, "%2d mins, ", host_uptime.tm_min); else if (host_stat->curtime.tv_sec < 60) snprintf(hours_buf, sizeof hours_buf, "%2d secs, ", host_uptime.tm_sec); else hours_buf[0] = '\0'; printf(" %2d:%02d%cm up %9.9s%9.9s load average: %.2f %.2f %.2f\n", (host_time.tm_hour % 12) ? host_time.tm_hour % 12 : 12, host_time.tm_min, (host_time.tm_hour >= 12) ? 'p' : 'a', days_buf, hours_buf, (double)host_stat->avenrun[0]/FSCALE, (double)host_stat->avenrun[1]/FSCALE, (double)host_stat->avenrun[2]/FSCALE); remember_host(raddrp->sin_addr); return(0); }
static int rusers_reply(caddr_t replyp, struct sockaddr_in *raddrp) { u_int x; int idle; char date[32], idle_time[64], remote[64]; struct hostent *hp; utmpidlearr *up, u; char *host; int days, hours, minutes, seconds; up = &u; memcpy(up, replyp, sizeof(*up)); if (search_host(raddrp->sin_addr)) return (0); if (!allopt && up->utmpidlearr_len == 0) return (0); hp = gethostbyaddr(&raddrp->sin_addr.s_addr, sizeof(struct in_addr), AF_INET); if (hp != NULL) host = hp->h_name; else host = inet_ntoa(raddrp->sin_addr); if (!longopt) printf("%-*s ", HOST_WIDTH, host); for (x = 0; x < up->utmpidlearr_len; x++) { strncpy(date, &(ctime((time_t *)&(up->utmpidlearr_val[x].ui_utmp.ut_time))[4]), sizeof(date) - 1); idle = up->utmpidlearr_val[x].ui_idle; sprintf(idle_time, " :%02d", idle); if (idle == MAX_INT) strcpy(idle_time, "??"); else if (idle == 0) strcpy(idle_time, ""); else { seconds = idle; days = seconds / (60 * 60 * 24); seconds %= (60 * 60 * 24); hours = seconds / (60 * 60); seconds %= (60 * 60); minutes = seconds / 60; seconds %= 60; if (idle > 60) sprintf(idle_time, "%d:%02d", minutes, seconds); if (idle >= (60 * 60)) sprintf(idle_time, "%d:%02d:%02d", hours, minutes, seconds); if (idle >= (24 * 60 * 60)) sprintf(idle_time, "%d days, %d:%02d:%02d", days, hours, minutes, seconds); } strncpy(remote, up->utmpidlearr_val[x].ui_utmp.ut_host, sizeof(remote) - 1); if (strlen(remote) != 0) sprintf(remote, "(%.16s)", up->utmpidlearr_val[x].ui_utmp.ut_host); if (longopt) printf("%-8.8s %*s:%-*.*s %-12.12s %6s %.18s\n", up->utmpidlearr_val[x].ui_utmp.ut_name, HOST_WIDTH, host, LINE_WIDTH, LINE_WIDTH, up->utmpidlearr_val[x].ui_utmp.ut_line, date, idle_time, remote ); else printf("%s ", up->utmpidlearr_val[x].ui_utmp.ut_name); } if (!longopt) putchar('\n'); remember_host(raddrp->sin_addr); return (0); }
void initialize_new(void) { // Initializing the 0th Tracer launch ...... N_Launches = 0 ; int i,j,k; //Point temp; // initializing Launch time for different tracer launch times..... for (i = 0; i < Trace_NumLaunchTimes; i++) { Launch_time[i] = Output_TStart + (double)(i * Trace_LaunchTimeSpacing); } // initializing different output times for output files ....... for (i = 0; i < Output_TRes; i++) { Output_time[i] = Output_TStart + (double)(i* Output_TDelta); } // Check How many data files will be used for integration only valid if data is periodic if (Data_TPeriodic) { // Get the stop time of last Data file double stop_data = Data_TMin + (double)((Data_TRes - 1)* Data_TDelta); if (Output_time[Output_TRes - 1] > stop_data) { frames_data = (Output_time[Output_TRes - 1]/Data_TDelta == 0) ? (floor(Output_time[Output_TRes - 1]/Data_TDelta)) : (floor(Output_time[Output_TRes - 1]/Data_TDelta) + 1); } else frames_data = Data_TRes - 1; } printf("frames_data = %d \n\n", frames_data); // initializing start time and stop time for different data set ....... //for (i = 0; i < (Data_TRes - 1); i++) { for (i = 0; i < frames_data; i++) { DataTime1[i].Start_time = Data_TMin + (double)(i* Data_TDelta); DataTime1[i].Stop_time = DataTime1[i].Start_time + Data_TDelta; //printf("start time for data = %f and end time for data = %f \n",Data_Time1[i].Start_time, Data_Time1[i].Stop_time); } //if (Output_time[Output_TRes - 1] > DataTime1[Data_TRes - 2].Stop_time) { //} if ( Trace_ReleaseStrategy == 0 ) { if (Generate_Frame) { // Calculating initial tracer positions. Also storing these positions into our temp buffer so that we can use for the later launches of the tracer grids. // These loops will initialize only the positions...... for(i = 0; i < Trace_CartMesh.XRes; i++) { for(j = 0; j < Trace_CartMesh.YRes; j++) { for(k = 0; k < Trace_CartMesh.ZRes; k++) { Tracer.x[getindexwosshost(i, j, k)] = Trace_CartMesh.XMin + (i * Trace_CartMesh.XDelta); Tracer.y[getindexwosshost(i, j, k)] = Trace_CartMesh.YMin + (j * Trace_CartMesh.YDelta); Tracer.z[getindexwosshost(i, j, k)] = Trace_CartMesh.ZMin + (k * Trace_CartMesh.ZDelta); //printf("num = %d \t",getindexwosshost(i, j, k) ); //printf("x = %0.9f y = %0.9f and z = %0.9f \n",Tracer.x[getindexwosshost(i, j, k)], Tracer.y[getindexwosshost(i, j, k)], Tracer.z[getindexwosshost(i, j, k)] ); // This value is set to 1 by default. It will be changed to 0 in globalsearch if tracer is found inside the domain. Tracer.LeftDomain[getindexwosshost(i, j, k)] = 1; } } } // This loop initializes different other properties (such as start time, end time and element index) of our first tracer launch .... for (i = 0 ; i < N_Frame; i++) { Tracer.Start_time[i] = Output_TStart; if( (Output_TStart + Trace_IntTLength) >= Output_TEnd) { Tracer.Stop_time[i] = Output_TStart + Output_TEnd; } else { Tracer.Stop_time[i] = Output_TStart + Trace_IntTLength; } Tracer.ElementIndex[i] = -1; } // Get element index of the traccer launch if mesh is unstructured if(Data_MeshType == UNSTRUCTURED) { // Searching on Host search_host(); } else { // Cartesian Mesh. double Point[3]; for(i = 0; i < Trace_CartMesh.XRes; i++) { for(j = 0; j < Trace_CartMesh.YRes; j++) { for(k = 0; k < Trace_CartMesh.ZRes; k++) { Point[0] = Tracer.x[getindexwosshost(i, j, k)]; Point[1] = Tracer.y[getindexwosshost(i, j, k)]; Point[2] = Tracer.z[getindexwosshost(i, j, k)]; // Check if tracer is found inside the domain. Tracer.LeftDomain[getindexwosshost(i, j, k)] = TestOutsideDomain_host(Point); //if (Tracer.LeftDomain[getindexwosshost(i, j, k)] == 1) //printf("Hiiiii \n"); //printf("x = %0.9f y = %0.9f \n",Tracer.x[getindexwosshost(i, j, k)], Tracer.y[getindexwosshost(i, j, k)] ); } } } } // Store initial frame into output file which can be loaded for different releases... temp2file(); printf("Release 0 Launched \n\n"); } else { // Read in from temp file itself // release(0); FatalError("This Function of reading in from input file is currently demoted \n\n\n"); } //for ( i = 0; i < N_Frame; i++) // printf("x = %0.9f y = %0.9f \n",Tracer.x[i], Tracer.y[i] ); // We will output the first tracer launch to the output file (This will be always done) Output_Release = 0; copyresult2vtk(0, 1, Output_TStart); copyresult2bin(0, 1, Output_TStart); // Our first tracer frame is launched. N_Launches = N_Launches + 1; } }