Examples of Fortran Code Re-written in IDL

Re-writing your fortran code in IDL is not difficult.  The following are examples of original Fortran code by a NIST researcher.



This is a program called align.f.  Click here for an IDL version of the same code called align.pro.  This example shows:
  • Declaring an array
  • Doing some simple math
  • Printing
  • Using a FOR loop
  • Plotting a graph to the monitor
  •  
     
     
     
     
     
     
     
    The outputted graph looks like:
     



     This example is based on the program plotber.f, and was re-written as plotber.pro.  The data files are NPOINT and TRAJ.  This example shows:
       
     
     
     
     

     


      This example is based on the program xy.f, and was re-written as xy.pro.  The data file is example.  This example shows the features listed below, but a caveat should be given.  The original program which generated the data outputted the data to be able to use disspla.  That was a cumbersome way of doing things.  IDL is much easier, but this example is a little cumbersome because it is using the old format (at least in part).  Nonetheless, this example provides useful techniques.   Also included is a special function written to plot both X and Y error bars.  Note that Oploterr is a built-in library function that plots points with Y error bars.
     

     Because this plot uses an external function, you must compile it first before compiling and executing the main code.  An example of the sequence of commands (at the IDL prompt) to do this would be:
    .rnew xyoerr.pro
    .rnew xy.pro
    xy