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

Fortran problem

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 11, 2007, 12:21
Default Fortran problem
  #1
MM
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
  Reply With Quote

Old   June 11, 2007, 14:00
Default Re: Fortran problem
  #2
otd
Guest
 
Posts: n/a
Put the comments at the end of the file.
  Reply With Quote

Old   June 11, 2007, 14:11
Default Re: Fortran problem
  #3
MM
Guest
 
Posts: n/a
I need to put comment in front of each data.
  Reply With Quote

Old   June 11, 2007, 15:26
Default Re: Fortran problem
  #4
Lost in CFD
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
  Reply With Quote

Old   June 11, 2007, 15:37
Default Re: Fortran problem
  #5
Jojo
Guest
 
Posts: n/a
You should be able to finely tune your reading with the NAMELIST statement.
  Reply With Quote

Old   June 11, 2007, 15:40
Default Re: Fortran problem
  #6
MM
Guest
 
Posts: n/a
Jojo, Could u please explain a little more and give an example thanks
  Reply With Quote

Old   June 12, 2007, 05:04
Default Re: Fortran problem
  #7
andy
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.

  Reply With Quote

Old   June 12, 2007, 10:00
Default Re: Fortran problem
  #8
Andrew
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.
  Reply With Quote

Old   June 12, 2007, 10:27
Default Re: Fortran problem
  #9
jojo
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.

  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
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


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