Commit 2bbb56cf1d8225fe886dfaffcf6f7b57a745fb5d

Authored by Jean-Philippe Bernard
1 parent 95bdc476
Exists in master

modified to fix bugs when running under fawlty

src/idl/dustem_activate_plugins.pro
... ... @@ -76,6 +76,9 @@ endelse
76 76 ;IF /avoid is used the specified scopes are avoided. They're considered when /avoid is missing.
77 77 ;using '**' so not to write the entire scope
78 78 dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['*STELLAR*','*REPLACE*','*ISRF*'], avoid=1
  79 +;stop
  80 +;=== The line below makes fawlty go Segmentation fault. st is undefined at that stage
  81 +;=== it would run fine if avoid was set to 1
79 82 dustem_run_plugins, p_dim ,param_descs, param_values, param_func, ['*STELLAR*','*ISRF*'] ,dustem_run=1,st=st ;dustem output is available at this step.
80 83  
81 84 ;added this small condition to ensure that dustem is run
... ...
src/idl/dustem_plugin_stellar_population.pro
1   -Function dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramtag=paramtag,help=help
  1 +Function dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramtag=paramtag,help=help,test=test
2 2  
3 3 ;+
4 4 ; NAME:
... ... @@ -32,6 +32,8 @@ Function dustem_plugin_stellar_population, key=key, val=val, scope=scope, paramt
32 32 ;-
33 33 ;- HISTORY: ADDED STELLAR LUMINOSITY CLASSES
34 34  
  35 +IF keyword_set(test) THEN stop
  36 +
35 37 IF keyword_set(help) THEN BEGIN
36 38 doc_library,'dustem_plugin_stellar_population'
37 39 goto,the_end
... ... @@ -88,8 +90,12 @@ IF keyword_set(key) THEN BEGIN
88 90 T_eff_MS = V2
89 91 R_star_MS = V7
90 92  
91   -
92   - lumclass = (strmid(key,2)).remove(-1) ; extracting the luminosity class strings
  93 + ;JPB: This is highly non standard and makes Fawlty go "Segmentation fault"
  94 + ;lumclass = (strmid(key,2)).remove(-1) ; extracting the luminosity class strings
  95 + lumclass=strarr(n_elements(key))
  96 + FOR i=0L,n_elements(key)-1 DO BEGIN
  97 + lumclass[i]=strmid(key[i],2,1)
  98 + ENDFOR
93 99 params = strmid(key,0,/reverse_offset) ; extracting the indices (in the 'key' array) of the stellar parameters to fit
94 100  
95 101 ; Locating the O3 stellar population parameters - this new code structure accounts for the presence of different luminosity classes.
... ... @@ -1855,7 +1861,7 @@ IF keyword_set(key) THEN BEGIN
1855 1861  
1856 1862 comp_pop=replicate(one_pop,popnumber) ; Replication of the default and initialized stellar population structure to create the composite stellar population structure. All the tag values are by default set to te null value
1857 1863  
1858   -
  1864 + ;stop
1859 1865  
1860 1866 ;Filling the tags of the compsite stellar population structure using the indices defined above
1861 1867  
... ...
src/idl/dustem_run_plugins.pro
1 1 PRO dustem_run_plugins, p_dim ,$
2   -param_descs,$
3   -param_values,$
4   -param_func,$
5   -scopes,$
6   -st=st,$
7   -avoid=avoid,$
8   -dustem_run=dustem_run,$
9   -help=help
  2 + param_descs,$
  3 + param_values,$
  4 + param_func,$
  5 + scopes,$
  6 + st=st,$
  7 + avoid=avoid,$
  8 + dustem_run=dustem_run,$
  9 + help=help
10 10  
11 11 ;+
12 12 ; NAME:
... ... @@ -54,12 +54,15 @@ help=help
54 54 ;Because I don't want to run this block each time the procedure is run I will test on the presence of all the scope tags in !dustem_plugin
55 55 ;if all of them are present then this block has been run.
56 56  
  57 +;stop
  58 +
57 59 IF (tag_names(*!dustem_plugin))(0) EQ 'NONE' THEN goto, the_end
58 60  
59 61 ;Just to be sure
60 62 if not keyword_set(avoid) then avoid=0
61 63 if not keyword_set(dustem_run) then dustem_run=0
62 64  
  65 +;stop
