zamaniM
Programmer
- Jul 10, 2011
- 12
Hi.
This code includes an Iteration process. The problem is in the section 4 and using "cycle".with cycle the output files are empty,but with using GO TO they aren't empty but all outputs are zero.how should i use 'cycle' and why they are zero?
!**************************************************************** 1 *******************************************************************************************
REAL ::i,j,d_time
REAL ,DIMENSION ( 14 )::a_ROC
REAL ,DIMENSION (6:21,14)::OX_P,OX_diff_P,d_cum,ROC_P,RP_P
REAL ,DIMENSION ( 25,14 )::K_1,K_3
REAL ,DIMENSION ( 25,14 )::K_2,K_4,K_5,K_6,K_7
REAL ,DIMENSION ( 6:21,14)::Initial_NO,Initial_NO2,Initia_oz
REAL ,DIMENSION (6:21,14)::OZ_P,NO_P,NO2_P,OZ_P_NEW,NO_P_NEW,NO2_P_NEW
REAL ,DIMENSION (7:21,14)::Er_NO,Er_NO2,Er_Oz,POS_Er_NO,POS_Er_NO2,POS_Er_Oz, Relative_POS_NO, Relative_POS_NO2, Relative_POS_oz, SUM_Relative
!****************************************************************************************************************************************************************
d_time=60
!******************************* 2 ***********************************
OPEN(1,file='k_1.txt',status='old')
OPEN(2,file='K_2.txt',status='old')
OPEN(3,file='K_3.txt',status='old')
OPEN(4,file='K_4.txt',status='old')
OPEN(5,file='K_5.txt',status='old')
OPEN(6,file='K_6.txt',status='old')
OPEN(7,file='K_7.txt',status='old')
OPEN(8,file='a_ROC.txt',status='old')
OPEN(9,file='Initial Try NO.txt',status='old')
OPEN(10,file='Initial Try NO2.txt',status='old')
OPEN(11,file='Initial Try oz.txt',status='old')
OPEN(12,file='d_cum.txt',status='old')
OPEN(13,file='ROC_Prediction.txt')
OPEN(14,file='RP_Prediction.txt')
OPEN(15,file='NO_P.txt')
OPEN(16,file='NO2_P.txt')
OPEN(17,file='OZ_P.txt')
OPEN(18,file='Er_NO.txt')
OPEN(19,file='Er_NO2.txt')
OPEN(20,file='Er_Oz.txt')
OPEN(21,file='POS_Er_NO.txt')
OPEN(22,file='POS_Er_NO2.txt')
OPEN(23,file='POS_Er_Oz.txt')
OPEN(24,file='SUM_Relative.txt')
!**********************************************************************
!******************************** 3 **********************************
DO i=1,25
READ(1,*) (K_1(i,j),j=1,14)
READ(2,*) (K_2(i,j),j=1,14)
READ(3,*) (K_3(i,j),j=1,14)
READ(4,*) (K_4(i,j),j=1,14)
READ(5,*) (K_5(i,j),j=1,14)
READ(6,*) (K_6(i,j),j=1,14)
READ(7,*) (K_7(i,j),j=1,14)
END DO
DO j=1,14
READ(8,*) (a_ROC(j))
END DO
DO i=6,21
READ(9,*) (Initial_NO(i,j),j=1,14)
READ(10,*)(Initial_NO2(i,j),j=1,14)
READ(11,*)(Initia_oz(i,j),j=1,14)
END DO
DO i=6,21
READ(12,*)(d_cum(i,j),j=1,14)
END DO
DO i=6,21
DO j=1,14
NO_P_NEW(i,j)=Initial_NO(i,j)
NO2_P_NEW(i,j)=Initial_NO2(i,j)
OZ_P_NEW(i,j)=Initia_oz(i,j)
END DO
END DO
!******************************************************************************
!************************************************************* 4 ****************************************************************************
DO j=1,14
OX_P(6,j)=OZ_P_NEW(6,j)-(2*NO_P_NEW(6,j))-NO2_P_NEW(6,j)
OX_diff_P(6,j)=0
ROC_P(6,j)=0
RP_P(6,j)=0
END DO
DO j=1,14
DO i=7,21
DO
NO_P(i,j)= NO_P_NEW(i,j)
NO2_P(i,j)=NO2_P_NEW(i,j)
OZ_P(i,j)= OZ_P_NEW(i,j)
OX_P(i,j)=OZ_P(i,j)-(2*NO_P(i,j))-NO2_P(i,j)
OX_diff_P(i,j)= OX_P(i,j)- OX_P(i-1,j)
ROC_P(i,j)=OX_diff_P(i,j)/(a_ROC(j)*d_cum(i,j))
RP_P(i,j)=K_1(i,j)*ROC_P(i,j)/((K_2(i,j)*NO_P(i,j))+(2*K_6(i,j)*NO2_P(i,j)))
OZ_P_NEW(i,j)=(((k_3(i-1,j)*NO2_P(i-1,j))-(K_4(i-1,j)*NO_P(i-1,j)*OZ_P(i-1,j)))*d_time )+OZ_P(i-1,j)
NO_P_NEW(i,j)=(((K_3(i-1,j)*NO2_P(i-1,j))-(K_4(i-1,j)*NO_P(i-1,j)*OZ_P(i-1,j))-(K_2(i-1,j)*RP_P(i-1,j)*NO_P(i-1,j)))*d_time)+NO_P(i-1,j)
NO2_P_NEW(i,j)=(((K_2(i-1,j)*RP_P(i-1,j)*NO_P(i-1,j))+(K_2(i-1,j)*NO_P(i-1,j)*OZ_P(i-1,j))-(K_3(i-1,j)* NO2_P(i-1,j))-(K_6(i-1,j)*RP_P(i-1,j)* NO2_P(i-1,j))-(K_7(i-1,j)*RP_P(i-1,j)*NO2_P(i-1,j)))*d_time)+NO2_P(i-1,j)
Er_NO(i,j)=NO_P_NEW(i,j)-NO_P(i,j)
Er_NO2(i,j)=NO2_P_NEW(i,j)-NO2_P(i,j)
Er_Oz(i,j)=OZ_P_NEW(i,j)-OZ_P(i,j)
POS_Er_NO(i,j)=ABS(Er_NO(i,j))
POS_Er_NO2(i,j)=ABS(Er_NO2(i,j))
POS_Er_Oz(i,j)=ABS(Er_Oz(i,j))
Relative_POS_NO(i,j)=(Er_NO(i,j))/NO_P_NEW(i,j)
Relative_POS_NO2(i,j)=(Er_NO2(i,j))/NO2_P_NEW(i,j)
Relative_POS_oz(i,j)=(Er_Oz(i,j))/OZ_P_NEW(i,j)
SUM_Relative(i,j)=Relative_POS_NO(i,j)+Relative_POS_NO2(i,j)+ Relative_POS_oz(i,j)
IF( SUM_Relative(i,j)>1 ) CYCLE
NO_P(i,j)= NO_P_NEW(i,j)
NO2_P(i,j)=NO2_P_NEW(i,j)
OZ_P(i,j)= OZ_P_NEW(i,j)
END DO
END DO
END DO
!********************************************************************************************************************************************************
DO i=6,21
WRITE(13,"(14(1x,1pe14.7))")(ROC_P(i,j),j=1,14)
WRITE(14,"(14(1x,1pe14.7))")(RP_P(i,j),j=1,14)
WRITE(15,"(14(1x,1pe14.7))")(NO_P(i,j),j=1,14 )
WRITE(16,"(14(1x,1pe14.7))")(NO2_P(i,j),j=1,14)
WRITE(17,"(14(1x,1pe14.7))")(OZ_P(i,j),j=1,14 )
END DO
DO i=7,21
WRITE(18,"(14(1x,1pe14.7))")(Er_NO(i,j),j=1,14)
WRITE(19,"(14(1x,1pe14.7))")(Er_NO2(i,j),j=1,14)
WRITE(20,"(14(1x,1pe14.7))")(Er_Oz(i,j),j=1,14 )
WRITE(21,"(14(1x,1pe14.7))")(POS_Er_NO(i,j),j=1,14)
WRITE(22,"(14(1x,1pe14.7))")(POS_Er_NO2(i,j),j=1,14)
WRITE(23,"(14(1x,1pe14.7))")(POS_Er_Oz(i,j),j=1,14 )
WRITE(24,"(14(1x,1pe14.7))")(SUM_Relative(i,j),j=1,14)
END DO
END PROGRAM Chemical_Production
This code includes an Iteration process. The problem is in the section 4 and using "cycle".with cycle the output files are empty,but with using GO TO they aren't empty but all outputs are zero.how should i use 'cycle' and why they are zero?
!**************************************************************** 1 *******************************************************************************************
REAL ::i,j,d_time
REAL ,DIMENSION ( 14 )::a_ROC
REAL ,DIMENSION (6:21,14)::OX_P,OX_diff_P,d_cum,ROC_P,RP_P
REAL ,DIMENSION ( 25,14 )::K_1,K_3
REAL ,DIMENSION ( 25,14 )::K_2,K_4,K_5,K_6,K_7
REAL ,DIMENSION ( 6:21,14)::Initial_NO,Initial_NO2,Initia_oz
REAL ,DIMENSION (6:21,14)::OZ_P,NO_P,NO2_P,OZ_P_NEW,NO_P_NEW,NO2_P_NEW
REAL ,DIMENSION (7:21,14)::Er_NO,Er_NO2,Er_Oz,POS_Er_NO,POS_Er_NO2,POS_Er_Oz, Relative_POS_NO, Relative_POS_NO2, Relative_POS_oz, SUM_Relative
!****************************************************************************************************************************************************************
d_time=60
!******************************* 2 ***********************************
OPEN(1,file='k_1.txt',status='old')
OPEN(2,file='K_2.txt',status='old')
OPEN(3,file='K_3.txt',status='old')
OPEN(4,file='K_4.txt',status='old')
OPEN(5,file='K_5.txt',status='old')
OPEN(6,file='K_6.txt',status='old')
OPEN(7,file='K_7.txt',status='old')
OPEN(8,file='a_ROC.txt',status='old')
OPEN(9,file='Initial Try NO.txt',status='old')
OPEN(10,file='Initial Try NO2.txt',status='old')
OPEN(11,file='Initial Try oz.txt',status='old')
OPEN(12,file='d_cum.txt',status='old')
OPEN(13,file='ROC_Prediction.txt')
OPEN(14,file='RP_Prediction.txt')
OPEN(15,file='NO_P.txt')
OPEN(16,file='NO2_P.txt')
OPEN(17,file='OZ_P.txt')
OPEN(18,file='Er_NO.txt')
OPEN(19,file='Er_NO2.txt')
OPEN(20,file='Er_Oz.txt')
OPEN(21,file='POS_Er_NO.txt')
OPEN(22,file='POS_Er_NO2.txt')
OPEN(23,file='POS_Er_Oz.txt')
OPEN(24,file='SUM_Relative.txt')
!**********************************************************************
!******************************** 3 **********************************
DO i=1,25
READ(1,*) (K_1(i,j),j=1,14)
READ(2,*) (K_2(i,j),j=1,14)
READ(3,*) (K_3(i,j),j=1,14)
READ(4,*) (K_4(i,j),j=1,14)
READ(5,*) (K_5(i,j),j=1,14)
READ(6,*) (K_6(i,j),j=1,14)
READ(7,*) (K_7(i,j),j=1,14)
END DO
DO j=1,14
READ(8,*) (a_ROC(j))
END DO
DO i=6,21
READ(9,*) (Initial_NO(i,j),j=1,14)
READ(10,*)(Initial_NO2(i,j),j=1,14)
READ(11,*)(Initia_oz(i,j),j=1,14)
END DO
DO i=6,21
READ(12,*)(d_cum(i,j),j=1,14)
END DO
DO i=6,21
DO j=1,14
NO_P_NEW(i,j)=Initial_NO(i,j)
NO2_P_NEW(i,j)=Initial_NO2(i,j)
OZ_P_NEW(i,j)=Initia_oz(i,j)
END DO
END DO
!******************************************************************************
!************************************************************* 4 ****************************************************************************
DO j=1,14
OX_P(6,j)=OZ_P_NEW(6,j)-(2*NO_P_NEW(6,j))-NO2_P_NEW(6,j)
OX_diff_P(6,j)=0
ROC_P(6,j)=0
RP_P(6,j)=0
END DO
DO j=1,14
DO i=7,21
DO
NO_P(i,j)= NO_P_NEW(i,j)
NO2_P(i,j)=NO2_P_NEW(i,j)
OZ_P(i,j)= OZ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_POS_oz(i,j)
IF( SUM_Relative(i,j)>1 ) CYCLE
NO_P(i,j)= NO_P_NEW(i,j)
NO2_P(i,j)=NO2_P_NEW(i,j)
OZ_P(i,j)= OZ_P_NEW(i,j)
END DO
END DO
END DO
!********************************************************************************************************************************************************
DO i=6,21
WRITE(13,"(14(1x,1pe14.7))")(ROC_P(i,j),j=1,14)
WRITE(14,"(14(1x,1pe14.7))")(RP_P(i,j),j=1,14)
WRITE(15,"(14(1x,1pe14.7))")(NO_P(i,j),j=1,14 )
WRITE(16,"(14(1x,1pe14.7))")(NO2_P(i,j),j=1,14)
WRITE(17,"(14(1x,1pe14.7))")(OZ_P(i,j),j=1,14 )
END DO
DO i=7,21
WRITE(18,"(14(1x,1pe14.7))")(Er_NO(i,j),j=1,14)
WRITE(19,"(14(1x,1pe14.7))")(Er_NO2(i,j),j=1,14)
WRITE(20,"(14(1x,1pe14.7))")(Er_Oz(i,j),j=1,14 )
WRITE(21,"(14(1x,1pe14.7))")(POS_Er_NO(i,j),j=1,14)
WRITE(22,"(14(1x,1pe14.7))")(POS_Er_NO2(i,j),j=1,14)
WRITE(23,"(14(1x,1pe14.7))")(POS_Er_Oz(i,j),j=1,14 )
WRITE(24,"(14(1x,1pe14.7))")(SUM_Relative(i,j),j=1,14)
END DO
END PROGRAM Chemical_Production