{"id":6,"date":"2006-11-18T17:26:52","date_gmt":"2006-11-19T01:26:52","guid":{"rendered":"http:\/\/www.viscerallogic.com\/programming\/blog\/2006\/11\/18\/compiling-with-gfortran\/"},"modified":"2006-12-29T11:02:38","modified_gmt":"2006-12-29T19:02:38","slug":"compiling-with-gfortran","status":"publish","type":"post","link":"https:\/\/www.viscerallogic.com\/programming\/blog\/compiling-with-gfortran\/","title":{"rendered":"Compiling with gfortran"},"content":{"rendered":"<p>I compiled <a href=\"http:\/\/web.mit.edu\/drela\/Public\/web\/xfoil\/\">XFoil<\/a> earlier today for my Mac.  XFoil is an open-source airfoil analysis tool.  There are various compiled binaries available for Windows systems, but for Unix computers, including Mac OS X, it must be built from the source code.  This requires the use of a Fortran compiler.  To build it on my Intel-based Mac (10.4.8), I made use of the GCC&#8217;s gfortran compiler, available <a href=\"http:\/\/hpc.sourceforge.net\/\">here<\/a> along with several other Mac Fortran compilers and other interesting stuff.<!--more-->\n<\/p>\n<p>The gfortran utility can be installed in its default location of \/usr\/local\/bin.  This location is not included in the executable search path by default, so you will need to modify your PATH environment variable.  I use the default BASH shell, which looks for the file <i>.profile<\/i> in your home directory.  You can add the following line to that file (creating it if it does not already exist) to add to the PATH variable:<\/p>\n<blockquote><p>\nexport PATH=$PATH:\/usr\/local\/bin\n<\/p><\/blockquote>\n<p>\nYou will now be able to compile XFoil.  There are various items you will need to compile.  You can just follow the Readme file.  It will tell you to modify your Makefile to set the compiler and flags appropriately.  In this case, you will set the compiler (FF) to <i>gfortran<\/i>.  Unfortunately, the makefiles are not all commented properly, so you will need to make sure you edit the last definition of FF.  If you try to compile and you get an error saying <i>ifort<\/i> is not a recognized command, this is because you have not set the last entry.  Also, some of the makefiles include a file <i>config.make<\/i>, which also defines FF.  If this is the case, that file is the place to modify it.<\/p>\n<p>\nThe steps taken so far should allow you to <i>compile<\/i> all the files.  However, when the linker then attempts to join the files into an executable or library, for some of them you will get an error saying <i>___dso_handle<\/i> is an undefined symbol.  Apparently this is a problem with the gfortran compiler.  You can get rid of it by adding as a compiler flag:<\/p>\n<blockquote><p>\n-mmacosx-version-min=10.5\n<\/p><\/blockquote>\n<p>\nI don&#8217;t know why this works or what it actually does, but it should get rid of the linking error, allowing you fully compile the software.  I have compiled XFoil previously on a PPC mac, using the <i>g77<\/i> compiler, and encountered some slightly different problems.  I will make another post to show how that works.<\/p>\n<p>\nTo compile <a href=\"http:\/\/web.mit.edu\/drela\/Public\/web\/avl\/\">AVL<\/a>, a vortex lattice code by the same author, you will need to folow the same steps.  Additionally, you will need to make a small change in the <i>aplotmd.f<\/i> file.  Open it and do a search for &#8220;CLOCKX&#8221;. This is a function supported by Intel Fortran compilers.  However, you will see just below this call that an alternative for other compilers is present but commented out.  Comment out the CLOCKX stuff, and uncomment the SECNDS call.  This will now compile and link correctly with <i>gfortran<\/i>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I compiled XFoil earlier today for my Mac. XFoil is an open-source airfoil analysis tool. There are various compiled binaries available for Windows systems, but for Unix computers, including Mac OS X, it must be built from the source code. This requires the use of a Fortran compiler. To build it on my Intel-based Mac [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[7,2,5],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9npkn-6","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":10,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/smultron-code-editor\/","url_meta":{"origin":6,"position":0},"title":"Smultron Code Editor","date":"May 16, 2007","format":false,"excerpt":"In developing software, the choice of tools used can affect the ease of the job significantly. While the choice of a language may dictate the compiler to be used, there are generally a number of options for the code editor. For most C, Objective-C, and Java applications, I use Apple's\u2026","rel":"","context":"In &quot;OS X&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/desktop-screensaver-background\/","url_meta":{"origin":6,"position":1},"title":"Desktop Screensaver Background","date":"February 4, 2007","format":false,"excerpt":"The screensaver module in OS X has a command-line option that allows it to be run in the background of your screen, as a replacement for the desktop picture. I found this in the application bgscreensaver, which contains an AppleScript to launch the screensaver module in the background, using a\u2026","rel":"","context":"In &quot;AppleScript&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/guitar-chords-to-midi-in-objective-c\/","url_meta":{"origin":6,"position":2},"title":"Guitar Chords to MIDI in Objective-C","date":"December 3, 2005","format":false,"excerpt":"This tutorial will show you how to write a program that creates MIDI files of guitar chords by processing text files. Although I wrote this in Objective-C and the GUI is built using Cocoa, the MIDI algorithms could easily be applied to another language or platform. Essentially, this program scans\u2026","rel":"","context":"In &quot;Languages&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":111,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/basic-interpreter-part-v\/","url_meta":{"origin":6,"position":3},"title":"BASIC Interpreter, Part V","date":"September 7, 2018","format":false,"excerpt":"This is a continuation of Part IV. In Part V we will add support for parentheses in mathematical expressions, add the GOTO and END statements, and implement the remaining program storage statements: CATALOG, SCRATCH, and RENAME. Now that we have a framework for supporting numerical operations, adding parentheses is not\u2026","rel":"","context":"In &quot;BASIC&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":46,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/basic-interpreter-part-ii\/","url_meta":{"origin":6,"position":4},"title":"BASIC Interpreter, Part II","date":"September 7, 2018","format":false,"excerpt":"This is a continuation of Part I. In Part II, we will add functionality to store and run BASIC programs, although still limited to the PRINT statement. We will also be adding a LIST statement to print out the currently stored program. We will be adding a number of new\u2026","rel":"","context":"In &quot;BASIC&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":149,"url":"https:\/\/www.viscerallogic.com\/programming\/blog\/basic-interpreter-part-vii\/","url_meta":{"origin":6,"position":5},"title":"Basic Interpreter, Part VII","date":"September 7, 2018","format":false,"excerpt":"This is a continuation of Part VI. This time, we will be adding the FOR-NEXT loop and unary negation. The FOR-NEXT loop takes a couple forms: FOR <VAR> = <START> TO <STOP> ... NEXT <VAR> or FOR <VAR> = <START> TO <STOP> STEP <STEP> ... NEXT <VAR> In the former\u2026","rel":"","context":"In &quot;BASIC&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/posts\/6"}],"collection":[{"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/comments?post=6"}],"version-history":[{"count":0,"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/posts\/6\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/media?parent=6"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/categories?post=6"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.viscerallogic.com\/programming\/blog\/wp-json\/wp\/v2\/tags?post=6"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}