[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDF #HFH-711245]: Linking from Windows Fortran to NetCDF 4.2 shared library
- Subject: [netCDF #HFH-711245]: Linking from Windows Fortran to NetCDF 4.2 shared library
- Date: Wed, 20 Feb 2013 09:01:48 -0700
Hi Graham,
Just a brief comment on this issue you raised:
> Fortran offers no way to tell a routine how to send arguments, only how to
> receive them. So when I say, for example
> nt_open = nc_open(path,modev,ncid)
> I cannot explain to nc_open that all three arguments are pointers. It expects
> path and ncid as pointers but modev as a value. The NetCDF code has elaborate
> machinery for sorting out this kind of thing, but so far at least I have
> failed to understand it.
>
> With a 64-bit C compiler I could solve this problem by compiling 64-bit
> objects equivalent to the 32-bit objects produced by gcc and understood by my
> older 32-bit program.
The Fortran 2003 standard (F03) provides a standardized mechanism for
interoperating with C functions and types. For practical purposes,
all current Fortran compilers implement this part of the F03 standard,
which provides how to send arguments fro Fortran to C as well as how
to receive values from C functions. A good description of these
capabilities is in this document, in Chapter 5, "Interoperability with
C":
ftp://ftp.nag.co.uk/sc22wg5/N1551-N1600/N1579.pdf
or in the examples in this guide "Standardized Mixed Language Programming
for Fortran and C":
http://www.roguewave.com/DesktopModules/Bring2mind/DMX/Download.aspx?entryid=751&command=core_download&PortalId=0&TabId=607
The netCDF Fortran version 4.4-beta1 or the newer development version
available from svn
ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4-beta1.tar.gz
http://svn.unidata.ucar.edu/repos/netcdf-fortran/trunk/
implement the F03 standard for calling C from Fortran, so would be a
better basis for a Windows port than the current netcdf-4.2 release,
in my opinion. We'll be working from the current svn trunk for our
next netCDF-Fortran release, which we hope to make available in the
next few months, if we don't encounter any unanticipated difficulties,
and we intend that it will work on Windows.
--Russ
> -----Original Message-----
> From: Unidata netCDF Support [mailto:address@hidden]
> Sent: 19 February 2013 19:02
> To: address@hidden
> Cc: address@hidden
> Subject: [netCDF #HFH-711245]: Linking from Windows Fortran to NetCDF 4.2
> shared library
>
> Good afternoon Graham,
>
> > I am trying to rebuild, in a 64-bit Windows 7 command-line environment using
> > Intel Visual Fortran compiler XE 12.1, an executable that used to work fine
> > with NetCDF 3.5 in a 32-bit Windows environment. I formerly used gcc to
> > compile the C code and Intel Fortran for my own Fortran code. I have tried
> > and failed to build the MinGW-64 C compiler, and it seems that I must invest
> > in a commercial 64-bit C compiler. One way to avoid this, that ought to work
> > but doesn't, is to rely on your shared library from
> > NetCDF-4.2.dev-NC4-64-shared.exe.
> >
>
> I'll try my best to help you out. A couple of things to start; first,
> beginning with
> netCDF 4.2, the netCDF-C and netCDF-Fortran libraries have been separated
> from each other. The netCDF-Fortran source code is available for download
> from:
>
> http://www.unidata.ucar.edu/downloads/netcdf/netcdf-fortran/index.jsp
>
> The netCDF-Fortran libraries depend on the netCDF-C libraries, so those will
> need to be installed first.
>
> The pre-built libraries you reference, netCDF-4.2.dev-NC4-64-shared, built
> using a developer snapshot; these are netCDF-C libraries. The are built
> specifically for use with Visual Studio and/or in a development environment
> using the Microsoft development libraries. Work to provide corresponding
> netCDF-Fortran libraries is ongoing, but they are not yet available.
>
> The netCDF-C and corresponding netCDF-Fortran libraries can be used on
> Windows when using the MSYS/MinGW or Cygwin
> development environments.
>
> You mention the difficulties you've had building the 64-bit MinGW C compiler;
> it is certainly true that it is not very intuitive. According to my notes, I
> was able
> to build MinGW-64 using the code available at:
>
> http://sourceforge.net/projects/mingw-w64/.
>
> Once downloaded, I have a note to follow the directions in 'mingw-w64-v2.0.7/
> mingw-w64-doc/howto-build'. Note that I built MinGW-64 inside of the MSYS
> environment, installed from here: http://www.mingw.org/wiki/MSYS
>
> If you were to go this route, I can confirm that the netCDF-C and
> netCDF-Fortran
> libraries appear to compile with MinGW. Likewise, if you were able to use
> cygwin, the netCDF-C and netCDF-Fortran libraries are available as packages
> which can be installed from the cygwin package manager.
>
> I'm sorry I can't point you to an MFC/Windows-developer-library compatible
> netCDF-fortran library, but hopefully this information will help.
>
> Have a great evening,
>
> -Ward
>
> p.s., I notice that this support request is entered in our system twice; I
> will
> close the earlier one, but leave this one open if there are any questions I
> can help with.
>
>
> >
> > With thanks for your attention.
> >
> >
> >
> > Graham Cogley.
> >
> >
> >
> > J. Graham Cogley, Ph.D., Professor of Geography,
> >
> > Department of Geography, Trent University,
> >
> > Peterborough, Ontario, CANADA K9J 7B8.
> >
> >
> >
> > Tel +1 705-748-1011-x7686
> >
> > Email address@hidden
> >
> > Web http://www.trentu.ca/geography/glaciology
> >
> >
> >
> >
> >
>
> Ticket Details
> ===================
> Ticket ID: HFH-711245
> Department: Support netCDF
> Priority: Normal
> Status: Open
>
>
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu
Ticket Details
===================
Ticket ID: HFH-711245
Department: Support netCDF
Priority: Normal
Status: Closed