Документ взят из кэша поисковой машины. Адрес оригинального документа : http://hea-www.harvard.edu/PINTofALE/pro/getpoadef.pro
Дата изменения: Sun Sep 20 00:33:22 2015
Дата индексирования: Sun Apr 10 07:35:22 2016
Кодировка:

Поисковые слова: легирование
function getpoadef,varname,force=force,verbose=verbose,_extra=e
;+
;function getpoadef
; returns the default value for a common PINTofALE variable
; usually for filenames, which are often dependent on where
; the files are installed.
;
; The way this works is, if a system variable is already set,
; the default is taken from that. If not, after figuring out
; what the default is (usually by checking where this program
; is located), the appropriate system variable is set to it.
;
;syntax
; default=getpoadef(varname,/force,verbose=verbose)
;
;parameters
; var [INPUT] name of variable as a character string
; * may be an array of strings
; * special variable names are the only ones recognized
; * if 'help' or '?', lists all the variables for which
; defaults can be set
; * in some cases default might be a number, but if the
; input is an array, then the output will always be a
; string array
;
;keywords
; force [INPUT] if set, ignores whether any default (except TOPDIR)
; has already been set and resets it anyway
; * to reset TOPDIR, just do it on the command line, as
; !TOPDIR='/path/to/PINTofALE'
; verbose [INPUT] controls chatter
; _extra [JUNK] here only to prevent crashing the program
;
;history
; Vinay Kashyap (2015aug)
; now if input is scalar, returns scalar (VK; 2015sep)
;-

; usage
ok='ok' & np=n_params() & defsysv,'!TOPDIR',exists=iPoA & nv=n_elements(varname) & szv=size(varname,/type)
if np ne 0 then begin
if nv eq 0 then ok='VARNAME is not defined' else $
if szv ne 7 then ok='VARNAME must be char string scalar or vector'
endif
if ok ne 'ok' then begin
print,'Usage: default=getpoadef(varname,/force,verbose=verbose)'
print,' returns default values for common PINTofALE variables'
if np ne 0 then message,ok,/informational
return,-1L
endif
if np eq 0 and iPoA ne 0 then return,!TOPDIR

; keywords
vv=0L & if keyword_set(verbose) then vv=long(verbose[0])>1L

; define output
def=strarr(nv>1)

; basic default
if iPoA eq 1 then topdir=!TOPDIR else begin ;(iPoA=0

;figure out where this program is and thence where TOPDIR should be
; NOTE: this does not work in GDL, so that part is hardcoded, sorry
defsysv,'!GDL',exists=ivar
if ivar eq 0 then begin
help,/source,output=srcpaths
ok=where(strpos(srcpaths,'getpoadef.pro') gt 0,mok)
if mok gt 0 then begin
cc=strsplit(srcpaths[ok[0]],' ',/extract)
ccc=cc[1] & itree=strpos(ccc,'/pro/getpoadef.pro')
topdir=filepath('',root_dir=strmid(ccc,0,itree))
endif else begin
message,'something went wrong'
endelse
endif else begin
print,'GDL does not support the output keyword to HELP.'
print,'We will define the !TOPDIR variable here, just'
print,'reset it to whatever you want and rerun this function.
print,'Or set it in your GDL_STARTUP.'
topdir='/fubar/SCAR'
endelse
defsysv,'!TOPDIR',topdir
if vv gt 0 then message,'setting !TOPDIR='+!TOPDIR,/informational
if nv eq 0 then def=topdir

endelse ;iPoA=0)

