-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
AI is not initialized, leading to potential segfault, and update of AI is happening at the wrong index. See comments "Jaideep FIXME" in below code:
if(length(Au)==1){
#if there is no information on how many cell drain to this point, assume 3 sides of the octogonal cell
ncellin<-3
ncellout<-3
soil_info<-c(SAT,WP,FC,soil_info$Ksat,lambda,depth,bub_press,RES,Au[1],resolution^2,ncellin,ncellout,0)
# ^ Jaideep FIXME: Note that this does not set soil_info[13] to AI. This means that when this is dereferenced in quick-run, there's a risk of segfault or garbage value
}else{
ncellin<-Au[2]
ncellout<-Au[3]
soil_info<-c(SAT,WP,FC,soil_info$Ksat,lambda,depth,bub_press,RES,Au[1],resolution^2,ncellin,ncellout,1)
}
And here:
initial_AI<-my_splash$spin_up(as.integer(365), as.integer(y[1]), as.numeric(sw_av[1:365]), as.numeric(tc_av[1:365]),as.numeric(pn_av[1:365]),slop,asp,as.numeric(snowf_av[1:365]),soil_info)
# ^ Jaideep FIXME: This sees a size-12 soil_info when length(Au)=1, so might get segfault, or worse, AI will get garbage value
#update aridity
soil_info[13]<-sum(initial_AI$pet,na.rm=T)/sum(Pinit[1:365],na.rm = T)
# ^ Jaideep FIXME: This is assigning AI to soil_info[12] (R indexing) which is ncellout. It should instead go into soil_info[13] (R indexing), i.e. soil_info[12] (C++ indexing)
# run spin up
``
Metadata
Metadata
Assignees
Labels
No labels