63 66  
64 67 test_all_scopes = 1.
65 68 FOR i=0L,n_tags(*!dustem_plugin)-1 DO BEGIN
... ... @@ -69,6 +72,8 @@ FOR i=0L,n_tags(*!dustem_plugin)-1 DO BEGIN
69 72  
70 73 ENDFOR
71 74  
  75 +;stop
  76 +
72 77 IF ~test_all_scopes THEN BEGIN
73 78 ;FIRST LOOP TO RETRIEVE THE SCOPES OF ALL THE PLUGINS
74 79 f=1 ; Initializing the index that is associated to each plugin
... ... @@ -121,6 +126,7 @@ IF ~test_all_scopes THEN BEGIN
121 126 ENDFOR
122 127 ENDIF
123 128  
  129 +;stop
124 130  
125 131 ;LOCATING THE PLUGINS THAT SHOULD BE RUN
126 132  
... ... @@ -172,68 +178,79 @@ FOR i=0L,n_elements(scopes)-1 DO BEGIN
172 178  
173 179 ENDFOR
174 180  
175   -
  181 +;stop
176 182 ;RUNNING THE PLUGINS ACCORDING TO THEIR SCOPES
177 183  
178 184 f=1 ; Initializing the index that is associated to each plugin
179 185 FOR i=0L,n_elements(param_descs)-1 DO BEGIN
180 186  
181   - parameter_type=dustem_parameter_description2type(param_descs[i],string_name=string_name) ; Looping over the parameter description vector (here saved in a system variable) to sort out its different elements with repect to their types
182   -
183   - IF parameter_type EQ 'PLUGIN' THEN BEGIN ; Selecting the plugins
184   -
185   - ftn = strmid(param_descs(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
186   - ii = strsplit(ftn,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
187   - ftn = strmid(ftn,0,ii) ; String containing the name of the plugin without the associated keyword
188   -
189   - k=where(strmid(tag_names(*!dustem_plugin),0,8) eq strmid(strupcase(strmid(ftn,14)),0,8),counte) ; Selecting a plugin through matching the string name of the plugin from the scope system variable with the one read from the parameter description vector
190   -
191   - tmp = where(param_func eq f, count) ; Array of indices helping with the sorting out of the different plugins (as a plugin can be called several times with different keywords so as to fit several quantities)
192   - PDO_tmp = param_descs(tmp) ; Array containing the different calls of each plugin at a time
193   -
194   - p_dim_tmp = param_values(tmp) ; Array containing the values of the parameters used for the run
195   -
196   - vari = strmid(PDO_tmp(0),ii+1) ; Test variable to be used to alter the initialization of the index and value arrays below for a keyword can be a scalar or a string
197   -
198   - ; Initialization of the index and value arrays. These arrays will be used (below) when calling the plugins (with the default key=key and val=val keywords)
199   -
200   - if strlen(strtrim(string(vari),2)) gt 1 then begin
201   - index = strarr(count) & value = fltarr(count)
202   - endif else begin
203   - index = fltarr(count) & value = fltarr(count)
204   - endelse
205   -
206   - ; Filling the index and value arrays for one plugin at a time
207   - FOR l=0, count-1 DO BEGIN
208   - index[l] = strmid(PDO_tmp[l],ii+1)
209   - value[l] = p_dim_tmp[l]
210   - ENDFOR
211   -
212   - ;==============Runnig of the plugins according to their scopes==============
  187 + parameter_type=dustem_parameter_description2type(param_descs[i],string_name=string_name) ; Looping over the parameter description vector (here saved in a system variable) to sort out its different elements with repect to their types
  188 +
  189 + IF parameter_type EQ 'PLUGIN' THEN BEGIN ; Selecting the plugins
  190 + ;stop
  191 + ftn = strmid(param_descs(i),0) ; String containing the name of the plugin and the keyword used (ie: dustem_create_continuum_2)
  192 + ii = strsplit(ftn,'_',count=countx) & ii = ii(countx-1)-1 ; Locating the last underscore to automate the extraction of the plugin's keyword
  193 + ftn = strmid(ftn,0,ii) ; String containing the name of the plugin without the associated keyword
  194 +
  195 + k=where(strmid(tag_names(*!dustem_plugin),0,8) eq strmid(strupcase(strmid(ftn,14)),0,8),counte) ; Selecting a plugin through matching the string name of the plugin from the scope system variable with the one read from the parameter description vector
  196 + ;help,f
  197 + ;stop
  198 + tmp = where(param_func eq f, count) ; Array of indices helping with the sorting out of the different plugins (as a plugin can be called several times with different keywords so as to fit several quantities)
  199 + PDO_tmp = param_descs(tmp) ; Array containing the different calls of each plugin at a time
  200 +
  201 + p_dim_tmp = param_values(tmp) ; Array containing the values of the parameters used for the run
  202 +
  203 + vari = strmid(PDO_tmp(0),ii+1) ; Test variable to be used to alter the initialization of the index and value arrays below for a keyword can be a scalar or a string
  204 +
  205 + ; Initialization of the index and value arrays. These arrays will be used (below) when calling the plugins (with the default key=key and val=val keywords)
  206 + ;print,ftn,ii,ftn,counte
  207 + ;print,PDO_tmp,p_dim_tmp,vari
  208 + if strlen(strtrim(string(vari),2)) gt 1 then begin
  209 + index = strarr(count) & value = fltarr(count)
  210 + endif else begin
  211 + index = fltarr(count) & value = fltarr(count)
  212 + endelse
  213 + ;help,'<<<<',index,count
  214 +
  215 + ; Filling the index and value arrays for one plugin at a time
  216 + FOR l=0, count-1 DO BEGIN
  217 + index[l] = strmid(PDO_tmp[l],ii+1)
  218 + value[l] = p_dim_tmp[l]
  219 + ENDFOR
  220 +
  221 + ;==============Running of the plugins according to their scopes==============
  222 +
  223 +
  224 + if keyword_set(avoid) then idd=product(indices[k,*]) else idd=total(indices[k,*])
  225 +
  226 + IF idd GE 1 THEN BEGIN
  227 + str='((*!dustem_plugin).('+strtrim(k,2)+').spec)=ptr_new('+ftn+'(key=index,val=value)'+')' & str=str(0)
  228 + ;print,'>>>>>',str
  229 + ;stop
  230 + ;plante fawlty quand
  231 + ;((*!dustem_plugin).(1).spec)=ptr_new(dustem_plugin_stellar_population(key=index,val=value))
  232 + toto=execute(str)
  233 + ;stop
  234 + IF !dustem_verbose NE 0 THEN message,strupcase(strmid(ftn,7)),/info
  235 + ENDIF
213 236  
214   -
215   - if keyword_set(avoid) then idd=product(indices[k,*]) else idd=total(indices[k,*])
216   -
217   - IF idd GE 1 THEN BEGIN
218   -
219   - str='((*!dustem_plugin).('+strtrim(k,2)+').spec)=ptr_new('+ftn+'(key=index,val=value)'+')' & str=str(0)
220   - toto=execute(str) & IF !dustem_verbose NE 0 THEN message,strupcase(strmid(ftn,7)),/info
221   -
222   - ENDIF
223   -
224   -
225   -
226   - f=f+1 & i=i+count-1 ; Incrementing the parameter and same-type plugin indices
  237 +
  238 +
  239 + f=f+1 & i=i+count-1 ; Incrementing the parameter and same-type plugin indices
227 240  
228   - ENDIF
229   - ENDFOR
230   -
  241 + ENDIF
  242 +ENDFOR
  243 +
  244 +;stop
  245 +
231 246 if keyword_set(dustem_run) then begin
232 247  
233 248 st = dustem_run(p_dim)
234 249 !dustem_current = ptr_new(st)
235 250  
236 251 endif
237   -
  252 +
  253 +;stop
  254 +
238 255 the_end:
239 256 END
240 257 \ No newline at end of file
... ...
src/idl/dustem_write_isrf_lv.pro
... ... @@ -86,7 +86,8 @@ IF ctpop NE 0 or ctusrisrf NE 0 THEN BEGIN
86 86 final_isrf = fltarr(n_elements(st)) ;Initializing the ISRF vector
87 87 Ncomments=3 ;default number of comments in the .DAT file (minus the ISRF used)
88 88 c=strarr(Ncomments)
89   - c(0)='# DUSTEM: exciting radiation field featuring'
  89 + c(0)='# DUSTEM: exciting radiation field featuring'
  90 + ;stop
90 91 IF ctpop NE 0 THEN final_isrf=final_isrf+(*(*!dustem_plugin).(tstpop).spec)
91 92 IF ctusrisrf NE 0 THEN final_isrf=final_isrf+(*(*!dustem_plugin).(tstusrisrf).spec)
92 93  
... ...