Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ilovecodinghaha opened this issue Jan 6, 2023 · 8 comments
Open

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

Ilovecodinghaha opened this issue Jan 6, 2023 · 8 comments

Comments

@Ilovecodinghaha
Copy link

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
Copy link

HathewayWill commented Jan 10, 2023

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

@HathewayWill
Copy link

@edhartnett

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

@HathewayWill
Copy link

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
Copy link

@HathewayWill
Copy link

HathewayWill commented Jan 10, 2023

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
Copy link

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
Copy link

@Ilovecodinghaha @edhartnett

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

@WardF
Copy link
Member

WardF commented Jan 13, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants