HRLDAS模型编译

Posted by CryoECNU on October 16, 2021

下载HRLDAS模型:【HRLDAS模型】。当前是V3.8

需要很多库:netcdf、jasper、bzip2等,参考帖子去编译:【编译NETCDF和MPICH】

编译串行HRLDAS也不太复杂,只要修改一下user_build_options文件里的几个参数:

libs_path   = ~/gcc_libs/

COMPILERF90	=	gfortran-7
FREESOURCE	=	-ffree-form  -ffree-line-length-none
F90FLAGS	=   -g -fconvert=big-endian -fbounds-check -fno-range-check -fno-underscoring
MODFLAG	    =	-I
LDFLAGS	    =	
CPP		    =	cpp-7
CPPFLAGS	= -C -P -traditional -D_HRLDAS_URBAN_
LIBS		=	

INCJASPER   =  -I${libs_path}/include
LIBJASPER   =  -ljpeg -L${libs_path}/lib -ljasper

NETCDFMOD	=	-I${libs_path}/include
NETCDFLIB	=	-L${libs_path}/lib -lnetcdff -lnetcdf

BZIP2		=       YES
BZIP2_LIB	=       -lbz2
BZIP2_INCLUDE	=       -I${libs_path}/include/
RM		= 	rm -f
CC		=	gcc-7

一定不能漏掉-lnetcdff,不然编译不过去。

[注意]

  • 如果编译有问题,提示_iargc有问题。这是gfortran编译器的一个问题,解决办法是修改FORTRAN代码:create_forcing.F。 第89行左右(integer, external :: iargc),改成INTRINSIC :: iargc

  • 如果编译提示ld: ./lib/libsmda.a(module_grib2.o): in function `__module_grib2_MOD_fortran_decode_jpeg2000': 这一类错误,需要取消F90FLAGS里面的-fno-underscoring

编译完成后,有两个exe文件:HRLDAS_forcing/create_forcing.exerun/hrldas.exe


Ubuntu 20下面编译的配置:


COMPILERF90    =       gfortran
FREESOURCE     =       -ffree-form  -ffree-line-length-none
F90FLAGS       =       -g -fbounds-check -fno-range-check -fconvert=big-endian #-fallow-invalid-boz  -fno-underscoring
MODFLAG        =       -I
LDFLAGS        =       
CPP            =       cpp
CPPFLAGS       =       -P -traditional #-D_GFORTRAN_ # -D_HRLDAS_URBAN_
LIBS           =       
LIBJASPER      =       -ljpeg -L/usr/lib -ljasper
INCJASPER      =       -I/usr/include/jasper
NETCDFMOD      =       -I/usr/include
NETCDFLIB      =       -L/usr/lib -lnetcdf -lnetcdff
BZIP2          =       NO
BZIP2_LIB      =       -lbz2
BZIP2_INCLUDE  =       -I/usr/include
RM             =       rm -f
CC             =       gcc

编译的时候可能提示jasper-dev可能无法找到。解决办法:

sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt-get install libjasper-dev