[問題] 遇到難搞bug求解

看板Programming作者 (Vin)時間2年前 (2021/07/04 20:32), 2年前編輯推噓3(301)
留言4則, 2人參與, 2年前最新討論串1/1
如題,小弟目前在當碩士生,明明是程式苦手 卻還是讀起了物理系,現在在實驗室幫忙。 我現在手上的程式遇到一個看似很常見, 可是錯誤訊息講得很籠統, 查了一堆資料後還是看不懂它要什麼, 可以幫我看看嗎? void FB_UVFeedback( real (*Fluid)[PS2][PS2][PS2], real &particleIonizingLuminosity, const int &pararticleWillExplode, 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 &pararticleWillExplode, 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://www.ptt.cc/bbs/Programming/M.1625401976.A.E95.html

07/04 20:38, 2年前 , 1F
你的 [16][16][16] 那個東西是想傳什麼?
07/04 20:38, 1F
那是一個在別的地方定義好的矩陣 被我負責的程式拿過來做處理 跟上面的*Fluid[PS2][PS2][PS2]是同一個東西 ※ 編輯: Vinygli (114.38.243.207 臺灣), 07/04/2021 20:58:22

07/05 01:37, 2年前 , 2F
那總該有個名字...
07/05 01:37, 2F

07/05 02:33, 2年前 , 3F
這是C?很久沒用了,我只想問:(*type){[
07/05 02:33, 3F

07/05 02:33, 2年前 , 4F
][ ][ ]} 這語法正確嗎?
07/05 02:33, 4F
你說得對,我應該把它弄成一個parameter. 我再試試看好了,謝謝。 ※ 編輯: Vinygli (1.173.223.253 臺灣), 07/05/2021 08:23:19 解決了!!! ※ 編輯: Vinygli (1.175.248.73 臺灣), 07/05/2021 12:21:17
文章代碼(AID): #1WuQfuwL (Programming)