Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dukebound85

macrumors Core
Original poster
Jul 17, 2005
19,131
4,110
5045 feet above sea level
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!
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
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
 

dukebound85

macrumors Core
Original poster
Jul 17, 2005
19,131
4,110
5045 feet above sea level
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?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.