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

Fortran question

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 30, 2007, 08:59
Default Fortran question
  #1
Noureddine
Guest
 
Posts: n/a
Hi everybody,

I want to understand the following command lines from Peric's code:

CHARACTER*10 FILIN, NAME*6

PRINT *, ' ENTER PROBLEM NAME (SIX CHARACTERS): '

READ(*,'(A6)') NAME

WRITE( FILIN,'(A6,4H.cin)') NAME

OPEN (UNIT=5,FILE=FILIN)

REWIND 5

My question is about WRITE and OPEN command lines. I have understood that we write NAME in an internal file, but I did not understand the format '(A6,4H.cin)'. For OPEN command line, I did not understand what does it mean FILIN, name of file or what ?.

if there's someone who can explain me this part of code, I will be thankful.

Noureddine
  Reply With Quote

Old   October 30, 2007, 09:23
Default Re: Fortran question
  #2
Glenn
Guest
 
Posts: n/a
FILIN is the name of the file you are specifying to be opened. The Character*10 FILIN specifies that the file name can be up to 10 characters in length.

write statement specified to write to the FILIN file the alpha-numeric parameter NAME, which is specified as 6 character length limited (character Name*6). In the write statement, the A6 specifies an alph-numeric 6 character write field, consistent with the NAME parameter. (Sorry, but I am not sure exactly what the 4Hcin specification is stipulating) Hope this helps some.
  Reply With Quote

Old   October 30, 2007, 09:29
Default Re: Fortran question
  #3
Noureddine
Guest
 
Posts: n/a
thanks Glenn.

4H.cin it's exactly what i did not undertand.

and how we can wrtie FILE=FILIN ?. usually we write FILE='filename.xxx'

  Reply With Quote

Old   October 30, 2007, 10:00
Default Re: Fortran question
  #4
Glenn
Guest
 
Posts: n/a
Agreed... Usually, one does not write back to the input file...but it is allowed.

The 4hcin is probably an H-format code. Ifn this case, 4Hcin woudl specify to write the 4 characters following the 4H as an alph-numeric string. Is there a 4th character after cin?
  Reply With Quote

Old   October 30, 2007, 10:09
Default Re: Fortran question
  #5
Noureddine
Guest
 
Posts: n/a
No...As you see there's not 4th caracter after cin, there is only 3
  Reply With Quote

Old   October 30, 2007, 10:16
Default Re: Fortran question
  #6
Glenn
Guest
 
Posts: n/a
Actually, there are 4 characters... the dot (.) before the cin counts as the first... so .cin = 4 characters

If you run the code and look, you should see the .cin written.
  Reply With Quote

Old   October 30, 2007, 10:20
Default Re: Fortran question
  #7
Noureddine
Guest
 
Posts: n/a
thanks glenn

i'll try
  Reply With Quote

Old   October 30, 2007, 10:40
Default Re: Fortran question
  #8
Noureddine
Guest
 
Posts: n/a
there are a lot of input files and we should choose one for the case which we like to calculate.

per example : buocyl.cin, cav45b.cin, chanel.cin, ...etc

  Reply With Quote

Old   October 30, 2007, 11:01
Default Re: Fortran question
  #9
Noureddine
Guest
 
Posts: n/a
yes you are right, but i don't understand what does it mean FILIN in OPEN command ?

FILIN = "NAME.cin" ?....Character*10 (FILIN) = A6 (NAME) + 4H (.cin)....as 10 = 6 + 4
  Reply With Quote

Old   October 30, 2007, 11:45
Default Re: Fortran question
  #10
ag
Guest
 
Posts: n/a
The write statement assigns a value to the character variable FILIN. Then that character variable is used as the file name for the file to be opened in the OPEN statement.
  Reply With Quote

Old   October 30, 2007, 12:54
Default Re: Fortran question
  #11
noureddine
Guest
 
Posts: n/a
Thanks ag,

it is what I have understood. but it's strange for me that we assign a value to character variable FILIN via write statment...via internal file name.

Thanks for all.
  Reply With Quote

Old   October 31, 2007, 05:16
Default Re: Fortran question
  #12
Rami
Guest
 
Posts: n/a
It is rather straightforward.

In the WRITE statement you assign a value to the 10 character string FILIN by an internal write statement. Its value comprises of the 6 characters contained in the variable NAME, followed by the 4 character string ".cin" (4H.cin is a 4 character Hollerith, similar to the syntax '.cin'). For example, if you enter ABCDEF in response to the prompt, then it is the value of NAME, and consequently the WRITE statement makes FILIN be 'ABCDEF.cin'.

In the OPEN statement, you open unit 5, with the file name being the value held in FILIN. In the above example, file ABCDEF.cin is opened as unit 5. As its status is not specified, it is opened for both input and output.

... So many words for two statements... But hopefully this clarifies your doubts.
  Reply With Quote

Old   October 31, 2007, 14:07
Default Re: Fortran question
  #13
Noureddine
Guest
 
Posts: n/a
Thanks Rami, and also for ag and Glenn

Noureddine
  Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CFX11 + Fortran compiler ? Mohan CFX 20 March 30, 2011 19:56
a strange question about Fortran Hall Main CFD Forum 9 May 18, 2004 03:48
Question on USER FORTRAN: GETVAR BoZ CFX 2 May 6, 2003 11:32
Short question on command in user fortran Franz Thomsen CFX 2 June 20, 2000 07:35
'C' or FORTRAN or 'C++' Yogesh Talekar Main CFD Forum 20 October 21, 1999 05:00


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