heackjin
heackjin

Reputation: 23

Fortran using write(6,*) statement

I'm studying Fortran programs.

When I use the write statements below, my code builds fine but it doesn't run as expected, especially READ(6,*).

What could be the problem and how can I fix it? Thanks!

      OPEN(UNIT= 5, FILE='inp.dat')
      OPEN(UNIT= 10, FILE='apr1400.dat')   
      OPEN(UNIT= 11, FILE='ulpu2001.dat')  
      OPEN(UNIT= 12, FILE='aprslice.dat')
      OPEN(UNIT= 6, FILE='HEATFX.dat')
      OPEN(UNIT= 13, FILE='HEATFX1.dat')
      OPEN(UNIT= 14, FILE='HEATFX2.dat')
      OPEN(UNIT= 15, FILE='HEATFX3.dat')  
      OPEN(UNIT= 7, FILE='out.dat')
      OPEN(UNIT= 8, FILE='check.dat')
      OPEN(UNIT= 9, FILE='checkout.dat')

      READ (5, *)IPLANT
      IF(IPLANT.EQ.1)IIP=10
      IF(IPLANT.EQ.2)IIP=11
      IF(IPLANT.EQ.3)IIP=12

      READ (IIP, 250) TITLE
250   FORMAT(A20)

      READ (IIP, 300) ISLICE
300   FORMAT(I1)

      READ (IIP, 400) RADIUS, XLCYL, DIACYL, DEPTH, GAP, AINLET
      IF(ISLICE.EQ.0)READ (IIP, 400) POWER

      READ (6, *)HEATFX
      IF(HEATFX.EQ.1)llk=13
      IF(HEATFX.EQ.2)llk=14
      IF(HEATFX.EQ.3)llk=15
      READ(llk, 400) HEATFX

      READ (IIP, 400) PSYS
      READ (IIP, 400) DTSUBI

      READ (IIP, 400) XKLOSSI, XKLOSSC
      READ (IIP, 405) IPARA

Upvotes: 2

Views: 1583

Answers (1)

Simon
Simon

Reputation: 32943

Unit numbers 0, 5, and 6 are associated with the standard error, standard input, and standard output files

Unit 6 is a special one, that might well be the problem here.

In general, try to use larger numbers for file units. I typically use 100, 101, 102, etc.

Upvotes: 2

Related Questions