Blame view

src/idl/dustem_run_plugins.pro 3.54 KB
a84e0595   Jean-Philippe Bernard   modified plugin s...
1
2
3
4
5
6
7
8
9
10
PRO dustem_run_plugins, p_dim $
                        ,param_descs $
                        ,param_values $
                        ,param_func $
                        ,run_order $
                        ,st=st $
                        ,avoid=avoid $
                        ,force_dustem_run=force_dustem_run $
                        ,use_previous_fortran=use_previous_fortran  $
                        ,help=help
0c25ef54   Ilyes Choubani   Forgotten procedure
11

57cdd991   Ilyes Choubani   updating sections...
12
13
14
;+
; NAME:
;    dustem_run_plugins
8768c2c2   Annie Hughes   generalised strin...
15
;  
57cdd991   Ilyes Choubani   updating sections...
16
; PURPOSE:
2a8e29d5   Ilyes Choubani   small corrections...
17
;    runs the plugins according to their scopes
40cb4765   Ilyes Choubani   Small correction ...
18
;    a N_ELEMENTS(PLUGINS)X N_ELEMENTS(SCOPES) matrix is created to achieve this 
8768c2c2   Annie Hughes   generalised strin...
19
;
57cdd991   Ilyes Choubani   updating sections...
20
; CATEGORY:
8dbb9ca6   Annie Hughes   fix bug with free...
21
;    DustEMWrap, Distributed, Mid-Level, Plugins
8768c2c2   Annie Hughes   generalised strin...
22
;
57cdd991   Ilyes Choubani   updating sections...
23
; CALLING SEQUENCE:
355953bc   Annie Hughes   modifs because gd...
24
;    dustem_run_plugins,p_dim,param_descs,param_values,scopes,[,st][,avoid][,force_dustem_run][,/help] 
8768c2c2   Annie Hughes   generalised strin...
25
;
57cdd991   Ilyes Choubani   updating sections...
26
27
; INPUTS:
;    p_dim  = parameter values 
87785eb6   Ilyes Choubani   Completing help h...
28
29
30
;    param_descs = parameter description vector
;    param_values = current parameter values
;    param-func   = plugin indices array 
a84e0595   Jean-Philippe Bernard   modified plugin s...
31
;    run_order    = run order of the plugins to be run
8768c2c2   Annie Hughes   generalised strin...
32
;
57cdd991   Ilyes Choubani   updating sections...
33
34
; OPTIONAL INPUT PARAMETERS:
;    avoid      = scopes should be avoided
355953bc   Annie Hughes   modifs because gd...
35
;    force_dustem_run = Dustem should be run
5eebdedb   Jean-Philippe Bernard   changed plugin st...
36
;    use_previous_fortran = if set, uses the output of the previous fortran run, and does not run the fortran.
8768c2c2   Annie Hughes   generalised strin...
37
;
57cdd991   Ilyes Choubani   updating sections...
38
39
; OUTPUTS:
;    None
8768c2c2   Annie Hughes   generalised strin...
40
;
57cdd991   Ilyes Choubani   updating sections...
41
42
; OPTIONAL OUTPUT PARAMETERS:
;    st         = Dustem output structure
8768c2c2   Annie Hughes   generalised strin...
43
;
57cdd991   Ilyes Choubani   updating sections...
44
45
; ACCEPTED KEY-WORDS:
;    help                  = if set, print this help
8768c2c2   Annie Hughes   generalised strin...
46
;
57cdd991   Ilyes Choubani   updating sections...
47
48
; COMMON BLOCKS:
;    None
8768c2c2   Annie Hughes   generalised strin...
49
;
57cdd991   Ilyes Choubani   updating sections...
50
51
; SIDE EFFECTS:
;    None
8768c2c2   Annie Hughes   generalised strin...
52
;
57cdd991   Ilyes Choubani   updating sections...
53
54
; RESTRICTIONS:
;    The DustEM fortran code must be installed
8dbb9ca6   Annie Hughes   fix bug with free...
55
;    The DustEMWrap IDL code must be installed
8768c2c2   Annie Hughes   generalised strin...
56
;
57cdd991   Ilyes Choubani   updating sections...
57
; PROCEDURES AND SUBROUTINES USED:
8768c2c2   Annie Hughes   generalised strin...
58
;
57cdd991   Ilyes Choubani   updating sections...
59
; EXAMPLES
355953bc   Annie Hughes   modifs because gd...
60
;    dustem_run_plugins, p_min, param_descs, param_values, param_func, scopes, st=st, avoid=avoid, /force_dustem_run 
8768c2c2   Annie Hughes   generalised strin...
61
;
57cdd991   Ilyes Choubani   updating sections...
62
63
64
65
66
; 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
67

