Exemplo n.º 1
0
Term ProcMkProc(Term t, Term ind)
{
	Atom prt[4];
	Atom mass[4];
	Term color[4];
	int spin[4];
	int i;
	int neufact=1;
	double thcut=0.0;
	int dec=0;
	char pname[128];
	FILE *f;
	
	if(CompoundArity(t)==1)
	{
		List l,dlist;
		double m1;
		set_ppl();
		
		l=GetAtomProperty(CompoundArg1(t),PROP_TYPE);
		if(!is_compound(l)||CompoundName(l)!=OPR_PARTICLE ||
				CompoundArgN(l,5)==0)
			{
			ErrorInfo(0);
			WriteTerm(t);
			printf(" : decays are not generated.\n");
			return 0;
			}
		m1=fabs(EvalParameter(CompoundArgN(l,5)));
		
		dlist=GetAtomProperty(CompoundArg1(t),PROP_PPL);
		for(l=dlist;l;l=ListTail(l))
		{
			List pl=ListFirst(l);
			Atom prp,a;
			Atom ap1, ap2;
			double m2,m3;
			int is_neut;
			
			if(ListLength(pl)!=2)
				continue;
			prp=GetAtomProperty(ListFirst(pl),PROP_TYPE);
			if(!is_compound(prp)||CompoundName(prp)!=OPR_PARTICLE)
				continue;
			if(CompoundArgN(prp,7)==OPR_MLT)
				continue;
			a=CompoundArgN(prp,5);
			if(a==0)
				continue;
			else
				m2=fabs(EvalParameter(a));
				
			prp=GetAtomProperty(ListFirst(ListTail(pl)),PROP_TYPE);
			if(!is_compound(prp)||CompoundName(prp)!=OPR_PARTICLE)
				continue;
			if(CompoundArgN(prp,7)==OPR_MLT)
				continue;
			a=CompoundArgN(prp,5);
			if(a==0)
				continue;
			else
				m3=fabs(EvalParameter(a));
				
			if(m1<=m2+m3)
				continue;
			
			is_neut=(CompoundArg1(t)==GetAtomProperty(CompoundArg1(t),A_ANTI));
			
			ap1=GetAtomProperty(ListFirst(pl),A_ANTI);
			ap2=GetAtomProperty(ListFirst(ListTail(pl)),A_ANTI);
			
			if(is_neut)
			{
				List l1;
				for(l1=dlist;l1!=l;l1=ListTail(l1))
				{
				if( (ListFirst(ListFirst(l1))==ap1 && 
							ListFirst(ListTail(ListFirst(l1)))==ap2) ||
					(ListFirst(ListFirst(l1))==ap2 && 
							ListFirst(ListTail(ListFirst(l1)))==ap1))
					break;
				}
				if(l1!=l)
					continue;
			}
			
			/*WriteTerm(CompoundArg1(t));printf(" -> ");
			WriteTerm(pl);puts("");*/
			prp=MakeCompound(A_I,4);
			SetCompoundArg(prp,1,CompoundArg1(t));
			SetCompoundArg(prp,2,NewInteger(0));
			SetCompoundArg(prp,3,is_neut?ListFirst(pl):ap1);
			SetCompoundArg(prp,4,is_neut?ListFirst(ListTail(pl)):ap2);
			ProcMkProc(prp,0);
			
		}
		return 0;
	}
	
	if(CompoundArity(t)<4)
		{
		ErrorInfo(2000);
		puts("mkProc: wrong argument number.");
		return 0;
		}
		
	for(i=5;i<=CompoundArity(t);i++)
		{
		Term t1=CompoundArgN(t,i);
		if(is_compound(t1) && is_atom(CompoundArg1(t1)) &&
			strcmp(AtomValue(CompoundArg1(t1)),"THETACUT")==0)
			{
			if(is_integer(CompoundArg2(t1)))
				thcut=IntegerValue(CompoundArg2(t1));
			else if(is_float(CompoundArg2(t1)))
				thcut=FloatValue(CompoundArg2(t1));
			else
				{
				ErrorInfo(303);puts("wrong THETACUT value.");
				continue;
				}
			continue;
			}
		ErrorInfo(304);
		puts("wrong argument in mkProc.");
		}
			
		
		
	for(i=0;i<4;i++)
		{
		Term prp, t7;
		prt[i]=CompoundArgN(t,i+1);
		if(prt[i]==NewInteger(0)&&i==1)
			{
			dec=1;spin[i]=0;color[1]=0;
			continue;
			}
		if(!is_particle(prt[i],NULL))
			{
			ErrorInfo(2001);
			WriteTerm(prt[i]);
			puts(": is not a particle.");
			return 0;
			}
		prp=GetAtomProperty(prt[i],PROP_TYPE);
		if(CompoundName(prp)!=OPR_PARTICLE)
			{
			ErrorInfo(2001);
			WriteTerm(prt[i]);
			puts(": is not a particle.");
			return 0;
			}
		if(prt[i]==CompoundArg2(prp))
			prp=GetAtomProperty(CompoundArg1(prp),PROP_TYPE);
		spin[i]=IntegerValue(CompoundArgN(prp,4));
		mass[i]=CompoundArgN(prp,5);
		color[i]=GetAtomProperty(prt[i],A_COLOR);
		t7=CompoundArgN(prp,7);
		if(i<2 && (t7==A_LEFT||t7==A_RIGHT))
			neufact*=2;
		}
	
	if(dec==0)	
	sprintf(pname,"%s%s__%s%s",AtomValue(prt[0]),AtomValue(prt[1]),
			AtomValue(prt[2]),AtomValue(prt[3]));
	else
	sprintf(pname,"%s__%s%s",AtomValue(prt[0]),
			AtomValue(prt[2]),AtomValue(prt[3]));
	
	
	for(i=0;pname[i];i++)
		{
		if(pname[i]=='~') pname[i]='_';
		if(pname[i]=='+') pname[i]='p';
		if(pname[i]=='-') pname[i]='m';
		}
	
	f=fopen("scan.bat",inifile?"a":"w");
	if(f==NULL)
		{
		ErrorInfo(2000);
		puts("mkProc: can not open scan.bat");
		return 0;
		}
		
	if(!inifile)
		{
		fprintf(f,"#!/bin/sh\n\n");
		inifile=1;
		}
		
	fprintf(f,"echo Generating process %s   `date`\n\n",pname);
	fprintf(f,"echo Process %s:  >> scan.log\n",pname);
	fprintf(f,"num0=`date +%%s`\n");
	fprintf(f,"cat > proc.m <<END\n");
	if(dec==0)
	fprintf(f,"process = {prt[\"%s\"],prt[\"%s\"]} ->",
			AtomValue(prt[0]),AtomValue(prt[1]));
	else
	fprintf(f,"process = {prt[\"%s\"]} ->",
			AtomValue(prt[0]));
	
	fprintf(f," {prt[\"%s\"],prt[\"%s\"]}\n",
			AtomValue(prt[2]),AtomValue(prt[3]));
	if(FAver==4)
		fprintf(f,"dir = SetupCodeDir[\"scan_%s\"]\n",pname);
	if(FAver>4)
		fprintf(f,"name = \"%s\"\n",pname);
	fprintf(f,"SetOptions[InsertFields,Model->model%d, GenericModel->model%d,\n",
				ModelNumber,ModelNumber);
	fprintf(f,"       ExcludeParticles->{ ");
	if(color[0]&&color[1]&&color[2]&&color[3])
		{
		int glu=1,gno=1;
		if(GetAtomProperty(prt[0],A_ANTI)!=prt[1]) glu=0;
		if(spin[0]==0&&spin[1]==0&&spin[2]==0&&spin[3]==0) gno=0;
		if(glu)
			fprintf(f,"prt[\"G\"]%c ",gno?',':' ');
		if(gno)
			fprintf(f,"prt[\"~%c\"] ",ModelNumber>30?'G':'g');
		}
	fprintf(f,"} ]\n");
	
	fprintf(f,"END\n\n");
	
	fprintf(f,"if test ! -d scan_%s/squaredme ;\n",pname);
	fprintf(f,"then  math < %s.m;\n",dec?"scand":"scan");
	fprintf(f,"fi\n\n");
	
	fprintf(f,"num1=$((`date +%%s`-num0))\nnum0=`date +%%s`\n\n");
	
	fprintf(f,"if test ! -d scan_%s/squaredme ;\n",pname);
	fprintf(f,"then echo Output directory is not created | tee -a scan.log && exit;\n");
	fprintf(f,"fi\n\n");
	
        fprintf(f,"if test ! -d drivers/F ;\n");
	fprintf(f,"then cat > scan_%s/process.h <<END\n",pname);
	for(i=1;i<=4;i++)
		{
		int i1=i;
		if(dec&&i==2) continue;
		if(dec&&i>2) i1=i-1;
		fprintf(f,"#define TYPE%d %s\n",i1,
				spin[i-1]==0?"SCALAR":(spin[i-1]==1?"FERMION":
					(mass[i-1]==0?"PHOTON":"VECTOR")));
		fprintf(f,"#define MASS%d %s\n",i1,mass[i-1]?AtomValue(mass[i-1]):"0");
		fprintf(f,"#define CHARGE%d 0\n\n",i1);
		}
	fprintf(f,"#define IDENTICALFACTOR %s\n",(prt[2]==prt[3])?"0.5":"1");
	fprintf(f,"#define COLOURFACTOR %dD0",neufact);
	if(color[0] && color[1]) fprintf(f,"/9D0");
	else if(color[0] || color[1]) fprintf(f,"/3D0");
	fprintf(f,"\n");
	if(FAver>4)
	{fprintf(f,"#define SCALE sqrtS\n#define LUMI \"lumi_parton.F\"\n");
	 fprintf(f,"c#define FORCE_ONSHELL\n");
	}
	fprintf(f,"#define NCOMP 2\n#include \"%cto2.F\"\nEND\n\nfi\n\n",dec?'1':'2');
	
	
	/*
	fprintf(f,"cp model%d.h scan_%s/model.h\n",ModelNumber,pname);
	fprintf(f,"cp mdl_ini%d.F scan_%s/mdl_ini.F\n\n",ModelNumber,pname);
	*/
        
	if(FAver==4)
		fprintf(f,"cp main.F scan_%s/\n\n",pname);
	
	if(thcut!=0.0)
		{
		fprintf(f,"echo \"#define THETACUT (%f*degree)\" > scan_%s/run.F\n",
					thcut,pname);
		fprintf(f,"grep -v THETACUT drivers/run.F >> scan_%s/run.F\n",pname);
		} 
	
	fprintf(f,"cd scan_%s\n",pname);
	
	fprintf(f,"sz0=`du -sm .`\n");
	
	fprintf(f,"if test ! -f run ;\n");
	fprintf(f,"then ./configure ;\n");
	fprintf(f,"fi\n\n");
	fprintf(f,"rm run ru*.01000*/*\n");
	fprintf(f,"gmake\n");
	fprintf(f,"if test ! -f run  ;\n");
	fprintf(f,"then echo Run file is not created | tee -a ../scan.log && exit;\n");
	fprintf(f,"fi\n");	
	
	fprintf(f,"num2=$((`date +%%s`-num0))\nnum0=`date +%%s`\n\n");
	fprintf(f,"sz1=`du -sm .`\n");

	fprintf(f,"./run uuuu 1000,1000\n");
	if(FAver>4)
		fprintf(f,"../exval6 ru*.01000*/* >> ../scan.log\n\n\n");
	fprintf(f,"cd ..\n");
//	fprintf(f,"grep \"|    1000.000\" scan_%s/ru*.01000*/* >> scan.log\n\n\n",
//				pname);

    if(FAver==4)
		fprintf(f,"./exval scan_%s/ru*.01000*/* >> scan.log\n\n\n",pname);
	
	fprintf(f,"num3=$((`date +%%s`-num0))\n\n");
	fprintf(f,"echo  $num1 + $num2 + $num3 = $(((num1+num2+num3)/60))");
	fprintf(f," min \\\n $sz0/$sz1 MB >> scan.log\n");
	fprintf(f,"rm -rf scan_%s\n\n",pname);
	fclose(f);
	return 0;
	
	}
