Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 20, 2012, 01:01 AM   #1
dukebound85
macrumors P6
 
dukebound85's Avatar
 
Join Date: Jul 2005
Location: 5045 feet above sea level
Fortran and Netcdf

I am trying to run some calculations and have been told that Fortran is much much much faster at computations than matlab

As such, I am trying to use fortran to work on various netcdf files

I used macports to install the netcdf-fortran package

My question, as my searching online has been a bear, is how exactly do I run a fortran code with netcdf calls?

Here is a quick example I tried to run (aa.f) and the resulting output

Code:
 PROGRAM nc

        USE netcdf

        IMPLICIT NONE

        INTEGER :: stat,id


        stat=nf90_open(path="~/Desktop/temp_2011-12-31.nc",mode=nf90_write,ncid=id)
        stat=nf90_close(id)


        END PROGRAM nc
Here is what terminal spits out

Code:
gfortran-mp-4.7 aa.f
aa.f:1.2:

 PROGRAM nc                                                             
  1
Error: Non-numeric character in statement label at (1)
aa.f:1.2:

 PROGRAM nc                                                             
  1
Error: Unclassifiable statement at (1)
aa.f:3.11:

        USE netcdf                                                      
           1
Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory
Any tips is great or a site that you know of that explains clearly how to use netcdf and fortran!
dukebound85 is offline   0 Reply With Quote
Old Jun 20, 2012, 05:54 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
First: Name your file .f90 or .f95 so it's clear that you're not writing in column-dependent Fortran 77. Next: Where did netcdf install its .mod file and library file? Have you made sure your compiler knows where to find this?

-Lee
lee1210 is offline   0 Reply With Quote
Old Jun 20, 2012, 10:33 PM   #3
dukebound85
Thread Starter
macrumors P6
 
dukebound85's Avatar
 
Join Date: Jul 2005
Location: 5045 feet above sea level
Quote:
Originally Posted by lee1210 View Post
First: Name your file .f90 or .f95 so it's clear that you're not writing in column-dependent Fortran 77. Next: Where did netcdf install its .mod file and library file? Have you made sure your compiler knows where to find this?

-Lee
I'll try that. As far as the library, I just installed the netcdf-fortran port via macports. That should suffice right?
dukebound85 is offline   0 Reply With Quote
Old Jun 20, 2012, 11:31 PM   #4
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
Quote:
Originally Posted by dukebound85 View Post
I'll try that. As far as the library, I just installed the netcdf-fortran port via macports. That should suffice right?
-I seems to be the switch to point to where modules are installed. Find netcdf.mod with spotlight and add a switch to gfortran pointing there. I don't know where macports installs things, but gfortran can't find the module right now.

-Lee
lee1210 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to run fortran on mac phamnu Mac Programming 1 Aug 25, 2013 09:56 PM
Fortran g77 on Mac nicolaus Mac Programming 5 Feb 7, 2013 08:09 AM

Forum Jump

All times are GMT -5. The time now is 11:19 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC