Fluids

Fluids

Topics relate to Fluent, CFX, Turbogrid and more

UDF Error Message

TAGGED: , ,

    • mctom0518
      Subscriber

      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!

    • Rob
      Forum Moderator

      I've not seen that one. Are there any other errors when you compile?

    • mctom0518
      Subscriber

      Hello Rob,

      There were no interpretations or compilation errors with the UDF. 

    • Rob
      Forum 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. 

    • mctom0518
      Subscriber

      We ran without the printf command and it still displayed the error message. 

    • mctom0518
      Subscriber

      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.

    • Rob
      Forum 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. 

    • mctom0518
      Subscriber

      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!

Viewing 7 reply threads
  • The topic ‘UDF Error Message’ is closed to new replies.