24小时热门版块排行榜    

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

zyj8119

木虫 (著名写手)

[交流] 【求助】此程序也是没有问题了,但是依然运行不出结果 已有2人参与

CODE:
!  Console5.f90
!
!  FUNCTIONS:
!  Console5 - Entry point of console application.
!

!****************************************************************************
!
!  PROGRAM: Console5
!
!  PURPOSE:  Entry point for the console application.
!
!****************************************************************************

   
    !
MODULE data
INTERFACE OPERATOR(*)
  MODULE PROCEDURE star
END INTERFACE
TYPE matrix
  INTEGER::m,n
  INTEGER,DIMENSION(:,:),POINTER::a
END TYPE matrix
CONTAINS
  FUNCTION star(mt1,mt2) RESULT(mproduct)
  TYPE(matrix),INTENT(IN)::mt1,mt2
  TYPE(matrix)::mproduct
  INTEGER::i,j,k
  IF(mt1.n/=mt2.n)THEN
    mproduct.m=0;mproduct.n=0
    ALLOCATE(mproduct%a(0,0))
  ELSE
    mproduct.m=mt1.m;mproduct.n=mt2.n
    ALLOCATE(mproduct%a(mt1.m,mt2.n))
    DO i=1,mt1.m
     DO j=1,mt2.n
      mproduct.a(i,j)=0
      DO k=1,mt1.n
      mproduct.a(i,j)=mproduct.a(i,j)+mt1.a(i,k)*mt2.a(k,j)
      END DO
     END DO
     END DO
    END IF
    END FUNCTION star
   END MODULE data
   !
     
     program Console5
    USE data
    TYPE(matrix)::mx1,mx2,mx
    INTEGER,TARGET::a1(2,4),a2(4,2)
    OPEN(1,FILE='myf1.out')
    a1=RESHAPE((/1,3,5,7,2,4,6,8/),(/2,4/))
    a2=RESHAPE((/2,4,6,8,1,3,5,7/),(/4,2/))
    mx1=matrix(2,4,a1);mx2=matrix(4,2,a2);mx=mx1*mx2
    WRITE(1,'(2I5)')((mx.a(i,j),j=1,2),i=1,2)
    end program Console5
   
  
  

我使用的是IVF,以前用的都是CVF,应该跟编译器关系不大吧?
回复此楼

» 猜你喜欢

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

好好学习,天天向上。
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

snoopyzhao

至尊木虫 (职业作家)

★
小木虫(金币+0.5):给个红包,谢谢回帖交流
下面是我编译时的输出:

gfortran -Wall zz.f90

zz.f90:30.8:

  IF(mt1.n/=mt2.n)THEN
        1
Error: Syntax error in IF-expression at (1)
zz.f90:31.4:

    mproduct.m=0;mproduct.n=0
    1
Error: Unclassifiable statement at (1)
zz.f90:31.17:

    mproduct.m=0;mproduct.n=0
                 1
Error: Unclassifiable statement at (1)
zz.f90:33.6:

  ELSE
      1
Error: Unexpected ELSE statement at (1)
zz.f90:34.4:

    mproduct.m=mt1.m;mproduct.n=mt2.n
    1
Error: Unclassifiable statement at (1)
zz.f90:34.21:

    mproduct.m=mt1.m;mproduct.n=mt2.n
                     1
Error: Unclassifiable statement at (1)
zz.f90:35.27:

    ALLOCATE(mproduct%a(mt1.m,mt2.n))
                           1
Error: Invalid form of array reference at (1)
zz.f90:36.14:

    DO i=1,mt1.m
              1
Error: Syntax error in DO statement at (1)
zz.f90:37.15:

     DO j=1,mt2.n
               1
Error: Syntax error in DO statement at (1)
zz.f90:38.6:

      mproduct.a(i,j)=0
      1
Error: Unclassifiable statement at (1)
zz.f90:39.16:

      DO k=1,mt1.n
                1
Error: Syntax error in DO statement at (1)
zz.f90:40.6:

      mproduct.a(i,j)=mproduct.a(i,j)+mt1.a(i,k)*mt2.a(k,j)
      1
Error: Unclassifiable statement at (1)
zz.f90:41.9:

      END DO
         1
Error: Expecting END FUNCTION statement at (1)
zz.f90:42.8:

     END DO
        1
Error: Expecting END FUNCTION statement at (1)
zz.f90:43.8:

     END DO
        1
Error: Expecting END FUNCTION statement at (1)
zz.f90:44.7:

    END IF
       1
Error: Expecting END FUNCTION statement at (1)
zz.f90:50.12:

    USE data
            1
Fatal Error: Can't open module file 'data.mod' for reading at (1): No such file or directory
gfortran.exe: Internal error: Aborted (program f951)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
7楼2010-09-11 22:20:04
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 8 个回答

snoopyzhao

至尊木虫 (职业作家)

zyj8119(金币+10):应该没有问题啊。。。 2010-09-11 15:29:28
你这个程序我用 gfortran 都不能编译,为什么?
2楼2010-09-10 22:16:14
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

snoopyzhao

至尊木虫 (职业作家)

的确不能编译,gfortran 会提示 IF(mt1.n/=mt2.n)THEN 这一行有错误,当然,还有很多很多的错误。我也不知道是怎么回事儿,因为我对 f90 不熟悉……
3楼2010-09-11 21:54:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)

引用回帖:
Originally posted by snoopyzhao at 2010-09-11 21:54:24:
的确不能编译,gfortran 会提示 IF(mt1.n/=mt2.n)THEN 这一行有错误,当然,还有很多很多的错误。我也不知道是怎么回事儿,因为我对 f90 不熟悉……

我记得gfortran只能编译F77,F90需要用ifort.
好好学习,天天向上。
4楼2010-09-11 21:56:07
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 龙 兔 虎 猫 高级回复 (可上传附件)
信息提示
请填处理意见