小编Kis*_*ain的帖子

如何终止do循环?

我正在编写一个非常基本的Fortran代码来创建Ising模型.但是,我陷入了最后一步 - 重复计算直到达到最稳定的状态.

do
!Calculation (omitted here)
!Making a decision
if (E1 /= -64) then             !not yet stable
    if(dE > 0.0) then       
    call seed
    call random_number(prob)        ! random generate a number which is 0 <= Prob <= 1      
    Print *, prob
        if(Prob < exp(-dE/T)) then
                        !do nothing as the flip was made
        else
        mat(b,c) = -mat(b,c)        !flip the sign back, i.e. reject the change; only accept with probability of exp(-dE/T)
        end if
    else
    end if                  !Since the sign has changed …
Run Code Online (Sandbox Code Playgroud)

fortran loops gfortran

2
推荐指数
1
解决办法
837
查看次数

标签 统计

fortran ×1

gfortran ×1

loops ×1