作者Vinygli (Vin)
看板Programming
标题[问题] 遇到难搞bug求解
时间Sun Jul 4 20:32:54 2021
如题,小弟目前在当硕士生,明明是程式苦手
却还是读起了物理系,现在在实验室帮忙。
我现在手上的程式遇到一个看似很常见,
可是错误讯息讲得很笼统,
查了一堆资料後还是看不懂它要什麽,
可以帮我看看吗?
void FB_UVFeedback( real (*Fluid)[PS2][PS2][PS2],
real &particleIonizingLuminosity, const int ¶rticleWillExplode,
const int idx[], const double dh );
void FB_User_Template( const int lv, const double TimeNew, const double TimeOld,
const double dt, const int NPar, const int *ParSortID,
real *ParAtt[PAR_NATT_TOTAL], real (*Fluid)[PS2][PS2][PS2],
const double EdgeL[], const double dh, bool CoarseFine[], const int TID,
RandomNumber_t *RNG )
{
…
// 1: UV feedback
FB_UVFeedback( (Fluid*){[16][16][16]}, ionizeLuminosity,
willExplode[n], idx, dh);
…
}
void FB_UVFeedback( real (*Fluid)[PS2][PS2][PS2], real
&particleIonizingLuminosity, const int ¶rticleWillExplode,
const int idx[], const double dh )
{
#ifdef DUAL_ENERGY
const real cell_volume = POW(dh*UNIT_L, 3);
const real mu = 0.6;
const real mass_h = 1.67262171e-24;
const real alpha = 2.60e-13; // Case B recombination, assuming T = 10^4 K.
const real flu_dens = Fluid[DENS][ idx[0] ][ idx[1] ][ idx[2] ];
// old density of this cell
const real flu_energy = Fluid[ENPY][ idx[0] ][ idx[1] ][ idx[2] ];
// old energy of this cell
const real num = flu_dens * UNIT_D / mu / mass_h;
const real stromgren_radius = POW( ( (3.0*particleIonizingLuminosity*1e49) / (4.0*M_PI*alpha*SQR(num)) ), (1.0/3.0) );
const real stromgren_volume = (4.0/3.0) * M_PI * CUBE(stromgren_radius);
real ionized = Const_kB*1e4 / mu / mass_h / SQR(UNIT_L) * SQR(UNIT_T);
if ( stromgren_volume < cell_volume ) ionized *= stromgren_volume/cell_volume;
if ( pararticleWillExplode == 1 && flu_energy < ionized )
{
// TODO: dual energy update
const real theDiff = ionized - flu_energy; // thermal energy difference caused by UV ionization
Fluid[ENGY][idx[0]][idx[1]][idx[2]] += theDiff; // Update the energy
Fluid[ENPY][idx[0]][idx[1]][idx[2]] += theDiff;
}
#endif // #ifdef DUAL_ENERGY
} // FUNCTION : FB_UVFeedback
error message: error: expected primary-expression before ‘)’ token
FB_UVFeedback( (Fluid*){[16][16][16]}, ionizeLuminosity, willExplode[n], idx, dh);
^
以上,要是有人路过,也遇过相同bug的话,
请跟我分享你怎麽解决的,谢谢。
p.s. 今天是我第一次来这个版发文,
礼数不周请多指教。
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.38.243.207 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Programming/M.1625401976.A.E95.html
1F:推 LPH66: 你的 [16][16][16] 那个东西是想传什麽? 180.177.0.237 07/04 20:38
那是一个在别的地方定义好的矩阵
被我负责的程式拿过来做处理
跟上面的*Fluid[PS2][PS2][PS2]是同一个东西
※ 编辑: Vinygli (114.38.243.207 台湾), 07/04/2021 20:58:22
2F:推 LPH66: 那总该有个名字... 180.177.0.237 07/05 01:37
3F:推 sppmg: 这是C?很久没用了,我只想问:(*type){[ 101.12.43.160 07/05 02:33
4F:→ sppmg: ][ ][ ]} 这语法正确吗? 101.12.43.160 07/05 02:33
你说得对,我应该把它弄成一个parameter.
我再试试看好了,谢谢。
※ 编辑: Vinygli (1.173.223.253 台湾), 07/05/2021 08:23:19
解决了!!!
※ 编辑: Vinygli (1.175.248.73 台湾), 07/05/2021 12:21:17