Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement else语句后出现意外垃圾:(i==1.AND.1<;j<;L)_If Statement_Fortran_Fortran90 - Fatal编程技术网

If statement else语句后出现意外垃圾:(i==1.AND.1<;j<;L)

If statement else语句后出现意外垃圾:(i==1.AND.1<;j<;L),if-statement,fortran,fortran90,If Statement,Fortran,Fortran90,我正试图写一个程序,其中包含很多其他if语句。然而,我不明白这个错误是从哪里来的。任何帮助都将不胜感激 以下是我目前拥有的if块: if (i == 1 .AND. j==1) then E = E + A(i+1,j) + A(i,j+1) + A(L,j) + A(i,L) else if (i == 1 .AND. j==L) then E = E + A(i,j-1) + A(i+1,j) + A(i,1) + A(L,j) e

我正试图写一个程序,其中包含很多其他if语句。然而,我不明白这个错误是从哪里来的。任何帮助都将不胜感激

以下是我目前拥有的if块:

    if (i == 1 .AND. j==1) then
        E = E + A(i+1,j) + A(i,j+1) + A(L,j) + A(i,L)

    else if (i == 1 .AND. j==L) then
        E = E + A(i,j-1) + A(i+1,j) + A(i,1) + A(L,j)

    else if (i == L .AND. j == 1) then
        E = E + A(i,j+1) + A(i-1,j) + A(1,j) + A(i,L)

    else if (i == L .AND. j == L) then
        E = E + A(i,j-1) + A(i-1,j) + A(1,j) + A(i,1)

    else if (i == 1 .AND. 1 < j < L) then
        E = E + A(i+1,j) + A(i,j+1) + A(i,j-1) + A(L,j)

    else if (i == L .AND. 1 < j < L) then
        E = E + A(i-1,j) + A(i,j+1) + A(i,j-1) + A(1,j)

    else if (1 < i < L .AND. j == 1) then
        E = E + A(i-1,j) + A(i+1,j) + A(i,j+1) + A(i,L)

    else if (1 < i < L .AND. j == L) then
        E = E + A(i-1,j) + A(i+1,j) + A(i,j-1) + A(i,1)
    else
        E = E + A(i-1,j) + A(i+1,j) + A(i,j-1) + A(i,j+1)
    end if
