Re: [netcdfgroup] Building netcdf-fortran on Windows

  • To: Dave Allured - NOAA Affiliate <dave.allured@xxxxxxxx>
  • Subject: Re: [netcdfgroup] Building netcdf-fortran on Windows
  • From: Aristotelis Liakatas <agliak@xxxxxxxxx>
  • Date: Wed, 19 Aug 2020 23:05:11 +0100
Hi Dave,

Thank you for your response.

I do have the line "use netcdf" in my module. In fact, the project can be
built just fine if I use an older version of the netcdff.lib (4.4.2).

The problem seems to originate from the static library I am using now.
Inspecting the contents of the static library for the previous version
(4.4.2) and the one I am building (4.5.2), the results are quite different.

Running the following as an example:
For 4.4.2:
*PS netcdf_fortran_442\lib>  dumpbin /symbols .\netcdff.lib | Select-String
"nf90"*







*003 00000010 SECT1  notype ()    External     |
NETCDF_mp_NF90_INQ_LIBVERS004 00000060 SECT1  notype ()    External     |
NETCDF_mp_NF90_INQ_BASE_PE005 00000070 SECT1  notype ()    External     |
NETCDF_mp_NF90_SET_BASE_PE006 00000080 SECT1  notype ()    External     |
NETCDF_mp_NF90_CREATE_MP007 00000090 SECT1  notype ()    External     |
NETCDF_mp_NF90_OPEN_MP008 000000A0 SECT1  notype ()    External     |
NETCDF_mp_NF90_SET_FILL009 000000B0 SECT1  notype ()    External     |
NETCDF_mp_NF90_REDEF*
*.................*

For 4.5.2:
*PS netcdf_fortran_452\lib> dumpbin /symbols .\netcdff.lib | Select-String
"nf90" *
comes up empty, but

















* PS netcdf_fortran_452\lib> dumpbin /symbols .\netcdff.lib | Select-String
"nc_"00B 00000000 UNDEF  notype ()    External     |
NETCDF_NC_INTERFACES_mp_ADDCNULLCHAR00D 00000000 UNDEF  notype ()
 External     | nc_def_dim01A 00000000 UNDEF  notype ()    External     |
nc_inq_dim01B 00000000 UNDEF  notype ()    External     |
NETCDF_NC_INTERFACES_mp_STRIPCNULLCHAR01D 00000000 UNDEF  notype ()
 External     | nc_inq_dimid01E 00000000 UNDEF  notype ()    External     |
nc_inq_dimlen01F 00000000 UNDEF  notype ()    External     |
nc_inq_dimname021 00000000 UNDEF  notype ()    External     |
nc_rename_dim00F 00000000 UNDEF  notype ()    External     |
NETCDF_NC_INTERFACES_mp_ADDCNULLCHAR015 00000000 UNDEF  notype ()
 External     | nc_def_var01B 00000000 UNDEF  notype ()    External     |
nc_inq_varndims020 00000000 UNDEF  notype ()    External     |
nc_inq_var021 00000000 UNDEF  notype ()    External     |
NETCDF_NC_INTERFACES_mp_STRIPCNULLCHAR024 00000000 UNDEF  notype ()
 External     | nc_inq_vardimid026 00000000 UNDEF  notype ()    External
  | nc_inq_varid*
*............................*

*PS netcdf_fortran_452\lib> dumpbin /symbols .\netcdff.lib | Select-String
"nf_"*












*004 00000000 SECT2  notype ()    External     | NF_DEF_DIM005 00000100
SECT2  notype ()    External     | NF_INQ_DIM006 00000310 SECT2  notype ()
   External     | NF_INQ_DIMID007 00000400 SECT2  notype ()    External
| NF_INQ_DIMLEN008 00000430 SECT2  notype ()    External     |
NF_INQ_DIMNAME009 00000630 SECT2  notype ()    External     |
NF_RENAME_DIM01C 00000000 SECT6  notype       Static       |
NF_INQ_DIM$TMPNAME.0.2020 00000100 SECT6  notype       Static       |
NF_INQ_DIMNAME$TMPNAME.0.5004 00000000 SECT2  notype ()    External     |
NF_DEF_VAR005 000001A0 SECT2  notype ()    External     |
NF_INQ_VARNDIMS006 000001D0 SECT2  notype ()    External     |
NF_INQ_VAR007 000004E0 SECT2  notype ()    External     | NF_INQ_VARDIMID*
*008 000005E0 SECT2  notype ()    External     | NF_INQ_VARID *
*..................*

My impression is that I am doing something wrong when building the static
library for 4.5.2, but I cannot find where.
I generally followed the instructions from this
https://www.unidata.ucar.edu/software/netcdf/docs/getting_and_building_netcdf.html
 .
However, instructions for Windows are not really helpful.
Gave it a try with both pre-built binaries for netcdf-c 4.7.2 and by
building the netcdf-c on my own with the same results though.

Aristotelis


On Wed, Aug 19, 2020 at 9:51 PM Dave Allured - NOAA Affiliate <
dave.allured@xxxxxxxx> wrote:

> Aristotelis,
>
> The line "use netcdf" is required at the top of every fortran procedure
> that calls any of the nf90_ procedures (unless inheritance is in play).
> Your particular error message suggests that this line is missing.
>
> On many systems, a special prefix is added to all symbol names defined in
> fortran modules.  The purpose is to isolate module name spaces.  I am not
> familiar with windows, but I expect something similar is done there.  You
> should be able to see this with an appropriate symbol tool.  For example,
> gfortran on Mac OS does this:
>
>    /opt/local/lib 7> nm libnetcdff.6.dylib | grep nf90_open
>    000000000004dd48 T ___netcdf_MOD_nf90_open
>    000000000004e00c T ___netcdf_MOD_nf90_open_mp
>    000000000000f3f7 T ___netcdf_MOD_nf90_open_par
>
> ... And under the hood, valid compiled user programs link with these
> decorated symbols, not with plain nf90_ symbols.  HTH.
>
>
> On Wed, Aug 19, 2020 at 10:54 AM Aristotelis Liakatas <agliak@xxxxxxxxx>
> wrote:
>
>> Hello,
>>
>> I am trying to build the static library for netcdf-Fortran on Windows 10
>> using VS2019 and Intel Fortran compiler.
>>
>> I have downloaded the source code for version 4.5.2 and using cmake to
>> generate the VS-related files. Also, I am linking against netcdf-c 4.7.3
>> for which I am using the pre-built binaries (installed on my machine).
>>
>> Everything seems fine when building the static library and the
>> netcdff.lib is being generated without issues. However, having a peek
>> inside, there are no symbols for the nf90_* procedures. This is confirmed
>> when trying to use this library in one of my projects (linking errors:
>> unresolved external symbol nf90_*...).
>>
>> Any guidance would be appreciated!
>>
>> Aristotelis
>>
>
  • 2020 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: