V3FIT
feedback.f
Go to the documentation of this file.
1 !*******************************************************************************
4 !
5 ! Note separating the Doxygen comment block here so detailed decription is
6 ! found in the Module not the file.
7 !
13 !*******************************************************************************
14 
15  MODULE feedback
16 
17  USE signal
18 
19  IMPLICIT NONE
20 
21 !*******************************************************************************
22 ! DERIVED-TYPE DECLARATIONS
23 ! 1) feedback base class
24 !
25 !*******************************************************************************
26 !-------------------------------------------------------------------------------
32 !-------------------------------------------------------------------------------
33  TYPE, EXTENDS(signal_class) :: feedback_class
35  class(signal_class), POINTER :: signal => null()
36  CONTAINS
37  final :: feedback_destruct
38  END TYPE feedback_class
39 
40 !*******************************************************************************
41 ! INTERFACE BLOCKS
42 !*******************************************************************************
43 !-------------------------------------------------------------------------------
46 !-------------------------------------------------------------------------------
47  INTERFACE feedback_class
48  MODULE PROCEDURE feedback_construct
49  END INTERFACE
50 
51  CONTAINS
52 !*******************************************************************************
53 ! CONSTRUCTION SUBROUTINES
54 !*******************************************************************************
55 !-------------------------------------------------------------------------------
62 !-------------------------------------------------------------------------------
63  FUNCTION feedback_construct(signal)
64 
65  IMPLICIT NONE
66 
67 ! Declare Arguments
68  class(feedback_class), POINTER :: feedback_construct_ratio
69  class(signal_class), POINTER :: signal
70 
71 ! local variables
72  REAL (rprec) :: start_time
73 
74 ! Start of executable code
75  start_time = profiler_get_start_time()
76 
77  ALLOCATE(feedback_construct_ratio)
78 
79  feedback_construct_ratio%signal => signal
80 
81  CALL profiler_set_stop_time('feedback_construct', start_time)
82 
83  END FUNCTION
84 
85 !*******************************************************************************
86 ! DESTRUCTION SUBROUTINES
87 !*******************************************************************************
88 !-------------------------------------------------------------------------------
94 !-------------------------------------------------------------------------------
95  SUBROUTINE feedback_destruct(this)
96 
97  IMPLICIT NONE
98 
99 ! Declare Arguments
100  TYPE (feedback_class), POINTER :: this
101 
102 ! Start of executable code
103  IF (ASSOCIATED(this%signal)) THEN
104  this%signal => null()
105  END IF
106 
107  DEALLOCATE(this)
108 
109  END SUBROUTINE
110 
111 !*******************************************************************************
112 ! GETTER SUBROUTINES
113 !*******************************************************************************
114 !-------------------------------------------------------------------------------
128 !-------------------------------------------------------------------------------
129  FUNCTION feedback_get_modeled_signal(this, a_model, sigma, &
130  & last_value)
131 
132  IMPLICIT NONE
133 
134 ! Declare Arguments
135  REAL (rprec), DIMENSION(4) :: feedback_get_modeled_signal
136  class(feedback_class), INTENT(in) :: this
137  TYPE (model_class), POINTER :: a_model
138  REAL (rprec), DIMENSION(4), INTENT(out) :: sigma
139  REAL (rprec), DIMENSION(4), INTENT(in) :: last_value
140 
141 ! local variables
142  REAL (rprec) :: start_time
143 
144 ! Start of executable code
145  start_time = profiler_get_start_time()
146 
147  SELECT CASE(this%type)
148 
149  CASE (feedback_sxrem_ratio_type)
151  & sxrem_ratio_get_modeled_signal(this%ratio, a_model, &
152  & sigma, last_value, &
153  & scale_factor, &
154  & offset_factor)
155 
156  END SELECT
157 
158  CALL profiler_set_stop_time('feedback_get_modeled_signal', &
159  & start_time)
160 
161  END FUNCTION
162 
163 !-------------------------------------------------------------------------------
177 !-------------------------------------------------------------------------------
178  FUNCTION feedback_get_observed_signal(this, a_model)
179 
180  IMPLICIT NONE
181 
182 ! Declare Arguments
183  REAL(rprec) :: feedback_get_observed_signal
184  TYPE(feedback_class), INTENT(in) :: this
185  TYPE (model_class), INTENT(in) :: a_model
186 
187 ! local variables
188  REAL (rprec) :: start_time
189 
190 ! Start of executable code
191  start_time = profiler_get_start_time()
192 
193  SELECT CASE(this%type)
194 
195  CASE (feedback_sxrem_ratio_type)
197  & sxrem_ratio_get_observed_signal(this%ratio, a_model)
198 
199  CASE DEFAULT
201 
202  END SELECT
203 
204  CALL profiler_set_stop_time('feedback_get_observed_signal', &
205  & start_time)
206 
207  END FUNCTION
208 
209 !-------------------------------------------------------------------------------
220 !-------------------------------------------------------------------------------
221  FUNCTION feedback_get_signal_type(this)
223 
224  IMPLICIT NONE
225 
226 ! Declare Arguments
227  CHARACTER (len=data_name_length) :: feedback_get_signal_type
228  TYPE (feedback_class), INTENT(in) :: this
229 
230 ! local variables
231  REAL (rprec) :: start_time
232 
233 ! Start of executable code
234  start_time = profiler_get_start_time()
235 
236  SELECT CASE(this%type)
237 
238  CASE (feedback_sxrem_ratio_type)
239  feedback_get_signal_type = trim('feedback ' // &
240  & sxrem_ratio_get_signal_type(this%ratio))
241 
242  END SELECT
243 
244  CALL profiler_set_stop_time('feedback_get_signal_type', &
245  & start_time)
246 
247  END FUNCTION
248 
249 !-------------------------------------------------------------------------------
258 !-------------------------------------------------------------------------------
259  FUNCTION feedback_get_header(this)
260 
261  IMPLICIT NONE
262 
263 ! Declare Arguments
264  CHARACTER (len=data_name_length), DIMENSION(7) &
266  TYPE (feedback_class), INTENT(in) :: this
267 
268 ! local variables
269  REAL (rprec) :: start_time
270 
271 ! Start of executable code
272  start_time = profiler_get_start_time()
273 
274  SELECT CASE(this%type)
275 
276  CASE DEFAULT
277  feedback_get_header(1:3) = 'N/A'
278  feedback_get_header(4) = 'model_sig(1)'
279  feedback_get_header(5) = 'model_sig(2)'
280  feedback_get_header(6) = 'model_sig(3)'
281  feedback_get_header(7) = 'model_sig(4)'
282 
283  END SELECT
284 
285  CALL profiler_set_stop_time('feedback_get_header', start_time)
286 
287  END FUNCTION
288 
289 !-------------------------------------------------------------------------------
298 !-------------------------------------------------------------------------------
299  FUNCTION feedback_get_feedback_type(this)
300 
301  IMPLICIT NONE
302 
303 ! Declare Arguments
304  CHARACTER (len=data_name_length) :: feedback_get_feedback_type
305  TYPE (feedback_class), INTENT(in) :: this
306 
307 ! local variables
308  REAL (rprec) :: start_time
309 
310 ! Start of executable code
311  start_time = profiler_get_start_time()
312 
313  SELECT CASE(this%type)
314 
315  CASE (feedback_sxrem_ratio_type)
317  & sxrem_ratio_get_signal_type(this%ratio)
318  END SELECT
319 
320  CALL profiler_set_stop_time('feedback_get_feedback_type', &
321  & start_time)
322 
323  END FUNCTION
324 
325 !*******************************************************************************
326 ! UTILITY SUBROUTINES
327 !*******************************************************************************
328 !-------------------------------------------------------------------------------
336 !-------------------------------------------------------------------------------
337  SUBROUTINE feedback_write_auxiliary(this, iou, index)
338 
339  IMPLICIT NONE
340 
341 ! Declare Arguments
342  TYPE (feedback_class), INTENT(in) :: this
343  INTEGER, INTENT(in) :: iou
344  INTEGER, INTENT(in) :: index
345 
346 ! local variables
347  REAL (rprec) :: start_time
348 
349 ! Start of executable code
350  start_time = profiler_get_start_time()
351 
352  WRITE (iou,*)
353  WRITE (iou,1000) index, feedback_get_feedback_type(this)
354 
355  SELECT CASE(this%type)
356 
357  CASE (feedback_sxrem_ratio_type)
358  CALL sxrem_ratio_write_auxiliary(this%ratio, iou)
359 
360  END SELECT
361 
362  CALL profiler_set_stop_time('feedback_write_auxiliary', &
363  & start_time)
364 
365 1000 FORMAT('Signal',1x,i4,1x,'is a feedback signal, type: ',a)
366 
367  END SUBROUTINE
368 
369  END MODULE
feedback::feedback_write_auxiliary
subroutine feedback_write_auxiliary(this, iou, index)
Write out auxiliary signal information to an output file.
Definition: feedback.f:338
feedback::feedback_get_feedback_type
character(len=data_name_length) function feedback_get_feedback_type(this)
Gets a discription of the feedback type.
Definition: feedback.f:300
feedback
Defines the base class of the type feedback_class.
Definition: feedback.f:15
feedback::feedback_get_observed_signal
real(rprec) function feedback_get_observed_signal(this, a_model)
Calculates the observed signal.
Definition: feedback.f:179
feedback::feedback_get_header
character(len=data_name_length) function, dimension(7) feedback_get_header(this)
Gets a discription of the model and model sigma array indices.
Definition: feedback.f:260
feedback::feedback_destruct
subroutine feedback_destruct(this)
Deconstruct a feedback_class object.
Definition: feedback.f:96
feedback::feedback_class
Base class representing a feedback signal.
Definition: feedback.f:33
data_parameters
This modules contains parameters used by equilibrium models.
Definition: data_parameters.f:10
signal::signal_class
Base class representing a signal.
Definition: signal.f:33
feedback::feedback_construct
function feedback_construct(signal)
Construct a feedback_class containing a sxrem_ratio object.
Definition: feedback.f:64
feedback::feedback_get_modeled_signal
real(rprec) function, dimension(4) feedback_get_modeled_signal(this, a_model, sigma, last_value)
Calculates the modeled signal.
Definition: feedback.f:131
feedback::feedback_get_signal_type
character(len=data_name_length) function feedback_get_signal_type(this)
Gets a discription of the feedback signal type.
Definition: feedback.f:222
signal
Defines the base class of the type signal_class.
Definition: signal.f:14