ADflow  v1.0
ADflow is a finite volume RANS solver tailored for gradient-based aerodynamic design optimization.
signals.F90
Go to the documentation of this file.
1  subroutine set_signal_write
2  !
3  ! set_signal_write sets the localSignal to signalWrite. On the
4  ! finest mesh this means that after the current iteration a
5  ! solution is written. On the coarser grids this signal will be
6  ! ignored.
7  ! This routine is only compiled when signalling is supported.
8  !
9 #ifndef USE_NO_SIGNALS
10 
11  use constants
12  use communication, only: myid
13  use inputphysics, only: equationmode
15  use iteration, only: groundlevel
16  use commonformats, only: strings
17  implicit none
18  !
19  ! Local variables.
20  !
21  character(len=7) :: integerString
22 
23  ! The user signals must be reconnected again, because the
24  ! connection is lost after a signal has been given.
25 
26  call connect_signals
27 
28  ! Parallel executable. Write a general message that this
29  ! processor has received a write signal.
30 
31  write (integerstring, '(i7)') myid
32  integerstring = adjustl(integerstring)
33  integerstring = trim(integerstring)
34  print "(a)", "#"
35  print strings, "# Processor ", integerstring(:len_trim(integerstring)), ": Received write signal."
36 
37  ! Check if a signal was set previously.
38 
39  testprevious: if (localsignal /= nosignal) then
40 
41  ! A signal was set before. Set it back to noSignal
42  ! and write a message that this has been done.
43 
45 
46  print "(a)", "# Signal was set previously and will now be overwritten to no signal"
47 
48  else testprevious
49 
50  ! No signal was set yet.
51  ! Determine the situation and act accordingly.
52 
53  if (groundlevel == 1) then
54 
55  ! Finest grid. A solution file will be written after either
56  ! this multigrid cycle or this time step. This depends whether
57  ! this is a steady or an unsteady computation.
58  ! In both cases localSignal must be set to signalWrite.
59 
61 
62  select case (equationmode)
63 
64  case (steady, timespectral)
65  print "(a)", "# Solution will be written after this iteration"
66 
67  case (unsteady)
68  print "(a)", "# Solution will be written after this time step"
69  end select
70 
71  else
72 
73  ! Coarser grid. Signal information will be ignored.
74 
75  print "(a)", "# Solver is still on a coarse grid and therefore the signal is ignored."
76  print "(a)", "# Use kill -USR2 if you want to go to the next finer grid level."
77 
78  end if
79 
80  end if testprevious
81 
82  ! Write a blank line, such that the message is pretty clear.
83 
84  print "(a)", "#"
85 
86 #endif /* USE_NO_SIGNALS */
87 
88  end subroutine set_signal_write
89 
90  ! ==================================================================
91 
93  !
94  ! set_signal_write_quit sets the localSignal to
95  ! signalWriteQuit. On the finest mesh this means that after
96  ! the current iteration the solution is written and the
97  ! computation is stopped. On the coarser grids the solution is
98  ! transferred to the next finer level and the computation is
99  ! continued there.
100  ! This routine is only compiled when signalling is supported.
101  !
102 #ifndef USE_NO_SIGNALS
103 
104  use constants
105  use communication, only: myid
106  use inputphysics, only: equationmode
108  use iteration, only: groundlevel
109  use commonformats, only: strings
110  implicit none
111  !
112  ! Local variables.
113  !
114  character(len=7) :: integerString
115 
116  ! The user signals must be reconnected again, because the
117  ! connection is lost after a signal has been given.
118  ! Only when signalling is wanted.
119 
120  call connect_signals
121 
122  ! Parallel executable. Write a general message that this
123  ! processor has received a write and quit signal.
124 
125  write (integerstring, '(i7)') myid
126  integerstring = adjustl(integerstring)
127  integerstring = trim(integerstring)
128  print "(a)", "#"
129  print strings, "# Processor ", integerstring(:len_trim(integerstring)), ": Received write and quit signal."
130 
131  ! Check if a signal was set previously.
132 
133  testprevious: if (localsignal /= nosignal) then
134 
135  ! A signal was set before. Set it back to noSignal
136  ! and write a message that this has been done.
137 
139 
140  print "(a)", "# Signal was set previously and will now be overwritten to no signal"
141 
142  else testprevious
143 
144  ! Set localSignal to signalWriteQuit.
145 
147 
148  ! Determine the situation and act accordingly.
149 
150  if (groundlevel == 1) then
151 
152  ! Finest grid. A solution file will be written and the
153  ! computation stopped after either this multigrid cycle or
154  ! this time step. This depends whether this is a steady or an
155  ! unsteady computation.
156 
157  select case (equationmode)
158  case (steady, timespectral)
159  print "(a)", "# Solution will be written and computation stopped after this multigrid cycle"
160 
161  case (unsteady)
162  print "(a)", "# Solution will be written and computation stopped after this time step"
163  end select
164 
165  else
166 
167  ! Coarser grid. The solution is transferred to the next finer
168  ! grid level. This happens either after this multigrid cycle
169  ! or after this time step depending on whether this is a
170  ! steady or an unsteady computation.
171 
172  print "(a)", "# Solver is still on the coarse grid."
173 
174  select case (equationmode)
175  case (steady, timespectral)
176  print "(a)", "# Solution will be transferred to the next finer grid after this multigrid cycle."
177 
178  case (unsteady)
179  print "(a)", "# Solution will be transferred to the next finer grid after this time step."
180  end select
181 
182  end if
183 
184  end if testprevious
185 
186  ! Write a blank line, such that the message is pretty clear.
187 
188  print "(a)", "#"
189 
190 #endif /* USE_NO_SIGNALS */
191 
192  end subroutine set_signal_write_quit
void connect_signals(void)
character(len=maxstringlen) strings
integer(kind=inttype), parameter timespectral
Definition: constants.F90:115
integer(kind=inttype), parameter unsteady
Definition: constants.F90:115
integer(kind=inttype), parameter steady
Definition: constants.F90:115
integer(kind=inttype) equationmode
Definition: inputParam.F90:583
integer(kind=inttype) groundlevel
Definition: iteration.f90:18
integer(kind=inttype), parameter signalwrite
Definition: killSignals.f90:24
integer(kind=inttype) localsignal
Definition: killSignals.f90:30
integer(kind=inttype), parameter signalwritequit
Definition: killSignals.f90:25
integer(kind=inttype), parameter nosignal
Definition: killSignals.f90:23
subroutine set_signal_write_quit
Definition: signals.F90:93
subroutine set_signal_write
Definition: signals.F90:2