Error while building UFS with clang and gfortran

Hello All, I was trying to build UFS application with Clang and Gfortran on Linux Ubuntu 18.04. I have built NCEPLIBS-external and NCEPLIBS successfully but facing issues while building the model.

I have attached some initials from the atm.bldlog file generated. Please have a look and suggest.

 

Initially I faced errors like this:

"

[ 52%] Built target ccppphys
make[1]: Leaving directory '/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj'
Makefile:151: recipe for target 'all' failed

  errput: /home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mosaic/create_xgrid.c:82:37: error: use of undeclared identifier 'M_PI'
      n_in = fix_lon(x_in, y_in, 4, M_PI);
                                    ^
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mosaic/create_xgrid.c:117:38: error: use of undeclared identifier 'M_PI'
      n_in = fix_lon(x_in, y_in, nv, M_PI);
                                     ^
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mosaic/create_xgrid.c:237:37: error: use of undeclared identifier 'M_PI'
      n_in = fix_lon(x_in, y_in, 4, M_PI);
                                    ^
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mosaic/create_xgrid.c:909:38: error: use of undeclared identifier 'M_PI'
    n2_in = fix_lon(x2_in, y2_in, 4, M_PI);
                                     ^
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mosaic/create_xgrid.c:945:44: error: use of undeclared identifier 'M_PI'
          n1_in = fix_lon(x1_in, y1_in, 4, M_PI);  

"

To overcome this error I manually defined M_PI function in some .c files.

But this gave some warnings like:

[ 54%] Built target ccppphys
make[1]: Leaving directory '/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj'
Makefile:151: recipe for target 'all' failed

  errput: /home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:1386:0:

 1386 | #define MPP_TYPE_ integer(INT_KIND)
      | 
Warning: "MPP_TYPE_" redefined
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:1374:0:

 1374 | #define MPP_TYPE_ logical(LONG_KIND)
      | 
note: this is the location of the previous definition
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:1387:0:

 1387 | #define MPI_TYPE_ MPI_INTEGER4
      | 
Warning: "MPI_TYPE_" redefined
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:1376:0:

 

And then the errors like:

"

  258 |         tmin = t; call mpp_min(tmin)
      |                                    1
Error: There is no specific subroutine for the generic ‘mpp_min’ at (1)
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:259:36:

  259 |         tmax = t; call mpp_max(tmax)
      |                                    1
Error: There is no specific subroutine for the generic ‘mpp_max’ at (1)
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:260:37:

  260 |         tavg = t; call mpp_sum(tavg); tavg = tavg/mpp_npes()
      |                                     1
Error: There is no specific subroutine for the generic ‘mpp_sum’ at (1)
/home/neeraj/ufs_v1.0.0/ufs_v1.0.0/ufs_v1.0.0_clang_2_2/cime/ufs_scratch/case1/bld/atm/obj/FMS/mpp/include/mpp_comm_mpi.inc:261:47:

"

Please have a look and suggest, what's going wrong here ?

Good day, thanks for submitting this bug report. We haven't tried using clang+gfortran on Ubuntu thus far, only on macOS. Can you use gcc+gfortran on Linux?

I believe you can ignore the MPI_TYPE_ warnings.

In order to debug this, I'll need to know exactly how you installed your system (apt-get commands etc), pretty much like the instructions in NCEPLIBS-external/doc/README_*.txt.

 

Permalink

In reply to by dom.heinzeller

Hello Dom, heinzeller

Thanks for your reply.

I am able to build the model using gcc+gfortran. But from the benchmarking perspective, I also need to build the model using clang+gfortran.

Currently, I am working on the system which was pre-configured with basic requirements like compiler and other requirements. So I am not aware about commands used for building system earlier. But on the same system, I was able to build model using gnu and intel compilers. Facing the issue only with clang+gfortran. 

Is there any workaround possible for this without system details ?

A quick consultation of Prof. Google with the error message "error: use of undeclared identifier 'M_PI'" suggests that the problem is that mathematical constants such as M_PI are not part of the standard and that it is possible that your clang version doesn't have it when using math.h

The following website offers a few suggestions that you can try:

https://stackoverflow.com/questions/26065359/m-pi-flagged-as-undeclared-identifier

Dom

Thanks for the suggestion dom, I resolved that M_PI  error by including math library. However, I am still stuck at mpp_sum, mpp_max, mpp_min subroutine error. 

I also tried building ufs-weather model using clang+gfortran. It got successully build. Can someone please clear the difference between ufs-mrweather app and ufs-weather model.

ufs-mrweather app stands for the UFS Medium-Range Weather App and one application of ufs-weather model.  ufs-weather model also has other applications, for example ufs-srweather app or UFS Short-Range Weather App.

Thanks,

Linlin

Attach Files