CFD Online Discussion Forums

CFD Online Discussion Forums (
-   Main CFD Forum (
-   -   Fortran question (

Noureddine October 30, 2007 08:59

Fortran question
Hi everybody,

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



READ(*,'(A6)') NAME

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



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.


Glenn October 30, 2007 09:23

Re: Fortran question
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.

Noureddine October 30, 2007 09:29

Re: Fortran question
thanks Glenn.

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

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

Glenn October 30, 2007 10:00

Re: Fortran question
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?

Noureddine October 30, 2007 10:09

Re: Fortran question
No...As you see there's not 4th caracter after cin, there is only 3

Glenn October 30, 2007 10:16

Re: Fortran question
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.

Noureddine October 30, 2007 10:20

Re: Fortran question
thanks glenn

i'll try

Noureddine October 30, 2007 10:40

Re: Fortran question
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

Noureddine October 30, 2007 11:01

Re: Fortran question
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) 10 = 6 + 4

ag October 30, 2007 11:45

Re: Fortran question
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.

noureddine October 30, 2007 12:54

Re: Fortran question
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.

Rami October 31, 2007 05:16

Re: Fortran question
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.

Noureddine October 31, 2007 14:07

Re: Fortran question
Thanks Rami, and also for ag and Glenn


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