|
[Sponsors] |
June 11, 2007, 12:21 |
Fortran problem
|
#1 |
Guest
Posts: n/a
|
Hi everyone,
I need to read an INPUT file. I would like to put some comments in my INPUT file but it makes error during reading the INPUT file. How can I read the input data and ignore the comments ? Thanks MM |
|
June 11, 2007, 14:00 |
Re: Fortran problem
|
#2 |
Guest
Posts: n/a
|
Put the comments at the end of the file.
|
|
June 11, 2007, 14:11 |
Re: Fortran problem
|
#3 |
Guest
Posts: n/a
|
I need to put comment in front of each data.
|
|
June 11, 2007, 15:26 |
Re: Fortran problem
|
#4 |
Guest
Posts: n/a
|
You can simply read a blank line into a dummy variable. So if your input file looks like:
this is 1 56 this is 2 43 this is 3 I'm pretty sure you can do: read(,*) dummyvar read(,*) var1 read(,*) dummyvar read(,*) var 2 etc or you could just either like said above put your comments at the end of the file, or something like this 56 !! this is variable 1 56 !! this is variable 2 34 !! this is variable 3, etc |
|
June 11, 2007, 15:37 |
Re: Fortran problem
|
#5 |
Guest
Posts: n/a
|
You should be able to finely tune your reading with the NAMELIST statement.
|
|
June 11, 2007, 15:40 |
Re: Fortran problem
|
#6 |
Guest
Posts: n/a
|
Jojo, Could u please explain a little more and give an example thanks
|
|
June 12, 2007, 05:04 |
Re: Fortran problem
|
#7 |
Guest
Posts: n/a
|
Read each line into a character array and then read your input data from the character array. This gives you much more freedom to interpret your input and, in this case, would allow you to inspect the first character to see if it is a comment or not.
|
|
June 12, 2007, 10:00 |
Re: Fortran problem
|
#8 |
Guest
Posts: n/a
|
READ(UNIT,*)
This reads a line but ignores the data held in it, effectively skipping the line. Probably quite a useful piece of code for you I would say. |
|
June 12, 2007, 10:27 |
Re: Fortran problem
|
#9 |
Guest
Posts: n/a
|
NAMELIST is a conventional statement you can find in any reference manual or on the Internet.
It helps you assemble variables to group a record. Ex: INTEGER :: aninteger = 4 REAL :: areal = 5. NAMELIST /record1/ aninteger, areal WRITE(6,NML=record1) should print on your screen: aninteger=4, areal = 5. It also works for reading. I also remember that a similar question was asked sometime ago and a forum user gave an very interesting trick by playing with string as a FORMAT command. Unfortunately, I cannot find it. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
User fortran error when running CFX-10 in parallel | CFDworker | CFX | 3 | September 22, 2015 09:59 |
Fortran compiler problem | Luke | Siemens | 2 | September 18, 2008 04:43 |
Problem with Fortran installation. | skarp | CFX | 0 | August 4, 2007 08:09 |
natural convection problem for a CHT problem | Se-Hee | CFX | 2 | June 10, 2007 07:29 |
'C' or FORTRAN or 'C++' | Yogesh Talekar | Main CFD Forum | 20 | October 21, 1999 05:00 |