Blame view

src/idl/dustem_run_plugins.pro 3.39 KB
80386bb1   Jean-Philippe Bernard   removed need for ...
1
2
PRO dustem_run_plugins $
	;,p_dim $
08e3260e   Jean-Philippe Bernard   cleaned unused ke...
3
4
5
6
7
8
9
                      ,param_descs $
                      ,param_values $
                      ,run_order $
                      ,ask_for_st=ask_for_st $
                      ,st=st $
                      ,N2be_run=N2be_run $
                      ,help=help
0c25ef54   Ilyes Choubani   Forgotten procedure
10

57cdd991   Ilyes Choubani   updating sections...
11
12
13
;+
; NAME:
;    dustem_run_plugins
8768c2c2   Annie Hughes   generalised strin...
14
;  
57cdd991   Ilyes Choubani   updating sections...
15
; PURPOSE:
2a8e29d5   Ilyes Choubani   small corrections...
16
;    runs the plugins according to their scopes
40cb4765   Ilyes Choubani   Small correction ...
17
;    a N_ELEMENTS(PLUGINS)X N_ELEMENTS(SCOPES) matrix is created to achieve this 
8768c2c2   Annie Hughes   generalised strin...
18
;
57cdd991   Ilyes Choubani   updating sections...
19
; CATEGORY:
8dbb9ca6   Annie Hughes   fix bug with free...
20
;    DustEMWrap, Distributed, Mid-Level, Plugins
8768c2c2   Annie Hughes   generalised strin...
21
;
57cdd991   Ilyes Choubani   updating sections...
22
; CALLING SEQUENCE:
08e3260e   Jean-Philippe Bernard   cleaned unused ke...
23
;    dustem_run_plugins,p_dim,param_descs,param_values,run_order,[,/ask_for_st][,st][N2be_run=][,/help] 
8768c2c2   Annie Hughes   generalised strin...
24
;
57cdd991   Ilyes Choubani   updating sections...
25
; INPUTS:
80386bb1   Jean-Philippe Bernard   removed need for ...
26
;    p_dim  = parameter values  (actually not used)
87785eb6   Ilyes Choubani   Completing help h...
27
28
;    param_descs = parameter description vector
;    param_values = current parameter values
a84e0595   Jean-Philippe Bernard   modified plugin s...
29
;    run_order    = run order of the plugins to be run
8768c2c2   Annie Hughes   generalised strin...
30
;
57cdd991   Ilyes Choubani   updating sections...
31
; OPTIONAL INPUT PARAMETERS:
8768c2c2   Annie Hughes   generalised strin...
32
;
57cdd991   Ilyes Choubani   updating sections...
33
34
; OUTPUTS:
;    None
8768c2c2   Annie Hughes   generalised strin...
35
;
57cdd991   Ilyes Choubani   updating sections...
36
37
; OPTIONAL OUTPUT PARAMETERS:
;    st         = Dustem output structure
0266152d   Jean-Philippe Bernard   fixed the way for...
38
;    N2be_run   = Number of plugins which have been run
57cdd991   Ilyes Choubani   updating sections...
39
40
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
8768c2c2   Annie Hughes   generalised strin...
41
;
57cdd991   Ilyes Choubani   updating sections...
42
43
; COMMON BLOCKS:
;    None
8768c2c2   Annie Hughes   generalised strin...
44
;
57cdd991   Ilyes Choubani   updating sections...
45
46
; SIDE EFFECTS:
;    None
8768c2c2   Annie Hughes   generalised strin...
47
;
57cdd991   Ilyes Choubani   updating sections...
48
49
; RESTRICTIONS:
;    The DustEM fortran code must be installed
8dbb9ca6   Annie Hughes   fix bug with free...
50
;    The DustEMWrap IDL code must be installed
80386bb1   Jean-Philippe Bernard   removed need for ...
51
;    CAUTION: p_dim is actually not used (!!)
57cdd991   Ilyes Choubani   updating sections...
52
; PROCEDURES AND SUBROUTINES USED:
8768c2c2   Annie Hughes   generalised strin...
53
;
57cdd991   Ilyes Choubani   updating sections...
54
; EXAMPLES
08e3260e   Jean-Philippe Bernard   cleaned unused ke...
55
;    dustem_run_plugins, p_min, param_descs, param_values, scopes, st=st
8768c2c2   Annie Hughes   generalised strin...
56
;
57cdd991   Ilyes Choubani   updating sections...
57
58
59
60
61
; MODIFICATION HISTORY:
;    Written by IC 
;    Evolution details on the DustEMWrap gitlab.
;    See http://dustemwrap.irap.omp.eu/ for FAQ and help.  
;-
0c25ef54   Ilyes Choubani   Forgotten procedure
62

