Пример #1
0
/**
   The main(). It parses the command line, setup the parms, ask the scheduler
   for signal to proceed, and then starts skysim to do sky coverage.
 */
int main(int argc, const char *argv[]){
    dirstart=mygetcwd();
    char *scmd=argv2str(argc, argv, " ");
    ARG_S* arg=parse_args(argc,argv);
    /*In detach mode send to background and disable drawing*/
    if(arg->detach){
	daemonize();
    }else{
	redirect();
    }
    info2("%s\n", scmd);
    info2("Output folder is '%s'. %d threads\n",arg->dirout, arg->nthread);
    skyc_version();
    /*register signal handler */
    register_signal_handler(skyc_signal_handler);
    /*
      Ask job scheduler for permission to proceed. If no CPUs are available,
      will block until ones are available.  if arg->force==1, will run
      immediately.
    */
    scheduler_start(scmd,arg->nthread,0,!arg->force);
    /*setting up parameters before asking scheduler to check for any errors. */
    dirsetup=stradd("setup",NULL);
    PARMS_S * parms=setup_parms(arg);
    if(parms->skyc.dbg){
	mymkdir("%s",dirsetup);
    }
    if(!arg->force){
	info2("Waiting start signal from the scheduler ...\n");
	/*Failed to wait. fall back to own checking.*/
	int count=0;
	while(scheduler_wait()&& count<60){
	    warning_time("failed to get reply from scheduler. retry\n");
	    sleep(10);
	    count++;
	    scheduler_start(scmd,arg->nthread,0,!arg->force);
	}
	if(count>=60){
	    warning_time("fall back to own checker\n");
	    wait_cpu(arg->nthread);
	}
    }
    info2("Simulation started at %s in %s.\n",myasctime(),myhostname());
    free(scmd);
    free(arg->dirout);
    free(arg);
    THREAD_POOL_INIT(parms->skyc.nthread);
    /*Loads the main software*/
    OMPTASK_SINGLE skysim(parms);
    free_parms(parms);
    free(dirsetup);
    free(dirstart);
    rename_file(0);
    scheduler_finish(0);
    info2("End:\t%.2f MiB\n",get_job_mem()/1024.);
    info2("Simulation finished at %s in %s.\n",myasctime(),myhostname());
    return 0;
}
Пример #2
0
void execLogfile(const char *fn, bool append)
{
	if ((Logfile = fopen(fn, append? "a" : "w")))
	{
		const char *timestr = myasctime();
		Printf("Log started: %s\n", timestr);
	}
	else
	{
		Printf("Could not start log\n");
	}
}
Пример #3
0
void skyc_version(void){
    info2("Skyc Version %s. Compiled on %s %s by %s, %d bit", PACKAGE_VERSION, __DATE__, __TIME__, __VERSION__, (int)sizeof(long)*8);
#ifdef __OPTIMIZE__
    info2(", w/t optimization.\n");
#else
    info2(", w/o optimization\n");
#endif
    info2("Source: %s %s\n", SRCDIR, GIT_VERSION);
    info2("BUILD: %s\n", BUILDDIR);
    info2("Launched at %s in %s with PID %ld.\n",myasctime(),myhostname(), (long)getpid());
#if HAS_LWS
    extern uint16_t PORT;
    info2("The web based job monitor can be accessed at http://localhost:%d\n", 1+PORT);
#endif
}
void print_log(FILE *log_file, 
			char *message, 
			char *program_name, 
			char *file_name, 
			int *line_no, 
			char *function_name)
{
	fprintf(log_file, "%s %s[%d] %s:%d:%s:%s\n", 
						myasctime(), 
						program_name, 
						getpid(),
						file_name, 
						line_no, 
						function_name,
						message);
	fflush(log_file);
}
void FGameConfigFile::WriteCommentHeader (FILE *file) const
{
	fprintf (file, "# This file was generated by " GAMENAME " " DOTVERSIONSTR " on %s\n", myasctime());
}
void print_err(FILE *log_file, char *message, char *program_name)
{
	fprintf(log_file, "%s %s[%d] %s\n", myasctime(), program_name, getpid(), message);
	fflush(log_file);
}
Пример #7
0
Файл: bin.c Проект: bitursa/maos
/**
   Write the time stamp as header into current location in the file.
*/
void write_timestamp(file_t *fp) {
    char header[128];
    snprintf(header,128, "Created by MAOS Version %s on %s in %s\n",
             PACKAGE_VERSION, myasctime(), myhostname());
    write_bin_headerstr(header, fp);
}
Пример #8
0
void FGameConfigFile::WriteCommentHeader (FileWriter *file) const
{
	file->Printf ("# This file was generated by " GAMENAME " %s on %s\n", GetVersionString(), myasctime());
}