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

convert_mpas error

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.

tomerburg

New member
Thus far I've been visualizing MPAS output (I'm running v6.3) using the native grid, but I've been having problems with trying to set up "convert_mpas" to convert it to a lat/lon grid.

I cloned the most recent "convert_mpas" version from GitHub and changed the first line in Makefile to "FC = gfortran" as this is the fortran compiler I have set up (when I ran it with the default I got too many error messages to post). When I run make I get the following output and error message:

Code:
( cd src; make FC="gfortran" FFLAGS="-O3 -DHAVE_NF90_INQ_VARIDS" FCINCLUDES="" FCLIBS="" )
make[1]: Entering directory `.../convert_mpas/src'
rm -f scan_input.o scan_input.mod
gfortran -O3 -DHAVE_NF90_INQ_VARIDS -c scan_input.F90
scan_input.F90:3.8:

    use netcdf
        1
Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory
make[1]: *** [scan_input.o] Error 1
make[1]: Leaving directory `.../convert_mpas/src'
make: *** [all] Error 2

As I'm a novice to Fortran, I'm not really sure what this error message means or what additional info I may need to provide to help diagnosing this, but hopefully this is at least a helpful start.
 
The top-level Makefile attempts to use the 'nc-config' program to determine which Fortran compiler and which libraries should be used. It may be that the 'nc-config' program isn't in your shell's PATH. Could you try adding the path to the 'nc-config' program to your $PATH environment variable? Usually nc-config is found in a bin/ subdirectory of your NetCDF installation path, and if you have the $NETCDF environment variable set to your NetCDF installation path, you could simply add $NETCDF/bin to your $PATH.
 
mgduda said:
The top-level Makefile attempts to use the 'nc-config' program to determine which Fortran compiler and which libraries should be used. It may be that the 'nc-config' program isn't in your shell's PATH. Could you try adding the path to the 'nc-config' program to your $PATH environment variable? Usually nc-config is found in a bin/ subdirectory of your NetCDF installation path, and if you have the $NETCDF environment variable set to your NetCDF installation path, you could simply add $NETCDF/bin to your $PATH.

Thanks for the tip! I added $NETCDF/bin and it solved that error. Now there's another error that appears:

Code:
( cd src; make FC="gfortran" FFLAGS="-O3 -DHAVE_NF90_INQ_VARIDS" FCINCLUDES="-g -O2 -I/home/nickszap/utils/libs/netcdf/include" FCLIBS="-L/home/nickszap/utils/libs/netcdf/lib -lnetcdff -L/home/nickszap/utils/libs/gcc-trunk/lib -lnetcdf -lm -lcurl" )
make[1]: Entering directory `convert_mpas/src'
rm -f scan_input.o scan_input.mod
gfortran -O3 -DHAVE_NF90_INQ_VARIDS -c scan_input.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
scan_input.F90:80.15:

        stat = nf90_inq_varids(handle % ncid, handle % num_vars, handle % varid
               1
Error: Function 'nf90_inq_varids' at (1) has no IMPLICIT type
make[1]: *** [scan_input.o] Error 1
make[1]: Leaving directory `convert_mpas/src'
make: *** [all] Error 2

As with before my lack of deep fortran expertise right now is a barrier (I'm just starting to dive more deeply into fortran), but based on this error message my first guess would be that the cause is on my end, perhaps something outdated with my netcdf or fortran compiler?
 
I think as you suspect the issue may be a rather old NetCDF library version that doesn't include the "nf90_inq_varids" inquiry function. As a workaround, it should suffice to just remove -DHAVE_NF90_INQ_VARIDS from the definition of FFLAGS in the top-level Makefile. After modifying the Makefile, just for good measure, it may be worth running "make clean" before running "make" again.
 
That would make sense... in the meantime I'll try to see if there's a way I can hopefully make this work with the current NetCDF version I have. Removing that portion of the FFLAGS definition did help progress further, but now it's encountering a similar error farther down the chain:

( cd src; make FC="gfortran" FFLAGS="-O3" FCINCLUDES="-g -O2 -I/home/nickszap/utils/libs/netcdf/include" FCLIBS="-L/home/nickszap/utils/libs/netcdf/lib -lnetcdff -L/home/nickszap/utils/libs/gcc-trunk/lib -lnetcdf -lm -lcurl" )
make[1]: Entering directory `convert_mpas/src'
rm -f scan_input.o scan_input.mod
gfortran -O3 -c scan_input.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
rm -f mpas_mesh.o mpas_mesh.mod
gfortran -O3 -c mpas_mesh.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
rm -f target_mesh.o target_mesh.mod
gfortran -O3 -c target_mesh.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
rm -f remapper.o remapper.mod
gfortran -O3 -c remapper.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
rm -f file_output.o file_output.mod
gfortran -O3 -c file_output.F90 -g -O2 -I/home/nickszap/utils/libs/netcdf/include
file_output.F90:44.59:

stat = nf90_create(trim(filename), NF90_NETCDF4, handle % ncid)
1
Error: Symbol 'nf90_netcdf4' at (1) has no IMPLICIT type
make[1]: *** [file_output.o] Error 1
make[1]: Leaving directory `convert_mpas/src'
make: *** [all] Error 2
 
You could try replacing NF90_NETCDF4 with NF90_64BIT_OFFSET in file_output.F90 to see if that helps. Unless you're interpolating to an especially high-resolution lat-lon grid, the ability to write individual records larger than 4 GB (which is permitted by the NetCDF-4 format) shouldn't be necessary.
 
This seems to have solved it - I was able to successfully compile and run convert_mpas! Testing now to see if the visual output looks reasonable, but so far I haven't encountered any issues. Thanks so much for the help!

10 Nov edit: The program worked 100% successfully and there are no issues with the output. Thanks for the help again!
 
Thanks very much for following-up!

I've had a few ideas in mind for how we could make the convert_mpas build procedure more robust through additional build-time checks. If you have a couple of minutes and wouldn't mind giving it a try, I have a branch of the convert_mpas code that I *think* should build "out-of-the-box" (with no modifications needed to the Fortran code or to the Makefile) with your library setup. If you'd like, you can run the following to obtain the code:

Code:
git clone https://github.com/mgduda/convert_mpas.git convert_mpas_test
cd convert_mpas_test
git checkout makefile_checks

Running 'make' in the convert_mpas_test directory will then hopefully just work. No worries at all if you don't have time to try this out, but if this branch works for you, it might be helpful to others as well once it's merged back to the main branch in the convert_mpas repository.
 
Top