Unidata / netcdf-c

Official GitHub repository for netCDF-C libraries and utilities.
BSD 3-Clause "New" or "Revised" License
508 stars 262 forks source link

Test: Fortran + C + NetCDF | compiling | Mac #2579

Open Ilovecodinghaha opened 1 year ago

Ilovecodinghaha commented 1 year ago

Hi there,

I just installed libraries and tried to test it, following https://www2.mmm.ucar.edu/wrf/OnLineTutorial/compilation_tutorial.php step by step.

There were some errors after running each comment, but the screen displayed correctly, so can anyone help me to check if I install the libraries correctly please? If it's not correct, could you please point it out?

gfortran -c 01_fortran+c+netcdf_f.f 01_fortran+c+netcdf_f.f:5:0: 5 INCLUDE 'netcdf.inc'

Fatal Error: Cannot open included file 'netcdf.inc' compilation terminated.

gcc -c 01_fortran+c+netcdf_c.c

return nothing

gfortran 01_fortran+c+netcdf_f.o 01_fortran+c+netcdf_c.o -L${NETCDF}/lib -lnetcdff -lnetcdf ld: file not found: 01_fortran+c+netcdf_f.o collect2: error: ld returned 1 exit status

./a.out C function called by Fortran Values are xx = 2.00 and ii = 1 SUCCESS test 4 fortran calling c

Mac Intel OS13 zsh gcc (Homebrew GCC 12.2.0) 12.2.0 NetCDF 4.9

Many many thanks

HathewayWill commented 1 year ago

@HathewayWill @Ilovecodinghaha I'm seeing the same thing, I'm trying to figure it out too. Looks like netcdf.inc wasn't made

HathewayWill commented 1 year ago

@edhartnett

One thing that is interesting is that make check comes back without any errors or fails.

HathewayWill commented 1 year ago
configure: netCDF-Fortran 4.6.0
checking build system type... x86_64-apple-darwin22.0.0
checking host system type... x86_64-apple-darwin22.0.0
checking target system type... x86_64-apple-darwin22.0.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a race-free mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
configure: checking user options
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/will/WRF/Downloads/netcdf-fortran-4.6.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target `install'.  Stop.

I think this might be the problem, netcdf fortran isn't being created.

HathewayWill commented 1 year ago

netcdf-fortran-config.log

HathewayWill commented 1 year ago

Possible source of the issue???

gcc version 12.2.0 (Homebrew GCC 12.2.0) 
configure:4445: $? = 0
configure:4434: gcc -V >&5
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:4445: $? = 1
configure:4434: gcc -qversion >&5
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:4445: $? = 1
configure:4434: gcc -version >&5
gcc: error: unrecognized command-line option '-version'
gcc: fatal error: no input files
compilation terminated.
configure:4445: $? = 1
HathewayWill commented 1 year ago

Standard outputs for MacOS 13:


will@wills-MacBook-Pro ~ % gcc -V
gcc: error: unrecognized command-line option '-V'
gcc: fatal error: no input files
compilation terminated.
will@wills-MacBook-Pro ~ % gcc -version
gcc: error: unrecognized command-line option '-version'
gcc: fatal error: no input files
compilation terminated.
will@wills-MacBook-Pro ~ % gcc -qversion
gcc: error: unrecognized command-line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
will@wills-MacBook-Pro ~ % gcc --V
gcc: error: unrecognized command-line option '--V'
gcc: fatal error: no input files
compilation terminated.
will@wills-MacBook-Pro ~ % gcc --version
gcc (Homebrew GCC 12.2.0) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

will@wills-MacBook-Pro ~ % gcc --qversion
gcc: error: unrecognized command-line option '--qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
will@wills-MacBook-Pro ~ % 
HathewayWill commented 1 year ago

@Ilovecodinghaha @edhartnett

There was a stray file name without the appropriate linker in the LIBS variable that caused this issue for @Ilovecodinghaha

WardF commented 1 year ago