dustem_run_plugins.pro
3.39 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
PRO dustem_run_plugins $
;,p_dim $
,param_descs $
,param_values $
,run_order $
,ask_for_st=ask_for_st $
,st=st $
,N2be_run=N2be_run $
,help=help
;+
; NAME:
; dustem_run_plugins
;
; PURPOSE:
; runs the plugins according to their scopes
; a N_ELEMENTS(PLUGINS)X N_ELEMENTS(SCOPES) matrix is created to achieve this
;
; CATEGORY:
; DustEMWrap, Distributed, Mid-Level, Plugins
;
; CALLING SEQUENCE:
; dustem_run_plugins,p_dim,param_descs,param_values,run_order,[,/ask_for_st][,st][N2be_run=][,/help]
;
; INPUTS:
; p_dim = parameter values (actually not used)
; param_descs = parameter description vector
; param_values = current parameter values
; run_order = run order of the plugins to be run
;
; OPTIONAL INPUT PARAMETERS:
;
; OUTPUTS:
; None
;
; OPTIONAL OUTPUT PARAMETERS:
; st = Dustem output structure
; N2be_run = Number of plugins which have been run
; ACCEPTED KEY-WORDS:
; help = if set, print this help
;
; COMMON BLOCKS:
; None
;
; SIDE EFFECTS:
; None
;
; RESTRICTIONS:
; The DustEM fortran code must be installed
; The DustEMWrap IDL code must be installed
; CAUTION: p_dim is actually not used (!!)
; PROCEDURES AND SUBROUTINES USED:
;
; EXAMPLES
; dustem_run_plugins, p_min, param_descs, param_values, scopes, st=st
;
; MODIFICATION HISTORY:
; Written by IC
; Evolution details on the DustEMWrap gitlab.
; See http://dustemwrap.irap.omp.eu/ for FAQ and help.
;-
dew_prefix='dustem_plugin_' ; we assume that this prefix is at the start of all plugin routines
;=== if no plugins, do nothing
IF (*!dustem_plugin)[0].name EQ 'NONE' THEN BEGIN
N2be_run=0L
goto, the_end
ENDIF
;LOCATING THE PLUGINS THAT SHOULD BE RUN
Nparams=n_elements(param_descs)
Nplugins=n_elements(*!dustem_plugin)
must_be_run=intarr(Nplugins)
FOR i=0L,Nplugins-1 DO BEGIN
IF (*!dustem_plugin)[i].run_order EQ run_order THEN BEGIN
must_be_run[i]=1
ENDIF
ENDFOR
ind2be_run=where(must_be_run EQ 1,count)
N2be_run=count
;=== run plugins that need be run
FOR i=0L,Nplugins-1 DO BEGIN
IF must_be_run[i] THEN BEGIN
keys=[0L]
vals=[0.d0]
FOR j=0L,Nparams-1 DO BEGIN
parameter_type=dustem_parameter_description2type(param_descs[j],string_name=string_name,plugin_name=plugin_name,key=key)
IF parameter_type EQ 'PLUGIN' THEN BEGIN
IF plugin_name EQ (*!dustem_plugin)[i].name THEN BEGIN
ind=where(param_descs EQ 'dustem_'+string_name,count)
IF count NE 0 THEN BEGIN
keys=[keys,key]
vals=[vals,param_values[ind[0]]]
ENDIF
ENDIF
ENDIF
ENDFOR
keys=keys[1:*]
vals=vals[1:*]
IF keyword_set(ask_for_st) THEN BEGIN
str='spectrum='+(*!dustem_plugin)[i].name+'(key=keys,val=vals,st=st)'
message,'executing '+str,/info
toto=execute(str)
ENDIF ELSE BEGIN
str='spectrum='+(*!dustem_plugin)[i].name+'(key=keys,val=vals)'
message,'executing '+str,/info
toto=execute(str)
ENDELSE
(*!dustem_plugin)[i].spec=ptr_new(spectrum)
ENDIF
ENDFOR
;== JPB: This is now done in dustem_activate_plugins
;IF keyword_set(force_dustem_run) and N2be_run EQ 0 THEN BEGIN
; st = dustem_run(p_dim,use_previous_fortran=use_previous_fortran)
; !dustem_current = ptr_new(st)
;ENDIF
;=== JPB: This was initially above the previous test. I moved it below.
the_end:
END