1 subroutine rstatCheck (res, ilwork,y,ac) 2c 3c---------------------------------------------------------------------- 4c 5c This subroutine calculates the statistics of the residual. 6c 7c input: 8c res (nshg,nflow) : preconditioned residual 9c 10c output: 11c The time step, cpu-time and entropy-norm of the residual 12c are printed in the file HISTOR.DAT. 13c 14c 15c Zdenek Johan, Winter 1991. (Fortran 90) 16c---------------------------------------------------------------------- 17c 18 include "common.h" 19 include "mpif.h" 20 include "auxmpi.h" 21c 22 dimension res(nshg,nflow) 23 dimension rtmp(nshg), nrsmax(1), ilwork(nlwork) 24 dimension Forin(4), Forout(4) 25!SCATTER dimension irecvcount(numpe), resvec(numpe) 26c integer TMRC 27 real*8 y(nshg,ndof),ac(nshg,ndof) 28 save ResLast 29 30 if (numpe == 1) nshgt=nshg ! global = this processor 31c 32c.... -----------------------> Convergence <------------------------- 33c 34c.... compute the maximum residual and the corresponding node number 35c 36 rtmp = zero 37 do i = 1, nflow 38 rtmp = rtmp + res(:,i)**2 39 enddo 40 41 call sumgat (rtmp, 1, resnrm, ilwork) 42 43 resmaxl = maxval(rtmp) 44 45 irecvcount = 1 46 resvec = resmaxl 47 if (numpe > 1) then 48 call MPI_ALLREDUCE (resvec, resmax, irecvcount, 49 & MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD, 50 & ierr) 51c call MPI_REDUCE_SCATTER (resvec, resmax, irecvcount, 52c & MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD, 53c & ierr) 54 else 55 resmax=resmaxl 56 endif 57 nrsmax = maxloc(rtmp) 58c 59c.... correct the residuals 60c 61 if (loctim(itseq) .eq. 0) then 62 resnrm = resnrm 63 resmax = resmax 64 else 65 resnrm = resnrm 66 resmax = resmax 67 endif 68c 69c.... approximate the number of entries 70c 71 totres = resnrm / float(nshgt) 72 totres = sqrt(totres) 73 if((iter.gt.1).and.(totres.gt.10000.0*ResLast)) then !diverging 74 call restar('out ',y,res) ! 'res' is used instead of 'ac' 75 if(myrank.eq.0) write(*,*) 'ResLast totres', ResLast, totres 76 if(myrank.eq.0) write(*,*) 'resmax', resmax 77 if (numpe > 1) call MPI_BARRIER(MPI_COMM_WORLD, ierr) 78 call error('rstat ','Diverge', iter) 79 endif 80 ResLast=totres 81 ttim(68) = ttim(68) + secs(0.0) 82 83c 84c.... return 85c 86 return 87c 88 end 89 subroutine rstatCheckSclr (rest, ilwork,y,ac) 90c 91c---------------------------------------------------------------------- 92c 93c This subroutine calculates the statistics of the residual. 94c 95c input: 96c rest (nshg) : preconditioned residual 97c 98c output: 99c The time step, cpu-time and entropy-norm of the residual 100c are printed in the file HISTOR.DAT. 101c 102c 103c Zdenek Johan, Winter 1991. (Fortran 90) 104c---------------------------------------------------------------------- 105c 106 include "common.h" 107 include "mpif.h" 108 include "auxmpi.h" 109c 110 dimension rest(nshg) 111 dimension rtmp(nshg), nrsmax(1), ilwork(nlwork) 112!SCATTER dimension irecvcount(numpe), resvec(numpe) 113c integer TMRC 114 real*8 y(nshg,ndof),ac(nshg,ndof) 115 save ResLast 116 save lstepLast 117 118 ttim(68) = ttim(68) - secs(0.0) 119 if (numpe == 1) nshgt=nshg ! global = this processor 120c 121c.... -----------------------> Convergence <------------------------- 122c 123c.... compute the maximum residual and the corresponding node number 124c 125 rtmp = zero 126 rtmp = rtmp + rest**2 127 128 call sumgat (rtmp, 1, resnrm, ilwork) 129 130 resmaxl = maxval(rtmp) 131 132continue on 133 134 irecvcount = 1 135 resvec = resmaxl 136 if (numpe > 1) then 137 call MPI_ALLREDUCE (resvec, resmax, irecvcount, 138 & MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD, 139 & ierr) 140c call MPI_REDUCE_SCATTER (resvec, resmax, irecvcount, 141c & MPI_DOUBLE_PRECISION, MPI_MAX, MPI_COMM_WORLD, 142c & ierr) 143 else 144 resmax=resmaxl 145 endif 146 nrsmax = maxloc(rtmp) 147c 148c.... correct the residuals 149c 150 if (loctim(itseq) .eq. 0) then 151 resnrm = resnrm 152 resmax = resmax 153 else 154 resnrm = resnrm 155 resmax = resmax 156 endif 157c 158c.... approximate the number of entries 159c 160 totres = resnrm / float(nshgt) 161 totres = sqrt(totres) 162 if((lstep.gt.0).and.(lstepLast.eq.lstep)) then 163 if(totres.gt.10000.0*ResLast) then !diverging 164 lstep = lstep+1 165 ac(:,5) = rest(:) ! T dot in 'ac' is filled with scl. res 166 call restar('out ',y,ac) 167 if(myrank.eq.0) write(*,*) 'ResLast totres', ResLast, totres 168 if(myrank.eq.0) write(*,*) 'resmax', resmax 169 call error('rstatSclr','Diverge', iter) 170 endif 171 else 172 lstepLast=lstep 173 endif 174 ResLast=totres 175c 176c.... return 177c 178 return 179c 180 end 181