GRAPES MESO模式学习笔记06——脚本运行之后处理

目录

后处理模块脚本尝试很多天终于在同事的帮助下跑通了。

后处理模块从模式输出的变量推导出其它变量(例如各种诊断量)。该模块独立于GRAPES MESO系统(还适用于全球模式),源代码来自perforce上的产品组。
之前我的测试数据选择2013年4月10日12时,模式输出变量有17层。直接使用post模块发现目前的变量输出层次有26层。所以我重新选择2014年6月10日12时的数据,并修改脚本及配置文件使模式输出26层。主要涉及背景场的生成和namelist文件的设置。并按照现有业务中的方式,分时效输出postvar文件。
在这过程中,遇到一个很严重的问题,卡了足足有两个星期。后处理模块程序product.exe读取post.ctl文件时总会提示读取文件时文件已到结尾的错误。今天在同事帮助下,终于发现是源代码在select case中没有相应变量的处理分支,计数器i没有增加,导致到达文件结尾处时循环依旧没有结束。幸运的是,源代码中注释部分包含对这两个变量的处理,去掉注释就可以正常运行。

IO

输入

模式积分输出(grades格式):

namelist.input文件:控制输出的诊断量类型。

输出

诊断量输出(grads格式):

脚本

处理单个时效的脚本,还需要后续改写。
[shell]
#!/bin/ksh
# @ comment = GRAPES
# @ job_type = serial
# @ input = /dev/null
# @ output = ./out/post_$(jobid).out
# @ error = ./out/post_$(jobid).err
# @ initialdir =./
# @ notification = error
# @ checkpoint = no
# @ class = normal
# @ queue
set -x
set -u
set -e
date
######################
# directory setting
######################
BASE_DIR=./grapes_meso/my_grapes_meso
BASE_SOURCE_DIR=./grapes_meso/GRAPES_MESO3.3.2.4
BASE_RUN_DIR=${BASE_DIR}/run
RUN_DIR=${BASE_RUN_DIR}/post
AN_RUN_DIR=${BASE_RUN_DIR}/an
SI_RUN_DIR=${BASE_RUN_DIR}/si
FCST_RUN_DIR=${BASE_RUN_DIR}/fcst
NEWDATE_BIN=${BASE_SOURCE_DIR}/fcst/grapes_model/run/newdate
PRODUCT_BIN=${BASE_DIR}/src/post/grapes_post_diag_ibm/product.exe
############
# parameter
############
levels=26
YYYYMMDDHH=2014061012
mfcast_len=24
do_static=.true.
do_3dv=.true.
do_3dv=.true.
output_inteval=3 #model output inteval in hour
model_dt=90 #model time step in second
make_surface_t=.false.
while getopts “t:b:r:g:c:” arg
do
case $arg in
t)
YYYYMMDDHH=$OPTARG
;;
b)
BCKG_DIR=$OPTARG
;;
r)
RUN_DIR=$OPTARG
;;
esac
done
begintime=$YYYYMMDDHH
endtime=$( ${NEWDATE_BIN} $begintime +$mfcast_len)
step_max=`expr $mfcast_len * 3600 / $model_dt`
step_output=`expr $output_inteval * 3600 / $model_dt`
YYYY1=`echo $begintime | cut -c1-4`
MM1=`echo $begintime | cut -c5-6`
DD1=`echo $begintime | cut -c7-8`
HH1=`echo $begintime | cut -c9-10`
YYYY2=`echo $endtime | cut -c1-4`
MM2=`echo $endtime | cut -c5-6`
DD2=`echo $endtime | cut -c7-8`
HH2=`echo $endtime | cut -c9-10`
#####################
# enter work space
#####################
test -d ${RUN_DIR} || mkdir -p ${RUN_DIR}
cd ${RUN_DIR}
#####################
# prepare data
#####################
#ln -sf ${FCST_RUN_DIR}/postvar${begintime} .
ln -sf ${FCST_RUN_DIR}/postvar* .
#ln -sf ${FCST_RUN_DIR}/post.ctl_${begintime} .
ln -sf ${FCST_RUN_DIR}/post.ctl_* .
###########
# namelist.input
###########
test -f namelist.input || rm -rf namelist.input
if [ $levels -eq 17 ];then
test -s namelist.input && rm -f namelist.input
cat > namelist.input «eof &ctl_file path = “.” grads_ctl = “post.ctl_${begintime}” ctl_flag = “meso” ! (global,meso,ruc) / &choose_output vor_div_c = true !global,meso,ruc rh_c = true !global,meso,ruc t_td_c = true !global,meso,ruc t_adv_vor_adv_c = false !global q_flux_div_c = true !global,meso,ruc thetase_c = true !global,meso,ruc ki_c = true !global,meso,ruc t24_c = false !meso h24_c = false !meso p24_c = false !meso h500_c = false !meso rain_c = false !meso rain3_c = false !meso rain6_c = false !meso rain12_c = false !meso rain24_c = false !meso speed_c = true !global,meso,ruc cal_smooth_c = false !global,meso,ruc CALCAPE_c = true !global,meso,ruc calq2m_rh2m_c = true !meso,ruc calrh2td2m_c = false !meso,ruc post2dbz_c = false !global,meso,ruc cal_dttase_c = false !global,meso,ruc cal_sweat_c = true !global,meso,ruc cal_srh_c = false !global,meso,ruc cal_tempadv_c = false !meso,ruc cal_shr_c = false !global,meso,ruc cal_PcTcLiLfc_c = true !meso,ruc cal_bli_c = true !global,meso,ruc ilc_c = true !global,meso,ruc / &grib_parameter1 vsel1 = 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 0, 0, 0 vsel2 = 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 0, 0, 0 vsel3 = 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 0, 0, 0 vsel4 = 1000, 925, 850, 700, 600, 500, 400, 300, 250, 200, 150, 100, 70, 50, 30, 20, 10, 0, 0, 0 / &grib_parameter2 dpbnd = 300.E2 itype = 1 / EOF elif [ $levels -eq 26 ];then test -s namelist.input && rm -f namelist.input cat > namelist.input «eof &ctl_file path = “.” grads_ctl = “post.ctl_${begintime}00000” ctl_flag = “meso” ! (global,meso,ruc) / &choose_output vor_div_c = true !global,meso,ruc rh_c = true !global,meso,ruc t_td_c = true !global,meso,ruc t_adv_vor_adv_c = false !global q_flux_div_c = true !global,meso,ruc thetase_c = true !global,meso,ruc ki_c = true !global,meso,ruc t24_c = false !meso h24_c = false !meso p24_c = false !meso h500_c = false !meso rain_c = false !meso rain3_c = false !meso rain6_c = false !meso rain12_c = false !meso rain24_c = false !meso speed_c = true !global,meso,ruc cal_smooth_c = true !global,meso,ruc CALCAPE_c = true !global,meso,ruc calq2m_rh2m_c = true !meso,ruc calrh2td2m_c = true !meso,ruc post2dbz_c = true !global,meso,ruc cal_dttase_c = true !global,meso,ruc cal_sweat_c = true !global,meso,ruc cal_srh_c = true !global,meso,ruc cal_tempadv_c = true !meso,ruc cal_shr_c = true !global,meso,ruc cal_PcTcLiLfc_c = true !meso,ruc cal_bli_c = true !global,meso,ruc ilc_c = true !global,meso,ruc / &grib_parameter1 vsel1 = 1000,975,950,925,900,850,800,750,700,650,600,550,500,450,400,350,300,250,200,150,100,70,50,30,20,10,0,0,0,0 vsel2 = 1000,975,950,925,900,850,800,750,700,650,600,550,500,450,400,350,300,250,200,150,100,70,50,30,20,10,0,0,0,0 vsel3 = 1000,975,950,925,900,850,800,750,700,650,600,550,500,450,400,350,300,250,200,150,100,70,50,30,20,10,0,0,0,0 vsel4 = 1000,975,950,925,900,850,800,750,700,650,600,550,500,450,400,350,300,250,200,150,100,70,50,30,20,10,0,0,0,0 / &grib_parameter2 dpbnd = 300.E2 itype = 1 / EOF fi ##################### # run program ##################### ${PRODUCT_BIN} ###################### # END ###################### date [/shell]