[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Support #KXL-102687]: using NetCDF files in Fortran 90



> Hello!
>
> I am a student, and I have just started programming in Fortran 90.

Congratulations!

First thing you should know about netCDF: there is a fortran 77 API, and a
Fortran 90 API.

You can use the F77 API from Fortran 90, as well as the F90 API.

> NetCDF files I have only used before in the grid  analysis and
> displaying package GrADS. I am quite unexperienced with programming and
> with NC files, so my questions might sound a bit stupid to you! Still I
> can not work out how to work with NetCDF-files in Fortran programs,just
> by browsing the internet.

I suggest you start with the netCDF tutorial:
http://www.unidata.ucar.edu/software/netcdf/docs/netcdf-tutorial.html

Is netCDF installed on your machine?

>
> I am using a windows XP pc, with a gfortran compiler, I do not know the
> version of this compiler. I just compile my programs with a 'gfortran
> x.f90' command.

You can find the gfortran version with the --version option, but it doesn't
make that much difference, as long as you are using the same version of
gfortran as was used when netCDF was built on that machine.

>
> In on-line examples, I see f90 programs in which specific NetCDF
> functions like 'nf_open', 'nf_close' etc. are used. These functions seem
> to be made available by a library, which I have found and downloaded (I
> have a netcdf.exp, netcdf.lib and netcdf.dll file). So now comes the
> gap: what to do with these files, so that I can open NetCDF files and
> work with them in a fortran 90 program? Is there a fortran command for
> calling these functions from a library, or should my compiler have an
> option to link these libraries to my program?

How are you running gfortran? That is, what command line are you using? DOS?

One easy thing to do is to download the cygwin port of Unix to the PC:
www.cygwin.com

This give you a Unix command line on your windows box, and then you can build
and install netCDF within a Unix environment, and use gfortran.

I don't know how to get gfortran to see the DLL, presumably you just need to
put the DLL is directory \windows\system32, and then use -lnetcdf on the
gfortran command line. But I have not tried this, since I work on Unix.

>
> I apologize if the level of my questions is a bit low! I did quite some
> searching on the internet and in a Fortran book on how to solve this,
> with no succes.
>

Quite OK! You might also be interested in the netCDF workshop, which is a
series of slides explaining netCDF:
http://www.unidata.ucar.edu/software/netcdf/workshops/2007

Good luck!

Ed


Ticket Details
===================
Ticket ID: KXL-102687
Department: Support netCDF
Priority: Normal
Status: Closed