lisp_atom lp_defun(slist_elem* next) { slist* def_list=new_slist(); slist_elem* pos=0; lisp_atom* fun=0; lisp_atom ret; char* sym=0; /* if this symbol is named then we need to skip an arg*/ if(ATOM_CAST(next)->type==LTID) { sym=(char*)ATOM_CAST(next)->data; pos=next->_next; }else pos=next; /* get params */ if(!pos||ATOM_CAST(pos)->type!=LTLIST) LPRETURN_NIL(ret) slist_pushb(def_list,(void*)atom_copy(ATOM_CAST(pos))); /* get body */ pos=pos->_next; if(!pos||ATOM_CAST(pos)->type!=LTLIST) LPRETURN_NIL(ret) slist_pushb(def_list,(void*)atom_copy(ATOM_CAST(pos))); /* install macro or fn if not a lambda*/ fun=new_atom(LENORMAL,LTLISPFN,(void*)def_list); if(sym&&!lisp_put_symbol(sym,(void*)fun)) LPRETURN_NIL(ret) ret.type=LTLISPFN; ret.data=(void*)fun; return ret; }
/*--------------------------------------------------------------------*/ int main(int argc, char **argv) { /*--------------------------------------------------------------------*/ double cpu1; MPI_Init(&argc,&argv); /* Initialize the MPI environment */ MPI_Comm_rank(MPI_COMM_WORLD, &sid); /* My processor ID */ /* Vector index of this processor */ vid[0] = sid/(vproc[1]*vproc[2]); vid[1] = (sid/vproc[2])%vproc[1]; vid[2] = sid%vproc[2]; init_params(); set_topology(); init_conf(); atom_copy(); compute_accel(); /* Computes initial accelerations */ cpu1 = MPI_Wtime(); for (stepCount=1; stepCount<=StepLimit; stepCount++) { single_step(); if (stepCount%StepAvg == 0) eval_props(); } cpu = MPI_Wtime() - cpu1; if (sid == 0) printf("CPU & COMT = %le %le\n",cpu,comt); MPI_Finalize(); /* Clean up the MPI environment */ }
/*--------------------------------------------------------------------*/ void single_step() { /*---------------------------------------------------------------------- r & rv are propagated by DeltaT using the velocity-Verlet scheme. ----------------------------------------------------------------------*/ int i,a; half_kick(); /* First half kick to obtain v(t+Dt/2) */ for (i=0; i<n; i++) /* Update atomic coordinates to r(t+Dt) */ for (a=0; a<3; a++) r[i][a] = r[i][a] + DeltaT*rv[i][a]; atom_move(); atom_copy(); compute_accel(); /* Computes new accelerations, a(t+Dt) */ half_kick(); /* Second half kick to obtain v(t+Dt) */ }