Fortran代码不会写入文件

时间:2017-07-02 05:32:45

标签: fortran fortran77

我正在研究计算超音速喷嘴中最小喷嘴长度的程序(特征方法)。我似乎无法弄清楚为什么我的代码不会写入我的输出文件(行“write(6,1000)....)。我的代码如下:

      program tester
c----------------------------------------------------------------------c
      implicit real (a-h,o-z)
      integer count
      real kminus(0:100),kplus(0:100),theta(0:100),nu(0:100),mach(0:100)
     +     ,mu(0:100)
      open (5,file='tester.in')
      open (6,file='tester.out')
      read (5,*) me
      read (5,*) maxturn
      read (5,*) nchar
      read (5,*) theta0
      close(5)
c.....set count to 0 and calculate dtheta
      count=0
      dtheta=(maxturn-theta0)/nchar
c.....first characteristic
      do 10 an=1,nchar+1
         count=count+1
c........these are already known
         theta(count)=theta0+dtheta*(an-1)
         nu(count)=theta(count)
c........trivial, but we will "calculate" them anyways
         kminus(count)=2*theta(count)
         kplus(count)=0
c........we feed it nu(count) and get m out
         call pm_hall_approx(nu(count),m)
         mach(count)=m
c........does not work with sqrt(...) for some reason
         mu(count)=atan((1/(mach(count)**2)-1)**0.5)
         write (6,1000) count,kminus(count),kplus(count),theta(count)
     +                  ,nu(count),mach(count),mu(count)
   10 continue
c.....the other characteristics
      do 30 bn=1,nchar
         do 20 cn=1,(nchar+1-bn)
            count=count+1
c...........these are given
            kminus(count)=kminus(cn+bn)
            kplus(count)=-1*kplus(bn+1)
c...........if this is the last point, copy the previous values
            if (cn.eq.(nchar+1-bn)) then
               kminus(count)=kminus(count-1)
               kplus(count)=kplus(count-1)
            endif
c...........calculate theta and nu
            theta(count)=0.5*(kminus(count)+kplus(count))
            nu(count)=0.5*(kminus(count)-kplus(count))
c...........calculate m
            call pm_hall_approx(nu(count),m)
            mach(count)=m
            mu(count)=atan((1/(mach(count)**2)-1)**0.5)
            write (6,1000) count,kminus(count),kplus(count),theta(count)
     +                     ,nu(count),mach(count),mu(count)
   20    continue
   30 continue
      close(6)
      stop
 1000 format (11(1pe12.4))
      end
c======================================================================c

      include 'pm_hall_approx.f'

我的子程序在这里给出:

      subroutine pm_hall_approx(nu,mach)
c----------------------------------------------------------------------c
c     Given a Mach number, use the Hall Approximation to calculate the 
c     Prandtl-Meyer Function.
c----------------------------------------------------------------------c
      implicit real (a-h,o-z)
c.....set constants
      parameter (a=1.3604,b=0.0962,c=-0.5127,d=-0.6722,e=-0.3278)
      parameter (numax=2.2769)
      y=nu/numax
      mach=(1+a*y+b*y*y+c*y*y*y)/(1+d*y+e*y*y)
      return
      end

以下是tester.in

的内容
 2.4     = mache
 5.0     = maxturn
 7       = nchar
 0.375    = theta0

1 个答案:

答案 0 :(得分:0)

在fortran中,单元号6保留用于屏幕。切勿将其用作单元号。尝试将其更改为其他数字,例如write(7,1000),然后它应该可以正常工作。