Author Topic: Formatting Fortran source code in OSX?  (Read 984 times)

Formatting Fortran source code in OSX?
« on: August 17, 2011, 02:35:59 pm »
I'm (reluctantly) using a Mac at work, and can't find out how to nicely format Fortran source code. Using a Windows machine, there is a nice function in the NAG Fortran builder which will capitalise all Fortran keywords, re-do any messed up tabs, line spacings etc, but I can't find similar for Mac. I'm using TextWrangler to write the code, and ifort on the command line to compile.

Any ideas, or is this too arcane even for YACF?

Re: Formatting Fortran source code in OSX?
« Reply #1 on: August 17, 2011, 03:05:35 pm »
There must be a verison of Tidy that will do that for you?

ETA: found one - http://www.unb.ca/fredericton/science/chem/ajit/tidy/

Jaded

  • The Codfather
  • Formerly known as Jaded
Re: Formatting Fortran source code in OSX?
« Reply #2 on: August 17, 2011, 03:07:32 pm »
This thread might have some ideas
If you don't like your democracy, vote against it.

vorsprung

  • Opposites Attract
    • Audaxing
Re: Formatting Fortran source code in OSX?
« Reply #3 on: August 17, 2011, 03:19:49 pm »
http://www.eclipse.org/photran/

Maybe?  I've never used it because I don't program in Fortran
Audaxing Blog follow @vorsprungbike on

Re: Formatting Fortran source code in OSX?
« Reply #4 on: August 17, 2011, 03:30:50 pm »
Nicely formatted Fortran source code? You are a quiche eater, Sir!
If the Good Lord had intended us to use indentation and variable names anything other than X Y and N he would not have given us card punches.

interzen

  • Venture Altruist
  • Agent Orange
    • interzen.homeunix.org
Re: Formatting Fortran source code in OSX?
« Reply #5 on: August 17, 2011, 03:39:39 pm »
Use vim (www.vim.org)

Re: Formatting Fortran source code in OSX?
« Reply #6 on: August 17, 2011, 04:40:37 pm »
Tidy looks like just the job, but unfortunately the download link for Mac doesn't work. I installed MacVim, but it's not obvious to me how to do what I'm trying to do with it (looks pretty Linux-tastic tbh). Perhaps you can tell me how to do it?

I'm after a simple way to reformat a given file. Simple as in like a couple of clicks ideally.

I also had a go on photran, and it would correct indentation (which I don't really need) but can't find the capitalisation feature I'm after.

Thanks for the ideas though!




Re: Formatting Fortran source code in OSX?
« Reply #7 on: August 17, 2011, 04:50:16 pm »
The Tidy source code is downloadable, thobut.

Re: Formatting Fortran source code in OSX?
« Reply #8 on: August 17, 2011, 06:49:51 pm »
That is true, but I am not particularly 1337 - I did have a look and read the instructions in said source code download and it appeared to say just put the exe in my path (not sure where that refers to - directory containing the Fortran files?) and then you're good to go in a command line sense. I just unzipped it using Kubuntu, and all I get are a couple of readme files (even though there are several other files in the zip archive).

If you have any patience to explain to a computer intermediate (I'm not sure what to do with this), I'd be most grateful. On the face of it, Tidy looks to be just what I'm after...

Re: Formatting Fortran source code in OSX?
« Reply #9 on: September 01, 2011, 02:35:53 pm »
All sorted - tidy does the job nicely. I didn't put 2 and 2 together that it was itself a Fortran program (despite all the (in retrospect, very obvious) clues). Cheers for the ideas one and all.

Panoramix

  • 50 61 6E 6F 72 61 6D 69 78
  • Suus cuique crepitus bene olet
    • Some routes
Re: Formatting Fortran source code in OSX?
« Reply #10 on: September 01, 2011, 02:54:15 pm »
I hadn't realised that people were still using Fortran. Are you designing rockets or doing some weather forecasting? (just curious)
Chief cat entertainer.

Re: Formatting Fortran source code in OSX?
« Reply #11 on: September 01, 2011, 04:46:54 pm »
Started a new job doing atmospheric process-level modelling. Everyone asks me why I'm using Fortran. Because that's what the model is written in! It's supposed to be an efficient language I believe, which I think is the reason for the choice. That and academics seem to love it.

interzen

  • Venture Altruist
  • Agent Orange
    • interzen.homeunix.org
Re: Formatting Fortran source code in OSX?
« Reply #12 on: September 01, 2011, 04:57:04 pm »
Started a new job doing atmospheric process-level modelling. Everyone asks me why I'm using Fortran. Because that's what the model is written in! It's supposed to be an efficient language I believe, which I think is the reason for the choice. That and academics seem to love it.
I haven't touched Fortran since I finished my PhD (amongst other things, I wrote some code to model supersonic, reactive flows) but it's still very much alive and well, particularly in legacy applications. Quite a lot of the newer code, particularly in computational fluid dynamics, seems to be written in C++ (spit!) nowadays.

Re: Formatting Fortran source code in OSX?
« Reply #13 on: September 02, 2011, 09:52:15 am »
There must be an Emacs mode for Fortran, there's an Emacs mode for everything ...
I think you'll find it's a bit more complicated than that.

interzen

  • Venture Altruist
  • Agent Orange
    • interzen.homeunix.org
Re: Formatting Fortran source code in OSX?
« Reply #14 on: September 02, 2011, 09:53:53 am »
There must be an Emacs mode for Fortran, there's an Emacs mode for everything ...
There is, but I prefer my text editors to edit text, not make tea.