/
QuitRoutine.F90
83 lines (71 loc) · 2.62 KB
/
QuitRoutine.F90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !
! FILE: QuitRoutine.F90 !
! CONTAINS: subroutine QuitRoutine, NotifyError !
! !
! PURPOSE: Routines to exit the program and write the !
! data if necessary !
! !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine QuitRoutine(tin,normalexit,errorcode)
use hdf5
use mpih
use param
use decomp_2d, only: nrank, decomp_2d_finalize
use decomp_2d_fft
implicit none
logical, intent(in) :: normalexit
integer :: errorcode
real :: tin(3)
if(errorcode.ne.100) then !EP skip if already finalized
tin(3) = MPI_WTIME()
if(ismaster) then
call NotifyError(errorcode)
endif
if(normalexit) then
if(nrank.eq.0) write(6,'(a,f10.2,a)') 'Total Iteration Time = ',tin(3) -tin(2),' sec.'
if (statcal) call WriteStats
call WriteFlowField
else
call MPI_Abort(MPI_COMM_WORLD,1)
endif
call DeallocateVariables
call HdfClose
call decomp_2d_fft_finalize
call decomp_2d_finalize
endif
end subroutine QuitRoutine
subroutine NotifyError(errorcode)
use param
implicit none
integer, intent(in) :: errorcode
if(errorcode.eq.166) then
write(6,168) dt
168 format(10x,'dt too small, DT= ',e14.7)
else if(errorcode.eq.165) then
write(6,164)
164 format(10x,'cfl too large ')
else if(errorcode.eq.266) then
write(6,268)
268 format(10x,'velocities diverged')
else if(errorcode.eq.169) then
write(6,178)
write(6,179)
write(6,180)
178 format(10x,'too large local residue for mass conservation at:')
179 format(10x,'Probably the matrix in SolvePressureCorrection becomes singular')
180 format(10x,'Try changing nxm or str3')
call LocateLargeDivergence
else if(errorcode.eq.333) then
write(*,*) "time greater than tmax"
write(*,*) "statistics and continuation updated"
else if(errorcode.eq.334) then
write(*,*) "walltime greater than walltimemax"
write(*,*) "statistics and continuation updated"
else if(errorcode.eq.444) then
write(*,*) "FFT size in ny or nz is not efficient"
else
write(*,*) "Maximum number of timesteps reached"
end if
return
end