Error during make of convert_mpas

Questions, issues, or suggestions related to post-processing of model output.
Post Reply
raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Error during make of convert_mpas

Post by raj123456 » Mon Feb 22, 2021 11:54 am

Hello,
I am trying to compile convert_mpas (https://github.com/mgduda/convert_mpas). During make, object files are not getting generated.


I am unable to find the reason for this error.
any suggestions will be appreciated.

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Mon Feb 22, 2021 9:42 pm

Can you attach your compilation log at a text file (or if it's short enough, just include it in a follow-up post)? When creating the log, you'll want to ensure that stderr and stdout messages are both saved to the log using >& redirection.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Wed Feb 24, 2021 9:04 am

Hello,

Hereby I am attaching the log file generated during make.

thanks and regards,
Dhanraj
Attachments
log.txt
(3.07 KiB) Downloaded 17 times

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Thu Feb 25, 2021 7:19 pm

The compilation commands shown in your log.txt file all seem to be creating object files named "sdfsd". For example:

Code: Select all

gfortran -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS -I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdf -lnetcdff -o sdfsd -c scan_input.F
The string "sfdsd" does not appear anywhere in the Makefiles that are distributed with the convert_mpas code. Have you modified any part of the convert_mpas Makefiles?
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Fri Feb 26, 2021 5:06 am

Yes I have added the following part

Code: Select all

-I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdf -lnetcdff -o sdfsd
Because it was showing an error as "nf-config not yet implemented for cmake builds"

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Fri Feb 26, 2021 5:17 am

The makefiles distributed with convert_mpas are for use with GNU Make, not CMake.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Fri Feb 26, 2021 6:31 am

I am just using "make" command. Will you please tell me how to use GNU make instead of CMake?

Thank you.

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Tue Mar 02, 2021 3:26 am

That's curious. On most Unix-like systems, the 'make' command is GNU Make. When you run 'make --version', do you see something that looks more like this

Code: Select all

GNU Make 4.0
Built for x86_64-unknown-linux-gnu
Copyright (C) 1988-2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
or like this

Code: Select all

cmake version 3.18.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).
? If the latter, does the output change if you run '\make --version' (i.e., the same command, but with a '\' character at the beginning)?

In any case, you could try running 'gmake' rather than 'make', which might give you GNU Make on your system.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Tue Mar 02, 2021 9:56 am

Thank you for your reply.

I tried 'gmake' command and the system says:

Code: Select all

Command 'gmake' not found, but there are 14 similar ones.
All this time conda environment was on. At this time I have deactivated the conda environment and run 'make' command then I got the error as

Code: Select all

( cd src; make FC="gfortran" FFLAGS="-O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS" FCINCLUDES="" FCLIBS="" )
make[1]: Entering directory '/home/ubuntu/convert_mpas/convert_mpas/src'
rm -f scan_input.o scan_input.mod
gfortran -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS -c scan_input.F
scan_input.F:3:8:

     use netcdf
        1
Fatal Error: Can't open module file ‘netcdf.mod’ for reading at (1): No such file or directory
compilation terminated.
After that to give the path of netcdf-fortran I added the option in Makefile as:

Code: Select all

-I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdf -lnetcdff -o sdfsd
and again that gave the same error which is attached in a file (log.txt), in this conversation.

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Fri Mar 05, 2021 5:37 pm

Adding "-o sdfsd" to the compiler flags will tell the compiler to write its output to a file named "sdfsd", which explains the errors you're seeing.

The top-level Makefile attempts to obtain the correct paths and library names for NetCDF using the nc-config command:

Code: Select all

FCINCLUDES = $(shell nc-config --fflags)
FCLIBS = $(shell nc-config --flibs)
I think the cleanest approach would be to not modify the Makefile (assuming you're using the GNU compilers; otherwise, you will need to adjust the Makefile for your compiler), and to ensure that the 'nc-config' command is in your path.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Sat Mar 06, 2021 7:52 pm

Thank you for your reply.

I have changed the Makefile as follows.

Code: Select all

FFLAGS = -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS -I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdf -lnetcdff
FCINCLUDES = $(shell nc-config --fflags)
FCLIBS = $(shell nc-config --flibs)
After that, I got an error as attached in the make.log file.

If there is any other way of attaching the 'nc-config' command in the path please let me know.
Attachments
make.log
(8.83 KiB) Downloaded 15 times

zemega
Posts: 11
Joined: Fri Sep 04, 2020 4:12 am

Re: Error during make of convert_mpas

Post by zemega » Sun Mar 07, 2021 12:22 pm

Can you change

Code: Select all

FFLAGS = -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS -I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdf -lnetcdff
to

Code: Select all

FFLAGS = -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS -I/home/ubuntu/install_mpas/libraries/include/ -L/home/ubuntu/install_mpas/libraries/lib/ -lnetcdff -lnetcdf
Often, the order of -lnetcdff first then -lnetcdf is important.

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Sun Mar 07, 2021 5:02 pm

Hello,
Thank you for your reply.

I tried as you suggested and still getting the same error as in make.log.

Thank you for your time.

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Mon Mar 08, 2021 10:35 pm

In the Makefiles for the convert_mpas program, the FCFLAGS variable is used to provide general compiler flags (e.g., for optimization, debugging, preprocessing macros), while the FCINCLUDES and FCLIBS variables are used to specify include file search paths and libraries, respectively. In principle, you could manually add -I, -L, and -l flags for your NetCDF library installation (and as zemega said, the order in which libraries are listed is important in general).

However, I would really suggest ensuring that the "nc-config" program is in your PATH, and not editing the Makefile at all (again, except if you're using a compiler other than the GNU Fortran compiler, in which case you'll need to set the compiler name and flags). The nc-config program should be in the bin/ subdirectory of your NetCDF installation directory.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Mon Apr 05, 2021 10:17 am

Hello all,
I kept nc-config program in my PATH and didn't change Makefile at all. After that also I am continuously getting the error mentioned in the make.log file which is, "undefined reference to".
I have stuck here for a very long time, I would really appreciate the help.

Thank you.

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Mon Apr 05, 2021 9:47 pm

Can you provide the output from the following commands:

Code: Select all

nc-config --fflags
nc-config --flibs
Could you also attach a new log file created by running the following (with nc-config in your PATH and with an unmodified Makefile):

Code: Select all

make >& make.log
Your original log file (log.txt) only shows errors due to changes in the Makefile that caused all object files to be named "sdfsd", so it would be helpful to see the current output from compilation of the convert_mpas program.
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Wed Apr 07, 2021 5:31 am

Thank you for your reply.

Code: Select all

nc-config --fflags
-I/datadrive/models/mpas_install/libraries/include
nc-config --flibs
-L/datadrive/models/mpas_install/libraries/lib -lnetcdff -L/datadrive/models/mpas_install/libraries/lib -lnetcdf -lhdf5_hl -lhdf5 -lm -lnetcdf -lhdf5_hl -lhdf5 -lz -ldl
make.log file is attached from the compilation using the original Makefile.
Attachments
make.log
(48.34 KiB) Downloaded 9 times

mgduda
Posts: 468
Joined: Mon Feb 26, 2018 7:35 pm

Re: Error during make of convert_mpas

Post by mgduda » Wed Apr 07, 2021 5:05 pm

Thanks for the new log file. It looks like the errors are all link-time errors related to PnetCDF and MPI:

Code: Select all

/datadrive/models/mpas_install/libraries/lib/libnetcdf.a(libdispatch_la-derror.o): In function `nc_strerror':
derror.c:(.text+0x46b): undefined reference to `ncmpi_strerror'
derror.c:(.text+0x47a): undefined reference to `ncmpi_strerror'
/datadrive/models/mpas_install/libraries/lib/libnetcdf.a(libdispatch_la-dfile.o): In function `openmagic':
dfile.c:(.text+0x1cd8): undefined reference to `MPI_File_open'
dfile.c:(.text+0x1cf2): undefined reference to `MPI_Error_class'
dfile.c:(.text+0x1d2d): undefined reference to `MPI_File_get_size'
etc.

Can you try changing the definition of FC from 'gfortran' to 'mpif90' and adding '-lpnetcdf' to the definition of FCLIBS, so that the beginning of your Makefile looks like the following?

Code: Select all

FC = mpif90
FFLAGS = -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS
FCINCLUDES = $(shell nc-config --fflags)
FCLIBS = $(shell nc-config --flibs) -lpnetcdf
NCAR/MMM

raj123456
Posts: 12
Joined: Mon Feb 08, 2021 5:05 am

Re: Error during make of convert_mpas

Post by raj123456 » Thu Apr 08, 2021 2:10 pm

Thank you for your effort and time.
Executable is created.

Regards.

henrys
Posts: 3
Joined: Fri Apr 09, 2021 8:07 pm

Re: Error during make of convert_mpas

Post by henrys » Mon Apr 26, 2021 5:28 pm

Adding '-lpnetcdf' fixed a similar linking error for me, too.
I'm running Ubuntu on an Azure Data Science Virtual Machine.

Post Reply

Return to “Post-processing”