; step through each VARNAME and figure out the default
for i=0L,nv-1L do begin ;{I=0,NV-1

cc=strtrim(strupcase(varname[i]),2)
case cc of ;{variable name

'HELP': begin
print,'variable names can be:'
print,'version topdir ldbdir cdbdir ardb ceroot chidir ionqef atomdb abref caldb'
end

'TOPDIR': def[i]=getpoadef() ;no need to do anything, this is basic default, see above

'VERSION': begin ;(version
defsysv,'!PoA',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!PoA else begin
def[i]='2.9611 (2015sep19)'
defsysv,'!PoA',def[i]
if vv gt 0 then message,'PINTofALE version '+def[i],/informational
endelse ;VERSION)
end

'LDBDIR': begin ;(!TOPDIR/emissivity/chianti
defsysv,'!LDBDIR',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!LDBDIR else begin
def[i]=filepath('chianti',root_dir=!TOPDIR,subdir='emissivity')
defsysv,'!LDBDIR',def[i]
if vv gt 0 then message,'setting !LDBDIR='+!LDBDIR,/informational
endelse
end ;LDBDIR)

'CDBDIR': begin ;(!TOPDIR/emissivity/cont
defsysv,'!CDBDIR',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!CDBDIR else begin
def[i]=filepath('cont',root_dir=!TOPDIR,subdir='emissivity')
defsysv,'!CDBDIR',def[i]
if vv gt 0 then message,'setting !CDBDIR='+!CDBDIR,/informational
endelse
end ;CDBDIR)

'ARDB': begin ;(!TOPDIR/ardb
defsysv,'!ARDB',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!ARDB else begin
def[i]=filepath('ardb',root_dir=!TOPDIR)
defsysv,'!ARDB',def[i]
if vv gt 0 then message,'setting !ARDB='+!ARDB,/informational
endelse
end ;ARDB)

'CEROOT': begin ;(cie
defsysv,'!CEROOT',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!CEROOT else begin
def[i]='cie'
defsysv,'!CEROOT',def[i]
if vv gt 0 then message,'setting !CEROOT='+!CEROOT,/informational
endelse
end ;CEROOT)

'CHIDIR': begin ;(!TOPDIR/../CHIANTI/dbase
defsysv,'!CHIDIR',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!CHIDIR else begin
ccc=!TOPDIR & cccl=strmid(ccc,strlen(ccc)-1,1)
while cccl eq '/' do begin & ccc=strmid(ccc,0,strlen(ccc)-1) & cccl=strmid(ccc,strlen(ccc)-1,1) & endwhile ;strip trailing "/"s
itree=strpos(ccc,'/',/reverse_search)
def[i]=filepath('dbase',root_dir=strmid(ccc,0,itree),subdir='CHIANTI')
defsysv,'!CHIDIR',def[i]
if vv gt 0 then message,'setting !CHIDIR='+!CHIDIR,/informational
endelse
end ;CHIDIR)

'IONEQF': begin ;(ioneq/chianti.ioneq
defsysv,'!IONEQF',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!IONEQF else begin
def[i]=filepath('chianti.ioneq',root_dir='ioneq')
defsysv,'!IONEQF',def[i]
if vv gt 0 then message,'setting !IONEQF='+!IONEQF,/informational
endelse
end ;IONEQF)

'ATOMDB': begin ;(!TOPDIR/../atomdb
defsysv,'!ATOMDB',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!ATOMDB else begin
ccc=!TOPDIR & cccl=strmid(ccc,strlen(ccc)-1,1)
while cccl eq '/' do begin & ccc=strmid(ccc,0,strlen(ccc)-1) & cccl=strmid(ccc,strlen(ccc)-1,1) & endwhile ;strip trailing "/"s
itree=strpos(ccc,'/',/reverse_search)
def[i]=filepath('',root_dir=strmid(ccc,0,itree),subdir='atomdb')
defsysv,'!ATOMDB',def[i]
if vv gt 0 then message,'setting !ATOMDB='+!ATOMDB,/informational
endelse
end ;ATOMDB)

'ABREF': begin ;(grevesse et al.
defsysv,'!ABREF',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!ABREF else begin
def[i]='Grevesse et al.'
defsysv,'!ABREF',def[i]
if vv gt 0 then message,'setting !ABREF='+!ABREF,/informational
endelse
end ;ABREF)

'CALDB': begin ;(!TOPDIR/caldb
defsysv,'!CALDB',exists=ivar
if keyword_set(force) then ivar=0 ;force override
if ivar eq 1 then def[i]=!CALDB else begin
def[i]=filepath('',root_dir=!TOPDIR,subdir='caldb')
defsysv,'!CALDB',def[i]
if vv gt 0 then message,'setting !CALDB='+!CALDB,/informational
endelse
end ;CALDB)

else: begin ;(
if vv gt 0 then message,cc+': variable name not understood',/informational
end ;else)

endcase ;case CC}

endfor ;I=0,NV-1}

if nv eq 1 then def=def[0]

return,def
end