|
[Sponsors] |
October 30, 2007, 08:59 |
Fortran question
|
#1 |
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 |
|
October 30, 2007, 09:23 |
Re: Fortran question
|
#2 |
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. |
|
October 30, 2007, 09:29 |
Re: Fortran question
|
#3 |
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' |
|
October 30, 2007, 10:00 |
Re: Fortran question
|
#4 |
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? |
|
October 30, 2007, 10:09 |
Re: Fortran question
|
#5 |
Guest
Posts: n/a
|
No...As you see there's not 4th caracter after cin, there is only 3
|
|
October 30, 2007, 10:16 |
Re: Fortran question
|
#6 |
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. |
|
October 30, 2007, 10:20 |
Re: Fortran question
|
#7 |
Guest
Posts: n/a
|
thanks glenn
i'll try |
|
October 30, 2007, 10:40 |
Re: Fortran question
|
#8 |
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 |
|
October 30, 2007, 11:01 |
Re: Fortran question
|
#9 |
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 |
|
October 30, 2007, 11:45 |
Re: Fortran question
|
#10 |
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.
|
|
October 30, 2007, 12:54 |
Re: Fortran question
|
#11 |
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. |
|
October 31, 2007, 05:16 |
Re: Fortran question
|
#12 |
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. |
|
October 31, 2007, 14:07 |
Re: Fortran question
|
#13 |
Guest
Posts: n/a
|
Thanks Rami, and also for ag and Glenn
Noureddine |
|
|
|
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 |