阵列可能没有任何理由改变其元素? - Fortran 77

时间:2015-11-23 09:07:14

标签: arrays fortran fortran77

我在fortran中很新,所以也许这可能是一个愚蠢的问题。

我遇到一个似乎没有任何理由改变其元素的数组的问题。我刚刚绘制了数组,您可以看到它不应该改变,但显然它确实如此:

代码很长,我只粘贴有关数组的部分。基本上从主代码中我调用了一个soubroutine,它对元素'kkk'进行了一些计算。如果颗粒的轴低于一定量,则将颗粒设置为死并存储在名为DEADGR的数组中,该数组是更改元素的数组。

 c     TOTAL COUNTER OF DEAD GRAINS

       NDEADGRTOTAL=0

 C     SET TO 0 THE COUNTER OF DEAD GRAINS IN STEP
       NDEADGR=0
       NDEADGRTOTALOLD=NDEADGRTOTAL

       DO NN=1,NLIVEGR
           KKK=LIVEGR(NN)
           CALL GROWTH(KKK,IDEAD)
  C      IF THE GRAIN HAS TO BE ELIMINATED STORE IN ARRAY DEADGRAINS

        IF (IDEAD.EQ.1) THEN
              NDEADGR=NDEADGR+1 !DEAD GRAINS IS STEP
              NDEADGRTOTAL=NDEADGRTOTAL+1 !TOTAL DEAD GRAINS
              DEADGR(NDEADGRTOTAL)=KKK !STORE THE ID OF THE DEAD GRAIN
        END IF            
  END DO

这是子程序:

  SUBROUTINE GROWTH(KKK,IDEAD)

  INCLUDE 'vpsc7.dim'

  REAL RO, GRV, DELTAX, NEWVOL, DUMMYONE, OLDVOL, toll
  integer idead

  toll=1e-5

C     GET VARIABLES USED IN THE ROUTINE
  RO=DSLDNSTY(KKK)
  OLDVOL=VOL(KKK)

  IDEAD=0

C     CALCULATE GRAIN BOUNDARY VELOCITY
  GRV=MOB*0.5*MU*BURG*BURG*(AVGDSLDNSTY-RO)
  DELTAX=2*GRV*TINCR      !VARIATION IN LENGHT OF AXES

C     GET ACTUAL AXES LENGHT OF GRAIN KKK      
  AX1GR=AXISGR(0,1,KKK)
  AX2GR=AXISGR(0,2,KKK)
  AX3GR=AXISGR(0,3,KKK)

C     UPDATE AXES
  AX1GR=AX1GR+DELTAX
  AX2GR=AX2GR+DELTAX
  AX3GR=AX3GR+DELTAX

C     IF ONE OF THE AXIS IS NEGATIVE THE GRAIN IS SET TO DEAD
  if ((AX1GR.LE.toll).OR.(AX2GR.LE.toll).OR.(AX3GR.LE.toll)) then
        IDEAD=1
        RETURN
  end if

C     CALCULATE NEW VOLUME
  NEWVOL=(4./3.)*PI*AX1GR*AX2GR*AX3GR

C     CALCULATE THE GROWTH FACTOR
  DUMMYONE=NEWVOL/OLDVOL

C     ASSIGN VARIABLES BEFORE EXIT FROM SUBROUTINE
  VOLGRGROWTH(KKK)=NEWVOL
  GRGRWTHFAC(KKK)=DUMMYONE


  RETURN
  END

我使用英特尔Parallel Studio XE 2015。

0 个答案:

没有答案