CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > FLUENT

SCANF

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   April 7, 2003, 18:26
Default SCANF
  #1
Alex Munoz
Guest
 
Posts: n/a
Hello CFD community

I wonder if someone knows a function similar to scanf, which could read string from the screen window. Unfortunately, it seems that Fluent does not support this C function in its UDF.

I really appreciate a suggestion of how to read strings from the window screen by a UDF.

Regards

Alex
  Reply With Quote

Old   April 8, 2003, 11:28
Default Re: SCANF
  #2
Thierry
Guest
 
Posts: n/a
Hello Alex

Indeed it is not posible to use SCANF in FLUENT, you must use FSCANF instead ! (Fluent.Inc/fluent6.1/help/html/udf/node39.htm).

Maybe you can put your filename in a special file, which name is unvariant, and read this file with fscanf.

Thierry.
  Reply With Quote

Old   April 8, 2003, 14:01
Default Re: SCANF
  #3
Vladimir Krejci
Guest
 
Posts: n/a
Hello both, function fscanf can read from standard input in C nad C++, I am not sure if it works in Fluent. The only difference is that you use 'stdin' instead of a your pointer to a file. The screen terminal (standard input and output) is treated as a file in this programming language. Hope it helps. Vladimir
  Reply With Quote

Old   April 8, 2003, 15:44
Default Re: SCANF
  #4
Alex Munoz
Guest
 
Posts: n/a
Hello Thierry!

Thanks you for thinking a solution for my problem

Actually, I an using fscanf to read the file with invariant name. However, in my case I need to several data file, where the only difference between them is the name. Consequently I am looking for a C function which be able to read the name files from the MAIN FLUENT WINDOW

If you know a way to read these file without changing the name in the user define, compiling and running fluent over and over it will be great.

Best Regards

Alex Munoz
  Reply With Quote

Old   April 9, 2003, 03:51
Default Re: SCANF
  #5
Thierry
Guest
 
Posts: n/a
Hello Alex !

I have well understood your problem...and I think it's not possible to access directly to the main fluent window. What I suggested you is reading a file with fscanf, which name is invariant (names.txt for instance), and that includes all the filenames you need.

Example :

names.txt contains : filename_1 filename_2 filename_3

and you use something like that !

char filename[20]; FILE *f; FILE *g;

if ((f=fopen("names.txt","r"))==NULL)

{

Internal_Error("NAMES.TXT NOT FOUND !!\n");

} else nb_files=3; for (i=0; i<nb_files; i++)

{

fscanf(f,"%s\n",filename);

g=fopen(filename,"r");

...

...

fclose(g)

}

fclose(f)

Of course you have to modify this file each time the filenames change, but you can avoid compiling the UDF.

Best regards

Thierry
  Reply With Quote

Old   April 9, 2003, 14:33
Default Re: SCANF
  #6
Alex Munoz
Guest
 
Posts: n/a
Hi Thieery

Thanks you for your suggestion, unfortunately i can not do it, The files are extremely large and If I save the cas and data file plus several scalar files, I will run out of computer storage.

I guess I have to live with the problem!

Thank you

Alex
  Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the format of.txt file for scanf to read lamlash FLUENT 0 July 17, 2006 18:04


All times are GMT -4. The time now is 04:25.