CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   Main CFD Forum (http://www.cfd-online.com/Forums/main/)
-   -   Fortran 'list-directed I/O syntax error' (KIVA 3V) (http://www.cfd-online.com/Forums/main/65839-fortran-list-directed-i-o-syntax-error-kiva-3v.html)

ottbot June 28, 2009 11:29

Fortran 'list-directed I/O syntax error' (KIVA 3V)
 
Hi all, I've been given KIVA 3V code to get familiar with.. Being relatively new to Fortran and CFD, it's been a challenge getting this to run on OS X (using ifort 11)

Anyway, I'm having problems getting kiva to read itape5, this is the specific error:
Code:

forrtl: severe (59): list-directed I/O syntax error, unit 5, file /Users/rob/Desktop/kiva/kiva/itape5
This is happening starting here:
Code:

      read ( 5,*)      id(1),(presi(n),n=1,nreg)
      write(12,*) ' presi  ',(presi(n),n=1,nreg)
      read ( 5,*)      id(1),(tempi(n),n=1,nreg)
      write(12,*) ' tempi  ',(tempi(n),n=1,nreg)

Here is the relevant location in itape5:
Code:

  nreg      1
 presi,                4.9e+6
 tempi,                500.0
 tkei,      0.1
 scli,      0.0

nreg is read just above the fortran line above, then it chokes when trying to read presi, and I can't sort out why. I wrote a small stand alone to do the same thing, which seems to work fine.

Anyone have any ideas how to debug this?

Thanks!

Ananda Himansu June 28, 2009 20:17

It would appear that either (a) you put quotation marks (single or double) to delimit the words "nreg", "presi", "tempi", etc. in your input file itape5, assuming id(1) has been declared to be of type character, or (b) you change the read statement to a formatted read (instead of list-directed) and use the "a" format for the names. However, it is a mystery to me how you succeeded in reading the "nreg 1" line. Perhaps the commas play a role and id(1) is declared of type integer?

ottbot June 29, 2009 17:04

Thanks for the response.. What's most interesting, is I cannot duplicate the problem outside of KIVA.

I've made a test program using relevant snippets from kiva.. The following program works:
Code:

      program readtest
        character *8 id(4)
c        integer nreg
c        double precision presi(10), tempi(2)
        common /scrhoi/ nreg
        common /scrhor/ er(3),presi(3),tempi(2)


        open(unit=5, file='test')
        open(unit=12,file='out_test')
        read ( 5,600) id(1),nreg
        read ( 5,*)  id(1),(presi(n),n=1,nreg)

        write(12, *), ' presi  ',(presi(n),n=1,nreg)
        read ( 5,*)      id(1),(tempi(n),n=1,nreg)
        write(12, *) ' tempi  ',(tempi(n),n=1,nreg)

 600    format(a8,i5)
      end program readtest

I've defined the variables using the same common statement as in kiva (this is happening in rinput.F)

The program above has no problem reading the following file:
Code:

  nreg      1
 presi,  4.9e+6
 tempi,  500.0
 tkei,      0.1
 scli,      0.0

This executes without error, I can't figure out what's causing KIVA to fail.

Ananda Himansu June 29, 2009 19:41

The fact that your mini-program "readtest.f" works and executes without error does not mean that it conforms to the Fortran standard. Notice that in your mini-program (and presumably in the KIVA read statement that you left out), the character string nreg is read using an "a" format in the format statement labeled 600. That is why KIVA does not bomb out on that line, but rather on the next line. When you run "readtest.f", try writing out id(1) after each read statement.

Try running your mini-program "readtest.f" on an altered input file "test" which contains the lines

nreg 1
'presi', 4.9e+6
'tempi', 500.0
'tkei', 0.1
'scli', 0.0

ottbot June 30, 2009 03:26

Ah, thanks a lot Ananda.. If only I would have listened to you yesterday!

Putting quotes around 'presi', etc got kiva working. Thanks again.

Ananda Himansu June 30, 2009 06:59

You are welcome, Robert. Some compilers are forgiving, but the resulting non-conforming code is not portable to other compilers. However, this particular error was an input format error rather than a syntax error, and so I do not know whether setting a "strict conformance" flag on the compiler would have caused "readtest.f" to object to the original "test" input file.

habib58 May 28, 2011 18:20

kiva 3V.2x
 
I'm looking for the kiva 3V.2x code for editing and I'm very gratful if i will receive it.
I work on internal combustion for optimization of chamber...thanx:):):)

javisandovali June 11, 2013 12:09

Hi Robert,
I'm having a problem with Kiva 3v, I had the code running and I made the first simulation with no problem... but now I want to do the next simulation and for that purpose I've modified some parameters in the ITAPE5 (such as rpm, fuel mass, etc.) and after that when I try to run the simulation this error appears...
(I don't know why, I mean, I just changed a few numbers from the initial ITAPE5)

"dofio: [1015] Unknown error
logical unit 5, named 'itape5'
lately: reading sequential formatted external IO
part of last data: v 0.0 ^M|^J ca
Abort (core dumped)"

Can you please help me?
Thanks


All times are GMT -4. The time now is 05:51.