Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Error during make of convert_mpas

This post was from a previous version of the WRF&MPAS-A Support Forum. New replies have been disabled and if you have follow up questions related to this post, then please start a new thread from the forum home page.

raj123456

New member
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.
 
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.
 
Hello,

Hereby I am attaching the log file generated during make.

thanks and regards,
Dhanraj
 

Attachments

  • log.txt
    3.1 KB · Views: 60
The compilation commands shown in your log.txt file all seem to be creating object files named "sdfsd". For example:
Code:
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?
 
Yes I have added the following part
Code:
-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"
 
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:
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:
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.
 
Thank you for your reply.

I tried 'gmake' command and the system says:
Code:
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:
( 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:
-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.
 
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:
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.
 
Thank you for your reply.

I have changed the Makefile as follows.
Code:
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.8 KB · Views: 58
Can you change
Code:
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:
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.
 
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.
 
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.
 
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.
 
Can you provide the output from the following commands:
Code:
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:
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.
 
Thank you for your reply.
Code:
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.3 KB · Views: 56
Thanks for the new log file. It looks like the errors are all link-time errors related to PnetCDF and MPI:
Code:
/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:
FC = mpif90
FFLAGS = -O2 -ffree-form -Wall -DHAVE_NF90_INQ_VARIDS
FCINCLUDES = $(shell nc-config --fflags)
FCLIBS = $(shell nc-config --flibs) -lpnetcdf
 
Adding '-lpnetcdf' fixed a similar linking error for me, too.
I'm running Ubuntu on an Azure Data Science Virtual Machine.
 
Top