Exemplo n.º 2
0
//static GFont s_date_font;
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
    text_layer_set_text(s_shit_layer, "");
    // Store incoming information
    static char batt_buffer[8];
    static char refresh_buffer[8];
    static char vibration_buffer[8];
    static char ppl_buffer[8];
    static char ppl_total_buffer[8];
    static char buffer[6][8];
    Tuple *name_tuple[6];
    Tuple *value_tuple[6];

    Tuple *temp_tuple = dict_find(iterator, KEY_TEMP);
    Tuple *hightemp_tuple = dict_find(iterator, KEY_HIGHTEMP);
    Tuple *lowtemp_tuple = dict_find(iterator, KEY_LOWTEMP);
    Tuple *cond_tuple = dict_find(iterator, KEY_COND);
    Tuple *batt_tuple = dict_find(iterator, KEY_BATT);
    Tuple *refresh_tuple = dict_find(iterator, KEY_REFRESH);
    Tuple *vibration_tuple = dict_find(iterator, KEY_VIBRATE);
    Tuple *ppl_tuple = dict_find(iterator, KEY_PPL);
    Tuple *ppl_total_tuple = dict_find(iterator, KEY_PPL_TOTAL);

    if(ppl_total_tuple){
        snprintf(ppl_total_buffer, sizeof(ppl_total_buffer), "%s", ppl_total_tuple->value->cstring);
        if (ppl_total != 0) {
            if (atoi(ppl_total_buffer) != ppl_total){
                //deinit before changing ppl_total
                deinit_ppl();
                ppl_total = atoi(ppl_total_buffer);
                create_ppl();
                //if number of people change, then have to wait till next refresh
            }
        }

    }

    for(int i = 1; i <= ppl_total; i++){
        name_tuple[i] = dict_find(iterator, i-1);
        value_tuple[i] = dict_find(iterator, i+9);
        set_ppl(i,buffer[i], name_tuple[i], value_tuple[i], sa_name_layer[i]);
    }

    if(s_changed){
        APP_LOG(APP_LOG_LEVEL_INFO, "changed");
        s_changed = false;
        if(s_vibrate){
            vibes_double_pulse();
        }
    }

    if(vibration_tuple){
        snprintf(vibration_buffer, sizeof(vibration_buffer), "%s", vibration_tuple->value->cstring);
        if (strcmp(vibration_buffer, "true")==0){
            s_vibrate = true;
        } else {
            s_vibrate = false;
        }
    }

    if(refresh_tuple){
        snprintf(refresh_buffer, sizeof(refresh_buffer), "%s", refresh_tuple->value->cstring);
        if (atoi(refresh_buffer) != s_interval){
            s_interval = atoi(refresh_buffer);
            update_time();
            tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
        }
    }

    if(ppl_tuple){
        snprintf(ppl_buffer, sizeof(ppl_buffer), "%s", ppl_tuple->value->cstring);
        if (strcmp(ppl_buffer, "true")==0){
            deinit_ppl();
            ppl_total=0;
        } else {
            ppl_total = persist_exists(KEY_PPL_TOTAL) ? persist_read_int(KEY_PPL_TOTAL) : 4;
            create_ppl();
        }
    }
    if(batt_tuple){
        snprintf(batt_buffer, sizeof(batt_buffer), "%s", batt_tuple->value->cstring);
        text_layer_set_text(s_batt_layer, batt_buffer);
    }

    if (cond_tuple){
        snprintf(cond_buffer, sizeof(cond_buffer), "%s", cond_tuple->value->cstring);
        bwbg = GColorBlack;
        snprintf(s_prev_cond, sizeof(s_prev_cond), "%s", s_cond);

        set_cond_color(cond_buffer);

        if (strcmp(s_cond, s_prev_cond)!=0) {
            APP_LOG(APP_LOG_LEVEL_INFO, "set colors");
            set_colors();
        }
    }


    if(temp_tuple){
        snprintf(temp_buffer, sizeof(temp_buffer), "%d°", (int)temp_tuple->value->int32);
        text_layer_set_text(s_temp_layer, temp_buffer);
    }
    // If all data is available, use it
    if(hightemp_tuple && lowtemp_tuple) {
        snprintf(hightemp_buffer, sizeof(hightemp_buffer), "%d", (int)hightemp_tuple->value->int32);
        snprintf(lowtemp_buffer, sizeof(lowtemp_buffer), "%d", (int)lowtemp_tuple->value->int32);
        snprintf(hilo_buffer, sizeof(hilo_buffer), "%d°\n%d°", (int)hightemp_tuple->value->int32, (int)lowtemp_tuple->value->int32);
        text_layer_set_text(s_hilo_layer, hilo_buffer);
    }
}