639e87fb   Ilyes Choubani   Allowing run with...
68

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

5eebdedb   Jean-Philippe Bernard   changed plugin st...
71
72
;=== if no plugins, do nothing
IF (*!dustem_plugin)[0].name EQ 'NONE' THEN goto, the_end 
639e87fb   Ilyes Choubani   Allowing run with...
73

5eebdedb   Jean-Philippe Bernard   changed plugin st...
74
;==== This is probably not useful
91e991b5   Ilyes Choubani   Applying correcti...
75
if not keyword_set(avoid) then avoid=0
355953bc   Annie Hughes   modifs because gd...
76
if not keyword_set(force_dustem_run) then force_dustem_run=0
91e991b5   Ilyes Choubani   Applying correcti...
77

5eebdedb   Jean-Philippe Bernard   changed plugin st...
78
79
;print,scopes
;print,(*!dustem_plugin).scope
0c25ef54   Ilyes Choubani   Forgotten procedure
80
81
82

;LOCATING THE PLUGINS THAT SHOULD BE RUN

5eebdedb   Jean-Philippe Bernard   changed plugin st...
83
84
85
Nparams=n_elements(param_descs)
Nplugins=n_elements(*!dustem_plugin)
must_be_run=intarr(Nplugins)
0c25ef54   Ilyes Choubani   Forgotten procedure
86

5eebdedb   Jean-Philippe Bernard   changed plugin st...
87
FOR i=0L,Nplugins-1 DO BEGIN
a84e0595   Jean-Philippe Bernard   modified plugin s...
88
89
90
		IF (*!dustem_plugin)[i].run_order EQ run_order THEN BEGIN
			must_be_run[i]=1
		ENDIF
0c25ef54   Ilyes Choubani   Forgotten procedure
91
92
ENDFOR

a84e0595   Jean-Philippe Bernard   modified plugin s...
93
94
95
;print,must_be_run
;stop

5eebdedb   Jean-Philippe Bernard   changed plugin st...
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
;=== 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:*]
		str='(*!dustem_plugin)['+strtrim(i,2)+'].spec=ptr_new('+(*!dustem_plugin)[i].name+'(key=keys,val=vals)'+')'
		message,'executing '+str,/info
		toto=execute(str)
4a2d1650   Jean-Philippe Bernard   improved
118
		;stop
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
119
120
121
	ENDIF
ENDFOR

9afd87a1   Ilyes Choubani   fixed goto condit...
122
the_end:
5eebdedb   Jean-Philippe Bernard   changed plugin st...
123
124
IF keyword_set(force_dustem_run) THEN BEGIN ;and idd gt 0. : remved this so that dustem is always run when the keyword is mentioned.
   st = dustem_run(p_dim,use_previous_fortran=use_previous_fortran)
6dc6aa41   Annie Hughes   stop removal
125
   !dustem_current = ptr_new(st)
5eebdedb   Jean-Philippe Bernard   changed plugin st...
126
ENDIF 
2bbb56cf   Jean-Philippe Bernard   modified to fix b...
127

8768c2c2   Annie Hughes   generalised strin...
128
END