Fortran Coder

利用format 输出矩阵时如何将format里面的10直接变成N

查看数: 353 | 评论数: 2 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2024-8-19 16:21

正文摘要:

[Fortran] 纯文本查看 复制代码  Module m_wik   Contains   Subroutine Wik_()   Implicit none   Integer,parameter::N=10   Integer::a=0,b=0,i,k, ...

回复

huhelong 发表于 2024-8-19 16:45:13

对了,就是这个,非常感谢,解决了
Transpose 发表于 2024-8-19 16:30:17
ifort可以用扩展
[Fortran] 纯文本查看 复制代码
  Module m_wik
  Contains
  Subroutine Wik_()
  Implicit none
  Integer,parameter::N=10
  Integer::a=0,b=0,i,k,j,c,d
  real*8::G(N),M(N),Wik(N,N),x(N),y(N),z(N),H,pi=acos(-1.0),L=16

  Do i=1,N
    x(i)=(L/2)*(1-cos(((i-1.0)/(N-1.0))*pi))
  END Do
  open(unit=16,file='X.txt')
  write(16,105)x
105 format(T4,'x=',10(/F21.8))
  close(16)
  y=x
  z=x
  DO
100 a=a+1
    Do
      b=1+b
      if (a==b)then
        i=a
        k=b
        Wik(i,k)=sum(1/(x(i)-y),y/=x(i))
        if(a==N.and.b==N)then
          exit
        end if
      end if
      if(a/=b.and.b<=N)then
        i=a
        k=b
        G(i)=product(x(i)-y,y/=x(i))
        M(k)=product(z(k)-y,y/=z(k))
        H=1/(x(i)-x(k))
        Wik(i,k)=H*G(i)/M(k)
      end if
      if (b==N)then
        b=0
        Goto 100
      end if
    end do
    exit
  end do
  open(unit=15,file='Wik.txt')
  write(15,104)((Wik(c,d),d=1,N),c=1,N)!写入Wik
104 format(10(F20.10,2x))
  close(15)
  end Subroutine Wik_
  end Module m_wik


gfortran目前没什么直接的语法,需要用字符串自己造一个

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

GMT+8, 2024-9-21 18:51

Powered by Tencent X3.4

© 2013-2024 Tencent

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