我在IDL中编写了一个程序,用于根据命令行参数生成散点图.我可以直接在终端中成功调用程序,如下所示:
idl -e “scatterplot_1_2d_file.pro” $infile $outfile $title $xtitle $ytitle $xmin $xmax $ymin $ymax $timescale
其中$*引用了一些输入的字符串文字.问题是,我以为我只能输入那一行,将变量名代替文字,放入bash脚本,并生成一百万个散点图我在休息时.不幸的是,如果我这样做,我得到错误:
idl: -e option cannot be specified with batch files
所以我的下一次尝试是尝试将这些命令写入我随后运行的IDL批处理文件.
这种尝试看起来像这样:
#!/bin/bash indir=/path/to/indir/ outdir=/path/to/outdir/ files=`ls $indir` batchfile=/path/to/tempbatchfile.pro echo .r "/path/to/scatterplot_1_2d_file.pro" >> $batchfile for file in $files do name=${file%\.*} echo scatterplot_1_2d_file $indir$name.txt $outdir$name.jpg $name "Gauge Precipitation (mm)" "NMQ Precipitation (mm)" "*" "*" "*" "*" 2 >> $batchfile done #done file echo exit >> $batchfile idl <<EOF @/path/to/scatterplot_1_2d_file EOF rm $batchfile
我不知道脚本生成的大部分错误是否相关,所以我只是发布开始,如果需要,我会稍后发布其余的:
[foo]$bash script_thing.sh IDL Version 6.3 (linux x86 m32). (c) 2006,Research Systems,Inc. Installation number: 91418. Licensed for personal use by XXXXXXXXX only. All other use is strictly prohibited. PRO scatterplot_1_2d_file ^ % Programs can't be compiled from single statement mode. At: /path/to/scatterplot_1_2d_file.pro,Line 1 % Attempt to subscript ARGS with <INT ( 1)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 2)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 3)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 4)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 5)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 6)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 7)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 8)> is out of range. % Execution halted at: $MAIN$ % Attempt to subscript ARGS with <INT ( 9)> is out of range. % Execution halted at: $MAIN$
我不知道我是不是只想做一些无法做到的事情,但它并不喜欢它.有什么建议?
有两种方法可以解决这个问题:使用COMMAND_LINE_ARGS或构建有效的IDL例程调用.此例程使用两者:
pro test,other_args compile_opt strictarr args = command_line_args(count=nargs) help,nargs if (nargs gt 0L) then print,args help,other_args if (n_elements(other_args) gt 0L) then print,other_args end
Desktop$idl -e "test" -args $MODE IDL Version 8.2,Mac OS X (darwin x86_64 m64). (c) 2012,Exelis Visual Information Solutions,Inc. Installation number: 216855. Licensed for use by: Tech-X Corporation % Compiled module: TEST. NARGS LONG = 1 test OTHER_ARGS UNDEFINED = <Undefined> Desktop$idl -e "test,'$MODE'" IDL Version 8.2,Inc. Installation number: 216855. Licensed for use by: Tech-X Corporation % Compiled module: TEST. NARGS LONG = 0 OTHER_ARGS STRING = 'test' test