如果(i==1.和.j==1)那么
E=E+A(i+1,j)+A(i,j+1)+A(L,j)+A(i,L)
否则如果(i==1.和.j==L)那么
E=E+A(i,j-1)+A(i+1,j)+A(i,1)+A(L,j)
否则,如果(i==L.和.j==1),则
E=E+A(i,j+1)+A(i-1,j)+A(1,j)+A(i,L)
否则如果(i==L.和.j==L)那么
E=E+A(i,j-1)+A(i-1,j)+A(1,j)+A(i,1)
否则如果(i==1.和.1
不断出现的错误是:

Ising.f90:56:15:

     else if (i == 1 .AND. 1 < j < L) then
           1
Error: Unexpected junk after ELSE statement at (1)
Ising.f90:59:15:

     else if (i == L .AND. 1 < j < L) then
           1
Error: Unexpected junk after ELSE statement at (1)
Ising.f90:62:15:

     else if (1 < i < L .AND. j == 1) then
             1
Error: Unexpected junk after ELSE statement at (1)
Ising.f90:65:15:

     else if (1 < i < L .AND. j == L) then
           1
Error: Unexpected junk after ELSE statement at (1)
Ising.f90:56:15:
否则如果(i==1.和.1
您不能使用
1
这样的表达式来确定
i
是否在1到L的范围内。 您需要使用两个不等式测试的交集。使用类似


else如果(1

您不能使用像
1
这样的表达式来确定
i
是否在1到L的范围内。 您需要使用两个不等式测试的交集。使用类似


else如果(1

这对选择病例的眼睛,或者在何处和其他地方会更容易一些。或者制作if结构,然后在其中进行j测试

在看不到其余代码的情况下,我只能猜测这可能类似于某些插值


如果数组是从(0:n+1)indiexed出来的,则可以在单个数学语句行上执行此操作。

对于选择大小写的眼睛,或者在何处和其他地方,这会稍微容易一些。或者制作if结构,然后在其中进行j测试

在看不到其余代码的情况下,我只能猜测这可能类似于某些插值


如果数组是从(0:n+1)indiexed出来的,则可以在单个数学语句行上执行此操作。

@VladimirF正如我提到的,它看起来像某种插值

@伊恩布什也提到了一些好的观点

也许。。。这是一个更平滑/插值器

更平滑的示例:

L = UBOUND(OldThing, 1)   !assumes it is square!
ALLOCATE(newthing(0:L+1, 0:L+1) )
DO I = 1, L
  DO J = 1, L
    NewThing(I,j) = OldThing(I,j)
  ENDDO 
ENDDO

! Probably a derivative to extrapolate the outliers is better...
! Kindergarten example below is for simplicity. 
DO I= 1, L
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
ENDDO

NewThing(0  ,  0) = OldThing(1,1)
NewThing(0,  L+1) = OldThing(1,L)
NewThing(L+1,  0) = OldThing(L,1)
NewThing(L+1,L+1) = OldThing(L,L)

!then one is always within the bounds... And the normal case is executed.
E = E + NewThing(I-1,j) + NewThing(i+1,j) + NewThing(i,j-1) + NewThing(i,j+1)

很可能新事物(1:1,1:1)的回归需要发生

@VladimirF正如我提到的,它看起来像是某种插值

@伊恩布什也提到了一些好的观点

也许。。。这是一个更平滑/插值器

更平滑的示例:

L = UBOUND(OldThing, 1)   !assumes it is square!
ALLOCATE(newthing(0:L+1, 0:L+1) )
DO I = 1, L
  DO J = 1, L
    NewThing(I,j) = OldThing(I,j)
  ENDDO 
ENDDO

! Probably a derivative to extrapolate the outliers is better...
! Kindergarten example below is for simplicity. 
DO I= 1, L
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
  NewThing(0,(I))= OldThing(1,I)
ENDDO

NewThing(0  ,  0) = OldThing(1,1)
NewThing(0,  L+1) = OldThing(1,L)
NewThing(L+1,  0) = OldThing(L,1)
NewThing(L+1,L+1) = OldThing(L,L)

!then one is always within the bounds... And the normal case is executed.
E = E + NewThing(I-1,j) + NewThing(i+1,j) + NewThing(i,j-1) + NewThing(i,j+1)

可能需要返回NewThing(1:L,1:L)

即使您使用的扩展接受逻辑和整数之间的比较,它也不会按照您的想法执行。如果您的意思是1,即使您使用的扩展接受逻辑和整数之间的比较,它也不会做您认为的事情。如果您的意思是1,那么在选定病例的眼睛上,或者在何处和其他地方,这会更容易一些。或者制作if结构,然后将j测试放在其中。或者,考虑到它看起来像周期性边界条件,将几乎肯定存在的I和j循环从2变为j,并将异常情况设置在循环之外,只需避免if/case/任何组合。这对选择案例的眼睛来说会更容易一些,或者在哪里和其他地方。或者制作if结构,然后在其中进行j测试。或者,假设它看起来像周期性的边界条件,让几乎肯定存在的I和j循环从2到j,并将异常情况设置在循环之外,只是避免if/case/无论什么,这如何回答关于错误的问题?这是一个评论吗?你会如何用WHERE重写它?我花了相当长的时间研究这个问题,但我仍然不知道。你怎么知道结果被分配给了某个数组?这是如何回答关于错误的问题的?这是一个评论吗?你会如何用WHERE重写它?我花了相当长的时间研究这个问题,但我仍然不知道。你怎么知道结果被分配到了某个数组?请不要将新答案作为反应发布,如果是关于同一主题的,你可以编辑当前答案。而且你对WHERE
的用法很奇怪
其中
用于数组表达式。请不要将新答案作为反应发布,如果与同一主题相关,您可以编辑当前答案。而且你对WHERE
的用法很奇怪<代码>其中
用于数组表达式。