Skip to content

Instantly share code, notes, and snippets.

@isag
Created April 12, 2012 08:37
Show Gist options
  • Save isag/2365641 to your computer and use it in GitHub Desktop.
Save isag/2365641 to your computer and use it in GitHub Desktop.
A way to create a species pool from assembly process
void create_assembled_pool(Params *p, double **pool, int divpool, double fert)
{
restart:;
// define and initialize the ecosystem list
//-----------------------------------------
sll ecosys;
sll_init(&ecosys,(void*)free_species);
// create the basal resources
//---------------------------
basal(p,&ecosys,fert);
// assemble until the targetted diversity is reached
//--------------------------------------------------
int a = divpool + EAM_NBNUT + EAM_NBDET;
int counter = EAM_STOP_UNSUCCESS_ASSEMBLY*divpool;
while(ecosys.length != a)
{
ParamSP *sp = (void*)species(p,2);
install_process(p,&ecosys,sp);
sll_rm(&ecosys,extinct_condition);
++(p->num);
--counter;
if(counter == 0)
{
sll_rm_all(&ecosys);
goto restart;
}
}
// remove the resources
//---------------------
sll_rm(&ecosys,is_resource);
// create the subpool matrix and fill it with the selected species
//----------------------------------------------------------------
sllnode *node = ecosys.head;
for (int i = 0; node != NULL; i++, node = node->next)
{
ParamSP sp = *(ParamSP*)(node->data);
sp.d = EAM_N0SP;
tr_sp_array(&sp,pool[i]);
}
// free the memory
//----------------
sll_rm_all(&ecosys);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment