-
-
May 30, 2023 at 8:25 pmmctom0518Subscriber
Hello,
I am trying to compile and execute this UDF code to initialize an array, but I am receving the following error message: Chip: invalid opcode 0: pc=21
My UDF code is below:
#include "udf.h" int grid[2][2][10]; DEFINE_ON_DEMAND(ini_all) { int i, j, m; for (i = 0; i < 2; i ++) { for (j = 0; j < 2; j ++) { for (m = 0; m < 10; m ++) { printf("At index %d %d %d \n", i, j, m); grid[i][j][m] = 3; } } } }
What does this error message mean, and how can I resolve it? I can easily execute the same for loop structure using gcc compilers, but it just does not seem to work in ANSYS.
Thank you!
-
May 31, 2023 at 10:36 amRobForum Moderator
I've not seen that one. Are there any other errors when you compile?
-
May 31, 2023 at 4:34 pmmctom0518Subscriber
Hello Rob,
There were no interpretations or compilation errors with the UDF.
-
June 1, 2023 at 3:24 pmRobForum Moderator
Can you confirm you're compiling the code, ie linking to the libudf library? Also, you may want to look at the Message function rather than printf.
-
June 1, 2023 at 6:56 pmmctom0518Subscriber
We ran without the printf command and it still displayed the error message.
-
June 1, 2023 at 9:04 pmmctom0518Subscriber
As of right now, the only solution from my end is to use a while loop instead of a for loop, but I am still wondering why the for loop does not work but the while loop works.
-
June 2, 2023 at 8:59 amRobForum Moderator
Not sure, my UDF coding isn't overly good, and I don't think I ever used FOR or WHILE in a code. Will FOR fail the block & move on for when i isn't 0, but WHILE moves onto i<2 when i isn't 0? Just been reading an online C manual for my own benefit.
-
June 5, 2023 at 8:35 pmmctom0518Subscriber
Hello Rob,
I figured out the issue. For loops just do not seem to work when interpreting UDFs and only seem to work with compiling only. The code is running smoothly now without issue.
I appreciate your time and help!
-
- The topic ‘UDF Error Message’ is closed to new replies.
- How do I get my hands on Ansys Rocky DEM
- Non-Intersected faces found for matching interface periodic-walls
- Fluent fails with Intel MPI protocol on 2 nodes
- Unburnt Hydrocarbons contour in ANSYS FORTE for sector mesh
- Help: About the expression of turbulent viscosity in Realizable k-e model
- Cyclone (Stairmand) simulation using RSM
- Mass Conservation Issue in Methane Pyrolysis Shock Tube Simulation
- Script Error
- Facing trouble regarding setting up boundary conditions for SOEC Modeling
- convergence issue for transonic flow
-
1592
-
602
-
599
-
591
-
366
© 2025 Copyright ANSYS, Inc. All rights reserved.