July 28, 2015, 22:53
|
I know WHERE but not WHY- segmentation fault in an interpreted UDF
|
#1
|
New Member
Achint Sanghi
Join Date: Mar 2015
Posts: 3
Rep Power: 11
|
I am interpreting an ADJUST macro as well as two Source macros. I have identified that I get segmentation errors while using C_UDMI and C_UDSI (though they are both already defined in the case using GUI). For example, in lines 17 and 18 of the below code. Can someone ID the problem?
Code:
DEFINE_ADJUST (moisture_update, d)
{
real n_ts, m, time, dmdt, Tabs, RH, mr, t_hour, Psat, time_step, k, n, power, a, b, EMC, Mnew, w, Pvs, E_evp;
Thread *t;
cell_t c;
n_ts = RP_Get_Integer ("time-step");
time_step=RP_Get_Real("physical-time-step");
time=RP_Get_Real("flow-time");
t_hour=time/3600;
if(last_timestep !=n_ts)
{
last_timestep=n_ts;
thread_loop_c(t,d)
{
begin_c_loop(c,t)
{
m=C_UDMI(c,t,0);
w=C_UDSI(c,t,0);
Tabs=C_T(c,t);
Pvs=0.1 * exp(27.014-(6887/Tabs)-(5.31*log(Tabs/273.16)));
RH=(101.3 * w)/(Pvs*(0.62189 + w));
if(RH>0.99)
{RH=0.99;}
C_UDMI(c,t,1)=RH;
dmdt=100.0;
Mnew=(time_step*dmdt)+m;
C_UDMI(c,t,0)=Mnew;
C_UDMI(c,t,2)=dmdt;
}
end_c_loop(c,t)
}
}
}
|
|
|