24小时热门版块排行榜    

CyRhmU.jpeg
查看: 4096  |  回复: 4
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

庐山活水

铜虫 (小有名气)

[求助] fortran含有module程序的编译已有2人参与

module types
    implicit none
    type :: personal
        character(len=6)::first
        character::mi
        character(len=6)::last
        character(len=6)::street
        character(len=6)::city
        character(len=6)::state
        integer::zip
    end type personal

end module types
PROGRAM my
   use types
   integer::status,count=0
   character(len=12)::filename
   type(personal),dimension(10)::a
   type(personal)::temp
   write(*,*)'enter the name of the file;'
   read(*,*)  filename
   open (unit=8,file=filename,status='old',action='readwrite',iostat=status)
   openfile: if (status==0) then
               do
                 read(8,110,iostat=status) temp
                    110 format(A6,1X,A,1X,A6,1X,A6,1X,A6,1X,A6,I3)
                  if(status/=0) exit
                      count=count+1
                      a(count)=temp
                  end if
                write(*,*) 'the all:',a
                write(*,*) 'the a(10:',a(1)
              else openfile
                write(*,100)status
                  100 format (1x,'the file open failed----iostat=',i2)
            end if  openfile
            close(unit=8)
END PROGRAM my

编译出现错误:fatal error:types.mod is not a GUN fortran module file

请问这是什么地方出问题了?谢谢
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

自信人生二百年,会当击水三千里
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

luxier

新虫 (初入文坛)

引用回帖:
3楼: Originally posted by linrn at 2014-04-09 21:21:50
就程序中的问题不说了

将module定义单独建立一个文件。

好像gfortran需要这样做。

请问用什么文件类型?怎么和主程序关联?我用Inc文件写的module,然后在program开始前使用“        include 'INPUT\INPARA\CModule.inc'
”来进行调用,但是总是提示错误,不能在定义时赋初值。
4楼2018-03-01 20:44:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 5 个回答

fish.yfyh

铜虫 (小有名气)

【答案】应助回帖

(1) 貌似你的代码有点问题, 将a(count)=temp下一行的end if改为end do
(2) 用intel fortran编译器, 我的机子上可以编译过。
2楼2014-04-08 20:16:00
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

linrn

至尊木虫 (著名写手)

【答案】应助回帖

就程序中的问题不说了

将module定义单独建立一个文件。

好像gfortran需要这样做。
3楼2014-04-09 21:21:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

linrn

至尊木虫 (著名写手)

定义时赋值,要在参数前加parameter::

发自小木虫Android客户端
5楼2018-03-02 07:07:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见