Syntax Highlighting

Tuesday, 1 January 2013

Compiling Xfoil on Debian (squeeze)

OK, first off: if you want xfoil to design aerofoils only, then use the xfoil apt package . If, for some reason, you actually want to compile xfoil, then you can follow these instructions.

Instructions

  1. Decide on where the various files for xfoil are going to be stored:
    1. My preferences are to download the file's to the the Downloads directory in my home folder. Extract the zipped files to a 'src' directory in my home folder, and perform all the compilations there. I have a bin folder in my home directory ( ${HOME}/bin/xfoil ) which has a symbolic link to the final compiled binary in src folder ( ${HOME}/src/Xfoil/bin/xfoil ). 
    2. Also decide on if you are going to use double precision or single precision arithmetic. I chose double precision.
  2. Download the source for the xfoil.
  3. Build Orr-Sommerfeld database in ./orrs
    1. cd orrs
    2. pwd
    3. cd src
    4. edit osmap.f
      1. Find the following line in osmap.f (roughly line 100) : DATA OSFILE / '/var/local/codes/orrs/osmap.dat' /
      2. Take the absolute directory string which is generated by the pwd command above, paste it in front of the osmap.dat filename, e.g. DATA OSFILE / '/home/me/src/Xfoil/orrs/osmap.dat' /
      3. This statement will tell SUBROUTINE OSMAP where to find this table data file. 
      4. Find the following line in osmap.f (roughly line 75): REAL*4 RLSP, WLSP, HLSP, & RINCR, WINCR, RL, WL, HL, & A, AR, AW, AH, ARW, ARH, AWH, ARWH
      5. If you choose to use single-precision for the OS data file (should be adequate), leave this line as is. If you wish to do everything in double precision, change the REAL*4 to REAL.
    5. cd ../bin
    6. edit Makefile
      1. Note that there is a lot of redundancy in the make files. For example, in one of the make files the variable FC is assigned about three times. If you get an ifort not found compile error, then you haven't set the last assigned value to your fortran compiler.
      2. Change the compiler flags to match the Fortran compiler on your system. For debian squeeze this is probably fort77 or gfortran. I am using gfortran and have used the setting below:
        FC = gfortran
        FLG = -O -fdefault-real-8
        PLTLIB = -L/usr/X11R6/lib -lX11 # left as is from the intel fortran settings
        FTNLIB = # left as is from the intel fortran settings
      3. Note that the FLG setting -fdefault-real-8 changes the the compiler treats reals. I suspect that this setting overides the change to osmap.f (Item 3dv).
    7. Make the osgen object. Use Makefile_DP for double-precision OS database file.
      1. make osgen
        make osmap.o
        for single precision (check compiler flag settings) OR for double precision:
        make -f Makefile_DP osgen
        make -f Makefile_DP osmap.o
    8. cd .. 
    9. bin/osgen osmaps_ns.lst (creates binary file osmap.dat)
  4. Build the plot library in ./plotlib
    1. cd plotlib
    2. edit Makefile (set compiler flags for your machine)
      1. Comment out the include ./config.make
      2. If you want to use double precision then
        comment out PLTLIB = libPlt.a and uncomment PLTLIB = libPltDP.a
        #PLTLIB = libPlt.a
        PLTLIB = libPltDP.a
        and now set the compiler flags settings for double precision. Uncomment the DP variable and set the appropriate flag. Mine is:
        #DP = -r8 becomes
        DP = -fdefault-real-8
    3. make
  5. Build the programs in ./bin 
    1. cd bin
    2. edit Makefile
      1. Be sure to set up the FC variable and other compiler flags, FFLAGS and FFLOPT (used for xsolve) as appropriate. My settings were:
        FC = gfortran
        FFLAGS = -O3 -fdefault-real-8
        FFLOPT = -O3 -fdefault-real-8
        INSTALLCMD = install -s
        CC = gcc
        CFLAGS = -O -DUNDERSCORE
        Note: some other instructions use the -c flag with gfortran.
      2. make xfoil
        1. At this point, I got some arithmetic overflow errors:
          gfortran -c -O3 -fdefault-real8
          ../src/xoper.f:117.22:

          IINPUT(I) = 2**31
                                  1
          Error: Arithmetic overflow at (1)
        2. This can be fixed by modifying the source code. You need to make two changes, which are easily implemented using the sed command. Thanks to Judson's Notes.:
          cd src/
          sed -i 's/LOGICAL ERROR, LGETFN/LOGICAL ERROR, LGETFN, LERR/g' pplot.f
          sed -i 's/IINPUT(I) = 2\*\*31/IINPUT(I) = HUGE(0)/g' xoper.f
      3. make pplot
      4. make pxplot
    3. If all works out, then you can run xfoil by going to the $BINDIR specified in the make file 

    Sources:

    1. README available in the xfoil source code download (.tar.gz)
    2. Judson's Notes for Compiling Xfoil on Ubuntu 11.04
    3.  Icaro's Blog for HOW TO Compile Xfoil 6.97 in Ubuntu Linux

No comments:

Post a Comment