|
[Sponsors] |
November 13, 2013, 07:31 |
Parse error in UDF code
|
#1 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Hi,
I am very new to c coding. I am trying to define temperature dependent material properties and have come across a parse error in my code, getting the error: UDF.c: line 2: parse error My code at this stage is: #include “udf.h” DEFINE_PROPERTY(argon_density, cell, thread) { float temp, rho; temp = C_T(cell, thread); So it's in the define property line. Probably simple but can someone point out what I've done wrong and how to correct it? Thanks, Stuart |
|
November 14, 2013, 08:51 |
|
#2 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I compiled this without parse error:
Code:
#include"udf.h" DEFINE_PROPERTY(argon_density, cell, thread) { float temp, rho; temp = C_T(cell, thread); return temp; } |
|
November 14, 2013, 09:07 |
|
#3 |
Super Moderator
Alex
Join Date: Jun 2012
Location: Germany
Posts: 3,428
Rep Power: 49 |
Depending on where you copied the code from, the text may contain "invisible" characters that lead to errors during compilation.
Copying the code again for example from this forum post can indeed lead to a better result. |
|
November 14, 2013, 09:40 |
|
#4 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Thanks for your replies.
However, I am still getting the same parse code error. I have attached a screenshot and the UDF code that I am trying to interpret. If you could help out that would be much appreciated. Thanks, Stuart |
|
November 14, 2013, 10:29 |
|
#5 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I got the same result when I interpreted your code.
I was able to fix it by changing the format from UNICODE to ASCII, and using linux-style Line-endings. I don't know which of those solved the problem. If you don't know how to do this yourself, I can not give you a clear advice on how to do it, but in that case I hope google can help you or somebody else on this forum. |
|
November 14, 2013, 11:03 |
|
#6 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Thanks for your response Pakk,
How did you convert from UNICODE to ASCII? I found websites online that convert the format but because of my lack of programming knowledge I'm not sure if what it changes it to is correct. Either way it still wouldn't interpret. How did you convert the line endings to Linux? Is this something that can be done without any Linux programming knowledge or a Linux OS? Also, could you send the file that you managed to interpret so I can try and figure it out? Cheers, Stuart |
|
November 20, 2013, 08:17 |
|
#7 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Does anyone know how to fix this?
|
|
November 20, 2013, 08:20 |
|
#8 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
What I think could help:
-Open the file in Textpad -Select 'Save as' -File format: UNIX -Encoding: ANSI -Save the file |
|
November 20, 2013, 09:14 |
|
#9 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
This is driving me demented!
When I change the file format from .c to .unix Fluent does not recognise this as a source file. When I change UDF source files to All files in the search box and select the new .unix file I get the same parse code error. You mentioned linux-style line endings - how do I go about doing that? Thanks |
|
November 20, 2013, 09:20 |
|
#10 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I never said you should change the extension from .c to .unix...
I gave you an explanation at 13:20 today on how to use Textpad to change your file to unix-style endings. (In my vocabulary, "unix-style endings" and "linux-style endings" are the same thing. I know that one of them is a wrong term.) |
|
November 20, 2013, 09:30 |
|
#11 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Ok, I think I must be missing something as I don't have the option to select UNIX file format and ANSI encoding...
What have I done wrong this time? Sorry to be a pest |
|
November 20, 2013, 09:44 |
|
#12 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
You used Notepad, I used Textpad. Notepad does not have this option, Textpad does.
(And Notepad does have the ANSI encoding option, I can see it in your screenshot. But it looks like you already selected that one.) |
|
November 20, 2013, 10:18 |
|
#13 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Thanks for your help Pakk
Downloaded Textpad but still having the parse error after following your steps above. So frustrating! |
|
November 20, 2013, 10:48 |
|
#14 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
Are you 100% sure that you tried my UDF that I posted on November 14, 2013, 13:51, and that this gave the same error for you?
|
|
November 20, 2013, 11:23 |
|
#15 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
I am using the code that I uploaded on 14th November at 14.40.
The error has changed to "invalid expression type for if: float" referring to the line "rho = 0.098;" |
|
November 20, 2013, 11:40 |
|
#16 |
Senior Member
Join Date: Nov 2013
Posts: 1,965
Rep Power: 27 |
I think you initially received an error message because you used the wrong quotes in your first line.
Code:
#include “udf.h” //your version #include "udf.h"//correct version Code:
if (temp = 293. ) Code:
if (temp == 293. ) In fact, this line can be removed, which will make your code easier: Code:
if (temp == 293. ) rho = 1.623; elseif (temp > 293. && temp < 500. ) rho = 1.623 + ((0.999 - 1.623) / 207. ) * (temp - 293. ); Code:
if ((temp >= 293.) && (temp < 500.)) rho = 1.623 + ((0.999 - 1.623) / 207. ) * (temp - 293. ); Finally, note that in the current code, if the temperature is below 293K your argon will have a low density (0.098), which is not physical. If you are sure that the temperature will not drop below 293K, it is not a problem, but it could be safer to start with a line "if (temp<293.) ...". |
|
November 21, 2013, 04:45 |
|
#17 |
New Member
Join Date: Oct 2013
Posts: 25
Rep Power: 13 |
Thanks very much for the help Pakk.
The UDFs appear to be interpreting now although I haven't run a simulation yet. |
|
Tags |
c coding, parse error, programming, udf error |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
udf code for anisotropy turbulence model- square duct | Eliasjal | Fluent UDF and Scheme Programming | 1 | August 29, 2012 11:26 |
parse error while interpreting udf | Kristin | Fluent UDF and Scheme Programming | 3 | March 15, 2012 07:43 |
Parse Error Message While interpreting UDF in FLUENT | dhimans | Fluent UDF and Scheme Programming | 1 | July 10, 2009 07:29 |
UDF parse error | alemenchaca | FLUENT | 0 | July 1, 2009 20:45 |
PARSE ERROR Message when interpreting UDF in FLUENT | dhimans | FLUENT | 0 | May 24, 2009 12:40 |