-
-
May 30, 2023 at 8:25 pm
mctom0518
SubscriberHello,
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 am
Rob
Ansys EmployeeI've not seen that one. Are there any other errors when you compile?
-
May 31, 2023 at 4:34 pm
mctom0518
SubscriberHello Rob,
There were no interpretations or compilation errors with the UDF.
-
June 1, 2023 at 3:24 pm
Rob
Ansys EmployeeCan 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 pm
mctom0518
SubscriberWe ran without the printf command and it still displayed the error message.
-
June 1, 2023 at 9:04 pm
mctom0518
SubscriberAs 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 am
Rob
Ansys EmployeeNot 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 pm
mctom0518
SubscriberHello 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!
-
- You must be logged in to reply to this topic.

Boost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.

Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.

Ansys Blog
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- Floating point exception in Fluent
- What are the differences between CFX and Fluent?
- Heat transfer coefficient
- Difference between K-epsilon and K-omega Turbulence Model
- Getting graph and tabular data from result in workbench mechanical
- The solver failed with a non-zero exit code of : 2
- Suppress Fluent to open with GUI while performing in journal file
- Mesh Interfaces in ANSYS FLUENT
- Time Step Size and Courant Number
- error: Received signal SIGSEGV
-
7676
-
4476
-
2957
-
1433
-
1322
© 2023 Copyright ANSYS, Inc. All rights reserved.