xcode and fortran

Hi folks,

first of all I'd like to drop here my 'hello guys' statement since this is my first post in these forums 🙂
Next i'd like to ask something that I guess I know the answer already but maybe (hopefully) I'm wrong. The fact is that i'm a
university researcher fortran developer who has jumped recently into the Mac world, to find this nice Xcode development tool. Now i've seen how well it handles c and other languages, but i can't make Xcode do some of these nice features with my fortran codes. For exemple somthing I miss is folding/unfolding capabilities including DO loops and IF statement recognition. i've read somewhere that previous versions of Xcode were lacking all that, but now I'm running Xcode 3.2.6 and use the atest intel fortran XE 12.0 composer/compiler. No luck with gfortran either so I suspect is an Xcode issue...
Can anybody confirm that, or (better 🙂 tell me what should i do within xcode to have m fortran files and fortran syntax fully recognized?

Thanks a lot in advance 🙂

Posted on Mar 10, 2011 12:44 AM

Reply
15 replies

Mar 10, 2011 9:20 AM in response to fmazzanti

You're a bit too strong in your statements... I know Xcode already has partial support for fortran at least.
Actually Intel advertises his fortran XE 2011 Composer edition as being supported by Xcode.
Right now I can choose free format or fixed format fortran styles in Xcode.
So i was not asking if Xcode has support for fortran, which i know it has, but rather if that was complete as it is for other languages as C for instance. I was also wondering if other
fortran programmers have ever found these issues and if they know what is going on there.

Thanks anyway for your response...

Mar 10, 2011 10:59 AM in response to fmazzanti

fmazzanti wrote:
You're a bit too strong in your statements... I know Xcode already has partial support for fortran at least.


I think my statement was accurate. There is no explicit support in Xcode for Fortran. You can create a makefile-based project or define a new build rule under Target > Rules. But all of that is just Xcode's support for "other" languages as an IDE. The code editor performs those fancy tricks only with C-based code.

Mar 11, 2011 7:54 PM in response to fmazzanti

While I don't write Fortran code now (almost), a fair amount of legacy code exists at our company, with more on the way due to the fact that many of us grew up with that as our (engineering) language of choice. I dug around on Macresearch.org and eventually ended up adding a special build rule to Xcode to get it to compile the Fortran source along with a C wrapper for making a dynamic library that can be called from MATLAB. So, my "procedure" was: (1) download and install the gfortran compiler from HPC (high performance computing), and then (2) add the following to the build rules for Fortran source:

Fortran source files using Script:
Process: Fortran source files
using: Custom script:


/usr/bin/gfortran -g -m64 -fno-underscoring -c ${PROJECT_DIR}/${INPUT_FILE_NAME} -o ${TARGET_BUILD_DIR}/${INPUT_FILE_BASE}.o


with output files:
Name

$(TARGET_BUILD_DIR)/$(INPUT_FILE_BASE).o

SInce I am really green in all this, I'd suggest you save your questions to me and instead dig through Macresearch.org and read the more recent posts about Fortran development in Xcode. By the way, plugins are not the answer anymore for Xcode 3 and Snow Leopard, so just do the special build rule.

Good luck, and hang in there. Worst case is you could use Xcode 3 for colorized editing, and do your builds at the command line under Terminal.

Mar 24, 2011 1:23 AM in response to Robert McKillip

Hi Robert

sorry for the delay in my reply, but I've been nuried by tons of work and could not devote time to this any more... for a while.
Let me say first that i thnk youa lot for your answer.
Then I must add that i seem to be able to compile and debug using xcode more or less well (that's why I was talking about partial fortran support in Xcode). The real problem is actual debuggin, since global variables in common and modules are not recognized and one can not inspect/modify their values.

Any clue about that?

Thanks...

Apr 14, 2011 9:32 PM in response to Jabberwalky

I am sorry to jump into your post. I am trying to find an answer on: how to set up a gfortran to work with xcode 3.2.5 ?
I am fairly new to Mac (10.6.7). I used to work with Fortran some time ago on mainframes and PCs. Now its time to use Mac and I am a bit lost.
I do not have a problem running the compiler with command line but it could be nice to use a debugging and editing within a nice GUI.

Is there any guide (simple enough for a newbie) to use ?

Nov 23, 2013 6:26 PM in response to fmazzanti

Any new info in this area? I am new to macs and was wondering if recent versions of Xcode have gotten any more friendly with fortran. Despite the gaming and web worlds attachment to C and other newer languages, 95% of the productive work in the scientific and engineering community around the world is still done in Fortran. It does exactly what we need to do in order to accomplish our work. We are more interested in getting the job done, than in recoding a 100 million lines of code just to keep up with the latest programming bandwagon.

Nov 23, 2013 6:53 PM in response to Hydrad

I haven't heard of any interest from Apple in FORTRAN. Apple turns over new operating systems each year now. I can't see them having too much interest in a customer base that prefers 25-year cycles. There are people working in this area. They might appreciate an e-mail telling them to step it up because people are waiting. Then there is the option of using some other FORTRAN compiler with makefile-based projects. That option was poorly received in 2011 so I doubt that has improved.

Jun 11, 2014 7:25 PM in response to fmazzanti

xcode 5.1.1 breaks the old plugin from http://r.research.att.com that actually worked.


apple is too focused on BS objective compiler that is more concerned about returning messages from a swipe than number crunching.


you have to manually compile your fortran code than link the lib or .o in Xode


i use pgfortran but for something quick, get homebrew to install gfortran

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

xcode and fortran

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.