24小时热门版块排行榜    

查看: 2475  |  回复: 5

kardrine

新虫 (初入文坛)

[求助] Visual Studio 2012 已有1人参与

用的是Visual Studio 2012,调试的时候,只说有错误,不提示错在第几行了,怎么让它继续显示第几行呢?比如下面的小程序:
program attempt_initial_fai
      dimension fai(300,300)
      !open(101,file='E:\试验程序\one dimension random seed\test_fai.dat')
      open(101,file='E:\试验程序\one dimension random seed\fai.dat')
      call initial_data(fai(i,j))
      write(101,20) ((fai(i,j),j=1,300),i=1,300)
20    FORMAT (1X,300D15.6)
      !end do
      end program attempt_initial_fai
      
      subroutine initial_data(a(i,j))
      open(1,file='E:\试验程序\one dimension random seed\data1.dat')
      DO i=1,300
      READ(1,'(300D15.6)') fai(:,i)!//这个地方就实现了你的要求,冒号代表将从1~100,它是根据你声明部分的多少而定的   
      end do
      do i=1,300
          do j=1,300
                  a(i,j)=mod(a(i,j),1.0)
          end do
      end do
      close(1)
      return
      end subroutine

1里面是300*300的数据,想实现的是用子程序把1里面的值赋到二维数组fai(i,j)并输出到101里面。
还有,小弟用的是visual studio 2012,代码写出来提示错误,但是不提示在哪一行了,很苦恼。比如上面这段,就有一下错误。


错误        1         error #5082: Syntax error, found '(' when expecting one of: ) ,        E:\\mass of disorder\mass of disorder\Source1.for        
错误        2         error #5082: Syntax error, found ')' when expecting one of: , : ]        E:\\mass of disorder\mass of disorder\Source1.for        
错误        3         error #7271: Not a valid attribute for the DEC$ ATTRIBUTES directive.   [I]        E:\\mass of disorder\mass of disorder\Source1.for        
错误        4         error #6911: The syntax of this substring is invalid.   [FAI]        E:\\mass of disorder\mass of disorder\Source1.for        
错误        5        Compilation Aborted (code 1)        E:\试验程序\mass of disorder\mass of disorder\Source1.for        1      

但是1,2个错误都不提示在第几行了,很急 怎么办
回复此楼

» 猜你喜欢

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

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

【答案】应助回帖

★ ★ ★ ★ ★
感谢参与,应助指数 +1
kardrine(jjdg代发): 金币+1, 感谢参与,剩下的由lz发吧 2016-11-11 11:31:05
kardrine: 金币+4, ★★★★★最佳答案 2016-11-14 10:44:14
program attempt_initial_fai
    implicit none
      real*8::fai( 300,300 )
      integer i,j
      open( 101,file='E:\试验程序\one dimension random seed\test_fai.dat' )
      open( 101,file='E:\试验程序\one dimension random seed\fai.dat' )
      call initial_data( fai ) !//传递数组的时候,不能写成类似于fai(300,300),要写成fai
      write( 101,20 ) (( fai(i,j),j=1,300 ),i=1,300 )
20    FORMAT ( 1X,300D15.6 )
      !end do
    end program attempt_initial_fai
      
   
   
   
      subroutine initial_data( a )
      implicit none
      real*8::a( 300,300 )
      integer::i,j
      open( 1,file='E:\试验程序\one dimension random seed\data1.dat' )
      DO i=1,300
      READ( 1,'( 300D15.6 )' ) a( :,i )!//这个地方就实现了你的要求,冒号代表将从1~100,它是根据你声明部分的多少而定的   
      end do
      do i=1,300
          do j=1,300
                  a( i,j )=mod( a(i,j),1.0 )
          end do
      end do
      close( 1 )
      return
      end subroutine
PS:implicit none大法好,注意一定要用它。需要注意的是,这个程序并不严格,因为数组的传递正常是需要interface的,我暂时不想给你加太大的难度,写了之后怕你晕。你记住有这么回事就行了,等你熟悉了Fortran的语法,熟练写出程序后,你再看看书(其实我个人还是喜欢module的,但是说多了,恐怕你又晕了)。
Chemistry
2楼2016-11-11 08:59:24
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

kardrine

新虫 (初入文坛)

