pragmg
C PRAGMG SOURCE PV 20/09/26 21:19:09 10724 $ INCX,ITER,INMV, $ RESID,KPREC, $ NREST,ICALRS,IDDOT,IMVEC,KTIME,LTIME,IMPR,IRET) IMPLICIT REAL*8 (A-H,O-Z) IMPLICIT INTEGER (I-N) C*********************************************************************** C NOM : PRAGMG C DESCRIPTION : C Préparation de la résolution d'un système linéaire Ax=b C par une méthode Multigrille Algébrique C C LANGAGE : ESOPE C AUTEUR : Stéphane GOUNAND (CEA/DRN/DMT/SEMT/TTMF) C mél : gounand@semt2.smts.cea.fr C REFERENCE (bibtex-like) : C*********************************************************************** C*********************************************************************** C VERSION : v1, 17/06/08, version initiale C HISTORIQUE : 17/06/08 : Crétation C HISTORIQUE : C*********************************************************************** C Prière de PRENDRE LE TEMPS de compléter les commentaires C en cas de modification de ce sous-programme afin de faciliter C la maintenance ! C*********************************************************************** * * .. Includes et pointeurs associés .. -INC PPARAM -INC CCOPTIO -INC CCREEL -INC SMLREEL INTEGER JG POINTEUR LRES.MLREEL -INC SMLENTI POINTEUR LNMV.MLENTI POINTEUR ATYP.MLENTI POINTEUR KTYP.MLENTI -INC SMMATRIK POINTEUR MAPREC.MATRIK POINTEUR KMORS.PMORS POINTEUR KISA.IZA POINTEUR AMORS.PMORS POINTEUR AISA.IZA POINTEUR KS2B.IZA,RES.IZA POINTEUR INCX.IZA POINTEUR INVDIA.IZA POINTEUR ILUM.PMORS POINTEUR ILUI.IZA -INC SMTABLE POINTEUR KTIME.MTABLE CHARACTER*8 CHARI LOGICAL LTIME,LOGII * .. Parameters * This is a breakdown tolerance for BiCGSTAB-type method REAL*8 BRTOL *STAT-INC SMSTAT * .. Scalar Arguments .. INTEGER ITER, KPREC, IMPR, IRET INTEGER ICNT REAL*8 RESID,TOL,BNRM2,RNRM2,XFACT * .. * Vars reqd for STOPTEST2 * REAL*8 TOL, BNRM2 * .. * .. External subroutines .. * EXTERNAL STOPTEST2 INTEGER NBVA,NJA,NTT,NTTPRE EXTERNAL GNRM2 * .. * .. Executable Statements .. * * WRITE(IOIMP,*) 'Debut de pragmg' IRET = 0 IVALI=0 XVALI=0.D0 LOGII=.FALSE. IRETI=0 IAT =0 XVALR=0.D0 IRETR=0 IST =0 * * On récupère les paramètres * * SEGACT MATRIK NTT =AMORS.IA(/1)-1 * NJA =KMORS.JA(/1) SEGINI,ATYP=KTYP SEGINI,AISA=KISA SEGACT KS2B SEGINI,RES=KS2B SEGACT INCX*MOD C C Initialisation de l'historique de convergence C JG=ITER+1 SEGINI LNMV SEGINI LRES * * Autres paramètres * IJOB=0 IF (IMPR.GT.2) THEN IPRINT=IOIMP ELSE IPRINT=-1 ENDIF TOL=RESID ICNT=0 * * AGMG ne fait que du résidu relatif d'où les petits ajustements * suivants. * * res = b - AX IF (ICALRS.EQ.1) BNRM2=RNRM2 IF (BNRM2.LT.XPETIT) BNRM2=1.D0 RESID=RNRM2 / BNRM2 LNMV.LECT(ICNT+1)=1 * IF (RESID.LE.TOL) THEN ITER=0 GOTO 30 ENDIF * IF (ICALRS.EQ.0) THEN XFACT=1.D0/RESID TOL=TOL*XFACT ENDIF * * Changement automatique du signe des lignes de la matrice * et du second membre si le terme diagonal est négatif. * * CALL ECMORS(AMORS,AISA,3) DO I=1,NTT IFOUND=0 DO J=AMORS.IA(I),(AMORS.IA(I+1)-1) * WRITE(IOIMP,*) 'J=',J * WRITE(IOIMP,*) 'JA(J)=',AMORS.JA(J) IF (AMORS.JA(J).EQ.I) THEN IF (AISA.A(J).GT.XZERO) THEN IFOUND=1 ELSEIF (AISA.A(J).LT.XZERO) THEN IFOUND=-1 ENDIF GOTO 10 ENDIF ENDDO 10 CONTINUE * WRITE(IOIMP,*) 'IFOUND=',IFOUND IF (IFOUND.EQ.0) THEN WRITE(IOIMP,*) 'The ',I $ ,'th diagonal term of the matrix is nil' IRET=-3 GOTO 9999 ELSEIF (IFOUND.EQ.-1) THEN RES.A(I)=-1.D0*RES.A(I) DO J=AMORS.IA(I),(AMORS.IA(I+1)-1) AISA.A(J)=-1.D0*AISA.A(J) ENDDO ENDIF ENDDO * WRITE(IOIMP,*) '4' * CALL ECMORS(AMORS,AISA,3) * * To use the standard AGMG library, you should make sure that it * is compiled with same compiler and options than Castem's and that * the sequential example furnished with AGMG works. * Then it is sufficient to put agmg_seq.o and agmg.o in the * current directory and use essai for linking. * * No interface to the parallel version of agmg for now * WRITE(IOIMP,*) '***********************************' WRITE(IOIMP,*) ' ' WRITE(IOIMP,*) 'Please uncomment the CALL AGMG(...', $ ' in the pragmg.eso subroutine if you wish to use' WRITE(IOIMP,*) 'the AGMG library by Y. Notay' WRITE(IOIMP,*) ' ' WRITE(IOIMP,*) '***********************************' * 251 2 *Tentative d'utilisation d'une option non implémentée IRET=-1 GOTO 9999 ********************************************************************* * * AGMG v1.1 call (standard sequential version) * C ITR2=ITER-1 C CALL AGMG(NTT,AISA.A,AMORS.JA,AMORS.IA,RES.A, C $ IJOB,IPRINT,NREST,ITR2,TOL) C* X = X_0 + \delta X C CALL GAXPY(1.D0,RES,INCX) C* Résidu final C CALL GCOPY(KS2B,RES) C CALL GMOMV(IMVEC,'N',-1.D0,AMORS,AISA,INCX,1.D0,RES) C RNRM2=GNRM2(RES) C RESID=RNRM2/BNRM2 C* C IF (ITR2.LT.0) THEN C IRET=1 C ITER=-ITR2 C ELSE C IRET=0 C ITER=ITR2 C ENDIF C* C ICNT=ICNT+1 C LRES.PROG(ICNT+1)=RESID C LNMV.LECT(ICNT+1)=1+ITER C INMV=1+ITER * * End of AGMG call (standard sequential version) * ********************************************************************* ********************************************************************* * * AGMG call (sequential version slightly modified * for better error handling and back transmission of residual * norm history) * C ITR2=ITER-1 C* CALL ECMORS(AMORS,AISA,3) C* WRITE(IOIMP,*) 'Appel de agmg' C CALL AGMG(NTT,AISA.A,AMORS.JA,AMORS.IA,ATYP.LECT,RES.A, C $ IJOB,IPRINT,NREST,ITR2,TOL,LTIME,IAT,IST,LRES.PROG,IDDOT) C* X = X_0 + \delta X C CALL GAXPY(1.D0,RES,INCX) C* C IF (ITR2.LT.0) THEN C IRET=1 C ITER=-ITR2 C ELSE C IRET=0 C ITER=ITR2 C ENDIF C IF (ICALRS.EQ.0) THEN C DO I=1,ITER C LRES.PROG(I+1)=LRES.PROG(I+1)/XFACT C ENDDO C ENDIF C DO I=1,ITER C LNMV.LECT(I+1)=I+1 C ENDDO C INMV=1+ITER C RESID=LRES.PROG(ITER+1) C ICNT=ITER * * End of AGMG call (sequential version slightly modified * for better error handling and back transmission of residual * norm history) * ********************************************************************* * IF (LTIME) THEN CHARI='MGAGGREG' $ 'ENTIER ',IAT,XVALR,CHARR,LOGIR,IRETR) CHARI='MGSOLUTI' $ 'ENTIER ',IST,XVALR,CHARR,LOGIR,IRETR) ENDIF * C C Désactivation C 30 CONTINUE JG=ICNT+1 SEGADJ LRES SEGDES LRES SEGADJ LNMV SEGDES LNMV SEGDES INCX SEGDES KS2B SEGSUP RES SEGSUP AISA SEGSUP ATYP SEGSUP AMORS SEGDES KISA SEGDES KTYP SEGDES KMORS SEGDES MATRIK C C A breakdown has occured in the CGS method C IF (IRET.LT.0) GOTO 9999 * * Normal termination * RETURN * * Format handling * * 1002 FORMAT(10(1X,1PE11.4)) * * Error handling * 9999 CONTINUE WRITE(IOIMP,*) 'An error was detected in pragmg.eso' RETURN * * End of PRAGMG * END
© Cast3M 2003 - Tous droits réservés.
Mentions légales