主题:do循环加上openmp语句后,收敛性变差了,怎么回事?
我将peric程序修改成并行OpenMP并行程序,在Calcuv,Calcp函数中加OpenMP语句并行,能够减少计算时间,在Calcsc函数中加OpenMP语句并行,结果发现多迭代了1000多次,计算时间大大增加了,怎么回事?将程序前前后后看了几遍,也没找出减弱收敛性的原因,望高手解答。代码如下:
C#############################################################
SUBROUTINE CALCSC(K,IFI,FI,FIO,FIOO)
C#############################################################
C This routine discretizes and solves the scalar transport
C equations (temperature, turbulent kinetic energy, diss.).
C=============================================================
use global_field
use global_public
DIMENSION FI(NXYA),FIO(NXYA),FIOO(NXYA)
C
C.....CALCULATE GRADIENTS OF FI
C
CALL SETIND(K)
CALL GRADFI(K,FI,DPX,DPY)
C
C.....INITIALIZE ARRAYS, SET BLENDING AND UNDER_RELAXATION COEFF.
C
IJST=IJGR(K)+1
IJEN=IJGR(K)+NIJ
C
DO IJ=IJST,IJEN
SU(IJ)=0.
AP(IJ)=0.
END DO
C
GFI=GDS(IFI)
URFFI=1./URF(IFI)
C
C.....CALCULATE FLUXES THROUGH INNER CV-FACES (EAST & NORTH)
C
[color=808000][color=000000][b]C$omp parallel do private(I,IJ)
DO I=2,NIM-1
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
CALL FLUXSC(IFI,IJ,IJ+NJ,IJ,IJ-1,F1(IJ),AW(IJ+NJ),AE(IJ),
* FX(IJ),GFI,FI)
END DO
END DO
C$omp end parallel do [/b][/color][/color]
C
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM-1
CALL FLUXSC(IFI,IJ,IJ+1,IJ-NJ,IJ,F2(IJ),AS(IJ+1),AN(IJ),
* FY(IJ),GFI,FI)
END DO
END DO
C
C.....CONTRIBUTION FROM O- AND C-GRID CUTS
C
DO I=IOCS(K)+1,IOCS(K)+NOC(K)
IJP=IJL(I)
IJN=IJR(I)
CALL FLUXSC(IFI,IJP,IJN,IJOC1(I),IJOC2(I),FMOC(I),
* AL(I),AR(I),FOC(I),GFI,FI)
AP(IJP)=AP(IJP)-AR(I)
AP(IJN)=AP(IJN)-AL(I)
END DO
C
C.....UNSTEADY TERM CONTRIBUTION
C
IF(LTIME) THEN
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
APT=DEN(IJ)*VOL(IJ)*DTR
SU(IJ)=SU(IJ)+APT*((1.+GAMT)*FIO(IJ)-0.5*GAMT*FIOO(IJ))
AP(IJ)= AP(IJ) +APT*(1.+0.5*GAMT)
END DO
END DO
ENDIF
C
C.....INLET BOUNDARIES
C
DO II=IIS(K)+1,IIS(K)+NINL(K)
IJP=IJPI(II)
IJB=IJI(II)
DPX(IJB)=DPX(IJP)
DPY(IJB)=DPY(IJP)
CALL FLUXSC(IFI,IJP,IJB,IJI1(II),IJI2(II),FMI(II),CP,CB,
* ONE,ZERO,FI)
AP(IJP)=AP(IJP)-CB
SU(IJP)=SU(IJP)-CB*FI(IJB)
END DO
C
C.....OUTLET BOUNDARIES
C
DO IO=IOS(K)+1,IOS(K)+NOUT(K)
IJP=IJPO(IO)
IJB=IJO(IO)
DPX(IJB)=DPX(IJP)
DPY(IJB)=DPY(IJP)
CALL FLUXSC(IFI,IJP,IJB,IJO1(IO),IJO2(IO),FMO(IO),CP,CB,
* ONE,ZERO,FI)
AP(IJP)=AP(IJP)-CB
SU(IJP)=SU(IJP)-CB*FI(IJB)
END DO
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR TEMPERATURE
C
IF(IFI.EQ.IEN) CALL TEMP(K)
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR TURBULENT KINETIC ENERGY
C
IF(IFI.EQ.ITE) CALL KINE(K)
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR DISSIPATION RATE
C
IF(IFI.EQ.IED) CALL DISE(K)
C
C.....FINAL COEFFICIENT AND SOURCE MATRIX FOR FI-EQUATION
C
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
AP(IJ)=(AP(IJ)-AE(IJ)-AW(IJ)-AN(IJ)-AS(IJ))*URFFI
SU(IJ)=SU(IJ)+(1.-URF(IFI))*AP(IJ)*FI(IJ)
END DO
END DO
C
C.....SOLVING EQUATION SYSTEM FOR FI-EQUATION
C
CALL SIPSOL(FI,IFI,K)
C
C.....SYMMETRY AND OUTLET BOUNDARIES
C
DO IS=ISS(K)+1,ISS(K)+NSYM(K)
FI(IJS(IS))=FI(IJPS(IS))
END DO
C
DO IO=IOS(K)+1,IOS(K)+NOUT(K)
FI(IJO(IO))=FI(IJPO(IO))
END DO
C
RETURN
END
C
C
C#############################################################
SUBROUTINE CALCSC(K,IFI,FI,FIO,FIOO)
C#############################################################
C This routine discretizes and solves the scalar transport
C equations (temperature, turbulent kinetic energy, diss.).
C=============================================================
use global_field
use global_public
DIMENSION FI(NXYA),FIO(NXYA),FIOO(NXYA)
C
C.....CALCULATE GRADIENTS OF FI
C
CALL SETIND(K)
CALL GRADFI(K,FI,DPX,DPY)
C
C.....INITIALIZE ARRAYS, SET BLENDING AND UNDER_RELAXATION COEFF.
C
IJST=IJGR(K)+1
IJEN=IJGR(K)+NIJ
C
DO IJ=IJST,IJEN
SU(IJ)=0.
AP(IJ)=0.
END DO
C
GFI=GDS(IFI)
URFFI=1./URF(IFI)
C
C.....CALCULATE FLUXES THROUGH INNER CV-FACES (EAST & NORTH)
C
[color=808000][color=000000][b]C$omp parallel do private(I,IJ)
DO I=2,NIM-1
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
CALL FLUXSC(IFI,IJ,IJ+NJ,IJ,IJ-1,F1(IJ),AW(IJ+NJ),AE(IJ),
* FX(IJ),GFI,FI)
END DO
END DO
C$omp end parallel do [/b][/color][/color]
C
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM-1
CALL FLUXSC(IFI,IJ,IJ+1,IJ-NJ,IJ,F2(IJ),AS(IJ+1),AN(IJ),
* FY(IJ),GFI,FI)
END DO
END DO
C
C.....CONTRIBUTION FROM O- AND C-GRID CUTS
C
DO I=IOCS(K)+1,IOCS(K)+NOC(K)
IJP=IJL(I)
IJN=IJR(I)
CALL FLUXSC(IFI,IJP,IJN,IJOC1(I),IJOC2(I),FMOC(I),
* AL(I),AR(I),FOC(I),GFI,FI)
AP(IJP)=AP(IJP)-AR(I)
AP(IJN)=AP(IJN)-AL(I)
END DO
C
C.....UNSTEADY TERM CONTRIBUTION
C
IF(LTIME) THEN
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
APT=DEN(IJ)*VOL(IJ)*DTR
SU(IJ)=SU(IJ)+APT*((1.+GAMT)*FIO(IJ)-0.5*GAMT*FIOO(IJ))
AP(IJ)= AP(IJ) +APT*(1.+0.5*GAMT)
END DO
END DO
ENDIF
C
C.....INLET BOUNDARIES
C
DO II=IIS(K)+1,IIS(K)+NINL(K)
IJP=IJPI(II)
IJB=IJI(II)
DPX(IJB)=DPX(IJP)
DPY(IJB)=DPY(IJP)
CALL FLUXSC(IFI,IJP,IJB,IJI1(II),IJI2(II),FMI(II),CP,CB,
* ONE,ZERO,FI)
AP(IJP)=AP(IJP)-CB
SU(IJP)=SU(IJP)-CB*FI(IJB)
END DO
C
C.....OUTLET BOUNDARIES
C
DO IO=IOS(K)+1,IOS(K)+NOUT(K)
IJP=IJPO(IO)
IJB=IJO(IO)
DPX(IJB)=DPX(IJP)
DPY(IJB)=DPY(IJP)
CALL FLUXSC(IFI,IJP,IJB,IJO1(IO),IJO2(IO),FMO(IO),CP,CB,
* ONE,ZERO,FI)
AP(IJP)=AP(IJP)-CB
SU(IJP)=SU(IJP)-CB*FI(IJB)
END DO
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR TEMPERATURE
C
IF(IFI.EQ.IEN) CALL TEMP(K)
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR TURBULENT KINETIC ENERGY
C
IF(IFI.EQ.ITE) CALL KINE(K)
C
C.....WALL BOUNDARY CONDITIONS AND SOURCES FOR DISSIPATION RATE
C
IF(IFI.EQ.IED) CALL DISE(K)
C
C.....FINAL COEFFICIENT AND SOURCE MATRIX FOR FI-EQUATION
C
DO I=2,NIM
DO IJ=LI(I+IST)+2,LI(I+IST)+NJM
AP(IJ)=(AP(IJ)-AE(IJ)-AW(IJ)-AN(IJ)-AS(IJ))*URFFI
SU(IJ)=SU(IJ)+(1.-URF(IFI))*AP(IJ)*FI(IJ)
END DO
END DO
C
C.....SOLVING EQUATION SYSTEM FOR FI-EQUATION
C
CALL SIPSOL(FI,IFI,K)
C
C.....SYMMETRY AND OUTLET BOUNDARIES
C
DO IS=ISS(K)+1,ISS(K)+NSYM(K)
FI(IJS(IS))=FI(IJPS(IS))
END DO
C
DO IO=IOS(K)+1,IOS(K)+NOUT(K)
FI(IJO(IO))=FI(IJPO(IO))
END DO
C
RETURN
END
C
C