引用回帖:
2楼: Originally posted by 7152075 at 2016-11-11 08:59:24
program attempt_initial_fai
    implicit none
      real*8::fai( 300,300 )
      integer i,j
      open( 101,file='E:\试验程序\one dimension random seed\test_fai.dat' )
      open( 101,file='E:\ ...

刚才看了一下书,是说函数返回值为数组时,需要特别说明他们的“使用接口”,书上是有个例子,有点长,前辈把interface在这里给我加上吧,我对照着书看一下,既然遇到了,也不能忽略了,还有,我VS不提示错误行了,调试起来很费劲,能设置回来吗?短代码还能一行一行的看,长一点实在扛不住啊
3楼2016-11-14 10:47:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

iamshitizen

铜虫 (小有名气)

引用回帖:
3楼: Originally posted by kardrine at 2016-11-14 10:47:23
刚才看了一下书,是说函数返回值为数组时,需要特别说明他们的“使用接口”,书上是有个例子,有点长,前辈把interface在这里给我加上吧,我对照着书看一下,既然遇到了,也不能忽略了,还有,我VS不提示错误行了, ...

按照错误提示,貌似说的不是接口的问题。而且这么简短的一个程序,用不着搞interface什么的吧?
错误        1         error #5082: Syntax error, found '(' when expecting one of: ) ,     !====这个提示的意思是括号有问题。我理解可能是 ===READ( 1,'( 300D15.6 )' ) a( :,i ) ===这一行是不是有问题?  我自己写一般是“(300D15.6)”,用双引号,而不用单引号,而且读的时候一般也懒得给格式。
4楼2016-11-14 11:09:19
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

引用回帖:
3楼: Originally posted by kardrine at 2016-11-14 10:47:23
刚才看了一下书,是说函数返回值为数组时,需要特别说明他们的“使用接口”,书上是有个例子,有点长,前辈把interface在这里给我加上吧,我对照着书看一下,既然遇到了,也不能忽略了,还有,我VS不提示错误行了, ...

program attempt_initial_fai
    implicit none
    interface
    subroutine initial_data(a) !//加入接口
      real*8::a( : ,: )
      end subroutine initial_data
    end interface
    real*8::fai( 300,300 )
      integer i,j
      open( 101,file='E:\试验程序\one dimension random seed\test_fai.dat' )
      open( 101,file='E:\试验程序\one dimension random seed\fai.dat' )
      call initial_data( fai ) !//传递数组的时候,不能写成类似于fai(300,300),要写成fai
      write( 101,20 ) (( fai(i,j),j=1,300 ),i=1,300 )
20    FORMAT ( 1X,300D15.6 )
      !end do
      close( 101 )
      close( 102 )
    end program attempt_initial_fai
      

      subroutine initial_data( a )
      implicit none
      real*8::a(:,
      integer::i,j
      open( 1,file='E:\试验程序\one dimension random seed\data1.dat' )
      DO i=1,300
      READ( 1,'( 300D15.6 )' ) a( i ,!//这个地方就实现了你的要求,冒号代表将从1~100,它是根据你声明部分的多少而定的   
      end do
      do i=1,300
          do j=1,300
                  a( i,j )=mod( a(i,j),1.0 )
          end do
      end do
      close( 1 )
      return
      end subroutine
你一定是点击output右边的叉号,导致再无法再出现output错误输出窗口。重新调用出来的过程是tools->options->projects and solutions->general->挑上show output window when bulid starts具体如图1所示。PS:interface我建议你forget这个,建议你学习module,因此随着你会的知识增多,一旦子程序都要调用这个的话,都要加一个接口,十分麻烦。看推荐那个网站,有一期叫module的那个。还是建议你都看看吧。
Visual Studio 2012
2016-11-14_142053.png

Chemistry
5楼2016-11-14 14:45:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

7152075

铁杆木虫 (著名写手)

解决问题的方法比遇到的问题多

real*8: :,: )

      READ( 1,'( 300D15.6 )' ) a( i ,: )
笑脸处的代码分别是上面那两个。
Chemistry
6楼2016-11-14 14:46:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 kardrine 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 情人节自我反思:在爱情中有过遗憾吗? +5 瞬息宇宙 2026-02-15 6/300 2026-02-18 12:51 by 月下雪林
[找工作] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 i3cz6qj6l2 2026-02-17 3/150 2026-02-18 11:09 by lqtl9djx19
[考博] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 i3cz6qj6l2 2026-02-17 3/150 2026-02-18 10:54 by lqtl9djx19
[考研] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 i3cz6qj6l2 2026-02-17 3/150 2026-02-18 10:39 by lqtl9djx19
[考研] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-17 3/150 2026-02-18 08:53 by lqtl9djx19
[硕博家园] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-17 3/150 2026-02-18 08:38 by lqtl9djx19
[找工作] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +4 pnpwoqbg8f 2026-02-17 4/200 2026-02-18 07:55 by lotyj5cz79
[基金申请] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-16 4/200 2026-02-18 07:40 by lotyj5cz79
[考研] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +4 pnpwoqbg8f 2026-02-16 4/200 2026-02-18 07:38 by lotyj5cz79
[硕博家园] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +4 pnpwoqbg8f 2026-02-16 4/200 2026-02-18 07:23 by lotyj5cz79
[论文投稿] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +4 pnpwoqbg8f 2026-02-16 4/200 2026-02-18 07:08 by lotyj5cz79
[公派出国] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-16 3/150 2026-02-18 06:53 by lotyj5cz79
[论文投稿] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-17 3/150 2026-02-18 00:40 by tk2gfblvuz
[找工作] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-17 4/200 2026-02-18 00:23 by tk2gfblvuz
[公派出国] 售SCI一区文章,我:8 O5 51O 54,科目齐全,可+急 +3 pnpwoqbg8f 2026-02-17 3/150 2026-02-17 23:40 by tk2gfblvuz
[基金申请] 基金正文30页指的是报告正文还是整个申请书 +3 successhe 2026-02-16 4/200 2026-02-17 20:56 by successhe
[基金申请] 今年春晚有几个节目很不错,点赞! +5 瞬息宇宙 2026-02-16 6/300 2026-02-17 12:49 by jymy19840415
[微米和纳米] 球磨粉体时遇到了大的问题,请指教! 10+3 6sbiam 2026-02-12 15/750 2026-02-16 15:03 by tgzxzqj
[基金申请] 过年走亲戚时感受到了所开私家车的鄙视链 +3 瞬息宇宙 2026-02-15 5/250 2026-02-16 14:23 by aspect3000
[硕博家园] 江汉大学解明教授课题组招博士研究生/博士后 +3 cleverlyy 2026-02-12 3/150 2026-02-12 21:02 by qsdf1
信息提示
请填处理意见