 <p>There are several ways you can do this.</p> <p>It looks like you have four columns and 40,000 lines, correct?</p> <p>Then you can do the following. First, I will assume there is no header data in the ASCII file for the following commands.</p> <pre><code>FUNCTION read_my_file,file_name ;; Assume FILE_NAME is full path to and including file name with extension fname = file_name[0] ;; One could also find the file with the following ;; fname = FILE_SEARCH([path to file],[file name with extension]) ;; Define the number of lines in the file nl = FILE_LINES(fname[0]) ;; Define empty arrays to fill col1 = DBLARR(nl[0]) col2 = DBLARR(nl[0]) col3 = DBLARR(nl[0]) col4 = DBLARR(nl[0]) dumb = DBLARR(4) ;; Open file OPENR,gunit,fname[0],ERROR=err,/GET_LUN IF (err NE 0) THEN PRINT, -2, !ERROR_STATE.MSG ;; Prints an error message FOR n=0L, nl[0] - 1L DO BEGIN ;; Read in file data READF,gunit,FORMAT='(4d)',dumb ;; Fill arrays col1[n] = dumb[0] col2[n] = dumb[1] col3[n] = dumb[2] col4[n] = dumb[3] ENDFOR ;; Close file FREE_LUN,gunit ;; Define output output = [[col1],[col2],[col3],[col4]] ;; Return to calling routine RETURN,output END </code></pre> <p>Note that this will work better if you provide an explicit width for the format statement, e.g., <code>'(4d15.5)</code>, which means a 15 character input with 5 decimal places.</p> <p>This will return <code>col1</code> through <code>col4</code> to the user or calling routine as an [N,4]-element array, e.g., <code>col1 = output[*,0]</code>. You could use a structure where each tag contains one of the <code>colj</code> arrays or you could return them through <code>keywords</code>.</p> <p>Then you can pass these arrays to another function/program in the following way:</p> <pre><code>PRO my_algorithm_wrapper,file_name,RESULTS=results ;; Get data from files columns = read_my_file(file_name) ;; Pass data to [algorithm] function results = my_algorithm(columns[*,0],columns[*,1],columns[*,2],columns[*,3]) ;; Return to user RETURN END </code></pre> <p>To call this from the command line (after making sure both routines are compiled), you would do something like the following:</p> <pre><code>IDL&gt; my_algorithm_wrapper,file_name,RESULTS=results IDL&gt; HELP,results ;; see what the function my_algorithm.pro returned </code></pre> <p>The above code should work with IDL 6.2.</p> <h1><strong>General Notes</strong></h1> <ol> <li>Try to avoid using uppercase letters in IDL routine names as it can cause issues when IDL searches for the routine during a call or compilation statement.</li> <li>You need to name the program/function in the line with the <code>PRO</code>/<code>FUNCTION</code> statement at the beginning of the file. The name must come immediately after the <code>PRO</code>/<code>FUNCTION</code> statement.</li> <li>It is generally wise to use explicit formatting statements to avoid ambiguities/errors when reading data files.</li> <li>You can pass any variable type (e.g., scalar integer, array, structure, object, etc.) to programs/functions so long as they are handled appropriately within the program/function.</li> </ol>