IDL环境下EXOFAST代码运行出现getenv()相关语法错误求助
It looks like the syntax errors you're facing are directly tied to the older IDL version (7.0.6) you're running—EXOFASTv2 is typically validated with newer IDL releases, so some modern syntax that works in recent versions breaks in v7.0.6. Let's break down each error and fix them step by step:
Error 1: Line 3 filepath() Keyword Argument Incompatibility
Your original line:
path = filepath('',root_dir=getenv('EXOFAST_PATH'),subdir=['examples','hat3'])
IDL 7.0.6's filepath function doesn't support the root_dir and subdir keyword arguments—these were introduced in IDL 8.0 and later. Instead, you need to build the path manually using string concatenation and path_sep():
Replace that line with:
exofast_root = getenv('EXOFAST_PATH') path = exofast_root + path_sep() + 'examples' + path_sep() + 'hat3' + path_sep()
This explicitly constructs the full directory path, which is fully compatible with older IDL versions.
Error 2: Line 8 Ambiguous String Concatenation & Line Continuation
Your original line (with continuation):
prefix=path+'fitresults'+path_sep() +'HAT-3b.Torres.', maxsteps=maxsteps, $
Older IDL versions can struggle with inline string concatenation mixed with function call keywords. To fix this, pre-construct the prefix string separately to eliminate ambiguity, and double-check your line continuation ($) has no trailing spaces:
First, add this line before the function call:
prefix_str = path + 'fitresults' + path_sep() + 'HAT-3b.Torres.'
Then update the function call line to:
prefix=prefix_str, maxsteps=maxsteps, $
This separates string construction from the function call, making the syntax clearer and less prone to version-related issues.
Quick Additional Checks
- Confirm
EXOFAST_PATHis set correctly: Runprint, getenv('EXOFAST_PATH')in IDL to ensure it returns the full path to your EXOFASTv2 directory. - Verify EXOFAST libraries are in IDL's path: Run
print, !pathand make sure all EXOFAST subdirectories are listed here.
内容的提问来源于stack exchange,提问作者Mahtaab Phy

