slyu 发表于 2006-8-21 22:16:54

请教关于gfortran的输出问题!

我用gfortran运行一段程序,用输出语句write(*,*)老是有问题,请高手指点!
程序如下:
    program test_sbhdl

        implicit doubleprecision (a-h,o-z)

        ! Variables

    character algorithm*3,direction*1,vc
        dimension a(6),ica(6),ira(0:4),ncqa(1,4)
        dimension ncqsub(1)
        common nout

        ! Body of test_sbhdl

    nout=20
        write(*,*)"aaa"
        open(unit=nout,file="information.txt",status="unknown",form="formatted")
        ma=6;msa=4;nsa=4;mncq=1
        a(1)=0.25d0;a(2)=-0.25d0;a(3)=0.5d0;a(4)=0.5d0;a(5)=-0.25d0;a(6)=0.25d0
        ica(1)=1;ica(2)=2;ica(3)=3;ica(4)=2;ica(5)=3;ica(6)=4
        ira(0)=0;ira(1)=1;ira(2)=3;ira(3)=5;ira(4)=6
        ncqa(1,1)=2;ncqa(1,2)=0;ncqa(1,3)=0;ncqa(1,4)=-2
        write(*,*)"bbb"
        open(unit=6,file="HBL002",status="unknown",form="unformatted")
        write(*,*)"ccc"
        write(6)ma,msa,nsa,mncq
    write(6)ncqa
        write(6)a
        write(6)ica
        write(6)ira
        close(6)
   
        end
其中,前两个write(*,*)可以在屏幕上打印出来,而第三个有问题。
出错信息:
At line 24 of file 666.f90
Fortran runtime error: Format present for UNFORMATTED data transfer
我文件名取的是666.f90
同样是这段程序用compag visual fortran 运行就没问题。
我想不通是什么问题,请高手指点!

slyu 发表于 2006-8-21 22:33:51

open(unit=6,file="HBL002",status="unknown",form="unformatted")
我把unit=6改成unit=4就没有错误了,
难道unit=6有特殊的用途?还是编译器的bug?

freepu 发表于 2006-8-22 03:09:04

Unit numbers 0, 5, and 6 are associated with the standard error, standard input (keyboard), and standard output files (screen)
页: [1]
查看完整版本: 请教关于gfortran的输出问题!