Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading Input File

Status
Not open for further replies.

kkmkk

Technical User
Dec 21, 2011
3
GB
Hi everyone, I am trying to code using fortan 90 to read a file which I have then use the numbers for some stuff.

So far I have

"
SUBROUTINE readinput
USE simParam, ONLY: xDim,yDim,tMax,Re,obstR,obstX,obstY,obsth,tprint,pi,po
implicit none
character (LEN=100)::fileName
write(fileName,*) 1
fileName = adjustl(fileName)
open(12,file='READ'//trim(fileName)//'.dat')
read(12,101) xDim,yDim,obstX,obstY,obsth,obstR,tMax,tprint,Re,pi,po
101 format(2x,8i6,1E12.5)
close (12)
END SUBROUTINE readinput
"

It is all working fine apart from reading in "pi" and "po".
I just stuck them on the end of the code I currently use but I have obviously done something wrong....

To format in my input file (READ) is

" 500, 2000, 100,50, 10, 20,1000,10, 500,10,20.0d0 "

Im thinking its something to do with the format command?

Thanks!
 
The format you use in the READ statement does not correspond to the one of your file.

Try READ(12,*) instead of READ(12,101)...

François Jacq
 
just gave it a shot and it doesnt seem to work, once its compiled it closes as soon as I try to run it.. the readinput is one of the first subroutines called.

I literally just used READ(12,*) instead of READ(12,101)
I tried with and without the 101 format(2x.....)

Is there any good websites which could explain all the different types of formats for this command?
 
Just a question, Do you have really the characters " in your input file ?

If yes then remove them and replace, in the same time, the commas by spaces.

At last, give us the exact error message (without trying to interpret it !)

François Jacq
 
Hi,
No I dont have the " in my code I just put them in to show where the code starts and stops. As for the error message I cant actually see it as the cmd window that I use for the code closes itself as soon as I run the code! If I could find a high speed camera maybe.....
 
Run cmd.exe and execute your code within that command windows. Then you will see the error message.

Could you also show the definition of variables in the module simParam please ?

François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top