|
[Sponsors] |
June 8, 2022, 06:20 |
Error while using C_CENTROID
|
#1 |
Member
Chris
Join Date: Dec 2020
Posts: 45
Rep Power: 5 |
Hey,
I´m trying to order my cells inside each thread by coordinates. Therefore I have Code:
cell_t cIDs_t0[50], cIDs_t1[50]; // Cell ID arrays of each thread cell_t *cIDs[Nt] = {cIDs_t0, cIDs_t1}; // Pointer to all cell IDs of all threads These arrays contain the IDs in a sorted order (e.g. 0,5,4,3,2,1,6,7,...). Now I have a problem using C_CENTROID function: Code:
const int Nt = 2; // Number of threads int tIDs[Nt] = {6, 7}; // Thread IDs int Nct[Nt] = {50, 50}; // Number of cells in each thread cell_t c; Thread *t; Domain *d = Get_Domain(1); for(int i=0; i<Nt; i++) // Loop over all threads { t = Lookup_Thread(d,tIDs[i]); for(int j=0; j<Nct[i]; j++) { //begin_c_loop(c,t) //{ // if(c == j) // { C_CENTROID(pt,cIDs[i][j],t); // Message("%d %d %g %g %g\n",t,cIDs[i][j],pt[0],pt[1],pt[2]); // } //} //end_c_loop(c,t) } } The problem is, if I use my function like this, the program crashes with segmentation fault error but if I use the commented out lines with the c_loop and if statement (if statement is only for a reduced message output, also works without the if), than the program works and give me my expected output. Confusing for me is that my C_CENTROID and my message lines do not contain c in any case. Does anybody know, whats the problem here? The code is inside a DEFINE_ON_LOADING function. Here is my error file: Code:
Node 999999 Fatal signal raised sig = Segmentation fault b0fec6b0 CX_Primitive_Error 7f67bd50 seh_filter_exe b108d290 logical_right_shift 6485ec50 _C_specific_handler 81ec1ee0 _chkstk 81e8a740 RtlRaiseException 81ec0c40 KiUserExceptionDispatcher 74e90000 Ordinal0 b06214b0 Open_UDF_Library af65e330 cx_strdup b1078840 eval b1078840 eval b1078840 eval b1078840 eval b1079ea0 set_cc b107a650 eval_errprotect b1078840 eval b1078840 eval b1078840 eval b1078840 eval b1079ea0 set_cc b107a650 eval_errprotect b0fed5c0 CX_Interpret_String af7288d0 rpgetvar_errprotect b108d290 logical_right_shift 81b97c10 BaseThreadInitThunk 81e8d700 RtlUserThreadStart Error [node 999999] [time 6/8/22 11:8:48] Abnormal Exit! Chris |
|
June 9, 2022, 07:17 |
|
#2 | |
Senior Member
Alexander
Join Date: Apr 2013
Posts: 2,363
Rep Power: 34 |
Quote:
Code:
cell_t *cIDs[Nt] = {cIDs_t0, cIDs_t1}; // Pointer to all cell IDs of all threads thread (t) is not integer, so you are not able to use %d to plot it
__________________
best regards ****************************** press LIKE if this message was helpful |
||
Tags |
c_centroid, segmentation fault |
|
|