639e87fb   Ilyes Choubani   Allowing run with...
63

8768c2c2   Annie Hughes   generalised strin...
64
65
dew_prefix='dustem_plugin_' ; we assume that this prefix is at the start of all plugin routines

5eebdedb   Jean-Philippe Bernard   changed plugin st...
66
;=== if no plugins, do nothing
0266152d   Jean-Philippe Bernard   fixed the way for...
67
68
69
70
IF (*!dustem_plugin)[0].name EQ 'NONE' THEN BEGIN
	N2be_run=0L
	goto, the_end 
ENDIF
639e87fb   Ilyes Choubani   Allowing run with...
71

0c25ef54   Ilyes Choubani   Forgotten procedure
72
73
74

;LOCATING THE PLUGINS THAT SHOULD BE RUN

5eebdedb   Jean-Philippe Bernard   changed plugin st...
75
76
77
Nparams=n_elements(param_descs)
Nplugins=n_elements(*!dustem_plugin)
must_be_run=intarr(Nplugins)
0c25ef54   Ilyes Choubani   Forgotten procedure
78

5eebdedb   Jean-Philippe Bernard   changed plugin st...
79
FOR i=0L,Nplugins-1 DO BEGIN
a84e0595   Jean-Philippe Bernard   modified plugin s...
80
81
82
		IF (*!dustem_plugin)[i].run_order EQ run_order THEN BEGIN
			must_be_run[i]=1
		ENDIF
0c25ef54   Ilyes Choubani   Forgotten procedure
83
84
ENDFOR

0266152d   Jean-Philippe Bernard   fixed the way for...
85
86
ind2be_run=where(must_be_run EQ 1,count)
N2be_run=count
a84e0595   Jean-Philippe Bernard   modified plugin s...
87

5eebdedb   Jean-Philippe Bernard   changed plugin st...
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
;=== 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:*]
746b3ee2   Jean-Philippe Bernard   fixed for REPLACE...
107
108
109
110
		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)
746b3ee2   Jean-Philippe Bernard   fixed for REPLACE...
111
112
113
114
115
		ENDIF ELSE BEGIN
			str='spectrum='+(*!dustem_plugin)[i].name+'(key=keys,val=vals)'
			message,'executing '+str,/info
			toto=execute(str)
		ENDELSE
746b3ee2   Jean-Philippe Bernard   fixed for REPLACE...
116
		(*!dustem_plugin)[i].spec=ptr_new(spectrum)
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
117
118
119
	ENDIF
ENDFOR

0266152d   Jean-Philippe Bernard   fixed the way for...
120
121

;== JPB: This is now done in dustem_activate_plugins
08e3260e   Jean-Philippe Bernard   cleaned unused ke...
122
;IF keyword_set(force_dustem_run) and N2be_run EQ 0 THEN BEGIN
0266152d   Jean-Philippe Bernard   fixed the way for...
123
124
125
;   st = dustem_run(p_dim,use_previous_fortran=use_previous_fortran)
;   !dustem_current = ptr_new(st)
;ENDIF
746b3ee2   Jean-Philippe Bernard   fixed for REPLACE...
126
127
128

;=== JPB: This was initially above the previous test. I moved it below.
the_end:
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
129

8768c2c2   Annie Hughes   generalised strin...
130
END