24小时热门版块排行榜    

CyRhmU.jpeg
查看: 10751  |  回复: 157
本帖产生 1 个 程序强帖 ,点击这里进行查看

woshilsh

荣誉版主 (职业作家)

优秀版主


小木虫(金币+0.5):给个红包,谢谢回帖交流
maomao还是那个程序,我想取i=N/2到i=3*N/2,为何会出错啊?
[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&say=各位版主辛苦了![/img][/url][/center]
61楼2009-11-28 17:22:48
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

woshilsh

荣誉版主 (职业作家)

优秀版主


小木虫(金币+0.5):给个红包,谢谢回帖交流
引用回帖:
Originally posted by maomao1210 at 2009-5-31 18:15:
[box=pink]

帖主寄言


其实语言并不是最重要的,形势的载体而已,fortran擅长工程计算,因为工作需要,偶尔用用fortran。在此开贴目的有二:

第一,希望能和大 ...

u1(j)=A*sqrt(1./2./ft)*exp(-((x/2./ft-B(i-N/2))/W)**2)
        u2(j)=A*sqrt(1./2./ft)*exp(-((x/2./ft+B(i-N/2))/W)**2)

那天那个程序我想去时间pi/2到3pi/2,所以i就得取N/2开始到3N/2结束
我直接在源代码上修改,就改了这两句,不知道对不?高手指点
[center][url=http://www.91cool.net/][img]http://id.91cool.net/sign/?name=小木虫印&say=各位版主辛苦了![/img][/url][/center]
62楼2009-11-28 17:33:55
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lindlar0078

木虫 (著名写手)

0._q,以及-1._q的含义是什么


小木虫(金币+0.5):给个红包,谢谢回帖交流
刚接触Fortran,看到程序中有
CBLOCK(I,NB)=W%CPTWFP(I+IADDPL,NB,NK,ISP)*GC(I)*(0._q,-1._q)
对于括号中(0._q,-1._q)的0._q,以及-1._q含义不是很清楚,希望解释一下,谢谢
一切从头开始!
63楼2009-12-11 10:28:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

cxc521

银虫 (正式写手)

新手

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
senlia(金币+1,VIP+0):第四次欢迎新虫cxc521 !嘿嘿! 12-12 10:06
大家好,我们老板让今天开始自学Fortran,以前只学过C语言,对Fortran一点接触没有,请问各位高手,如何学习Fortran 有点茫然呀 希望能给点好的经验和方法小弟在此先谢过了!
64楼2009-12-12 07:55:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

senlia

木虫 (小有名气)

★ ★ ★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
wangen994(金币+3,VIP+0):不错,呵呵 12-12 12:43
引用回帖:
Originally posted by cxc521 at 2009-12-12 07:55:
大家好,我们老板让今天开始自学Fortran,以前只学过C语言,对Fortran一点接触没有,请问各位高手,如何学习Fortran 有点茫然呀 希望能给点好的经验和方法小弟在此先谢过了!

fortran和c有本质的区别么?没有!
编程主要是一种思想 你会了这种思想 拿到什么语言都是一样的
你只需要花半个星期的时间 把fortran里面的语句和函数的写法弄清楚就行
比如c里面是for加大括号 matlab里面是for-end Fortran里面是do-enddo
还有就是fortran的指针不大方便 函数的参量传递是地址传递 不像c里面是值传递[不用指针的时候] 注意一下在fortran的子程序[函数或者子例程]里面不要随便改动参量的值
还有一些注意的地方 多练习一下就知道了
另外 可以直接学Fortran90 不用先学77 我觉得77让人头大
77里面很喜欢用goto 尽量少用[并不是不能用 因为偶尔用一下 程序反而会更清晰]

[ Last edited by senlia on 2009-12-12 at 10:13 ]
书到用时方恨少, 天涯何处无芳草.
65楼2009-12-12 10:11:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tina100

新虫 (初入文坛)

新手提问

★ ★
小木虫(金币+0.5):给个红包,谢谢回帖交流
senlia(金币+1,VIP+0):欢迎新虫!语句 你说的是编程么?用pause语句 你说的关闭是什么意思?运行的时候么?按ctrl+c 12-12 18:24
FORTRAN的.exe 文件用什么语句,可以让它在屏幕上定住,并且输入任意键可以关闭。急用!谢谢
人生就是奋斗的过程
66楼2009-12-12 17:50:49
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

tina100

新虫 (初入文坛)


小木虫(金币+0.5):给个红包,谢谢回帖交流
关闭就是输出界面关闭。
谢谢回答。
人生就是奋斗的过程
67楼2009-12-13 14:27:11
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

bluesine

铁杆木虫 (职业作家)

科苑小木虫


小木虫(金币+0.5):给个红包,谢谢回帖交流
请问format(10000f16.8)格式中的10000是什么意思,在这里控制什么格式的,不太明白,请专家致指点
板凳要做十年冷文章不发一个字
68楼2009-12-28 17:21:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

nono2009

超级版主 (文学泰斗)

No gains, no pains.

优秀区长优秀区长优秀区长优秀区长优秀版主


小木虫(金币+0.5):给个红包,谢谢回帖交流
引用回帖:
Originally posted by bluesine at 2009-12-28 17:21:
请问format(10000f16.8)格式中的10000是什么意思,在这里控制什么格式的,不太明白,请专家致指点

10000f16.8就是10000个f16.8的意思
这么多数据
69楼2009-12-28 17:25:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

yanggis

木虫 (著名写手)

小木虫GIS家族族长


小木虫(金币+0.5):给个红包,谢谢回帖交流
!1. Solving linear equations by QR decomposition/Gram-Schmidt and
        !                               QR decomposition/back-substitution.
        !2. Calculating the determinant of a matrix.
       
        program LIN_EQ
                implicit none

                         integer, parameter :: dbl=SELECTED_REAL_KIND(14), n=3, m=2
                         real(KIND=dbl) :: A(n,m), Q(n,m), R(m,m), QR(n,m), A_old(n,m), &
                                                         & b(n), x(m), DET
                         integer :: i

                A(1,1)=1 ; A(1,2)=1
                A(2,1)=0 ; A(2,2)=1
                A(3,1)=1 ; A(3,2)=1

                b(1)=6 ; b(2)=4 ; b(3)=6

                A_old = A

                CALL QR_GS(A, n, m, Q, R)
                CALL QR_BACK(Q, R, n, m, b, x)
                CALL QR_DETERMINANT(R, m, DET)

                call matout("A is", A, n, m)
                call matout("b is", b, n, 1)
                call matout("Q is", Q, n, m)
                call matout("R is", R, m, m)
                QR = MATMUL(Q,R)
                call matout("Q*R is", QR, n, m)
                call matout("x is", x, m, 1)

                if (n/=m) then
                   print '("The determinant of the matrix R is", f10.6)', DET
                   else
                          print '("The determinant of the matrix A is", f10.6)', DET
                endif

       

        end program LIN_EQ


        !Subroutine for QR decomposition by a modified Gram-Schmidt method
        subroutine QR_GS(A, n, m, Q, R)
        Implicit none

        integer, parameter :: dbl=SELECTED_REAL_KIND(14)
        integer :: n, m, i, j, k, l, i1
        real(KIND=dbl) :: A(n,m), Q(n,m), R(m,m)

        do i = 1, m
           R(i,i)=SQRT(DOT_PRODUCT(A(1:n,i),A(1:n,i)))
           do j = 1, n
                  Q(j,i) = A(j,i)/R(i,i)
           enddo
           do j = i+1, m
                  R(i,j)=DOT_PRODUCT(Q(1:n,i), A(1:n,j))
                  do k = 1, n
                         A(k,j) = A(k,j)-Q(k,i)*R(i,j)
                  enddo
           enddo
        enddo   

        end subroutine QR_GS

       
        !Subroutine for solving linear equations Ax=b => QRx=b by QR back-substitution.

        subroutine QR_BACK(Q, R, n, m, b, x)
        implicit none

        integer, parameter :: dbl=SELECTED_REAL_KIND(14)
        real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
        !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       
        !++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        integer :: n, m, i, k

        Q_T = TRANSPOSE(Q)
        b_ny = MATMUL(Q_T, b)

        x = 0.0

        do i = m, 1, -1
           do k = i+1, m
                  x(i) = x(i) - R(i,k)*x(k)
           enddo
           x(i) = (x(i) + b_ny(i))/R(i,i)
        enddo

        end subroutine QR_BACK

        !Subroutine for calculating the determinant of a matrix by QR decomposition.

        subroutine QR_DETERMINANT(R, m, DET)
        implicit none

         integer, parameter :: dbl=SELECTED_REAL_KIND(14)
         real(KIND=dbl) ::  R(m,m), DET
         integer :: m, i

        DET = 1

        do i = 1, m
        DET = DET*R(i,i)
        enddo

        end subroutine QR_DETERMINANT
却报如下错误:
:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: This name does not have a type, and must have an explicit type.   [N]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
----------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [N]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
----------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: This name does not have a type, and must have an explicit type.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
--------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
--------------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [N]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
--------------------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
----------------------------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [N]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
------------------------------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(78) : Error: A specification expression is invalid.   [M]
real(KIND=dbl) :: Q(n,m), R(m,m), x(m), b(n), Q_T(m,n), b_ny(m)
---------------------------------------------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(104) : Error: This name does not have a type, and must have an explicit type.   [M]
  real(KIND=dbl) ::  R(m,m), DET
------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(104) : Error: A specification expression is invalid.   [M]
  real(KIND=dbl) ::  R(m,m), DET
------------------------------^
D:\Fortran_App\QR_Decomposition\LIN_EQ.f90(104) : Error: A specification expression is invalid.   [M]
  real(KIND=dbl) ::  R(m,m), DET
--------------------------------^
高手帮忙看看吧。
70楼2009-12-30 10:21:54
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 maomao1210 的主题更新
普通表情 高级回复(可上传附件)
信息提示
请填处理意见