Fortran Coder

查看: 17339|回复: 8
打印 上一主题 下一主题

[求助] 崩溃了...不太会使用sum和random函数,所以总是报错

[复制链接]

11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
跳转到指定楼层
楼主
发表于 2018-8-27 16:24:27 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
[Fortran] 纯文本查看 复制代码
subroutine read_obstacles(obst)
        implicit none
        include "head.inc"
      EXTERNAL sum
      complex h(51,51),h1(51,51),F(51,51),F1(51,51),
     &obst(51,51)
      integer k,l,P,Q
      integer x,y

        do 11 k= 1, 51
                do 10 l = 1, 51
              F(P,Q)=0.675*0.675*(exp(-2.3*((k/50)*(k/50)+(l/10)* 
     &         (l/10))**0.5))*((-1)**(2*k*P/50+2*l*Q/50))
              if (k==(1,51).and.l==(1,51))then
                  F1(P,Q)=sum(F,1,[1:51,1:51])
      end if
   10 continue
   11 continue

      do 20 P=1,51
          do 21 Q=1, 51
              h(k,l)=1/10000*F1(P,Q)*(-1)**((k*P+l*Q)/26)
               if (P==(1,51).and.Q==(1,51))then
               h1(k,l)=sum(h,1,[1:51,1:21])
      end if
   21 continue
   20 continue

      do 22 k= 1, 51
                do 23 l = 1, 51
              call RANDOM_SEED()
              call RANDOM_NUMBER()
              obst(lx,ly)=h1(k,l)*random_number(lx,ly)
              if (lx==(1,51).and.ly==(1,51))then
              obst(x,y)=sum(obst,1,[1:51,1:21])
      end if 
   23 continue
   22 continue

        end

分享到:  微信微信
收藏收藏 点赞点赞 点踩点踩

11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
沙发
 楼主| 发表于 2018-8-27 16:24:46 | 显示全部楼层
错误        1         error #6404: This name does not have a type, and must have an explicit type.   [SUM]        E:\sia\2018.8月\coding\chap2\chap2\main.for        178        
警告        2         warning #7532: The number of arguments is incompatible with intrinsic procedure, assume 'external'.   [RANDOM_NUMBER]        E:\sia\2018.8月\coding\chap2\chap2\main.for        197       

错误        3         error #6404: This name does not have a type, and must have an explicit type.   [RANDOM_NUMBER]        E:\sia\2018.8月\coding\chap2\chap2\main.for        200       

错误        4         error #5508: Declaration of routine 'READ_PARAMETERS' conflicts with a previous declaration        E:\sia\2018.8月\coding\chap2\chap2\main.for        124       


11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
板凳
 楼主| 发表于 2018-8-27 16:26:31 | 显示全部楼层
啊真是被这个程序心态搞崩了

11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
地板
 楼主| 发表于 2018-8-28 10:49:08 | 显示全部楼层
fcode 发表于 2018-8-28 07:38
EXTERNAL sum
这句去掉

sum就是想把从1到51的所有情况的值相加....我也搞乱了...查了好多地方也没搞明白这个sum到底应该怎么用。是只能用在数组中吗?

11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
5#
 楼主| 发表于 2018-8-28 11:11:19 | 显示全部楼层
fcode 发表于 2018-8-28 11:02
对,只能用于数组。
如果第一个参数是二维数组,你可以指定在第几维上进行累加。
如果在第一维,那么结果就 ...

系统提示说random_number的数据类型参数是无效的...可是我已经call过了诶...

11

帖子

4

主题

0

精华

入门

F 币
79 元
贡献
41 点
6#
 楼主| 发表于 2018-8-29 14:23:09 | 显示全部楼层
fcode 发表于 2018-8-28 14:57
给出代码,错误提示

现在已经没错误了,就是调试又断点,可能是逻辑上的错误。谢谢您前辈!这几天给了我很多指导!麻烦您了!嘻嘻
您需要登录后才可以回帖 登录 | 极速注册

本版积分规则

捐赠本站|Archiver|关于我们 About Us|小黑屋|Fcode ( 京ICP备18005632-2号 )

GMT+8, 2024-5-20 04:52

Powered by Tencent X3.4

© 2013-2024 Tencent

快速回复 返回顶部 返回列表