************************** W A R N I N G ************************************

The moving nest option is not available due to missing rpc/types.h file.
Copy landread.c.dist to landread.c in share directory to bypass compile error.

*****************************************************************************

该问题主要在较新的linux系统中运行WRF的./configure命令时出现。

笔者在此记录一下自己的解决方式,希望能帮助面临同样问题的用户。
  • 本文分为简略版详细版简略版仅记录了执行操作,详细版包含了问题查找分析过程。

简略版

需要满足以下条件,才可直接进行简略版的操作。

  1. 确保当前处在WRF目录(即运行 ./configure 命令的目录)
  2. 执行ls -l /usr/include/tirpc/rpc/types.h,文件存在
  3. 执行ls -l /usr/include/tirpc/netconfig.h,文件存在

操作

  1. vi ./Makefile

  2. 定位到rpc_test。/rpc

    rpc_test:
    @cd tools ; /bin/rm -f rpc_test.exe ; $(SCC) -DUSE_TIRPC -o rpc_test.exe rpc_test.c ; $(SCC) -o rpc_test.exe rpc_test.c; cd …

  3. 修改为如下。i

    rpc_test:
    @cd tools ; /bin/rm -f rpc_test.exe ; $(SCC) -DUSE_TIRPC -I/usr/include/tirpc -o rpc_test.exe rpc_test.c ; cd …

    4.退出文本。:wq

完。再运行./configure警告消失。

详细版

  1. 首先弄清报错的来源,

在WRF目录下,打开configure文件,定位到testing for location of rpc/types.h file, used in landuse,注释掉下面第三行的rm代码(在其前面加一个#

# testing for location of rpc/types.h file, used in landuse
make rpc_test > tools/rpc_test.log 2>&1
rm -f tools/rpc_test.log

if [ -f tools/rpc_test.exe ] ; then
rpc_type=`tools/rpc_test.exe`
if [ $rpc_type = “rpc” ]; then
sed -e ‘/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=1 &/’ configure.wrf > configure.wrf.edit
else
sed -e ‘/^CFLAGS_LOCAL/s/#/-DRPC_TYPES=2 &/’ configure.wrf > configure.wrf.edit
fi
mv configure.wrf.edit configure.wrf
else
echo “********************************************* W A R N I N G *********************************************”
echo " "
echo “The moving nest option is not available due to missing rpc/types.h file.”
echo “Copy landread.c.dist to landread.c in share directory to bypass compile error.”
echo " "
echo “*********************************************************************************************************”
fi

这个日志文件很有用,再运行一下./configure,得到日志文件(cd tools打开rpc_test.log)
看到内容如下:

In file included from rpc_test.c:4:
/usr/include/tirpc/rpc/types.h:98:10: fatal error: netconfig.h: No such file or directory
98 | #include <netconfig.h>
| ^~~~~~~~~~~~~
compilation terminated.
rpc_test.c:6:10: fatal error: rpc/types.h: No such file or directory
6 | #include <rpc/types.h>
| ^~~~~~~~~~~~~
compilation terminated.

表明这是Makefile文件的问题

  1. 回到根目录(WRF),打开Makefile,定位到 rpc_test,其内容如下

rpc_test:
@cd tools ; /bin/rm -f rpc_test.exe ; $(SCC) -DUSE_TIRPC -o rpc_test.exe rpc_test.c ; $(SCC) -o rpc_test.exe rpc_test.c; cd …

注意看,这是问题所在,且该bug存在于多个WRF版本。

它进行了重复编译:第二次编译直接覆盖了第一次编译结果。

根据情况修改该代码,分别运行下面两个命令,看自己的types.h在哪个文件夹里。
ls -l /usr/include/rpc/types.h
ls -l /usr/include/tirpc/rpc/types.h

笔者的电脑里,第一个命令提示No such file or directory,第二个命令提示存在,即笔者的电脑存在TIRPC,
不出意外,读者们也是,如果不是,下面的步骤可能不适用,或者请检查自己电脑的types.h文件的路径,再辩证性地进行操作。

有多种维护方式(只需要保证第一个编译的代码能成功运行即可),笔者这里直接选择删掉第二次编译的代码。
改为:

rpc_test:
@cd tools ; /bin/rm -f rpc_test.exe ; $(SCC) -DUSE_TIRPC -o rpc_test.exe rpc_test.c ; cd …

改好后,再次回到WRF根目录,运行./configure,发现报错仍存,再次检查rpc_test.log,发现内容如下:

In file included from rpc_test.c:4:
/usr/include/tirpc/rpc/types.h:98:10: fatal error: netconfig.h: No such file or directory
98 | #include <netconfig.h>
| ^~~~~~~~~~~~~
compilation terminated.

它找不到netconfig.h,没关系,它仍然在/usr/include/tirpc/rpc里,检查一下,find /usr/include -name "netconfig.h",发现确实在里面,再次修改WRF目录下的Makefile文件,回到刚才的rpc_test,将其改为:

rpc_test:
@cd tools ; /bin/rm -f rpc_test.exe ; $(SCC) -DUSE_TIRPC -I/usr/include/tirpc -o rpc_test.exe rpc_test.c ; cd …

这就算是改好了,再次回到WRF根目录,运行./configure就没有警告信息了。完毕后,可以顺手把第1步中configure文件中注释的部分取消注释。

完。

更多推荐