diff --git a/jobs/JHAFS_ANALYSIS b/jobs/JHAFS_ANALYSIS
index 039e54ec9..a4af5d369 100755
--- a/jobs/JHAFS_ANALYSIS
+++ b/jobs/JHAFS_ANALYSIS
@@ -39,6 +39,11 @@ export cyc=${cyc:?}
export STORM=${STORM:-FAKE}
export STORMID=${STORMID:-00L}
export ENSDA=${ENSDA:-NO}
+export GSI_D01=${GSI_D01:-NO}
+export GSI_D02=${GSI_D02:-NO}
+
+# analysis for d01
+if [ ${GSI_D01} = YES ]; then
export DATA=${WORKhafs}/analysis
@@ -52,12 +57,38 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_analysis.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
rm -rf $DATA
fi
+fi
+
+# analysis for d02
+if [ ${GSI_D02} = YES ]; then
+
+export neststr=".nest02"
+export tilestr=".tile2"
+export nesttilestr=".nest02.tile2"
+export DATA=${WORKhafs}/analysis_d02
+
+export SCRUBDATA=${SCRUBDATA:-YES}
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+fi
+
+mkdir -p $DATA
+cd $DATA
+
+# Execute ex-script
+${HOMEhafs}/scripts/exhafs_analysis.sh
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+fi
+
date
diff --git a/jobs/JHAFS_ANALYSIS_VR b/jobs/JHAFS_ANALYSIS_VR
index 20ecb7977..9010965e7 100755
--- a/jobs/JHAFS_ANALYSIS_VR
+++ b/jobs/JHAFS_ANALYSIS_VR
@@ -62,8 +62,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_analysis_vr.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ATM_IC b/jobs/JHAFS_ATM_IC
index 08de1cd63..b80fd9e1a 100755
--- a/jobs/JHAFS_ATM_IC
+++ b/jobs/JHAFS_ATM_IC
@@ -41,15 +41,20 @@ export cyc=${cyc:?}
export STORM=${STORM:-FAKE}
export STORMID=${STORMID:-00L}
export ENSDA=${ENSDA:-NO}
+export FGAT_MODEL=${FGAT_MODEL:-gfs}
+export FGAT_HR=${FGAT_HR:-00}
# Deterministic or ensemble
-if [ ${ENSDA} != YES ]; then
- export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/chgres}
- export DATA=${WORKhafs}/atm_ic
-else
+if [ ${ENSDA} = YES ]; then
export ENSID=${ENSID:-001}
export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/chgres_ens/mem${ENSID}}
export DATA=${WORKhafs}/atm_ic_ens/mem${ENSID}
+elif [ ${FGAT_MODEL} = gdas ]; then
+ export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/chgres_fgat${FGAT_HR}}
+ export DATA=${WORKhafs}/atm_ic_fgat${FGAT_HR}
+else
+ export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/chgres}
+ export DATA=${WORKhafs}/atm_ic
fi
export SCRUBDATA=${SCRUBDATA:-YES}
@@ -62,8 +67,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_ic.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ATM_INIT b/jobs/JHAFS_ATM_INIT
index d5e162450..c3176b559 100755
--- a/jobs/JHAFS_ATM_INIT
+++ b/jobs/JHAFS_ATM_INIT
@@ -17,8 +17,14 @@ export machine=${WHERE_AM_I:-wcoss_cray}
export envir=${envir:-prod} # prod, para, test
export RUN_ENVIR=${RUN_ENVIR:-dev} # nco or dev
if [ "${RUN_ENVIR^^}" != NCO ]; then
- module use ${HOMEhafs}/sorc/hafs_forecast.fd/modulefiles
- module load ufs_${machine}
+ #module list
+ #module unload intelpython
+ #module use ${HOMEhafs}/sorc/hafs_forecast.fd/modulefiles
+ #if [ "${machine}" = "wcoss_cray" ] || [ "${machine}" = "wcoss_dell_p3" ]; then
+ # module load ufs_${machine}
+ #else
+ # module load ufs_${machine}.intel
+ #fi
module list
fi
@@ -34,35 +40,79 @@ export COMIN=${COMIN:?}
export COMOUT=${COMOUT:?}
export COMhafs=${COMhafs:-${COMOUT}}
+export MPISERIAL=${MPISERIAL:-${EXEChafs}/hafs_mpiserial.x}
+
export CDATE=${CDATE:-${YMDH}}
export cyc=${cyc:?}
export STORM=${STORM:-FAKE}
export STORMID=${STORMID:-00L}
export ENSDA=${ENSDA:-NO}
+export FGAT_MODEL=${FGAT_MODEL:-gfs}
+export FGAT_HR=${FGAT_HR:-00}
-# Deterministic or ensemble
-if [ "${ENSDA}" != YES ]; then
- export FIXgrid=${FIXgrid:-${WORKhafs}/intercom/grid}
- export INPdir=${INPdir:-${WORKhafs}/intercom/chgres}
- export DATA=${WORKhafs}/atm_init
- export RESTARTout=${COMhafs}/RESTART_init
-else
+export run_init=yes
+if [ ${FGAT_MODEL} = gdas ]; then
+ export CDATE=$(${NDATE} $(awk "BEGIN {print ${FGAT_HR}-6}") $CDATE)
+# export out_prefix=$(echo "${STORM}${STORMID}.${CDATE}" | tr '[A-Z]' '[a-z]')
+ export out_prefix="${STORMID,,}.${CDATE}"
+fi
+
+#===============================================================================
+# forecast
+
+if [ "${ENSDA}" = YES ]; then
export ENSID=${ENSID:-001}
- export FIXgrid=${FIXgrid:-${WORKhafs}/intercom/grid_ens}
- export INPdir=${INPdir:-${WORKhafs}/intercom/chgres_ens/mem${ENSID}}
- export DATA=${WORKhafs}/atm_init_ens/mem${ENSID}
- export RESTARTout=${COMhafs}/RESTART_init_ens/mem${ENSID}
+ export FIXgrid=${WORKhafs}/intercom/grid_ens
+ export INPdir=${WORKhafs}/intercom/chgres_ens/mem${ENSID}
+ export DATA=${WORKhafs}/atm_init_ens/mem${ENSID}/forecast
+ export RESTARTout=${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}
+elif [ ${FGAT_MODEL} = gdas ]; then
+ export FIXgrid=${WORKhafs}/intercom/grid
+ export INPdir=${WORKhafs}/intercom/chgres_fgat${FGAT_HR}
+ export DATA=${WORKhafs}/atm_init_fgat${FGAT_HR}/forecast
+ export RESTARTout=${WORKhafs}/intercom/RESTART_init_fgat${FGAT_HR}
+else
+ export FIXgrid=${WORKhafs}/intercom/grid
+ export INPdir=${WORKhafs}/intercom/chgres
+ export DATA=${WORKhafs}/atm_init/forecast
+ export RESTARTout=${WORKhafs}/intercom/RESTART_init
fi
#export NHRS=$(echo "${dt_atmos}/3600" | bc -l)
-export NHRS=$(awk "BEGIN {print ${dt_atmos}/3600*2}")
+#export NHRS=$(awk "BEGIN {print ${dt_atmos}/3600*2}")
+export NHRS=$(awk "BEGIN {print ${dt_atmos}/3600}")
+export NHRS_ENS=$(awk "BEGIN {print ${dt_atmos}/3600}")
+#export NBDYHRS=0
export restart_interval="$(awk "BEGIN {print ${dt_atmos}/3600}") 6"
export warm_start_opt=0
-export RUN_GSI=NO
+
+export RUN_ATM_MERGE=NO
+export RUN_ATM_MERGE_FGAT=NO
+export RUN_ATM_MERGE_ENS=NO
+export RUN_ATM_VI=NO
+export RUN_ATM_VI_FGAT=NO
+export RUN_ATM_VI_ENS=NO
export RUN_GSI_VR=NO
+export RUN_GSI_VR_FGAT=NO
export RUN_GSI_VR_ENS=NO
+export RUN_GSI=NO
export RUN_ENKF=NO
+export RUN_ANALYSIS_MERGE=NO
+export RUN_ANALYSIS_MERGE_ENS=NO
export run_ocean=no
+export run_wave=no
+export ccpp_suite_regional=${ccpp_suite_regional_init:-$ccpp_suite_regional}
+export ccpp_suite_glob=${ccpp_suite_glob_init:-$ccpp_suite_glob}
+export ccpp_suite_nest=${ccpp_suite_nest_init:-$ccpp_suite_nest}
+export nstf_n1=${nstf_n1_init:-$nstf_n1}
+export nstf_n2=${nstf_n2_init:-$nstf_n2}
+export nstf_n3=${nstf_n3_init:-$nstf_n3}
+export nstf_n4=${nstf_n4_init:-$nstf_n4}
+export nstf_n5=${nstf_n5_init:-$nstf_n5}
+export glob_layoutx=${glob_layoutx_init:-$glob_layoutx}
+export glob_layouty=${glob_layouty_init:-$glob_layouty}
+export layoutx=${layoutx_init:-$layoutx}
+export layouty=${layouty_init:-$layouty}
export SCRUBDATA=${SCRUBDATA:-YES}
if [ "${SCRUBDATA}" = YES ]; then
@@ -74,8 +124,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_forecast.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
@@ -83,3 +131,142 @@ if [ "${KEEPDATA^^}" != YES ]; then
fi
date
+
+#===============================================================================
+# post
+
+if [ ${ENSDA} = YES ]; then
+ export ENSID=${ENSID:-001}
+ export INPdir=${WORKhafs}/atm_init_ens/mem${ENSID}/forecast
+ export DATA=${WORKhafs}/atm_init_ens/mem${ENSID}/post
+ export COMOUTpost=${WORKhafs}/intercom/atm_init_ens/mem${ENSID}
+ export intercom=${WORKhafs}/intercom/atm_init_ens/mem${ENSID}/post
+ export NHRS_ENS=0
+elif [ ${FGAT_MODEL} = gdas ]; then
+ export INPdir=${WORKhafs}/atm_init_fgat${FGAT_HR}/forecast
+ export DATA=${WORKhafs}/atm_init_fgat${FGAT_HR}/post
+ export COMOUTpost=${WORKhafs}/intercom/atm_init_fgat${FGAT_HR}
+ export intercom=${WORKhafs}/intercom/atm_init_fgat${FGAT_HR}/post
+ export NHRS=0
+else
+ export INPdir=${WORKhafs}/atm_init/forecast
+ export DATA=${WORKhafs}/atm_init/post
+ export COMOUTpost=${WORKhafs}/intercom/atm_init
+ export intercom=${WORKhafs}/intercom/atm_init/post
+ export NHRS=0
+fi
+
+export SENDCOM=${SENDCOM:-YES}
+export SCRUBDATA=${SCRUBDATA:-YES}
+
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+ rm -f $INPdir/postf???
+ rm -rf ${intercom}
+fi
+mkdir -p ${COMOUTpost}
+mkdir -p ${intercom}
+mkdir -p $DATA
+cd $DATA
+
+# Execute ex-script
+${HOMEhafs}/scripts/exhafs_atm_post.sh
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+date
+
+#===============================================================================
+# product
+
+export OMP_NUM_THREADS=1
+export APRUNC=${APRUNS}
+
+if [ ${ENSDA} = YES ]; then
+ export ENSID=${ENSID:-001}
+ export INPdir=${WORKhafs}/intercom/atm_init_ens/mem${ENSID}/post
+ export DATA=${WORKhafs}/atm_init_ens/mem${ENSID}/product
+ export COMOUTproduct=${WORKhafs}/intercom/atm_init_ens/mem${ENSID}
+ export NHRS_ENS=0
+elif [ ${FGAT_MODEL} = gdas ]; then
+ export INPdir=${WORKhafs}/intercom/atm_init_fgat${FGAT_HR}/post
+ export DATA=${WORKhafs}/atm_init_fgat${FGAT_HR}/product
+ export COMOUTproduct=${WORKhafs}/intercom/atm_init_fgat${FGAT_HR}
+ export NHRS=0
+else
+ export INPdir=${WORKhafs}/intercom/atm_init/post
+ export DATA=${WORKhafs}/atm_init/product
+ export COMOUTproduct=${WORKhafs}/intercom/atm_init
+ export NHRS=0
+fi
+
+export SENDCOM=${SENDCOM:-YES}
+export SCRUBDATA=${SCRUBDATA:-YES}
+
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+fi
+
+mkdir -p ${COMOUTproduct}
+mkdir -p $DATA
+cd $DATA
+
+if [ ${gtype} = nest ]; then
+ ngrids=$((${nest_grids} + 1))
+else
+ ngrids=${nest_grids}
+fi
+
+rm -f cmdfile_product
+# Loop for grids/domains to prepare the cmdfile
+for ng in $(seq 1 ${ngrids});
+do
+
+if [[ $ng -eq 1 ]]; then
+ neststr=""
+ tilestr=".tile1"
+else
+ neststr=".nest$(printf '%02d' ${ng})"
+ tilestr=".tile$(printf '%d' ${ng})"
+fi
+gridstr=".grid$(printf '%02d' ${ng})"
+echo "export neststr=$neststr tilestr=${tilestr} gridstr=${gridstr}; ${HOMEhafs}/scripts/exhafs_product.sh > run_product${gridstr}.log 2>&1" >> cmdfile_product
+
+done
+
+chmod +x cmdfile_product
+if [ ${machine} = "wcoss_cray" ]; then
+ export OMP_NUM_THREADS=1
+ export APRUNF="aprun -b -j1 -n2 -N1 -d1 -cc depth cfp"
+ ${APRUNF} cmdfile_product
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_product
+fi
+
+for ng in $(seq 1 ${ngrids});
+do
+
+gridstr=".grid$(printf '%02d' ${ng})"
+if grep "PROGRAM GETTRK HAS ENDED" ./run_product${gridstr}.log ; then
+ echo "INFO: successfully ran run_product${gridstr}"
+else
+ echo "ERROR: failed running run_product${gridstr}"
+ echo "ERROR: exitting..."
+ exit 1
+fi
+
+done
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+date
+
+#===============================================================================
+
+exit
diff --git a/jobs/JHAFS_ATM_LBC b/jobs/JHAFS_ATM_LBC
index 98f4dae60..1dd07afb7 100755
--- a/jobs/JHAFS_ATM_LBC
+++ b/jobs/JHAFS_ATM_LBC
@@ -65,8 +65,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_lbc.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ATM_POST b/jobs/JHAFS_ATM_POST
index e2fb38443..ce8efb18c 100755
--- a/jobs/JHAFS_ATM_POST
+++ b/jobs/JHAFS_ATM_POST
@@ -59,8 +59,8 @@ export SCRUBDATA=${SCRUBDATA:-YES}
if [ "${SCRUBDATA}" = YES ]; then
rm -rf $DATA
- rm -f $INPdir/postf???
- rm -rf ${intercom}
+# rm -f $INPdir/post*f???
+# rm -rf ${intercom}
fi
mkdir -p ${COMOUTpost}
mkdir -p ${intercom}
@@ -69,8 +69,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_atm_post.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ATM_PREP b/jobs/JHAFS_ATM_PREP
index 1aa31ac98..850891c43 100755
--- a/jobs/JHAFS_ATM_PREP
+++ b/jobs/JHAFS_ATM_PREP
@@ -41,16 +41,27 @@ export STORMID=${STORMID:-00L}
export ENSDA=${ENSDA:-NO}
# Deterministic or ensemble
-if [ "${ENSDA}" != YES ]; then
- export CASE=${CASE:-C768}
- export CRES=`echo $CASE | cut -c 2-`
- export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/grid/${CASE}}
- export DATA=${WORKhafs}/atm_prep
-else
+if [ ${ENSDA} = YES ]; then
export CASE=${CASE_ENS:-C768}
export CRES=`echo $CASE | cut -c 2-`
+ export gtype=${gtype_ens:-regional}
+ export gridfixdir=${gridfixdir_ens:-'/let/hafs_grid/generate/grid_ens'}
+ export LEVS=${LEVS_ENS:-65}
+ export istart_nest=${istart_nest_ens:-46}
+ export jstart_nest=${jstart_nest_ens:-238}
+ export iend_nest=${iend_nest_ens:-1485}
+ export jend_nest=${jend_nest_ens:-1287}
+ export stretch_fac=${stretch_fac_ens:-1.0001}
+ export target_lon=${target_lon_ens:--62.0}
+ export target_lat=${target_lat_ens:-22.0}
+ export refine_ratio=${refine_ratio_ens:-4}
export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/grid_ens/${CASE}}
export DATA=${WORKhafs}/atm_prep_ens
+else
+ export CASE=${CASE:-C768}
+ export CRES=`echo $CASE | cut -c 2-`
+ export OUTDIR=${OUTDIR:-${WORKhafs}/intercom/grid/${CASE}}
+ export DATA=${WORKhafs}/atm_prep
fi
export SCRUBDATA=${SCRUBDATA:-YES}
@@ -69,11 +80,50 @@ else
${HOMEhafs}/scripts/exhafs_atm_prep.sh
export err=$?
fi
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
rm -rf $DATA
fi
+# If moving nest is enabled
+if [[ "${is_moving_nest}" = *".true."* ]] || [[ "${is_moving_nest}" = *".T."* ]] ; then
+
+export CASE=${CASE_mvnest1res:-C768}
+export CRES=`echo $CASE | cut -c 2-`
+export gtype=${gtype_mvnest1res:-regional}
+export gridfixdir=${gridfixdir_mvnest1res:-'/let/hafs_grid/generate/grid_mvnest1res'}
+export LEVS=${LEVS_ENS:-65}
+export stretch_fac=${stretch_fac_mvnest1res:-1.0001}
+export target_lon=${target_lon_mvnest1res:--62.0}
+export target_lat=${target_lat_mvnest1res:-22.0}
+export refine_ratio=${refine_ratio_mvnest1res:-4}
+export nest_grids=${nest_grids_mvnest1res:-1}
+export parent_grid_num=${parent_grid_num_mvnest1res:-1}
+export parent_tile=${parent_tile_mvnest1res:-1}
+export istart_nest=${istart_nest_mvnest1res:-46}
+export jstart_nest=${jstart_nest_mvnest1res:-238}
+export iend_nest=${iend_nest_mvnest1res:-1485}
+export jend_nest=${jend_nest_mvnest1res:-1287}
+
+export OUTDIR=${WORKhafs}/intercom/grid_mvnest1res/${CASE}
+export DATA=${WORKhafs}/atm_prep_mvnest1res
+
+export SCRUBDATA=${SCRUBDATA:-YES}
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+fi
+
+mkdir -p $OUTDIR $DATA
+cd $DATA
+
+${HOMEhafs}/scripts/exhafs_atm_prep.sh
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+fi
+
date
diff --git a/jobs/JHAFS_ATM_VI b/jobs/JHAFS_ATM_VI
new file mode 100755
index 000000000..4dfb06b27
--- /dev/null
+++ b/jobs/JHAFS_ATM_VI
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+date
+export PS4='+ $SECONDS + '
+set -xue
+
+export HOMEhafs=${HOMEhafs:?}
+export USHhafs=${USHhafs:-${HOMEhafs}/ush}
+export EXEChafs=${EXEChafs:-${HOMEhafs}/exec}
+export PARMhafs=${PARMhafs:-${HOMEhafs}/parm}
+export FIXhafs=${FIXhafs:-${HOMEhafs}/fix}
+
+source ${USHhafs}/hafs_pre_job.sh.inc
+source ${HOLDVARS:-storm1.holdvars.txt}
+
+export machine=${WHERE_AM_I:-wcoss_cray}
+export envir=${envir:-prod} # prod, para, test
+export RUN_ENVIR=${RUN_ENVIR:-dev} # nco or dev
+if [ "${RUN_ENVIR^^}" != NCO ]; then
+ module use ${HOMEhafs}/modulefiles
+ module load modulefile.hafs.${machine}
+ module list
+fi
+
+source ${USHhafs}/hafs_runcmd.sh.inc
+
+# Run setpdy and initialize PDY variables
+#setpdy.sh
+#. ./PDY
+export PDY=${PDY:-$(echo ${YMDH} | cut -c 1-8 )}
+
+export WORKhafs=${WORKhafs:?}
+export COMIN=${COMIN:?}
+export COMOUT=${COMOUT:?}
+export COMhafs=${COMhafs:-${COMOUT}}
+
+export CDATE=${CDATE:-${YMDH}}
+export cyc=${cyc:?}
+export STORM=${STORM:-FAKE}
+export STORMID=${STORMID:-00L}
+export ENSDA=${ENSDA:-NO}
+export FGAT_MODEL=${FGAT_MODEL:-gfs}
+export FGAT_HR=${FGAT_HR:-00}
+
+NDATE=${NDATE:-ndate}
+export CDATEprior=`${NDATE} -6 $CDATE`
+export COMhafsprior=${COMhafsprior:-${COMhafs}/../../${CDATEprior}/${STORMID}}
+
+# Deterministic or ensemble
+if [ "${ENSDA}" = YES ]; then
+ export ENSID=${ENSID:-001}
+ export RESTARTinp=${COMhafsprior}/RESTART_ens/mem${ENSID}
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_analysis_merge_ens/mem${ENSID}
+ export INTCOMinit=${WORKhafs}/intercom/atm_init_ens/mem${ENSID}
+ export RESTARTinit=${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}
+ export RESTARTout=${WORKhafs}/intercom/RESTART_vi_ens/mem${ENSID}
+ export DATA=${WORKhafs}/atm_vi_ens/mem${ENSID}
+elif [ ${FGAT_MODEL} = gdas ]; then
+ export RESTARTinp=${COMhafsprior}/RESTART
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_merge_fgat${FGAT_HR}
+ export INTCOMinit=${WORKhafs}/intercom/atm_init_fgat${FGAT_HR}
+ export RESTARTinit=${WORKhafs}/intercom/RESTART_init_fgat${FGAT_HR}
+ export RESTARTout=${WORKhafs}/intercom/RESTART_vi_fgat${FGAT_HR}
+ export DATA=${WORKhafs}/atm_vi_fgat${FGAT_HR}
+ export CDATE=$(${NDATE} $(awk "BEGIN {print ${FGAT_HR}-6}") $CDATE)
+else
+ export RESTARTinp=${COMhafsprior}/RESTART
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_merge
+ export INTCOMinit=${WORKhafs}/intercom/atm_init
+ export RESTARTinit=${WORKhafs}/intercom/RESTART_init
+ export RESTARTout=${WORKhafs}/intercom/RESTART_vi
+ export DATA=${WORKhafs}/atm_vi
+fi
+
+export SCRUBDATA=${SCRUBDATA:-YES}
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+fi
+
+mkdir -p $DATA
+cd $DATA
+
+# Execute ex-script
+${HOMEhafs}/scripts/exhafs_atm_vi.sh
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+date
diff --git a/jobs/JHAFS_EMCGRAPHICS b/jobs/JHAFS_EMCGRAPHICS
index a7c2274e5..6edc07b28 100755
--- a/jobs/JHAFS_EMCGRAPHICS
+++ b/jobs/JHAFS_EMCGRAPHICS
@@ -63,8 +63,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_emcgraphics.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ENKF_HX b/jobs/JHAFS_ENKF_HX
index 64af3ab0b..9ea744846 100755
--- a/jobs/JHAFS_ENKF_HX
+++ b/jobs/JHAFS_ENKF_HX
@@ -61,8 +61,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf_hx.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ENKF_MEAN b/jobs/JHAFS_ENKF_MEAN
index 0bd923f67..e4cb2389b 100755
--- a/jobs/JHAFS_ENKF_MEAN
+++ b/jobs/JHAFS_ENKF_MEAN
@@ -52,8 +52,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ENKF_RECENTER b/jobs/JHAFS_ENKF_RECENTER
index fde6af3db..eec57c576 100755
--- a/jobs/JHAFS_ENKF_RECENTER
+++ b/jobs/JHAFS_ENKF_RECENTER
@@ -52,8 +52,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_ENKF_UPDATE b/jobs/JHAFS_ENKF_UPDATE
index 13f14a0af..591191438 100755
--- a/jobs/JHAFS_ENKF_UPDATE
+++ b/jobs/JHAFS_ENKF_UPDATE
@@ -52,8 +52,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_enkf.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_FORECAST b/jobs/JHAFS_FORECAST
index 871dccc3b..26dc1d03c 100755
--- a/jobs/JHAFS_FORECAST
+++ b/jobs/JHAFS_FORECAST
@@ -17,16 +17,14 @@ export machine=${WHERE_AM_I:-wcoss_cray}
export envir=${envir:-prod} # prod, para, test
export RUN_ENVIR=${RUN_ENVIR:-dev} # nco or dev
if [ "${RUN_ENVIR^^}" != NCO ]; then
- if [ "${machine}" = "hera" ]; then
- module unload intelpython
- fi
- module use ${HOMEhafs}/sorc/hafs_forecast.fd/modulefiles
- module unload intelpython
- if [ "${machine}" = "wcoss_cray" ] || [ "${machine}" = "wcoss_dell_p3" ]; then
- module load ufs_${machine}
- else
- module load ufs_${machine}.intel
- fi
+ #module list
+ #module unload intelpython
+ #module use ${HOMEhafs}/sorc/hafs_forecast.fd/modulefiles
+ #if [ "${machine}" = "wcoss_cray" ] || [ "${machine}" = "wcoss_dell_p3" ]; then
+ # module load ufs_${machine}
+ #else
+ # module load ufs_${machine}.intel
+ #fi
module list
fi
@@ -70,8 +68,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_forecast.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_HRDGRAPHICS b/jobs/JHAFS_HRDGRAPHICS
index 406ce8fbe..cd43b8554 100755
--- a/jobs/JHAFS_HRDGRAPHICS
+++ b/jobs/JHAFS_HRDGRAPHICS
@@ -62,8 +62,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_hrdgraphics.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_MERGE b/jobs/JHAFS_MERGE
new file mode 100755
index 000000000..51c36f056
--- /dev/null
+++ b/jobs/JHAFS_MERGE
@@ -0,0 +1,124 @@
+#!/bin/sh
+
+date
+export PS4='+ $SECONDS + '
+set -xue
+
+export HOMEhafs=${HOMEhafs:?}
+export USHhafs=${USHhafs:-${HOMEhafs}/ush}
+export EXEChafs=${EXEChafs:-${HOMEhafs}/exec}
+export PARMhafs=${PARMhafs:-${HOMEhafs}/parm}
+export FIXhafs=${FIXhafs:-${HOMEhafs}/fix}
+
+source ${USHhafs}/hafs_pre_job.sh.inc
+source ${HOLDVARS:-storm1.holdvars.txt}
+
+export machine=${WHERE_AM_I:-wcoss_cray}
+export envir=${envir:-prod} # prod, para, test
+export RUN_ENVIR=${RUN_ENVIR:-dev} # nco or dev
+if [ "${RUN_ENVIR^^}" != NCO ]; then
+ module use ${HOMEhafs}/modulefiles
+ module load modulefile.hafs.${machine}
+ module list
+fi
+
+source ${USHhafs}/hafs_runcmd.sh.inc
+
+# Run setpdy and initialize PDY variables
+#setpdy.sh
+#. ./PDY
+export PDY=${PDY:-$(echo ${YMDH} | cut -c 1-8 )}
+
+export WORKhafs=${WORKhafs:?}
+export COMIN=${COMIN:?}
+export COMOUT=${COMOUT:?}
+export COMhafs=${COMhafs:-${COMOUT}}
+
+export CDATE=${CDATE:-${YMDH}}
+export cyc=${cyc:?}
+export STORM=${STORM:-FAKE}
+export STORMID=${STORMID:-00L}
+export ENSDA=${ENSDA:-NO}
+export FGAT_MODEL=${FGAT_MODEL:-gfs}
+export FGAT_HR=${FGAT_HR:-00}
+
+NDATE=${NDATE:-ndate}
+CDATEprior=`${NDATE} -6 $CDATE`
+PDYprior=`echo ${CDATEprior} | cut -c1-8`
+cycprior=`echo ${CDATEprior} | cut -c9-10`
+yrprior=`echo ${CDATEprior} | cut -c1-4`
+mnprior=`echo ${CDATEprior} | cut -c5-6`
+dyprior=`echo ${CDATEprior} | cut -c7-8`
+hhprior=`echo ${CDATEprior} | cut -c9-10`
+export COMhafsprior=${COMhafsprior:-${COMhafs}/../../${CDATEprior}/${STORMID}}
+
+# merge analysis or init
+if [ ${MERGE_TYPE} = analysis ]; then
+
+export merge_method=${analysis_merge_method:-vortexreplace}
+# Deterministic or ensemble
+if [ "${ENSDA}" = YES ]; then
+ export ENSID=${ENSID:-001}
+ if [ -d ${WORKhafs}/intercom/RESTART_analysis_ens/mem${ENSID} ]; then
+ export RESTARTsrc=${WORKhafs}/intercom/RESTART_analysis_ens/mem${ENSID}
+ elif [ -d ${WORKhafs}/intercom/RESTART_vi_ens/mem${ENSID} ]; then
+ export RESTARTsrc=${WORKhafs}/intercom/RESTART_vi_ens/mem${ENSID}
+ else
+ echo "Error RESTARTsrc does not exist"
+ exit 1
+ fi
+ export RESTARTdst=${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_analysis_merge_ens/mem${ENSID}
+ export DATA=${WORKhafs}/analysis_merge_ens/mem${ENSID}
+else
+ if [ -e ${WORKhafs}/intercom/RESTART_analysis ]; then
+ export RESTARTsrc=${WORKhafs}/intercom/RESTART_analysis
+ elif [ -e ${WORKhafs}/intercom/RESTART_vi ]; then
+ export RESTARTsrc=${WORKhafs}/intercom/RESTART_vi
+ else
+ echo "Error RESTARTsrc does not exist"
+ exit 1
+ fi
+ export RESTARTdst=${WORKhafs}/intercom/RESTART_init
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_analysis_merge
+ export DATA=${WORKhafs}/analysis_merge
+fi
+
+elif [ ${MERGE_TYPE} = init ]; then
+
+export merge_method=${atm_merge_method:-vortexreplace}
+if [ ${FGAT_MODEL} = gdas ]; then
+ export RESTARTsrc=${COMhafsprior}/RESTART
+ export RESTARTdst=${WORKhafs}/intercom/RESTART_init_fgat${FGAT_HR}
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_merge_fgat${FGAT_HR}
+ export DATA=${WORKhafs}/atm_merge_fgat${FGAT_HR}
+ export CDATE=$(${NDATE} $(awk "BEGIN {print ${FGAT_HR}-6}") $CDATE)
+else
+ export RESTARTsrc=${COMhafsprior}/RESTART
+ export RESTARTdst=${WORKhafs}/intercom/RESTART_init
+ export RESTARTmrg=${WORKhafs}/intercom/RESTART_merge
+ export DATA=${WORKhafs}/atm_merge
+fi
+
+else
+ echo "Error unsupported MERGE_TYPE: ${MERGE_TYPE}"
+ exit 1
+fi
+
+export SCRUBDATA=${SCRUBDATA:-YES}
+if [ "${SCRUBDATA}" = YES ]; then
+ rm -rf $DATA
+fi
+
+mkdir -p $DATA
+cd $DATA
+
+# Execute ex-script
+${HOMEhafs}/scripts/exhafs_merge.sh
+
+export KEEPDATA=${KEEPDATA:-YES}
+if [ "${KEEPDATA^^}" != YES ]; then
+ rm -rf $DATA
+fi
+
+date
diff --git a/jobs/JHAFS_OBS_PROC b/jobs/JHAFS_OBS_PROC
index d19955970..c3d2f9dea 100755
--- a/jobs/JHAFS_OBS_PROC
+++ b/jobs/JHAFS_OBS_PROC
@@ -51,8 +51,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_obs_proc.sh
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_OCN_POST b/jobs/JHAFS_OCN_POST
index 15881b465..388129022 100755
--- a/jobs/JHAFS_OCN_POST
+++ b/jobs/JHAFS_OCN_POST
@@ -52,8 +52,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_ocn_post.py
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_OCN_PREP b/jobs/JHAFS_OCN_PREP
index 6f6eb5af6..66204b602 100755
--- a/jobs/JHAFS_OCN_PREP
+++ b/jobs/JHAFS_OCN_PREP
@@ -53,12 +53,9 @@ cd $DATA
# Execute ex-script
if [[ "${run_docn:-no}" == yes ]] ; then
${HOMEhafs}/scripts/exhafs_docn_prep.sh
- export err=$?
else
${HOMEhafs}/scripts/exhafs_ocn_prep.py
- export err=$?
fi
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_PRODUCT b/jobs/JHAFS_PRODUCT
index e33f59f15..f92d50022 100755
--- a/jobs/JHAFS_PRODUCT
+++ b/jobs/JHAFS_PRODUCT
@@ -34,6 +34,8 @@ export COMIN=${COMIN:?}
export COMOUT=${COMOUT:?}
export COMhafs=${COMhafs:-${COMOUT}}
+export MPISERIAL=${MPISERIAL:-${EXEChafs}/hafs_mpiserial.x}
+
export CDATE=${CDATE:-${YMDH}}
export cyc=${cyc:?}
export STORM=${STORM:-FAKE}
@@ -63,10 +65,51 @@ mkdir -p ${COMOUTproduct}
mkdir -p $DATA
cd $DATA
-# Execute ex-script
-${HOMEhafs}/scripts/exhafs_product.sh
-export err=$?
-exit $err
+if [ ${gtype} = nest ]; then
+ ngrids=$((${nest_grids} + 1))
+else
+ ngrids=${nest_grids}
+fi
+
+rm -f cmdfile_product
+# Loop for grids/domains to prepare the cmdfile
+for ng in $(seq 1 ${ngrids});
+do
+
+if [[ $ng -eq 1 ]]; then
+ neststr=""
+ tilestr=".tile1"
+else
+ neststr=".nest$(printf '%02d' ${ng})"
+ tilestr=".tile$(printf '%d' ${ng})"
+fi
+gridstr=".grid$(printf '%02d' ${ng})"
+echo "export neststr=$neststr tilestr=${tilestr} gridstr=${gridstr}; ${HOMEhafs}/scripts/exhafs_product.sh > run_product${gridstr}.log 2>&1" >> cmdfile_product
+
+done
+
+chmod +x cmdfile_product
+if [ ${machine} = "wcoss_cray" ]; then
+ export OMP_NUM_THREADS=1
+ export APRUNF="aprun -b -j1 -n2 -N1 -d1 -cc depth cfp"
+ ${APRUNF} cmdfile_product
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_product
+fi
+
+for ng in $(seq 1 ${ngrids});
+do
+
+gridstr=".grid$(printf '%02d' ${ng})"
+if grep "PROGRAM GETTRK HAS ENDED" ./run_product${gridstr}.log ; then
+ echo "INFO: successfully ran run_product${gridstr}"
+else
+ echo "ERROR: failed running run_product${gridstr}"
+ echo "ERROR: exitting..."
+ exit 1
+fi
+
+done
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_WAV_POST b/jobs/JHAFS_WAV_POST
index 4468ba5d6..06a1bbada 100755
--- a/jobs/JHAFS_WAV_POST
+++ b/jobs/JHAFS_WAV_POST
@@ -52,8 +52,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_wav_post.py
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/jobs/JHAFS_WAV_PREP b/jobs/JHAFS_WAV_PREP
index 574e6da6f..b450d78ce 100755
--- a/jobs/JHAFS_WAV_PREP
+++ b/jobs/JHAFS_WAV_PREP
@@ -57,8 +57,6 @@ cd $DATA
# Execute ex-script
${HOMEhafs}/scripts/exhafs_wav_prep.py
-export err=$?
-exit $err
export KEEPDATA=${KEEPDATA:-YES}
if [ "${KEEPDATA^^}" != YES ]; then
diff --git a/modulefiles/modulefile.hafs.hera b/modulefiles/modulefile.hafs.hera
index e1716fafa..8ff9d1316 100644
--- a/modulefiles/modulefile.hafs.hera
+++ b/modulefiles/modulefile.hafs.hera
@@ -28,8 +28,8 @@ module load png/1.6.35
module load hdf5/1.10.6
module load netcdf/4.7.4
module load pio/2.5.2
-module load esmf/8_2_0
-module load fms/2021.03-avx
+module load esmf/8.3.0b09
+module load fms/2021.04
module load bacio/2.4.1
module load crtm/2.3.0
@@ -40,9 +40,9 @@ module load sp/2.3.3
module load w3emc/2.7.3
module load w3nco/2.4.1
-module load gftl-shared/v1.3.0
+module load gftl-shared/v1.3.3
module load yafyaml/v0.5.1
-module load mapl/2.11.0-esmf-8_2_0
+module load mapl/2.11.0-esmf-8.3.0b09
module load g2/3.4.3
diff --git a/modulefiles/modulefile.hafs.jet b/modulefiles/modulefile.hafs.jet
index 25269bd8d..d0a966ea3 100644
--- a/modulefiles/modulefile.hafs.jet
+++ b/modulefiles/modulefile.hafs.jet
@@ -28,8 +28,8 @@ module load png/1.6.35
module load hdf5/1.10.6
module load netcdf/4.7.4
module load pio/2.5.2
-module load esmf/8_2_0
-module load fms/2021.03
+module load esmf/8.3.0b09
+module load fms/2021.04
module load bacio/2.4.1
module load crtm/2.3.0
@@ -40,9 +40,9 @@ module load sp/2.3.3
module load w3emc/2.7.3
module load w3nco/2.4.1
-module load gftl-shared/v1.3.0
+module load gftl-shared/v1.3.3
module load yafyaml/v0.5.1
-module load mapl/2.11.0-esmf-8_2_0
+module load mapl/2.11.0-esmf-8.3.0b09
module load g2/3.4.3
diff --git a/modulefiles/modulefile.hafs.orion b/modulefiles/modulefile.hafs.orion
index c1be63c60..4c7941e77 100644
--- a/modulefiles/modulefile.hafs.orion
+++ b/modulefiles/modulefile.hafs.orion
@@ -26,8 +26,8 @@ module load png/1.6.35
module load hdf5/1.10.6
module load netcdf/4.7.4
module load pio/2.5.2
-module load esmf/8_2_0
-module load fms/2021.03
+module load esmf/8.3.0b09
+module load fms/2021.04
module load bacio/2.4.1
module load crtm/2.3.0
@@ -38,9 +38,9 @@ module load sp/2.3.3
module load w3emc/2.7.3
module load w3nco/2.4.1
-module load gftl-shared/v1.3.0
+module load gftl-shared/v1.3.3
module load yafyaml/v0.5.1
-module load mapl/2.11.0-esmf-8_2_0
+module load mapl/2.11.0-esmf-8.3.0b09
module load g2/3.4.3
diff --git a/modulefiles/modulefile.hafs.wcoss_cray b/modulefiles/modulefile.hafs.wcoss_cray
index b20c015f7..65f5c8478 100644
--- a/modulefiles/modulefile.hafs.wcoss_cray
+++ b/modulefiles/modulefile.hafs.wcoss_cray
@@ -59,8 +59,8 @@ module load wrf_io/1.1.1
module load wgrib2/2.0.8
#doesn't work setenv WGRIB2 /usrx/local/nceplibs/NCEPLIBS/cmake/install/NCEPLIBS-v1.3.0/wgrib2/wgrib2-2.0.8/bin/wgrib2
-module load esmf/820
-module load fms/2021.03
+module load esmf/8.3.0b09
+module load fms/2021.04
## WCOSS Cray execution prereqs:
module load rca
diff --git a/modulefiles/modulefile.hafs.wcoss_dell_p3 b/modulefiles/modulefile.hafs.wcoss_dell_p3
index 8928b7ce6..ebf41c0a2 100644
--- a/modulefiles/modulefile.hafs.wcoss_dell_p3
+++ b/modulefiles/modulefile.hafs.wcoss_dell_p3
@@ -6,7 +6,7 @@ proc ModulesHelp { } {
}
module-whatis " HAFS model prerequisites"
-module load ips/18.0.1.163
+module load ips/18.0.5.274
module load impi/18.0.1
module load lsf/10.1
module load python/3.6.3
@@ -15,7 +15,7 @@ module use /usrx/local/nceplibs/dev/hpc-stack/libs/hpc-stack/modulefiles/stack
module load hpc/1.1.0
module load cmake/3.20.0
-module load hpc-ips/18.0.1.163
+module load hpc-ips/18.0.5.274
module load hpc-impi/18.0.1
module load jasper/2.0.22
@@ -25,8 +25,8 @@ module load png/1.6.35
module load hdf5/1.10.6
module load netcdf/4.7.4
module load pio/2.5.2
-module load esmf/8_2_0
-module load fms/2021.03
+module load esmf/8.3.0b09
+module load fms/2021.04
module load bacio/2.4.1
module load crtm/2.3.0
@@ -37,9 +37,9 @@ module load sp/2.3.3
module load w3emc/2.7.3
module load w3nco/2.4.1
-module load gftl-shared/v1.3.0
+module load gftl-shared/v1.3.3
module load yafyaml/v0.5.1
-module load mapl/2.11.0-esmf-8_2_0
+module load mapl/2.11.0-esmf-8.3.0b09
module load g2/3.4.3
diff --git a/parm/examples/hafs_globnest2_C96_static.conf b/parm/examples/hafs_globnest2_C96_static.conf
new file mode 100644
index 000000000..dcfc8131e
--- /dev/null
+++ b/parm/examples/hafs_globnest2_C96_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=2
+parent_grid_num=1,1
+parent_tile=2,6
+refine_ratio=3,3
+istart_nest=17,17
+jstart_nest=17,17
+iend_nest=176,176
+jend_nest=176,176
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=10
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=10,10
+layouty=10,10
+npx=241,241
+npy=241,241
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.09 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.09 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest2
+
diff --git a/parm/examples/hafs_globnest2_static.conf b/parm/examples/hafs_globnest2_static.conf
new file mode 100644
index 000000000..1a6950560
--- /dev/null
+++ b/parm/examples/hafs_globnest2_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C768 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=2
+parent_grid_num=1,1
+parent_tile=6,2
+refine_ratio=4,4
+istart_nest=47,47
+jstart_nest=239,239
+iend_nest=1486,1486
+jend_nest=1198,1198
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=8
+glob_npx=769
+glob_npy=769
+# For the nested or regional standalone domain
+layoutx=30,30
+layouty=10,10
+npx=2881,2881
+npy=1921,1921
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest2
+
diff --git a/parm/examples/hafs_globnest2tele_C96_static.conf b/parm/examples/hafs_globnest2tele_C96_static.conf
new file mode 100644
index 000000000..0cc408172
--- /dev/null
+++ b/parm/examples/hafs_globnest2tele_C96_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=2
+parent_grid_num=1,2
+parent_tile=6,7
+refine_ratio=3,3
+istart_nest=17,121
+jstart_nest=17,121
+iend_nest=176,360
+jend_nest=176,360
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=10
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=10,10
+layouty=10,10
+npx=241,361
+npy=241,361
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.09 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.09 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest2
+
diff --git a/parm/examples/hafs_globnest3_C96_static.conf b/parm/examples/hafs_globnest3_C96_static.conf
new file mode 100644
index 000000000..4d5ae2a85
--- /dev/null
+++ b/parm/examples/hafs_globnest3_C96_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=3
+parent_grid_num=1,2,3
+parent_tile=6,7,8
+refine_ratio=3,3,3
+istart_nest=17,121,241
+jstart_nest=17,121,241
+iend_nest=176,360,480
+jend_nest=176,360,480
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=10
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=10,10,10
+layouty=10,10,10
+npx=241,361,361
+npy=241,361,361
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.09 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.09 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest3
+
diff --git a/parm/examples/hafs_globnest4_C96_static.conf b/parm/examples/hafs_globnest4_C96_static.conf
new file mode 100644
index 000000000..50bdb8361
--- /dev/null
+++ b/parm/examples/hafs_globnest4_C96_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=3
+parent_grid_num=1,1,2,3
+parent_tile=2,6,7,8
+refine_ratio=3,3,3,3
+istart_nest=17,17,121,241
+jstart_nest=17,17,121,241
+iend_nest=176,176,360,480
+jend_nest=176,176,360,480
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=10
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=10,10,10,10
+layouty=10,10,10,10
+npx=241,241,361,361
+npy=241,241,361,361
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.09 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.09 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest4
+
diff --git a/parm/examples/hafs_globnest6_C96_static.conf b/parm/examples/hafs_globnest6_C96_static.conf
new file mode 100644
index 000000000..9addac777
--- /dev/null
+++ b/parm/examples/hafs_globnest6_C96_static.conf
@@ -0,0 +1,77 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=22.0
+domlon=-62.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=220N
+vitalsdomlon=620W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=6
+parent_grid_num=1,1,1,1,5,6
+parent_tile=2,3,4,6,10,11
+refine_ratio=3,3,3,3,3,3
+istart_nest=17,17,17,17,121,241
+jstart_nest=17,17,17,17,121,241
+iend_nest=176,176,176,176,360,480
+jend_nest=176,176,176,176,360,480
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=8
+glob_layouty=10
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=10,10,10,10,10,10
+layouty=10,10,10,10,10,10
+npx=241,241,241,241,361,361
+npy=241,241,241,241,361,361
+npz=64
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.09 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.09 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest6
+
diff --git a/parm/forecast/globnest/diag_table.tmp b/parm/forecast/globnest/diag_table.tmp
index 457c451e0..c37a3ee64 100644
--- a/parm/forecast/globnest/diag_table.tmp
+++ b/parm/forecast/globnest/diag_table.tmp
@@ -1,9 +1,14 @@
+ufs.hafs
+@[SYEAR] @[SMONTH] @[SDAY] @[SHOUR] 0 0
+
#output files
-"grid_spec", -1, "months", 1, "days", "time"
+ "grid_spec", -1, "months", 1, "days", "time"
#"atmos_4xdaily", 1, "hours", 1, "days", "time"
-"atmos_static", -1, "hours", 1, "hours", "time"
-"fv3_history", 0, "hours", 1, "hours", "time"
-"fv3_history2d", 0, "hours", 1, "hours", "time"
+ "atmos_static", -1, "hours", 1, "hours", "time"
+ "grid_mspec%4yr%2mo%2dy%2hr", @[GRID_MSPEC_INT], "hours", 1, "hours", "time", 3, "hours"
+#"atmos_diag%4yr%2mo%2dy%2hr", @[ATMOS_DIAG_INT], "hours", 1, "hours", "time", 3, "hours"
+ "fv3_history", 0, "hours", 1, "hours", "time"
+ "fv3_history2d", 0, "hours", 1, "hours", "time"
#"ref3D", 0, "hours", 1, "hours", "time"
#"maxmin2D", 1, "hours", 1, "hours", "time"
@@ -14,11 +19,21 @@
###
# grid_spec
###
- "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
"dynamics", "grid_lont", "grid_lont", "grid_spec", "all", .false., "none", 2,
"dynamics", "grid_latt", "grid_latt", "grid_spec", "all", .false., "none", 2,
- "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
+###
+# grid_mspec
+###
+ "dynamics", "grid_mlon", "grid_lon", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlat", "grid_lat", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlont", "grid_lont", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlatt", "grid_latt", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "marea", "area", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "mdx", "dx", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "mdy", "dy", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
###
# 4x daily output
###
@@ -104,6 +119,35 @@
"dynamics", "hybm", "hybm", "atmos_static", "all", .false., "none", 2
"dynamics", "zsurf", "zsurf", "atmos_static", "all", .false., "none", 2
###
+# GFDL tracker needed variables
+###
+##"dynamics", "grid_lon", "grid_lon", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+##"dynamics", "grid_lat", "grid_lat", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "grid_mlon", "grid_lon", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "grid_mlat", "grid_lat", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "vort850", "vort850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "vort700", "vort700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "us", "us", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u850", "u850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u700", "u700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u500", "u500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "vs", "vs", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v850", "v850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v700", "v700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v500", "v500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t850", "t850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t500", "t500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t300", "t300", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "slp", "slp", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z850", "z850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z700", "z700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z500", "z500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z200", "z200", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "rh850", "rh850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "rh500", "rh500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+##"gfs_phys", "u10m", "u10m", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+##"gfs_phys", "v10m", "v10m", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+###
# FV3 variabls needed for NGGPS evaluation
###
"gfs_dyn", "ucomp", "ugrd", "fv3_history", "all", .false., "none", 2
diff --git a/parm/forecast/globnest/input.nml.tmp b/parm/forecast/globnest/input.nml.tmp
index 164f07f04..0e1983baa 100644
--- a/parm/forecast/globnest/input.nml.tmp
+++ b/parm/forecast/globnest/input.nml.tmp
@@ -1,375 +1,382 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
+&atmos_model_nml
+ blocksize = @[blocksize]
+ chksum_debug = .false.
+ dycore_only = .false.
+ avg_max_length = 3600.
+ ccpp_suite = '@[ccpp_suite_nml]'
/
- &diag_manager_nml
- prepend_date = .false.
+&diag_manager_nml
+ prepend_date = .false.
/
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
+&mpp_io_nml
+ header_buffer_val = 16384,
+ global_field_on_root_pe = .true.,
+ io_clocks_on = .false.,
+ shuffle = 0,
+ deflate_level = @[deflate_level],
+ cf_compliance = .false.
/
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
+&fms_io_nml
+ checksum_required = .false.
+ max_files_r = 1000,
+ max_files_w = 1000,
/
- &fms2_io_nml
-netcdf_default_format="netcdf4"
+&fms2_io_nml
+ netcdf_default_format="netcdf4"
/
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
+&fms_nml
+ clock_grain = 'ROUTINE',
+ domains_stack_size = 30000000,
+ print_memory_usage = .false.
/
- &fv_grid_nml
- !grid_file = 'INPUT/grid_spec.nc'
+&fv_grid_nml
+ !grid_file = 'INPUT/grid_spec.nc'
/
- &fv_core_nml
- !layout = 12,12
- !layout = 8,8
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 6
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 30.e2
- d2_bg_k1 = 0.16
- d2_bg_k2 = 0.05
- kord_tm = -9
- kord_mt = 9
- kord_wz = 9
- kord_tr = 9
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 6
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.002
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 5
- hord_vt = 5
- hord_tm = 5
- hord_dp = -5
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 1.
- do_sat_adj = .T.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
+&fv_core_nml
+ layout = @[layoutx_nml],@[layouty_nml]
+ io_layout = @[io_layoutx_nml],@[io_layouty_nml]
+ npx = @[npx_nml]
+ npy = @[npy_nml]
+ ntiles = 6
+ npz = @[npz]
+ !grid_type = -1
+ make_nh = .false.
+ fv_debug = .false.
+ range_warn = .true.
+ reset_eta = .false.
+ n_sponge = 24
+ nudge_qv = .false.
+ nudge_dz = .false.
+ tau = 5.
+ rf_cutoff = 30.e2
+ d2_bg_k1 = 0.16
+ d2_bg_k2 = 0.05
+ kord_tm = -9
+ kord_mt = 9
+ kord_wz = 9
+ kord_tr = 9
+ hydrostatic = .false.
+ phys_hydrostatic = .false.
+ use_hydro_pressure = .false.
+ beta = 0.
+ a_imp = 1.
+ p_fac = 0.1
+ k_split = @[k_split_nml]
+ n_split = @[n_split_nml]
+ nwat = 6
+ na_init = @[na_init]
+ d_ext = 0.0
+ dnats = 1
+ fv_sg_adj = 300
+ d2_bg = 0.
+ nord = 2
+ dddmp = 0.1
+ d4_bg = 0.15
+ vtdm4 = 0.04
+ delt_max = 0.002
+ ke_bg = 0.
+ do_vort_damp = .true.
+ external_ic = @[external_ic]
+ external_eta = .true.
+ gfs_phil = .false.
+ nggps_ic = @[nggps_ic]
+ mountain = @[mountain]
+ ncep_ic = .false.
+ d_con = 1.0
+ hord_mt = 5
+ hord_vt = 5
+ hord_tm = 5
+ hord_dp = -5
+ hord_tr = -5
+ adjust_dry_mass = .false.
+ consv_te = 1.
+ do_sat_adj = .true.
+ consv_am = .false.
+ fill = .true.
+ dwind_2d = .false.
+ print_freq = 3
+ warm_start = @[warm_start]
+ no_dycore = .false.
+ z_tracer = .true.
+ agrid_vel_rst = .true.
+ read_increment = .false.
+ res_latlon_dynamics = "fv3_increment.nc"
+ write_3d_diags = .true.
- do_schmidt = .true.
- target_lat = _target_lat_
- target_lon = _target_lon_
- stretch_fac = _stretch_fac_
+ do_schmidt = .true.
+ target_lat = @[target_lat]
+ target_lon = @[target_lon]
+ stretch_fac = @[stretch_fac]
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 0
- nord_zs_filter = 4
+ full_zs_filter = @[full_zs_filter_nml]
+ n_zs_filter = @[n_zs_filter_nml]
+ nord_zs_filter = 4
/
- &fv_nest_nml
- grid_pes = _glob_pes_, _nest_pes_
- tile_coarse = 0, 6
- num_tile_top = 6
- p_split = 1
- nest_refine = 0, _refinement_
- nest_ioffsets= 1, _ioffset_
- nest_joffsets= 1, _joffset_
+&fv_nest_nml
+ grid_pes = @[grid_pes]
+ tile_coarse = @[tile_coarse]
+ num_tile_top = 6
+ p_split = 1
+ nest_refine = @[refine]
+ nest_ioffsets = @[ioffset]
+ nest_joffsets = @[joffset]
/
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
+&fv_moving_nest_nml
+ surface_dir = "INPUT/moving_nest"
+ is_moving_nest = @[is_moving_nest]
+ vortex_tracker = @[vortex_tracker]
+ ntrack = @[ntrack]
+ move_cd_x = @[move_cd_x]
+ move_cd_y = @[move_cd_y]
/
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
+&surf_map_nml
+ zero_ocean = .false.
+ cd4 = 0.15
+ cd2 = -1
+ n_del2_strong = 0
+ n_del2_weak = @[n_del2_weak_nml]
+ n_del4 = 2
+ max_slope = @[max_slope_nml]
+ peak_fac = 1.
/
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 11
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .true.
- shal_cnv = .true. !Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .false.
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF_moninedmf
- satmedmf = .true.
- isatmedmf = 1
- rlmx = 300.
- elmx = 300.
- sfc_rlm = 1
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 3.5, 0.25 ! NCEP default
- sfc_z0_type = 6
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 1
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
+&external_ic_nml
+ filtered_terrain = .true.
+ levp = @[levp]
+ gfs_dwinds = .true.
+ checker_tr = .false.
+ nt_checker = 0
/
- &gfdl_cloud_microphysics_nml
- sedi_transport = .true.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
+&gfs_physics_nml
+ fhzero = 3.
+ ldiag3d = .false.
+ lradar = .true.
+ avg_max_length = 3600.
+ h2o_phys = .true.
+ fhcyc = 0.
+ use_ufo = .true.
+ pre_rad = .false.
+ imp_physics = 11
+ pdfcld = .false.
+ fhswr = @[fhswr]
+ fhlwr = @[fhlwr]
+ ialb = 1
+ iems = 1
+ iaer = 111
+ ico2 = 2
+ isubc_sw = 2
+ isubc_lw = 2
+ isol = 2
+ lwhtr = .true.
+ swhtr = .true.
+ cnvgwd = .true.
+ cal_pre = .false.
+ redrag = .true.
+ dspheat = .true.
+ hybedmf = .false.
+ hurr_pbl = .true. ! HWRF moninedmf
+ moninq_fac = -1.0 ! HWRF_moninedmf
+ satmedmf = .true.
+ isatmedmf = 1
+ rlmx = 300.
+ elmx = 300.
+ sfc_rlm = 1
+ random_clds = .false.
+ trans_trac = .true.
+ cnvcld = .true.
+ shal_cnv = @[shal_cnv_nml] !Shallow convection
+ do_deep = @[do_deep_nml]
+ imfshalcnv = 2
+ imfdeepcnv = 2
+ cdmbgwd = 3.5, 0.25 ! NCEP default
+ sfc_z0_type = 6
+ prslrd0 = 0.
+ ivegsrc = 1
+ isot = 1
+ lsm = 1
+ iopt_dveg = 2
+ iopt_crs = 1
+ iopt_btr = 1
+ iopt_run = 1
+ iopt_sfc = 1
+ iopt_frz = 1
+ iopt_inf = 1
+ iopt_rad = 1
+ iopt_alb = 2
+ iopt_snf = 4
+ iopt_tbot = 2
+ iopt_stc = 1
+ debug = .false.
+ oz_phys = .false.
+ oz_phys_2015 = .true.
+ nst_anl = .true.
+ nstf_name = @[nstf_n1],@[nstf_n2],@[nstf_n3],@[nstf_n4],@[nstf_n5]
+ cplflx = @[cplflx]
+ cplice = .false.
+ cplocn2atm = @[cplocn2atm]
+ cplwav = @[cplwav]
+ cplwav2atm = @[cplwav2atm]
+ cpl_imp_mrg = @[merge_import]
+ psautco = 0.0008, 0.0005
+ prautco = 0.00015, 0.00015
+ iau_delthrs = 6
+ iaufhrs = 30
+ iau_inc_files = ''
+ iau_drymassfixer = .false.
+ lgfdlmprad = .true.
+ effr_in = .true.
+ do_sppt = .false.
+ do_shum = .false.
+ do_skeb = .false.
+ lndp_type = 0
+ n_var_lndp = 0
+ do_ca = .false.
+ ca_sgs = .false.
+ nca = 1
+ ncells = 5
+ nlives = 12
+ nseed = 1
+ nfracseed = 0.5
+ ca_trigger = .false.
+ ca_entr = .false.
+ ca_closure = .false.
+ ca_global = .false.
+ nca_g = 1
+ ncells_g = 1
+ nlives_g = 100
+ nseed_g = 100
+ ca_smooth = .false.
+ nspinup = 1
+ iseed_ca = 1
+ nsmooth = 100
+ ca_amplitude = 0.35
+ print_diff_pgr = .true.
/
- &interpolator_nml
- interp_method = 'conserve_great_circle'
+&gfdl_cloud_microphysics_nml
+ sedi_transport = .true.
+ do_sedi_heat = .false.
+ rad_snow = .true.
+ rad_graupel = .true.
+ rad_rain = .true.
+ const_vi = .false.
+ const_vs = .false.
+ const_vg = .false.
+ const_vr = .false.
+ vi_max = 1.
+ vs_max = 2.
+ vg_max = 12.
+ vr_max = 12.
+ qi_lim = 1.
+ prog_ccn = .false.
+ do_qa = .true.
+ fast_sat_adj = .true.
+ tau_l2v = 180.
+ tau_v2l = 90.
+ tau_g2v = 900.
+ rthresh = 10.e-6 ! This is a key parameter for cloud water
+ dw_land = 0.16
+ dw_ocean = 0.10
+ ql_gen = 1.0e-3
+ ql_mlt = 1.0e-3
+ qi0_crt = 8.0E-5
+ qs0_crt = 1.0e-3
+ tau_i2s = 1000.
+ c_psaci = 0.05
+ c_pgacs = 0.01
+ rh_inc = 0.30
+ rh_inr = 0.30
+ rh_ins = 0.30
+ ccn_l = 300.
+ ccn_o = 100.
+ c_paut = 0.5
+ c_cracw = 0.8
+ use_ppm = .false.
+ use_ccn = .true.
+ mono_prof = .true.
+ z_slope_liq = .true.
+ z_slope_ice = .true.
+ de_ice = .false.
+ fix_negative = .true.
+ icloud_f = 1
+ mp_time = 90.
/
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
+&interpolator_nml
+ interp_method = 'conserve_great_circle'
/
- &nam_stochy
+&namsfc
+ FNGLAC = "global_glacier.2x2.grb",
+ FNMXIC = "global_maxice.2x2.grb",
+ FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
+ FNSNOC = "global_snoclim.1.875.grb",
+ FNZORC = "igbp"
+ !FNZORC = "global_zorclim.1x1.grb",
+ FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
+ FNALBC2 = "global_albedo4.1x1.grb",
+ FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
+ FNTG3C = "global_tg3clim.2.6x1.5.grb",
+ FNVEGC = "global_vegfrac.0.144.decpercent.grb",
+ FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
+ FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
+ FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
+ FNMSKH = "seaice_newland.grb",
+ FNTSFA = "",
+ FNACNA = "",
+ FNSNOA = "",
+ FNVMNC = "global_shdmin.0.144x0.144.grb",
+ FNVMXC = "global_shdmax.0.144x0.144.grb",
+ FNSLPC = "global_slope.1x1.grb",
+ FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
+ LDEBUG = .true.,
+ FSMCL(2) = 99999
+ FSMCL(3) = 99999
+ FSMCL(4) = 99999
+ FTSFS = 90
+ FAISS = 99999
+ FSNOL = 99999
+ FSICL = 99999
+ FTSFL = 99999
+ FAISL = 99999
+ FVETL = 99999,
+ FSOTL = 99999,
+ FvmnL = 99999,
+ FvmxL = 99999,
+ FSLPL = 99999,
+ FABSL = 99999,
+ FSNOS = 99999,
+ FSICS = 99999,
/
- &nam_sfcperts
+&nam_stochy
/
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
+&nam_sfcperts
+/
+
+&cires_ugwp_nml
+ knob_ugwp_solver = 2
+ knob_ugwp_source = 1,1,0,0
+ knob_ugwp_wvspec = 1,25,25,25
+ knob_ugwp_azdir = 2,4,4,4
+ knob_ugwp_stoch = 0,0,0,0
+ knob_ugwp_effac = 1,1,1,1
+ knob_ugwp_doaxyz = 1
+ knob_ugwp_doheat = 1
+ knob_ugwp_dokdis = 1
+ knob_ugwp_ndx4lh = 1
+ knob_ugwp_version = 0
+ launch_level = 25
/
diff --git a/parm/forecast/globnest/input_nest.nml.tmp b/parm/forecast/globnest/input_nest.nml.tmp
new file mode 100644
index 000000000..55c5cda61
--- /dev/null
+++ b/parm/forecast/globnest/input_nest.nml.tmp
@@ -0,0 +1,365 @@
+&atmos_model_nml
+ blocksize = @[blocksize]
+ chksum_debug = .false.
+ dycore_only = .false.
+ avg_max_length = 3600.
+ ccpp_suite = '@[ccpp_suite_nml]'
+/
+
+&diag_manager_nml
+ prepend_date = .false.
+/
+
+&mpp_io_nml
+ header_buffer_val = 16384,
+ global_field_on_root_pe = .true.,
+ io_clocks_on = .false.,
+ shuffle = 0,
+ deflate_level = @[deflate_level],
+ cf_compliance = .false.
+/
+
+&fms_io_nml
+ checksum_required = .false.
+ max_files_r = 1000,
+ max_files_w = 1000,
+/
+
+&fms2_io_nml
+ netcdf_default_format="netcdf4"
+/
+
+&fms_nml
+ clock_grain = 'ROUTINE',
+ domains_stack_size = 30000000,
+ print_memory_usage = .false.
+/
+
+&fv_grid_nml
+ !grid_file = 'INPUT/grid_spec.nc'
+/
+
+&fv_core_nml
+ layout = @[layoutx_nml],@[layouty_nml]
+ io_layout = @[io_layoutx_nml],@[io_layouty_nml]
+ npx = @[npx_nml]
+ npy = @[npy_nml]
+ ntiles = 1
+ npz = @[npz]
+ !grid_type = -1
+ make_nh = .false.
+ fv_debug = .false.
+ range_warn = .true.
+ reset_eta = .false.
+ n_sponge = 24
+ nudge_qv = .false.
+ nudge_dz = .false.
+ tau = 5.
+ rf_cutoff = 50.e2
+ d2_bg_k1 = 0.20
+ d2_bg_k2 = 0.15
+ kord_tm = -11
+ kord_mt = 11
+ kord_wz = 11
+ kord_tr = 11
+ hydrostatic = .false.
+ phys_hydrostatic = .false.
+ use_hydro_pressure = .false.
+ beta = 0.
+ a_imp = 1.
+ p_fac = 0.1
+ k_split = @[k_split_nml]
+ n_split = @[n_split_nml]
+ nwat = 6
+ na_init = @[na_init]
+ d_ext = 0.0
+ dnats = 1
+ fv_sg_adj = 300
+ d2_bg = 0.
+ nord = 2
+ dddmp = 0.1
+ d4_bg = 0.15
+ vtdm4 = 0.04
+ delt_max = 0.008
+ ke_bg = 0.
+ do_vort_damp = .true.
+ external_ic = @[external_ic]
+ external_eta = .true.
+ gfs_phil = .false.
+ nggps_ic = @[nggps_ic]
+ mountain = @[mountain]
+ ncep_ic = .false.
+ d_con = 1.0
+ hord_mt = 6
+ hord_vt = 6
+ hord_tm = 6
+ hord_dp = 6
+ hord_tr = -5
+ adjust_dry_mass = .false.
+ consv_te = 0.
+ do_sat_adj = .true.
+ consv_am = .false.
+ fill = .true.
+ dwind_2d = .false.
+ print_freq = 3
+ warm_start = @[warm_start]
+ no_dycore = .false.
+ z_tracer = .true.
+ agrid_vel_rst = .true.
+ read_increment = .false.
+ res_latlon_dynamics = "fv3_increment.nc"
+ write_3d_diags = .true.
+
+ nested = .true.
+ twowaynest = .true.
+ nestupdate = 7
+
+ full_zs_filter = @[full_zs_filter_nml]
+ n_zs_filter = @[n_zs_filter_nml]
+ nord_zs_filter = 4
+/
+
+&surf_map_nml
+ zero_ocean = .false.
+ cd4 = 0.15
+ cd2 = -1
+ n_del2_strong = 0
+ n_del2_weak = @[n_del2_weak_nml]
+ n_del4 = 2
+ max_slope = @[max_slope_nml]
+ peak_fac = 1.
+/
+
+&external_ic_nml
+ filtered_terrain = .true.
+ levp = @[levp]
+ gfs_dwinds = .true.
+ checker_tr = .false.
+ nt_checker = 0
+/
+
+&gfs_physics_nml
+ fhzero = 3.
+ ldiag3d = .false.
+ lradar = .true.
+ avg_max_length = 3600.
+ h2o_phys = .true.
+ fhcyc = 0.
+ use_ufo = .true.
+ pre_rad = .false.
+ imp_physics = 11
+ pdfcld = .false.
+ fhswr = @[fhswr]
+ fhlwr = @[fhlwr]
+ ialb = 1
+ iems = 1
+ iaer = 111
+ ico2 = 2
+ isubc_sw = 2
+ isubc_lw = 2
+ isol = 2
+ lwhtr = .true.
+ swhtr = .true.
+ cnvgwd = .false.
+ cal_pre = .false.
+ redrag = .true.
+ dspheat = .true.
+ hybedmf = .false.
+ hurr_pbl = .true. ! HWRF moninedmf
+ moninq_fac = -1.0 ! HWRF_moninedmf
+ satmedmf = .true.
+ isatmedmf = 1
+ rlmx = 300.
+ elmx = 300.
+ sfc_rlm = 1
+ random_clds = .false.
+ trans_trac = .true.
+ cnvcld = .true.
+ shal_cnv = @[shal_cnv_nml] !Shallow convection
+ do_deep = @[do_deep_nml]
+ imfshalcnv = 2
+ imfdeepcnv = 2
+ clam_deep = 0.1
+ betal_deep = 0.05
+ betas_deep = 0.05
+ cdmbgwd = 0.88, 0.04
+ sfc_z0_type = 6
+ prslrd0 = 0.
+ ivegsrc = 1
+ isot = 1
+ lsm = 1
+ iopt_dveg = 2
+ iopt_crs = 1
+ iopt_btr = 1
+ iopt_run = 1
+ iopt_sfc = 1
+ iopt_frz = 1
+ iopt_inf = 1
+ iopt_rad = 1
+ iopt_alb = 2
+ iopt_snf = 4
+ iopt_tbot = 2
+ iopt_stc = 1
+ debug = .false.
+ oz_phys = .false.
+ oz_phys_2015 = .true.
+ nst_anl = .true.
+ nstf_name = @[nstf_n1],@[nstf_n2],@[nstf_n3],@[nstf_n4],@[nstf_n5]
+ cplflx = @[cplflx]
+ cplice = .false.
+ cplocn2atm = @[cplocn2atm]
+ cplwav = @[cplwav]
+ cplwav2atm = @[cplwav2atm]
+ cpl_imp_mrg = @[merge_import]
+ psautco = 0.0008, 0.0005
+ prautco = 0.00015, 0.00015
+ iau_delthrs = 6
+ iaufhrs = 30
+ iau_inc_files = ''
+ iau_drymassfixer = .false.
+ lgfdlmprad = .true.
+ effr_in = .true.
+ do_sppt = .false.
+ do_shum = .false.
+ do_skeb = .false.
+ lndp_type = 0
+ n_var_lndp = 0
+ do_ca = .false.
+ ca_sgs = .false.
+ nca = 1
+ ncells = 5
+ nlives = 12
+ nseed = 1
+ nfracseed = 0.5
+ ca_trigger = .false.
+ ca_entr = .false.
+ ca_closure = .false.
+ ca_global = .false.
+ nca_g = 1
+ ncells_g = 1
+ nlives_g = 100
+ nseed_g = 100
+ ca_smooth = .false.
+ nspinup = 1
+ iseed_ca = 1
+ nsmooth = 100
+ ca_amplitude = 0.35
+ print_diff_pgr = .true.
+/
+
+&gfdl_cloud_microphysics_nml
+ sedi_transport = .false.
+ do_sedi_heat = .false.
+ rad_snow = .true.
+ rad_graupel = .true.
+ rad_rain = .true.
+ const_vi = .false.
+ const_vs = .false.
+ const_vg = .false.
+ const_vr = .false.
+ vi_max = 1.
+ vs_max = 2.
+ vg_max = 12.
+ vr_max = 12.
+ qi_lim = 1.
+ prog_ccn = .false.
+ do_qa = .true.
+ fast_sat_adj = .true.
+ tau_l2v = 180.
+ tau_v2l = 90.
+ tau_g2v = 900.
+ rthresh = 10.e-6 ! This is a key parameter for cloud water
+ dw_land = 0.16
+ dw_ocean = 0.10
+ ql_gen = 1.0e-3
+ ql_mlt = 1.0e-3
+ qi0_crt = 8.0E-5
+ qs0_crt = 1.0e-3
+ tau_i2s = 1000.
+ c_psaci = 0.05
+ c_pgacs = 0.01
+ rh_inc = 0.30
+ rh_inr = 0.30
+ rh_ins = 0.30
+ ccn_l = 300.
+ ccn_o = 100.
+ c_paut = 0.5
+ c_cracw = 0.8
+ use_ppm = .false.
+ use_ccn = .true.
+ mono_prof = .true.
+ z_slope_liq = .true.
+ z_slope_ice = .true.
+ de_ice = .false.
+ fix_negative = .true.
+ icloud_f = 1
+ mp_time = 90.
+/
+
+&interpolator_nml
+ interp_method = 'conserve_great_circle'
+/
+
+&namsfc
+ FNGLAC = "global_glacier.2x2.grb",
+ FNMXIC = "global_maxice.2x2.grb",
+ FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
+ FNSNOC = "global_snoclim.1.875.grb",
+ FNZORC = "igbp"
+ !FNZORC = "global_zorclim.1x1.grb",
+ FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
+ FNALBC2 = "global_albedo4.1x1.grb",
+ FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
+ FNTG3C = "global_tg3clim.2.6x1.5.grb",
+ FNVEGC = "global_vegfrac.0.144.decpercent.grb",
+ FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
+ FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
+ FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
+ FNMSKH = "seaice_newland.grb",
+ FNTSFA = "",
+ FNACNA = "",
+ FNSNOA = "",
+ FNVMNC = "global_shdmin.0.144x0.144.grb",
+ FNVMXC = "global_shdmax.0.144x0.144.grb",
+ FNSLPC = "global_slope.1x1.grb",
+ FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
+ LDEBUG = .true.,
+ FSMCL(2) = 99999
+ FSMCL(3) = 99999
+ FSMCL(4) = 99999
+ FTSFS = 90
+ FAISS = 99999
+ FSNOL = 99999
+ FSICL = 99999
+ FTSFL = 99999
+ FAISL = 99999
+ FVETL = 99999,
+ FSOTL = 99999,
+ FvmnL = 99999,
+ FvmxL = 99999,
+ FSLPL = 99999,
+ FABSL = 99999,
+ FSNOS = 99999,
+ FSICS = 99999,
+/
+
+&nam_stochy
+/
+
+&nam_sfcperts
+/
+
+&cires_ugwp_nml
+ knob_ugwp_solver = 2
+ knob_ugwp_source = 1,1,0,0
+ knob_ugwp_wvspec = 1,25,25,25
+ knob_ugwp_azdir = 2,4,4,4
+ knob_ugwp_stoch = 0,0,0,0
+ knob_ugwp_effac = 1,1,1,1
+ knob_ugwp_doaxyz = 1
+ knob_ugwp_doheat = 1
+ knob_ugwp_dokdis = 1
+ knob_ugwp_ndx4lh = 1
+ knob_ugwp_version = 0
+ launch_level = 25
+/
diff --git a/parm/forecast/globnest/input_nest02.nml.tmp b/parm/forecast/globnest/input_nest02.nml.tmp
deleted file mode 100644
index abdd9fa9d..000000000
--- a/parm/forecast/globnest/input_nest02.nml.tmp
+++ /dev/null
@@ -1,364 +0,0 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
-/
-
- &diag_manager_nml
- prepend_date = .false.
-/
-
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
-/
-
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
-/
-
- &fms2_io_nml
-netcdf_default_format="netcdf4"
-/
-
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
-/
-
- &fv_grid_nml
- !grid_file = 'INPUT/grid_spec.nc'
-/
-
- &fv_core_nml
- !layout = 64,30
- !layout = 40,30
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 1
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 50.e2
- d2_bg_k1 = 0.20
- d2_bg_k2 = 0.15
- kord_tm = -11
- kord_mt = 11
- kord_wz = 11
- kord_tr = 11
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 6
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.008
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 6
- hord_vt = 6
- hord_tm = 6
- hord_dp = -6
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 0.
- do_sat_adj = .T.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
-
- nested = .true.
- twowaynest = .true.
- nestupdate = 7
-
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 1
- nord_zs_filter = 4
-/
-
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
-/
-
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
-/
-
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 11
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .false.
- shal_cnv = .true. !Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .false.
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF_moninedmf
- satmedmf = .true.
- isatmedmf = 1
- rlmx = 300.
- elmx = 300.
- sfc_rlm = 1
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 0.88, 0.04
- sfc_z0_type = 6
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 1
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
-/
-
- &gfdl_cloud_microphysics_nml
- sedi_transport = .false.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
-/
-
- &interpolator_nml
- interp_method = 'conserve_great_circle'
-/
-
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
-/
-
- &nam_stochy
-/
-
- &nam_sfcperts
-/
-
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
-/
diff --git a/parm/forecast/globnest/model_configure.tmp b/parm/forecast/globnest/model_configure.tmp
index 52eb1c465..c7d73587a 100644
--- a/parm/forecast/globnest/model_configure.tmp
+++ b/parm/forecast/globnest/model_configure.tmp
@@ -1,45 +1,151 @@
-print_esmf: _print_esmf_
-start_year: YR
-start_month: MN
-start_day: DY
-start_hour: H_R
+start_year: @[SYEAR]
+start_month: @[SMONTH]
+start_day: @[SDAY]
+start_hour: @[SHOUR]
start_minute: 0
start_second: 0
-nhours_fcst: NHRS
-dt_atmos: _dt_atmos_
+nhours_fcst: @[FHMAX]
+dt_atmos: @[DT_ATMOS]
calendar: 'julian'
-restart_interval: _restart_interval_
+restart_interval: @[RESTART_INTERVAL]
output_1st_tstep_rst: .false.
-quilting: _quilting_
-write_groups: _write_groups_
-write_tasks_per_group: _write_tasks_per_group_
-write_dopost: _write_dopost_
-output_history: _output_history_
-num_files: 2
-filename_base: 'atm' 'sfc'
-output_file: 'netcdf_parallel' 'netcdf_parallel'
+quilting: @[QUILTING]
+write_groups: @[WRITE_GROUP]
+write_tasks_per_group: @[WRTTASK_PER_GROUP]
+num_files: @[NUM_FILES]
+filename_base: @[FILENAME_BASE]
+output_file: @[OUTPUT_FILE]
+write_dopost: @[WRITE_DOPOST]
+output_history: @[OUTPUT_HISTORY]
ichunk2d: -1
jchunk2d: -1
ichunk3d: -1
jchunk3d: -1
kchunk3d: -1
-ideflate: 1
-nbits: 0
+ideflate: @[IDEFLATE]
+nbits: @[NBITS]
-app_domain: '_app_domain_'
-output_grid: '_OUTPUT_GRID_'
-cen_lon: _CEN_LON_ # central longitude
-cen_lat: _CEN_LAT_ # central latitude
-lon1: _LON1_ # longitude of lower-left
-lat1: _LAT1_ # latitude of lower-left
-lon2: _LON2_ # longitude of upper-right
-lat2: _LAT2_ # latitude of upper-right
-dlon: _DLON_
-dlat: _DLAT_
+output_grid: @[OUTPUT_GRID] # gaussian_grid, global_latlon, regional_latlon, rotated_latlon, lambert_conformal, cubed_sphere_grid
+imo: @[IMO] # number of grid points along longitude/latitude direction
+jmo: @[JMO] # needed for gaussian_grid or global_latlon
+cen_lon: @[CEN_LON] # central longitude/latitude (degrees)
+cen_lat: @[CEN_LAT] # needed for rotated_latlon, lambert_conformal
+lon1: @[LON1] # longitude/latitude of lower-left corner
+lat1: @[LAT1] # needed for regional_latlon, rotated_latlon, lambert_conformal
+lon2: @[LON2] # longitude/latitude of upper-right corner
+lat2: @[LAT2] # needed for regional_latlon, rotated_latlon
+dlon: @[DLON] # grid spacing in longitude/latitude direction (degrees)
+dlat: @[DLAT] # needed for regional_latlon, rotated_latlon
+stdlat1: @[STDLAT1] # latitude of first/second standard parallel (degrees)
+stdlat2: @[STDLAT2] # needed for lambert_conformal
+nx: @[NX] # number of grid cells along x/y-axis
+ny: @[NY] # needed for lambert_conformal
+dx: @[DX] # grid cell size in x/y direction (meters)
+dy: @[DY] # needed for lambert_conformal
-nfhout: 3
-nfhmax_hf: -1
-nfhout_hf: 3
-nsout: -1
-output_fh: -1
+
+output_grid: @[OUTPUT_GRID_2]
+imo: @[IMO_2]
+jmo: @[JMO_2]
+cen_lon: @[CEN_LON_2]
+cen_lat: @[CEN_LAT_2]
+lon1: @[LON1_2]
+lat1: @[LAT1_2]
+lon2: @[LON2_2]
+lat2: @[LAT2_2]
+dlon: @[DLON_2]
+dlat: @[DLAT_2]
+stdlat1: @[STDLAT1_2]
+stdlat2: @[STDLAT2_2]
+nx: @[NX_2]
+ny: @[NY_2]
+dx: @[DX_2]
+dy: @[DY_2]
+
+
+output_grid: @[OUTPUT_GRID_3]
+imo: @[IMO_3]
+jmo: @[JMO_3]
+cen_lon: @[CEN_LON_3]
+cen_lat: @[CEN_LAT_3]
+lon1: @[LON1_3]
+lat1: @[LAT1_3]
+lon2: @[LON2_3]
+lat2: @[LAT2_3]
+dlon: @[DLON_3]
+dlat: @[DLAT_3]
+stdlat1: @[STDLAT1_3]
+stdlat2: @[STDLAT2_3]
+nx: @[NX_3]
+ny: @[NY_3]
+dx: @[DX_3]
+dy: @[DY_3]
+
+
+output_grid: @[OUTPUT_GRID_4]
+imo: @[IMO_4]
+jmo: @[JMO_4]
+cen_lon: @[CEN_LON_4]
+cen_lat: @[CEN_LAT_4]
+lon1: @[LON1_4]
+lat1: @[LAT1_4]
+lon2: @[LON2_4]
+lat2: @[LAT2_4]
+dlon: @[DLON_4]
+dlat: @[DLAT_4]
+stdlat1: @[STDLAT1_4]
+stdlat2: @[STDLAT2_4]
+nx: @[NX_4]
+ny: @[NY_4]
+dx: @[DX_4]
+dy: @[DY_4]
+
+
+output_grid: @[OUTPUT_GRID_5]
+imo: @[IMO_5]
+jmo: @[JMO_5]
+cen_lon: @[CEN_LON_5]
+cen_lat: @[CEN_LAT_5]
+lon1: @[LON1_5]
+lat1: @[LAT1_5]
+lon2: @[LON2_5]
+lat2: @[LAT2_5]
+dlon: @[DLON_5]
+dlat: @[DLAT_5]
+stdlat1: @[STDLAT1_5]
+stdlat2: @[STDLAT2_5]
+nx: @[NX_5]
+ny: @[NY_5]
+dx: @[DX_5]
+dy: @[DY_5]
+
+
+output_grid: @[OUTPUT_GRID_6]
+imo: @[IMO_6]
+jmo: @[JMO_6]
+cen_lon: @[CEN_LON_6]
+cen_lat: @[CEN_LAT_6]
+lon1: @[LON1_6]
+lat1: @[LAT1_6]
+lon2: @[LON2_6]
+lat2: @[LAT2_6]
+dlon: @[DLON_6]
+dlat: @[DLAT_6]
+stdlat1: @[STDLAT1_6]
+stdlat2: @[STDLAT2_6]
+nx: @[NX_6]
+ny: @[NY_6]
+dx: @[DX_6]
+dy: @[DY_6]
+
+
+nfhout: @[NFHOUT] # Output frequency in hours after forecast hour nfhmax_hf
+nfhmax_hf: @[NFHMAX_HF] # Number of forecast hours until output frequency nfhout takes affect
+nfhout_hf: @[NFHOUT_HF] # Output frequency in hours until forecast hour nfhmax_hf
+nsout: @[NSOUT] # Output frequency in time steps (positive values override nfhout and nfhout_hf)
+output_fh: @[OUTPUT_FH] # Output forecast hours controlled by output_fh (see notes below)
+# a) An array of output_fh means to output history files at those forecast time (e.g., "output_fh: 0 1 2 3 12 24 48")
+# If the first elelment is zero, it means the first time step output
+# b) If there are two elements in output_fh and the second one is -1, then the first element is output frequency. e.g.
+# For example, "output_fh: 6 -1" will output the history file every 6 hours.
diff --git a/parm/forecast/globnest/nems.configure.atmonly b/parm/forecast/globnest/nems.configure.atmonly
index fe59cc645..4b46da1f1 100644
--- a/parm/forecast/globnest/nems.configure.atmonly
+++ b/parm/forecast/globnest/nems.configure.atmonly
@@ -1,3 +1,5 @@
+logKindFlag: ESMF_LOGKIND_MULTI
+
EARTH_component_list: ATM
ATM_model: fv3
diff --git a/parm/forecast/globnest_hwrf/diag_table.tmp b/parm/forecast/globnest_hwrf/diag_table.tmp
deleted file mode 100644
index 874cd0285..000000000
--- a/parm/forecast/globnest_hwrf/diag_table.tmp
+++ /dev/null
@@ -1,354 +0,0 @@
-#output files
-"grid_spec", -1, "months", 1, "days", "time"
-#"atmos_4xdaily", 1, "hours", 1, "days", "time"
-"atmos_static", -1, "hours", 1, "hours", "time"
-"fv3_history", 0, "hours", 1, "hours", "time"
-"fv3_history2d", 0, "hours", 1, "hours", "time"
-#"ref3D", 0, "hours", 1, "hours", "time"
-#"maxmin2D", 1, "hours", 1, "hours", "time"
-
-#
-#=======================
-# ATMOSPHERE DIAGNOSTICS
-#=======================
-###
-# grid_spec
-###
- "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lont", "grid_lont", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_latt", "grid_latt", "grid_spec", "all", .false., "none", 2,
- "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
-###
-# 4x daily output
-###
-# "dynamics", "slp", "slp", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort850", "vort850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort500", "vort500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort200", "vort200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "us", "us", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u1000", "u1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u850", "u850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u700", "u700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u500", "u500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u200", "u200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u100", "u100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u50", "u50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u10", "u10", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vs", "vs", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v1000", "v1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v850", "v850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v700", "v700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v500", "v500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v200", "v200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v100", "v100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v50", "v50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v10", "v10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "tm", "tm", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t1000", "t1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t850", "t850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t700", "t700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t500", "t500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t200", "t200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t100", "t100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t50", "t50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t10", "t10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "z1000", "z1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z850", "z850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z700", "z700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z500", "z500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z200", "z200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z100", "z100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z50", "z50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z10", "z10", "atmos_4xdaily", "all", .false., "none", 2
-####
-#"dynamics", "w1000", "w1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w850", "w850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w700", "w700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w500", "w500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w200", "w200", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "q1000", "q1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q850", "q850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q700", "q700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q500", "q500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q200", "q200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q100", "q100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q50", "q50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q10", "q10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "rh1000", "rh1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh850", "rh850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh700", "rh700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh500", "rh500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh200", "rh200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg1000", "omg1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg850", "omg850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg700", "omg700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg500", "omg500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg200", "omg200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg100", "omg100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg50", "omg50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg10", "omg10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "cape", "sbcape", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "cin", "sbcin", "atmos_4xdaily", "all", .false., "none", 2
-###
-# gfs static data
-###
- "dynamics", "pk", "pk", "atmos_static", "all", .false., "none", 2
- "dynamics", "bk", "bk", "atmos_static", "all", .false., "none", 2
- "dynamics", "hyam", "hyam", "atmos_static", "all", .false., "none", 2
- "dynamics", "hybm", "hybm", "atmos_static", "all", .false., "none", 2
- "dynamics", "zsurf", "zsurf", "atmos_static", "all", .false., "none", 2
-###
-# FV3 variabls needed for NGGPS evaluation
-###
-"gfs_dyn", "ucomp", "ugrd", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "vcomp", "vgrd", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "sphum", "spfh", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "temp", "tmp", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "liq_wat", "clwmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "o3mr", "o3mr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "delp", "dpres", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "delz", "delz", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "w", "dzdt", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ice_wat", "icmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "rainwat", "rwmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "snowwat", "snmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "graupel", "grle", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "q_rimef", "qrim", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ps", "pressfc", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "hs", "hgtsfc", "fv3_history", "all", .false., "none", 2
-#"gfs_dyn", "ice_nc", "nicp", "fv3_history", "all", .false., "none", 2
-#"gfs_dyn", "rain_nc", "ntrnc", "fv3_history", "all", .false., "none", 2
-
-###
-# Max hourly fields
-###
-"gfs_dyn", "wmaxup", "upvvelmax", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "wmaxdn", "dnvvelmax", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmax03", "uhmax03", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmax25", "uhmax25", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmin03", "uhmin03", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmin25", "uhmin25", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvort01", "maxvort01", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvort02", "maxvort02", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvorthy1", "maxvorthy1", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ustm", "ustm", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "vstm", "vstm", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "srh01", "srh01", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "srh03", "srh03", "fv3_history", "all", .false., "none", 2
-
-"gfs_phys", "u10max", "u10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v10max", "v10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spd10max", "spd10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "refdmax", "refdmax", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "refdmax263k", "refdmax263k", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "t02max", "t02max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "t02min", "t02min", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "rh02max", "rh02max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "rh02min", "rh02min", "fv3_history2d", "all", .false., "none", 2
-
-
-"gfs_phys", "ALBDO_ave", "albdo_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cnvprcp_ave", "cprat_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cnvprcpb_ave", "cpratb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "totprcp_ave", "prate_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "totprcpb_ave", "prateb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DLWRF", "dlwrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DLWRFI", "dlwrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRF", "ulwrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRFI", "ulwrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRF", "dswrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRFI", "dswrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRF", "uswrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRFI", "uswrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRFtoa", "dswrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRFtoa", "uswrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRFtoa", "ulwrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "gflux_ave", "gflux_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "hpbl", "hpbl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "lhtfl_ave", "lhtfl_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "shtfl_ave", "shtfl_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pwat", "pwatclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "soilm", "soilm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_aveclm", "tcdc_aveclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avebndcl", "tcdc_avebndcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avehcl", "tcdc_avehcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avelcl", "tcdc_avelcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avemcl", "tcdc_avemcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDCcnvcl", "tcdccnvcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PREScnvclt", "prescnvclt", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PREScnvclb", "prescnvclb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avehct", "pres_avehct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avehcb", "pres_avehcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avehct", "tmp_avehct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avemct", "pres_avemct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avemcb", "pres_avemcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avemct", "tmp_avemct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avelct", "pres_avelct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avelcb", "pres_avelcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avelct", "tmp_avelct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "u-gwd_ave", "u-gwd_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v-gwd_ave", "v-gwd_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "dusfc", "uflx_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "dvsfc", "vflx_ave", "fv3_history2d", "all", .false., "none", 2
-
-"gfs_phys", "psurf", "pressfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "u10m", "ugrd10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v10m", "vgrd10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "crain", "crain", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_ice", "f_ice", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_rain", "f_rain", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_rimef", "f_rimef", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tprcp", "tprcp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "hgtsfc", "orog", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "weasd", "weasd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "f10m", "f10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "q2m", "spfh2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "t2m", "tmp2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tsfc", "tmpsfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "vtype", "vtype", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "stype", "sotyp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slmsksfc", "land", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "vfracsfc", "veg", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "zorlsfc", "sfcr", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "uustar", "fricv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt1", "soilt1" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt2", "soilt2" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt3", "soilt3" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt4", "soilt4" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw1", "soilw1" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw2", "soilw2" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw3", "soilw3" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw4", "soilw4" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_1", "soill1", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_2", "soill2", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_3", "soill3", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_4", "soill4", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slope", "sltyp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alnsf", "alnsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alnwf", "alnwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alvsf", "alvsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alvwf", "alvwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "canopy", "cnwat", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "facsf", "facsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "facwf", "facwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "ffhh", "ffhh", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "ffmm", "ffmm", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "fice", "icec", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "hice", "icetk", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "snoalb", "snoalb", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "shdmax", "shdmax", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "shdmin", "shdmin", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "snowd", "snod", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tg3", "tg3", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tisfc", "tisfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tref", "tref", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "z_c", "zc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "c_0", "c0", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "c_d", "cd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "w_0", "w0", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "w_d", "wd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xt", "xt", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xz", "xz", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "dt_cool", "dtcool", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xs", "xs", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xu", "xu", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xv", "xv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xtts", "xtts", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xzts", "xzts", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "d_conv", "dconv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "qrain", "qrain", "fv3_history2d", "all", .false., "none", 2
-
-"gfs_phys", "acond", "acond", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cduvb_ave", "cduvb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cpofp", "cpofp", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "duvb_ave", "duvb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csdlf_ave", "csdlf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csusf_ave", "csusf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csusf_avetoa", "csusftoa", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csdsf_ave", "csdsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csulf_ave", "csulf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csulf_avetoa", "csulftoa", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cwork_ave", "cwork_aveclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "evbs_ave", "evbs_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "evcw_ave", "evcw_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "fldcp", "fldcp", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "hgt_hyblev1", "hgt_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfh_hyblev1", "spfh_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ugrd_hyblev1", "ugrd_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vgrd_hyblev1", "vgrd_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmp_hyblev1", "tmp_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "gfluxi", "gflux", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "lhtfl", "lhtfl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "shtfl", "shtfl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pevpr", "pevpr", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pevpr_ave", "pevpr_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sbsno_ave", "sbsno_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sfexc", "sfexc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "snohf", "snohf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "snowc_ave", "snowc_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfhmax2m", "spfhmax_max2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfhmin2m", "spfhmin_min2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmpmax2m", "tmax_max2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmpmin2m", "tmin_min2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ssrun_acc", "ssrun_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sunsd_acc", "sunsd_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "watr_acc", "watr_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "wilt", "wilt", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vbdsf_ave", "vbdsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vddsf_ave", "vddsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "nbdsf_ave", "nbdsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "nddsf_ave", "nddsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "trans_ave", "trans_ave", "fv3_history2d", "all", .false., "none", 2
-#HWRF
-#"gfs_phys", "cleffr", "cleffr", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "cieffr", "cieffr", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "cseffr", "cseffr", "fv3_history2d", "all", .false., "none", 2
-#
-# Reflectivity from microphysics
-"gfs_phys", "refl_10cm", "refl_10cm", "fv3_history2d", "all", .false., "none", 2
-
-#Max/Min must be kept in separate files. Time is controlled by diag_table
-# "dynamics", "uh25", "MXUPHL2_5km", "maxmin2D", "all", max, "none", 2
-# "dynamics", "uh25", "MNUPHL2_5km", "maxmin2D", "all", min, "none", 2
-# "dynamics", "max_reflectivity", "MAXREFC", "maxmin2D", "all", max, "none", 2
-# "dynamics", "base_reflectivity", "MAXREF_1km", "maxmin2D", "all", max, "none", 2
-#
-#=============================================================================================
-#
-#====> This file can be used with diag_manager/v2.0a (or higher) <====
-#
-#
-# FORMATS FOR FILE ENTRIES (not all input values are used)
-# ------------------------
-#
-#"file_name", output_freq, "output_units", format, "time_units", "long_name",
-#
-#
-#output_freq: > 0 output frequency in "output_units"
-# = 0 output frequency every time step
-# =-1 output frequency at end of run
-#
-#output_units = units used for output frequency
-# (years, months, days, minutes, hours, seconds)
-#
-#time_units = units used to label the time axis
-# (days, minutes, hours, seconds)
-#
-#
-# FORMAT FOR FIELD ENTRIES (not all input values are used)
-# ------------------------
-#
-#"module_name", "field_name", "output_name", "file_name" "time_sampling", time_avg, "other_opts", packing
-#
-#time_avg = .true. or .false.
-#
-#packing = 1 double precision
-# = 2 float
-# = 4 packed 16-bit integers
-# = 8 packed 1-byte (not tested?)
diff --git a/parm/forecast/globnest_hwrf/field_table b/parm/forecast/globnest_hwrf/field_table
deleted file mode 100644
index 420f4a48a..000000000
--- a/parm/forecast/globnest_hwrf/field_table
+++ /dev/null
@@ -1,36 +0,0 @@
-# added by FRE: sphum must be present in atmos
-# specific humidity for moist runs
- "TRACER", "atmos_mod", "sphum"
- "longname", "specific humidity"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic cloud water mixing ratio
- "TRACER", "atmos_mod", "liq_wat"
- "longname", "cloud water mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
- "TRACER", "atmos_mod", "ice_wat"
- "longname", "cloud ice mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic rain water mixing ratio
- "TRACER", "atmos_mod", "rainwat"
- "longname", "rain mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic mass weighted rime factor
- "TRACER", "atmos_mod", "q_rimef"
- "longname", "mass weighted rime factor"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic ozone mixing ratio tracer
- "TRACER", "atmos_mod", "o3mr"
- "longname", "ozone mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# non-prognostic cloud amount
- "TRACER", "atmos_mod", "cld_amt"
- "longname", "cloud amount"
- "units", "1"
- "profile_type", "fixed", "surface_value=1.e30" /
-
diff --git a/parm/forecast/globnest_hwrf/input.nml.tmp b/parm/forecast/globnest_hwrf/input.nml.tmp
deleted file mode 100644
index 146b58c03..000000000
--- a/parm/forecast/globnest_hwrf/input.nml.tmp
+++ /dev/null
@@ -1,379 +0,0 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
-/
-
- &diag_manager_nml
- prepend_date = .false.
-/
-
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
-/
-
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
-/
-
- &fms2_io_nml
-netcdf_default_format="netcdf4"
-/
-
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
-/
-
- &fv_grid_nml
- !grid_file = 'INPUT/grid_spec.nc'
-/
-
- &fv_core_nml
- !layout = 12,12
- !layout = 8,8
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 6
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 30.e2
- d2_bg_k1 = 0.16
- d2_bg_k2 = 0.05
- kord_tm = -9
- kord_mt = 9
- kord_wz = 9
- kord_tr = 9
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 4
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.002
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 5
- hord_vt = 5
- hord_tm = 5
- hord_dp = -5
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 1.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
-
- do_schmidt = .true.
- target_lat = _target_lat_
- target_lon = _target_lon_
- stretch_fac = _stretch_fac_
-
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 0
- nord_zs_filter = 4
-/
-
- &fv_nest_nml
- grid_pes = _glob_pes_, _nest_pes_
- tile_coarse = 0, 6
- num_tile_top = 6
- p_split = 1
- nest_refine = 0, _refinement_
- nest_ioffsets= 1, _ioffset_
- nest_joffsets= 1, _joffset_
-/
-
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
-/
-
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
-/
-
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 15 ! F-A MP scheme
- RHGRD = 0.975 ! F-A
- spec_adv = .true. ! F-A
- icloud = 3 ! Thompson cloud fraction
- iovr_lw = 4 ! HWRF RRTMG
- iovr_sw = 4 ! HWRF RRTMG
- hwrf_samfdeep = .true. ! HWRF SASdeep
- hwrf_samfshal = .true. ! HWRF SASshal
- asolfac_deep = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- asolfac_shal = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF moninedmf
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .true.
- shal_cnv = .true. ! HWRF SAS Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .true.
- satmedmf = .false.
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 3.5, 0.25 ! NCEP default
- sfc_z0_type = 4 !HWRF
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 4 !HWRF
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
-/
-
- &gfdl_cloud_microphysics_nml
- sedi_transport = .true.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
-/
-
- &interpolator_nml
- interp_method = 'conserve_great_circle'
-/
-
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
-/
-
- &nam_stochy
-/
-
- &nam_sfcperts
-/
-
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
-/
diff --git a/parm/forecast/globnest_hwrf/input_nest02.nml.tmp b/parm/forecast/globnest_hwrf/input_nest02.nml.tmp
deleted file mode 100644
index 0650f9396..000000000
--- a/parm/forecast/globnest_hwrf/input_nest02.nml.tmp
+++ /dev/null
@@ -1,369 +0,0 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
-/
-
- &diag_manager_nml
- prepend_date = .false.
-/
-
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
-/
-
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
-/
-
- &fms2_io_nml
-netcdf_default_format="netcdf4"
-/
-
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
-/
-
- &fv_grid_nml
- !grid_file = 'INPUT/grid_spec.nc'
-/
-
- &fv_core_nml
- !layout = 64,30
- !layout = 40,30
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 1
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 50.e2
- d2_bg_k1 = 0.20
- d2_bg_k2 = 0.15
- kord_tm = -11
- kord_mt = 11
- kord_wz = 11
- kord_tr = 11
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 4
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.008
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 6
- hord_vt = 6
- hord_tm = 6
- hord_dp = -6
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 0.
- do_sat_adj = .F.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
-
- nested = .true.
- twowaynest = .true.
- nestupdate = 7
-
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 1
- nord_zs_filter = 4
-/
-
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
-/
-
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
-/
-
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 15 ! F-A MP scheme
- RHGRD = 1.0 ! F-A
- spec_adv = .true. ! F-A
- icloud = 3 ! Thompson cloud fraction
- iovr_lw = 4 ! HWRF RRTMG
- iovr_sw = 4 ! HWRF RRTMG
- hwrf_samfdeep = .true. ! HWRF SASdeep
- hwrf_samfshal = .true. ! HWRF SASshal
- asolfac_deep = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- asolfac_shal = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF moninedmf
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .true.
- shal_cnv = .true. ! HWRF SAS Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .true.
- satmedmf = .false.
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 0.88, 0.04
- sfc_z0_type = 4 !HWRF
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 4 !HWRF
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
-/
-
- &gfdl_cloud_microphysics_nml
- sedi_transport = .false.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
-/
-
- &interpolator_nml
- interp_method = 'conserve_great_circle'
-/
-
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
-/
-
- &nam_stochy
-/
-
- &nam_sfcperts
-/
-
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
-/
diff --git a/parm/forecast/globnest_hwrf/model_configure.tmp b/parm/forecast/globnest_hwrf/model_configure.tmp
deleted file mode 100644
index 52eb1c465..000000000
--- a/parm/forecast/globnest_hwrf/model_configure.tmp
+++ /dev/null
@@ -1,45 +0,0 @@
-print_esmf: _print_esmf_
-start_year: YR
-start_month: MN
-start_day: DY
-start_hour: H_R
-start_minute: 0
-start_second: 0
-nhours_fcst: NHRS
-dt_atmos: _dt_atmos_
-calendar: 'julian'
-restart_interval: _restart_interval_
-output_1st_tstep_rst: .false.
-
-quilting: _quilting_
-write_groups: _write_groups_
-write_tasks_per_group: _write_tasks_per_group_
-write_dopost: _write_dopost_
-output_history: _output_history_
-num_files: 2
-filename_base: 'atm' 'sfc'
-output_file: 'netcdf_parallel' 'netcdf_parallel'
-ichunk2d: -1
-jchunk2d: -1
-ichunk3d: -1
-jchunk3d: -1
-kchunk3d: -1
-ideflate: 1
-nbits: 0
-
-app_domain: '_app_domain_'
-output_grid: '_OUTPUT_GRID_'
-cen_lon: _CEN_LON_ # central longitude
-cen_lat: _CEN_LAT_ # central latitude
-lon1: _LON1_ # longitude of lower-left
-lat1: _LAT1_ # latitude of lower-left
-lon2: _LON2_ # longitude of upper-right
-lat2: _LAT2_ # latitude of upper-right
-dlon: _DLON_
-dlat: _DLAT_
-
-nfhout: 3
-nfhmax_hf: -1
-nfhout_hf: 3
-nsout: -1
-output_fh: -1
diff --git a/parm/forecast/globnest_hwrf/nems.configure.atmonly b/parm/forecast/globnest_hwrf/nems.configure.atmonly
deleted file mode 100644
index fe59cc645..000000000
--- a/parm/forecast/globnest_hwrf/nems.configure.atmonly
+++ /dev/null
@@ -1,18 +0,0 @@
-EARTH_component_list: ATM
-
-ATM_model: fv3
-
-runSeq::
- ATM
-::
-
-ATM_attributes::
-::
-
-DRIVER_attributes::
- start_type = startup
-::
-
-ALLCOMP_attributes::
- mediator_read_restart = false
-::
diff --git a/parm/forecast/hwrf_physics_fix/DETAMPNEW_DATA.expanded_rain_LE b/parm/forecast/hwrf_physics_fix/DETAMPNEW_DATA.expanded_rain_LE
deleted file mode 100644
index d01c8f54e..000000000
Binary files a/parm/forecast/hwrf_physics_fix/DETAMPNEW_DATA.expanded_rain_LE and /dev/null differ
diff --git a/parm/forecast/hwrf_physics_fix/GENPARM.TBL b/parm/forecast/hwrf_physics_fix/GENPARM.TBL
deleted file mode 100644
index 17fc9172b..000000000
--- a/parm/forecast/hwrf_physics_fix/GENPARM.TBL
+++ /dev/null
@@ -1,36 +0,0 @@
-General Parameters
-SLOPE_DATA
-9
-0.1
-0.6
-1.0
-0.35
-0.55
-0.8
-0.63
-0.0
-0.0
-SBETA_DATA
--2.0
-FXEXP_DATA
-2.0
-CSOIL_DATA
-2.00E+6
-SALP_DATA
-2.6
-REFDK_DATA
-2.0E-6
-REFKDT_DATA
-3.0
-FRZK_DATA
-0.15
-ZBOT_DATA
--8.0
-CZIL_DATA
-0.1
-SMLOW_DATA
-0.5
-SMHIGH_DATA
-3.0
-LVCOEF_DATA
-0.5
diff --git a/parm/forecast/hwrf_physics_fix/SOILPARM.TBL b/parm/forecast/hwrf_physics_fix/SOILPARM.TBL
deleted file mode 100644
index 518ba6f8b..000000000
--- a/parm/forecast/hwrf_physics_fix/SOILPARM.TBL
+++ /dev/null
@@ -1,45 +0,0 @@
-Soil Parameters
-STAS
-19,1 'BB DRYSMC F11 MAXSMC REFSMC SATPSI SATDK SATDW WLTSMC QTZ '
-1, 2.79, 0.010, -0.472, 0.339, 0.192, 0.069, 4.66E-5, 2.65E-5, 0.010, 0.92, 'SAND'
-2, 4.26, 0.028, -1.044, 0.421, 0.283, 0.036, 1.41E-5, 5.14E-6, 0.028, 0.82, 'LOAMY SAND'
-3, 4.74, 0.047, -0.569, 0.434, 0.312, 0.141, 5.23E-6, 8.05E-6, 0.047, 0.60, 'SANDY LOAM'
-4, 5.33, 0.084, 0.162, 0.476, 0.360, 0.759, 2.81E-6, 2.39E-5, 0.084, 0.25, 'SILT LOAM'
-5, 3.86, 0.061, 0.162, 0.484, 0.347, 0.955, 2.18E-6, 1.66E-5, 0.061, 0.10, 'SILT'
-6, 5.25, 0.066, -0.327, 0.439, 0.329, 0.355, 3.38E-6, 1.43E-5, 0.066, 0.40, 'LOAM'
-7, 6.77, 0.069, -1.491, 0.404, 0.315, 0.135, 4.45E-6, 1.01E-5, 0.069, 0.60, 'SANDY CLAY LOAM'
-8, 8.72, 0.120, -1.118, 0.464, 0.387, 0.617, 2.03E-6, 2.35E-5, 0.120, 0.10, 'SILTY CLAY LOAM'
-9, 8.17, 0.103, -1.297, 0.465, 0.382, 0.263, 2.45E-6, 1.13E-5, 0.103, 0.35, 'CLAY LOAM'
-10, 10.73, 0.100, -3.209, 0.406, 0.338, 0.098, 7.22E-6, 1.87E-5, 0.100, 0.52, 'SANDY CLAY'
-11, 10.39, 0.126, -1.916, 0.468, 0.404, 0.324, 1.34E-6, 9.64E-6, 0.126, 0.10, 'SILTY CLAY'
-12, 11.55, 0.138, -2.138, 0.468, 0.412, 0.468, 9.74E-7, 1.12E-5, 0.138, 0.25, 'CLAY'
-13, 5.25, 0.066, -0.327, 0.439, 0.329, 0.355, 3.38E-6, 1.43E-5, 0.066, 0.05, 'ORGANIC MATERIAL'
-14, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.60, 'WATER'
-15, 2.79, 0.006, -1.111, 0.20, 0.17, 0.069, 1.41E-4, 1.36E-4, 0.006, 0.07, 'BEDROCK'
-16, 4.26, 0.028, -1.044, 0.421, 0.283, 0.036, 1.41E-5, 5.14E-6, 0.028, 0.25, 'OTHER(land-ice)'
-17, 11.55, 0.030, -10.472, 0.468, 0.454, 0.468, 9.74E-7, 1.12E-5, 0.030, 0.60, 'PLAYA'
-18, 2.79, 0.006, -0.472, 0.200, 0.17, 0.069, 1.41E-4, 1.36E-4, 0.006, 0.52, 'LAVA'
-19, 2.79, 0.01, -0.472, 0.339, 0.192, 0.069, 4.66E-5, 2.65E-5, 0.01, 0.92, 'WHITE SAND'
-Soil Parameters
-STAS-RUC
-19,1 'BB DRYSMC HC MAXSMC REFSMC SATPSI SATDK SATDW WLTSMC QTZ '
-1, 4.05, 0.002, 1.47, 0.395, 0.174, 0.121, 1.76E-4, 0.608E-6, 0.033, 0.92, 'SAND'
-2, 4.38, 0.035, 1.41, 0.410, 0.179, 0.090, 1.56E-4, 0.514E-5, 0.055, 0.82, 'LOAMY SAND'
-3, 4.90, 0.041, 1.34, 0.435, 0.249, 0.218, 3.47E-5, 0.805E-5, 0.095, 0.60, 'SANDY LOAM'
-4, 5.30, 0.034, 1.27, 0.485, 0.369, 0.786, 7.20E-6, 0.239E-4, 0.143, 0.25, 'SILT LOAM'
-5, 5.30, 0.034, 1.27, 0.485, 0.369, 0.786, 7.20E-6, 0.239E-4, 0.143, 0.10, 'SILT'
-6, 5.39, 0.050, 1.21, 0.451, 0.314, 0.478, 6.95E-6, 0.143E-4, 0.137, 0.40, 'LOAM'
-7, 7.12, 0.068, 1.18, 0.420, 0.299, 0.299, 6.30E-6, 0.990E-5, 0.148, 0.60, 'SANDY CLAY LOAM'
-8, 7.75, 0.060, 1.32, 0.477, 0.357, 0.356, 1.70E-6, 0.237E-4, 0.208, 0.10, 'SILTY CLAY LOAM'
-9, 8.52, 0.085, 1.23, 0.476, 0.391, 0.630, 2.45E-6, 0.113E-4, 0.230, 0.35, 'CLAY LOAM'
-10, 10.40, 0.100, 1.18, 0.426, 0.316, 0.153, 2.17E-6, 0.187E-4, 0.210, 0.52, 'SANDY CLAY'
-11, 10.40, 0.070, 1.15, 0.492, 0.409, 0.490, 1.03E-6, 0.964E-5, 0.250, 0.10, 'SILTY CLAY'
-12, 11.40, 0.068, 1.09, 0.482, 0.400, 0.405, 1.28E-6, 0.112E-4, 0.268, 0.25, 'CLAY'
-13, 5.39, 0.027, 1.21, 0.451, 0.314, 0.478, 6.95E-6, 0.143E-4, 0.117, 0.05, 'ORGANIC MATERIAL'
-14, 0.0, 0.0, 4.18, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.00, 'WATER'
-15, 4.05, 0.004, 2.03, 0.200, 0.10 , 0.121, 1.41E-4, 0.136E-3, 0.006, 0.60, 'BEDROCK'
-16, 4.90, 0.065, 2.10, 0.435, 0.249, 0.218, 3.47E-5, 0.514E-5, 0.114, 0.05, 'OTHER(land-ice)'
-17, 11.40, 0.030, 1.41, 0.468, 0.454, 0.468, 9.74E-7, 0.112E-4, 0.030, 0.60, 'PLAYA'
-18, 4.05, 0.006, 1.41, 0.200, 0.17, 0.069, 1.41E-4, 0.136E-3, 0.006, 0.52, 'LAVA'
-19, 4.05, 0.01, 1.47, 0.339, 0.236, 0.069, 1.76E-4, 0.608E-6, 0.060, 0.92, 'WHITE SAND'
-
diff --git a/parm/forecast/hwrf_physics_fix/VEGPARM.TBL b/parm/forecast/hwrf_physics_fix/VEGPARM.TBL
deleted file mode 100644
index 5b7ab79a5..000000000
--- a/parm/forecast/hwrf_physics_fix/VEGPARM.TBL
+++ /dev/null
@@ -1,243 +0,0 @@
-Vegetation Parameters
-USGS
-27,1, 'SHDFAC NROOT RS RGL HS SNUP MAXALB LAIMIN LAIMAX EMISSMIN EMISSMAX ALBEDOMIN ALBEDOMAX Z0MIN Z0MAX ZTOPV ZBOTV'
-1, .10, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .15, .15, .50, .50, 0.00, 0.00, 'Urban and Built-Up Land'
-2, .80, 3, 40., 100., 36.25, 0.04, 66., 1.56, 5.68, .920, .985, .17, .23, .05, .15, 0.50, 0.01, 'Dryland Cropland and Pasture'
-3, .80, 3, 40., 100., 36.25, 0.04, 66., 1.56, 5.68, .930, .985, .20, .25, .02, .10, 0.50, 0.01, 'Irrigated Cropland and Pasture'
-4, .80, 3, 40., 100., 36.25, 0.04, 66., 1.00, 4.50, .920, .985, .18, .23, .05, .15, 0.50, 0.01, 'Mixed Dryland/Irrigated Cropland and Pasture'
-5, .80, 3, 40., 100., 36.25, 0.04, 68., 2.29, 4.29, .920, .980, .18, .23, .05, .14, 0.50, 0.01, 'Cropland/Grassland Mosaic'
-6, .80, 3, 70., 65., 44.14, 0.04, 60., 2.00, 4.00, .930, .985, .16, .20, .20, .20, 0.50, 0.01, 'Cropland/Woodland Mosaic'
-7, .80, 3, 40., 100., 36.35, 0.04, 70., 0.52, 2.90, .920, .960, .19, .23, .10, .12, 0.50, 0.01, 'Grassland'
-8, .70, 3, 300., 100., 42.00, 0.03, 60., 0.50, 3.66, .930, .930, .25, .30, .01, .05, 0.50, 0.10, 'Shrubland'
-9, .70, 3, 170., 100., 39.18, 0.035, 65., 0.60, 2.60, .930, .950, .22, .30, .01, .06, 0.50, 0.10, 'Mixed Shrubland/Grassland'
-10, .50, 3, 70., 65., 54.53, 0.04, 50., 0.50, 3.66, .920, .920, .20, .20, .15, .15, 5.00, 0.10, 'Savanna'
-11, .80, 4, 100., 30., 54.53, 0.08, 58., 1.85, 3.31, .930, .930, .16, .17, .50, .50, 20.0, 11.5, 'Deciduous Broadleaf Forest'
-12, .70, 4, 150., 30., 47.35, 0.08, 54., 1.00, 5.16, .930, .940, .14, .15, .50, .50, 14.0, 7.0, 'Deciduous Needleleaf Forest'
-13, .95, 4, 150., 30., 41.69, 0.08, 35., 3.08, 6.48, .950, .950, .12, .12, .50, .50, 35.0, 1.0, 'Evergreen Broadleaf Forest'
-14, .70, 4, 125., 30., 47.35, 0.08, 52., 5.00, 6.40, .950, .950, .12, .12, .50, .50, 17.0, 8.5, 'Evergreen Needleleaf Forest'
-15, .80, 4, 125., 30., 51.93, 0.08, 53., 2.80, 5.50, .930, .970, .17, .25, .20, .50, 18.0, 10.0, 'Mixed Forest'
-16, .00, 0, 100., 30., 51.75, 0.01, 70., 0.01, 0.01, .980, .980, .08, .08, 0.0001, 0.0001, 0.00, 0.00, 'Water Bodies'
-17, .60, 2, 40., 100., 60.00, 0.01, 68., 1.50, 5.65, .950, .950, .14, .14, .20, .20, 0.50, 0.01, 'Herbaceous Wetland'
-18, .60, 2, 100., 30., 51.93, 0.02, 50., 2.00, 5.80, .950, .950, .14, .14, .40, .40, 20.0, 11.5, 'Wooded Wetland'
-19, .01, 1, 999., 999., 999.0, 0.02, 75., 0.10, 0.75, .900, .900, .38, .38, .01, .01, 0.02, 0.01, 'Barren or Sparsely Vegetated'
-20, .60, 3, 150., 100., 42.00, 0.025, 68., 0.41, 3.35, .920, .920, .15, .20, .10, .10, 0.50, 0.01, 'Herbaceous Tundra'
-21, .60, 3, 150., 100., 42.00, 0.025, 55., 0.41, 3.35, .930, .930, .15, .20, .30, .30, 10.0, 0.10, 'Wooded Tundra'
-22, .60, 3, 150., 100., 42.00, 0.025, 60., 0.41, 3.35, .920, .920, .15, .20, .15, .15, 5.00, 0.10, 'Mixed Tundra'
-23, .30, 2, 200., 100., 42.00, 0.02, 75., 0.41, 3.35, .900, .900, .25, .25, .05, .10, 0.02, 0.01, 'Bare Ground Tundra'
-24, .00, 1, 999., 999., 999.0, 0.02, 82., 0.01, 0.01, .950, .950, .55, .70, 0.001, 0.001, 0.00, 0.00, 'Snow or Ice'
-25, .50, 1, 40., 100., 36.25, 0.02, 75., 0.01, 0.01, .890, .890, .30, .30, .01, .01, 0.00, 0.00, 'Playa'
-26, .00, 0, 999., 999., 999.0, 0.02, 75., 0.01, 0.01, .880, .880, .16, .16, .15, .15, 0.00, 0.00, 'Lava'
-27, .00, 0, 999., 999., 999.0, 0.02, 75., 0.01, 0.01, .830, .830, .60, .60, .01, .01, 0.00, 0.00, 'White Sand'
-TOPT_DATA
-298.0
-CMCMAX_DATA
-0.5E-3
-CFACTR_DATA
-0.5
-RSMAX_DATA
-5000.0
-BARE
-19
-NATURAL
-5
-CROP
-3
-LOW_DENSITY_RESIDENTIAL
-31
-HIGH_DENSITY_RESIDENTIAL
-32
-HIGH_INTENSITY_INDUSTRIAL
-33
-Vegetation Parameters
-MODIFIED_IGBP_MODIS_NOAH
-20,1, 'SHDFAC NROOT RS RGL HS SNUP MAXALB LAIMIN LAIMAX EMISSMIN EMISSMAX ALBEDOMIN ALBEDOMAX Z0MIN Z0MAX ZTOPV ZBOTV'
-1 .70, 4, 125., 30., 47.35, 0.08, 52., 5.00, 6.40, .950, .950, .12, .12, .50, .50, 17.0, 8.5, 'Evergreen Needleleaf Forest'
-2, .95, 4, 150., 30., 41.69, 0.08, 35., 3.08, 6.48, .950, .950, .12, .12, .50, .50, 35.0, 1.0, 'Evergreen Broadleaf Forest'
-3, .70, 4, 150., 30., 47.35, 0.08, 54., 1.00, 5.16, .930, .940, .14, .15, .50, .50, 14.0, 7.0, 'Deciduous Needleleaf Forest'
-4, .80, 4, 100., 30., 54.53, 0.08, 58., 1.85, 3.31, .930, .930, .16, .17, .50, .50, 20.0, 11.5, 'Deciduous Broadleaf Forest'
-5, .80, 4, 125., 30., 51.93, 0.08, 53., 2.80, 5.50, .930, .970, .17, .25, .20, .50, 18.0, 10.0, 'Mixed Forests'
-6, .70, 3, 300., 100., 42.00, 0.03, 60., 0.50, 3.66, .930, .930, .25, .30, .01, .05, 0.50, 0.10, 'Closed Shrublands'
-7, .70, 3, 170., 100., 39.18, 0.035, 65., 0.60, 2.60, .930, .950, .22, .30, .01, .06, 0.50, 0.10, 'Open Shrublands'
-8, .70, 3, 300., 100., 42.00, 0.03, 60., 0.50, 3.66, .930, .930, .25, .30, .01, .05, 0.50, 0.10, 'Woody Savannas'
-9, .50, 3, 70., 65., 54.53, 0.04, 50., 0.50, 3.66, .920, .920, .20, .20, .15, .15, 0.50, 0.10, 'Savannas'
-10, .80, 3, 40., 100., 36.35, 0.04, 70., 0.52, 2.90, .920, .960, .19, .23, .10, .12, 0.50, 0.01, 'Grasslands'
-11 .60, 2, 70., 65., 55.97 0.015 59., 1.75, 5.72, .950, .950, .14, .14, .30, .30, 0.00, 0.00, 'Permanent wetlands'
-12, .80, 3, 40., 100., 36.25, 0.04, 66., 1.56, 5.68, .920, .985, .17, .23, .05, .15, 0.50, 0.01, 'Croplands'
-13, .10, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .15, .15, .50, .50, 0.00, 0.00, 'Urban and Built-Up'
-14 .80, 3, 40., 100., 36.25, 0.04, 68., 2.29, 4.29, .920, .980, .18, .23, .05, .14, 0.50, 0.01, 'cropland/natural vegetation mosaic'
-15, .00, 1, 999., 999., 999.0, 0.02, 82., 0.01, 0.01, .950, .950, .55, .70, 0.001, 0.001, 0.00, 0.00, 'Snow and Ice'
-16, .01, 1, 999., 999., 999.0, 0.02, 75., 0.10, 0.75, .900, .900, .38, .38, .01, .01, 0.02, 0.01, 'Barren or Sparsely Vegetated'
-17, .00, 0, 100., 30., 51.75, 0.01, 70., 0.01, 0.01, .980, .980, .08, .08, 0.0001, 0.0001, 0.00, 0.00, 'Water'
-18, .60, 3, 150., 100., 42.00, 0.025, 55., 0.41, 3.35, .930, .930, .15, .20, .30, .30, 10.0, 0.10, 'Wooded Tundra'
-19, .60, 3, 150., 100., 42.00, 0.025, 60., 0.41, 3.35, .920, .920, .15, .20, .15, .15, 5.00, 0.10, 'Mixed Tundra'
-20, .30, 2, 200., 100., 42.00, 0.02, 75., 0.41, 3.35, .900, .900, .25, .25, .05, .10, 0.02, 0.01, 'Barren Tundra'
-TOPT_DATA
-298.0
-CMCMAX_DATA
-0.5E-3
-CFACTR_DATA
-0.5
-RSMAX_DATA
-5000.0
-BARE
-16
-NATURAL
-14
-CROP
-12
-LOW_DENSITY_RESIDENTIAL
-31
-HIGH_DENSITY_RESIDENTIAL
-32
-HIGH_INTENSITY_INDUSTRIAL
-33
-Vegetation Parameters
-NLCD40
-40,1, 'SHDFAC NROOT RS RGL HS SNUP MAXALB LAIMIN LAIMAX EMISSMIN EMISSMAX ALBEDOMIN ALBEDOMAX Z0MIN Z0MAX ZTOPV ZBOTV'
-1, .70, 4, 125., 30., 47.35, 0.08, 52., 5.00, 6.40, .950, .950, .12, .12, .50, .50, 17.00, 8.50, 'Evergreen Needleleaf Forest'
-2, .95, 4, 150., 30., 41.69, 0.08, 35., 3.08, 6.48, .950, .950, .12, .12, .50, .50, 35.00, 1.00, 'Evergreen Broadleaf Forest'
-3, .70, 4, 150., 30., 47.35, 0.08, 54., 1.00, 5.16, .930, .940, .14, .15, .50, .50, 14.00, 7.00, 'Deciduous Needleleaf Forest'
-4, .80, 4, 100., 30., 54.53, 0.08, 58., 1.85, 3.31, .930, .930, .16, .17, .50, .50, 20.00, 11.50, 'Deciduous Broadleaf Forest'
-5, .80, 4, 125., 30., 51.93, 0.08, 53., 2.80, 5.50, .930, .970, .17, .25, .20, .50, 18.00, 10.00, 'Mixed Forest'
-6, .70, 3, 300., 100., 42.00, 0.03, 60., 0.50, 3.66, .930, .930, .25, .30, .01, .05, 0.50, 0.10, 'Closed Shrubland'
-7, .70, 3, 170., 100., 39.18, 0.035, 65., 0.60, 2.60, .930, .950, .22, .30, .01, .06, 0.50, 0.10, 'Open Shrubland'
-8, .50, 3, 70., 65., 54.53, 0.04, 50., 0.50, 3.66, .930, .930, .25, .30, .01, .05, 0.00, 0.00, 'Woody Savanna'
-9, .50, 3, 70., 65., 54.53, 0.04, 50., 0.50, 3.66, .920, .920, .20, .20, .15, .15, 0.50, 0.10, 'Savanna'
-10, .80, 3, 40., 100., 36.35, 0.04, 70., 0.52, 2.90, .920, .960, .19, .23, .10, .12, 0.50, 0.10, 'Grassland'
-11, .60, 2, 100., 30., 51.93, 0.02, 50., 1.75, 5.72, .950, .950, .14, .14, .30, .30, 0.50, 0.10, 'Permanent Wetland'
-12, .80, 3, 40., 100., 36.25, 0.04, 66., 1.50, 5.68, .920, .985, .15, .23, .05, .15, 0.50, 0.10, 'Cropland'
-13, .10, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .15, .15, .50, .50, 0.00, 0.00, 'Urban and Built-Up'
-14, .80, 3, 40., 100., 36.25, 0.04, 66., 2.29, 4.29, .920, .980, .18, .23, .05, .14, 0.50, 0.10, 'Cropland / Natural Veg. Mosaic'
-15, .00, 1, 999., 999., 999.0, 0.02, 82., 0.01, 0.01, .950, .950, .55, .70, 0.001, 0.001, 0.00, 0.00, 'Permanent Snow'
-16, .01, 1, 999., 999., 999.0, 0.02, 75., 0.10, 0.75, .900, .900, .38, .38, .01, .01, 0.02, 0.01, 'Barren / Sparsely Vegetated'
-17, .00, 0, 100., 30., 51.75, 0.01, 70., 0.01, 0.01, .980, .980, .08, .08, 0.0001, 0.0001, 0.00, 0.00, 'IGBP Water'
-18, .00, 0, 999., 999., 999.0, 999., 999., 999.0, 999.0, 999., 999.0, 999.0, 999.0, 999.0, 999.0, 0.00, 0.00, 'Unclassified'
-19, .00, 0, 999., 999., 999.0, 999., 999., 999.0, 999.0, 999., 999.0, 999.0, 999.0, 999.0, 999.0, 0.00, 0.00, 'Fill Value'
-20, .00, 0, 999., 999., 999.0, 999., 999., 999.0, 999.0, 999., 999.0, 999.0, 999.0, 999.0, 999.0, 0.00, 0.00, 'Unclassified'
-21, .00, 0, 100., 30., 51.75, 0.01, 70., 0.01, 0.01, .980, .980, .08, .08, 0.0001, 0.0001, 0.00, 0.00, 'Open Water'
-22, .00, 1, 999., 999., 999.0, 0.02, 82., 0.01, 0.01, .950, .950, .55, .70, 0.001, 0.001, 0.00, 0.00, 'Perennial Ice/Snow'
-23, .30, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .20, .20, .50, .50, 0.00, 0.00, 'Developed Open Space'
-24, .27, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .20, .20, .70, .70, 0.00, 0.00, 'Developed Low Intensity'
-25, .02, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .20, .20, 1.5, 1.5, 0.00, 0.00, 'Developed Medium Intensity'
-26, .11, 1, 200., 999., 999.0, 0.04, 46., 1.00, 1.00, .880, .880, .20, .20, 2.0, 2.0, 0.00, 0.00, 'Developed High Intensity'
-27, .01, 1, 999., 999., 999.0, 0.02, 75., 0.10, 0.75, .900, .900, .38, .38, .01, .01, 0.02, 0.01, 'Barren Land'
-28, .80, 4, 125., 30., 54.70, 0.08, 56., 1.00, 5.16, .930, .940, .14, .17, .50, .50, 20.00, 11.50, 'Deciduous Forest'
-29, .95, 4, 140., 30., 44.00, 0.08, 42., 3.08, 6.48, .950, .950, .12, .12, .50, .50, 17.00, 8.50, 'Evergreen Forest'
-30, .80, 4, 125., 30., 51.93, 0.08, 53., 2.80, 5.50, .930, .970, .17, .25, .20, .50, 18.00, 10.00, 'Mixed Forest'
-31, .70, 3, 170., 100., 39.18, 0.035, 65., 1.00, 4.00, .930, .950, .16, .30, .01, .04, 0.50, 0.10, 'Dwarf Scrub'
-32, .70, 3, 300., 100., 42.00, 0.03, 60., 0.50, 3.66, .930, .930, .22, .30, .01, .05, 0.50, 0.10, 'Shrub/Scrub'
-33, .80, 3, 40., 100., 36.35, 0.04, 70., 0.52, 2.90, .920, .960, .19, .23, .10, .12, 0.50, 0.10, 'Grassland/Herbaceous'
-34, .60, 2, 40., 100., 60.00, 0.01, 68., 1.50, 5.65, .950, .950, .14, .14, .20, .20, 0.50, 0.10, 'Sedge/Herbaceous'
-35, .60, 2, 40., 100., 60.00, 0.01, 68., 1.00, 2.00, .950, .950, .31, .31, .01, .01, 0.00, 0.00, 'Lichens'
-36, .60, 2, 40., 100., 60.00, 0.01, 68., 1.00, 2.00, .950, .950, .24, .24, .01, .01, 0.00, 0.00, 'Moss'
-37, .80, 3, 40., 100., 36.25, 0.04, 66., 1.56, 5.68, .920, .985, .17, .23, .05, .15, 0.50, 0.10, 'Pasture/Hay'
-38, .80, 3, 40., 100., 36.25, 0.04, 66., 1.56, 5.68, .930, .985, .20, .25, .02, .10, 0.50, 0.10, 'Cultivated Crops'
-39, .60, 2, 100., 30., 51.93, 0.02, 50., 0.70, 3.50, .950, .950, .14, .14, .40, .40, 20.00, 11.50, 'Woody Wetland'
-40, .60, 2, 40., 100., 60.00, 0.01, 68., 0.70, 3.50, .950, .950, .12, .12, .20, .20, 0.50, 0.10, 'Emergent Herbaceous Wetland'
-TOPT_DATA
-298.0
-CMCMAX_DATA
-0.5E-3
-CFACTR_DATA
-0.5
-RSMAX_DATA
-5000.0
-BARE
-16
-NATURAL
-14
-CROP
-12
-LOW_DENSITY_RESIDENTIAL
-24
-HIGH_DENSITY_RESIDENTIAL
-26
-HIGH_INTENSITY_INDUSTRIAL
-99
-Vegetation Parameters
-USGS-RUC
-28,1, 'ALBEDO Z0 LEMI PC SHDFAC IFOR RS RGL HS SNUP LAI MAXALB'
-1, .18, 1.0, .88, .40, .10, 9, 200., 999., 999.0, 0.04, 1.00, 40., 'Urban and Built-Up Land'
-2, .17, .06, .92, .30, .80, 7, 40., 100., 36.25, 0.04, 5.68, 64., 'Dryland Cropland and Pasture'
-3, .18, .075, .92, .40, .80, 7, 40., 100., 36.25, 0.04, 5.68, 64., 'Irrigated Cropland and Pasture'
-4, .18, .125, .92, .40, .80, 7, 40., 100., 36.25, 0.04, 4.50, 64., 'Mixed Dryland/Irrigated Cropland and Pasture'
-5, .18, .15, .92, .40, .80, 3, 40., 100., 36.25, 0.04, 4.29, 64., 'Cropland/Grassland Mosaic'
-6, .16, .20, .93, .40, .80, 3, 70., 65., 44.14, 0.04, 4.00, 60., 'Cropland/Woodland Mosaic'
-7, .19, .075 .92, .40, .80, 5, 40., 100., 36.35, 0.04, 2.90, 64., 'Grassland'
-8, .22, .10, .88, .40, .70, 4, 300., 100., 42.00, 0.03, 3.66, 69., 'Shrubland'
-9, .20, .11, .90, .40, .70, 4, 170., 100., 39.18, 0.035, 2.60, 67., 'Mixed Shrubland/Grassland'
-10, .20, .15, .92, .40, .50, 5, 70., 65., 54.53, 0.04, 3.66, 45., 'Savanna'
-11, .16, .70, .93, .55, .80, 3, 100., 30., 54.53, 0.08, 3.31, 58., 'Deciduous Broadleaf Forest'
-12, .14, .70, .94, .55, .70, 4, 150., 30., 47.35, 0.08, 5.16, 54., 'Deciduous Needleleaf Forest'
-13, .12, .70, .95, .55, .95, 2, 150., 30., 41.69, 0.08, 6.48, 32., 'Evergreen Broadleaf Forest'
-14, .12, .70, .95, .55, .70, 1, 125., 30., 47.35, 0.08, 6.40, 52., 'Evergreen Needleleaf Forest'
-15, .13, .70, .94, .55, .80, 2, 125., 30., 51.93, 0.08, 5.50, 53., 'Mixed Forest'
-16, .08, .0001, .98, .00, .00, 9, 100., 30., 51.75, 0.01, 0.01, 70., 'Water Bodies'
-17, .14, .20, .95, .55, .60, 4, 40., 100., 60.00, 0.01, 5.65, 35., 'Herbaceous Wetland'
-18, .14, .40, .95, .55, .60, 4, 100., 30., 51.93, 0.02, 5.80, 30., 'Wooded Wetland'
-19, .25, .05, .85, .30, .01, 5, 999., 999., 999.0, 0.02, 0.75, 69., 'Barren or Sparsely Vegetated'
-20, .15, .10, .92, .30, .60, 5, 150., 100., 42.00, 0.025, 3.35, 58., 'Herbaceous Tundra'
-21, .15, .15, .93, .40, .60, 5, 150., 100., 42.00, 0.025, 3.35, 55., 'Wooded Tundra'
-22, .15, .10, .92, .40, .60, 5, 150., 100., 42.00, 0.025, 3.35, 55., 'Mixed Tundra'
-23, .25, .065, .85, .30, .30, 5, 200., 100., 42.00, 0.02, 3.35, 65., 'Bare Ground Tundra'
-24, .55, .0024, .98, .00, .00, 9, 999., 999., 999.0, 0.02, 0.01, 75., 'Snow or Ice'
-25, .30, .01, .85, .30, .50, 9, 40., 100., 36.25, 0.02, 0.01, 69., 'Playa'
-26, .16, .15, .85, .00, .00, 9, 999., 999., 999.0, 0.02, 0.01, 69., 'Lava'
-27, .60, .01, .90, .00, .00, 9, 999., 999., 999.0, 0.02, 0.01, 69., 'White Sand'
-28, .08, .0001, .98, .00, .00, 9, 100., 30., 51.75, 0.01, 0.01, 70., 'Lakes'
-TOPT_DATA
-298.0
-CMCMAX_DATA
-0.2E-3
-CFACTR_DATA
-0.5
-RSMAX_DATA
-5000.0
-BARE
-19
-NATURAL
-5
-CROP
-3
-URBAN
-1
-Vegetation Parameters
-MODI-RUC
-21,1, 'ALBEDO Z0 LEMI PC SHDFAC IFOR RS RGL HS SNUP LAI MAXALB'
-1 .12, .70, .950, .55, .70, 1, 125., 30., 47.35, 0.08, 6.40, 52., 'Evergreen Needleleaf Forest'
-2, .12, .70, .950, .55, .95, 2, 150., 30., 41.69, 0.08, 6.48, 35., 'Evergreen Broadleaf Forest'
-3, .14, .70, .940, .55, .70, 4, 150., 30., 47.35, 0.08, 5.16, 54., 'Deciduous Needleleaf Forest'
-4, .16, .70, .930, .55, .80, 3, 100., 30., 54.53, 0.08, 3.31, 58., 'Deciduous Broadleaf Forest'
-5, .13, .70, .940, .55, .80, 2, 125., 30., 51.93, 0.08, 5.50, 53., 'Mixed Forests'
-6, .22, .10, .930, .40, .70, 4, 300., 100., 42.00, 0.03, 3.66, 60., 'Closed Shrublands'
-7, .20, .10, .880, .40, .70, 4, 170., 100., 39.18, 0.035, 2.60, 65., 'Open Shrublands'
-8, .20, .15, .930, .40, .70, 5, 300., 100., 42.00, 0.03, 3.66, 60., 'Woody Savannas'
-9, .20, .15, .920, .40, .50, 5, 70., 65., 54.53, 0.04, 3.66, 50., 'Savannas'
-10, .19, .075, .920, .40, .80, 5, 40., 100., 36.35, 0.04, 2.90, 70., 'Grasslands'
-11 .14, .30, .950, .40, .60, 4, 70., 65., 55.97 0.015 5.72, 59., 'Permanent wetlands'
-12, .18, .20, .935, .40, .80, 7, 40., 100., 36.25, 0.04, 5.68, 66., 'Croplands'
-13, .18, 1.0, .880, .40, .10, 9, 200., 999., 999.0, 0.04, 1.00, 46., 'Urban and Built-Up'
-14 .16, .20, .920, .40, .80, 7, 40., 100., 36.25, 0.04, 4.29, 68., 'cropland/natural vegetation mosaic'
-15, .55, .011, .980, .00, .00, 9, 999., 999., 999.0, 0.02, 0.01, 82., 'Snow and Ice'
-16, .25, .065, .850, .30, .01, 5, 999., 999., 999.0, 0.02, 0.75, 75., 'Barren or Sparsely Vegetated'
-17, .08, .0001, .980, .00, .00, 9, 100., 30., 51.75, 0.01, 0.01, 70., 'Water'
-18, .15, .15, .930, .40, .60, 5, 150., 100., 42.00, 0.025, 3.35, 55., 'Wooded Tundra'
-19, .15, .10, .920, .40, .60, 5, 150., 100., 42.00, 0.025, 3.35, 60., 'Mixed Tundra'
-20, .15, .06, .900, .30, .30, 5, 200., 100., 42.00, 0.02, 3.35, 75., 'Barren Tundra'
-21, .08, .0001, .980, .00, .00, 9, 100., 30., 51.75, 0.01, 0.01, 70., 'Lakes'
-TOPT_DATA
-298.0
-CMCMAX_DATA
-0.2E-3
-CFACTR_DATA
-0.5
-RSMAX_DATA
-5000.0
-BARE
-16
-NATURAL
-10
-CROP
-12
-URBAN
-13
diff --git a/parm/forecast/regional/diag_table.tmp b/parm/forecast/regional/diag_table.tmp
index 457c451e0..c37a3ee64 100644
--- a/parm/forecast/regional/diag_table.tmp
+++ b/parm/forecast/regional/diag_table.tmp
@@ -1,9 +1,14 @@
+ufs.hafs
+@[SYEAR] @[SMONTH] @[SDAY] @[SHOUR] 0 0
+
#output files
-"grid_spec", -1, "months", 1, "days", "time"
+ "grid_spec", -1, "months", 1, "days", "time"
#"atmos_4xdaily", 1, "hours", 1, "days", "time"
-"atmos_static", -1, "hours", 1, "hours", "time"
-"fv3_history", 0, "hours", 1, "hours", "time"
-"fv3_history2d", 0, "hours", 1, "hours", "time"
+ "atmos_static", -1, "hours", 1, "hours", "time"
+ "grid_mspec%4yr%2mo%2dy%2hr", @[GRID_MSPEC_INT], "hours", 1, "hours", "time", 3, "hours"
+#"atmos_diag%4yr%2mo%2dy%2hr", @[ATMOS_DIAG_INT], "hours", 1, "hours", "time", 3, "hours"
+ "fv3_history", 0, "hours", 1, "hours", "time"
+ "fv3_history2d", 0, "hours", 1, "hours", "time"
#"ref3D", 0, "hours", 1, "hours", "time"
#"maxmin2D", 1, "hours", 1, "hours", "time"
@@ -14,11 +19,21 @@
###
# grid_spec
###
- "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
"dynamics", "grid_lont", "grid_lont", "grid_spec", "all", .false., "none", 2,
"dynamics", "grid_latt", "grid_latt", "grid_spec", "all", .false., "none", 2,
- "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
+ "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
+###
+# grid_mspec
+###
+ "dynamics", "grid_mlon", "grid_lon", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlat", "grid_lat", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlont", "grid_lont", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "grid_mlatt", "grid_latt", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+ "dynamics", "marea", "area", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "mdx", "dx", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "mdy", "dy", "grid_mspec%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
###
# 4x daily output
###
@@ -104,6 +119,35 @@
"dynamics", "hybm", "hybm", "atmos_static", "all", .false., "none", 2
"dynamics", "zsurf", "zsurf", "atmos_static", "all", .false., "none", 2
###
+# GFDL tracker needed variables
+###
+##"dynamics", "grid_lon", "grid_lon", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+##"dynamics", "grid_lat", "grid_lat", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "grid_mlon", "grid_lon", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "grid_mlat", "grid_lat", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2,
+#"dynamics", "vort850", "vort850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "vort700", "vort700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "us", "us", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u850", "u850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u700", "u700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "u500", "u500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "vs", "vs", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v850", "v850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v700", "v700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "v500", "v500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t850", "t850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t500", "t500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "t300", "t300", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "slp", "slp", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z850", "z850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z700", "z700", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z500", "z500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "z200", "z200", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "rh850", "rh850", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+#"dynamics", "rh500", "rh500", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+##"gfs_phys", "u10m", "u10m", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+##"gfs_phys", "v10m", "v10m", "atmos_diag%4yr%2mo%2dy%2hr", "all", .false., "none", 2
+###
# FV3 variabls needed for NGGPS evaluation
###
"gfs_dyn", "ucomp", "ugrd", "fv3_history", "all", .false., "none", 2
diff --git a/parm/forecast/regional/input.nml.tmp b/parm/forecast/regional/input.nml.tmp
index 3bd62a7ed..be0295571 100644
--- a/parm/forecast/regional/input.nml.tmp
+++ b/parm/forecast/regional/input.nml.tmp
@@ -1,368 +1,388 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
+&atmos_model_nml
+ blocksize = @[blocksize]
+ chksum_debug = .false.
+ dycore_only = .false.
+ avg_max_length = 3600.
+ ccpp_suite = '@[ccpp_suite_nml]'
/
- &diag_manager_nml
- prepend_date = .false.
+&diag_manager_nml
+ prepend_date = .false.
/
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
+&mpp_io_nml
+ header_buffer_val = 16384,
+ global_field_on_root_pe = .true.,
+ io_clocks_on = .false.,
+ shuffle = 0,
+ deflate_level = @[deflate_level],
+ cf_compliance = .false.
/
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
+&fms_io_nml
+ checksum_required = .false.
+ max_files_r = 1000,
+ max_files_w = 1000,
/
- &fms2_io_nml
-netcdf_default_format="netcdf4"
+&fms2_io_nml
+ netcdf_default_format="netcdf4"
/
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
+&fms_nml
+ clock_grain = 'ROUTINE',
+ domains_stack_size = 30000000,
+ print_memory_usage = .false.
/
- &fv_grid_nml
- grid_file = 'INPUT/grid_spec.nc'
+&fv_grid_nml
+ grid_file = 'INPUT/grid_spec.nc'
/
- &fv_core_nml
- !layout = 64,30
- !layout = 40,30
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 1
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 50.e2
- d2_bg_k1 = 0.20
- d2_bg_k2 = 0.15
- kord_tm = -11
- kord_mt = 11
- kord_wz = 11
- kord_tr = 11
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 6
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.008
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 6
- hord_vt = 6
- hord_tm = 6
- hord_dp = -6
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 0.
- do_sat_adj = .T.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
+&fv_core_nml
+ layout = @[layoutx_nml],@[layouty_nml]
+ io_layout = @[io_layoutx_nml],@[io_layouty_nml]
+ npx = @[npx_nml]
+ npy = @[npy_nml]
+ ntiles = 1
+ npz = @[npz]
+ !grid_type = -1
+ make_nh = .false.
+ fv_debug = .false.
+ range_warn = .true.
+ reset_eta = .false.
+ n_sponge = 24
+ nudge_qv = .false.
+ nudge_dz = .false.
+ tau = 5.
+ rf_cutoff = 50.e2
+ d2_bg_k1 = 0.20
+ d2_bg_k2 = 0.15
+ kord_tm = -11
+ kord_mt = 11
+ kord_wz = 11
+ kord_tr = 11
+ hydrostatic = .false.
+ phys_hydrostatic = .false.
+ use_hydro_pressure = .false.
+ beta = 0.
+ a_imp = 1.
+ p_fac = 0.1
+ k_split = @[k_split_nml]
+ n_split = @[n_split_nml]
+ nwat = 6
+ na_init = @[na_init]
+ d_ext = 0.0
+ dnats = 1
+ fv_sg_adj = 300
+ d2_bg = 0.
+ nord = 2
+ dddmp = 0.1
+ d4_bg = 0.15
+ vtdm4 = 0.04
+ delt_max = 0.008
+ ke_bg = 0.
+ do_vort_damp = .true.
+ external_ic = @[external_ic]
+ external_eta = .true.
+ gfs_phil = .false.
+ nggps_ic = @[nggps_ic]
+ mountain = @[mountain]
+ ncep_ic = .false.
+ d_con = 1.0
+ hord_mt = 6
+ hord_vt = 6
+ hord_tm = 6
+ hord_dp = 6
+ hord_tr = -5
+ adjust_dry_mass = .false.
+ consv_te = 0.
+ do_sat_adj = .true.
+ consv_am = .false.
+ fill = .true.
+ dwind_2d = .false.
+ print_freq = 3
+ warm_start = @[warm_start]
+ no_dycore = .false.
+ z_tracer = .true.
+ agrid_vel_rst = .true.
+ read_increment = .false.
+ res_latlon_dynamics = "fv3_increment.nc"
+ write_3d_diags = .true.
- do_schmidt = .true.
- target_lat = _target_lat_
- target_lon = _target_lon_
- stretch_fac = _stretch_fac_
- regional = .true.
- bc_update_interval = _bc_update_interval_
- nrows_blend = _nrows_blend_
+ do_schmidt = .true.
+ target_lat = @[target_lat]
+ target_lon = @[target_lon]
+ stretch_fac = @[stretch_fac]
+ regional = .true.
+ bc_update_interval = @[bc_update_interval]
+ nrows_blend = @[nrows_blend]
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 0 ! safety
- nord_zs_filter = 4
+ full_zs_filter = @[full_zs_filter_nml]
+ n_zs_filter = @[n_zs_filter_nml]
+ nord_zs_filter = 4
/
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
+&fv_nest_nml
+ grid_pes = @[grid_pes]
+ tile_coarse = @[tile_coarse]
+ num_tile_top = 1
+ p_split = 1
+ nest_refine = @[refine]
+ nest_ioffsets = @[ioffset]
+ nest_joffsets = @[joffset]
/
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
+&fv_moving_nest_nml
+ surface_dir = "INPUT/moving_nest"
+ is_moving_nest = @[is_moving_nest]
+ vortex_tracker = @[vortex_tracker]
+ ntrack = @[ntrack]
+ move_cd_x = @[move_cd_x]
+ move_cd_y = @[move_cd_y]
/
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 11
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .false.
- shal_cnv = .true. !Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .false.
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF_moninedmf
- satmedmf = .true.
- isatmedmf = 1
- rlmx = 300.
- elmx = 300.
- sfc_rlm = 1
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 0.88, 0.04
- sfc_z0_type = 6
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 1
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
+&surf_map_nml
+ zero_ocean = .false.
+ cd4 = 0.15
+ cd2 = -1
+ n_del2_strong = 0
+ n_del2_weak = @[n_del2_weak_nml]
+ n_del4 = 2
+ max_slope = @[max_slope_nml]
+ peak_fac = 1.
/
- &gfdl_cloud_microphysics_nml
- sedi_transport = .false.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
+&external_ic_nml
+ filtered_terrain = .true.
+ levp = @[levp]
+ gfs_dwinds = .true.
+ checker_tr = .false.
+ nt_checker = 0
/
- &interpolator_nml
- interp_method = 'conserve_great_circle'
+&gfs_physics_nml
+ fhzero = 3.
+ ldiag3d = .false.
+ lradar = .true.
+ avg_max_length = 3600.
+ h2o_phys = .true.
+ fhcyc = 0.
+ use_ufo = .true.
+ pre_rad = .false.
+ imp_physics = 11
+ pdfcld = .false.
+ fhswr = @[fhswr]
+ fhlwr = @[fhlwr]
+ ialb = 1
+ iems = 1
+ iaer = 111
+ ico2 = 2
+ isubc_sw = 2
+ isubc_lw = 2
+ isol = 2
+ lwhtr = .true.
+ swhtr = .true.
+ cnvgwd = .false.
+ cal_pre = .false.
+ redrag = .true.
+ dspheat = .true.
+ hybedmf = .false.
+ hurr_pbl = .true. ! HWRF moninedmf
+ moninq_fac = -1.0 ! HWRF_moninedmf
+ satmedmf = .true.
+ isatmedmf = 1
+ rlmx = 300.
+ elmx = 300.
+ sfc_rlm = 1
+ random_clds = .false.
+ trans_trac = .true.
+ cnvcld = .true.
+ shal_cnv = @[shal_cnv_nml] !Shallow convection
+ do_deep = @[do_deep_nml]
+ imfshalcnv = 2
+ imfdeepcnv = 2
+ clam_deep = 0.1
+ betal_deep = 0.05
+ betas_deep = 0.05
+ cdmbgwd = 0.88, 0.04
+ sfc_z0_type = 6
+ prslrd0 = 0.
+ ivegsrc = 1
+ isot = 1
+ lsm = 1
+ iopt_dveg = 2
+ iopt_crs = 1
+ iopt_btr = 1
+ iopt_run = 1
+ iopt_sfc = 1
+ iopt_frz = 1
+ iopt_inf = 1
+ iopt_rad = 1
+ iopt_alb = 2
+ iopt_snf = 4
+ iopt_tbot = 2
+ iopt_stc = 1
+ debug = .false.
+ oz_phys = .false.
+ oz_phys_2015 = .true.
+ nst_anl = .true.
+ nstf_name = @[nstf_n1],@[nstf_n2],@[nstf_n3],@[nstf_n4],@[nstf_n5]
+ cplflx = @[cplflx]
+ cplice = .false.
+ cplocn2atm = @[cplocn2atm]
+ cplwav = @[cplwav]
+ cplwav2atm = @[cplwav2atm]
+ cpl_imp_mrg = @[merge_import]
+ psautco = 0.0008, 0.0005
+ prautco = 0.00015, 0.00015
+ iau_delthrs = 6
+ iaufhrs = 30
+ iau_inc_files = ''
+ iau_drymassfixer = .false.
+ lgfdlmprad = .true.
+ effr_in = .true.
+ do_sppt = .false.
+ do_shum = .false.
+ do_skeb = .false.
+ lndp_type = 0
+ n_var_lndp = 0
+ do_ca = .false.
+ ca_sgs = .false.
+ nca = 1
+ ncells = 5
+ nlives = 12
+ nseed = 1
+ nfracseed = 0.5
+ ca_trigger = .false.
+ ca_entr = .false.
+ ca_closure = .false.
+ ca_global = .false.
+ nca_g = 1
+ ncells_g = 1
+ nlives_g = 100
+ nseed_g = 100
+ ca_smooth = .false.
+ nspinup = 1
+ iseed_ca = 1
+ nsmooth = 100
+ ca_amplitude = 0.35
+ print_diff_pgr = .true.
/
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
+&gfdl_cloud_microphysics_nml
+ sedi_transport = .false.
+ do_sedi_heat = .false.
+ rad_snow = .true.
+ rad_graupel = .true.
+ rad_rain = .true.
+ const_vi = .false.
+ const_vs = .false.
+ const_vg = .false.
+ const_vr = .false.
+ vi_max = 1.
+ vs_max = 2.
+ vg_max = 12.
+ vr_max = 12.
+ qi_lim = 1.
+ prog_ccn = .false.
+ do_qa = .true.
+ fast_sat_adj = .true.
+ tau_l2v = 180.
+ tau_v2l = 90.
+ tau_g2v = 900.
+ rthresh = 10.e-6 ! This is a key parameter for cloud water
+ dw_land = 0.16
+ dw_ocean = 0.10
+ ql_gen = 1.0e-3
+ ql_mlt = 1.0e-3
+ qi0_crt = 8.0E-5
+ qs0_crt = 1.0e-3
+ tau_i2s = 1000.
+ c_psaci = 0.05
+ c_pgacs = 0.01
+ rh_inc = 0.30
+ rh_inr = 0.30
+ rh_ins = 0.30
+ ccn_l = 300.
+ ccn_o = 100.
+ c_paut = 0.5
+ c_cracw = 0.8
+ use_ppm = .false.
+ use_ccn = .true.
+ mono_prof = .true.
+ z_slope_liq = .true.
+ z_slope_ice = .true.
+ de_ice = .false.
+ fix_negative = .true.
+ icloud_f = 1
+ mp_time = 90.
/
- &nam_stochy
+&interpolator_nml
+ interp_method = 'conserve_great_circle'
/
- &nam_sfcperts
+&namsfc
+ FNGLAC = "global_glacier.2x2.grb",
+ FNMXIC = "global_maxice.2x2.grb",
+ FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
+ FNSNOC = "global_snoclim.1.875.grb",
+ FNZORC = "igbp"
+ !FNZORC = "global_zorclim.1x1.grb",
+ FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
+ FNALBC2 = "global_albedo4.1x1.grb",
+ FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
+ FNTG3C = "global_tg3clim.2.6x1.5.grb",
+ FNVEGC = "global_vegfrac.0.144.decpercent.grb",
+ FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
+ FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
+ FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
+ FNMSKH = "seaice_newland.grb",
+ FNTSFA = "",
+ FNACNA = "",
+ FNSNOA = "",
+ FNVMNC = "global_shdmin.0.144x0.144.grb",
+ FNVMXC = "global_shdmax.0.144x0.144.grb",
+ FNSLPC = "global_slope.1x1.grb",
+ FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
+ LDEBUG = .true.,
+ FSMCL(2) = 99999
+ FSMCL(3) = 99999
+ FSMCL(4) = 99999
+ FTSFS = 90
+ FAISS = 99999
+ FSNOL = 99999
+ FSICL = 99999
+ FTSFL = 99999
+ FAISL = 99999
+ FVETL = 99999,
+ FSOTL = 99999,
+ FvmnL = 99999,
+ FvmxL = 99999,
+ FSLPL = 99999,
+ FABSL = 99999,
+ FSNOS = 99999,
+ FSICS = 99999,
/
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
+&nam_stochy
+/
+
+&nam_sfcperts
+/
+
+&cires_ugwp_nml
+ knob_ugwp_solver = 2
+ knob_ugwp_source = 1,1,0,0
+ knob_ugwp_wvspec = 1,25,25,25
+ knob_ugwp_azdir = 2,4,4,4
+ knob_ugwp_stoch = 0,0,0,0
+ knob_ugwp_effac = 1,1,1,1
+ knob_ugwp_doaxyz = 1
+ knob_ugwp_doheat = 1
+ knob_ugwp_dokdis = 1
+ knob_ugwp_ndx4lh = 1
+ knob_ugwp_version = 0
+ launch_level = 25
/
diff --git a/parm/forecast/regional/input_nest.nml.tmp b/parm/forecast/regional/input_nest.nml.tmp
new file mode 100644
index 000000000..55c5cda61
--- /dev/null
+++ b/parm/forecast/regional/input_nest.nml.tmp
@@ -0,0 +1,365 @@
+&atmos_model_nml
+ blocksize = @[blocksize]
+ chksum_debug = .false.
+ dycore_only = .false.
+ avg_max_length = 3600.
+ ccpp_suite = '@[ccpp_suite_nml]'
+/
+
+&diag_manager_nml
+ prepend_date = .false.
+/
+
+&mpp_io_nml
+ header_buffer_val = 16384,
+ global_field_on_root_pe = .true.,
+ io_clocks_on = .false.,
+ shuffle = 0,
+ deflate_level = @[deflate_level],
+ cf_compliance = .false.
+/
+
+&fms_io_nml
+ checksum_required = .false.
+ max_files_r = 1000,
+ max_files_w = 1000,
+/
+
+&fms2_io_nml
+ netcdf_default_format="netcdf4"
+/
+
+&fms_nml
+ clock_grain = 'ROUTINE',
+ domains_stack_size = 30000000,
+ print_memory_usage = .false.
+/
+
+&fv_grid_nml
+ !grid_file = 'INPUT/grid_spec.nc'
+/
+
+&fv_core_nml
+ layout = @[layoutx_nml],@[layouty_nml]
+ io_layout = @[io_layoutx_nml],@[io_layouty_nml]
+ npx = @[npx_nml]
+ npy = @[npy_nml]
+ ntiles = 1
+ npz = @[npz]
+ !grid_type = -1
+ make_nh = .false.
+ fv_debug = .false.
+ range_warn = .true.
+ reset_eta = .false.
+ n_sponge = 24
+ nudge_qv = .false.
+ nudge_dz = .false.
+ tau = 5.
+ rf_cutoff = 50.e2
+ d2_bg_k1 = 0.20
+ d2_bg_k2 = 0.15
+ kord_tm = -11
+ kord_mt = 11
+ kord_wz = 11
+ kord_tr = 11
+ hydrostatic = .false.
+ phys_hydrostatic = .false.
+ use_hydro_pressure = .false.
+ beta = 0.
+ a_imp = 1.
+ p_fac = 0.1
+ k_split = @[k_split_nml]
+ n_split = @[n_split_nml]
+ nwat = 6
+ na_init = @[na_init]
+ d_ext = 0.0
+ dnats = 1
+ fv_sg_adj = 300
+ d2_bg = 0.
+ nord = 2
+ dddmp = 0.1
+ d4_bg = 0.15
+ vtdm4 = 0.04
+ delt_max = 0.008
+ ke_bg = 0.
+ do_vort_damp = .true.
+ external_ic = @[external_ic]
+ external_eta = .true.
+ gfs_phil = .false.
+ nggps_ic = @[nggps_ic]
+ mountain = @[mountain]
+ ncep_ic = .false.
+ d_con = 1.0
+ hord_mt = 6
+ hord_vt = 6
+ hord_tm = 6
+ hord_dp = 6
+ hord_tr = -5
+ adjust_dry_mass = .false.
+ consv_te = 0.
+ do_sat_adj = .true.
+ consv_am = .false.
+ fill = .true.
+ dwind_2d = .false.
+ print_freq = 3
+ warm_start = @[warm_start]
+ no_dycore = .false.
+ z_tracer = .true.
+ agrid_vel_rst = .true.
+ read_increment = .false.
+ res_latlon_dynamics = "fv3_increment.nc"
+ write_3d_diags = .true.
+
+ nested = .true.
+ twowaynest = .true.
+ nestupdate = 7
+
+ full_zs_filter = @[full_zs_filter_nml]
+ n_zs_filter = @[n_zs_filter_nml]
+ nord_zs_filter = 4
+/
+
+&surf_map_nml
+ zero_ocean = .false.
+ cd4 = 0.15
+ cd2 = -1
+ n_del2_strong = 0
+ n_del2_weak = @[n_del2_weak_nml]
+ n_del4 = 2
+ max_slope = @[max_slope_nml]
+ peak_fac = 1.
+/
+
+&external_ic_nml
+ filtered_terrain = .true.
+ levp = @[levp]
+ gfs_dwinds = .true.
+ checker_tr = .false.
+ nt_checker = 0
+/
+
+&gfs_physics_nml
+ fhzero = 3.
+ ldiag3d = .false.
+ lradar = .true.
+ avg_max_length = 3600.
+ h2o_phys = .true.
+ fhcyc = 0.
+ use_ufo = .true.
+ pre_rad = .false.
+ imp_physics = 11
+ pdfcld = .false.
+ fhswr = @[fhswr]
+ fhlwr = @[fhlwr]
+ ialb = 1
+ iems = 1
+ iaer = 111
+ ico2 = 2
+ isubc_sw = 2
+ isubc_lw = 2
+ isol = 2
+ lwhtr = .true.
+ swhtr = .true.
+ cnvgwd = .false.
+ cal_pre = .false.
+ redrag = .true.
+ dspheat = .true.
+ hybedmf = .false.
+ hurr_pbl = .true. ! HWRF moninedmf
+ moninq_fac = -1.0 ! HWRF_moninedmf
+ satmedmf = .true.
+ isatmedmf = 1
+ rlmx = 300.
+ elmx = 300.
+ sfc_rlm = 1
+ random_clds = .false.
+ trans_trac = .true.
+ cnvcld = .true.
+ shal_cnv = @[shal_cnv_nml] !Shallow convection
+ do_deep = @[do_deep_nml]
+ imfshalcnv = 2
+ imfdeepcnv = 2
+ clam_deep = 0.1
+ betal_deep = 0.05
+ betas_deep = 0.05
+ cdmbgwd = 0.88, 0.04
+ sfc_z0_type = 6
+ prslrd0 = 0.
+ ivegsrc = 1
+ isot = 1
+ lsm = 1
+ iopt_dveg = 2
+ iopt_crs = 1
+ iopt_btr = 1
+ iopt_run = 1
+ iopt_sfc = 1
+ iopt_frz = 1
+ iopt_inf = 1
+ iopt_rad = 1
+ iopt_alb = 2
+ iopt_snf = 4
+ iopt_tbot = 2
+ iopt_stc = 1
+ debug = .false.
+ oz_phys = .false.
+ oz_phys_2015 = .true.
+ nst_anl = .true.
+ nstf_name = @[nstf_n1],@[nstf_n2],@[nstf_n3],@[nstf_n4],@[nstf_n5]
+ cplflx = @[cplflx]
+ cplice = .false.
+ cplocn2atm = @[cplocn2atm]
+ cplwav = @[cplwav]
+ cplwav2atm = @[cplwav2atm]
+ cpl_imp_mrg = @[merge_import]
+ psautco = 0.0008, 0.0005
+ prautco = 0.00015, 0.00015
+ iau_delthrs = 6
+ iaufhrs = 30
+ iau_inc_files = ''
+ iau_drymassfixer = .false.
+ lgfdlmprad = .true.
+ effr_in = .true.
+ do_sppt = .false.
+ do_shum = .false.
+ do_skeb = .false.
+ lndp_type = 0
+ n_var_lndp = 0
+ do_ca = .false.
+ ca_sgs = .false.
+ nca = 1
+ ncells = 5
+ nlives = 12
+ nseed = 1
+ nfracseed = 0.5
+ ca_trigger = .false.
+ ca_entr = .false.
+ ca_closure = .false.
+ ca_global = .false.
+ nca_g = 1
+ ncells_g = 1
+ nlives_g = 100
+ nseed_g = 100
+ ca_smooth = .false.
+ nspinup = 1
+ iseed_ca = 1
+ nsmooth = 100
+ ca_amplitude = 0.35
+ print_diff_pgr = .true.
+/
+
+&gfdl_cloud_microphysics_nml
+ sedi_transport = .false.
+ do_sedi_heat = .false.
+ rad_snow = .true.
+ rad_graupel = .true.
+ rad_rain = .true.
+ const_vi = .false.
+ const_vs = .false.
+ const_vg = .false.
+ const_vr = .false.
+ vi_max = 1.
+ vs_max = 2.
+ vg_max = 12.
+ vr_max = 12.
+ qi_lim = 1.
+ prog_ccn = .false.
+ do_qa = .true.
+ fast_sat_adj = .true.
+ tau_l2v = 180.
+ tau_v2l = 90.
+ tau_g2v = 900.
+ rthresh = 10.e-6 ! This is a key parameter for cloud water
+ dw_land = 0.16
+ dw_ocean = 0.10
+ ql_gen = 1.0e-3
+ ql_mlt = 1.0e-3
+ qi0_crt = 8.0E-5
+ qs0_crt = 1.0e-3
+ tau_i2s = 1000.
+ c_psaci = 0.05
+ c_pgacs = 0.01
+ rh_inc = 0.30
+ rh_inr = 0.30
+ rh_ins = 0.30
+ ccn_l = 300.
+ ccn_o = 100.
+ c_paut = 0.5
+ c_cracw = 0.8
+ use_ppm = .false.
+ use_ccn = .true.
+ mono_prof = .true.
+ z_slope_liq = .true.
+ z_slope_ice = .true.
+ de_ice = .false.
+ fix_negative = .true.
+ icloud_f = 1
+ mp_time = 90.
+/
+
+&interpolator_nml
+ interp_method = 'conserve_great_circle'
+/
+
+&namsfc
+ FNGLAC = "global_glacier.2x2.grb",
+ FNMXIC = "global_maxice.2x2.grb",
+ FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
+ FNSNOC = "global_snoclim.1.875.grb",
+ FNZORC = "igbp"
+ !FNZORC = "global_zorclim.1x1.grb",
+ FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
+ FNALBC2 = "global_albedo4.1x1.grb",
+ FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
+ FNTG3C = "global_tg3clim.2.6x1.5.grb",
+ FNVEGC = "global_vegfrac.0.144.decpercent.grb",
+ FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
+ FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
+ FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
+ FNMSKH = "seaice_newland.grb",
+ FNTSFA = "",
+ FNACNA = "",
+ FNSNOA = "",
+ FNVMNC = "global_shdmin.0.144x0.144.grb",
+ FNVMXC = "global_shdmax.0.144x0.144.grb",
+ FNSLPC = "global_slope.1x1.grb",
+ FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
+ LDEBUG = .true.,
+ FSMCL(2) = 99999
+ FSMCL(3) = 99999
+ FSMCL(4) = 99999
+ FTSFS = 90
+ FAISS = 99999
+ FSNOL = 99999
+ FSICL = 99999
+ FTSFL = 99999
+ FAISL = 99999
+ FVETL = 99999,
+ FSOTL = 99999,
+ FvmnL = 99999,
+ FvmxL = 99999,
+ FSLPL = 99999,
+ FABSL = 99999,
+ FSNOS = 99999,
+ FSICS = 99999,
+/
+
+&nam_stochy
+/
+
+&nam_sfcperts
+/
+
+&cires_ugwp_nml
+ knob_ugwp_solver = 2
+ knob_ugwp_source = 1,1,0,0
+ knob_ugwp_wvspec = 1,25,25,25
+ knob_ugwp_azdir = 2,4,4,4
+ knob_ugwp_stoch = 0,0,0,0
+ knob_ugwp_effac = 1,1,1,1
+ knob_ugwp_doaxyz = 1
+ knob_ugwp_doheat = 1
+ knob_ugwp_dokdis = 1
+ knob_ugwp_ndx4lh = 1
+ knob_ugwp_version = 0
+ launch_level = 25
+/
diff --git a/parm/forecast/regional/model_configure.tmp b/parm/forecast/regional/model_configure.tmp
index 52eb1c465..c7d73587a 100644
--- a/parm/forecast/regional/model_configure.tmp
+++ b/parm/forecast/regional/model_configure.tmp
@@ -1,45 +1,151 @@
-print_esmf: _print_esmf_
-start_year: YR
-start_month: MN
-start_day: DY
-start_hour: H_R
+start_year: @[SYEAR]
+start_month: @[SMONTH]
+start_day: @[SDAY]
+start_hour: @[SHOUR]
start_minute: 0
start_second: 0
-nhours_fcst: NHRS
-dt_atmos: _dt_atmos_
+nhours_fcst: @[FHMAX]
+dt_atmos: @[DT_ATMOS]
calendar: 'julian'
-restart_interval: _restart_interval_
+restart_interval: @[RESTART_INTERVAL]
output_1st_tstep_rst: .false.
-quilting: _quilting_
-write_groups: _write_groups_
-write_tasks_per_group: _write_tasks_per_group_
-write_dopost: _write_dopost_
-output_history: _output_history_
-num_files: 2
-filename_base: 'atm' 'sfc'
-output_file: 'netcdf_parallel' 'netcdf_parallel'
+quilting: @[QUILTING]
+write_groups: @[WRITE_GROUP]
+write_tasks_per_group: @[WRTTASK_PER_GROUP]
+num_files: @[NUM_FILES]
+filename_base: @[FILENAME_BASE]
+output_file: @[OUTPUT_FILE]
+write_dopost: @[WRITE_DOPOST]
+output_history: @[OUTPUT_HISTORY]
ichunk2d: -1
jchunk2d: -1
ichunk3d: -1
jchunk3d: -1
kchunk3d: -1
-ideflate: 1
-nbits: 0
+ideflate: @[IDEFLATE]
+nbits: @[NBITS]
-app_domain: '_app_domain_'
-output_grid: '_OUTPUT_GRID_'
-cen_lon: _CEN_LON_ # central longitude
-cen_lat: _CEN_LAT_ # central latitude
-lon1: _LON1_ # longitude of lower-left
-lat1: _LAT1_ # latitude of lower-left
-lon2: _LON2_ # longitude of upper-right
-lat2: _LAT2_ # latitude of upper-right
-dlon: _DLON_
-dlat: _DLAT_
+output_grid: @[OUTPUT_GRID] # gaussian_grid, global_latlon, regional_latlon, rotated_latlon, lambert_conformal, cubed_sphere_grid
+imo: @[IMO] # number of grid points along longitude/latitude direction
+jmo: @[JMO] # needed for gaussian_grid or global_latlon
+cen_lon: @[CEN_LON] # central longitude/latitude (degrees)
+cen_lat: @[CEN_LAT] # needed for rotated_latlon, lambert_conformal
+lon1: @[LON1] # longitude/latitude of lower-left corner
+lat1: @[LAT1] # needed for regional_latlon, rotated_latlon, lambert_conformal
+lon2: @[LON2] # longitude/latitude of upper-right corner
+lat2: @[LAT2] # needed for regional_latlon, rotated_latlon
+dlon: @[DLON] # grid spacing in longitude/latitude direction (degrees)
+dlat: @[DLAT] # needed for regional_latlon, rotated_latlon
+stdlat1: @[STDLAT1] # latitude of first/second standard parallel (degrees)
+stdlat2: @[STDLAT2] # needed for lambert_conformal
+nx: @[NX] # number of grid cells along x/y-axis
+ny: @[NY] # needed for lambert_conformal
+dx: @[DX] # grid cell size in x/y direction (meters)
+dy: @[DY] # needed for lambert_conformal
-nfhout: 3
-nfhmax_hf: -1
-nfhout_hf: 3
-nsout: -1
-output_fh: -1
+
+output_grid: @[OUTPUT_GRID_2]
+imo: @[IMO_2]
+jmo: @[JMO_2]
+cen_lon: @[CEN_LON_2]
+cen_lat: @[CEN_LAT_2]
+lon1: @[LON1_2]
+lat1: @[LAT1_2]
+lon2: @[LON2_2]
+lat2: @[LAT2_2]
+dlon: @[DLON_2]
+dlat: @[DLAT_2]
+stdlat1: @[STDLAT1_2]
+stdlat2: @[STDLAT2_2]
+nx: @[NX_2]
+ny: @[NY_2]
+dx: @[DX_2]
+dy: @[DY_2]
+
+
+output_grid: @[OUTPUT_GRID_3]
+imo: @[IMO_3]
+jmo: @[JMO_3]
+cen_lon: @[CEN_LON_3]
+cen_lat: @[CEN_LAT_3]
+lon1: @[LON1_3]
+lat1: @[LAT1_3]
+lon2: @[LON2_3]
+lat2: @[LAT2_3]
+dlon: @[DLON_3]
+dlat: @[DLAT_3]
+stdlat1: @[STDLAT1_3]
+stdlat2: @[STDLAT2_3]
+nx: @[NX_3]
+ny: @[NY_3]
+dx: @[DX_3]
+dy: @[DY_3]
+
+
+output_grid: @[OUTPUT_GRID_4]
+imo: @[IMO_4]
+jmo: @[JMO_4]
+cen_lon: @[CEN_LON_4]
+cen_lat: @[CEN_LAT_4]
+lon1: @[LON1_4]
+lat1: @[LAT1_4]
+lon2: @[LON2_4]
+lat2: @[LAT2_4]
+dlon: @[DLON_4]
+dlat: @[DLAT_4]
+stdlat1: @[STDLAT1_4]
+stdlat2: @[STDLAT2_4]
+nx: @[NX_4]
+ny: @[NY_4]
+dx: @[DX_4]
+dy: @[DY_4]
+
+
+output_grid: @[OUTPUT_GRID_5]
+imo: @[IMO_5]
+jmo: @[JMO_5]
+cen_lon: @[CEN_LON_5]
+cen_lat: @[CEN_LAT_5]
+lon1: @[LON1_5]
+lat1: @[LAT1_5]
+lon2: @[LON2_5]
+lat2: @[LAT2_5]
+dlon: @[DLON_5]
+dlat: @[DLAT_5]
+stdlat1: @[STDLAT1_5]
+stdlat2: @[STDLAT2_5]
+nx: @[NX_5]
+ny: @[NY_5]
+dx: @[DX_5]
+dy: @[DY_5]
+
+
+output_grid: @[OUTPUT_GRID_6]
+imo: @[IMO_6]
+jmo: @[JMO_6]
+cen_lon: @[CEN_LON_6]
+cen_lat: @[CEN_LAT_6]
+lon1: @[LON1_6]
+lat1: @[LAT1_6]
+lon2: @[LON2_6]
+lat2: @[LAT2_6]
+dlon: @[DLON_6]
+dlat: @[DLAT_6]
+stdlat1: @[STDLAT1_6]
+stdlat2: @[STDLAT2_6]
+nx: @[NX_6]
+ny: @[NY_6]
+dx: @[DX_6]
+dy: @[DY_6]
+
+
+nfhout: @[NFHOUT] # Output frequency in hours after forecast hour nfhmax_hf
+nfhmax_hf: @[NFHMAX_HF] # Number of forecast hours until output frequency nfhout takes affect
+nfhout_hf: @[NFHOUT_HF] # Output frequency in hours until forecast hour nfhmax_hf
+nsout: @[NSOUT] # Output frequency in time steps (positive values override nfhout and nfhout_hf)
+output_fh: @[OUTPUT_FH] # Output forecast hours controlled by output_fh (see notes below)
+# a) An array of output_fh means to output history files at those forecast time (e.g., "output_fh: 0 1 2 3 12 24 48")
+# If the first elelment is zero, it means the first time step output
+# b) If there are two elements in output_fh and the second one is -1, then the first element is output frequency. e.g.
+# For example, "output_fh: 6 -1" will output the history file every 6 hours.
diff --git a/parm/forecast/regional/nems.configure.atmonly b/parm/forecast/regional/nems.configure.atmonly
index bb49e1ee8..da7560ff7 100644
--- a/parm/forecast/regional/nems.configure.atmonly
+++ b/parm/forecast/regional/nems.configure.atmonly
@@ -1,3 +1,5 @@
+logKindFlag: ESMF_LOGKIND_MULTI
+
EARTH_component_list: ATM
ATM_model: fv3
diff --git a/parm/forecast/regional/nems.configure.cdeps.tmp b/parm/forecast/regional/nems.configure.cdeps.tmp
index 5390f2485..2f5462a2f 100644
--- a/parm/forecast/regional/nems.configure.cdeps.tmp
+++ b/parm/forecast/regional/nems.configure.cdeps.tmp
@@ -1,3 +1,5 @@
+logKindFlag: ESMF_LOGKIND_MULTI
+
# component list
EARTH_component_list: MED ATM OCN
diff --git a/parm/forecast/regional/nems.configure.cpl.tmp b/parm/forecast/regional/nems.configure.cpl.tmp
index 479f2a783..3d2774ac4 100644
--- a/parm/forecast/regional/nems.configure.cpl.tmp
+++ b/parm/forecast/regional/nems.configure.cpl.tmp
@@ -1,3 +1,5 @@
+logKindFlag: ESMF_LOGKIND_MULTI
+
# component list
_EARTH_component_list_
@@ -108,6 +110,8 @@ WAV_attributes::
Diagnostic = 0
OverwriteSlice = false
merge_import = .true.
+ mask_value_water = 1
+ mask_value_land = 0
::
# The following are only used by the hycom ocean model. #
diff --git a/parm/forecast/regional_hwrf/diag_table.tmp b/parm/forecast/regional_hwrf/diag_table.tmp
deleted file mode 100644
index 874cd0285..000000000
--- a/parm/forecast/regional_hwrf/diag_table.tmp
+++ /dev/null
@@ -1,354 +0,0 @@
-#output files
-"grid_spec", -1, "months", 1, "days", "time"
-#"atmos_4xdaily", 1, "hours", 1, "days", "time"
-"atmos_static", -1, "hours", 1, "hours", "time"
-"fv3_history", 0, "hours", 1, "hours", "time"
-"fv3_history2d", 0, "hours", 1, "hours", "time"
-#"ref3D", 0, "hours", 1, "hours", "time"
-#"maxmin2D", 1, "hours", 1, "hours", "time"
-
-#
-#=======================
-# ATMOSPHERE DIAGNOSTICS
-#=======================
-###
-# grid_spec
-###
- "dynamics", "grid_lon", "grid_lon", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lat", "grid_lat", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_lont", "grid_lont", "grid_spec", "all", .false., "none", 2,
- "dynamics", "grid_latt", "grid_latt", "grid_spec", "all", .false., "none", 2,
- "dynamics", "area", "area", "grid_spec", "all", .false., "none", 2,
-###
-# 4x daily output
-###
-# "dynamics", "slp", "slp", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort850", "vort850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort500", "vort500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vort200", "vort200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "us", "us", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u1000", "u1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u850", "u850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u700", "u700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u500", "u500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u200", "u200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u100", "u100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u50", "u50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "u10", "u10", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "vs", "vs", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v1000", "v1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v850", "v850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v700", "v700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v500", "v500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v200", "v200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v100", "v100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v50", "v50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "v10", "v10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "tm", "tm", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t1000", "t1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t850", "t850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t700", "t700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t500", "t500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t200", "t200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t100", "t100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t50", "t50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "t10", "t10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "z1000", "z1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z850", "z850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z700", "z700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z500", "z500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z200", "z200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z100", "z100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z50", "z50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "z10", "z10", "atmos_4xdaily", "all", .false., "none", 2
-####
-#"dynamics", "w1000", "w1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w850", "w850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w700", "w700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w500", "w500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "w200", "w200", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "q1000", "q1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q850", "q850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q700", "q700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q500", "q500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q200", "q200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q100", "q100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q50", "q50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "q10", "q10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "rh1000", "rh1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh850", "rh850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh700", "rh700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh500", "rh500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "rh200", "rh200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg1000", "omg1000", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg850", "omg850", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg700", "omg700", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg500", "omg500", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg200", "omg200", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg100", "omg100", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg50", "omg50", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "omg10", "omg10", "atmos_4xdaily", "all", .false., "none", 2
-####
-# "dynamics", "cape", "sbcape", "atmos_4xdaily", "all", .false., "none", 2
-# "dynamics", "cin", "sbcin", "atmos_4xdaily", "all", .false., "none", 2
-###
-# gfs static data
-###
- "dynamics", "pk", "pk", "atmos_static", "all", .false., "none", 2
- "dynamics", "bk", "bk", "atmos_static", "all", .false., "none", 2
- "dynamics", "hyam", "hyam", "atmos_static", "all", .false., "none", 2
- "dynamics", "hybm", "hybm", "atmos_static", "all", .false., "none", 2
- "dynamics", "zsurf", "zsurf", "atmos_static", "all", .false., "none", 2
-###
-# FV3 variabls needed for NGGPS evaluation
-###
-"gfs_dyn", "ucomp", "ugrd", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "vcomp", "vgrd", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "sphum", "spfh", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "temp", "tmp", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "liq_wat", "clwmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "o3mr", "o3mr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "delp", "dpres", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "delz", "delz", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "w", "dzdt", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ice_wat", "icmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "rainwat", "rwmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "snowwat", "snmr", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "graupel", "grle", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "q_rimef", "qrim", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ps", "pressfc", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "hs", "hgtsfc", "fv3_history", "all", .false., "none", 2
-#"gfs_dyn", "ice_nc", "nicp", "fv3_history", "all", .false., "none", 2
-#"gfs_dyn", "rain_nc", "ntrnc", "fv3_history", "all", .false., "none", 2
-
-###
-# Max hourly fields
-###
-"gfs_dyn", "wmaxup", "upvvelmax", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "wmaxdn", "dnvvelmax", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmax03", "uhmax03", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmax25", "uhmax25", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmin03", "uhmin03", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "uhmin25", "uhmin25", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvort01", "maxvort01", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvort02", "maxvort02", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "maxvorthy1", "maxvorthy1", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "ustm", "ustm", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "vstm", "vstm", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "srh01", "srh01", "fv3_history", "all", .false., "none", 2
-"gfs_dyn", "srh03", "srh03", "fv3_history", "all", .false., "none", 2
-
-"gfs_phys", "u10max", "u10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v10max", "v10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spd10max", "spd10max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "refdmax", "refdmax", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "refdmax263k", "refdmax263k", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "t02max", "t02max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "t02min", "t02min", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "rh02max", "rh02max", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "rh02min", "rh02min", "fv3_history2d", "all", .false., "none", 2
-
-
-"gfs_phys", "ALBDO_ave", "albdo_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cnvprcp_ave", "cprat_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cnvprcpb_ave", "cpratb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "totprcp_ave", "prate_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "totprcpb_ave", "prateb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DLWRF", "dlwrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DLWRFI", "dlwrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRF", "ulwrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRFI", "ulwrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRF", "dswrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRFI", "dswrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRF", "uswrf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRFI", "uswrf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "DSWRFtoa", "dswrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "USWRFtoa", "uswrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ULWRFtoa", "ulwrf_avetoa","fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "gflux_ave", "gflux_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "hpbl", "hpbl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "lhtfl_ave", "lhtfl_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "shtfl_ave", "shtfl_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pwat", "pwatclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "soilm", "soilm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_aveclm", "tcdc_aveclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avebndcl", "tcdc_avebndcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avehcl", "tcdc_avehcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avelcl", "tcdc_avelcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDC_avemcl", "tcdc_avemcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TCDCcnvcl", "tcdccnvcl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PREScnvclt", "prescnvclt", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PREScnvclb", "prescnvclb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avehct", "pres_avehct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avehcb", "pres_avehcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avehct", "tmp_avehct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avemct", "pres_avemct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avemcb", "pres_avemcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avemct", "tmp_avemct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avelct", "pres_avelct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "PRES_avelcb", "pres_avelcb", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "TEMP_avelct", "tmp_avelct", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "u-gwd_ave", "u-gwd_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v-gwd_ave", "v-gwd_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "dusfc", "uflx_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "dvsfc", "vflx_ave", "fv3_history2d", "all", .false., "none", 2
-
-"gfs_phys", "psurf", "pressfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "u10m", "ugrd10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "v10m", "vgrd10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "crain", "crain", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_ice", "f_ice", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_rain", "f_rain", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "f_rimef", "f_rimef", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tprcp", "tprcp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "hgtsfc", "orog", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "weasd", "weasd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "f10m", "f10m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "q2m", "spfh2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "t2m", "tmp2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tsfc", "tmpsfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "vtype", "vtype", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "stype", "sotyp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slmsksfc", "land", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "vfracsfc", "veg", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "zorlsfc", "sfcr", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "uustar", "fricv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt1", "soilt1" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt2", "soilt2" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt3", "soilt3" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilt4", "soilt4" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw1", "soilw1" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw2", "soilw2" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw3", "soilw3" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "soilw4", "soilw4" "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_1", "soill1", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_2", "soill2", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_3", "soill3", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slc_4", "soill4", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "slope", "sltyp", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alnsf", "alnsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alnwf", "alnwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alvsf", "alvsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "alvwf", "alvwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "canopy", "cnwat", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "facsf", "facsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "facwf", "facwf", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "ffhh", "ffhh", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "ffmm", "ffmm", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "fice", "icec", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "hice", "icetk", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "snoalb", "snoalb", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "shdmax", "shdmax", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "shdmin", "shdmin", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "snowd", "snod", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tg3", "tg3", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tisfc", "tisfc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "tref", "tref", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "z_c", "zc", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "c_0", "c0", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "c_d", "cd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "w_0", "w0", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "w_d", "wd", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xt", "xt", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xz", "xz", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "dt_cool", "dtcool", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xs", "xs", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xu", "xu", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xv", "xv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xtts", "xtts", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "xzts", "xzts", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "d_conv", "dconv", "fv3_history2d", "all", .false., "none", 2
-"gfs_sfc", "qrain", "qrain", "fv3_history2d", "all", .false., "none", 2
-
-"gfs_phys", "acond", "acond", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cduvb_ave", "cduvb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cpofp", "cpofp", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "duvb_ave", "duvb_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csdlf_ave", "csdlf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csusf_ave", "csusf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csusf_avetoa", "csusftoa", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csdsf_ave", "csdsf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csulf_ave", "csulf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "csulf_avetoa", "csulftoa", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "cwork_ave", "cwork_aveclm", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "evbs_ave", "evbs_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "evcw_ave", "evcw_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "fldcp", "fldcp", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "hgt_hyblev1", "hgt_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfh_hyblev1", "spfh_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ugrd_hyblev1", "ugrd_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vgrd_hyblev1", "vgrd_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmp_hyblev1", "tmp_hyblev1", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "gfluxi", "gflux", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "lhtfl", "lhtfl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "shtfl", "shtfl", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pevpr", "pevpr", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "pevpr_ave", "pevpr_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sbsno_ave", "sbsno_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sfexc", "sfexc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "snohf", "snohf", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "snowc_ave", "snowc_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfhmax2m", "spfhmax_max2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "spfhmin2m", "spfhmin_min2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmpmax2m", "tmax_max2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "tmpmin2m", "tmin_min2m", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "ssrun_acc", "ssrun_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "sunsd_acc", "sunsd_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "watr_acc", "watr_acc", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "wilt", "wilt", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vbdsf_ave", "vbdsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "vddsf_ave", "vddsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "nbdsf_ave", "nbdsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "nddsf_ave", "nddsf_ave", "fv3_history2d", "all", .false., "none", 2
-"gfs_phys", "trans_ave", "trans_ave", "fv3_history2d", "all", .false., "none", 2
-#HWRF
-#"gfs_phys", "cleffr", "cleffr", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "cieffr", "cieffr", "fv3_history2d", "all", .false., "none", 2
-#"gfs_phys", "cseffr", "cseffr", "fv3_history2d", "all", .false., "none", 2
-#
-# Reflectivity from microphysics
-"gfs_phys", "refl_10cm", "refl_10cm", "fv3_history2d", "all", .false., "none", 2
-
-#Max/Min must be kept in separate files. Time is controlled by diag_table
-# "dynamics", "uh25", "MXUPHL2_5km", "maxmin2D", "all", max, "none", 2
-# "dynamics", "uh25", "MNUPHL2_5km", "maxmin2D", "all", min, "none", 2
-# "dynamics", "max_reflectivity", "MAXREFC", "maxmin2D", "all", max, "none", 2
-# "dynamics", "base_reflectivity", "MAXREF_1km", "maxmin2D", "all", max, "none", 2
-#
-#=============================================================================================
-#
-#====> This file can be used with diag_manager/v2.0a (or higher) <====
-#
-#
-# FORMATS FOR FILE ENTRIES (not all input values are used)
-# ------------------------
-#
-#"file_name", output_freq, "output_units", format, "time_units", "long_name",
-#
-#
-#output_freq: > 0 output frequency in "output_units"
-# = 0 output frequency every time step
-# =-1 output frequency at end of run
-#
-#output_units = units used for output frequency
-# (years, months, days, minutes, hours, seconds)
-#
-#time_units = units used to label the time axis
-# (days, minutes, hours, seconds)
-#
-#
-# FORMAT FOR FIELD ENTRIES (not all input values are used)
-# ------------------------
-#
-#"module_name", "field_name", "output_name", "file_name" "time_sampling", time_avg, "other_opts", packing
-#
-#time_avg = .true. or .false.
-#
-#packing = 1 double precision
-# = 2 float
-# = 4 packed 16-bit integers
-# = 8 packed 1-byte (not tested?)
diff --git a/parm/forecast/regional_hwrf/field_table b/parm/forecast/regional_hwrf/field_table
deleted file mode 100644
index 420f4a48a..000000000
--- a/parm/forecast/regional_hwrf/field_table
+++ /dev/null
@@ -1,36 +0,0 @@
-# added by FRE: sphum must be present in atmos
-# specific humidity for moist runs
- "TRACER", "atmos_mod", "sphum"
- "longname", "specific humidity"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic cloud water mixing ratio
- "TRACER", "atmos_mod", "liq_wat"
- "longname", "cloud water mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
- "TRACER", "atmos_mod", "ice_wat"
- "longname", "cloud ice mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic rain water mixing ratio
- "TRACER", "atmos_mod", "rainwat"
- "longname", "rain mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic mass weighted rime factor
- "TRACER", "atmos_mod", "q_rimef"
- "longname", "mass weighted rime factor"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# prognostic ozone mixing ratio tracer
- "TRACER", "atmos_mod", "o3mr"
- "longname", "ozone mixing ratio"
- "units", "kg/kg"
- "profile_type", "fixed", "surface_value=1.e30" /
-# non-prognostic cloud amount
- "TRACER", "atmos_mod", "cld_amt"
- "longname", "cloud amount"
- "units", "1"
- "profile_type", "fixed", "surface_value=1.e30" /
-
diff --git a/parm/forecast/regional_hwrf/input.nml.tmp b/parm/forecast/regional_hwrf/input.nml.tmp
deleted file mode 100644
index a02853535..000000000
--- a/parm/forecast/regional_hwrf/input.nml.tmp
+++ /dev/null
@@ -1,373 +0,0 @@
- &atmos_model_nml
- blocksize = _blocksize_
- chksum_debug = .false.
- dycore_only = .false.
- avg_max_length = 3600.
- ccpp_suite = '_ccpp_suite_'
-/
-
- &diag_manager_nml
- prepend_date = .false.
-/
-
- &mpp_io_nml
- header_buffer_val = 16384,
- global_field_on_root_pe = .true.,
- io_clocks_on = .false.,
- shuffle = 0,
- deflate_level = _deflate_level_,
- cf_compliance = .false.
-/
-
- &fms_io_nml
- checksum_required = .false.
- max_files_r = 100,
- max_files_w = 100,
-/
-
- &fms2_io_nml
-netcdf_default_format="netcdf4"
-/
-
- &fms_nml
- clock_grain = 'ROUTINE',
- domains_stack_size = 30000000,
- print_memory_usage = .false.
-/
-
- &fv_grid_nml
- grid_file = 'INPUT/grid_spec.nc'
-/
-
- &fv_core_nml
- !layout = 64,30
- !layout = 40,30
- layout = _layoutx_,_layouty_
- io_layout = 1,1
- npx = _npx_
- npy = _npy_
- ntiles = 1
- npz = _npz_
- !grid_type = -1
- make_nh = .F.
- fv_debug = .F.
- range_warn = .T.
- reset_eta = .F.
- n_sponge = 24
- nudge_qv = .F.
- nudge_dz = .F.
- tau = 5.
- rf_cutoff = 50.e2
- d2_bg_k1 = 0.20
- d2_bg_k2 = 0.15
- kord_tm = -11
- kord_mt = 11
- kord_wz = 11
- kord_tr = 11
- hydrostatic = .F.
- phys_hydrostatic = .F.
- use_hydro_pressure = .F.
- beta = 0.
- a_imp = 1.
- p_fac = 0.1
- k_split = _k_split_
- n_split = _n_split_
- nwat = 4
- na_init = _na_init_
- d_ext = 0.0
- dnats = 1
- fv_sg_adj = 300
- d2_bg = 0.
- nord = 2
- dddmp = 0.1
- d4_bg = 0.15
- vtdm4 = 0.04
- delt_max = 0.008
- ke_bg = 0.
- do_vort_damp = .T.
- external_ic = _external_ic_
- external_eta = .T.
- gfs_phil = .false.
- nggps_ic = _nggps_ic_
- mountain = _mountain_
- ncep_ic = .F.
- d_con = 1.0
- hord_mt = 6
- hord_vt = 6
- hord_tm = 6
- hord_dp = -6
- hord_tr = 8
- adjust_dry_mass = .F.
- consv_te = 0.
- do_sat_adj = .F.
- consv_am = .F.
- fill = .T.
- dwind_2d = .F.
- print_freq = 3
- warm_start = _warm_start_
- no_dycore = .false.
- z_tracer = .T.
- agrid_vel_rst = .true.
- read_increment = .F.
- res_latlon_dynamics = "fv3_increment.nc"
- write_3d_diags = .true.
-
- do_schmidt = .true.
- target_lat = _target_lat_
- target_lon = _target_lon_
- stretch_fac = _stretch_fac_
- regional = .true.
- bc_update_interval = _bc_update_interval_
- nrows_blend = _nrows_blend_
-
- full_zs_filter = .F. !unreleased feature
- n_zs_filter = 0 ! safety
- nord_zs_filter = 4
-/
-
- &surf_map_nml
- zero_ocean = .F.
- cd4 = 0.15
- cd2 = -1
- n_del2_strong = 0
- n_del2_weak = 15
- n_del4 = 2
- max_slope = 0.4
- peak_fac = 1.
-/
-
- &external_ic_nml
- filtered_terrain = .true.
- levp = _levp_
- gfs_dwinds = .true.
- checker_tr = .F.
- nt_checker = 0
-/
-
- &gfs_physics_nml
- fhzero = 3.
- ldiag3d = .false.
- lradar = .true.
- avg_max_length = 3600.
- h2o_phys = .true.
- fhcyc = 0.
- use_ufo = .true.
- pre_rad = .false.
- imp_physics = 15 ! F-A MP scheme
- RHGRD = 1.0 ! F-A
- spec_adv = .true. ! F-A
- icloud = 3 ! Thompson cloud fraction
- iovr_lw = 4 ! HWRF RRTMG
- iovr_sw = 4 ! HWRF RRTMG
- hwrf_samfdeep = .true. ! HWRF SASdeep
- hwrf_samfshal = .true. ! HWRF SASshal
- asolfac_deep = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- asolfac_shal = 0.89 ! HWRF SASdeep; GFS SAS:0.958
- hurr_pbl = .T. ! HWRF moninedmf
- moninq_fac = -1.0 ! HWRF moninedmf
- pdfcld = .false.
- fhswr = _fhswr_
- fhlwr = _fhlwr_
- ialb = 1
- iems = 1
- iaer = 111
- ico2 = 2
- isubc_sw = 2
- isubc_lw = 2
- isol = 2
- lwhtr = .true.
- swhtr = .true.
- cnvgwd = .true.
- shal_cnv = .true. ! HWRF SAS Shallow convection
- cal_pre = .false.
- redrag = .true.
- dspheat = .true.
- hybedmf = .true.
- satmedmf = .false.
- random_clds = .false.
- trans_trac = .true.
- cnvcld = .true.
- imfshalcnv = 2
- imfdeepcnv = 2
- cdmbgwd = 0.88, 0.04
- sfc_z0_type = 4 !HWRF
- prslrd0 = 0.
- ivegsrc = 1
- isot = 1
- lsm = 4 !HWRF
- iopt_dveg = 2
- iopt_crs = 1
- iopt_btr = 1
- iopt_run = 1
- iopt_sfc = 1
- iopt_frz = 1
- iopt_inf = 1
- iopt_rad = 1
- iopt_alb = 2
- iopt_snf = 4
- iopt_tbot = 2
- iopt_stc = 1
- debug = .false.
- oz_phys = .F.
- oz_phys_2015 = .T.
- nst_anl = .true.
- nstf_name = _nstf_n1_,_nstf_n2_,_nstf_n3_,_nstf_n4_,_nstf_n5_
- cplflx = _cplflx_
- cplice = .false.
- cplocn2atm = _cplocn2atm_
- cplwav = _cplwav_
- cplwav2atm = _cplwav2atm_
- cpl_imp_mrg = _merge_import_
- psautco = 0.0008, 0.0005
- prautco = 0.00015, 0.00015
- iau_delthrs = 6
- iaufhrs = 30
- iau_inc_files = ''
- iau_drymassfixer = .false.
- do_deep = .true.
- lgfdlmprad = .true.
- effr_in = .true.
- do_sppt = .F.
- do_shum = .F.
- do_skeb = .F.
- lndp_type = 0
- n_var_lndp = 0
- do_ca = .false.
- ca_sgs = .false.
- nca = 1
- ncells = 5
- nlives = 12
- nseed = 1
- nfracseed = 0.5
- ca_trigger = .false.
- ca_entr = .false.
- ca_closure = .false.
- ca_global = .false.
- nca_g = 1
- ncells_g = 1
- nlives_g = 100
- nseed_g = 100
- ca_smooth = .false.
- nspinup = 1
- iseed_ca = 1
- nsmooth = 100
- ca_amplitude = 0.35
- print_diff_pgr = .true.
-/
-
- &gfdl_cloud_microphysics_nml
- sedi_transport = .false.
- do_sedi_heat = .false.
- rad_snow = .true.
- rad_graupel = .true.
- rad_rain = .true.
- const_vi = .F.
- const_vs = .F.
- const_vg = .F.
- const_vr = .F.
- vi_max = 1.
- vs_max = 2.
- vg_max = 12.
- vr_max = 12.
- qi_lim = 1.
- prog_ccn = .false.
- do_qa = .true.
- fast_sat_adj = .true.
- tau_l2v = 180.
- tau_v2l = 90.
- tau_g2v = 900.
- rthresh = 10.e-6 ! This is a key parameter for cloud water
- dw_land = 0.16
- dw_ocean = 0.10
- ql_gen = 1.0e-3
- ql_mlt = 1.0e-3
- qi0_crt = 8.0E-5
- qs0_crt = 1.0e-3
- tau_i2s = 1000.
- c_psaci = 0.05
- c_pgacs = 0.01
- rh_inc = 0.30
- rh_inr = 0.30
- rh_ins = 0.30
- ccn_l = 300.
- ccn_o = 100.
- c_paut = 0.5
- c_cracw = 0.8
- use_ppm = .false.
- use_ccn = .true.
- mono_prof = .true.
- z_slope_liq = .true.
- z_slope_ice = .true.
- de_ice = .false.
- fix_negative = .true.
- icloud_f = 1
- mp_time = 90.
-/
-
- &interpolator_nml
- interp_method = 'conserve_great_circle'
-/
-
- &namsfc
- FNGLAC = "global_glacier.2x2.grb",
- FNMXIC = "global_maxice.2x2.grb",
- FNTSFC = "RTGSST.1982.2012.monthly.clim.grb",
- FNSNOC = "global_snoclim.1.875.grb",
- FNZORC = "igbp"
- !FNZORC = "global_zorclim.1x1.grb",
- FNALBC = "global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb",
- FNALBC2 = "global_albedo4.1x1.grb",
- FNAISC = "CFSR.SEAICE.1982.2012.monthly.clim.grb",
- FNTG3C = "global_tg3clim.2.6x1.5.grb",
- FNVEGC = "global_vegfrac.0.144.decpercent.grb",
- FNVETC = "global_vegtype.igbp.t1534.3072.1536.rg.grb",
- FNSOTC = "global_soiltype.statsgo.t1534.3072.1536.rg.grb",
- FNSMCC = "global_soilmgldas.t1534.3072.1536.grb",
- FNMSKH = "seaice_newland.grb",
- FNTSFA = "",
- FNACNA = "",
- FNSNOA = "",
- FNVMNC = "global_shdmin.0.144x0.144.grb",
- FNVMXC = "global_shdmax.0.144x0.144.grb",
- FNSLPC = "global_slope.1x1.grb",
- FNABSC = "global_mxsnoalb.uariz.t1534.3072.1536.rg.grb",
- LDEBUG =.true.,
- FSMCL(2) = 99999
- FSMCL(3) = 99999
- FSMCL(4) = 99999
- FTSFS = 90
- FAISS = 99999
- FSNOL = 99999
- FSICL = 99999
- FTSFL = 99999
- FAISL = 99999
- FVETL = 99999,
- FSOTL = 99999,
- FvmnL = 99999,
- FvmxL = 99999,
- FSLPL = 99999,
- FABSL = 99999,
- FSNOS = 99999,
- FSICS = 99999,
-/
-
- &nam_stochy
-/
-
- &nam_sfcperts
-/
-
- &cires_ugwp_nml
- knob_ugwp_solver = 2
- knob_ugwp_source = 1,1,0,0
- knob_ugwp_wvspec = 1,25,25,25
- knob_ugwp_azdir = 2,4,4,4
- knob_ugwp_stoch = 0,0,0,0
- knob_ugwp_effac = 1,1,1,1
- knob_ugwp_doaxyz = 1
- knob_ugwp_doheat = 1
- knob_ugwp_dokdis = 1
- knob_ugwp_ndx4lh = 1
- knob_ugwp_version = 0
- launch_level = 25
-/
diff --git a/parm/forecast/regional_hwrf/model_configure.tmp b/parm/forecast/regional_hwrf/model_configure.tmp
deleted file mode 100644
index 52eb1c465..000000000
--- a/parm/forecast/regional_hwrf/model_configure.tmp
+++ /dev/null
@@ -1,45 +0,0 @@
-print_esmf: _print_esmf_
-start_year: YR
-start_month: MN
-start_day: DY
-start_hour: H_R
-start_minute: 0
-start_second: 0
-nhours_fcst: NHRS
-dt_atmos: _dt_atmos_
-calendar: 'julian'
-restart_interval: _restart_interval_
-output_1st_tstep_rst: .false.
-
-quilting: _quilting_
-write_groups: _write_groups_
-write_tasks_per_group: _write_tasks_per_group_
-write_dopost: _write_dopost_
-output_history: _output_history_
-num_files: 2
-filename_base: 'atm' 'sfc'
-output_file: 'netcdf_parallel' 'netcdf_parallel'
-ichunk2d: -1
-jchunk2d: -1
-ichunk3d: -1
-jchunk3d: -1
-kchunk3d: -1
-ideflate: 1
-nbits: 0
-
-app_domain: '_app_domain_'
-output_grid: '_OUTPUT_GRID_'
-cen_lon: _CEN_LON_ # central longitude
-cen_lat: _CEN_LAT_ # central latitude
-lon1: _LON1_ # longitude of lower-left
-lat1: _LAT1_ # latitude of lower-left
-lon2: _LON2_ # longitude of upper-right
-lat2: _LAT2_ # latitude of upper-right
-dlon: _DLON_
-dlat: _DLAT_
-
-nfhout: 3
-nfhmax_hf: -1
-nfhout_hf: 3
-nsout: -1
-output_fh: -1
diff --git a/parm/forecast/regional_hwrf/nems.configure.atmonly b/parm/forecast/regional_hwrf/nems.configure.atmonly
deleted file mode 100644
index fe59cc645..000000000
--- a/parm/forecast/regional_hwrf/nems.configure.atmonly
+++ /dev/null
@@ -1,18 +0,0 @@
-EARTH_component_list: ATM
-
-ATM_model: fv3
-
-runSeq::
- ATM
-::
-
-ATM_attributes::
-::
-
-DRIVER_attributes::
- start_type = startup
-::
-
-ALLCOMP_attributes::
- mediator_read_restart = false
-::
diff --git a/parm/forecast/regional_hwrf/nems.configure.cpl.tmp b/parm/forecast/regional_hwrf/nems.configure.cpl.tmp
deleted file mode 100644
index a456d63c9..000000000
--- a/parm/forecast/regional_hwrf/nems.configure.cpl.tmp
+++ /dev/null
@@ -1,128 +0,0 @@
-# component list
-_EARTH_component_list_
-
-# component models
-_ATM_model_component_
-_OCN_model_component_
-_WAV_model_component_
-_MED_model_component_
-
-# component petLists
-_ATM_petlist_bounds_
-_OCN_petlist_bounds_
-_MED_petlist_bounds_
-_WAV_petlist_bounds_
-
-# run sequence
-runSeq::
- @_cpl_dt_
- _runSeq_ALL_
- @
-::
-
-DRIVER_attributes::
- start_type = startup
-::
-
-MED_attributes::
- _ATM_model_attribute_
- _OCN_model_attribute_
- _WAV_model_attribute_
- _MED_model_attribute_
- history_n = 1
- history_option = nhours
- history_ymd = -999
- coupling_mode = hafs
- system_type = ufs
- normalization = none
- merge_type = copy
-::
-
-ALLCOMP_attributes::
- _ATM_model_attribute_
- _OCN_model_attribute_
- _WAV_model_attribute_
- _MED_model_attribute_
- ScalarFieldCount = 3
- ScalarFieldIdxGridNX = 1
- ScalarFieldIdxGridNY = 2
- ScalarFieldIdxNextSwCday = 3
- ScalarFieldName = cpl_scalars
- start_type = startup
- case_name = ufs.hafs
- restart_n = 1
- restart_option = nhours
- restart_ymd = -999
- dbug_flag = 1
- use_coldstart = true
- # orb_* for cdeps coupling with data atmosphere
- orb_eccen = 1.e36
- orb_iyear = 2000
- orb_iyear_align = 2000
- orb_mode = fixed_year
- orb_mvelp = 1.e36
- orb_obliq = 1.e36
- mediator_read_restart = false
- mediator_present = true
-::
-
-# component attributes
-
-ATM_attributes::
- Verbosity = 1
- Diagnostic = 0
-::
-
-OCN_attributes::
- Verbosity = 1
- Diagnostic = 0
- cdf_impexp_freq = 3
- cpl_hour = 0
- cpl_min = 0
- cpl_sec = _cpl_dt_
- base_dtg = _base_dtg_
- merge_import = _merge_import_
- skip_first_import = .true.
- hycom_arche_output = .false.
- hyc_esmf_exp_output = .true.
- hyc_esmf_imp_output = .true.
- import_diagnostics = .false.
- import_setting = flexible
- hyc_impexp_file = nems.configure
- espc_show_impexp_minmax = .true.
- ocean_start_dtg = _ocean_start_dtg_
- start_hour = 0
- start_min = 0
- start_sec = 0
- end_hour = _end_hour_
- end_min = 0
- end_sec = 0
-::
-
-WAV_attributes::
- Verbosity = 1
- Diagnostic = 0
- OverwriteSlice = false
- merge_import = .true.
-::
-
-ocn_export_fields::
- 'sst' 'sea_surface_temperature' 'K'
- 'mask' 'ocean_mask' '1'
-::
-
-ocn_import_fields::
-# 'u10' 'inst_zonal_wind_height10m' 'm_s-1'
-# 'v10' 'inst_merid_wind_height10m' 'm_s-1'
- 'taux10' 'mean_zonal_moment_flx_atm' 'N_m-2'
- 'tauy10' 'mean_merid_moment_flx_atm' 'N_m-2'
-# 'airtmp' 'inst_temp_height2m' 'K'
-# 'airhum' 'inst_spec_humid_height2m' 'kg_kg-1'
- 'prcp' 'mean_prec_rate' 'kg_m-2_s-1'
- 'swflxd' 'mean_net_sw_flx' 'W_m-2'
- 'lwflxd' 'mean_net_lw_flx' 'W_m-2'
- 'mslprs' 'inst_pres_height_surface' 'Pa'
-# 'gt' 'inst_temp_height_surface' 'K'
- 'sensflx' 'mean_sensi_heat_flx' 'W_m-2'
- 'latflx' 'mean_laten_heat_flx' 'W_m-2'
-::
diff --git a/parm/hafs.conf b/parm/hafs.conf
index 465ccf693..938e3ca2d 100644
--- a/parm/hafs.conf
+++ b/parm/hafs.conf
@@ -16,10 +16,14 @@ HOLDVARS={com}/{stormlabel}.holdvars.txt
RUNhafs={SUBEXPT}
# Prefix to prepend to most output files in the COM directory.
-out_prefix={vit[stormnamelc]}{vit[stnum]:02d}{vit[basin1lc]}.{vit[YMDH]}
-out_prefix_nodate={vit[stormnamelc]}{vit[stnum]:02d}{vit[basin1lc]}
-old_out_prefix={oldvit[stormnamelc]}{oldvit[stnum]:02d}{oldvit[basin1lc]}.{oldvit[YMDH]}
-old_out_prefix_nodate={oldvit[stormnamelc]}{oldvit[stnum]:02d}{oldvit[basin1lc]}
+#out_prefix={vit[stormnamelc]}{vit[stnum]:02d}{vit[basin1lc]}.{vit[YMDH]}
+#out_prefix_nodate={vit[stormnamelc]}{vit[stnum]:02d}{vit[basin1lc]}
+#old_out_prefix={oldvit[stormnamelc]}{oldvit[stnum]:02d}{oldvit[basin1lc]}.{oldvit[YMDH]}
+#old_out_prefix_nodate={oldvit[stormnamelc]}{oldvit[stnum]:02d}{oldvit[basin1lc]}
+out_prefix={vit[stnum]:02d}{vit[basin1lc]}.{vit[YMDH]}
+out_prefix_nodate={vit[stnum]:02d}{vit[basin1lc]}
+old_out_prefix={oldvit[stnum]:02d}{oldvit[basin1lc]}.{oldvit[YMDH]}
+old_out_prefix_nodate={oldvit[stnum]:02d}{oldvit[basin1lc]}
ENS=99 ;; The ensemble number (placeholder)
@@ -49,9 +53,9 @@ outatcfcorrected={CDNOSCRUB}/atcf/{SUBEXPT} ;; delivery location for corrected A
outships={CDNOSCRUB}/ships/{SUBEXPT} ;; delivery location for SHIPS files
statusfile={WORKhafs}/{stormlabel}.{YMDH} ;; cycle status file
## Domain center location file in COM.
-domlocfile={com}/{vit[stnum]:02d}{vit[basin1lc]}.{vit[YMDH]}.domain.center
+domlocfile={com}/{vit[stnum]:02d}{vit[basin1lc]}.{vit[YMDH]}.hafs.domain.center
## File to check in a prior cycle's com, to see if the cycle exists.
-HISTCHECK={oldcom}/{oldvit[stnum]:02d}{oldvit[basin1lc]}.{oldvit[YMDH]}.domain.center
+HISTCHECK={oldcom}/{oldvit[stnum]:02d}{oldvit[basin1lc]}.{oldvit[YMDH]}.hafs.domain.center
## The name of the gsi status file in the com directory
gsistatus={stormlabel}.gsi_status
## Operational name of the gsi status file
@@ -104,6 +108,7 @@ orog={EXEChafs}/hafs_orog.x
make_hgrid={EXEChafs}/hafs_make_hgrid.x
make_solo_mosaic={EXEChafs}/hafs_make_solo_mosaic.x
fregrid={EXEChafs}/hafs_fregrid.x
+fregrid_parallel={EXEChafs}/hafs_fregrid_parallel.x
filter_topo={EXEChafs}/hafs_filter_topo.x
shave={EXEChafs}/hafs_shave.x
@@ -186,6 +191,9 @@ stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
# The following options set a 2560x2160 regional grid with a refinement ratio of 4, sitting at the center of the tile
refine_ratio=4 ;; specify the refinement ratio for nest grid
istart_nest=128 ;; start index of the regional/nested domain on the tile's super grid
@@ -196,6 +204,23 @@ halo=3 ;; halo size to be used in the atmosphere cubic sphere mode
halop1=4 ;; halo size that will be used for the orography and grid tile in chgres
halo0=0 ;; no halo, used to shave the filtered orography for use in the model
+[grid_mvnest1res]
+CASE_mvnest1res=C1536
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=3
+istart_nest_mvnest1res=97
+jstart_nest_mvnest1res=97
+iend_nest_mvnest1res=2976
+jend_nest_mvnest1res=2976
+
[grid_ens]
CASE_ENS={grid/CASE} ;; FV3 resolution
LEVS_ENS={grid/LEVS} ;; Model vertical levels: 65
@@ -204,6 +229,7 @@ gridfixdir_ens={grid/gridfixdir}
stretch_fac_ens={grid/stretch_fac} ;; Stretching factor for the grid
target_lon_ens={grid/target_lon} ;; center longitude of the highest resolution tile
target_lat_ens={grid/target_lat} ;; center latitude of the highest resolution tile
+nest_grids_ens={grid/nest_grids}
refine_ratio_ens={grid/refine_ratio} ;; Specify the refinement ratio for nest grid
istart_nest_ens={grid/istart_nest}
jstart_nest_ens={grid/jstart_nest}
@@ -216,7 +242,29 @@ jend_nest_ens={grid/jend_nest}
[atm_lbc]
-[chgres]
+[atm_init]
+# ccpp suites
+ccpp_suite_regional_init=FV3_HAFS_v0_gfdlmp_tedmf
+ccpp_suite_glob_init=FV3_HAFS_v0_gfdlmp_tedmf
+ccpp_suite_nest_init=FV3_HAFS_v0_gfdlmp_tedmf
+
+# nsst related namelist options
+# Choose nstf_name=2,0,0,0,0 when nemsio type ictype
+# Choose nstf_name=2,1,0,0,0 when grib2 type ictype
+nstf_n1_init=2
+nstf_n2_init=0
+nstf_n3_init=0
+nstf_n4_init=0
+nstf_n5_init=0
+
+glob_layoutx_init=8
+glob_layouty_init=8
+# For the nested or regional standalone domain
+layoutx_init=20
+layouty_init=12
+
+[atm_merge]
+atm_merge_method=vortexreplace ;; vortexreplace or domainmerge
## Configure options for WW3 initialization
[ww3init]
@@ -318,7 +366,14 @@ atmos2_dataset=gfs ;; Dataset for global atmospheric surface data after t
atmos2_flux=gfs_sfluxgrb ;; Item for atmospheric flux data after time 0
atmos2_grid=gfs_gribA ;; Item for atmospheric air data after time 0
-[vortexinit]
+[vi]
+vi_warm_start_vmax_threshold=20 ;; m/s
+vi_bogus_vmax_threshold=50 ;; m/s
+vi_storm_env=init ;; init: from gfs/gdas init; pert: from the same source for the storm perturbation
+vi_storm_relocation=yes
+vi_storm_modification=yes
+vi_ajust_intensity=yes
+vi_ajust_size=yes
[bufrprep]
@@ -337,7 +392,8 @@ online_satbias=no ;; Should we recycle satbias data?
corrlength=500 ;; length for horizontal localization in km
lnsigcutoff=1.3 ;; length for vertical localization
-[merge]
+[analysis_merge]
+analysis_merge_method=vortexreplace ;; vortexreplace or domainmerge
[forecast]
# ccpp suites
@@ -391,6 +447,14 @@ glob_layoutx=8
glob_layouty=8
glob_npx=769
glob_npy=769
+glob_io_layoutx=1
+glob_io_layouty={forecast/glob_layouty}
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
# For the nested or regional standalone domain
k_split=4
n_split=5
@@ -398,17 +462,30 @@ layoutx=40
layouty=30
npx=2561
npy=2161
+io_layoutx=1
+io_layouty=10
+full_zs_filter=.true.
+n_zs_filter=0
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
npz=64
-print_esmf=.false. ;; .true. to generate ESMF log files or .false. not to
+# Moving nest related options
+is_moving_nest=.false.,.false.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
# The write_grid_component related options
quilting=.true.
write_groups=2
write_tasks_per_group=48
-write_dopost=.true.
-output_history=.false.
-app_domain=regional ;; write_grid_component output domain: regional, nest, or global
+write_dopost=.false.
+output_history=.true.
# The option for output grid type: rotated_latlon, regional_latlon
# Currently, the cubed_sphere_grid option is only supported by the forecast job, the post and product jobs cannot work for cubed_sphere_grid yet.
@@ -421,11 +498,6 @@ output_grid_lon_span=78.0 ;; output domain span for longitude in rotated
output_grid_lat_span=69.0 ;; output domain span for latitude in rotated coordinate system (in degrees)
output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
-# If the following options are not set, their values will be calculated according to cen_lon(lat), lon(lat)_span
-#output_grid_lon1=-39.0 ;; longitude of lower-left . . . .
-#output_grid_lat1=-34.5 ;; latitude of lower-left . . . .
-#output_grid_lon2=39.0 ;; longitude of upper-right . . . .
-#output_grid_lat2=34.5 ;; latitude of upper-right . . . .
#output_grid=regional_latlon
#output_grid_cen_lon={domlon} ;; central longitude
@@ -459,6 +531,15 @@ glob_layoutx_ens={forecast/glob_layoutx}
glob_layouty_ens={forecast/glob_layouty}
glob_npx_ens={forecast/glob_npx}
glob_npy_ens={forecast/glob_npy}
+glob_io_layoutx_ens={forecast/glob_io_layoutx}
+glob_io_layouty_ens={forecast/glob_io_layouty}
+glob_full_zs_filter_ens={forecast/glob_full_zs_filter}
+glob_n_zs_filter_ens={forecast/glob_n_zs_filter}
+glob_n_del2_weak_ens={forecast/glob_n_del2_weak}
+glob_max_slope_ens={forecast/glob_max_slope}
+glob_shal_cnv_ens={forecast/glob_shal_cnv}
+glob_do_deep_ens={forecast/glob_do_deep}
+
# For the nested or regional standalone domain
k_split_ens={forecast/k_split}
n_split_ens={forecast/n_split}
@@ -466,6 +547,15 @@ layoutx_ens={forecast/layoutx}
layouty_ens={forecast/layouty}
npx_ens={forecast/npx}
npy_ens={forecast/npy}
+io_layoutx_ens={forecast/io_layoutx}
+io_layouty_ens={forecast/io_layouty}
+full_zs_filter_ens={forecast/full_zs_filter}
+n_zs_filter_ens={forecast/n_zs_filter}
+n_del2_weak_ens={forecast/n_del2_weak}
+max_slope_ens={forecast/max_slope}
+shal_cnv_ens=.true.
+do_deep_ens=.true.
+
npz_ens={forecast/npz}
# The write_grid_component related options
@@ -488,7 +578,7 @@ output_grid_dlat_ens={forecast/output_grid_dlat}
[atm_post]
# Grid definition for atm_post and tracker, used by wgrib2
# Example:
-# synop_gridspecs="latlon 246.6:4112:0.025 -2.4:1976:0.025"
+# post_gridspecs="latlon 246.6:4112:0.025 -2.4:1976:0.025"
# latlon lon0:nlon:dlon lat0:nlat:dlat
# lat0, lon0 = degrees of lat/lon for 1st grid point
# nlon = number of longitudes
@@ -496,28 +586,18 @@ output_grid_dlat_ens={forecast/output_grid_dlat}
# dlon = grid cell size in degrees of longitude
# dlat = grid cell size in degrees of latitude
#
-# if synop_gridspecs=auto, which is the default, then synop_gridspecs will be automatically generated based on the output grid
-# if output_grid is rotated_latlon
-# lon0=output_grid_cen_lon+output_grid_lon1-9.
-# lat0=output_grid_cen_lat+output_grid_lat1
-# dlon=output_grid_dlon
-# dlat=output_grid_dlat
-# nlon=(output_grid_lon2-output_grid_lon1+18.)/output_grid_dlon
-# nlat=(output_grid_lat2-output_grid_lat2)/output_grid_dlat
-# if output_grid is regional_latlon, synop_gridspecs will be the same as the ouput regular latlon grid
-#
-#synop_gridspecs="latlon 246.6:4112:0.025 -2.4:1976:0.025"
-synop_gridspecs=auto
-trker_gridspecs={synop_gridspecs} ;; Currently a placeholder, and the traker uses the same grid as the output grid
+# if post_gridspecs=auto, which is the default, then post_gridspecs will be automatically generated based on the output grid
+post_gridspecs=auto
+trak_gridspecs={post_gridspecs} ;; Currently a placeholder, and the traker uses the same grid as the output grid
+satpost=.false. # do satellite post or not
[atm_post_ens]
-synop_gridspecs_ens=auto
-trker_gridspecs_ens={synop_gridspecs_ens} ;; Currently a placeholder, and the traker uses the same grid as the output grid
+post_gridspecs_ens=auto
+trak_gridspecs_ens={post_gridspecs_ens} ;; Currently a placeholder, and the traker uses the same grid as the output grid
+satpost_ens={atm_post/satpost}
[product]
-[tracker]
-
## Configure options for WW3 post-processing
[ww3post]
ww3_grib_post=yes ;; Produce WW3 grid output in grib2 format
@@ -562,14 +642,28 @@ GFSVER={config/GFSVER} ;; Version of GFS input data, e.g., PROD2019
# Variables to set as boolean values when parsing the hafs_workflow.xml.in.
# They'll be changed to YES or NO. This section is only used by the rocoto-based workflow.
[rocotobool]
+RUN_ATM_INIT={run_atm_init} ;;
+RUN_ATM_INIT_FGAT={run_atm_init_fgat}
+RUN_ATM_INIT_ENS={run_atm_init_ens}
+RUN_ATM_MERGE={run_atm_merge} ;;
+RUN_ATM_MERGE_FGAT={run_atm_merge_fgat}
+RUN_ATM_MERGE_ENS={run_atm_merge_ens}
+RUN_ATM_VI={run_atm_vi} ;;
+RUN_ATM_VI_FGAT={run_atm_vi_fgat} ;;
+RUN_ATM_VI_ENS={run_atm_vi_ens} ;;
RUN_GSI_VR={run_gsi_vr} ;; Do we run GSI based vortex relocation?
RUN_GSI_VR_FGAT={run_gsi_vr_fgat} ;; Do we run GSI based vortex relocation for FGAT?
RUN_GSI_VR_ENS={run_gsi_vr_ens} ;; Do we run GSI based vortex relocation for ensda members?
RUN_GSI={run_gsi} ;; Do we run GSI?
+GSI_D01={gsi_d01} ;; Do we run GSI for domain 01?
+GSI_D02={gsi_d02} ;; Do we run GSI for domain 02?
+GSI_D03={gsi_d03} ;; Do we run GSI for domain 03?
RUN_FGAT={run_fgat} ;; Do we run DA with FGAT?
RUN_ENVAR={run_envar} ;; Do we run hybrid EnVar with either GDAS ensembles or regional ensembles?
RUN_ENSDA={run_ensda} ;; Do we run the ensda system?
RUN_ENKF={run_enkf} ;; Do we run the self-cycled ensda system with EnKF analysis
+RUN_ANALYSIS_MERGE={run_analysis_merge} ;;
+RUN_ANALYSIS_MERGE_ENS={run_analysis_merge_ens} ;;
RUN_OCEAN={run_ocean} ;; Do we run with ocean coupling?
RUN_WAVE={run_wave} ;; Do we run with wave coupling?
RUN_DATM={run_datm} ;; Do we run with a data atmosphere using CDEPS?
@@ -577,7 +671,6 @@ RUN_DOCN={run_docn} ;; Do we run with a data ocean using CDEPS?
RUN_DWAV={run_dwav} ;; Do we run with data waves using CDEPS?
MAKE_MESH_ATM={make_mesh_atm} ;; Should the DATM mesh be generated by the workflow?
MAKE_MESH_OCN={make_mesh_ocn} ;; Should the DOCN mesh be generated by the workflow?
-RUN_VORTEXINIT={run_vortexinit} ;; Do we enable vortex initialization?
RUN_HRDGRAPHICS={run_hrdgraphics} ;; Do we run HRD graphics?
RUN_EMCGRAPHICS={run_emcgraphics} ;; Do we run EMC graphics?
SCRUB_COM={scrub_com} ;; Should Rocoto scrub the COM directory?
diff --git a/parm/hafs_C192_global_1mvnest_storm.conf b/parm/hafs_C192_global_1mvnest_storm.conf
new file mode 100644
index 000000000..9aa279733
--- /dev/null
+++ b/parm/hafs_C192_global_1mvnest_storm.conf
@@ -0,0 +1,106 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C192 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=133
+iend_nest=252
+jstart_nest=133
+jend_nest=252
+
+[grid_mvnest1res]
+CASE_mvnest1res=C576
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=1
+istart_nest_mvnest1res=433
+jstart_nest_mvnest1res=433
+iend_nest_mvnest1res=720
+jend_nest_mvnest1res=720
+
+[forecast]
+dt_atmos=180
+# For the global domain if it is a global or global-nesting experiment
+glob_k_split=1
+glob_n_split=7
+glob_layoutx=4
+glob_layouty=5
+glob_npx=193
+glob_npy=193
+glob_io_layoutx=1
+glob_io_layouty=1
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
+# For the nested or regional standalone domain
+k_split=4
+n_split=5
+layoutx=4
+layouty=5
+npx=181
+npy=181
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+npz=64
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=20
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon_moving
+output_grid_cen_lon=180.0,{domlon} ;; central longitude
+output_grid_cen_lat=0.0,{domlat} ;; central latitude
+output_grid_lon_span=360.0,36.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=180.0,36.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.50,0.20 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.50,0.20 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_180PE
diff --git a/parm/hafs_C512_regional_1mvnest_storm.conf b/parm/hafs_C512_regional_1mvnest_storm.conf
new file mode 100644
index 000000000..601917abd
--- /dev/null
+++ b/parm/hafs_C512_regional_1mvnest_storm.conf
@@ -0,0 +1,94 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C512 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=2
+parent_grid_num=1,2
+parent_tile=6,7
+refine_ratio=3,3
+istart_nest=33,1121
+jstart_nest=33,1121
+iend_nest=992,1760
+jend_nest=992,1760
+
+[grid_mvnest1res]
+CASE_mvnest1res=C1536
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=3
+istart_nest_mvnest1res=97
+jstart_nest_mvnest1res=97
+iend_nest_mvnest1res=2976
+jend_nest_mvnest1res=2976
+
+[atm_init]
+layoutx_init=12,12
+layouty_init=20,20
+
+[forecast]
+dt_atmos=90
+npx=1441,961
+npy=1441,961
+npz=81
+k_split=2,5
+n_split=5,9
+layoutx=30,30
+layouty=20,20
+io_layoutx=1,1
+io_layouty=10,10
+full_zs_filter=.true.,.true.
+n_zs_filter=1,1
+n_del2_weak=15,24
+max_slope=0.25,0.25
+shal_cnv=.true.,.true.
+do_deep=.true.,.true.
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+restart_interval="3 6 9"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon,rotated_latlon_moving
+output_grid_cen_lon={domlon},{domlon} ;; central longitude
+output_grid_cen_lat={domlat},{domlat} ;; central latitude
+output_grid_lon_span=84.0,24.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=84.0,24.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.06,0.02 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.06,0.02 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1320PE
diff --git a/parm/hafs_C512_regional_3kmL81.conf b/parm/hafs_C512_regional_3kmL81.conf
new file mode 100644
index 000000000..c8ba2c883
--- /dev/null
+++ b/parm/hafs_C512_regional_3kmL81.conf
@@ -0,0 +1,61 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C512 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels: 65
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=6
+istart_nest=93
+jstart_nest=113
+iend_nest=932
+jend_nest=912
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=513
+glob_npy=513
+# For the nested or regional standalone domain
+layoutx=40
+layouty=30
+npx=2521
+npy=2401
+npz=81
+
+restart_interval="3 6 9" ;; restart interval in hours for the forecast
+
+quilting=.true.
+write_groups=1
+write_tasks_per_group=80
+write_dopost=.true.
+output_history=.false.
+
+output_grid=rotated_latlon
+output_grid_cen_lon={domlon} ;; central longitude
+output_grid_cen_lat={domlat} ;; central latitude
+output_grid_lon_span=78.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=72.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_ENS_RESOURCES=FORECAST_ENS_RESOURCES_regional_{forecast_ens/layoutx_ens}x{forecast_ens/layouty_ens}io{forecast_ens/write_groups_ens}x{forecast_ens/write_tasks_per_group_ens}_omp2
diff --git a/parm/hafs_C512_regional_6kmL81.conf b/parm/hafs_C512_regional_6kmL81.conf
new file mode 100644
index 000000000..14ed0e1a9
--- /dev/null
+++ b/parm/hafs_C512_regional_6kmL81.conf
@@ -0,0 +1,61 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C512 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels: 65
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=33
+jstart_nest=33
+iend_nest=992
+jend_nest=992
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=513
+glob_npy=513
+# For the nested or regional standalone domain
+layoutx=40
+layouty=30
+npx=1441
+npy=1441
+npz=81
+
+restart_interval="3 6 9" ;; restart interval in hours for the forecast
+
+quilting=.true.
+write_groups=1
+write_tasks_per_group=80
+write_dopost=.true.
+output_history=.false.
+
+output_grid=rotated_latlon
+output_grid_cen_lon={domlon} ;; central longitude
+output_grid_cen_lat={domlat} ;; central latitude
+output_grid_lon_span=84.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=84.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.06 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.06 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_ENS_RESOURCES=FORECAST_ENS_RESOURCES_regional_{forecast_ens/layoutx_ens}x{forecast_ens/layouty_ens}io{forecast_ens/write_groups_ens}x{forecast_ens/write_tasks_per_group_ens}_omp2
diff --git a/parm/hafs_C768_global_1mvnest_storm.conf b/parm/hafs_C768_global_1mvnest_storm.conf
new file mode 100644
index 000000000..f7940e04d
--- /dev/null
+++ b/parm/hafs_C768_global_1mvnest_storm.conf
@@ -0,0 +1,106 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C768 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=529
+jstart_nest=529
+iend_nest=1008
+jend_nest=1008
+
+[grid_mvnest1res]
+CASE_mvnest1res=C2304
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=1
+istart_nest_mvnest1res=1585
+jstart_nest_mvnest1res=1585
+iend_nest_mvnest1res=3024
+jend_nest_mvnest1res=3024
+
+[forecast]
+dt_atmos=90
+# For the global domain if it is a global or global-nesting experiment
+glob_k_split=2
+glob_n_split=5
+glob_layoutx=6
+glob_layouty=10
+glob_npx=769
+glob_npy=769
+glob_io_layoutx=1
+glob_io_layouty=1
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
+# For the nested or regional standalone domain
+k_split=5
+n_split=9
+layoutx=12
+layouty=10
+npx=721
+npy=721
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=24
+max_slope=0.15
+shal_cnv=.true.
+do_deep=.true.
+
+npz=81
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon_moving
+output_grid_cen_lon=180.0,{domlon} ;; central longitude
+output_grid_cen_lat=0.0,{domlat} ;; central latitude
+output_grid_lon_span=360.0,36.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=180.0,36.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.20,0.05 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.20,0.05 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_600PE
diff --git a/parm/hafs_C96_global_1mvnest_storm.conf b/parm/hafs_C96_global_1mvnest_storm.conf
new file mode 100644
index 000000000..7bfeb639e
--- /dev/null
+++ b/parm/hafs_C96_global_1mvnest_storm.conf
@@ -0,0 +1,106 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=73
+iend_nest=120
+jstart_nest=73
+jend_nest=120
+
+[grid_mvnest1res]
+CASE_mvnest1res=C288
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=1
+istart_nest_mvnest1res=217
+jstart_nest_mvnest1res=217
+iend_nest_mvnest1res=360
+jend_nest_mvnest1res=360
+
+[forecast]
+dt_atmos=180
+# For the global domain if it is a global or global-nesting experiment
+glob_k_split=1
+glob_n_split=7
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+glob_io_layoutx=1
+glob_io_layouty=1
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
+# For the nested or regional standalone domain
+k_split=4
+n_split=5
+layoutx=4
+layouty=5
+npx=73
+npy=73
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+npz=64
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=20
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon_moving
+output_grid_cen_lon=180.0,{domlon} ;; central longitude
+output_grid_cen_lat=0.0,{domlat} ;; central latitude
+output_grid_lon_span=360.0,36.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=180.0,36.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=1.00,0.25 ;; output grid spacing dlon . . . .
+output_grid_dlat=1.00,0.25 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_180PE
diff --git a/parm/hafs_C96_global_1nest_storm.conf b/parm/hafs_C96_global_1nest_storm.conf
new file mode 100644
index 000000000..387d4533c
--- /dev/null
+++ b/parm/hafs_C96_global_1nest_storm.conf
@@ -0,0 +1,82 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=23.0
+domlon=-86.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=230N
+vitalsdomlon=860W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=17
+jstart_nest=17
+iend_nest=176
+jend_nest=176
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=6
+layouty=10
+npx=241
+npy=241
+npz=64
+
+quilting=.true.
+write_groups=1
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon
+output_grid_cen_lon=-86.0 ;; central longitude
+output_grid_cen_lat=23.0 ;; central latitude
+output_grid_lon_span=90.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=80.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.10 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest1
diff --git a/parm/hafs_C96_global_multiple_4nests_storm.conf b/parm/hafs_C96_global_multiple_4nests_storm.conf
new file mode 100644
index 000000000..0598e569a
--- /dev/null
+++ b/parm/hafs_C96_global_multiple_4nests_storm.conf
@@ -0,0 +1,82 @@
+# This is a UNIX conf file that contains ALL information relating to
+# the HAFS basin-focused global-nesting configuration.
+#
+[config]
+# Specify the domain center Latitude and Longitude
+domlat=23.0
+domlon=-86.0
+# Same as domlat and domlon but vitals formatted
+vitalsdomlat=230N
+vitalsdomlon=860W
+
+# HAFS launcher requires vitals and a storm.
+# This is a default minimum vitals file for a fake storm.
+# The format of the missing value fields was based on the log
+# output returned when running the launcher after the vitals have
+# been "cleaned" up. That is, if you enter the fields as all -999 values,
+# the "cleaned" output is returned. In essence I'm treating the vitals
+# module as a factory in the sense that it knows the correct format.
+# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+# fakestormid is a config option set in the launcher and is the
+# last storm id in the list of storms.
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/globnest
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
+gtype=nest ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
+gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
+# Otherwise, will generate the model grid according to the following grid parameters
+# Need for grid types: stretch, nest and regional
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=4
+parent_grid_num=1,1,2,3
+parent_tile=2,6,8,9
+refine_ratio=3,3,3,3
+istart_nest=17,17,121,241
+jstart_nest=17,17,121,241
+iend_nest=176,176,360,480
+jend_nest=176,176,360,480
+
+[forecast]
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=6,6,6,6
+layouty=10,10,10,10
+npx=241,241,361,361
+npy=241,241,361,361
+npz=64
+
+quilting=.true.
+write_groups=1
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon
+output_grid_cen_lon=-86.0 ;; central longitude
+output_grid_cen_lat=23.0 ;; central latitude
+output_grid_lon_span=90.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=80.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.10 ;; output grid spacing dlat . . . .
+
+[rocotostr]
+#FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_globnest4
diff --git a/parm/hafs_C96_regional_1mvnest_storm.conf b/parm/hafs_C96_regional_1mvnest_storm.conf
new file mode 100644
index 000000000..54784d4f1
--- /dev/null
+++ b/parm/hafs_C96_regional_1mvnest_storm.conf
@@ -0,0 +1,89 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+# Need for grid types: nest and regional
+nest_grids=2
+parent_grid_num=1,2
+parent_tile=6,7
+refine_ratio=3,3
+istart_nest=17,121
+jstart_nest=17,121
+iend_nest=176,360
+jend_nest=176,360
+
+[grid_mvnest1res]
+CASE_mvnest1res=C288
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=3
+istart_nest_mvnest1res=49
+jstart_nest_mvnest1res=49
+iend_nest_mvnest1res=528
+jend_nest_mvnest1res=528
+
+[forecast]
+dt_atmos=180
+npx=241,361
+npy=241,361
+npz=64
+k_split=2,3
+n_split=5,10
+layoutx=6,6
+layouty=10,10
+io_layoutx=1,1
+io_layouty=1,1
+full_zs_filter=.true.,.true.
+n_zs_filter=1,1
+n_del2_weak=15,24
+max_slope=0.25,0.25
+shal_cnv=.true.,.true.
+do_deep=.true.,.true.
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=20
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon,rotated_latlon_moving
+output_grid_cen_lon={domlon},{domlon} ;; central longitude
+output_grid_cen_lat={domlat},{domlat} ;; central latitude
+output_grid_lon_span=84.0,36.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=84.0,36.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.30,0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.30,0.10 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_C96_regional_1mvnest
diff --git a/parm/hafsv0p1aL91_EP.conf b/parm/hafs_C96_regional_1nest_storm.conf
similarity index 57%
rename from parm/hafsv0p1aL91_EP.conf
rename to parm/hafs_C96_regional_1nest_storm.conf
index ba94e4579..e2c3547cf 100644
--- a/parm/hafsv0p1aL91_EP.conf
+++ b/parm/hafs_C96_regional_1nest_storm.conf
@@ -1,13 +1,13 @@
# This is a UNIX conf file that contains ALL information relating to
-# the HAFS basin-focused standalone regional configuration.
+# the HAFS basin-focused global-nesting configuration.
#
[config]
# Specify the domain center Latitude and Longitude
-domlat=22.0
-domlon=-122.0
+domlat=23.0
+domlon=-86.0
# Same as domlat and domlon but vitals formatted
-vitalsdomlat=220N
-vitalsdomlon=1220W
+vitalsdomlat=230N
+vitalsdomlon=860W
# HAFS launcher requires vitals and a storm.
# This is a default minimum vitals file for a fake storm.
@@ -19,50 +19,63 @@ vitalsdomlon=1220W
# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
# fakestormid is a config option set in the launcher and is the
# last storm id in the list of storms.
-fakestormid=00E
-fakestormname=EPAC
+fakestormid=00L
+fakestormname=NATL
fakestormorg=NHC
fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
-ictype=gfsnetcdf
-bctype=gfsgrib2ab_0p25
-halo_blend=10
-
[dir]
PARMforecast={PARMhafs}/forecast/regional
[grid]
-CASE=C768 ;; FV3 resolution
-LEVS=92 ;; Model vertical levels: 65, 128, 76, 86, and 97
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
gtype=regional ;; grid type: uniform, stretch, nest, or regional
# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
# Otherwise, will generate the model grid according to the following grid parameters
# Need for grid types: stretch, nest and regional
-stretch_fac=1.0001 ;; Stretching factor for the grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
-istart_nest=46
-jstart_nest=168
-iend_nest=1485
-jend_nest=1367
+nest_grids=2
+parent_grid_num=1,2
+parent_tile=6,7
+refine_ratio=3,3
+istart_nest=17,121
+jstart_nest=17,121
+iend_nest=176,360
+jend_nest=176,360
[forecast]
-layoutx=48
-layouty=40
-npx=2881
-npy=2401
-npz=91
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=6,6
+layouty=10,10
+npx=241,361
+npy=241,361
+npz=64
+
+quilting=.true.
+write_groups=1
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
-output_grid=regional_latlon
-output_grid_cen_lon=-122.0 ;; central longitude
-output_grid_cen_lat=22.0 ;; central latitude
-output_grid_lon_span=109.8 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=72.9 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
-output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
-output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+output_grid=rotated_latlon
+output_grid_cen_lon=-86.0 ;; central longitude
+output_grid_cen_lat=23.0 ;; central latitude
+output_grid_lon_span=90.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=80.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.10 ;; output grid spacing dlat . . . .
[rocotostr]
-FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_regnest2
diff --git a/parm/hafsv0p1aL91_AL.conf b/parm/hafs_C96_regional_storm.conf
similarity index 58%
rename from parm/hafsv0p1aL91_AL.conf
rename to parm/hafs_C96_regional_storm.conf
index c87f22d7e..845c20376 100644
--- a/parm/hafsv0p1aL91_AL.conf
+++ b/parm/hafs_C96_regional_storm.conf
@@ -1,13 +1,13 @@
# This is a UNIX conf file that contains ALL information relating to
-# the HAFS basin-focused standalone regional configuration.
+# the HAFS basin-focused global-nesting configuration.
#
[config]
# Specify the domain center Latitude and Longitude
-domlat=22.0
-domlon=-62.0
+domlat=23.0
+domlon=-86.0
# Same as domlat and domlon but vitals formatted
-vitalsdomlat=220N
-vitalsdomlon=620W
+vitalsdomlat=230N
+vitalsdomlon=860W
# HAFS launcher requires vitals and a storm.
# This is a default minimum vitals file for a fake storm.
@@ -28,37 +28,54 @@ fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {v
PARMforecast={PARMhafs}/forecast/regional
[grid]
-CASE=C768 ;; FV3 resolution
-LEVS=92 ;; Model vertical levels: 65, 128, 76, 86, and 97
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
gtype=regional ;; grid type: uniform, stretch, nest, or regional
# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
# Otherwise, will generate the model grid according to the following grid parameters
# Need for grid types: stretch, nest and regional
-stretch_fac=1.0001 ;; Stretching factor for the grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
-istart_nest=46
-jstart_nest=168
-iend_nest=1485
-jend_nest=1367
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=3
+istart_nest=17
+jstart_nest=17
+iend_nest=176
+jend_nest=176
[forecast]
-layoutx=48
-layouty=40
-npx=2881
-npy=2401
-npz=91
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=6
+layouty=10
+npx=241
+npy=241
+npz=64
-output_grid=regional_latlon
-output_grid_cen_lon=-62.0 ;; central longitude
-output_grid_cen_lat=22.0 ;; central latitude
-output_grid_lon_span=109.8 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=72.9 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
-output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
-output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+quilting=.true.
+write_groups=1
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon
+output_grid_cen_lon=-86.0 ;; central longitude
+output_grid_cen_lat=23.0 ;; central latitude
+output_grid_lon_span=90.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=80.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.10 ;; output grid spacing dlat . . . .
[rocotostr]
-FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_regnest1
diff --git a/parm/hafsv0p1aL91_WP.conf b/parm/hafs_C96_regional_telescopic_2nests_storm.conf
similarity index 55%
rename from parm/hafsv0p1aL91_WP.conf
rename to parm/hafs_C96_regional_telescopic_2nests_storm.conf
index 47a604bc3..d7e6bc90e 100644
--- a/parm/hafsv0p1aL91_WP.conf
+++ b/parm/hafs_C96_regional_telescopic_2nests_storm.conf
@@ -1,13 +1,13 @@
# This is a UNIX conf file that contains ALL information relating to
-# the HAFS basin-focused standalone regional configuration.
+# the HAFS basin-focused global-nesting configuration.
#
[config]
# Specify the domain center Latitude and Longitude
-domlat=22.0
-domlon=140.0
+domlat=23.0
+domlon=-86.0
# Same as domlat and domlon but vitals formatted
-vitalsdomlat=220N
-vitalsdomlon=1400E
+vitalsdomlat=230N
+vitalsdomlon=860W
# HAFS launcher requires vitals and a storm.
# This is a default minimum vitals file for a fake storm.
@@ -19,46 +19,63 @@ vitalsdomlon=1400E
# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
# fakestormid is a config option set in the launcher and is the
# last storm id in the list of storms.
-fakestormid=00W
-fakestormname=WPAC
-fakestormorg=JTWC
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
[dir]
PARMforecast={PARMhafs}/forecast/regional
[grid]
-CASE=C768 ;; FV3 resolution
-LEVS=92 ;; Model vertical levels: 65, 128, 76, 86, and 97
+CASE=C96 ;; FV3 resolution
+LEVS=65 ;; Model vertical levels: 65
gtype=regional ;; grid type: uniform, stretch, nest, or regional
# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
gridfixdir=/let/hafs_grid/generate/grid
+#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
# Otherwise, will generate the model grid according to the following grid parameters
# Need for grid types: stretch, nest and regional
-stretch_fac=1.0001 ;; Stretching factor for the grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
-istart_nest=46
-jstart_nest=168
-iend_nest=1485
-jend_nest=1367
+nest_grids=3
+parent_grid_num=1,2,3
+parent_tile=6,7,8
+refine_ratio=3,3,3
+istart_nest=17,121,241
+jstart_nest=17,121,241
+iend_nest=176,360,480
+jend_nest=176,360,480
[forecast]
-layoutx=48
-layouty=40
-npx=2881
-npy=2401
-npz=91
+# For the global domain if it is a global or global-nesting experiment
+glob_layoutx=4
+glob_layouty=5
+glob_npx=97
+glob_npy=97
+# For the nested or regional standalone domain
+layoutx=6,6,6
+layouty=10,10,10
+npx=241,361,361
+npy=241,361,361
+npz=64
-output_grid=regional_latlon
-output_grid_cen_lon=140.0 ;; central longitude
-output_grid_cen_lat=22.0 ;; central latitude
-output_grid_lon_span=109.8 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=72.9 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
-output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
-output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+quilting=.true.
+write_groups=1
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon
+output_grid_cen_lon=-86.0 ;; central longitude
+output_grid_cen_lat=23.0 ;; central latitude
+output_grid_lon_span=90.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=80.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.10 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.10 ;; output grid spacing dlat . . . .
[rocotostr]
-FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
+FORECAST_RESOURCES=FORECAST_RESOURCES_regnest3
diff --git a/parm/hafs_basic.conf b/parm/hafs_basic.conf
index 0f34401fb..c472fe78a 100644
--- a/parm/hafs_basic.conf
+++ b/parm/hafs_basic.conf
@@ -35,11 +35,24 @@ vcoord_file_target_grid={PARMhafs}/levels/hafs_hyblev.l{LEVS}.txt ;; Vertical le
halo_blend=10 ;; Number of rows for lateral boundary blending for the regional configuration
# Enable or disable parts of the workflow
-run_vortexinit=no ;; vortex initialization
+run_atm_init=no
+run_atm_init_fgat=no
+run_atm_init_ens=no
+run_atm_merge=no ;;
+run_atm_merge_fgat=no ;;
+run_atm_merge_ens=no ;;
+run_atm_vi=no ;; vortex initialization
+run_atm_vi_fgat=no ;;
+run_atm_vi_ens=no ;;
run_gsi_vr=no ;; GSI based vortex relocation
run_gsi_vr_fgat=no ;; GSI based vortex relocation for FGAT
run_gsi_vr_ens=no ;; GSI based vortex relocation for ensda members
run_gsi=no ;; GSI and FGAT initialization
+gsi_d01=no ;; GSI for domain 01
+gsi_d02=no ;; GSI for domain 02
+gsi_d03=no ;; GSI for domain 03
+run_analysis_merge=no ;;
+run_analysis_merge_ens=no ;;
run_fgat=no ;; Enable FGAT in DA
run_envar=no ;; Run GSI with hybrid EnVar with either GDAS ensembles or regional ensembles
run_ensda=no ;; Run ensemble data assimilation system
diff --git a/parm/hafs_globnest.conf b/parm/hafs_globnest.conf
index c9463b719..586c27099 100644
--- a/parm/hafs_globnest.conf
+++ b/parm/hafs_globnest.conf
@@ -13,7 +13,10 @@ stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=4
istart_nest=127
jstart_nest=227
iend_nest=1406
@@ -21,17 +24,59 @@ jend_nest=1306
[forecast]
# For the global domain if it is a global or global-nesting experiment
+glob_k_split=1
+glob_n_split=7
glob_layoutx=8
glob_layouty=10
glob_npx=769
glob_npy=769
+glob_io_layoutx=1
+glob_io_layouty=1
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
# For the nested or regional standalone domain
+k_split=4
+n_split=5
layoutx=30
layouty=40
npx=2561
npy=2161
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=24
+max_slope=0.15
+shal_cnv=.true.
+do_deep=.true.
+
npz=64
+quilting=.true.
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon
+output_grid_cen_lon=180.0,{domlon} ;; central longitude
+output_grid_cen_lat=0.0,{domlat} ;; central latitude
+output_grid_lon_span=360.0,105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=180.0,60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.20,0.05 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.20,0.05 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
[rocotostr]
FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
-
diff --git a/parm/hafs_globnest_static.conf b/parm/hafs_globnest_static.conf
index 63b7af0f1..a86ea1c31 100644
--- a/parm/hafs_globnest_static.conf
+++ b/parm/hafs_globnest_static.conf
@@ -32,16 +32,17 @@ CASE=C768 ;; FV3 resolution
LEVS=65 ;; Model vertical levels: 65
gtype=nest ;; grid type: uniform, stretch, nest, or regional
# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
-#gridfixdir={FIXhafs}/fix_fv3/{CASE}_globnest_static
gridfixdir=/let/hafs_grid/generate/grid
-#gridfixdir=/lfs1/projects/hwrf-data/globalnest_static_grid
# Otherwise, will generate the model grid according to the following grid parameters
# Need for grid types: stretch, nest and regional
-stretch_fac=1.0001 ;; Stretching factor for the grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
target_lon={domlon} ;; center longitude of the highest resolution tile
target_lat={domlat} ;; center latitude of the highest resolution tile
# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=4
istart_nest=47
jstart_nest=239
iend_nest=1486
@@ -49,27 +50,59 @@ jend_nest=1198
[forecast]
# For the global domain if it is a global or global-nesting experiment
+glob_k_split=1
+glob_n_split=7
glob_layoutx=8
glob_layouty=10
glob_npx=769
glob_npy=769
+glob_io_layoutx=1
+glob_io_layouty=1
+glob_full_zs_filter=.true.
+glob_n_zs_filter=0
+glob_n_del2_weak=15
+glob_max_slope=0.15
+glob_shal_cnv=.true.
+glob_do_deep=.true.
# For the nested or regional standalone domain
-#zzlayoutx=48
-#zzlayouty=32
+k_split=4
+n_split=5
layoutx=30
layouty=40
npx=2881
npy=1921
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=24
+max_slope=0.15
+shal_cnv=.true.
+do_deep=.true.
+
npz=64
-output_grid=regional_latlon
-output_grid_cen_lon=-62.0 ;; central longitude
-output_grid_cen_lat=25.0 ;; central latitude
-output_grid_lon_span=105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
-output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
-output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+quilting=.true.
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon
+output_grid_cen_lon=180.0,{domlon} ;; central longitude
+output_grid_cen_lat=0.0,{domlat} ;; central latitude
+output_grid_lon_span=360.0,105.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=180.0,60.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.20,0.05 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.20,0.05 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
[rocotostr]
FORECAST_RESOURCES=FORECAST_RESOURCES_globnest_6x{forecast/glob_layoutx}x{forecast/glob_layouty}_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
-
diff --git a/parm/hafs_holdvars.conf b/parm/hafs_holdvars.conf
index 9e3baf7cd..6817f0e0b 100644
--- a/parm/hafs_holdvars.conf
+++ b/parm/hafs_holdvars.conf
@@ -12,6 +12,15 @@
[holdvars]
COMIN={com} ;; Input com directory
COMOUT={com} ;; output com directory
+RUN_ATM_INIT={cap_run_atm_init} ;;
+RUN_ATM_INIT_FGAT={cap_run_atm_init_fgat} ;;
+RUN_ATM_INIT_ENS={cap_run_atm_init_ens} ;;
+RUN_ATM_MERGE={cap_run_atm_merge} ;;
+RUN_ATM_MERGE_FGAT={cap_run_atm_merge_fgat} ;;
+RUN_ATM_MERGE_ENS={cap_run_atm_merge_ens} ;;
+RUN_ATM_VI={cap_run_atm_vi} ;;
+RUN_ATM_VI_FGAT={cap_run_atm_vi_fgat} ;;
+RUN_ATM_VI_ENS={cap_run_atm_vi_ens} ;;
RUN_GSI_VR={cap_run_gsi_vr} ;; Do we run GSI based vortex relocation?
RUN_GSI_VR_FGAT={cap_run_gsi_vr_fgat} ;; Do we run GSI based vortex relocation for FGAT?
RUN_GSI_VR_ENS={cap_run_gsi_vr_ens} ;; Do we run GSI based vortex relocation for ensda members?
@@ -20,11 +29,12 @@ RUN_FGAT={cap_run_fgat} ;; Do we run DA with FGAT?
RUN_ENVAR={cap_run_envar} ;; Do we run hybrid EnVar with either GDAS ensembles or regional ensembles?
RUN_ENSDA={cap_run_ensda} ;; Do we run the ensda system?
RUN_ENKF={cap_run_enkf} ;; Do we run the self-cycled ensda system with EnKF analysis?
-RUN_VORTEXINIT={cap_run_vortexinit} ;; Do we run vortex initialization?
+RUN_ANALYSIS_MERGE={cap_run_analysis_merge} ;;
+RUN_ANALYSIS_MERGE_ENS={cap_run_analysis_merge_ens} ;;
RUN_HRDGRAPHICS={cap_run_hrdgraphics} ;; Do we run HRD graphics?
-GSID01={cap_run_gsi} ;; Do we run GSI for domain 1?
-GSID02={cap_run_gsi} ;; Do we run GSI for domain 2?
-GSID03={cap_run_gsi} ;; Do we run GSI for domain 3?
+GSI_D01={cap_gsi_d01} ;; Do we run GSI for domain 1?
+GSI_D02={cap_gsi_d02} ;; Do we run GSI for domain 2?
+GSI_D03={cap_gsi_d03} ;; Do we run GSI for domain 3?
FGATSTR=-3 ;; FGAT start hour relative to analysis time
FGATINV=3 ;; FGAT increment in horus
FGATEND=3 ;; FGAT end hour relative to analysis time
@@ -39,6 +49,17 @@ DATM_SOURCE={datm_source}
docn_mesh_nx_global={forecast/docn_mesh_nx_global}
docn_mesh_ny_global={forecast/docn_mesh_ny_global}
+vi_warm_start_vmax_threshold={vi/vi_warm_start_vmax_threshold}
+vi_bogus_vmax_threshold={vi/vi_bogus_vmax_threshold}
+vi_storm_env={vi/vi_storm_env}
+vi_storm_relocation={vi/vi_storm_relocation}
+vi_storm_modification={vi/vi_storm_modification}
+vi_ajust_intensity={vi/vi_ajust_intensity}
+vi_ajust_size={vi/vi_ajust_size}
+
+atm_merge_method={atm_merge/atm_merge_method}
+analysis_merge_method={analysis_merge/analysis_merge_method}
+
CASE={grid/CASE}
LEVS={grid/LEVS}
gtype={grid/gtype}
@@ -46,6 +67,9 @@ gridfixdir={grid/gridfixdir}
stretch_fac={grid/stretch_fac}
target_lon={grid/target_lon}
target_lat={grid/target_lat}
+nest_grids={grid/nest_grids}
+parent_grid_num={grid/parent_grid_num}
+parent_tile={grid/parent_tile}
refine_ratio={grid/refine_ratio}
istart_nest={grid/istart_nest}
jstart_nest={grid/jstart_nest}
@@ -55,44 +79,28 @@ halo={grid/halo}
halop1={grid/halop1}
halo0={grid/halo0}
-# ENSDA related items
-CASE_ENS={grid_ens/CASE_ENS}
-LEVS_ENS={grid_ens/LEVS_ENS}
-gtype_ens={grid_ens/gtype_ens}
-gridfixdir_ens={grid_ens/gridfixdir_ens}
-stretch_fac_ens={grid_ens/stretch_fac_ens}
-target_lon_ens={grid_ens/target_lon_ens}
-target_lat_ens={grid_ens/target_lat_ens}
-refine_ratio_ens={grid_ens/refine_ratio_ens}
-istart_nest_ens={grid_ens/istart_nest_ens}
-jstart_nest_ens={grid_ens/jstart_nest_ens}
-iend_nest_ens={grid_ens/iend_nest_ens}
-jend_nest_ens={grid_ens/jend_nest_ens}
-
-ccpp_suite_regional_ens={forecast_ens/ccpp_suite_regional_ens}
-ccpp_suite_glob_ens={forecast_ens/ccpp_suite_glob_ens}
-ccpp_suite_nest_ens={forecast_ens/ccpp_suite_nest_ens}
+# moving nest related items
+CASE_mvnest1res={grid_mvnest1res/CASE_mvnest1res}
+LEVS_mvnest1res={grid_mvnest1res/LEVS_mvnest1res}
+gtype_mvnest1res={grid_mvnest1res/gtype_mvnest1res}
+gridfixdir_mvnest1res={grid_mvnest1res/gridfixdir_mvnest1res}
+stretch_fac_mvnest1res={grid_mvnest1res/stretch_fac_mvnest1res}
+target_lon_mvnest1res={grid_mvnest1res/target_lon_mvnest1res}
+target_lat_mvnest1res={grid_mvnest1res/target_lat_mvnest1res}
+nest_grids_mvnest1res={grid_mvnest1res/nest_grids_mvnest1res}
+parent_grid_num_mvnest1res={grid_mvnest1res/parent_grid_num_mvnest1res}
+parent_tile_mvnest1res={grid_mvnest1res/parent_tile_mvnest1res}
+refine_ratio_mvnest1res={grid_mvnest1res/refine_ratio_mvnest1res}
+istart_nest_mvnest1res={grid_mvnest1res/istart_nest_mvnest1res}
+jstart_nest_mvnest1res={grid_mvnest1res/jstart_nest_mvnest1res}
+iend_nest_mvnest1res={grid_mvnest1res/iend_nest_mvnest1res}
+jend_nest_mvnest1res={grid_mvnest1res/jend_nest_mvnest1res}
-dt_atmos_ens={forecast_ens/dt_atmos_ens}
-restart_interval_ens={forecast_ens/restart_interval_ens}
-quilting_ens={forecast_ens/quilting_ens}
-write_groups_ens={forecast_ens/write_groups_ens}
-write_tasks_per_group_ens={forecast_ens/write_tasks_per_group_ens}
-
-glob_k_split_ens={forecast_ens/glob_k_split_ens}
-glob_n_split_ens={forecast_ens/glob_n_split_ens}
-glob_layoutx_ens={forecast_ens/glob_layoutx_ens}
-glob_layouty_ens={forecast_ens/glob_layouty_ens}
-glob_npx_ens={forecast_ens/glob_npx_ens}
-glob_npy_ens={forecast_ens/glob_npy_ens}
-
-k_split_ens={forecast_ens/k_split_ens}
-n_split_ens={forecast_ens/n_split_ens}
-layoutx_ens={forecast_ens/layoutx_ens}
-layouty_ens={forecast_ens/layouty_ens}
-npx_ens={forecast_ens/npx_ens}
-npy_ens={forecast_ens/npy_ens}
-npz_ens={forecast_ens/npz_ens}
+is_moving_nest={forecast/is_moving_nest}
+vortex_tracker={forecast/vortex_tracker}
+ntrack={forecast/ntrack}
+move_cd_x={forecast/move_cd_x}
+move_cd_y={forecast/move_cd_y}
use_bufr_nr={gsi/use_bufr_nr}
grid_ratio_fv3_regional={gsi/grid_ratio_fv3_regional}
@@ -114,14 +122,20 @@ write_tasks_per_group={forecast/write_tasks_per_group}
write_dopost={forecast/write_dopost}
output_history={forecast/output_history}
-print_esmf={forecast/print_esmf}
-
glob_k_split={forecast/glob_k_split}
glob_n_split={forecast/glob_n_split}
glob_layoutx={forecast/glob_layoutx}
glob_layouty={forecast/glob_layouty}
glob_npx={forecast/glob_npx}
glob_npy={forecast/glob_npy}
+glob_io_layoutx={forecast/glob_io_layoutx}
+glob_io_layouty={forecast/glob_io_layouty}
+glob_full_zs_filter={forecast/glob_full_zs_filter}
+glob_n_zs_filter={forecast/glob_n_zs_filter}
+glob_n_del2_weak={forecast/glob_n_del2_weak}
+glob_max_slope={forecast/glob_max_slope}
+glob_shal_cnv={forecast/glob_shal_cnv}
+glob_do_deep={forecast/glob_do_deep}
k_split={forecast/k_split}
n_split={forecast/n_split}
@@ -129,6 +143,14 @@ layoutx={forecast/layoutx}
layouty={forecast/layouty}
npx={forecast/npx}
npy={forecast/npy}
+io_layoutx={forecast/io_layoutx}
+io_layouty={forecast/io_layouty}
+full_zs_filter={forecast/full_zs_filter}
+n_zs_filter={forecast/n_zs_filter}
+n_del2_weak={forecast/n_del2_weak}
+max_slope={forecast/max_slope}
+shal_cnv={forecast/shal_cnv}
+do_deep={forecast/do_deep}
npz={forecast/npz}
fhswr={forecast/fhswr}
@@ -139,19 +161,31 @@ nstf_n3={forecast/nstf_n3}
nstf_n4={forecast/nstf_n4}
nstf_n5={forecast/nstf_n5}
-app_domain={forecast/app_domain}
output_grid={forecast/output_grid}
output_grid_cen_lon={forecast/output_grid_cen_lon}
output_grid_cen_lat={forecast/output_grid_cen_lat}
-output_grid_lon1={forecast/output_grid_lon1}
-output_grid_lat1={forecast/output_grid_lat1}
-output_grid_lon2={forecast/output_grid_lon2}
-output_grid_lat2={forecast/output_grid_lat2}
+output_grid_lon_span={forecast/output_grid_lon_span}
+output_grid_lat_span={forecast/output_grid_lat_span}
output_grid_dlon={forecast/output_grid_dlon}
output_grid_dlat={forecast/output_grid_dlat}
-synop_gridspecs={atm_post/synop_gridspecs}
-trker_gridspecs={atm_post/trker_gridspecs}
+post_gridspecs={atm_post/post_gridspecs}
+trak_gridspecs={atm_post/trak_gridspecs}
+satpost={atm_post/satpost}
+
+# atm_init related items
+ccpp_suite_regional_init={atm_init/ccpp_suite_regional_init}
+ccpp_suite_glob_init={atm_init/ccpp_suite_glob_init}
+ccpp_suite_nest_init={atm_init/ccpp_suite_nest_init}
+nstf_n1_init={atm_init/nstf_n1_init}
+nstf_n2_init={atm_init/nstf_n2_init}
+nstf_n3_init={atm_init/nstf_n3_init}
+nstf_n4_init={atm_init/nstf_n4_init}
+nstf_n5_init={atm_init/nstf_n5_init}
+glob_layoutx_init={atm_init/glob_layoutx_init}
+glob_layouty_init={atm_init/glob_layouty_init}
+layoutx_init={atm_init/layoutx_init}
+layouty_init={atm_init/layouty_init}
# ENSDA related items
CASE_ENS={grid_ens/CASE_ENS}
@@ -166,6 +200,7 @@ istart_nest_ens={grid_ens/istart_nest_ens}
jstart_nest_ens={grid_ens/jstart_nest_ens}
iend_nest_ens={grid_ens/iend_nest_ens}
jend_nest_ens={grid_ens/jend_nest_ens}
+
ccpp_suite_regional_ens={forecast_ens/ccpp_suite_regional_ens}
ccpp_suite_glob_ens={forecast_ens/ccpp_suite_glob_ens}
ccpp_suite_nest_ens={forecast_ens/ccpp_suite_nest_ens}
@@ -176,19 +211,41 @@ write_groups_ens={forecast_ens/write_groups_ens}
write_tasks_per_group_ens={forecast_ens/write_tasks_per_group_ens}
write_dopost_ens={forecast_ens/write_dopost_ens}
output_history_ens={forecast_ens/output_history_ens}
+glob_k_split_ens={forecast_ens/glob_k_split_ens}
+glob_n_split_ens={forecast_ens/glob_n_split_ens}
glob_layoutx_ens={forecast_ens/glob_layoutx_ens}
glob_layouty_ens={forecast_ens/glob_layouty_ens}
glob_npx_ens={forecast_ens/glob_npx_ens}
glob_npy_ens={forecast_ens/glob_npy_ens}
+glob_io_layoutx_ens={forecast_ens/glob_io_layoutx_ens}
+glob_io_layouty_ens={forecast_ens/glob_io_layouty_ens}
+glob_full_zs_filter_ens={forecast_ens/glob_full_zs_filter_ens}
+glob_n_zs_filter_ens={forecast_ens/glob_n_zs_filter_ens}
+glob_n_del2_weak_ens={forecast_ens/glob_n_del2_weak_ens}
+glob_max_slope_ens={forecast_ens/glob_max_slope_ens}
+glob_shal_cnv_ens={forecast_ens/glob_shal_cnv_ens}
+glob_do_deep_ens={forecast_ens/glob_do_deep_ens}
+k_split_ens={forecast_ens/k_split_ens}
+n_split_ens={forecast_ens/n_split_ens}
layoutx_ens={forecast_ens/layoutx_ens}
layouty_ens={forecast_ens/layouty_ens}
npx_ens={forecast_ens/npx_ens}
npy_ens={forecast_ens/npy_ens}
+io_layoutx_ens={forecast_ens/io_layoutx_ens}
+io_layouty_ens={forecast_ens/io_layouty_ens}
+full_zs_filter_ens={forecast_ens/full_zs_filter_ens}
+n_zs_filter_ens={forecast_ens/n_zs_filter_ens}
+n_del2_weak_ens={forecast_ens/n_del2_weak_ens}
+max_slope_ens={forecast_ens/max_slope_ens}
+shal_cnv_ens={forecast_ens/shal_cnv_ens}
+do_deep_ens={forecast_ens/do_deep_ens}
npz_ens={forecast_ens/npz_ens}
+
output_grid_dlon_ens={forecast_ens/output_grid_dlon_ens}
output_grid_dlat_ens={forecast_ens/output_grid_dlat_ens}
-synop_gridspecs_ens={atm_post_ens/synop_gridspecs_ens}
-trker_gridspecs_ens={atm_post_ens/trker_gridspecs_ens}
+post_gridspecs_ens={atm_post_ens/post_gridspecs_ens}
+trak_gridspecs_ens={atm_post_ens/trak_gridspecs_ens}
+satpost_ens={atm_post_ens/satpost_ens}
cpl_dt={forecast/cpl_dt}
cpl_atm_ocn={forecast/cpl_atm_ocn}
diff --git a/parm/hafs_holdvars.txt b/parm/hafs_holdvars.txt
index 361c74b7f..7f987204f 100644
--- a/parm/hafs_holdvars.txt
+++ b/parm/hafs_holdvars.txt
@@ -7,9 +7,16 @@ export TZ=UTC # Orion workaround
export envir={ENV[envir|-prod]}
-export storm_num={storm_num}
export RUN_HRDGRAPHICS={RUN_HRDGRAPHICS}
-export RUN_VORTEXINIT={RUN_VORTEXINIT}
+export RUN_ATM_INIT={RUN_ATM_INIT}
+export RUN_ATM_INIT_FGAT={RUN_ATM_INIT_FGAT}
+export RUN_ATM_INIT_ENS={RUN_ATM_INIT_ENS}
+export RUN_ATM_MERGE={RUN_ATM_MERGE}
+export RUN_ATM_MERGE_FGAT={RUN_ATM_MERGE_FGAT}
+export RUN_ATM_MERGE_ENS={RUN_ATM_MERGE_ENS}
+export RUN_ATM_VI={RUN_ATM_VI}
+export RUN_ATM_VI_FGAT={RUN_ATM_VI_FGAT}
+export RUN_ATM_VI_ENS={RUN_ATM_VI_ENS}
export RUN_GSI_VR={RUN_GSI_VR}
export RUN_GSI_VR_FGAT={RUN_GSI_VR_FGAT}
export RUN_GSI_VR_ENS={RUN_GSI_VR_ENS}
@@ -18,13 +25,25 @@ export RUN_FGAT={RUN_FGAT}
export RUN_ENVAR={RUN_ENVAR}
export RUN_ENSDA={RUN_ENSDA}
export RUN_ENKF={RUN_ENKF}
-export GSID01={GSID01}
-export GSID02={GSID02}
-export GSID03={GSID03}
+export RUN_ANALYSIS_MERGE={RUN_ANALYSIS_MERGE}
+export RUN_ANALYSIS_MERGE_ENS={RUN_ANALYSIS_MERGE_ENS}
+export GSI_D01={GSI_D01}
+export GSI_D02={GSI_D02}
+export GSI_D03={GSI_D03}
export FGATSTR={FGATSTR}
export FGATINV={FGATINV}
export FGATEND={FGATEND}
+export vi_warm_start_vmax_threshold={vi_warm_start_vmax_threshold}
+export vi_bogus_vmax_threshold={vi_bogus_vmax_threshold}
+export vi_storm_env={vi_storm_env}
+export vi_storm_relocation={vi_storm_relocation}
+export vi_storm_modification={vi_storm_modification}
+export vi_ajust_intensity={vi_ajust_intensity}
+export vi_ajust_size={vi_ajust_size}
+
+export atm_merge_method={atm_merge_method}
+export analysis_merge_method={analysis_merge_method}
export warm_start_opt={warm_start_opt}
export utilexec={utilexec}
@@ -69,9 +88,11 @@ export PARMforecast={PARMforecast}
export YMDH={YMDH} cyc={HH} CYCLE={YMDH}
+export storm_num={storm_num}
export stormlabel={stormlabel}
export STORM={vit[stormname]}
export STORMID={vit[stormid3]}
+export pubbasin2={vit[pubbasin2]}
export NHRS={NHRS}
export NBDYHRS={NBDYHRS}
@@ -89,6 +110,9 @@ export gridfixdir={gridfixdir}
export stretch_fac={stretch_fac}
export target_lon={target_lon}
export target_lat={target_lat}
+export nest_grids={nest_grids}
+export parent_grid_num={parent_grid_num}
+export parent_tile={parent_tile}
export refine_ratio={refine_ratio}
export istart_nest={istart_nest}
export jstart_nest={jstart_nest}
@@ -98,6 +122,28 @@ export halo={halo}
export halop1={halop1}
export halo0={halo0}
+export CASE_mvnest1res={CASE_mvnest1res}
+export LEVS_mvnest1res={LEVS_mvnest1res}
+export gtype_mvnest1res={gtype_mvnest1res}
+export gridfixdir_mvnest1res={gridfixdir_mvnest1res}
+export stretch_fac_mvnest1res={stretch_fac_mvnest1res}
+export target_lon_mvnest1res={target_lon_mvnest1res}
+export target_lat_mvnest1res={target_lat_mvnest1res}
+export nest_grids_mvnest1res={nest_grids_mvnest1res}
+export parent_grid_num_mvnest1res={parent_grid_num_mvnest1res}
+export parent_tile_mvnest1res={parent_tile_mvnest1res}
+export refine_ratio_mvnest1res={refine_ratio_mvnest1res}
+export istart_nest_mvnest1res={istart_nest_mvnest1res}
+export jstart_nest_mvnest1res={jstart_nest_mvnest1res}
+export iend_nest_mvnest1res={iend_nest_mvnest1res}
+export jend_nest_mvnest1res={jend_nest_mvnest1res}
+
+export is_moving_nest={is_moving_nest}
+export vortex_tracker={vortex_tracker}
+export ntrack={ntrack}
+export move_cd_x={move_cd_x}
+export move_cd_y={move_cd_y}
+
export vcoord_file_target_grid={vcoord_file_target_grid}
export use_bufr_nr={use_bufr_nr}
@@ -120,14 +166,20 @@ export write_tasks_per_group={write_tasks_per_group}
export write_dopost={write_dopost}
export output_history={output_history}
-export print_esmf={print_esmf}
-
export glob_k_split={glob_k_split}
export glob_n_split={glob_n_split}
export glob_layoutx={glob_layoutx}
export glob_layouty={glob_layouty}
export glob_npx={glob_npx}
export glob_npy={glob_npy}
+export glob_io_layoutx={glob_io_layoutx}
+export glob_io_layouty={glob_io_layouty}
+export glob_full_zs_filter={glob_full_zs_filter}
+export glob_n_zs_filter={glob_n_zs_filter}
+export glob_n_del2_weak={glob_n_del2_weak}
+export glob_max_slope={glob_max_slope}
+export glob_shal_cnv={glob_shal_cnv}
+export glob_do_deep={glob_do_deep}
export k_split={k_split}
export n_split={n_split}
@@ -135,6 +187,14 @@ export layoutx={layoutx}
export layouty={layouty}
export npx={npx}
export npy={npy}
+export io_layoutx={io_layoutx}
+export io_layouty={io_layouty}
+export full_zs_filter={full_zs_filter}
+export n_zs_filter={n_zs_filter}
+export n_del2_weak={n_del2_weak}
+export max_slope={max_slope}
+export shal_cnv={shal_cnv}
+export do_deep={do_deep}
export npz={npz}
export fhswr={fhswr}
@@ -145,21 +205,33 @@ export nstf_n3={nstf_n3}
export nstf_n4={nstf_n4}
export nstf_n5={nstf_n5}
-export app_domain={app_domain}
export output_grid={output_grid}
export output_grid_cen_lon={output_grid_cen_lon}
export output_grid_cen_lat={output_grid_cen_lat}
-export output_grid_lon1={output_grid_lon1}
-export output_grid_lat1={output_grid_lat1}
-export output_grid_lon2={output_grid_lon2}
-export output_grid_lat2={output_grid_lat2}
+export output_grid_lon_span={output_grid_lon_span}
+export output_grid_lat_span={output_grid_lat_span}
export output_grid_dlon={output_grid_dlon}
export output_grid_dlat={output_grid_dlat}
export out_prefix={out_prefix}
export out_prefix_nodate={out_prefix_nodate}
-export synop_gridspecs={synop_gridspecs}
-export trker_gridspecs={trker_gridspecs}
+export post_gridspecs={post_gridspecs}
+export trak_gridspecs={trak_gridspecs}
+export satpost={satpost}
+
+# atm_init related items
+export ccpp_suite_regional_init={ccpp_suite_regional_init}
+export ccpp_suite_glob_init={ccpp_suite_glob_init}
+export ccpp_suite_nest_init={ccpp_suite_nest_init}
+export nstf_n1_init={nstf_n1_init}
+export nstf_n2_init={nstf_n2_init}
+export nstf_n3_init={nstf_n3_init}
+export nstf_n4_init={nstf_n4_init}
+export nstf_n5_init={nstf_n5_init}
+export glob_layoutx_init={glob_layoutx_init}
+export glob_layouty_init={glob_layouty_init}
+export layoutx_init={layoutx_init}
+export layouty_init={layouty_init}
# ENSDA related items
export ENS_SIZE={ENS_SIZE}
@@ -188,21 +260,40 @@ export write_groups_ens={write_groups_ens}
export write_tasks_per_group_ens={write_tasks_per_group_ens}
export write_dopost_ens={write_dopost_ens}
export output_history_ens={output_history_ens}
-export k_split_ens={k_split_ens}
-export n_split_ens={n_split_ens}
+export glob_k_split_ens={glob_k_split_ens}
+export glob_n_split_ens={glob_n_split_ens}
export glob_layoutx_ens={glob_layoutx_ens}
export glob_layouty_ens={glob_layouty_ens}
export glob_npx_ens={glob_npx_ens}
export glob_npy_ens={glob_npy_ens}
+export glob_io_layoutx_ens={glob_io_layoutx_ens}
+export glob_io_layouty_ens={glob_io_layouty_ens}
+export glob_full_zs_filter_ens={glob_full_zs_filter_ens}
+export glob_n_zs_filter_ens={glob_n_zs_filter_ens}
+export glob_n_del2_weak_ens={glob_n_del2_weak_ens}
+export glob_max_slope_ens={glob_max_slope_ens}
+export glob_shal_cnv_ens={glob_shal_cnv_ens}
+export glob_do_deep_ens={glob_do_deep_ens}
+export k_split_ens={k_split_ens}
+export n_split_ens={n_split_ens}
export layoutx_ens={layoutx_ens}
export layouty_ens={layouty_ens}
export npx_ens={npx_ens}
export npy_ens={npy_ens}
+export io_layoutx_ens={io_layoutx_ens}
+export io_layouty_ens={io_layouty_ens}
+export full_zs_filter_ens={full_zs_filter_ens}
+export n_zs_filter_ens={n_zs_filter_ens}
+export n_del2_weak_ens={n_del2_weak_ens}
+export max_slope_ens={max_slope_ens}
+export shal_cnv_ens={shal_cnv_ens}
+export do_deep_ens={do_deep_ens}
export npz_ens={npz_ens}
export output_grid_dlon_ens={output_grid_dlon_ens}
export output_grid_dlat_ens={output_grid_dlat_ens}
-export synop_gridspecs_ens={synop_gridspecs_ens}
-export trker_gridspecs_ens={trker_gridspecs_ens}
+export post_gridspecs_ens={post_gridspecs_ens}
+export trak_gridspecs_ens={trak_gridspecs_ens}
+export satpost_ens={satpost_ens}
export run_ocean={run_ocean}
export ocean_model={ocean_model}
diff --git a/parm/hafs_hycom.conf b/parm/hafs_hycom.conf
index 1c7d3c0f1..8ab29270e 100644
--- a/parm/hafs_hycom.conf
+++ b/parm/hafs_hycom.conf
@@ -6,6 +6,8 @@ ocean_model=hycom
[forecast]
ccpp_suite_regional=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_nest=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_glob=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
# Choose nstf_name=0,0,0,0,0
nstf_n1=0
nstf_n2=0
@@ -15,6 +17,8 @@ nstf_n5=0
[forecast_ens]
ccpp_suite_regional_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_nest_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_glob_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
[rocotostr]
FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_ocn{forecast/ocn_tasks}_omp2
diff --git a/parm/hafsv0p1aL91_da_AL.conf b/parm/hafsv0p1aL91_da_AL.conf
deleted file mode 100644
index bd71a0243..000000000
--- a/parm/hafsv0p1aL91_da_AL.conf
+++ /dev/null
@@ -1,96 +0,0 @@
-# This is a UNIX conf file that contains ALL information relating to
-# the HAFS basin-focused standalone regional configuration.
-#
-[config]
-# Specify the domain center Latitude and Longitude
-domlat=22.0
-domlon=-62.0
-# Same as domlat and domlon but vitals formatted
-vitalsdomlat=220N
-vitalsdomlon=620W
-
-# HAFS launcher requires vitals and a storm.
-# This is a default minimum vitals file for a fake storm.
-# The format of the missing value fields was based on the log
-# output returned when running the launcher after the vitals have
-# been "cleaned" up. That is, if you enter the fields as all -999 values,
-# the "cleaned" output is returned. In essence I'm treating the vitals
-# module as a factory in the sense that it knows the correct format.
-# NHC 00L FAKE 20120710 0000 250N 0800W -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
-# fakestormid is a config option set in the launcher and is the
-# last storm id in the list of storms.
-fakestormid=00L
-fakestormname=NATL
-fakestormorg=NHC
-fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
-
-[dir]
-PARMforecast={PARMhafs}/forecast/regional
-
-[grid]
-CASE=C768 ;; FV3 resolution
-LEVS=92 ;; Model vertical levels: 65, 128, 76, 86, and 97
-gtype=regional ;; grid type: uniform, stretch, nest, or regional
-# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
-#gridfixdir={FIXhafs}/fix_fv3/{CASE}_hafsv0p1aL91_AL
-gridfixdir=/let/hafs_grid/generate/grid
-# Otherwise, will generate the model grid according to the following grid parameters
-# Need for grid types: stretch, nest and regional
-stretch_fac=1.0001 ;; Stretching factor for the grid
-target_lon={domlon} ;; center longitude of the highest resolution tile
-target_lat={domlat} ;; center latitude of the highest resolution tile
-# Need for grid types: nest and regional
-refine_ratio=4 ;; Specify the refinement ratio for nest grid
-istart_nest=46
-jstart_nest=168
-iend_nest=1485
-jend_nest=1367
-
-[grid_ens]
-CASE_ENS=C768 ;; FV3 resolution
-LEVS_ENS=92 ;; Model vertical levels: 65
-gtype_ens=regional ;; grid type: uniform, stretch, nest, or regional
-gridfixdir_ens=/let/hafs_grid/generate/grid_ens
-stretch_fac_ens=1.0001 ;; Stretching factor for the grid
-target_lon_ens={domlon} ;; center longitude of the highest resolution tile
-target_lat_ens={domlat} ;; center latitude of the highest resolution tile
-refine_ratio_ens=2 ;; Specify the refinement ratio for nest grid
-istart_nest_ens=46
-jstart_nest_ens=168
-iend_nest_ens=1485
-jend_nest_ens=1367
-
-[forecast]
-ccpp_suite_regional=FV3_HAFS_v0_gfdlmp_tedmf
-
-restart_interval="3 6 9" ;; restart interval in hours for the forecast
-
-layoutx=48
-layouty=40
-npx=2881
-npy=2401
-npz=91
-
-output_grid=regional_latlon
-output_grid_cen_lon=-62.0 ;; central longitude
-output_grid_cen_lat=22.0 ;; central latitude
-output_grid_lon_span=109.8 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=72.9 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
-output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
-output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
-
-[forecast_ens]
-ccpp_suite_regional_ens=FV3_HAFS_v0_gfdlmp_tedmf
-
-restart_interval_ens="6 12" ;; restart interval in hours for the ensda member forecast
-
-layoutx_ens=48
-layouty_ens=40
-npx_ens=1441
-npy_ens=1201
-npz_ens=91
-
-[rocotostr]
-FORECAST_RESOURCES=FORECAST_RESOURCES_regional_{forecast/layoutx}x{forecast/layouty}io{forecast/write_groups}x{forecast/write_tasks_per_group}_omp2
-#FORECAST_RESOURCES_ENS=FORECAST_RESOURCES_regional_{forecast_ens/layoutx_ens}x{forecast_ens/layouty_ens}io{forecast_ens/write_groups_ens}x{forecast_ens/write_tasks_per_group_ens}_omp2
-
diff --git a/parm/hafsv0p2a_phase2_AL.conf b/parm/hafsv0p2aL81_phase3_AL.conf
similarity index 87%
rename from parm/hafsv0p2a_phase2_AL.conf
rename to parm/hafsv0p2aL81_phase3_AL.conf
index cdfc7e46c..79a2fbc07 100644
--- a/parm/hafsv0p2a_phase2_AL.conf
+++ b/parm/hafsv0p2aL81_phase3_AL.conf
@@ -3,10 +3,10 @@
#
[config]
# Specify the domain center Latitude and Longitude
-domlat=24.0
+domlat=25.0
domlon=-62.0
# Same as domlat and domlon but vitals formatted
-vitalsdomlat=240N
+vitalsdomlat=250N
vitalsdomlon=620W
# HAFS launcher requires vitals and a storm.
@@ -28,12 +28,12 @@ fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {v
PARMforecast={PARMhafs}/forecast/regional
[grid]
-CASE=C3099 ;; FV3 resolution
-LEVS=92 ;; Model vertical levels: 65, 128, 76, 86, and 97
+CASE=C3089 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels: 65, 128, 76, 86, and 97
gtype=regional ;; grid type: uniform, stretch, nest, or regional
# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
#gridfixdir=/let/hafs_grid/generate/grid
-gridfixdir={HOMEhafs}/fix/fix_fv3/ESG_C3099_62W24N_3120x2400
+gridfixdir={HOMEhafs}/fix/fix_fv3/ESG_C3089_62W25N_3120x2160
# Otherwise, will generate the model grid according to the following grid parameters
# Need for grid types: stretch, nest and regional
stretch_fac=1.0001 ;; Stretching factor for the grid
@@ -49,19 +49,22 @@ jend_nest=1367
[forecast]
k_split=3
n_split=5
-layoutx=48
+layoutx=40
layouty=30
npx=3121
-npy=2401
-npz=91
+npy=2161
+npz=81
restart_interval="240" ;; restart interval in hours for the forecast
+write_dopost=.true.
+output_history=.false.
+
output_grid=regional_latlon
output_grid_cen_lon=-62.0 ;; central longitude
-output_grid_cen_lat=24.00 ;; central latitude
+output_grid_cen_lat=25.8 ;; central latitude
output_grid_lon_span=109.5 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
-output_grid_lat_span=71.7 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=63.6 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
diff --git a/parm/hafsv0p3_hycom.conf b/parm/hafsv0p3_hycom.conf
new file mode 100644
index 000000000..96827bc25
--- /dev/null
+++ b/parm/hafsv0p3_hycom.conf
@@ -0,0 +1,25 @@
+[config]
+run_wave=no
+ww3_model=ww3
+run_ocean=yes
+ocean_model=hycom
+
+[forecast]
+ccpp_suite_regional=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_nest=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_glob=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+# Choose nstf_name=0,0,0,0,0
+nstf_n1=0
+nstf_n2=0
+nstf_n3=0
+nstf_n4=0
+nstf_n5=0
+
+[forecast_ens]
+ccpp_suite_regional_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_nest_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+ccpp_suite_glob_ens=FV3_HAFS_v0_gfdlmp_tedmf_nonsst
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1380PE
+FORECAST_ENS_RESOURCES=FORECAST_RESOURCES_1380PE
diff --git a/parm/hafsv0p3_regional_AL.conf b/parm/hafsv0p3_regional_AL.conf
new file mode 100644
index 000000000..511d079de
--- /dev/null
+++ b/parm/hafsv0p3_regional_AL.conf
@@ -0,0 +1,77 @@
+[config]
+domlat=25.0
+domlon=-62.0
+vitalsdomlat=250N
+vitalsdomlon=620W
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C3089 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+#gridfixdir=/let/hafs_grid/generate/grid
+gridfixdir={HOMEhafs}/fix/fix_fv3/ESG_C3089_62W25N_3120x2160
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=4
+istart_nest=46
+jstart_nest=168
+iend_nest=1485
+jend_nest=1367
+
+[atm_init]
+layoutx_init=24
+layouty_init=20
+
+[forecast]
+dt_atmos=90
+npx=3121
+npy=2161
+npz=81
+k_split=3
+n_split=5
+layoutx=40
+layouty=30
+io_layoutx=2
+io_layouty=10
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+restart_interval="3 6 9"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.8 ;; central latitude
+output_grid_lon_span=109.5 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=63.6 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+
+[atm_post_ens]
+satpost_ens=.false.
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1320PE
diff --git a/parm/hafsv0p3_regional_AL_da6km.conf b/parm/hafsv0p3_regional_AL_da6km.conf
new file mode 100644
index 000000000..459532932
--- /dev/null
+++ b/parm/hafsv0p3_regional_AL_da6km.conf
@@ -0,0 +1,77 @@
+[config]
+domlat=30.0
+domlon=-62.0
+vitalsdomlat=300N
+vitalsdomlon=620W
+fakestormid=00L
+fakestormname=NATL
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C1570 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+#gridfixdir=/let/hafs_grid/generate/grid
+gridfixdir={HOMEhafs}/fix/fix_fv3/ESG0p06_C1570_62W30N_1920x1360
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=4
+istart_nest=46
+jstart_nest=168
+iend_nest=1485
+jend_nest=1367
+
+[atm_init]
+layoutx_init=24
+layouty_init=20
+
+[forecast]
+dt_atmos=120
+npx=1921
+npy=1361
+npz=81
+k_split=3
+n_split=4
+layoutx=40
+layouty=30
+io_layoutx=2
+io_layouty=10
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+restart_interval="3 6 9"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon
+output_grid_cen_lon=-62.0 ;; central longitude
+output_grid_cen_lat=25.0 ;; central latitude
+output_grid_lon_span=180.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=90.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.06 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.06 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+
+[atm_post_ens]
+satpost_ens=.false.
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1320PE
diff --git a/parm/hafsv0p3_regional_conus_3km.conf b/parm/hafsv0p3_regional_conus_3km.conf
new file mode 100644
index 000000000..8017e82e6
--- /dev/null
+++ b/parm/hafsv0p3_regional_conus_3km.conf
@@ -0,0 +1,71 @@
+[config]
+domlat=38.5
+domlon=-97.5
+vitalsdomlat=385N
+vitalsdomlon=975W
+fakestormid=00L
+fakestormname=CONUS
+fakestormorg=NHC
+fakestorm_vitals={fakestormorg} {fakestormid} {fakestormname} {YMD} {HH}{min} {vitalsdomlat} {vitalsdomlon} -99 -99 -999 -999 -099 -9 -99 -999 -999 -999 -999 M
+
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C3357 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+# If gridfixdir is provided and the dir exists, then use the pre-generated static grid fix files under gridfixdir
+#gridfixdir=/let/hafs_grid/generate/grid
+gridfixdir={HOMEhafs}/fix/fix_fv3/ESG0p03_C3357_CONUS_1748x1038
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=4
+istart_nest=46
+jstart_nest=168
+iend_nest=1485
+jend_nest=1367
+
+[forecast]
+dt_atmos=90
+npx=1748
+npy=1038
+npz=81
+k_split=3
+n_split=5
+layoutx=30
+layouty=20
+io_layoutx=1
+io_layouty=1
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+restart_interval="240"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=40
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon
+output_grid_cen_lon=-97.5 ;; central longitude
+output_grid_cen_lat=38.5 ;; central latitude
+output_grid_lon_span=72.00 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=36.00 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_680PE
diff --git a/parm/hafsv0p3_regional_mvnest.conf b/parm/hafsv0p3_regional_mvnest.conf
new file mode 100644
index 000000000..faa692277
--- /dev/null
+++ b/parm/hafsv0p3_regional_mvnest.conf
@@ -0,0 +1,94 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C512 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=2
+parent_grid_num=1,2
+parent_tile=6,7
+refine_ratio=3,3
+istart_nest=33,1201
+jstart_nest=33,1201
+iend_nest=992,1680
+jend_nest=992,1680
+
+[grid_mvnest1res]
+CASE_mvnest1res=C1536
+LEVS_mvnest1res={grid/LEVS}
+gtype_mvnest1res={grid/gtype}
+gridfixdir_mvnest1res=/let/hafs_grid/generate/grid_mvnest1res
+stretch_fac_mvnest1res={grid/stretch_fac}
+target_lon_mvnest1res={grid/target_lon}
+target_lat_mvnest1res={grid/target_lat}
+nest_grids_mvnest1res=1
+parent_grid_num_mvnest1res=1
+parent_tile_mvnest1res=6
+refine_ratio_mvnest1res=3
+istart_nest_mvnest1res=97
+jstart_nest_mvnest1res=97
+iend_nest_mvnest1res=2976
+jend_nest_mvnest1res=2976
+
+[atm_init]
+layoutx_init=12,12
+layouty_init=20,20
+
+[forecast]
+dt_atmos=90
+npx=1441,721
+npy=1441,721
+npz=81
+k_split=2,5
+n_split=5,9
+layoutx=30,30
+layouty=20,20
+io_layoutx=1,1
+io_layouty=10,10
+full_zs_filter=.true.,.true.
+n_zs_filter=1,1
+n_del2_weak=15,24
+max_slope=0.25,0.25
+shal_cnv=.true.,.true.
+do_deep=.true.,.true.
+
+# Moving nest related options
+is_moving_nest=.false.,.true.
+vortex_tracker=0,7
+ntrack=0,2
+move_cd_x=0,0
+move_cd_y=0,0
+
+restart_interval="3 6 9"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=regional_latlon,regional_latlon_moving
+output_grid_cen_lon={domlon},{domlon} ;; central longitude
+output_grid_cen_lat={domlat},{domlat} ;; central latitude
+output_grid_lon_span=108.0,24.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=84.0,24.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.06,0.02 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.06,0.02 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+post_gridspecs=auto,auto
+trak_gridspecs={post_gridspecs}
+
+[atm_post_ens]
+satpost_ens=.false.
+post_gridspecs_ens=auto,auto
+trak_gridspecs_ens={post_gridspecs}
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1320PE
diff --git a/parm/hafsv0p3_regional_storm.conf b/parm/hafsv0p3_regional_storm.conf
new file mode 100644
index 000000000..baa68bb93
--- /dev/null
+++ b/parm/hafsv0p3_regional_storm.conf
@@ -0,0 +1,66 @@
+[dir]
+PARMforecast={PARMhafs}/forecast/regional
+
+[grid]
+CASE=C512 ;; FV3 resolution
+LEVS=82 ;; Model vertical levels
+gtype=regional ;; grid type: uniform, stretch, nest, or regional
+gridfixdir=/let/hafs_grid/generate/grid
+stretch_fac=1.0001 ;; Stretching factor for the grid
+target_lon={domlon} ;; center longitude of the highest resolution tile
+target_lat={domlat} ;; center latitude of the highest resolution tile
+nest_grids=1
+parent_grid_num=1
+parent_tile=6
+refine_ratio=6
+istart_nest=93
+jstart_nest=113
+iend_nest=932
+jend_nest=912
+
+[atm_init]
+layoutx_init=24
+layouty_init=20
+
+[forecast]
+dt_atmos=90
+npx=2521
+npy=2401
+npz=81
+k_split=4
+n_split=5
+layoutx=40
+layouty=30
+io_layoutx=2
+io_layouty=10
+full_zs_filter=.true.
+n_zs_filter=1
+n_del2_weak=15
+max_slope=0.25
+shal_cnv=.true.
+do_deep=.true.
+
+restart_interval="3 6 9"
+
+quilting=.true.
+write_groups=2
+write_tasks_per_group=60
+write_dopost=.false.
+output_history=.true.
+
+output_grid=rotated_latlon
+output_grid_cen_lon={domlon} ;; central longitude
+output_grid_cen_lat={domlat} ;; central latitude
+output_grid_lon_span=78.0 ;; output domain span for longitude in regular latlon coordinate system (in degrees)
+output_grid_lat_span=72.0 ;; output domain span for latitude in regular latlon coordinate system (in degrees)
+output_grid_dlon=0.03 ;; output grid spacing dlon . . . .
+output_grid_dlat=0.03 ;; output grid spacing dlat . . . .
+
+[atm_post]
+satpost=.false.
+
+[atm_post_ens]
+satpost_ens=.false.
+
+[rocotostr]
+FORECAST_RESOURCES=FORECAST_RESOURCES_1320PE
diff --git a/parm/product/namelist.gettrk_tmp b/parm/product/namelist.gettrk_tmp
index d6788f6c4..0eece2d5f 100644
--- a/parm/product/namelist.gettrk_tmp
+++ b/parm/product/namelist.gettrk_tmp
@@ -66,10 +66,10 @@
use_waitfor = "y",
wait_min_age = 10,
wait_min_size = 100,
- wait_max_wait = 3600,
+ wait_max_wait = 7200,
wait_sleeptime = 5,
- use_per_fcst_command = "n",
- per_fcst_command = "",
+ use_per_fcst_command = "y",
+ per_fcst_command = "./deliver.sh %[FHOUR]",
/
&netcdflist
diff --git a/rocoto/cronjob_h3bs_vida.sh b/rocoto/cronjob_h3bs_vida.sh
new file mode 100755
index 000000000..627873b08
--- /dev/null
+++ b/rocoto/cronjob_h3bs_vida.sh
@@ -0,0 +1,213 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+ # h3db_vidacycst: atm_init+atm_vi+fgat+3denvar+anal_merge and cycling storm
+ conf_h3bs_vidacycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_vidacycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=pert \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_vida: atm_init+atm_vi+fgat+3denvar+anal_merge and cycling storm perturbation
+ conf_h3bs_vida="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_vida \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_dacycst: atm_init+atm_merge+fgat+3denvar+anal_merge and cycling storm
+ conf_h3bs_dacycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_dacycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_dacycdm: atm_init+atm_merge+fgat+3denvar+anal_merge and cycling whole domain
+ conf_h3bs_dacycdm="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_dacycdm \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=domainmerge analysis_merge.analysis_merge_method=domainmerge \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_vicycst: atm_init+atm_vi+anal_merge and cycling storm
+ conf_h3bs_vicycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_vicycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=pert \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_vi: atm_init+atm_vi+anal_merge and cycling storm perturbation
+ conf_h3bs_vi="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_vi \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs_init: warmstart from the coldstart atm_init (initialized from gfs analysis)
+ conf_h3bs_init="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs_init \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ forecast.restart_interval=240 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3bs: coldstart from gfs analysis
+ conf_h3bs="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs \
+ config.run_atm_init=no config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ forecast.restart_interval=240 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # Choose the configuration to run
+#confopts="${conf_h3bs_vidacycst}"
+#confopts="${conf_h3bs_vida}"
+#confopts="${conf_h3bs_dacycst}"
+#confopts="${conf_h3bs_dacycdm}"
+#confopts="${conf_h3bs_vicycst}"
+#confopts="${conf_h3bs_vi}"
+#confopts="${conf_h3bs_init}"
+#confopts="${conf_h3bs}"
+
+ confopts="${conf_h3bs_vida}"
+ # Technical testing
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY ${confopts} \
+ config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+ # Storms to run: Laura13L2020, Ida09L2021, Sam18L2021
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020081918-2020082718 13L HISTORY ${confopts}
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082612-2021083012 09L HISTORY ${confopts}
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092300-2021100500 18L HISTORY ${confopts}
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafs_cpl.sh b/rocoto/cronjob_hafs_cpl.sh
index 878838d40..b380884bc 100755
--- a/rocoto/cronjob_hafs_cpl.sh
+++ b/rocoto/cronjob_hafs_cpl.sh
@@ -14,8 +14,7 @@ date
# NOAA RDHPCS Jet
#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
-##dev="-s sites/xjet.ent -f"
-#dev="-s sites/xjet_hafsv0p2a.ent -f"
+#dev="-s sites/xjet.ent -f"
#PYTHON3=/apps/intel/intelpython3/bin/python3
# MSU Orion
diff --git a/rocoto/cronjob_hafs_mvnest.sh b/rocoto/cronjob_hafs_mvnest.sh
new file mode 100755
index 000000000..127bf1df8
--- /dev/null
+++ b/rocoto/cronjob_hafs_mvnest.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+# HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+# dev="-s sites/hera.ent -f"
+# PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+scrubopt="config.scrub_work=no config.scrub_com=no"
+
+#===============================================================================
+# Example hafs moving nest experiments
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C96_regional_1mvnest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_regional_1mvnest_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C512_regional_1mvnest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C512_regional_1mvnest_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C512_regional_1mvnest_atm_ocn \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C512_regional_1mvnest_storm.conf \
+ ../parm/hafsv0p3_hycom.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C192_global_1mvnest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C192_global_1mvnest_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C768_global_1mvnest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C768_global_1mvnest_storm.conf
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafs_mvnest_vida.sh b/rocoto/cronjob_hafs_mvnest_vida.sh
new file mode 100755
index 000000000..dbfefa02e
--- /dev/null
+++ b/rocoto/cronjob_hafs_mvnest_vida.sh
@@ -0,0 +1,236 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+ # mvnest_vidacycst: atm_init+atm_vi+fgat+d02_3denvar+anal_merge and cycling storm
+ conf_mvnest_vidacycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_vidacycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=no config.gsi_d02=yes \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=pert \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_vida: atm_init+atm_vi+fgat+d02_3denvar+anal_merge and cycling storm perturbation
+ conf_mvnest_vida="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_vida \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=no config.gsi_d02=yes \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_dacycst: atm_init+atm_merge+fgat+d02_3denvar+anal_merge and cycling storm
+ conf_mvnest_dacycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_dacycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=no config.gsi_d02=yes \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_dacycdm: atm_init+atm_merge+fgat+d02_3denvar+anal_merge and cycling domain
+ conf_mvnest_dacycdm="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_dacycdm \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=yes \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=domainmerge analysis_merge.analysis_merge_method=domainmerge \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_vicycst: atm_init+atm_vi+anal_merge and cycling storm
+ conf_mvnest_vicycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_vicycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=pert \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_vi: atm_init+atm_vi+anal_merge and cycling storm perturbation
+ conf_mvnest_vi="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_vi \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest_init: warmstart from the coldstart atm_init (initialized from gfs analysis)
+ conf_mvnest_init="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest_init \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ forecast.restart_interval=240 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # mvnest: coldstart from gfs analysis
+ conf_mvnest="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_mvnest \
+ config.run_atm_init=no config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ forecast.restart_interval=240 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # Choose the configuration to run
+#confopts="${conf_mvnest_vidacycst}"
+#confopts="${conf_mvnest_vida}"
+#confopts="${conf_mvnest_dacycst}"
+#confopts="${conf_mvnest_dacycdm}"
+#confopts="${conf_mvnest_vicycst}"
+#confopts="${conf_mvnest_vi}"
+#confopts="${conf_mvnest_init}"
+#confopts="${conf_mvnest}"
+
+ confopts="${conf_mvnest_vida}"
+ # Technical testing
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY ${confopts} \
+ config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+ # 2021 NATL Storms
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021052206-2021052318 01L HISTORY ${confopts} # Ana
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061506-2021061518 02L HISTORY ${confopts} # Bill
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061906-2021062200 03L HISTORY ${confopts} # Claudette
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021062818-2021062900 04L HISTORY ${confopts} # Danny
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021070100-2021070918 05L HISTORY ${confopts} # Elsa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021080918-2021081700 06L HISTORY ${confopts} # Fred
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081312-2021082112 07L HISTORY ${confopts} # Grace
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081600-2021082300 08L HISTORY ${confopts} # Henri
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082612-2021083012 09L HISTORY ${confopts} # Ida
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021083012-2021090112 10L HISTORY ${confopts} # Kate
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082912-2021083000 11L HISTORY ${confopts} # Julian
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021083118-2021091106 12L HISTORY ${confopts} # Larry
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021090900-2021091000 13L HISTORY ${confopts} # Mindy
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091218-2021091500 14L HISTORY ${confopts} # Nicholas
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091718-2021091818 15L HISTORY ${confopts} # Odette part 1
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092112-2021092406 15L HISTORY ${confopts} # Odette part 2
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091906-2021092100 16L HISTORY ${confopts} # Peter part 1
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092112-2021092818 16L HISTORY ${confopts} # Peter part 2
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091918-2021092300 17L HISTORY ${confopts} # Rose
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092300-2021100500 18L HISTORY ${confopts} # Sam
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092418-2021092512 19L HISTORY ${confopts} # Teresa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092918-2021100412 20L HISTORY ${confopts} # Victor
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021103100-2021110706 21L HISTORY ${confopts} # Wanda
+
+ # 2020 NATL storms
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020081918-2020082718 13L HISTORY ${confopts} # Laura
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p2a_phase3_da.sh b/rocoto/cronjob_hafs_regional_AL_da6km.sh
similarity index 69%
rename from rocoto/cronjob_hafsv0p2a_phase3_da.sh
rename to rocoto/cronjob_hafs_regional_AL_da6km.sh
index 4f71752a5..9ceec1ee8 100755
--- a/rocoto/cronjob_hafsv0p2a_phase3_da.sh
+++ b/rocoto/cronjob_hafs_regional_AL_da6km.sh
@@ -14,8 +14,7 @@ date
# NOAA RDHPCS Jet
#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
-##dev="-s sites/xjet.ent -f"
-#dev="-s sites/xjet_hafsv0p2a.ent -f"
+#dev="-s sites/xjet.ent -f"
#PYTHON3=/apps/intel/intelpython3/bin/python3
# MSU Orion
@@ -35,43 +34,32 @@ EXPT=$(basename ${HOMEhafs})
#===============================================================================
# h2db: hafsv0p2a with fgat+3denvar
- confh2db="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_phase3_h2db \
+ confh2db="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_da6km_h2db \
+ config.run_atm_init=no config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=domainmerge analysis_merge.analysis_merge_method=domainmerge \
+ config.NHRS=126 \
config.GRID_RATIO_ENS=2 \
gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_phase3_da_AL.conf \
- ../parm/hafs_hycom.conf"
-
- # h2dc: hafsv0p2a with fgat+3denvar+enkf
- confh2dc="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_phase3_h2dc \
- config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
- config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
- config.run_ensda=yes config.ENS_SIZE=40 config.run_enkf=yes \
- config.GRID_RATIO_ENS=2 \
- gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_phase3_da_AL.conf \
- ../parm/hafs_hycom.conf"
-
- # h2dd: hafsv0p2a with gsi_vr+fgat+3denvar+enkf
- confh2dd="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_phase3_h2dd \
- config.run_gsi_vr=yes config.run_gsi_vr_fgat=yes config.run_gsi_vr_ens=yes \
- config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
- config.run_ensda=yes config.ENS_SIZE=40 config.run_enkf=yes \
- config.GRID_RATIO_ENS=2 \
- gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_phase3_da_AL.conf \
- ../parm/hafs_hycom.conf"
+ gsi.online_satbias=yes \
+ ../parm/hafsv0p3_regional_AL_da6km.conf \
+ ../parm/hafsv0p3_hycom.conf"
# Choose the configuration to run
confopts="${confh2db}"
-#confopts="${confh2dc}"
-## Technical test for 2020082506-2020082512 13L2020
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 00L HISTORY ${confopts} \
-# config.run_emcgraphics=no \
-# config.scrub_work=no config.scrub_com=no
+ # Technical test for 2020082506-2020082512 13L2020
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082518 00L HISTORY ${confopts} \
+ config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+## 2021 NATL storm slots
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021080100-2021100600 00L HISTORY ${confopts} #
## 2020 NATL storm slots
#${PYTHON3} ./run_hafs.py -t ${dev} 2020060112-2020060812 00L HISTORY ${confopts} # Slot 1.0: 03L
diff --git a/rocoto/cronjob_hafs_rt.sh b/rocoto/cronjob_hafs_rt.sh
index a1352a297..2496576ad 100755
--- a/rocoto/cronjob_hafs_rt.sh
+++ b/rocoto/cronjob_hafs_rt.sh
@@ -81,6 +81,35 @@ scrubopt="config.scrub_work=no config.scrub_com=no"
config.ictype=gfsgrib2ab_0p25 forecast.nstf_n2=1 \
config.NHRS=6 ${scrubopt}
+ # Regional low-resolution static NATL basin-focused configuration with 3DEnVar with GDAS ensembles
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_regional_da_C192s1n4_3denvar \
+ config.run_gsi=yes config.run_envar=yes \
+ gsi.use_bufr_nr=yes \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_regional_da_C192s1n4.conf
+
+ # Regional storm-focused moving-nesting configuration with vortex initialization and domain 02 data assimilation
+ # atm_init+atm_vi+fgat+d02_3denvar+anal_merge and cycling storm perturbation
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_regional_mvnest_vida \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=no config.gsi_d02=yes \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=init \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=12 ${scrubopt} \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ gsi.grid_ratio_fv3_regional=1 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf
+
#===============================================================================
# Global-nesting static NATL basin-focused configuration (atm-only)
@@ -98,16 +127,6 @@ scrubopt="config.scrub_work=no config.scrub_com=no"
#===============================================================================
-# 3DEnVar with GDAS ensembles
- ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 00L HISTORY \
- config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_C192s1n4_3denvar \
- config.run_gsi=yes config.run_envar=yes \
- gsi.use_bufr_nr=yes \
- config.NHRS=12 ${scrubopt} \
- ../parm/hafs_regional_da_C192s1n4.conf
-
-#===============================================================================
-
date
echo 'cronjob done'
diff --git a/rocoto/cronjob_hafs_rt_nest.sh b/rocoto/cronjob_hafs_rt_nest.sh
new file mode 100755
index 000000000..a3c75d246
--- /dev/null
+++ b/rocoto/cronjob_hafs_rt_nest.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+scrubopt="config.scrub_work=no config.scrub_com=no"
+
+#===============================================================================
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_C96_regional_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_regional_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_C96_regional_1nest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_regional_1nest_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_C96_regional_telescopic_2nests_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_regional_telescopic_2nests_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_C96_global_1nest_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_global_1nest_storm.conf
+
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082512 00L HISTORY \
+ config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_rt_C96_global_multiple_4nests_storm \
+ config.NHRS=12 ${scrubopt} \
+ ../parm/hafs_C96_global_multiple_4nests_storm.conf
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafs_vida.sh b/rocoto/cronjob_hafs_vida.sh
new file mode 100755
index 000000000..5c8adfd2c
--- /dev/null
+++ b/rocoto/cronjob_hafs_vida.sh
@@ -0,0 +1,197 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+ # h3db_vidacycst: atm_init+atm_vi+fgat+3denvar+anal_merge and cycling storm
+ confh3db_vidacycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_vidacycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ vi.vi_storm_env=pert \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3db_vida: atm_init+atm_vi+fgat+3denvar+anal_merge and cycling storm perturbation
+ confh3db_vida="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_vida \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=yes config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ vi.vi_storm_env=init \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3db_cycst: atm_init+atm_merge+fgat+3denvar+anal_merge and cycling storm
+ confh3db_cycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_cycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3db_cycdm: atm_init+atm_merge+fgat+3denvar+anal_merge and cycling whole domain
+ confh3db_cycdm="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_cycdm \
+ config.run_atm_init=yes config.run_atm_init_fgat=yes config.run_atm_init_ens=no \
+ config.run_atm_merge=yes config.run_atm_merge_fgat=yes config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
+ config.gsi_d01=yes config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=domainmerge analysis_merge.analysis_merge_method=domainmerge \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3db_vicycst: atm_init+atm_vi+anal_merge and cycling storm
+ confh3db_vicycst="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_vicycst \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ vi.vi_storm_env=pert \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3db_vi: atm_init+atm_vi and cycling storm perturbation
+ confh3db_vi="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3db_vi \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=yes config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=yes \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ vi.vi_storm_env=init \
+ config.run_analysis_merge=yes config.run_analysis_merge_ens=no \
+ atm_merge.atm_merge_method=vortexreplace analysis_merge.analysis_merge_method=vortexreplace \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # h3da_init: warmstart from the coldstart atm_init (initialized from gfs analysis)
+ confh3da_init="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3da_init \
+ config.run_atm_init=yes config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ config.NHRS=126 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafs_hycom.conf"
+
+ # h3da: coldstart from gfs analysis directly
+ confh3da="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3da \
+ config.run_atm_init=no config.run_atm_init_fgat=no config.run_atm_init_ens=no \
+ config.run_atm_merge=no config.run_atm_merge_fgat=no config.run_atm_merge_ens=no \
+ config.run_atm_vi=no config.run_atm_vi_fgat=no config.run_atm_vi_ens=no \
+ config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
+ config.run_gsi=no config.run_fgat=no config.run_envar=no \
+ config.gsi_d01=no config.gsi_d02=no \
+ config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
+ config.run_analysis_merge=no config.run_analysis_merge_ens=no \
+ config.NHRS=126 \
+ forecast.restart_interval=240 \
+ config.GRID_RATIO_ENS=2 \
+ gsi.use_bufr_nr=yes \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+ # Choose the configuration to run
+#confopts="${confh3db_vidacycst}"
+#confopts="${confh3db_vida}"
+#confopts="${confh3db_cycst}"
+#confopts="${confh3db_cycdm}"
+#confopts="${confh3db_vicycst}"
+#confopts="${confh3db_vi}"
+#confopts="${confh3da_init}"
+#confopts="${confh3da}"
+
+ confopts="${confh3db_vida}"
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY ${confopts} \
+ config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+ # Storms to run: Laura13L2020, Ida09L2021, Sam18L2021
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020081918-2020082718 13L HISTORY ${confopts}
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082612-2021083012 09L HISTORY ${confopts}
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092300-2021100500 18L HISTORY ${confopts}
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p2a_phase3.sh b/rocoto/cronjob_hafsv0p2a_phase3.sh
deleted file mode 100755
index c549b86f5..000000000
--- a/rocoto/cronjob_hafsv0p2a_phase3.sh
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/bin/sh
-set -x
-date
-
-# NOAA WCOSS Dell Phase3
-#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
-#dev="-s sites/wcoss_dell_p3.ent -f"
-#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
-
-# NOAA WCOSS Cray
-#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
-#dev="-s sites/wcoss_cray.ent -f"
-#PYTHON3=/opt/intel/intelpython3/bin/python3
-
-# NOAA RDHPCS Jet
-#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
-##dev="-s sites/xjet.ent -f"
-#dev="-s sites/xjet_hafsv0p2a.ent -f"
-#PYTHON3=/apps/intel/intelpython3/bin/python3
-
-# MSU Orion
- HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
- dev="-s sites/orion.ent -f"
- PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
-
-# NOAA RDHPCS Hera
-#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
-#dev="-s sites/hera.ent -f"
-#PYTHON3=/apps/intel/intelpython3/bin/python3
-
-cd ${HOMEhafs}/rocoto
-
-EXPT=$(basename ${HOMEhafs})
-
-#===============================================================================
-
- # hafsv0p2a phase3 final
- confopts="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_phase3_final \
- ../parm/hafsv0p2a_phase3_AL.conf \
- ../parm/hafs_hycom.conf"
-
-## Technical test for 2020082506-2020082512 13L2020
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 00L HISTORY ${confopts} \
-# config.run_emcgraphics=no \
-# config.scrub_work=no config.scrub_com=no
-
-## 2020 NATL storm slots
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020060112-2020060812 00L HISTORY ${confopts} # Slot 1.0: 03L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020062112-2020062406 00L HISTORY ${confopts} # Slot 1.1: 04L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020070400-2020070612 00L HISTORY ${confopts} # Slot 1.2: 05L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020070912-2020071100 00L HISTORY ${confopts} # Slot 1.3: 06L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020072112-2020072618 00L HISTORY ${confopts} # Slot 1.4: 07L, 08L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020072806-2020080500 00L HISTORY ${confopts} # Slot 2: 09L, 10L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020081100-2020081612 00L HISTORY ${confopts} # Slot 3: 11L, 12L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020081918-2020082718 00L HISTORY ${confopts} # Slot 4: 13L, 14L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020083112-2020090512 00L HISTORY ${confopts} # Slot 5: 15L, 16L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020090612-2020091118 00L HISTORY ${confopts} # Slot 6: 17Lp1, 18Lp1
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020091200-2020092300 00L HISTORY ${confopts} # Slot 7: 17Lp2, 18Lp2, 19-24L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020100212-2020101018 00L HISTORY ${confopts} # Slot 8: 25L, 26L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020101618-2020102912 00L HISTORY ${confopts} # Slot 9: 27L, 28L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020101618-2020102912 00L HISTORY ${confopts} # Slot 10: 29-31L # No GFSv16 version input data
-
-## 2019 NATL storm slots
-#${PYTHON3} ./run_hafs.py -t ${dev} 2019082406-2019091006 00L HISTORY ${confopts} # Slot 5: 05-08L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2019091212-2019092712 00L HISTORY ${confopts} # Slot 6: 09-12L
-
-#===============================================================================
-
-date
-
-echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p2a_regional_da.sh b/rocoto/cronjob_hafsv0p2a_regional_da.sh
deleted file mode 100755
index 8d7e3aabe..000000000
--- a/rocoto/cronjob_hafsv0p2a_regional_da.sh
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-set -x
-date
-
-# NOAA WCOSS Dell Phase3
-#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
-#dev="-s sites/wcoss_dell_p3.ent -f"
-#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
-
-# NOAA WCOSS Cray
-#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
-#dev="-s sites/wcoss_cray.ent -f"
-#PYTHON3=/opt/intel/intelpython3/bin/python3
-
-# NOAA RDHPCS Jet
-#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
-##dev="-s sites/xjet.ent -f"
-#dev="-s sites/xjet_hafsv0p2a.ent -f"
-#PYTHON3=/apps/intel/intelpython3/bin/python3
-
-# MSU Orion
- HOMEhafs=/work/noaa/hwrf/save/${USER}/HAFS
- dev="-s sites/orion.ent -f"
- PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
-
-# NOAA RDHPCS Hera
-#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
-#dev="-s sites/hera.ent -f"
-#PYTHON3=/apps/intel/intelpython3/bin/python3
-
-cd ${HOMEhafs}/rocoto
-
-EXPT=$(basename ${HOMEhafs})
-
-#===============================================================================
-
- # h2db: hafsv0p2a with fgat+3denvar
- confh2db="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_regional_h2db \
- config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
- config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
- config.run_ensda=no config.ENS_SIZE=40 config.run_enkf=no \
- config.NHRS=102 \
- config.GRID_RATIO_ENS=2 \
- gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_regional_da_AL.conf \
- ../parm/hafs_hycom.conf"
-
- # h2dc: hafsv0p2a with fgat+3denvar+enkf
- confh2dc="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_regional_h2dc \
- config.run_gsi_vr=no config.run_gsi_vr_fgat=no config.run_gsi_vr_ens=no \
- config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
- config.run_ensda=yes config.ENS_SIZE=40 config.run_enkf=yes \
- config.NHRS=102 \
- config.GRID_RATIO_ENS=2 \
- gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_regional_da_AL.conf \
- ../parm/hafs_hycom.conf"
-
- # h2dd: hafsv0p2a with gsi_vr+fgat+3denvar+enkf
- confh2dd="config.EXPT=${EXPT} config.SUBEXPT=hafsv0p2a_regional_h2dd \
- config.run_gsi_vr=yes config.run_gsi_vr_fgat=yes config.run_gsi_vr_ens=yes \
- config.run_gsi=yes config.run_fgat=yes config.run_envar=yes \
- config.run_ensda=yes config.ENS_SIZE=40 config.run_enkf=yes \
- config.NHRS=102 \
- config.GRID_RATIO_ENS=2 \
- gsi.use_bufr_nr=yes \
- ../parm/hafsv0p2a_regional_da_AL.conf \
- ../parm/hafs_hycom.conf"
-
- # Choose the configuration to run
- confopts="${confh2db}"
-#confopts="${confh2dc}"
-
-## Technical test for 2020082506-2020082512 13L2020
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 00L HISTORY ${confopts} \
-# config.run_emcgraphics=no \
-# config.scrub_work=no config.scrub_com=no
-
-## 2020 NATL storm slots
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020060112-2020060812 00L HISTORY ${confopts} # Slot 1.0: 03L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020062112-2020062406 00L HISTORY ${confopts} # Slot 1.1: 04L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020070400-2020070612 00L HISTORY ${confopts} # Slot 1.2: 05L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020070912-2020071100 00L HISTORY ${confopts} # Slot 1.3: 06L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020072112-2020072618 00L HISTORY ${confopts} # Slot 1.4: 07L, 08L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020072806-2020080500 00L HISTORY ${confopts} # Slot 2: 09L, 10L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020081100-2020081612 00L HISTORY ${confopts} # Slot 3: 11L, 12L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020081918-2020082718 00L HISTORY ${confopts} # Slot 4: 13L, 14L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020083112-2020090512 00L HISTORY ${confopts} # Slot 5: 15L, 16L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020090612-2020091118 00L HISTORY ${confopts} # Slot 6: 17Lp1, 18Lp1
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020091200-2020092300 00L HISTORY ${confopts} # Slot 7: 17Lp2, 18Lp2, 19-24L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020100212-2020101018 00L HISTORY ${confopts} # Slot 8: 25L, 26L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020101618-2020102912 00L HISTORY ${confopts} # Slot 9: 27L, 28L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2020101618-2020102912 00L HISTORY ${confopts} # Slot 10: 29-31L # No GFSv16 version input data
-
-## 2019 NATL storm slots
-#${PYTHON3} ./run_hafs.py -t ${dev} 2019082406-2019091006 00L HISTORY ${confopts} # Slot 5: 05-08L
-#${PYTHON3} ./run_hafs.py -t ${dev} 2019091212-2019092712 00L HISTORY ${confopts} # Slot 6: 09-12L
-
-#===============================================================================
-
-date
-
-echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p3_conus_3km.sh b/rocoto/cronjob_hafsv0p3_conus_3km.sh
new file mode 100755
index 000000000..c6663823d
--- /dev/null
+++ b/rocoto/cronjob_hafsv0p3_conus_3km.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+#HOMEhafs=/work/noaa/hwrf/save/${USER}/hafsv0p3_20220305
+#dev="-s sites/orion.ent -f"
+#PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+ HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/hafsv0p3_20220322
+ dev="-s sites/hera.ent -f"
+ PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+
+ confopts="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_conus_3km \
+ config.NHRS=60 config.scrub_work=no config.scrub_com=no \
+ ../parm/hafsv0p3_regional_conus_3km.conf"
+
+# Iowa Derecho case: 2020/08/10/00 or 2020/08/10/06. The 06Z cycle performed slightly better.
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020081000 00L HISTORY ${confopts}
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020081006 00L HISTORY ${confopts}
+
+# KY/TN tornado outbreak: 2021/12/10/12
+ ${PYTHON3} ./run_hafs.py -t ${dev} 2021121012 00L HISTORY ${confopts}
+
+# MCS and diurnal isolated deep convection: 2020/07/07/00
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020070700 00L HISTORY ${confopts}
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p3_h3bp.sh b/rocoto/cronjob_hafsv0p3_h3bp.sh
new file mode 100755
index 000000000..c8e944371
--- /dev/null
+++ b/rocoto/cronjob_hafsv0p3_h3bp.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/hafsv0p3_20220412
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+
+ confopts="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bp \
+ forecast.restart_interval=240 \
+ ../parm/hafsv0p3_regional_mvnest.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+# Techincal testing
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY ${confopts} \
+# config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+# 2021 NATL storms
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021052000-2021052400 01L HISTORY ${confopts} # Ana
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061400-2021061600 02L HISTORY ${confopts} # Bill
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061712-2021062200 03L HISTORY ${confopts} # Claudette
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021062712-2021062906 04L HISTORY ${confopts} # Danny
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021063006-2021070918 05L HISTORY ${confopts} # Elsa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021080912-2021082000 06L HISTORY ${confopts} # Fred
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081206-2021082118 07L HISTORY ${confopts} # Grace
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081518-2021082406 08L HISTORY ${confopts} # Henri
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082512-2021083012 09L HISTORY ${confopts} # Ida
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082800-2021090118 10L HISTORY ${confopts} # Kate
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082812-2021083000 11L HISTORY ${confopts} # Julian
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021083100-2021091112 12L HISTORY ${confopts} # Larry
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021090812-2021091000 13L HISTORY ${confopts} # Mindy
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091200-2021091718 14L HISTORY ${confopts} # Nicholas
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091506-2021092406 15L HISTORY ${confopts} # Odette
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091800-2021092918 16L HISTORY ${confopts} # Peter
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091818-2021092406 17L HISTORY ${confopts} # Rose
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092206-2021100506 18L HISTORY ${confopts} # Sam
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092406-2021092518 19L HISTORY ${confopts} # Teresa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092818-2021100412 20L HISTORY ${confopts} # Victor
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021103012-2021110712 21L HISTORY ${confopts} # Wanda
+
+# 2020 NATL storms
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020051606-2020051918 01L HISTORY ${confopts} # Arthur
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020052700-2020052718 02L HISTORY ${confopts} # Bertha
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020060112-2020060812 03L HISTORY ${confopts} # Cristobal hwrfdata_PROD2020HDOBS
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020062112-2020062406 04L HISTORY ${confopts} # Dolly
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020070400-2020070612 05L HISTORY ${confopts} # Edouard
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020070912-2020071100 06L HISTORY ${confopts} # Fay
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072112-2020072518 07L HISTORY ${confopts} # Gonzalo
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072212-2020072618 08L HISTORY ${confopts} # Hanna
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072806-2020080500 09L HISTORY ${confopts} # Isaias
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020073018-2020080118 10L HISTORY ${confopts} # Ten
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081100-2020081612 11L HISTORY ${confopts} # Josephine
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081412-2020081600 12L HISTORY ${confopts} # Kyle
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081918-2020082718 13L HISTORY ${confopts} # Laura
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081818-2020082500 14L HISTORY ${confopts} # Marco
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020083112-2020090512 15L HISTORY ${confopts} # Omar
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020083112-2020090318 16L HISTORY ${confopts} # Nana
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020090612-2020091612 17L HISTORY ${confopts} # Paulette part1
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091806-2020092318 17L HISTORY ${confopts} # Paulette part2
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020090700-2020091412 18L HISTORY ${confopts} # Rene
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091112-2020091618 19L HISTORY ${confopts} # Sally
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091212-2020092306 20L HISTORY ${confopts} # Teddy
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091318-2020091712 21L HISTORY ${confopts} # Vicky
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091700-2020092218 22L HISTORY ${confopts} # Beta
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091718-2020092100 23L HISTORY ${confopts} # Wilfred
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091818-2020091900 24L HISTORY ${confopts} # Alpha # Do not need to run
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020100118-2020100600 25L HISTORY ${confopts} # Gamma
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020100312-2020101012 26L HISTORY ${confopts} # Delta
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020101618-2020102600 27L HISTORY ${confopts} # Epsilon
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020102412-2020102912 28L HISTORY ${confopts} # Zeta
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/cronjob_hafsv0p3_h3bs.sh b/rocoto/cronjob_hafsv0p3_h3bs.sh
new file mode 100755
index 000000000..0c5ce4028
--- /dev/null
+++ b/rocoto/cronjob_hafsv0p3_h3bs.sh
@@ -0,0 +1,103 @@
+#!/bin/sh
+set -x
+date
+
+# NOAA WCOSS Dell Phase3
+#HOMEhafs=/gpfs/dell2/emc/modeling/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_dell_p3.ent -f"
+#PYTHON3=/usrx/local/prod/packages/python/3.6.3/bin/python3
+
+# NOAA WCOSS Cray
+#HOMEhafs=/gpfs/hps3/emc/hwrf/noscrub/${USER}/save/HAFS
+#dev="-s sites/wcoss_cray.ent -f"
+#PYTHON3=/opt/intel/intelpython3/bin/python3
+
+# NOAA RDHPCS Jet
+#HOMEhafs=/mnt/lfs4/HFIP/hwrfv3/${USER}/HAFS
+#dev="-s sites/xjet.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+# MSU Orion
+ HOMEhafs=/work/noaa/hwrf/save/${USER}/hafsv0p3_20220305
+ dev="-s sites/orion.ent -f"
+ PYTHON3=/apps/intel-2020/intel-2020/intelpython3/bin/python3
+
+# NOAA RDHPCS Hera
+#HOMEhafs=/scratch1/NCEPDEV/hwrf/save/${USER}/HAFS
+#dev="-s sites/hera.ent -f"
+#PYTHON3=/apps/intel/intelpython3/bin/python3
+
+cd ${HOMEhafs}/rocoto
+
+EXPT=$(basename ${HOMEhafs})
+
+#===============================================================================
+
+ confopts="config.EXPT=${EXPT} config.SUBEXPT=${EXPT}_h3bs \
+ forecast.restart_interval=240 \
+ ../parm/hafsv0p3_regional_storm.conf \
+ ../parm/hafsv0p3_hycom.conf"
+
+# Techincal testing
+#${PYTHON3} ./run_hafs.py -t ${dev} 2020082506-2020082512 13L HISTORY ${confopts} \
+# config.NHRS=12 config.scrub_work=no config.scrub_com=no
+
+# 2021 NATL storms
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021052000-2021052400 01L HISTORY ${confopts} # Ana
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061400-2021061600 02L HISTORY ${confopts} # Bill
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021061712-2021062200 03L HISTORY ${confopts} # Claudette
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021062712-2021062906 04L HISTORY ${confopts} # Danny
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021063006-2021070918 05L HISTORY ${confopts} # Elsa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021080912-2021082000 06L HISTORY ${confopts} # Fred
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081206-2021082118 07L HISTORY ${confopts} # Grace
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021081518-2021082406 08L HISTORY ${confopts} # Henri
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082512-2021083012 09L HISTORY ${confopts} # Ida
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082800-2021090118 10L HISTORY ${confopts} # Kate
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021082812-2021083000 11L HISTORY ${confopts} # Julian
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021083100-2021091112 12L HISTORY ${confopts} # Larry
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021090812-2021091000 13L HISTORY ${confopts} # Mindy
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091200-2021091718 14L HISTORY ${confopts} # Nicholas
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091506-2021092406 15L HISTORY ${confopts} # Odette
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091800-2021092918 16L HISTORY ${confopts} # Peter
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021091818-2021092406 17L HISTORY ${confopts} # Rose
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092206-2021100506 18L HISTORY ${confopts} # Sam
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092406-2021092518 19L HISTORY ${confopts} # Teresa
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021092818-2021100412 20L HISTORY ${confopts} # Victor
+#${PYTHON3} ./run_hafs.py -t ${dev} 2021103012-2021110712 21L HISTORY ${confopts} # Wanda
+
+# 2020 NATL storms
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020051606-2020051918 01L HISTORY ${confopts} # Arthur
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020052700-2020052718 02L HISTORY ${confopts} # Bertha
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020060112-2020060812 03L HISTORY ${confhdob} # Cristobal hwrfdata_PROD2020HDOBS
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020062112-2020062406 04L HISTORY ${confopts} # Dolly
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020070400-2020070612 05L HISTORY ${confopts} # Edouard
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020070912-2020071100 06L HISTORY ${confopts} # Fay
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072112-2020072518 07L HISTORY ${confopts} # Gonzalo
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072212-2020072618 08L HISTORY ${confopts} # Hanna
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020072806-2020080500 09L HISTORY ${confopts} # Isaias
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020073018-2020080118 10L HISTORY ${confopts} # Ten
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081100-2020081612 11L HISTORY ${confopts} # Josephine
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081412-2020081600 12L HISTORY ${confopts} # Kyle
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081918-2020082718 13L HISTORY ${confopts} # Laura
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020081818-2020082500 14L HISTORY ${confopts} # Marco
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020083112-2020090512 15L HISTORY ${confopts} # Omar
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020083112-2020090318 16L HISTORY ${confopts} # Nana
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020090612-2020091612 17L HISTORY ${confopts} # Paulette part1
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091806-2020092318 17L HISTORY ${confopts} # Paulette part2
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020090700-2020091412 18L HISTORY ${confopts} # Rene
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091112-2020091618 19L HISTORY ${confopts} # Sally
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091212-2020092306 20L HISTORY ${confopts} # Teddy
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091318-2020091712 21L HISTORY ${confopts} # Vicky
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091700-2020092218 22L HISTORY ${confopts} # Beta
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091718-2020092100 23L HISTORY ${confopts} # Wilfred
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020091818-2020091900 24L HISTORY ${confopts} # Alpha # Do not need to run
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020100118-2020100600 25L HISTORY ${confopts} # Gamma
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020100312-2020101012 26L HISTORY ${confopts} # Delta
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020101618-2020102600 27L HISTORY ${confopts} # Epsilon
+#${PYTHON3} ./run_hwrf.py -t ${dev} 2020102412-2020102912 28L HISTORY ${confopts} # Zeta
+
+#===============================================================================
+
+date
+
+echo 'cronjob done'
diff --git a/rocoto/hafs_workflow.xml.in b/rocoto/hafs_workflow.xml.in
index 41b5ffd60..9bc64125d 100644
--- a/rocoto/hafs_workflow.xml.in
+++ b/rocoto/hafs_workflow.xml.in
@@ -62,19 +62,31 @@
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
@@ -256,6 +268,273 @@
+@** if gtype==regional
+
+@** if RUN_ATM_INIT_FGAT==YES
+
+ 03 06 09
+
+ &JOBhafs;/JHAFS_ATM_IC
+ hafs_atm_ic_fgat#FGAT_HR#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_ic_fgat#FGAT_HR#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_IC_RESOURCES;
+ &ENV_VARS;
+ FGAT_MODELgdas
+ FGAT_HR#FGAT_HR#
+
+
+
+
+ &RUN_DATM;NO
+
+
+ &FETCH_INPUT;YES
+
+
+ @Y@m@d@H@M@S
+
+
+@** if GFSVER==PROD2019
+ &COMgfs;/gdas.@Y@m@d/@H/gdas.t@Hz.atmf0#FGAT_HR#.nemsio
+ &COMgfs;/gdas.@Y@m@d/@H/gdas.t@Hz.sfcf0#FGAT_HR#.nemsio
+@** endif
+@** if GFSVER==PROD2021
+ &COMgfs;/gdas.@Y@m@d/@H/atmos/gdas.t@Hz.atmf0#FGAT_HR#.nc
+ &COMgfs;/gdas.@Y@m@d/@H/atmos/gdas.t@Hz.sfcf0#FGAT_HR#.nc
+@** endif
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_INIT==YES
+
+ &JOBhafs;/JHAFS_ATM_INIT
+ hafs_atm_init_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_init.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_INIT_RESOURCES;
+ &ENV_VARS;
+
+
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_INIT_FGAT==YES
+
+ 03 06 09
+
+ &JOBhafs;/JHAFS_ATM_INIT
+ hafs_atm_init_fgat#FGAT_HR#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_init_fgat#FGAT_HR#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_INIT_RESOURCES;
+ &ENV_VARS;
+ FGAT_MODELgdas
+ FGAT_HR#FGAT_HR#
+
+
+
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_MERGE==YES
+
+ &JOBhafs;/JHAFS_MERGE
+ hafs_atm_merge_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_merge.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &MERGE_RESOURCES;
+ &ENV_VARS;
+ MERGE_TYPEinit
+
+
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+
+
+
+
+@** endif
+
+@** if RUN_ATM_MERGE_FGAT==YES
+
+ 03 06 09
+
+ &JOBhafs;/JHAFS_MERGE
+ hafs_atm_merge_fgat#FGAT_HR#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_merge_fgat#FGAT_HR#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &MERGE_RESOURCES;
+ &ENV_VARS;
+ MERGE_TYPEinit
+ FGAT_MODELgdas
+ FGAT_HR#FGAT_HR#
+
+
+
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_VI==YES
+
+ &JOBhafs;/JHAFS_ATM_VI
+ hafs_atm_vi_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_vi.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_VI_RESOURCES;
+ &ENV_VARS;
+
+
+
+
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f012
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_VI_FGAT==YES
+
+ 03 06 09
+
+ &JOBhafs;/JHAFS_ATM_VI
+ hafs_atm_vi_fgat#FGAT_HR#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_vi_fgat#FGAT_HR#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_VI_RESOURCES;
+ &ENV_VARS;
+ FGAT_MODELgdas
+ FGAT_HR#FGAT_HR#
+
+
+
+
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f012
+
+
+
+
+
+
+@** endif
+
+@** if RUN_GSI_VR==YES
+
+ &JOBhafs;/JHAFS_ANALYSIS_VR
+ hafs_analysis_vr_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_analysis_vr.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ANALYSIS_RESOURCES;
+ &ENV_VARS;
+
+
+
+
+ &RUN_GSI_VR;YES
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/RESTART/grid_spec.nc
+ &COMhafs;/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f012
+
+
+
+
+
+@** endif
+
+@** if RUN_GSI_VR_FGAT==YES
+
+ 03 09
+
+ &JOBhafs;/JHAFS_ANALYSIS_VR
+ hafs_analysis_vr_fgat#FGAT_HR#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_analysis_vr_fgat#FGAT_HR#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ANALYSIS_RESOURCES;
+ &ENV_VARS;
+ FGATYES
+ FGAT_HR#FGAT_HR#
+
+
+
+ &RUN_GSI_VR_FGAT;YES
+
+
+
+ &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/RESTART/grid_spec.nc
+ &COMhafs;/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f012
+
+
+
+
+
+
+@** endif
+
+@** endif
+
@** if gtype==regional
001 002 003 004 005 006
@@ -402,68 +681,6 @@
@** endif
-@** if RUN_GSI_VR==YES
-
- &JOBhafs;/JHAFS_ANALYSIS_VR
- hafs_analysis_vr_&SID;_@Y@m@d@H
- &WORKhafs;/hafs_analysis_vr.log
- &ACCOUNT;
- &RESERVATION;
- &QUEUE_PE;
- &PE_EXTRA;
- &ANALYSIS_RESOURCES;
- &ENV_VARS;
-
-
-
-
- &RUN_GSI_VR;YES
-
-
-
- &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
- &COMhafs;/RESTART/grid_spec.nc
- if [[ $(/bin/ls -l &COMhafs;/*&sidlc;.@Y@m@d@H.trak.hafs.atcfunix.all | wc -l) -ge 1 ]]; then exit 0; else exit 1; fi
-
-
-
-
-
-@** endif
-
-@** if RUN_GSI_VR_FGAT==YES
-
- 03 09
-
- &JOBhafs;/JHAFS_ANALYSIS_VR
- hafs_analysis_vr_fgat#FGAT_HR#_&SID;_@Y@m@d@H
- &WORKhafs;/hafs_analysis_vr_fgat#FGAT_HR#.log
- &ACCOUNT;
- &RESERVATION;
- &QUEUE_PE;
- &PE_EXTRA;
- &ANALYSIS_RESOURCES;
- &ENV_VARS;
- FGATYES
- FGAT_HR#FGAT_HR#
-
-
-
- &RUN_GSI_VR_FGAT;YES
-
-
-
- &COMhafs;/RESTART/@Y@m@d.@H0000.fv_core.res.tile1.nc
- &COMhafs;/RESTART/grid_spec.nc
- if [[ $(/bin/ls -l &COMhafs;/*&sidlc;.@Y@m@d@H.trak.hafs.atcfunix.all | wc -l) -ge 1 ]]; then exit 0; else exit 1; fi
-
-
-
-
-
-
-@** endif
-
@** if RUN_GSI==YES
@@ -485,29 +702,6 @@
-@** if RUN_ATM_INIT==YES
-
- &JOBhafs;/JHAFS_ATM_INIT
- hafs_atm_init_&SID;_@Y@m@d@H
- &WORKhafs;/hafs_atm_init.log
- &ACCOUNT;
- &RESERVATION;
- &QUEUE_PE;
- &PE_EXTRA;
- &ATM_INIT_RESOURCES;
- &ENV_VARS;
-
-
-
-
-@** if gtype==regional
-
-@** endif
-
-
-
-@** endif
-
&JOBhafs;/JHAFS_ANALYSIS
hafs_analysis_&SID;_@Y@m@d@H
@@ -523,6 +717,18 @@
&RUN_GSI;YES
+@** if RUN_ATM_VI_FGAT==YES
+
+ &RUN_ATM_VI_FGAT;YES
+
+
+@** endif
+@** if RUN_ATM_MERGE_FGAT==YES
+
+ &RUN_ATM_MERGE_FGAT;YES
+
+
+@** endif
@** if RUN_GSI_VR==YES
&RUN_GSI_VR;YES
@@ -549,29 +755,37 @@
@** endif
-@** endif
-@** if RUN_ATM_INIT==YES
-
- &JOBhafs;/JHAFS_ATM_INIT
- hafs_atm_init_&SID;_@Y@m@d@H
- &WORKhafs;/hafs_atm_init.log
+@** if RUN_ANALYSIS_MERGE==YES
+
+ &JOBhafs;/JHAFS_MERGE
+ hafs_analysis_merge_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_analysis_merge.log
&ACCOUNT;
&RESERVATION;
&QUEUE_PE;
&PE_EXTRA;
- &ATM_INIT_RESOURCES;
+ &MERGE_RESOURCES;
&ENV_VARS;
-
+ MERGE_TYPEanalysis
-
-@** if gtype==regional
-
+@** if RUN_ATM_INIT==YES
+
@** endif
+
+
+ &RUN_ATM_VI;YES
+
+
+
+ &RUN_GSI;YES
+
+@** endif
+
@** endif
@@ -602,12 +816,24 @@
@** if gtype==regional
-@** if RUN_GSI==YES
-
+@** if RUN_ATM_INIT==YES
+
+@** endif
+@** if RUN_ATM_MERGE==YES
+
+@** endif
+@** if RUN_ATM_VI==YES
+
@** endif
@** if RUN_GSI_VR==YES
@** endif
+@** if RUN_GSI==YES
+
+@** endif
+@** if RUN_ANALYSIS_MERGE==YES
+
+@** endif
@** endif
@@ -776,6 +1002,133 @@
+@** if RUN_ATM_INIT_ENS==YES
+
+ &ENSIDS;
+
+ &JOBhafs;/JHAFS_ATM_INIT
+ hafs_atm_init_ens#MEM#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_init_ens#MEM#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_INIT_RESOURCES;
+ &ENV_VARS;
+ ENSDAYES
+ ENSID#MEM#
+
+
+
+
+ &RUN_ATM_INIT_ENS;YES
+
+
+
+
+@** endif
+
+@** if RUN_ATM_MERGE_ENS==YES
+
+ &ENSIDS;
+
+ &JOBhafs;/JHAFS_MERGE
+ hafs_atm_merge_ens#MEM#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_merge_ens#MEM#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &MERGE_RESOURCES;
+ &ENV_VARS;
+ MERGE_TYPEinit
+ ENSDAYES
+ ENSID#MEM#
+
+
+
+
+ &RUN_ATM_MERGE_ENS;YES
+
+
+
+ &COMhafs;/RESTART_ens/mem#MEM#/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/product_ens/mem#MEM#/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f006
+
+
+
+
+
+
+@** endif
+
+@** if RUN_ATM_VI_ENS==YES
+
+ &ENSIDS;
+
+ &JOBhafs;/JHAFS_ATM_VI
+ hafs_atm_vi_ens#MEM#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_atm_vi_ens#MEM#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ATM_VI_RESOURCES;
+ &ENV_VARS;
+ ENSDAYES
+ ENSID#MEM#
+
+
+
+
+ &RUN_ATM_VI_ENS;YES
+
+
+
+ &COMhafs;/RESTART_ens/mem#MEM#/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/product_ens/mem#MEM#/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f006
+
+
+
+
+
+
+@** endif
+
+@** if RUN_GSI_VR_ENS==YES
+
+ &ENSIDS;
+
+ &JOBhafs;/JHAFS_ANALYSIS_VR
+ hafs_analysis_vr_ens#MEM#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_analysis_vr_ens#MEM#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &ANALYSIS_RESOURCES;
+ &ENV_VARS;
+ ENSDAYES
+ ENSID#MEM#
+
+
+
+
+ &RUN_GSI_VR_ENS;YES
+
+
+
+ &COMhafs;/RESTART_ens/mem#MEM#/@Y@m@d.@H0000.fv_core.res.tile1.nc
+ &COMhafs;/RESTART_ens/mem#MEM#/grid_spec.nc
+ &COMhafs;/product_ens/mem#MEM#/&sidlc;.@Y@m@d@H.hafs.trak.atcfunix.f006
+
+
+
+
+
+
+@** endif
+
@** if gtype==regional
&ENSIDS;
@@ -821,40 +1174,6 @@
@** endif
-@** if RUN_GSI_VR_ENS==YES
-
- &ENSIDS;
-
- &JOBhafs;/JHAFS_ANALYSIS_VR
- hafs_analysis_vr_ens#MEM#_&SID;_@Y@m@d@H
- &WORKhafs;/hafs_analysis_vr_ens#MEM#.log
- &ACCOUNT;
- &RESERVATION;
- &QUEUE_PE;
- &PE_EXTRA;
- &ANALYSIS_RESOURCES;
- &ENV_VARS;
- ENSDAYES
- ENSID#MEM#
-
-
-
-
- &RUN_GSI_VR_ENS;YES
-
-
-
- &COMhafs;/RESTART_ens/mem#MEM#/@Y@m@d.@H0000.fv_core.res.tile1.nc
- &COMhafs;/RESTART_ens/mem#MEM#/grid_spec.nc
- if [[ $(/bin/ls -l &COMhafs;/product_ens/mem#MEM#/*&sidlc;.@Y@m@d@H.trak.hafs.atcfunix.all | wc -l) -ge 1 ]]; then exit 0; else exit 1; fi
-
-
-
-
-
-
-@** endif
-
@** if RUN_ENKF==YES
&JOBhafs;/JHAFS_ENKF_MEAN
@@ -973,6 +1292,41 @@
@** endif
+@** if RUN_ANALYSIS_MERGE_ENS==YES
+
+ &ENSIDS;
+
+ &JOBhafs;/JHAFS_MERGE
+ hafs_analysis_merge_ens#MEM#_&SID;_@Y@m@d@H
+ &WORKhafs;/hafs_analysis_merge_ens#MEM#.log
+ &ACCOUNT;
+ &RESERVATION;
+ &QUEUE_PE;
+ &PE_EXTRA;
+ &MERGE_RESOURCES;
+ &ENV_VARS;
+ MERGE_TYPEanalysis
+ ENSDAYES
+ ENSID#MEM#
+
+
+@** if RUN_ATM_INIT_ENS==YES
+
+@** endif
+
+
+ &RUN_ATM_VI_ENS;YES
+
+
+
+ &RUN_ANALYSIS_MERGE_ENS;YES
+
+
+
+
+
+@** endif
+
&ENSIDS;
@@ -1014,6 +1368,12 @@
@** endif
+@** if RUN_ANALYSIS_MERGE_ENS==YES
+
+
+
+
+@** endif
@** endif
@@ -1074,7 +1434,6 @@
@** endif
-
@** if RUN_HRDGRAPHICS==YES
&JOBhafs;/JHAFS_HRDGRAPHICS
@@ -1134,7 +1493,7 @@
&CORES_EXTRA;
TOTAL_TASKS1
06:00:00
- &MEMORY;
+ &MORE_MEMORY;
&ENV_VARS;
ARCHIVE_STEPDISK
@@ -1174,7 +1533,7 @@
&CORES_EXTRA;
TOTAL_TASKS1
06:00:00
- &MEMORY;
+ &MORE_MEMORY;
&ENV_VARS;
ARCHIVE_STEPTAPE
@@ -1215,7 +1574,7 @@
&CORES_EXTRA;
TOTAL_TASKS1
06:00:00
- &MEMORY;
+ &MORE_MEMORY;
&ENV_VARS;
diff --git a/rocoto/sites/hera.ent b/rocoto/sites/hera.ent
index 0fa96d7aa..b93759b96 100644
--- a/rocoto/sites/hera.ent
+++ b/rocoto/sites/hera.ent
@@ -16,19 +16,22 @@
1G">
5G">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS600:30:0024G">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS601:30:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
+ 6:ppn=10:tpp=1TOTAL_TASKS60NCTSK10OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 40:ppn=20:tpp=2TOTAL_TASKS800NCTSK20OMP_THREADS203:00:00">
+ 40:ppn=10:tpp=2TOTAL_TASKS400NCTSK10OMP_THREADS203:59:00">
41:ppn=1:tpp=40TOTAL_TASKS41NCTSK1OMP_THREADS4002:00:00">
1:ppn=20:tpp=1TOTAL_TASKS20NCTSK20OMP_THREADS102:00:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS102:00:00">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20OMP_THREADS202:00:00">
07:59:00">
OMP_THREADS2">
@@ -60,8 +63,6 @@
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -78,6 +79,8 @@
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -95,6 +98,7 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
+ 68:ppn=20:tpp=2TOTAL_TASKS1360NCTSK20&FORECAST_EXTRA;">
79:ppn=20:tpp=2TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
@@ -102,7 +106,6 @@
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
73:ppn=20:tpp=2TOTAL_TASKS1460NCTSK20&FORECAST_EXTRA;">
73:ppn=20:tpp=2TOTAL_TASKS1460NCTSK20&FORECAST_EXTRA;">
- 71:ppn=20:tpp=2TOTAL_TASKS1420NCTSK20&FORECAST_EXTRA;">
82:ppn=20:tpp=2TOTAL_TASKS1640NCTSK20&FORECAST_EXTRA;">
106:ppn=20:tpp=2TOTAL_TASKS2120NCTSK20&FORECAST_EXTRA;">
@@ -110,6 +113,11 @@
6:ppn=40:tpp=1TOTAL_TASKS240NCTSK40OMP_THREADS103:00:00">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=2TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -135,6 +143,38 @@
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=2TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=2TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=2TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=2TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=2TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+ 34:ppn=20:tpp=2TOTAL_TASKS680NCTSK20&FORECAST_EXTRA;">
+ 63:ppn=20:tpp=2TOTAL_TASKS1260NCTSK20&FORECAST_EXTRA;">
+ 66:ppn=20:tpp=2TOTAL_TASKS1320NCTSK20&FORECAST_EXTRA;">
+ 69:ppn=20:tpp=2TOTAL_TASKS1380NCTSK20&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=2TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=2TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=2TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=2TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -200,10 +240,10 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
+ 4:ppn=20:tpp=1TOTAL_TASKS80NCTSK20OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
+ 1:ppn=2:tpp=1TOTAL_TASKS2NCTSK2OMP_THREADS107:59:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
diff --git a/rocoto/sites/kjet.ent b/rocoto/sites/kjet.ent
index 17e36fdf6..3b55b8477 100644
--- a/rocoto/sites/kjet.ent
+++ b/rocoto/sites/kjet.ent
@@ -16,19 +16,22 @@
1G">
5G">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS600:30:0024G">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS601:30:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
+ 6:ppn=10:tpp=1TOTAL_TASKS60NCTSK10OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 40:ppn=20:tpp=2TOTAL_TASKS800NCTSK20OMP_THREADS203:00:00">
+ 40:ppn=10:tpp=2TOTAL_TASKS400NCTSK10OMP_THREADS203:59:00">
41:ppn=1:tpp=40TOTAL_TASKS41NCTSK1OMP_THREADS4002:00:00">
1:ppn=20:tpp=1TOTAL_TASKS20NCTSK20OMP_THREADS102:00:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS102:00:00">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20OMP_THREADS202:00:00">
07:59:00">
OMP_THREADS2">
@@ -60,8 +63,6 @@
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -78,6 +79,8 @@
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -88,7 +91,6 @@
115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
- 116:ppn=12:tpp=2+1:ppn=8:tpp=2TOTAL_TASKS1400NCTSK12&FORECAST_EXTRA;">
135:ppn=12:tpp=2TOTAL_TASKS1620NCTSK12&FORECAST_EXTRA;">
175:ppn=12:tpp=2TOTAL_TASKS2100NCTSK12&FORECAST_EXTRA;">
@@ -96,6 +98,7 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
+ 68:ppn=20:tpp=2TOTAL_TASKS1360NCTSK20&FORECAST_EXTRA;">
79:ppn=20:tpp=2TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
@@ -106,7 +109,15 @@
82:ppn=20:tpp=2TOTAL_TASKS1640NCTSK20&FORECAST_EXTRA;">
106:ppn=20:tpp=2TOTAL_TASKS2120NCTSK20&FORECAST_EXTRA;">
+
+ 6:ppn=40:tpp=1TOTAL_TASKS240NCTSK40OMP_THREADS103:00:00">
+
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=2TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -132,6 +143,38 @@
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=2TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=2TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=2TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=2TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=2TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+ 34:ppn=20:tpp=2TOTAL_TASKS680NCTSK20&FORECAST_EXTRA;">
+ 63:ppn=20:tpp=2TOTAL_TASKS1260NCTSK20&FORECAST_EXTRA;">
+ 66:ppn=20:tpp=2TOTAL_TASKS1320NCTSK20&FORECAST_EXTRA;">
+ 69:ppn=20:tpp=2TOTAL_TASKS1380NCTSK20&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=2TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=2TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=2TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=2TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -197,10 +240,10 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
+ 2:ppn=40:tpp=1TOTAL_TASKS80NCTSK40OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
+ 1:ppn=2:tpp=1TOTAL_TASKS2NCTSK2OMP_THREADS107:59:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
diff --git a/rocoto/sites/orion.ent b/rocoto/sites/orion.ent
index 693f52e04..925ba8a28 100644
--- a/rocoto/sites/orion.ent
+++ b/rocoto/sites/orion.ent
@@ -18,17 +18,20 @@
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
- 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS600:30:0024G">
+ 6:ppn=2:tpp=6TOTAL_TASKS12NCTSK2OMP_THREADS601:30:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
+ 6:ppn=10:tpp=1TOTAL_TASKS60NCTSK10OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS100:30:00">
6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS101:00:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS100:30:00">
- 40:ppn=20:tpp=2TOTAL_TASKS800NCTSK20OMP_THREADS203:00:00">
+ 40:ppn=10:tpp=2TOTAL_TASKS400NCTSK10OMP_THREADS203:59:00">
41:ppn=1:tpp=40TOTAL_TASKS41NCTSK1OMP_THREADS4002:00:00">
1:ppn=20:tpp=1TOTAL_TASKS20NCTSK20OMP_THREADS102:00:00">
+ 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS102:00:00">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20OMP_THREADS202:00:00">
07:59:00">
OMP_THREADS2">
@@ -60,8 +63,6 @@
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -78,6 +79,8 @@
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -110,6 +113,11 @@
6:ppn=40:tpp=1TOTAL_TASKS240NCTSK40OMP_THREADS103:00:00">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=2TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -135,6 +143,38 @@
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=2TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=2TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=2TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=2TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=2TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+ 34:ppn=20:tpp=2TOTAL_TASKS680NCTSK20&FORECAST_EXTRA;">
+ 63:ppn=20:tpp=2TOTAL_TASKS1260NCTSK20&FORECAST_EXTRA;">
+ 66:ppn=20:tpp=2TOTAL_TASKS1320NCTSK20&FORECAST_EXTRA;">
+ 69:ppn=20:tpp=2TOTAL_TASKS1380NCTSK20&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=2TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=2TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=2TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=2TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -200,10 +240,10 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
+ 2:ppn=40:tpp=1TOTAL_TASKS80NCTSK40OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
+ 1:ppn=2:tpp=1TOTAL_TASKS2NCTSK2OMP_THREADS107:59:0024G">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK1OMP_THREADS107:59:00">
1:ppn=40:tpp=1TOTAL_TASKS40NCTSK40OMP_THREADS107:59:00">
diff --git a/rocoto/sites/wcoss_cray.ent b/rocoto/sites/wcoss_cray.ent
index c81f6815f..b7d7f39c5 100644
--- a/rocoto/sites/wcoss_cray.ent
+++ b/rocoto/sites/wcoss_cray.ent
@@ -18,17 +18,20 @@
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
- 3:ppn=4:tpp=6TOTAL_TASKS12NCTSK4OMP_THREADS600:30:00">
+ 3:ppn=6:tpp=4TOTAL_TASKS18NCTSK6OMP_THREADS401:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
15:ppn=12:tpp=1TOTAL_TASKS180NCTSK12OMP_THREADS100:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS103:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS100:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS103:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS101:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
- 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12OMP_THREADS202:00:00">
+ 50:ppn=6:tpp=2TOTAL_TASKS300NCTSK6OMP_THREADS202:00:00">
60:ppn=1:tpp=24TOTAL_TASKS60NCTSK1OMP_THREADS2402:00:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS102:00:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS102:00:00">
+ 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12OMP_THREADS202:00:00">
07:59:00">
OMP_THREADS2">
@@ -60,8 +63,6 @@
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -78,8 +79,8 @@
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
- 118:ppn=12:tpp=1TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
- 118:ppn=12:tpp=1TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -97,6 +98,7 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
+ 68:ppn=20:tpp=2TOTAL_TASKS1360NCTSK20&FORECAST_EXTRA;">
79:ppn=20:tpp=2TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
@@ -107,7 +109,15 @@
82:ppn=20:tpp=2TOTAL_TASKS1640NCTSK20&FORECAST_EXTRA;">
106:ppn=20:tpp=2TOTAL_TASKS2120NCTSK20&FORECAST_EXTRA;">
+
+ 10:ppn=24:tpp=1TOTAL_TASKS240NCTSK24OMP_THREADS103:00:00">
+
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=2TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -133,6 +143,38 @@
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=2TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=2TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=2TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=2TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=2TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 15:ppn=12:tpp=2TOTAL_TASKS180NCTSK12&FORECAST_EXTRA;">
+ 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12&FORECAST_EXTRA;">
+ 68:ppn=10:tpp=2TOTAL_TASKS680NCTSK10&FORECAST_EXTRA;">
+ 105:ppn=12:tpp=2TOTAL_TASKS1260NCTSK12&FORECAST_EXTRA;">
+ 110:ppn=12:tpp=2TOTAL_TASKS1320NCTSK12&FORECAST_EXTRA;">
+ 115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=2TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=2TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=2TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=2TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -198,10 +240,10 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
+ 4:ppn=24:tpp=1TOTAL_TASKS96NCTSK24OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:002G">
+ 2:ppn=1:tpp=1TOTAL_TASKS2NCTSK1OMP_THREADS107:59:00">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
diff --git a/rocoto/sites/wcoss_dell_p3.ent b/rocoto/sites/wcoss_dell_p3.ent
index 18bbebee0..74131240a 100644
--- a/rocoto/sites/wcoss_dell_p3.ent
+++ b/rocoto/sites/wcoss_dell_p3.ent
@@ -19,17 +19,20 @@
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
- 1:ppn=6:tpp=1TOTAL_TASKS6NCTSK6OMP_THREADS4-R affinity[core\(4\):distribute=balance]00:30:00">
+ 3:ppn=6:tpp=1TOTAL_TASKS18NCTSK6OMP_THREADS4-R affinity[core\(4\):distribute=balance]01:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS101:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS103:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS101:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS103:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS101:00:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
50:ppn=12:tpp=1TOTAL_TASKS600NCTSK12OMP_THREADS2-R affinity[core\(2\):distribute=balance]02:00:00">
60:ppn=1:tpp=1TOTAL_TASKS60NCTSK1OMP_THREADS24-R affinity[core\(24\):distribute=balance]02:00:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS102:00:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS102:00:00">
+ 50:ppn=12:tpp=1TOTAL_TASKS600NCTSK12OMP_THREADS2-R affinity[core\(2\):distribute=balance]02:00:00">
07:59:00">
OMP_THREADS2-R affinity[core\(2\):distribute=balance]">
@@ -61,8 +64,6 @@
6:ppn=12:tpp=1TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=1TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=1TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=1TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=1TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -98,6 +99,7 @@
67:ppn=20:tpp=1TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=1TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=1TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
+ 68:ppn=20:tpp=1TOTAL_TASKS1360NCTSK20&FORECAST_EXTRA;">
79:ppn=20:tpp=1TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
103:ppn=20:tpp=1TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
@@ -107,11 +109,16 @@
73:ppn=20:tpp=1TOTAL_TASKS1460NCTSK20&FORECAST_EXTRA;">
82:ppn=20:tpp=1TOTAL_TASKS1640NCTSK20&FORECAST_EXTRA;">
106:ppn=20:tpp=1TOTAL_TASKS2120NCTSK20&FORECAST_EXTRA;">
+
10:ppn=24:tpp=1TOTAL_TASKS240NCTSK24OMP_THREADS103:00:00">
- 114:ppn=12:tpp=1+1:ppn=8:tpp=1TOTAL_TASKS1376NCTSK12&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=1TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=1TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=1TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=1TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=1TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=1TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -137,6 +144,38 @@
91:ppn=20:tpp=1TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=1TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=1TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=1TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=1TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=1TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=1TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=1TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=1TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=1TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 15:ppn=12:tpp=1TOTAL_TASKS180NCTSK12&FORECAST_EXTRA;">
+ 50:ppn=12:tpp=1TOTAL_TASKS600NCTSK12&FORECAST_EXTRA;">
+ 68:ppn=10:tpp=1TOTAL_TASKS680NCTSK10&FORECAST_EXTRA;">
+ 105:ppn=12:tpp=1TOTAL_TASKS1260NCTSK12&FORECAST_EXTRA;">
+ 110:ppn=12:tpp=1TOTAL_TASKS1320NCTSK12&FORECAST_EXTRA;">
+ 115:ppn=12:tpp=1TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=1TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=1TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=1TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=1TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=1TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=1TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=1TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -167,7 +206,7 @@
34:ppn=12:tpp=1TOTAL_TASKS408NCTSK12&FORECAST_EXTRA;">
39:ppn=12:tpp=1TOTAL_TASKS468NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=1TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
- 49:ppn=12:tpp=2TOTAL_TASKS588NCTSK12&FORECAST_EXTRA;">
+ 49:ppn=12:tpp=1TOTAL_TASKS588NCTSK12&FORECAST_EXTRA;">
54:ppn=12:tpp=1TOTAL_TASKS648NCTSK12&FORECAST_EXTRA;">
109:ppn=12:tpp=1TOTAL_TASKS1308NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=1TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -202,10 +241,10 @@
67:ppn=20:tpp=1TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=1TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
+ 3:ppn=24:tpp=1TOTAL_TASKS72NCTSK24OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
+ 1:ppn=2:tpp=1TOTAL_TASKS2NCTSK2OMP_THREADS107:59:0024G">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
diff --git a/rocoto/sites/xjet.ent b/rocoto/sites/xjet.ent
index 0f4fe0925..45177abd5 100644
--- a/rocoto/sites/xjet.ent
+++ b/rocoto/sites/xjet.ent
@@ -16,19 +16,22 @@
1G">
5G">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 1:ppn=12TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 3:ppn=4:tpp=6TOTAL_TASKS12NCTSK4OMP_THREADS600:30:00">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:0024G">
+ 3:ppn=4:tpp=6TOTAL_TASKS12NCTSK4OMP_THREADS601:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
8:ppn=24:tpp=1TOTAL_TASKS192NCTSK24OMP_THREADS101:30:00">
5:ppn=12:tpp=1TOTAL_TASKS60NCTSK12OMP_THREADS103:30:00">
5:ppn=24:tpp=1TOTAL_TASKS120NCTSK24OMP_THREADS100:30:00">
5:ppn=12:tpp=1TOTAL_TASKS60NCTSK12OMP_THREADS103:30:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS101:00:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12OMP_THREADS202:00:00">
60:ppn=1:tpp=24TOTAL_TASKS60NCTSK1OMP_THREADS2402:00:00">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS102:00:00">
+ 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS102:00:00">
+ 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12OMP_THREADS202:00:00">
07:59:00">
OMP_THREADS2">
@@ -60,8 +63,6 @@
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
@@ -78,6 +79,8 @@
113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
+ 118:ppn=12:tpp=2TOTAL_TASKS1416NCTSK12&FORECAST_EXTRA;">
44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
@@ -88,7 +91,6 @@
115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
- 116:ppn=12:tpp=2+1:ppn=8:tpp=2TOTAL_TASKS1400NCTSK12&FORECAST_EXTRA;">
135:ppn=12:tpp=2TOTAL_TASKS1620NCTSK12&FORECAST_EXTRA;">
175:ppn=12:tpp=2TOTAL_TASKS2100NCTSK12&FORECAST_EXTRA;">
@@ -96,6 +98,7 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
+ 68:ppn=20:tpp=2TOTAL_TASKS1360NCTSK20&FORECAST_EXTRA;">
79:ppn=20:tpp=2TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
@@ -110,6 +113,11 @@
10:ppn=24:tpp=1TOTAL_TASKS240NCTSK24OMP_THREADS103:00:00">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 104:ppn=20:tpp=2TOTAL_TASKS2080NCTSK20&FORECAST_EXTRA;">
+ 30:ppn=20:tpp=2TOTAL_TASKS600NCTSK20&FORECAST_EXTRA;">
+
52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
@@ -135,6 +143,38 @@
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
+ 6:ppn=20:tpp=2TOTAL_TASKS120NCTSK20&FORECAST_EXTRA;">
+ 9:ppn=20:tpp=2TOTAL_TASKS180NCTSK20&FORECAST_EXTRA;">
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+
+ 8:ppn=20:tpp=2TOTAL_TASKS160NCTSK20&FORECAST_EXTRA;">
+ 11:ppn=20:tpp=2TOTAL_TASKS220NCTSK20&FORECAST_EXTRA;">
+ 96:ppn=20:tpp=2TOTAL_TASKS1920NCTSK20&FORECAST_EXTRA;">
+ 99:ppn=20:tpp=2TOTAL_TASKS1980NCTSK20&FORECAST_EXTRA;">
+ 49:ppn=20:tpp=2TOTAL_TASKS980NCTSK20&FORECAST_EXTRA;">
+
+ 15:ppn=12:tpp=2TOTAL_TASKS180NCTSK12&FORECAST_EXTRA;">
+ 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12&FORECAST_EXTRA;">
+ 68:ppn=10:tpp=2TOTAL_TASKS680NCTSK10&FORECAST_EXTRA;">
+ 105:ppn=12:tpp=2TOTAL_TASKS1260NCTSK12&FORECAST_EXTRA;">
+ 110:ppn=12:tpp=2TOTAL_TASKS1320NCTSK12&FORECAST_EXTRA;">
+ 115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
+
+
+ 12:ppn=20:tpp=2TOTAL_TASKS240NCTSK20&FORECAST_EXTRA;">
+ 38:ppn=20:tpp=2TOTAL_TASKS760NCTSK20&FORECAST_EXTRA;">
+ 43:ppn=20:tpp=2TOTAL_TASKS860NCTSK20&FORECAST_EXTRA;">
+
+ 21:ppn=20:tpp=2TOTAL_TASKS420NCTSK20&FORECAST_EXTRA;">
+ 58:ppn=20:tpp=2TOTAL_TASKS1160NCTSK20&FORECAST_EXTRA;">
+
+
6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
@@ -200,10 +240,10 @@
67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 1:ppn=12:tpp=1TOTAL_TASKS12NCTSK12OMP_THREADS107:59:00">
+ 5:ppn=12:tpp=1TOTAL_TASKS60NCTSK12OMP_THREADS107:59:00">
1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
+ 1:ppn=2:tpp=1TOTAL_TASKS2NCTSK2OMP_THREADS107:59:0024G">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
diff --git a/rocoto/sites/xjet_hafsv0p2a.ent b/rocoto/sites/xjet_hafsv0p2a.ent
deleted file mode 100644
index ab259faa8..000000000
--- a/rocoto/sites/xjet_hafsv0p2a.ent
+++ /dev/null
@@ -1,206 +0,0 @@
-
-
-
-
-
- --partition=xjet">
-
- --partition=xjet">
-
- --partition=xjet">
-
- --partition=service">
- 24">
- 24">
-
- 1G">
- 5G">
-
- 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 1:ppn=1TOTAL_TASKS1NCTSK1OMP_THREADS100:25:00">
- 3:ppn=4:tpp=6TOTAL_TASKS12NCTSK4OMP_THREADS600:30:00">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
- 30:ppn=24:tpp=1TOTAL_TASKS720NCTSK24OMP_THREADS101:30:00">
- 5:ppn=12:tpp=1TOTAL_TASKS60NCTSK12OMP_THREADS103:30:00">
- 5:ppn=24:tpp=1TOTAL_TASKS120NCTSK24OMP_THREADS100:30:00">
- 5:ppn=12:tpp=1TOTAL_TASKS60NCTSK12OMP_THREADS103:30:00">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS100:30:00">
- 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12OMP_THREADS202:00:00">
- 60:ppn=1:tpp=24TOTAL_TASKS60NCTSK1OMP_THREADS2402:00:00">
- 2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS102:00:00">
-
- 07:59:00">
- OMP_THREADS2">
-
-
-
- 20:ppn=12:tpp=2TOTAL_TASKS240NCTSK12&FORECAST_EXTRA;">
- 108:ppn=12:tpp=2TOTAL_TASKS1296NCTSK12&FORECAST_EXTRA;">
- 168:ppn=12:tpp=2TOTAL_TASKS2016NCTSK12&FORECAST_EXTRA;">
-
- 20:ppn=12:tpp=2TOTAL_TASKS240NCTSK12&FORECAST_EXTRA;">
- 108:ppn=12:tpp=2TOTAL_TASKS1296NCTSK12&FORECAST_EXTRA;">
- 168:ppn=12:tpp=2TOTAL_TASKS2016NCTSK12&FORECAST_EXTRA;">
-
- 21:ppn=12:tpp=2TOTAL_TASKS252NCTSK12&FORECAST_EXTRA;">
- 109:ppn=12:tpp=2TOTAL_TASKS1308NCTSK12&FORECAST_EXTRA;">
- 169:ppn=12:tpp=2TOTAL_TASKS2028NCTSK12&FORECAST_EXTRA;">
-
- 22:ppn=12:tpp=2TOTAL_TASKS264NCTSK12&FORECAST_EXTRA;">
- 110:ppn=12:tpp=2TOTAL_TASKS1320NCTSK12&FORECAST_EXTRA;">
- 170:ppn=12:tpp=2TOTAL_TASKS2040NCTSK12&FORECAST_EXTRA;">
-
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
- 100:ppn=20:tpp=2TOTAL_TASKS2000NCTSK20&FORECAST_EXTRA;">
-
- 67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
- 103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
-
- 6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
- 4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
-
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
-
-
- 43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
- 113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
- 115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
- 133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
- 173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
-
- 39:ppn=12:tpp=2TOTAL_TASKS468NCTSK12&FORECAST_EXTRA;">
- 109:ppn=12:tpp=2TOTAL_TASKS1308NCTSK12&FORECAST_EXTRA;">
- 129:ppn=12:tpp=2TOTAL_TASKS1548NCTSK12&FORECAST_EXTRA;">
- 169:ppn=12:tpp=2TOTAL_TASKS2028NCTSK12&FORECAST_EXTRA;">
-
- 43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
- 113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
- 133:ppn=12:tpp=2TOTAL_TASKS1596NCTSK12&FORECAST_EXTRA;">
- 173:ppn=12:tpp=2TOTAL_TASKS2076NCTSK12&FORECAST_EXTRA;">
-
- 44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
- 114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
- 134:ppn=12:tpp=2TOTAL_TASKS1608NCTSK12&FORECAST_EXTRA;">
- 174:ppn=12:tpp=2TOTAL_TASKS2088NCTSK12&FORECAST_EXTRA;">
-
- 45:ppn=12:tpp=2TOTAL_TASKS540NCTSK12&FORECAST_EXTRA;">
- 115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
- 120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
- 120:ppn=12:tpp=2TOTAL_TASKS1440NCTSK12&FORECAST_EXTRA;">
- 135:ppn=12:tpp=2TOTAL_TASKS1620NCTSK12&FORECAST_EXTRA;">
- 175:ppn=12:tpp=2TOTAL_TASKS2100NCTSK12&FORECAST_EXTRA;">
-
- 22:ppn=20:tpp=2TOTAL_TASKS440NCTSK20&FORECAST_EXTRA;">
- 67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
- 70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 79:ppn=20:tpp=2TOTAL_TASKS1580NCTSK20&FORECAST_EXTRA;">
- 103:ppn=20:tpp=2TOTAL_TASKS2060NCTSK20&FORECAST_EXTRA;">
-
- 25:ppn=20:tpp=2TOTAL_TASKS500NCTSK20&FORECAST_EXTRA;">
- 70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
- 73:ppn=20:tpp=2TOTAL_TASKS1460NCTSK20&FORECAST_EXTRA;">
- 73:ppn=20:tpp=2TOTAL_TASKS1460NCTSK20&FORECAST_EXTRA;">
- 82:ppn=20:tpp=2TOTAL_TASKS1640NCTSK20&FORECAST_EXTRA;">
- 106:ppn=20:tpp=2TOTAL_TASKS2120NCTSK20&FORECAST_EXTRA;">
-
-
- 52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
- 140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
- 148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
- 140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
- 148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
- 52:ppn=12:tpp=2TOTAL_TASKS624NCTSK12&FORECAST_EXTRA;">
- 140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
- 148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
- 140:ppn=12:tpp=2TOTAL_TASKS1680NCTSK12&FORECAST_EXTRA;">
- 148:ppn=12:tpp=2TOTAL_TASKS1776NCTSK12&FORECAST_EXTRA;">
- 53:ppn=12:tpp=2TOTAL_TASKS636NCTSK12&FORECAST_EXTRA;">
- 141:ppn=12:tpp=2TOTAL_TASKS1692NCTSK12&FORECAST_EXTRA;">
- 149:ppn=12:tpp=2TOTAL_TASKS1788NCTSK12&FORECAST_EXTRA;">
- 141:ppn=12:tpp=2TOTAL_TASKS1692NCTSK12&FORECAST_EXTRA;">
- 149:ppn=12:tpp=2TOTAL_TASKS1788NCTSK12&FORECAST_EXTRA;">
- 54:ppn=12:tpp=2TOTAL_TASKS648NCTSK12&FORECAST_EXTRA;">
- 142:ppn=12:tpp=2TOTAL_TASKS1704NCTSK12&FORECAST_EXTRA;">
- 150:ppn=12:tpp=2TOTAL_TASKS1800NCTSK12&FORECAST_EXTRA;">
- 142:ppn=12:tpp=2TOTAL_TASKS1704NCTSK12&FORECAST_EXTRA;">
- 150:ppn=12:tpp=2TOTAL_TASKS1800NCTSK12&FORECAST_EXTRA;">
- 88:ppn=20:tpp=2TOTAL_TASKS1760NCTSK20&FORECAST_EXTRA;">
- 88:ppn=20:tpp=2TOTAL_TASKS1760NCTSK20&FORECAST_EXTRA;">
- 91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
- 91:ppn=20:tpp=2TOTAL_TASKS1820NCTSK20&FORECAST_EXTRA;">
-
-
- 6:ppn=12:tpp=2TOTAL_TASKS72NCTSK12&FORECAST_EXTRA;">
- 11:ppn=12:tpp=2TOTAL_TASKS132NCTSK12&FORECAST_EXTRA;">
- 38:ppn=12:tpp=2TOTAL_TASKS456NCTSK12&FORECAST_EXTRA;">
- 43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
- 48:ppn=12:tpp=2TOTAL_TASKS576NCTSK12&FORECAST_EXTRA;">
- 53:ppn=12:tpp=2TOTAL_TASKS636NCTSK12&FORECAST_EXTRA;">
- 108:ppn=12:tpp=2TOTAL_TASKS1296NCTSK12&FORECAST_EXTRA;">
- 113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
-
- 34:ppn=12:tpp=2TOTAL_TASKS408NCTSK12&FORECAST_EXTRA;">
- 39:ppn=12:tpp=2TOTAL_TASKS468NCTSK12&FORECAST_EXTRA;">
- 44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
- 49:ppn=12:tpp=2TOTAL_TASKS588NCTSK12&FORECAST_EXTRA;">
- 104:ppn=12:tpp=2TOTAL_TASKS1248NCTSK12&FORECAST_EXTRA;">
- 109:ppn=12:tpp=2TOTAL_TASKS1308NCTSK12&FORECAST_EXTRA;">
-
- 28:ppn=12:tpp=2TOTAL_TASKS336NCTSK12&FORECAST_EXTRA;">
- 33:ppn=12:tpp=2TOTAL_TASKS396NCTSK12&FORECAST_EXTRA;">
- 38:ppn=12:tpp=2TOTAL_TASKS456NCTSK12&FORECAST_EXTRA;">
- 43:ppn=12:tpp=2TOTAL_TASKS516NCTSK12&FORECAST_EXTRA;">
- 48:ppn=12:tpp=2TOTAL_TASKS576NCTSK12&FORECAST_EXTRA;">
- 53:ppn=12:tpp=2TOTAL_TASKS636NCTSK12&FORECAST_EXTRA;">
- 108:ppn=12:tpp=2TOTAL_TASKS1296NCTSK12&FORECAST_EXTRA;">
- 113:ppn=12:tpp=2TOTAL_TASKS1356NCTSK12&FORECAST_EXTRA;">
-
- 29:ppn=12:tpp=2TOTAL_TASKS348NCTSK12&FORECAST_EXTRA;">
- 34:ppn=12:tpp=2TOTAL_TASKS408NCTSK12&FORECAST_EXTRA;">
- 39:ppn=12:tpp=2TOTAL_TASKS468NCTSK12&FORECAST_EXTRA;">
- 44:ppn=12:tpp=2TOTAL_TASKS528NCTSK12&FORECAST_EXTRA;">
- 49:ppn=12:tpp=2TOTAL_TASKS588NCTSK12&FORECAST_EXTRA;">
- 54:ppn=12:tpp=2TOTAL_TASKS648NCTSK12&FORECAST_EXTRA;">
- 109:ppn=12:tpp=2TOTAL_TASKS1308NCTSK12&FORECAST_EXTRA;">
- 114:ppn=12:tpp=2TOTAL_TASKS1368NCTSK12&FORECAST_EXTRA;">
-
- 30:ppn=12:tpp=2TOTAL_TASKS360NCTSK12&FORECAST_EXTRA;">
- 35:ppn=12:tpp=2TOTAL_TASKS420NCTSK12&FORECAST_EXTRA;">
- 40:ppn=12:tpp=2TOTAL_TASKS480NCTSK12&FORECAST_EXTRA;">
- 45:ppn=12:tpp=2TOTAL_TASKS540NCTSK12&FORECAST_EXTRA;">
- 50:ppn=12:tpp=2TOTAL_TASKS600NCTSK12&FORECAST_EXTRA;">
- 55:ppn=12:tpp=2TOTAL_TASKS660NCTSK12&FORECAST_EXTRA;">
- 110:ppn=12:tpp=2TOTAL_TASKS1320NCTSK12&FORECAST_EXTRA;">
- 115:ppn=12:tpp=2TOTAL_TASKS1380NCTSK12&FORECAST_EXTRA;">
-
- 4:ppn=20:tpp=2TOTAL_TASKS80NCTSK20&FORECAST_EXTRA;">
- 7:ppn=20:tpp=2TOTAL_TASKS140NCTSK20&FORECAST_EXTRA;">
-
- 16:ppn=20:tpp=2TOTAL_TASKS320NCTSK20&FORECAST_EXTRA;">
- 19:ppn=20:tpp=2TOTAL_TASKS380NCTSK20&FORECAST_EXTRA;">
- 19:ppn=20:tpp=2TOTAL_TASKS380NCTSK20&FORECAST_EXTRA;">
- 22:ppn=20:tpp=2TOTAL_TASKS440NCTSK20&FORECAST_EXTRA;">
- 28:ppn=20:tpp=2TOTAL_TASKS560NCTSK20&FORECAST_EXTRA;">
- 31:ppn=20:tpp=2TOTAL_TASKS620NCTSK20&FORECAST_EXTRA;">
- 64:ppn=20:tpp=2TOTAL_TASKS1280NCTSK20&FORECAST_EXTRA;">
- 67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
-
- 19:ppn=20:tpp=2TOTAL_TASKS380NCTSK20&FORECAST_EXTRA;">
- 22:ppn=20:tpp=2TOTAL_TASKS440NCTSK20&FORECAST_EXTRA;">
- 22:ppn=20:tpp=2TOTAL_TASKS440NCTSK20&FORECAST_EXTRA;">
- 25:ppn=20:tpp=2TOTAL_TASKS500NCTSK20&FORECAST_EXTRA;">
- 31:ppn=20:tpp=2TOTAL_TASKS620NCTSK20&FORECAST_EXTRA;">
- 34:ppn=20:tpp=2TOTAL_TASKS680NCTSK20&FORECAST_EXTRA;">
- 67:ppn=20:tpp=2TOTAL_TASKS1340NCTSK20&FORECAST_EXTRA;">
- 70:ppn=20:tpp=2TOTAL_TASKS1400NCTSK20&FORECAST_EXTRA;">
-
- 1:ppn=12:tpp=1TOTAL_TASKS12NCTSK12OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:00">
- 1:ppn=24:tpp=1TOTAL_TASKS24NCTSK24OMP_THREADS107:59:00">
- 1:ppn=1:tpp=1TOTAL_TASKS1NCTSK1OMP_THREADS107:59:0024G">
-
- 2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
- 2:ppn=12:tpp=1TOTAL_TASKS24NCTSK12OMP_THREADS107:59:00">
-
diff --git a/scripts/exhafs_analysis.sh b/scripts/exhafs_analysis.sh
index 50e8228ae..1449db657 100755
--- a/scripts/exhafs_analysis.sh
+++ b/scripts/exhafs_analysis.sh
@@ -26,6 +26,13 @@ export ENSDA=${ENSDA:-NO}
export GRID_RATIO_ENS=${GRID_RATIO_ENS:-1}
export online_satbias=${online_satbias:-no}
+export GSI_D01=${GSI_D01:-NO}
+export GSI_D02=${GSI_D02:-NO}
+
+export neststr=${neststr:-""} # ".nest02" for domain 02
+export tilestr=${tilestr:-".tile1"} # ".tile2" for domain 02
+export nesttilestr=${nesttilestr:-""} # ".nest02.tile2" for domain 02
+
TOTAL_TASKS=${TOTAL_TASKS:-2016}
NCTSK=${NCTSK:-12}
NCNODE=${NCNODE:-24}
@@ -38,6 +45,7 @@ export NCP=${NCP:-"/bin/cp"}
export NMV=${NMV:-"/bin/mv"}
export NLN=${NLN:-"/bin/ln -sf"}
export CHGRP_CMD=${CHGRP_CMD:-"chgrp ${group_name:-rstprod}"}
+export ANALYSISEXEC=${ANALYSISEXEC:-${EXEChafs}/hafs_gsi.x}
export CATEXEC=${CATEXEC:-${EXEChafs}/hafs_ncdiag_cat.x}
export MPISERIAL=${MPISERIAL:-${EXEChafs}/hafs_mpiserial.x}
export COMPRESS=${COMPRESS:-gzip}
@@ -76,26 +84,25 @@ hhprior=`echo ${CDATEprior} | cut -c9-10`
cycprior=`echo ${CDATEprior} | cut -c9-10`
PDYprior=`echo ${CDATEprior} | cut -c1-8`
-if [ ${RUN_FGAT} = YES ]; then
- CDATEtm03=`${NDATE} -3 $CDATE`
- PDYtm03=`echo ${CDATEtm03} | cut -c1-8`
- cyctm03=`echo ${CDATEtm03} | cut -c9-10`
- CDATEtm02=`${NDATE} -2 $CDATE`
- PDYtm02=`echo ${CDATEtm02} | cut -c1-8`
- cyctm02=`echo ${CDATEtm02} | cut -c9-10`
- CDATEtm01=`${NDATE} -1 $CDATE`
- PDYtm01=`echo ${CDATEtm01} | cut -c1-8`
- cyctm01=`echo ${CDATEtm01} | cut -c9-10`
- CDATEtp03=`${NDATE} +3 $CDATE`
- PDYtp03=`echo ${CDATEtp03} | cut -c1-8`
- cyctp03=`echo ${CDATEtp03} | cut -c9-10`
- CDATEtp02=`${NDATE} +2 $CDATE`
- PDYtp02=`echo ${CDATEtp02} | cut -c1-8`
- cyctp02=`echo ${CDATEtp02} | cut -c9-10`
- CDATEtp01=`${NDATE} +1 $CDATE`
- PDYtp01=`echo ${CDATEtp01} | cut -c1-8`
- cyctp01=`echo ${CDATEtp01} | cut -c9-10`
-fi
+CDATEtm03=`${NDATE} -3 $CDATE`
+PDYtm03=`echo ${CDATEtm03} | cut -c1-8`
+cyctm03=`echo ${CDATEtm03} | cut -c9-10`
+CDATEtm02=`${NDATE} -2 $CDATE`
+PDYtm02=`echo ${CDATEtm02} | cut -c1-8`
+cyctm02=`echo ${CDATEtm02} | cut -c9-10`
+CDATEtm01=`${NDATE} -1 $CDATE`
+PDYtm01=`echo ${CDATEtm01} | cut -c1-8`
+cyctm01=`echo ${CDATEtm01} | cut -c9-10`
+
+CDATEtp03=`${NDATE} +3 $CDATE`
+PDYtp03=`echo ${CDATEtp03} | cut -c1-8`
+cyctp03=`echo ${CDATEtp03} | cut -c9-10`
+CDATEtp02=`${NDATE} +2 $CDATE`
+PDYtp02=`echo ${CDATEtp02} | cut -c1-8`
+cyctp02=`echo ${CDATEtp02} | cut -c9-10`
+CDATEtp01=`${NDATE} +1 $CDATE`
+PDYtp01=`echo ${CDATEtp01} | cut -c1-8`
+cyctp01=`echo ${CDATEtp01} | cut -c9-10`
export COMhafsprior=${COMhafsprior:-${COMhafs}/../../${CDATEprior}/${STORMID}}
export WORKhafsprior=${WORKhafsprior:-${WORKhafs}/../../${CDATEprior}/${STORMID}}
@@ -106,44 +113,88 @@ if [ ! ${RUN_GSI} = "YES" ]; then
exit
fi
-if [ ! -s ${COMhafsprior}/storm1.holdvars.txt ] && [ ! -s ${COMhafsprior}/RESTART/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
- echo "Prior cycle does not exist. No need to run gsi for the first cycle."
- echo "Do nothing. Exiting"
- exit
-fi
-
-# Copy the first guess files
-if [ ${RUN_GSI_VR} = "YES" ]; then
- RESTARTinp=${COMhafs}/RESTART_analysis_vr
-else
- RESTARTinp=${COMhafsprior}/RESTART
-fi
-
-export RESTARTanl=${RESTARTanl:-${COMhafs}/RESTART_analysis}
+export RESTARTanl=${RESTARTanl:-${WORKhafs}/intercom/RESTART_analysis}
+export DIAGanl=${DIAGanl:-${COMhafs}/DIAG_analysis}
mkdir -p ${RESTARTanl}
+mkdir -p ${DIAGanl}
# We should already be in $DATA, but extra cd to be sure.
cd $DATA
-if [ ${RUN_FGAT} = "YES" ]; then
- if [ ${RUN_GSI_VR_FGAT} = "YES" ]; then
- RESTARTinp_fgat=${COMhafs}/RESTART_analysis_vr
+# Copy the first guess or fgat files
+if [ ${RUN_ATM_VI_FGAT} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_vi_fgat03
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_vi_fgat06
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_vi_fgat09
+elif [ ${RUN_GSI_VR_FGAT} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_analysis_vr_fgat03
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_analysis_vr_fgat06
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_analysis_vr_fgat09
+elif [ ${RUN_ATM_MERGE_FGAT} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_merge_fgat03
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_merge_fgat06
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_merge_fgat09
+elif [ ${RUN_ATM_INIT_FGAT} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_init_fgat03
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_init_fgat06
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_init_fgat09
+else
+ if [ ${RUN_ATM_VI} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_vi
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_vi
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_vi
+ elif [ ${RUN_GSI_VR} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_analysis_vr
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_analysis_vr
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_analysis_vr
+ elif [ ${RUN_ATM_MERGE} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_merge
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_merge
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_merge
+ elif [ ${RUN_ATM_INIT} = "YES" ]; then
+ RESTARTinp_fgat03=${WORKhafs}/intercom/RESTART_init
+ RESTARTinp_fgat06=${WORKhafs}/intercom/RESTART_init
+ RESTARTinp_fgat09=${WORKhafs}/intercom/RESTART_init
else
- RESTARTinp_fgat=${COMhafsprior}/RESTART
+ RESTARTinp_fgat03=${COMhafsprior}/RESTART
+ RESTARTinp_fgat06=${COMhafsprior}/RESTART
+ RESTARTinp_fgat09=${COMhafsprior}/RESTART
fi
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.coupler.res ./coupler.res_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.fv_core.res.nc ./fv3_akbk_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.sfc_data.nc ./fv3_sfcdata_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.fv_srf_wnd.res.tile1.nc ./fv3_srfwnd_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.fv_core.res.tile1.nc ./fv3_dynvars_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtm03}.${cyctm03}0000.fv_tracer.res.tile1.nc ./fv3_tracer_03
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.coupler.res ./coupler.res_09
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.fv_core.res.nc ./fv3_akbk_09
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.sfc_data.nc ./fv3_sfcdata_09
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.fv_srf_wnd.res.tile1.nc ./fv3_srfwnd_09
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.fv_core.res.tile1.nc ./fv3_dynvars_09
- ${NLN} ${RESTARTinp_fgat}/${PDYtp03}.${cyctp03}0000.fv_tracer.res.tile1.nc ./fv3_tracer_09
fi
+RESTARTinp=${RESTARTinp_fgat06}
+
+if [ ! -s ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res${neststr}${tilestr}.nc ]; then
+ echo "Warning: First guess for DA/Analysis missing"
+ echo "Warning: Do nothing, Exiting"
+ exit
+fi
+
+if [ ${RUN_FGAT} = "YES" ]; then
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.coupler.res ./coupler.res_03
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.fv_core.res${neststr}.nc ./fv3_akbk_03
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.sfc_data${nesttilestr}.nc ./fv3_sfcdata_03
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.fv_srf_wnd.res${neststr}${tilestr}.nc ./fv3_srfwnd_03
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.fv_core.res${neststr}${tilestr}.nc ./fv3_dynvars_03
+ ${NLN} ${RESTARTinp_fgat03}/${PDYtm03}.${cyctm03}0000.fv_tracer.res${neststr}${tilestr}.nc ./fv3_tracer_03
+
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.coupler.res ./coupler.res_09
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.fv_core.res${neststr}.nc ./fv3_akbk_09
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.sfc_data${nesttilestr}.nc ./fv3_sfcdata_09
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.fv_srf_wnd.res${neststr}${tilestr}.nc ./fv3_srfwnd_09
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.fv_core.res${neststr}${tilestr}.nc ./fv3_dynvars_09
+ ${NLN} ${RESTARTinp_fgat09}/${PDYtp03}.${cyctp03}0000.fv_tracer.res${neststr}${tilestr}.nc ./fv3_tracer_09
+fi
+
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.coupler.res ./coupler.res
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res${neststr}.nc ./fv3_akbk
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.sfc_data${nesttilestr}.nc ./fv3_sfcdata
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_srf_wnd.res${neststr}${tilestr}.nc ./fv3_srfwnd
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res${neststr}${tilestr}.nc ./fv3_dynvars
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res${neststr}${tilestr}.nc ./fv3_tracer
+
+${NCP} ${RESTARTinp}/oro_data${nesttilestr}.nc ./fv3_oro_data
+${NCP} ${RESTARTinp}/atmos_static${nesttilestr}.nc ./fv3_atmos_static
+${NCP} ${RESTARTinp}/grid_spec${nesttilestr}.nc ./fv3_grid_spec
if [ ${RUN_ENVAR} = "YES" ]; then
@@ -156,7 +207,6 @@ if [ ${RUN_ENSDA} = "YES" ]; then
for mem in $(seq -f '%03g' 1 ${N_ENS})
do
#if [ ${RUN_GSI_VR_ENS} = "YES" ]; then
- # RESTARTens=${COMhafs}/RESTART_analysis_vr_ens/mem${mem}
# RESTARTens=${WORKhafs}/intercom/RESTART_analysis_vr_ens/mem${mem}
#else
RESTARTens=${COMhafsprior}/RESTART_ens/mem${mem}
@@ -205,31 +255,19 @@ fi
fi # endif ${RUN_ENVAR}
-# Copy first guess files
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.coupler.res ./coupler.res
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.nc ./fv3_akbk
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.sfc_data.nc ./fv3_sfcdata
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_srf_wnd.res.tile1.nc ./fv3_srfwnd
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ./fv3_dynvars
-${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ./fv3_tracer
-
-${NCP} ${RESTARTinp}/oro_data.nc ./fv3_oro_data
-${NCP} ${RESTARTinp}/atmos_static.nc ./fv3_atmos_static
-${NCP} ${RESTARTinp}/grid_spec.nc ./fv3_grid_spec
-
# Stat files
-RADSTAT=${RADSTAT:-${RESTARTanl}/analysis.radstat}
-GSISTAT=${GSISTAT:-${RESTARTanl}/analysis.gsistat}
-PCPSTAT=${PCPSTAT:-${RESTARTanl}/analysis.pcpstat}
-CNVSTAT=${CNVSTAT:-${RESTARTanl}/analysis.cnvstat}
-OZNSTAT=${OZNSTAT:-${RESTARTanl}/analysis.oznstat}
-GSISOUT=${GSISOUT:-${RESTARTanl}/analysis.gsisout}
+RADSTAT=${RADSTAT:-${DIAGanl}/analysis${nesttilestr}.radstat}
+GSISTAT=${GSISTAT:-${DIAGanl}/analysis${nesttilestr}.gsistat}
+PCPSTAT=${PCPSTAT:-${DIAGanl}/analysis${nesttilestr}.pcpstat}
+CNVSTAT=${CNVSTAT:-${DIAGanl}/analysis${nesttilestr}.cnvstat}
+OZNSTAT=${OZNSTAT:-${DIAGanl}/analysis${nesttilestr}.oznstat}
+GSISOUT=${GSISOUT:-${DIAGanl}/analysis${nesttilestr}.gsisout}
# Obs diag
RUN_SELECT=${RUN_SELECT:-"NO"}
USE_SELECT=${USE_SELECT:-"NO"}
USE_RADSTAT=${USE_RADSTAT:-"NO"}
-SELECT_OBS=${SELECT_OBS:-${COMhafs}/obsinput.tar}
+SELECT_OBS=${SELECT_OBS:-${COMhafs}/obsinput${nesttilestr}.tar}
GENDIAG=${GENDIAG:-"YES"}
DIAG_SUFFIX=${DIAG_SUFFIX:-""}
if [ $netcdf_diag = ".true." ] ; then
@@ -237,8 +275,13 @@ if [ $netcdf_diag = ".true." ] ; then
fi
DIAG_COMPRESS=${DIAG_COMPRESS:-"YES"}
DIAG_TARBALL=${DIAG_TARBALL:-"YES"}
-USE_MPISERIAL=${USE_MPISERIAL:-"YES"}
-USE_CFP=${USE_CFP:-"NO"}
+if [ ${machine} = "wcoss_cray" ]; then
+ USE_MPISERIAL=${USE_MPISERIAL:-"NO"}
+ USE_CFP=${USE_CFP:-"YES"}
+else
+ USE_MPISERIAL=${USE_MPISERIAL:-"YES"}
+ USE_CFP=${USE_CFP:-"NO"}
+fi
CFP_MP=${CFP_MP:-"NO"}
nm=""
if [ $CFP_MP = "YES" ]; then
@@ -460,8 +503,8 @@ if [ -s ${WORKhafs}/intercom/obs_proc/hafs.prepbufr ]; then
${NCP} ${WORKhafs}/intercom/obs_proc/hafs.prepbufr prepbufr
fi
# cat tempdrop.prepbufr with drifting correction into prepbufr
-if [ -s ${WORKhafs}/intercom/obs_proc/tempdrop.prepbufr ]; then
- cat ${WORKhafs}/intercom/obs_proc/tempdrop.prepbufr >> prepbufr
+if [ -s ${WORKhafs}/intercom/obs_proc/hafs.tempdrop.prepbufr ]; then
+ cat ${WORKhafs}/intercom/obs_proc/hafs.tempdrop.prepbufr >> prepbufr
fi
COMINhafs_obs=${COMINhafs_obs:-${COMINhafs}/hafs.$PDY/$cyc/${atmos}}
${NLN} ${COMINhafs_obs}/hafs.t${cyc}z.hdob.tm00.bufr_d hdobbufr
@@ -474,13 +517,13 @@ fi #USE_SELECT
if [ ${online_satbias} = "yes" ]; then
PASSIVE_BC=.true.
UPD_PRED=1
- if [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
+ if [ ! -s ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias ] && [ ! -s ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias_pc ]; then
echo "Prior cycle satbias data does not exist. Grabbing satbias data from GDAS"
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias satbias_in
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias_pc satbias_pc
- elif [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_out satbias_in
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out satbias_pc
+ elif [ -s ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias ] && [ -s ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias_pc ]; then
+ ${NLN} ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias satbias_in
+ ${NLN} ${COMhafsprior}/DIAG_analysis/hafs${nesttilestr}.abias_pc satbias_pc
else
echo "ERROR: Either source satbias_in or source satbias_pc does not exist. Exiting script."
exit 2
@@ -553,8 +596,9 @@ sed -e "s/_MITER_/${MITER:-2}/g" \
ANALYSISEXEC=${ANALYSISEXEC:-${EXEChafs}/hafs_gsi.x}
${NCP} -p ${ANALYSISEXEC} ./hafs_gsi.x
-${APRUNC} ./hafs_gsi.x 1> stdout 2>&1
-cat stdout
+set -o pipefail
+${APRUNC} ./hafs_gsi.x 2>&1 | tee ./stdout
+set +o pipefail
${NCP} -p ./stdout ${GSISOUT}
@@ -572,16 +616,37 @@ fi
if [ ${HX_ONLY:-NO} != "YES" ]; then
-${NCP} ./fv3_oro_data ${RESTARTanl}/oro_data.nc
-${NCP} ./fv3_atmos_static ${RESTARTanl}/atmos_static.nc
-${NCP} ./fv3_grid_spec ${RESTARTanl}/grid_spec.nc
+${NCP} ./fv3_oro_data ${RESTARTanl}/oro_data${nesttilestr}.nc
+${NCP} ./fv3_atmos_static ${RESTARTanl}/atmos_static${nesttilestr}.nc
+${NCP} ./fv3_grid_spec ${RESTARTanl}/grid_spec${nesttilestr}.nc
${NCP} ./coupler.res ${RESTARTanl}/${PDY}.${cyc}0000.coupler.res
-${NCP} ./fv3_akbk ${RESTARTanl}/${PDY}.${cyc}0000.fv_core.res.nc
-${NCP} ./fv3_sfcdata ${RESTARTanl}/${PDY}.${cyc}0000.sfc_data.nc
-${NCP} ./fv3_srfwnd ${RESTARTanl}/${PDY}.${cyc}0000.fv_srf_wnd.res.tile1.nc
-${NCP} ./fv3_dynvars ${RESTARTanl}/${PDY}.${cyc}0000.fv_core.res.tile1.nc
-${NCP} ./fv3_tracer ${RESTARTanl}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc
+${NCP} ./fv3_akbk ${RESTARTanl}/${PDY}.${cyc}0000.fv_core.res${neststr}.nc
+${NCP} ./fv3_sfcdata ${RESTARTanl}/${PDY}.${cyc}0000.sfc_data${nesttilestr}.nc
+${NCP} ./fv3_srfwnd ${RESTARTanl}/${PDY}.${cyc}0000.fv_srf_wnd.res${neststr}${tilestr}.nc
+${NCP} ./fv3_dynvars ${RESTARTanl}/${PDY}.${cyc}0000.fv_core.res${neststr}${tilestr}.nc
+${NCP} ./fv3_tracer ${RESTARTanl}/${PDY}.${cyc}0000.fv_tracer.res${neststr}${tilestr}.nc
+
+# pass over phy_data as well
+${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.phy_data${nesttilestr}.nc ${RESTARTanl}/${PDY}.${cyc}0000.phy_data${nesttilestr}.nc
+
+if [[ ! -z "$neststr" ]] ; then
+ if [ -e ${RESTARTinp}/${PDY}.${cyc}0000.fv_BC_ne.res${neststr}.nc ]; then
+ ${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_BC_ne.res${neststr}.nc ${RESTARTanl}/${PDY}.${cyc}0000.fv_BC_ne.res${neststr}.nc
+ ${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_BC_sw.res${neststr}.nc ${RESTARTanl}/${PDY}.${cyc}0000.fv_BC_sw.res${neststr}.nc
+ fi
+fi
+
+# Pass over the grid_mspec files for moving nest
+if [[ "${is_moving_nest:-".false."}" = *".true."* ]] || [[ "${is_moving_nest:-".false."}" = *".T."* ]] ; then
+ if [[ -z "$neststr" ]] && [[ $tilestr = ".tile1" ]]; then
+ # "grid_mspec_${yr}_${mn}_${dy}_${cyc}.nc" for domain 02
+ ${NCP} -p ${RESTARTinp}/grid_mspec_${yr}_${mn}_${dy}_${cyc}.nc ${RESTARTanl}/
+ else
+ # "grid_mspec.nest02_${yr}_${mn}_${dy}_${cyc}.tile2.nc" for domain 02
+ ${NCP} -p ${RESTARTinp}/grid_mspec${neststr}_${yr}_${mn}_${dy}_${cyc}${tilestr}.nc ${RESTARTanl}/
+ fi
+fi
fi
@@ -763,8 +828,8 @@ fi # End diagnostic file generation block - if [ $GENDIAG = "YES" ]
# Save satbias data for next cycle
if [ ${online_satbias} = "yes" ]; then
- ${NCP} satbias_out $RESTARTanl/satbias_hafs_out
- ${NCP} satbias_pc.out $RESTARTanl/satbias_hafs_pc.out
+ ${NCP} satbias_out $DIAGanl/hafs${nesttilestr}.abias
+ ${NCP} satbias_pc.out $DIAGanl/hafs${nesttilestr}.abias_pc
fi
# If no processing error, remove $DIAG_DIR
diff --git a/scripts/exhafs_analysis_vr.sh b/scripts/exhafs_analysis_vr.sh
index 56ec3755a..a0d546d57 100755
--- a/scripts/exhafs_analysis_vr.sh
+++ b/scripts/exhafs_analysis_vr.sh
@@ -155,9 +155,10 @@ if [ "${ENSDA}" = "YES" ]; then
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_srf_wnd.res.tile1.nc ./fv3_srfwnd
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ./fv3_dynvars
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ./fv3_tracer
- ${NLN} ${COMhafsprior}/product_ens/mem${ENSID}/${STORM,,}${STORMID,,}.${CDATEprior}.trak.hafs.atcfunix.all ./hafs.atcfunix_prior
+ ${NLN} ${COMhafsprior}/product_ens/mem${ENSID}/${STORMID,,}.${CDATEprior}.hafs.trak.atcfunix.all ./hafs.atcfunix_prior
grep ", HAFS, 006," ./hafs.atcfunix_prior | grep ", 34, NEQ," > ./hafs.atcfunix
- export RESTARTanl=${RESTARTanl:-${COMhafs}/RESTART_analysis_vr_ens/mem${ENSID}}
+ export RESTARTanl=${RESTARTanl:-${WORKhafs}/intercom/RESTART_analysis_vr_ens/mem${ENSID}}
+ export DIAGanl=${DIAGanl:-${COMhafs}/DIAG_analysis_vr_ens/mem${ENSID}}
else
export RESTARTinp=${RESTARTinp:-${COMhafsprior}/RESTART}
${NCP} ${RESTARTinp}/oro_data.nc ./fv3_oro_data
@@ -170,7 +171,7 @@ else
${NCP} ${RESTARTinp}/${PDYfgat}.${cycfgat}0000.fv_srf_wnd.res.tile1.nc ./fv3_srfwnd
${NCP} ${RESTARTinp}/${PDYfgat}.${cycfgat}0000.fv_core.res.tile1.nc ./fv3_dynvars
${NCP} ${RESTARTinp}/${PDYfgat}.${cycfgat}0000.fv_tracer.res.tile1.nc ./fv3_tracer
- ${NLN} ${COMhafsprior}/${STORM,,}${STORMID,,}.${CDATEprior}.trak.hafs.atcfunix.all ./hafs.atcfunix_prior
+ ${NLN} ${COMhafsprior}/${STORMID,,}.${CDATEprior}.hafs.trak.atcfunix.all ./hafs.atcfunix_prior
grep ", HAFS, 0${FGAT_HR}," ./hafs.atcfunix_prior | grep ", 34, NEQ," > ./hafs.atcfunix
else
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.coupler.res ./coupler.res
@@ -180,10 +181,11 @@ else
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ./fv3_dynvars
${NCP} ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ./fv3_tracer
# Extract the 6-hr forecast atcf records from the prior cycle
- ${NLN} ${COMhafsprior}/${STORM,,}${STORMID,,}.${CDATEprior}.trak.hafs.atcfunix.all ./hafs.atcfunix_prior
+ ${NLN} ${COMhafsprior}/${STORMID,,}.${CDATEprior}.hafs.trak.atcfunix.all ./hafs.atcfunix_prior
grep ", HAFS, 006," ./hafs.atcfunix_prior | grep ", 34, NEQ," > ./hafs.atcfunix
fi
- export RESTARTanl=${RESTARTanl:-${COMhafs}/RESTART_analysis_vr}
+ export RESTARTanl=${RESTARTanl:-${WORKhafs}/intercom/RESTART_analysis_vr}
+ export DIAGanl=${DIAGanl:-${COMhafs}/DIAG_analysis_vr}
fi
cat ./hafs.atcfunix
@@ -236,22 +238,23 @@ ${APRUNS} ./hafs_obs_preproc.x 1> ./hafs_obs_preproc.out 2>&1
#----------------------------------------------
mkdir -p ${RESTARTanl}
+mkdir -p ${DIAGanl}
# Stat files
if [ ${FGAT} = "YES" ]; then
- RADSTAT=${RADSTAT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.radstat}
- GSISTAT=${GSISTAT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.gsistat}
- PCPSTAT=${PCPSTAT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.pcpstat}
- CNVSTAT=${CNVSTAT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.cnvstat}
- OZNSTAT=${OZNSTAT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.oznstat}
- GSISOUT=${GSISOUT:-${RESTARTanl}/${PDYfgat}.${cycfgat}0000.analysis.gsisout}
+ RADSTAT=${RADSTAT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.radstat}
+ GSISTAT=${GSISTAT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.gsistat}
+ PCPSTAT=${PCPSTAT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.pcpstat}
+ CNVSTAT=${CNVSTAT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.cnvstat}
+ OZNSTAT=${OZNSTAT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.oznstat}
+ GSISOUT=${GSISOUT:-${DIAGanl}/${PDYfgat}.${cycfgat}0000.analysis.gsisout}
else
- RADSTAT=${RADSTAT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.radstat}
- GSISTAT=${GSISTAT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.gsistat}
- PCPSTAT=${PCPSTAT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.pcpstat}
- CNVSTAT=${CNVSTAT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.cnvstat}
- OZNSTAT=${OZNSTAT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.oznstat}
- GSISOUT=${GSISOUT:-${RESTARTanl}/${PDY}.${cyc}0000.analysis.gsisout}
+ RADSTAT=${RADSTAT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.radstat}
+ GSISTAT=${GSISTAT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.gsistat}
+ PCPSTAT=${PCPSTAT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.pcpstat}
+ CNVSTAT=${CNVSTAT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.cnvstat}
+ OZNSTAT=${OZNSTAT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.oznstat}
+ GSISOUT=${GSISOUT:-${DIAGanl}/${PDY}.${cyc}0000.analysis.gsisout}
fi
# Obs diag
@@ -349,8 +352,9 @@ sed -e "s/_MITER_/${MITER:-2}/g" \
ANALYSISEXEC=${ANALYSISEXEC:-${EXEChafs}/hafs_gsi.x}
${NCP} -p ${ANALYSISEXEC} ./hafs_gsi.x
-${APRUNC} ./hafs_gsi.x 1> stdout 2>&1
-cat stdout
+set -o pipefail
+${APRUNC} ./hafs_gsi.x 2>&1 | tee ./stdout
+set +o pipefail
${NCP} -p ./stdout ${GSISOUT}
@@ -372,7 +376,7 @@ if [ $GENDIAG = "YES" ] ; then
# Set up lists and variables for various types of diagnostic files.
ntype=3
- diagtype[0]="conv conv_gps conv_ps conv_pw conv_q conv_sst conv_t conv_tcp conv_uv conv_spd"
+ diagtype[0]="conv conv_gps conv_ps conv_pw conv_q conv_sst conv_t conv_tcp conv_uv conv_spd conv_rw"
diagtype[1]="pcp_ssmi_dmsp pcp_tmi_trmm"
diagtype[2]="sbuv2_n16 sbuv2_n17 sbuv2_n18 sbuv2_n19 gome_metop-a gome_metop-b omi_aura mls30_aura ompsnp_npp ompstc8_npp gome_metop-c"
diagtype[3]="hirs2_n14 msu_n14 sndr_g08 sndr_g11 sndr_g12 sndr_g13 sndr_g08_prep sndr_g11_prep sndr_g12_prep sndr_g13_prep sndrd1_g11 sndrd2_g11 sndrd3_g11 sndrd4_g11 sndrd1_g12 sndrd2_g12 sndrd3_g12 sndrd4_g12 sndrd1_g13 sndrd2_g13 sndrd3_g13 sndrd4_g13 sndrd1_g14 sndrd2_g14 sndrd3_g14 sndrd4_g14 sndrd1_g15 sndrd2_g15 sndrd3_g15 sndrd4_g15 hirs3_n15 hirs3_n16 hirs3_n17 amsua_n15 amsua_n16 amsua_n17 amsub_n15 amsub_n16 amsub_n17 hsb_aqua airs_aqua amsua_aqua imgr_g08 imgr_g11 imgr_g12 imgr_g14 imgr_g15 ssmi_f13 ssmi_f15 hirs4_n18 hirs4_metop-a amsua_n18 amsua_metop-a mhs_n18 mhs_metop-a amsre_low_aqua amsre_mid_aqua amsre_hig_aqua ssmis_f16 ssmis_f17 ssmis_f18 ssmis_f19 ssmis_f20 iasi_metop-a hirs4_n19 amsua_n19 mhs_n19 seviri_m08 seviri_m09 seviri_m10 seviri_m11 cris_npp cris-fsr_npp cris-fsr_n20 atms_npp atms_n20 hirs4_metop-b amsua_metop-b mhs_metop-b iasi_metop-b avhrr_metop-b avhrr_n18 avhrr_n19 avhrr_metop-a amsr2_gcom-w1 gmi_gpm saphir_meghat ahi_himawari8 abi_g16 abi_g17 amsua_metop-c mhs_metop-c iasi_metop-c avhrr_metop-c"
diff --git a/scripts/exhafs_atm_ic.sh b/scripts/exhafs_atm_ic.sh
index 21e5544f9..a5d7fb5b7 100755
--- a/scripts/exhafs_atm_ic.sh
+++ b/scripts/exhafs_atm_ic.sh
@@ -12,6 +12,8 @@ NCNODE=${NCNODE:-24}
OMP_NUM_THREADS=${OMP_NUM_THREADS:-2}
APRUNC=${APRUNC:-"aprun -b -j1 -n${TOTAL_TASKS} -N${NCTSK} -d${OMP_NUM_THREADS} -cc depth"}
+nest_grids=${nest_grids:-1}
+
CDATE=${CDATE:-${YMDH}}
cyc=${cyc:-00}
STORM=${STORM:-FAKE}
@@ -29,6 +31,8 @@ WGRIB2=${WGRIB2:-wgrib2}
CHGRESCUBEEXEC=${CHGRESCUBEEXEC:-${EXEChafs}/hafs_chgres_cube.x}
ENSDA=${ENSDA:-NO}
+FGAT_MODEL=${FGAT_MODEL:-gfs}
+FGAT_HR=${FGAT_HR:-00}
# Set options specific to the deterministic/ensemble forecast
if [ ${ENSDA} != YES ]; then
@@ -67,12 +71,16 @@ vcoord_file_target_grid=${vcoord_file_target_grid:-${FIXhafs}/fix_am/global_hybl
if [ $GFSVER = "PROD2021" ]; then
if [ ${ENSDA} = YES ]; then
export INIDIR=${COMgfs}/enkfgdas.${PDY_prior}/${cyc_prior}/atmos/mem${ENSID}
+ elif [ ${FGAT_MODEL} = gdas ]; then
+ export INIDIR=${COMgfs}/gdas.${PDY_prior}/${cyc_prior}/atmos
else
export INIDIR=${COMgfs}/gfs.$PDY/$cyc/atmos
fi
elif [ $GFSVER = "PROD2019" ]; then
if [ ${ENSDA} = YES ]; then
export INIDIR=${COMgfs}/enkfgdas.${PDY_prior}/${cyc_prior}/mem${ENSID}
+ elif [ ${FGAT_MODEL} = gdas ]; then
+ export INIDIR=${COMgfs}/gdas.${PDY_prior}/${cyc_prior}
else
export INIDIR=${COMgfs}/gfs.$PDY/$cyc
fi
@@ -101,6 +109,9 @@ if [ $ictype = "gfsnetcdf" ]; then
if [ ${ENSDA} = YES ]; then
atm_files_input_grid=gdas.t${cyc_prior}z.atmf006.nc
sfc_files_input_grid=gdas.t${cyc_prior}z.sfcf006.nc
+ elif [ ${FGAT_MODEL} = gdas ]; then
+ atm_files_input_grid=gdas.t${cyc_prior}z.atmf0${FGAT_HR}.nc
+ sfc_files_input_grid=gdas.t${cyc_prior}z.sfcf0${FGAT_HR}.nc
else
atm_files_input_grid=${CDUMP}.t${cyc}z.atmanl.nc
sfc_files_input_grid=${CDUMP}.t${cyc}z.sfcanl.nc
@@ -116,6 +127,9 @@ elif [ $ictype = "gfsnemsio" ]; then
if [ ${ENSDA} = YES ]; then
atm_files_input_grid=gdas.t${cyc_prior}z.atmf006.nemsio
sfc_files_input_grid=gdas.t${cyc_prior}z.sfcf006.nemsio
+ elif [ ${FGAT_MODEL} = gdas ]; then
+ atm_files_input_grid=gdas.t${cyc_prior}z.atmf0${FGAT_HR}.nemsio
+ sfc_files_input_grid=gdas.t${cyc_prior}z.sfcf0${FGAT_HR}.nemsio
else
atm_files_input_grid=${CDUMP}.t${cyc}z.atmanl.nemsio
sfc_files_input_grid=${CDUMP}.t${cyc}z.sfcanl.nemsio
@@ -197,6 +211,10 @@ else
ln -sf ${INIDIR}/${atm_files_input_grid} ./
ln -sf ${INIDIR}/${sfc_files_input_grid} ./
INPDIR="./"
+ elif [ ${FGAT_MODEL} = gdas ]; then
+ ln -sf ${INIDIR}/${atm_files_input_grid} ./
+ ln -sf ${INIDIR}/${sfc_files_input_grid} ./
+ INPDIR="./"
else
INPDIR=${INIDIR}
fi
@@ -236,6 +254,9 @@ elif [ $gtype = regional ]; then
ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}.snowfree_albedo.tile7.halo4.nc $FIXDIR/$CASE/${CASE}.snowfree_albedo.tile7.nc
ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}.vegetation_type.tile7.halo4.nc $FIXDIR/$CASE/${CASE}.vegetation_type.tile7.nc
+ if [ $nest_grids -gt 1 ]; then
+ ln -sf $FIXDIR/$CASE/${CASE}_coarse_mosaic.nc $FIXDIR/$CASE/${CASE}_mosaic.nc
+ fi
mosaic_file_target_grid="$FIXDIR/$CASE/${CASE}_mosaic.nc"
orog_files_target_grid='"'${CASE}'_oro_data.tile7.halo4.nc"'
convert_atm=.true.
@@ -336,16 +357,28 @@ else
exit 9
fi
-# For the global-nesting configuration, run for the 7th tile
-if [ $gtype = nest ]; then
+# For the global-nesting or regional-nesting configurations, run for the nested tile(s)
+if [ $gtype = nest -o $nest_grids -gt 1 ]; then
- ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}*.nc $FIXDIR/$CASE/.
+ntiles=$(( ${nest_grids} + 6 ))
- ln -sf $FIXDIR/$CASE/${CASE}_nested_mosaic.nc $FIXDIR/$CASE/${CASE}_mosaic.nc
+if [ $gtype = regional ]; then
+ stile=8
+else
+ stile=7
+fi
+
+for itile in $(seq $stile $ntiles)
+do
+
+ inest=$(($itile + 2 - $stile))
+
+ ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}*.nc $FIXDIR/$CASE/.
+ ln -sf $FIXDIR/$CASE/${CASE}_nested0${inest}_mosaic.nc $FIXDIR/$CASE/${CASE}_mosaic.nc
export GRIDTYPE=nest
- HALO=${HALO:-0}
+ HALO=0
mosaic_file_target_grid="$FIXDIR/$CASE/${CASE}_mosaic.nc"
- orog_files_target_grid='"'${CASE}'_oro_data.tile7.nc"'
+ orog_files_target_grid='"'${CASE}'_oro_data.tile'${itile}'.nc"'
convert_atm=.true.
convert_sfc=.true.
if [ $input_type = "grib2" ]; then
@@ -395,8 +428,10 @@ EOF
${APRUNC} ./hafs_chgres_cube.x
#${APRUNC} ${CHGRESCUBEEXEC}
-mv out.atm.tile1.nc ${OUTDIR}/gfs_data.tile7.nc
-mv out.sfc.tile1.nc ${OUTDIR}/sfc_data.tile7.nc
+mv out.atm.tile1.nc ${OUTDIR}/gfs_data.tile${itile}.nc
+mv out.sfc.tile1.nc ${OUTDIR}/sfc_data.tile${itile}.nc
+
+done
fi
diff --git a/scripts/exhafs_atm_lbc.sh b/scripts/exhafs_atm_lbc.sh
index 0b194ddf1..41c122332 100755
--- a/scripts/exhafs_atm_lbc.sh
+++ b/scripts/exhafs_atm_lbc.sh
@@ -255,6 +255,9 @@ if [ $gtype = regional ]; then
ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}.snowfree_albedo.tile7.halo4.nc $FIXDIR/$CASE/${CASE}.snowfree_albedo.tile7.nc
ln -sf $FIXDIR/$CASE/fix_sfc/${CASE}.vegetation_type.tile7.halo4.nc $FIXDIR/$CASE/${CASE}.vegetation_type.tile7.nc
+ if [ $nest_grids -gt 1 ]; then
+ ln -sf $FIXDIR/$CASE/${CASE}_coarse_mosaic.nc $FIXDIR/$CASE/${CASE}_mosaic.nc
+ fi
mosaic_file_target_grid="$FIXDIR/$CASE/${CASE}_mosaic.nc"
orog_files_target_grid='"'${CASE}'_oro_data.tile7.halo4.nc"'
convert_atm=.true.
diff --git a/scripts/exhafs_atm_post.sh b/scripts/exhafs_atm_post.sh
index 9bb3f900b..b46bca0ce 100755
--- a/scripts/exhafs_atm_post.sh
+++ b/scripts/exhafs_atm_post.sh
@@ -14,8 +14,9 @@ if [ ${ENSDA} = YES ]; then
export CRES=`echo $CASE | cut -c 2-`
export gtype=${gtype_ens:-regional}
export LEVS=${LEVS_ENS:-65}
- export synop_gridspecs=${synop_gridspecs_ens:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
- export trker_gridspecs=${trker_gridspecs_ens:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
+ export post_gridspecs=${post_gridspecs_ens:-""}
+ export trak_gridspecs=${trak_gridspecs_ens:-""}
+ export satpost=${satpost_ens:-".false."}
else
export NHRS=${NHRS:-126}
export NBDYHRS=${NBDYHRS:-3}
@@ -24,8 +25,9 @@ else
export CRES=`echo $CASE | cut -c 2-`
export gtype=${gtype:-regional}
export LEVS=${LEVS:-65}
- export synop_gridspecs=${synop_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
- export trker_gridspecs=${trker_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
+ export post_gridspecs=${post_gridspecs:-""}
+ export trak_gridspecs=${trak_gridspecs:-""}
+ export satpost=${satpost:-".false."}
fi
TOTAL_TASKS=${TOTAL_TASKS:-144}
@@ -44,6 +46,7 @@ NOUTHRS=${NOUTHRS:-3}
POSTEXEC=${POSTEXEC:-${EXEChafs}/hafs_post.x}
MPISERIAL=${MPISERIAL:-${EXEChafs}/hafs_mpiserial.x}
+MPPNCCOMBINE=${MPPNCCOMBINE:-${EXEChafs}/hafs_mppnccombine.x}
WGRIB2=${WGRIB2:-wgrib2}
GRB2INDEX=${GRB2INDEX:-grb2index}
@@ -55,11 +58,13 @@ SENDCOM=${SENDCOM:-YES}
COMOUTpost=${COMOUTpost:-${COMhafs}}
-satpost=${satpost:-.false.}
+out_prefix=${out_prefix:-$(echo "${STORMID,,}.${CDATE}" | tr '[A-Z]' '[a-z]')}
+
output_grid=${output_grid:-rotated_latlon}
-synop_gridspecs=${synop_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
-trker_gridspecs=${trker_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
-out_prefix=${out_prefix:-$(echo "${STORM}${STORMID}.${YMDH}" | tr '[A-Z]' '[a-z]')}
+#post_gridspecs=${post_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
+#trak_gridspecs=${trak_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
+post_gridspecs=${post_gridspecs:-""}
+trak_gridspecs=${trak_gridspecs:-""}
DATA=${DATA:-${WORKhafs}/atm_post}
@@ -80,29 +85,55 @@ MM=`echo $NEWDATE | cut -c5-6`
DD=`echo $NEWDATE | cut -c7-8`
HH=`echo $NEWDATE | cut -c9-10`
-FMIN=$(( ${FHR}*60 ))
-minstr=$( printf "%5.5d" "$FMIN" )
-
-synop_grb2post=hafsprs.${CDATE}.f${FHR3}.grb2
-synop_grb2file=${out_prefix}.hafsprs.synoptic.0p03.f${FHR3}.grb2
-synop_grb2indx=${out_prefix}.hafsprs.synoptic.0p03.f${FHR3}.grb2.idx
-synop_sat_grb2post=hafssat.${CDATE}.f${FHR3}.grb2
-synop_sat_grb2file=${out_prefix}.hafssat.synoptic.0p03.f${FHR3}.grb2
-synop_sat_grb2indx=${out_prefix}.hafssat.synoptic.0p03.f${FHR3}.grb2.idx
-gmodname=hafs
-rundescr=trak
-atcfdescr=storm
-hafstrk_grb2file=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}
-hafstrk_grb2indx=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}.ix
+if [ ${gtype} = nest ]; then
+ ngrids=$((${nest_grids} + 1))
+else
+ ngrids=${nest_grids}
+fi
+
+# Loop for grids/domains
+for ng in $(seq 1 ${ngrids});
+do
-# Check if post has processed this forecast hour previously
-if [ -s ${INPdir}/postf${FHR3} ] && \
- [ -s ${COMOUTpost}/${synop_grb2file} ] && \
- [ -s ${COMOUTpost}/${synop_grb2indx} ] ; then
+if [[ $ng -eq 1 ]]; then
+ neststr=""
+ tilestr=".tile1"
+ nesttilestr=""
+ nestdotstr=""
+else
+ neststr=".nest$(printf '%02d' ${ng})"
+ tilestr=".tile$(printf '%d' ${ng})"
+ nesttilestr=".nest$(printf '%02d' ${ng}).tile$(printf '%d' ${ng})"
+ nestdotstr=".nest$(printf '%02d' ${ng})."
+fi
+
+gridstr=".grid$(printf '%02d' ${ng})"
+
+outputgrid=$(echo ${output_grid} | cut -d, -f ${ng})
+postgridspecs=$(echo ${post_gridspecs} | cut -d, -f ${ng})
+trakgridspecs=$(echo ${trak_gridspecs} | cut -d, -f ${ng})
+
+grb2post=${out_prefix}.hafs${gridstr}.f${FHR3}.postgrb2
+grb2file=${out_prefix}.hafs${gridstr}.f${FHR3}.grb2
+grb2indx=${out_prefix}.hafs${gridstr}.f${FHR3}.grb2.idx
+sat_grb2post=${out_prefix}.hafs${gridstr}.sat.f${FHR3}.postgrb2
+sat_grb2file=${out_prefix}.hafs${gridstr}.sat.f${FHR3}.grb2
+sat_grb2indx=${out_prefix}.hafs${gridstr}.sat.f${FHR3}.grb2.idx
+trk_grb2file=${out_prefix}.hafs${gridstr}.trk.f${FHR3}.grb2
+trk_grb2indx=${out_prefix}.hafs${gridstr}.trk.f${FHR3}.grb2.ix
+
+fort_patcf="fort.6$(printf '%02d' ${ng})"
+trk_patcf=${out_prefix}.hafs.trak.patcf
-echo "post message ${INPdir}/postf${FHR3} exist"
-echo "product ${COMOUTpost}/${synop_grb2file} exist"
-echo "product ${COMOUTpost}/${synop_grb2indx} exist"
+# Check if post has processed this forecast hour previously
+if [ -s ${INPdir}/post${nestdotstr}f${FHR3} ] && \
+ [ ${INPdir}/post${nestdotstr}f${FHR3} -nt ${INPdir}/logf${FHR3} ] && \
+ [ -s ${COMOUTpost}/${grb2file} ] && \
+ [ -s ${COMOUTpost}/${grb2indx} ] ; then
+
+echo "post done file ${INPdir}/post${nestdotstr}f${FHR3} exist and newer than ${INPdir}/logf${FHR3}"
+echo "product ${COMOUTpost}/${grb2file} exist"
+echo "product ${COMOUTpost}/${grb2indx} exist"
echo "skip post for forecast hour ${FHR3} valid at ${NEWDATE}"
# Otherwise run post for this forecast hour
@@ -114,11 +145,11 @@ if [ ${write_dopost:-.false.} = .true. ]; then
n=1
while [ $n -le 600 ]
do
- if [ ! -s ${INPdir}/logf${FHR3} ] || [ ! -s ${INPdir}/HURPRS.GrbF${FHR2} ]; then
+ if [ ! -s ${INPdir}/logf${FHR3} ] || [ ! -s ${INPdir}/HURPRS${neststr}.GrbF${FHR2} ]; then
echo "${INPdir}/logf${FHR3} not ready, sleep 60"
sleep 60s
else
- echo "${INPdir}/logf${FHR3}, ${INPdir}/HURPRS.GrbF${FHR2} ready, continue"
+ echo "${INPdir}/logf${FHR3}, ${INPdir}/HURPRS${neststr}.GrbF${FHR2} ready, continue"
sleep 3s
break
fi
@@ -135,11 +166,13 @@ else
n=1
while [ $n -le 600 ]
do
- if [ ! -s ${INPdir}/logf${FHR3} ] || [ ! -s ${INPdir}/atmf${FHR3}.nc ] || [ ! -s ${INPdir}/sfcf${FHR3}.nc ]; then
+ if [ ! -s ${INPdir}/logf${FHR3} ] || \
+ [ ! -s ${INPdir}/atm${nestdotstr}f${FHR3}.nc ] || \
+ [ ! -s ${INPdir}/sfc${nestdotstr}f${FHR3}.nc ]; then
echo "${INPdir}/logf${FHR3} not ready, sleep 60"
sleep 60s
else
- echo "${INPdir}/logf${FHR3}, ${INPdir}/atmf${FHR3}.nc ${INPdir}/sfcf${FHR3}.nc ready, do post"
+ echo "${INPdir}/logf${FHR3}, ${INPdir}/atm${nestdotstr}f${FHR3}.nc ${INPdir}/sfc${nestdotstr}f${FHR3}.nc ready, do post"
sleep 3s
break
fi
@@ -153,16 +186,17 @@ done
fi #if [ ${write_dopost:-.false.} = .true. ]
# Create the post working dir for the time level
-DATA_POST=${DATA}/post_${NEWDATE}
+DATA_POST=${DATA}/post${neststr}_${NEWDATE}
rm -rf ${DATA_POST}
mkdir -p ${DATA_POST}
cd ${DATA_POST}
+# Note: Currently the inline post (write_dopost) does not support nesting configurations yet.
if [ ${write_dopost:-.false.} = .true. ]; then
-cp -p ${INPdir}/HURPRS.GrbF${FHR2} ${synop_grb2post}
+${NCP} -p ${INPdir}/HURPRS${neststr}.GrbF${FHR2} ${grb2post}
if [ ${satpost} = .true. ]; then
-cp -p ${INPdir}/HURSAT.GrbF${FHR2} ${synop_sat_grb2post}
+ ${NCP} -p ${INPdir}/HURSAT${neststr}.GrbF${FHR2} ${sat_grb2post}
fi
else
@@ -170,12 +204,12 @@ else
# Preparte itag namelist input file
cat>itag< outpost_${NEWDATE}
+set -o pipefail
+${APRUNC} ./hafs_post.x < itag 2>&1 | tee ./outpost_${NEWDATE}
+set +o pipefail
-mv HURPRS.GrbF${FHR2} ${synop_grb2post}
+mv HURPRS.GrbF${FHR2} ${grb2post}
if [ ${satpost} = .true. ]; then
- mv HURSAT.GrbF${FHR2} ${synop_sat_grb2post}
+ mv HURSAT.GrbF${FHR2} ${sat_grb2post}
fi
fi #if [ ${write_dopost:-.false.} = .true. ]
-if [ "$output_grid" = rotated_latlon ]; then
+if [ ${postgridspecs} = auto ]; then
+ clon=$(echo ${output_grid_cen_lon} | cut -d , -f 1)
+ clat=$(echo ${output_grid_cen_lat} | cut -d , -f 1)
+ lon_span=$(echo ${output_grid_lon_span} | cut -d , -f 1)
+ lat_span=$(echo ${output_grid_lat_span} | cut -d , -f 1)
+ latlon_dlon=$( printf "%.6f" $(echo ${output_grid_dlon} | cut -d , -f ${ng}))
+ latlon_dlat=$( printf "%.6f" $(echo ${output_grid_dlat} | cut -d , -f ${ng}))
+if [[ "$outputgrid" = "rotated_latlon"* ]]; then
+ latlon_lon0=$( printf "%.6f" $(bc <<< "scale=6; ${clon}-${lon_span}/2.0-9.0") )
+ latlon_nlon=$( printf "%.0f" $(bc <<< "scale=6; (${lon_span}+18.0)/${latlon_dlon}") )
+else
+ latlon_lon0=$( printf "%.6f" $(bc <<< "scale=6; ${clon}-${lon_span}/2.0") )
+ latlon_nlon=$( printf "%.0f" $(bc <<< "scale=6; ${lon_span}/${latlon_dlon}") )
+fi
+ latlon_lat0=$( printf "%.6f" $(bc <<< "scale=6; ${clat}-${lat_span}/2.0") )
+ latlon_nlat=$( printf "%.0f" $(bc <<< "scale=6; ${lat_span}/${latlon_dlat}") )
+ postgridspecs="latlon ${latlon_lon0}:${latlon_nlon}:${latlon_dlon} ${latlon_lat0}:${latlon_nlat}:${latlon_dlat}"
+fi
+
+if [ ${trakgridspecs} = auto ]; then
+ trakgridspecs=${postgridspecs}
+fi
+
+if [[ "$outputgrid" = "rotated_latlon"* ]]; then
# For rotated_latlon output grid
# Convert from rotate lat-lon grib2 to regular lat-lon grib2
-#${WGRIB2} ${synop_grb2post} -set_bitmap 1 -set_grib_type c3 -new_grid_winds grid -new_grid_vectors "UGRD:VGRD" -new_grid_interpolation neighbor -new_grid ${synop_gridspecs} ${synop_grb2file}
+#${WGRIB2} ${grb2post} -set_bitmap 1 -set_grib_type c3 -new_grid_winds grid -new_grid_vectors "UGRD:VGRD" -new_grid_interpolation neighbor -new_grid ${postgridspecs} ${grb2file}
# Parallelize this section to speed up wgrib2
#opts='-set_bitmap 1 -set_grib_type c3 -new_grid_winds grid -new_grid_vectors "UGRD:VGRD" -new_grid_interpolation neighbor'
opts='-set_grib_type c2 -new_grid_winds grid -new_grid_vectors "UGRD:VGRD" -new_grid_interpolation neighbor'
rm -f cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":2 mb:|:5 mb:|:7 mb:|:10 mb:|:20 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part00 > cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":30 mb:|:50 mb:|:70 mb:|:100 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part01 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":125 mb:|:150 mb:|:175 mb:|:200 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part02 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":225 mb:|:250 mb:|:275 mb:|:300 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part03 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":325 mb:|:350 mb:|:375 mb:|:400 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part04 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":425 mb:|:450 mb:|:475 mb:|:500 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part05 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":525 mb:|:550 mb:|:575 mb:|:600 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part06 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":625 mb:|:650 mb:|:675 mb:|:700 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part07 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":725 mb:|:750 mb:|:775 mb:|:800 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part08 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":825 mb:|:850 mb:|:875 mb:|:900 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part09 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -match '":925 mb:|:950 mb:|:975 mb:|:1000 mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part10 >> cmdfile
-echo ${WGRIB2} ${synop_grb2post} -not '" mb:"' ${opts} -new_grid ${synop_gridspecs} ${synop_grb2post}.part11 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":2 mb:|:5 mb:|:7 mb:|:10 mb:|:20 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part00 > cmdfile
+echo ${WGRIB2} ${grb2post} -match '":30 mb:|:50 mb:|:70 mb:|:100 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part01 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":125 mb:|:150 mb:|:175 mb:|:200 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part02 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":225 mb:|:250 mb:|:275 mb:|:300 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part03 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":325 mb:|:350 mb:|:375 mb:|:400 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part04 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":425 mb:|:450 mb:|:475 mb:|:500 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part05 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":525 mb:|:550 mb:|:575 mb:|:600 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part06 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":625 mb:|:650 mb:|:675 mb:|:700 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part07 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":725 mb:|:750 mb:|:775 mb:|:800 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part08 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":825 mb:|:850 mb:|:875 mb:|:900 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part09 >> cmdfile
+echo ${WGRIB2} ${grb2post} -match '":925 mb:|:950 mb:|:975 mb:|:1000 mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part10 >> cmdfile
+echo ${WGRIB2} ${grb2post} -not '" mb:"' ${opts} -new_grid ${postgridspecs} ${grb2post}.part11 >> cmdfile
if [ ${satpost} = .true. ]; then
-echo ${WGRIB2} ${synop_sat_grb2post} ${opts} -new_grid ${synop_gridspecs} ${synop_sat_grb2file} >> cmdfile
+echo ${WGRIB2} ${sat_grb2post} ${opts} -new_grid ${postgridspecs} ${sat_grb2file} >> cmdfile
fi
chmod +x cmdfile
${APRUNC} ${MPISERIAL} -m cmdfile
# Cat the temporary files together
-cat ${synop_grb2post}.part?? > ${synop_grb2file}
+cat ${grb2post}.part?? > ${grb2file}
# clean up the temporary files
-rm -f ${synop_grb2post}.part??
+rm -f ${grb2post}.part??
-elif [ "$output_grid" = regional_latlon ]; then
+elif [[ "$outputgrid" = "regional_latlon"* ]]; then
# For regional_latlon output grid, no need to convert
-mv ${synop_grb2post} ${synop_grb2file}
+mv ${grb2post} ${grb2file}
if [ ${satpost} = .true. ]; then
-mv ${synop_sat_grb2post} ${synop_sat_grb2file}
+ mv ${sat_grb2post} ${sat_grb2file}
fi
## Alternatively, can use wgrib2 to convert from c3 to c2 packing, which can reduce the filesize by ~30%.
@@ -264,15 +326,15 @@ fi
else
-echo "ERROR: output grid: ${output_grid} not supported exitting"
+echo "ERROR: output grid: ${outputgrid} not supported exitting"
exit 1
fi
# Generate the grib2 index file
-${WGRIB2} -s ${synop_grb2file} > ${synop_grb2indx}
+${WGRIB2} -s ${grb2file} > ${grb2indx}
if [ ${satpost} = .true. ]; then
-${WGRIB2} -s ${synop_sat_grb2file} > ${synop_sat_grb2indx}
+ ${WGRIB2} -s ${sat_grb2file} > ${sat_grb2indx}
fi
# Extract hafstrk grib2 files for the tracker
@@ -287,35 +349,124 @@ PARMlist='UGRD:850|UGRD:700|UGRD:500|VGRD:850|VGRD:700|VGRD:500|UGRD:10 m a|VGRD
#PARMlist='UGRD:850|UGRD:700|UGRD:500|VGRD:850|VGRD:700|VGRD:500|UGRD:10 m a|VGRD:10 m a|ABSV:850|ABSV:700|PRMSL|HGT:900|HGT:850|HGT:800|HGT:750|HGT:700|HGT:650|HGT:600|HGT:550|HGT:500|HGT:450|HGT:400|HGT:350|HGT:300|HGT:250|HGT:200|TMP:500|TMP:450|TMP:400|TMP:350|TMP:300|TMP:250|TMP:200'
-${APRUNS} ${WGRIB2} ${synop_grb2file} -match "${PARMlist}" -grib ${hafstrk_grb2file}
+${APRUNS} ${WGRIB2} ${grb2file} -match "${PARMlist}" -grib ${trk_grb2file}
+
+# Create the combined grid01 and grid02 hafstrk grib2 file and use it to replace the grid02 hafstrk grib2 file
+if [ $ng -eq 2 ]; then
+ trkd01_grb2file=${out_prefix}.hafs.grid01.trk.f${FHR3}.grb2
+ trkd02_grb2file=${out_prefix}.hafs.grid02.trk.f${FHR3}.grb2
+ trkd12_grb2file=${out_prefix}.hafs.grid12.trk.f${FHR3}.grb2
+ opts='-set_grib_type c2 -new_grid_winds grid -new_grid_vectors "UGRD:VGRD" -new_grid_interpolation neighbor'
+ ${APRUNS} ${WGRIB2} ${intercom}/${trkd01_grb2file} ${opts} -new_grid ${trakgridspecs} ${trkd01_grb2file}.hires
+ ${APRUNS} ${WGRIB2} ${trkd02_grb2file} ${opts} -new_grid ${trakgridspecs} ${trkd02_grb2file}.hires
+ ${APRUNS} ${WGRIB2} ${trkd02_grb2file}.hires -rpn sto_1 -import_grib ${trkd01_grb2file}.hires -rpn "rcl_1:merge" -grib_out ${trkd12_grb2file}
+ mv ${trkd12_grb2file} ${trkd02_grb2file}
+fi
# Generate the index file for the tracker
-${GRB2INDEX} ${hafstrk_grb2file} ${hafstrk_grb2indx}
+${GRB2INDEX} ${trk_grb2file} ${trk_grb2indx}
+
+# Deliver to intercom
+mkdir -p ${intercom}
+mv ${trk_grb2file} ${intercom}/
+mv ${trk_grb2indx} ${intercom}/
# Deliver to COMOUTpost
if [ $SENDCOM = YES ]; then
mkdir -p ${COMOUTpost}
- mv ${synop_grb2file} ${COMOUTpost}/
- mv ${synop_grb2indx} ${COMOUTpost}/
-if [ ${satpost} = .true. ]; then
- mv ${synop_sat_grb2file} ${COMOUTpost}/
- mv ${synop_sat_grb2indx} ${COMOUTpost}/
+ mv ${grb2file} ${COMOUTpost}/
+ mv ${grb2indx} ${COMOUTpost}/
+ if [ ${satpost} = .true. ]; then
+ mv ${sat_grb2file} ${COMOUTpost}/
+ mv ${sat_grb2indx} ${COMOUTpost}/
+ fi
fi
+
+if [ ${gtype} = regional ]; then
+
+# Use mppnccombine to combine fragmented files if needed
+grid_spec=grid_spec${nesttilestr}.nc
+atmos_static=atmos_static${nesttilestr}.nc
+if [[ -z "$neststr" ]] && [[ $tilestr = ".tile1" ]]; then
+ grid_mspec=grid_mspec${neststr}_${YYYY}_${MM}_${DD}_${HH}.nc
+ atmos_diag=atmos_diag${neststr}_${YYYY}_${MM}_${DD}_${HH}.nc
+else
+ grid_mspec=grid_mspec${neststr}_${YYYY}_${MM}_${DD}_${HH}${tilestr}.nc
+ atmos_diag=atmos_diag${neststr}_${YYYY}_${MM}_${DD}_${HH}${tilestr}.nc
+fi
+fv_core=${YYYY}${MM}${DD}.${HH}0000.fv_core.res${neststr}${tilestr}.nc
+fv_tracer=${YYYY}${MM}${DD}.${HH}0000.fv_tracer.res${neststr}${tilestr}.nc
+fv_srf_wnd=${YYYY}${MM}${DD}.${HH}0000.fv_srf_wnd.res${neststr}${tilestr}.nc
+sfc_data=${YYYY}${MM}${DD}.${HH}0000.sfc_data${nesttilestr}.nc
+phy_data=${YYYY}${MM}${DD}.${HH}0000.phy_data${nesttilestr}.nc
+
+rm -f cmdfile_mppnccombine
+touch cmdfile_mppnccombine
+for file in ${INPdir}/${grid_spec} \
+ ${INPdir}/${atmos_static} \
+ ${INPdir}/${grid_mspec} \
+ ${INPdir}/${atmos_diag} \
+ ${INPdir}/RESTART/${fv_core} \
+ ${INPdir}/RESTART/${fv_tracer} \
+ ${INPdir}/RESTART/${fv_srf_wnd} \
+ ${INPdir}/RESTART/${sfc_data} \
+ ${INPdir}/RESTART/${phy_data};
+do
+ if [[ -s ${file}.0000 ]]; then
+ if [ $FHR -ge 12 ] && [ ${file} == ${INPdir}/${grid_mspec} ]; then
+ echo "Skip combining ${file}"
+ else
+ rm -f ${file}
+ # Wait for file to be complete in case it is still being written
+ while [ $(( $(date +%s) - $(stat -c %Y ${file}.0000) )) -lt 20 ]; do sleep 10; done
+ echo "time ${MPPNCCOMBINE} -v -n4 -r ${file}" >> cmdfile_mppnccombine
+ #echo "time ${MPPNCCOMBINE} -v -64 -r ${file}" >> cmdfile_mppnccombine
+ fi
+ fi
+done
+chmod +x cmdfile_mppnccombine
+if [ ${machine} = "wcoss_cray" ]; then
+ ${APRUNF} cmdfile_mppnccombine
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_mppnccombine
fi
-# Deliver to intercom
-mkdir -p ${intercom}
-mv ${hafstrk_grb2file} ${intercom}/
-mv ${hafstrk_grb2indx} ${intercom}/
+# Pass over the grid_spec.nc, atmos_static.nc, oro_data.nc if not yet exist
+if [ -s ${INPdir}/${grid_spec} ] && [ ! -s ${INPdir}/RESTART/${grid_spec} ]; then
+ ${NCP} -p ${INPdir}/${grid_spec} ${INPdir}/RESTART/
+fi
+if [ -s ${INPdir}/${atmos_static} ] && [ ! -s ${INPdir}/RESTART/${atmos_static} ]; then
+ ${NCP} -p ${INPdir}/${atmos_static} ${INPdir}/RESTART/
+fi
+oro_data=oro_data${nesttilestr}.nc
+if [ -s ${INPdir}/INPUT/${oro_data} ] && [ ! -s ${INPdir}/RESTART/${oro_data} ]; then
+ ${NCP} -pL ${INPdir}/INPUT/${oro_data} ${INPdir}/RESTART/
+fi
+
+if [[ "${is_moving_nest:-.false.}" = *".true."* ]] || [[ "${is_moving_nest:-.false.}" = *".T."* ]] ; then
+ # Pass over the grid_mspec files for moving nest (useful for storm cycling)
+ if [ $FHR -lt 12 ] && [ -s ${INPdir}/${grid_mspec} ]; then
+ ${NCP} -p ${INPdir}/${grid_mspec} ${INPdir}/RESTART/
+ fi
+ # Deliver hafs.trak.patcf if exists
+ if [ $FHR -eq $NHRS ] && [ -s ${INPdir}/${fort_patcf} ]; then
+ ${NCP} -p ${INPdir}/${fort_patcf} ${COMOUTpost}/${trk_patcf}
+ fi
+fi
+
+fi #if [ ${gtype} = regional ]; then
# Write out the postdone message file
-echo 'done' > ${INPdir}/postf${FHR3}
+echo 'done' > ${INPdir}/post${nestdotstr}f${FHR3}
cd ${DATA}
fi
# End if for checking if post has processed this forecast hour previously
+# End loop for grids/domains
+done
+
IFHR=`expr $IFHR + 1`
FHR=`expr $FHR + $NOUTHRS`
FHR2=$( printf "%02d" "$FHR" )
diff --git a/scripts/exhafs_atm_prep.sh b/scripts/exhafs_atm_prep.sh
index 8b6dade4e..eb823d93c 100755
--- a/scripts/exhafs_atm_prep.sh
+++ b/scripts/exhafs_atm_prep.sh
@@ -19,36 +19,19 @@ cyc=${cyc:-00}
STORM=${STORM:-FAKE}
STORMID=${STORMID:-00L}
-export ENSDA=${ENSDA:-NO}
-if [ ${ENSDA} != YES ]; then
- export CASE=${CASE:-C768}
- export CRES=`echo $CASE | cut -c 2-`
- export gtype=${gtype:-regional}
- export gridfixdir=${gridfixdir:-'/let/hafs_grid/generate/grid'}
- export LEVS=${LEVS:-65}
- export istart_nest=${istart_nest:-46}
- export jstart_nest=${jstart_nest:-238}
- export iend_nest=${iend_nest:-1485}
- export jend_nest=${jend_nest:-1287}
- export stretch_fac=${stretch_fac:-1.0001}
- export target_lon=${target_lon:--62.0}
- export target_lat=${target_lat:-22.0}
- export refine_ratio=${refine_ratio:-4}
-else
- export CASE=${CASE_ENS:-C768}
- export CRES=`echo $CASE | cut -c 2-`
- export gtype=${gtype_ens:-regional}
- export gridfixdir=${gridfixdir_ens:-'/let/hafs_grid/generate/grid_ens'}
- export LEVS=${LEVS_ENS:-65}
- export istart_nest=${istart_nest_ens:-46}
- export jstart_nest=${jstart_nest_ens:-238}
- export iend_nest=${iend_nest_ens:-1485}
- export jend_nest=${jend_nest_ens:-1287}
- export stretch_fac=${stretch_fac_ens:-1.0001}
- export target_lon=${target_lon_ens:--62.0}
- export target_lat=${target_lat_ens:-22.0}
- export refine_ratio=${refine_ratio_ens:-4}
-fi
+export CASE=${CASE:-C768}
+export CRES=`echo $CASE | cut -c 2-`
+export gtype=${gtype:-regional}
+export gridfixdir=${gridfixdir:-'/let/hafs_grid/generate/grid'}
+export LEVS=${LEVS:-65}
+export istart_nest=${istart_nest:-46}
+export jstart_nest=${jstart_nest:-238}
+export iend_nest=${iend_nest:-1485}
+export jend_nest=${jend_nest:-1287}
+export stretch_fac=${stretch_fac:-1.0001}
+export target_lon=${target_lon:--62.0}
+export target_lat=${target_lat:-22.0}
+export refine_ratio=${refine_ratio:-4}
export res=${res:-$CRES}
export halo=${halo:-3}
export halop1=${halop1:-4}
@@ -96,24 +79,24 @@ elif [ $gtype = stretch ]; then
export target_lon=${target_lon:--97.5} # center longitude of the highest resolution tile
export target_lat=${target_lat:-35.5} # center latitude of the highest resolution tile
echo "creating stretched grid"
-elif [ $gtype = nest ] || [ $gtype = regional ]; then
+elif [ $gtype = nest -o $gtype = regional ]; then
export stretch_fac=${stretch_fac:-1.0001} # Stretching factor for the grid
export target_lon=${target_lon:--62.0} # center longitude of the highest resolution tile
export target_lat=${target_lat:-22.0} # center latitude of the highest resolution tile
- # Need for grid types: nest and regional
- export refine_ratio=${refine_ratio:-4} # Specify the refinement ratio for nest grid
+
+ export nest_grids=${nest_grids:-1}
+ export parent_tile=${parent_tile:-6}
+ export refine_ratio=${refine_ratio:-4}
export istart_nest=${istart_nest:-46}
export jstart_nest=${jstart_nest:-238}
export iend_nest=${iend_nest:-1485}
export jend_nest=${jend_nest:-1287}
+
export halo=${halo:-3} # halo size to be used in the atmosphere cubic sphere model for the grid tile.
export halop1=${halop1:-4} # halo size that will be used for the orography and grid tile in chgres
export halo0=${halo0:-0} # no halo, used to shave the filtered orography for use in the model
- if [ $gtype = nest ];then
- echo "creating nested grid"
- else
- echo "creating regional grid"
- fi
+
+ echo "creating grid for gtype of $gtype"
else
echo "Error: please specify grid type with 'gtype' as uniform, stretch, nest or regional"
exit 1
@@ -164,20 +147,27 @@ fi
$FILTERTOPOSSH $CRES $grid_dir $orog_dir $filter_dir
echo "Grid and orography files are now prepared"
elif [ $gtype = nest ]; then
- export ntiles=7
+ export ntiles=$((6 + ${nest_grids}))
date
echo "............ execute $MAKEGRIDSSH ................."
- ${APRUNS} $MAKEGRIDSSH $CRES $grid_dir $stretch_fac $target_lon $target_lat $refine_ratio $istart_nest $jstart_nest $iend_nest $jend_nest $halo $script_dir
+ #${APRUNS} $MAKEGRIDSSH $CRES $grid_dir $stretch_fac $target_lon $target_lat $refine_ratio $istart_nest $jstart_nest $iend_nest $jend_nest $halo $script_dir
+ ${APRUNS} $MAKEGRIDSSH $CRES $grid_dir $stretch_fac $target_lon $target_lat \
+ $nest_grids \
+ "$parent_tile" \
+ "$refine_ratio" \
+ "$istart_nest" \
+ "$jstart_nest" \
+ "$iend_nest" \
+ "$jend_nest" \
+ $halo $script_dir
date
echo "............ execute $MAKEOROGSSH ................."
# Run multiple tiles simulatneously for the orography
echo "${APRUNO} $MAKEOROGSSH $CRES 1 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 2 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 3 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 4 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 5 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 6 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
+ for itile in $(seq 2 $ntiles)
+ do
+ echo "${APRUNO} $MAKEOROGSSH $CRES ${itile} $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
+ done
if [ "$machine" = hera ] || [ "$machine" = orion ] || [ "$machine" = jet ]; then
echo 'wait' >> orog.file1
fi
@@ -188,12 +178,55 @@ fi
#rm $DATA/orog.file1
date
echo "Grid and orography files are now prepared"
-elif [ $gtype = regional ]; then
+
+# regional grid with nests
+elif [ $gtype = regional ] && [ ${nest_grids} -gt 1 ]; then
+
+ export ntiles=$((6 + ${nest_grids}))
+ echo "............ execute $MAKEGRIDSSH ................."
+ #${APRUNS} $MAKEGRIDSSH $CRES $grid_dir $stretch_fac $target_lon $target_lat $refine_ratio $istart_nest $jstart_nest $iend_nest $jend_nest $halo $script_dir
+ ${APRUNS} $MAKEGRIDSSH $CRES $grid_dir $stretch_fac $target_lon $target_lat \
+ $nest_grids \
+ "$parent_tile" \
+ "$refine_ratio" \
+ "$istart_nest" \
+ "$jstart_nest" \
+ "$iend_nest" \
+ "$jend_nest" \
+ $halo $script_dir
+ date
+ echo "............ execute $MAKEOROGSSH ................."
+ # Run multiple tiles simulatneously for the orography
+ echo "${APRUNO} $MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >$DATA/orog.file1
+ for itile in $(seq 8 $ntiles)
+ do
+ echo "${APRUNO} $MAKEOROGSSH $CRES ${itile} $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
+ done
+if [ "$machine" = hera ] || [ "$machine" = orion ] || [ "$machine" = jet ]; then
+ echo 'wait' >> orog.file1
+fi
+ chmod u+x $DATA/orog.file1
+ #aprun -j 1 -n 4 -N 4 -d 6 -cc depth cfp $DATA/orog.file1
+ ${APRUNF} $DATA/orog.file1
+ wait
+ #rm $DATA/orog.file1
+ date
+ echo "Grid and orography files are now prepared"
+
+fi
+
+if [ $gtype = regional ]; then
# We are now creating only 1 tile and it is tile 7
export ntiles=1
tile=7
# number of parent points
+ iend_nest=`echo $iend_nest | cut -d , -f 1`
+ istart_nest=`echo $istart_nest | cut -d , -f 1`
+ jend_nest=`echo $jend_nest | cut -d , -f 1`
+ jstart_nest=`echo $jstart_nest | cut -d , -f 1`
+ refine_ratio=`echo $refine_ratio | cut -d , -f 1`
+
nptsx=`expr $iend_nest - $istart_nest + 1`
nptsy=`expr $jend_nest - $jstart_nest + 1`
# number of compute grid points
@@ -230,8 +263,8 @@ elif [ $gtype = regional ]; then
date
echo "............ execute $MAKEOROGSSH ................."
- #echo "$MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA " >>$DATA/orog.file1
- echo "${APRUNO} $MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >>$DATA/orog.file1
+ #echo "$MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA " >$DATA/orog.file1
+ echo "${APRUNO} $MAKEOROGSSH $CRES 7 $grid_dir $orog_dir $script_dir $FIXorog $DATA ${BACKGROUND}" >$DATA/orog.file1
if [ "$machine" = hera ] || [ "$machine" = orion ] || [ "$machine" = jet ]; then
echo 'wait' >> orog.file1
fi
@@ -288,10 +321,14 @@ fi
fi
#----------------------------------------------------------------
+# Copy mosaic file(s) to output directory.
+cp $grid_dir/${CASE}_*mosaic.nc $out_dir/
+
# For non-regional grids, copy grid and orography files to output directory.
-if [ $gtype != regional ]; then
+if [ $gtype = uniform -o $gtype = stretch -o $gtype = nest ]; then
echo "Copy grid and orography files to output directory"
tile=1
+ ntiles=`expr ${nest_grids} + 6`
while [ $tile -le $ntiles ]; do
cp $filter_dir/oro.${CASE}.tile${tile}.nc $out_dir/${CASE}_oro_data.tile${tile}.nc
cp $grid_dir/${CASE}_grid.tile${tile}.nc $out_dir/${CASE}_grid.tile${tile}.nc
@@ -299,8 +336,17 @@ if [ $gtype != regional ]; then
done
fi
-# Copy mosaic file(s) to output directory.
-cp $grid_dir/${CASE}_*mosaic.nc $out_dir/
+if [ $gtype = regional -a $nest_grids -gt 1 ]; then
+ cp -p $out_dir/${CASE}_all_mosaic.nc $out_dir/${CASE}_mosaic.nc
+ echo "Copy grid and orography files to output directory"
+ tile=8
+ ntiles=`expr ${nest_grids} + 6`
+ while [ $tile -le $ntiles ]; do
+ cp $filter_dir/oro.${CASE}.tile${tile}.nc $out_dir/${CASE}_oro_data.tile${tile}.nc
+ cp $grid_dir/${CASE}_grid.tile${tile}.nc $out_dir/${CASE}_grid.tile${tile}.nc
+ tile=`expr $tile + 1 `
+ done
+fi
#----------------------------------------------------------------
# Make surface static fields - vegetation type, soil type, etc.
@@ -338,7 +384,11 @@ elif [ $gtype = regional ]; then
HALO=$halop1
ln -fs $out_dir/${CASE}_grid.tile${tile}.halo${HALO}.nc $out_dir/${CASE}_grid.tile${tile}.nc
ln -fs $out_dir/${CASE}_oro_data.tile${tile}.halo${HALO}.nc $out_dir/${CASE}_oro_data.tile${tile}.nc
- mosaic_file=${out_dir}/${CASE}_mosaic.nc
+ if [ $nest_grids -gt 1 ]; then
+ mosaic_file=${out_dir}/${CASE}_coarse_mosaic.nc
+ else
+ mosaic_file=${out_dir}/${CASE}_mosaic.nc
+ fi
the_orog_files='"'${CASE}'_oro_data.tile'${tile}'.nc"'
else
echo "Error: please specify grid type with 'gtype' as uniform, stretch, nest or regional"
@@ -367,7 +417,9 @@ EOF
more ./fort.41
#APRUNC="srun --ntasks=6 --ntasks-per-node=6 --cpus-per-task=1"
-cp -p $SFCCLIMOEXEC ./hafs_sfc_climo_gen.x
+if [[ -e ./hafs_sfc_climo_gen.x ]]; then
+ cp -p $SFCCLIMOEXEC ./hafs_sfc_climo_gen.x
+fi
$APRUNC ./hafs_sfc_climo_gen.x
#$APRUNC $SFCCLIMOEXEC
@@ -407,16 +459,28 @@ if [ $gtype = regional ]; then
fi
#----------------------------------------------------------------
-# Run for the global nest - tile 7.
-# Second pass for global-nesting configuration will run the 7th tile
+# Run for the global or regional nested tiles
+# Second pass for global-nesting or regional-nesting configuration will run the 7+th/8+th tiles
#----------------------------------------------------------------
-if [ $gtype = nest ]; then
+if [ $gtype = nest -o $nest_grids -gt 1 ]; then
+ntiles=$(( ${nest_grids} + 6 ))
export GRIDTYPE=nest
-HALO=${HALO:-0}
-mosaic_file=$out_dir/${CASE}_nested_mosaic.nc
-the_orog_files='"'${CASE}'_oro_data.tile7.nc"'
+HALO=0
+
+if [ $gtype = regional ]; then
+ stile=8
+else
+ stile=7
+fi
+
+for itile in $(seq $stile $ntiles)
+do
+
+inest=$(($itile + 2 - $stile))
+mosaic_file=$out_dir/${CASE}_nested0${inest}_mosaic.nc
+the_orog_files='"'${CASE}'_oro_data.tile'${itile}'.nc"'
cat>./fort.41< trak.atcfunix.tmp
+ # | grep -E "^${STORMBS1^^}.,|^.${STORMBS1^^}," \
+ # | grep -E "HAFS, 00.," > trak.atcfunix.tmp
+ else
+ touch trak.atcfunix.tmp
+ fi
+ ln -sf trak.atcfunix.tmp fort.12
+ # output
+ ln -sf ./trak.fnl.all fort.30
+
+ ln -sf ${EXEChafs}/hafs_vi_create_trak_guess.x ./
+ ${APRUNS} ./hafs_vi_create_trak_guess.x ${STORMID}
+
+ # split
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ./trak.fnl.all fort.30
+ ln -sf ../prep_guess/vi_inp_30deg0p02.bin ./fort.26
+ ln -sf ../prep_guess/vi_inp_45deg0p20.bin ./fort.46
+ # output
+ ln -sf storm_env fort.56
+ ln -sf rel_inform fort.52
+ ln -sf vital_syn fort.55
+ ln -sf storm_pert fort.71
+ ln -sf storm_radius fort.85
+
+ ln -sf ${EXEChafs}/hafs_vi_split.x ./
+ gesfhr=${gesfhr:-6}
+ ibgs=0
+ iflag_cold=0
+ crfactor=${crfactor:-1.0}
+ echo ${gesfhr} $ibgs $vmax_vit $iflag_cold $crfactor | ${APRUNS} ./hafs_vi_split.x
+
+ # anl_pert
+ work_dir=${DATA}/anl_pert_guess
+ mkdir -p ${work_dir}
+ cd ${work_dir}
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ../split_guess/storm_env fort.26
+ ln -sf ../prep_guess/vi_inp_30deg0p02.bin fort.46
+ ln -sf ../split_guess/storm_pert fort.71
+ ln -sf ../split_guess/storm_radius fort.65
+ # output
+ ln -sf storm_pert_new fort.58
+ ln -sf storm_size_p fort.14
+ ln -sf storm_sym fort.23
+
+ ln -sf ${EXEChafs}/hafs_vi_anl_pert.x ./
+ basin=${pubbasin2:-AL}
+ initopt=${initopt:-0}
+ echo 6 ${basin} ${initopt} | ${APRUNS} ./hafs_vi_anl_pert.x
+
+fi
+#===============================================================================
+# Stage 2: Process current cycle's vortex from the global/parent model
+
+cd $DATA
+
+ # prep
+ work_dir=${DATA}/prep_init
+ mkdir -p ${work_dir}
+ cd ${work_dir}
+ vortexradius=30
+ res=0.02
+ ${APRUNS} ${DATOOL} hafsvi_preproc --in_dir=${RESTARTinit} \
+ --debug_level=11 --interpolation_points=5 \
+ --infile_date=${CDATE:0:8}.${CDATE:8:2}0000 \
+ --tcvital=${tcvital} \
+ --vortexradius=${vortexradius} --res=${res} \
+ --nestdoms=$((${nest_grids:-1}-1)) \
+ --out_file=vi_inp_${vortexradius}deg${res/\./p}.bin
+ if [[ ${nest_grids} -gt 1 ]]; then
+ mv vi_inp_${vortexradius}deg${res/\./p}.bin vi_inp_${vortexradius}deg${res/\./p}.bin_grid01
+ mv vi_inp_${vortexradius}deg${res/\./p}.bin_nest$(printf "%02d" ${nest_grids}) vi_inp_${vortexradius}deg${res/\./p}.bin
+ fi
+ vortexradius=45
+ res=0.20
+ ${APRUNS} ${DATOOL} hafsvi_preproc --in_dir=${RESTARTinit} \
+ --debug_level=11 --interpolation_points=5 \
+ --infile_date=${CDATE:0:8}.${CDATE:8:2}0000 \
+ --tcvital=${tcvital} \
+ --vortexradius=${vortexradius} --res=${res} \
+ --nestdoms=$((${nest_grids:-1}-1)) \
+ --out_file=vi_inp_${vortexradius}deg${res/\./p}.bin
+ if [[ ${nest_grids} -gt 1 ]]; then
+ mv vi_inp_${vortexradius}deg${res/\./p}.bin vi_inp_${vortexradius}deg${res/\./p}.bin_grid01
+ mv vi_inp_${vortexradius}deg${res/\./p}.bin_nest$(printf "%02d" ${nest_grids}) vi_inp_${vortexradius}deg${res/\./p}.bin
+ fi
+
+ # create_trak and split
+ work_dir=${DATA}/split_init
+ mkdir -p ${work_dir}
+ cd ${work_dir}
+ # input
+ ln -sf ${tcvital} fort.11
+ if [ -e ${INTCOMinit}/${STORMID,,}.${CDATE}.hafs.trak.atcfunix.all ]; then
+ ln -sf ${INTCOMinit}/${STORMID,,}.${CDATE}.hafs.trak.atcfunix.all ./trak.atcfunix.all
+ grep "^.., ${STORMID:0:2}," trak.atcfunix.all \
+ > trak.atcfunix.tmp
+ # | grep -E "^${STORMBS1^^}.,|^.${STORMBS1^^}," \
+ # | grep -E "HAFS, 00.," > trak.atcfunix.tmp
+ else
+ touch trak.atcfunix.tmp
+ fi
+ ln -sf trak.atcfunix.tmp fort.12
+ # output
+ ln -sf ./trak.fnl.all fort.30
+
+ ln -sf ${EXEChafs}/hafs_vi_create_trak_init.x ./
+ ${APRUNS} ./hafs_vi_create_trak_init.x ${STORMID}
+
+ # split
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ./trak.fnl.all fort.30
+ ln -sf ../prep_init/vi_inp_30deg0p02.bin ./fort.26
+ ln -sf ../prep_init/vi_inp_45deg0p20.bin ./fort.46
+ if [ -s ../split_guess/storm_radius ]; then
+ ln -sf ../split_guess/storm_radius ./fort.65
+ fi
+ # output
+ ln -sf storm_env fort.56
+ ln -sf rel_inform fort.52
+ ln -sf vital_syn fort.55
+ ln -sf storm_pert fort.71
+ ln -sf storm_radius fort.85
+
+ ln -sf ${EXEChafs}/hafs_vi_split.x ./
+ gesfhr=${gesfhr:-6}
+ # Warm start or cold start
+ if [ -s fort.65 ]; then
+ ibgs=1
+ iflag_cold=0
+ else
+ ibgs=2
+ iflag_cold=1
+ fi
+ echo ${gesfhr} $ibgs $vmax_vit $iflag_cold 1.0 | ${APRUNS} ./hafs_vi_split.x
+
+ # anl_pert
+ work_dir=${DATA}/anl_pert_init
+ mkdir -p ${work_dir}
+ cd ${work_dir}
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ../split_init/storm_env fort.26
+ ln -sf ../prep_init/vi_inp_30deg0p02.bin fort.46
+ ln -sf ../split_init/storm_pert fort.71
+ ln -sf ../split_init/storm_radius fort.65
+ # output
+ ln -sf storm_pert_new fort.58
+ ln -sf storm_size_p fort.14
+ ln -sf storm_sym fort.23
+
+ ln -sf ${EXEChafs}/hafs_vi_anl_pert.x ./
+ basin=${pubbasin2:-AL}
+ initopt=${initopt:-0}
+ echo 6 ${basin} ${initopt} | ${APRUNS} ./hafs_vi_anl_pert.x
+
+#===============================================================================
+# Stage 3:
+
+ # anl_storm
+ work_dir=${DATA}/anl_storm
+ mkdir -p ${work_dir}
+ cd ${work_dir}
+
+if [[ ${vmax_vit} -ge ${vi_bogus_vmax_threshold} ]] && [ ! -s ../anl_pert_guess/storm_pert_new ] ; then
+ # Bogus a storm if prior cycle does not exist and tcvital intensity >= vi_bogus_vmax_threshold (e.g., 33 m/s)
+
+ pert=init
+ senv=$pert
+ # anl_bogus
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ../split_${senv}/storm_env fort.26
+ ln -sf ../prep_${pert}/vi_inp_30deg0p02.bin ./fort.36
+ ln -sf ../prep_${pert}/vi_inp_30deg0p02.bin ./fort.46 #roughness
+ ln -sf ../split_${pert}/storm_pert fort.61
+ ln -sf ../split_${pert}/storm_radius fort.85
+
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.71
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.72
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.73
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.74
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.75
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.76
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.77
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.78
+
+ # output
+ ln -sf storm_anl_bogus fort.56
+
+ ln -sf ${EXEChafs}/hafs_vi_anl_bogus.x ./
+ basin=${pubbasin2:-AL}
+ echo 6 ${basin} | ${APRUNS} ./hafs_vi_anl_bogus.x
+ cp -p storm_anl_bogus storm_anl
+
+else
+ # warm-start from prior cycle or cold start from global/parent model
+
+ # anl_combine
+ if [[ ${vmax_vit} -ge ${vi_warm_start_vmax_threshold} ]] && [ -s ../anl_pert_guess/storm_pert_new ] ; then
+ pert=guess
+ else
+ pert=init
+ fi
+ if [ $vi_storm_env = init ] ; then
+ senv=init
+ else
+ senv=$pert
+ fi
+ if [ $pert = init ] ; then
+ gfs_flag=0
+ else
+ gfs_flag=6
+ fi
+ if [ $ENSDA = YES ]; then
+ gfs_flag=1
+ fi
+
+ rm -f flag_file
+ # input
+ ln -sf ${tcvital} fort.11
+ ln -sf ../split_${pert}/trak.atcfunix.tmp fort.12
+ ln -sf ../split_${pert}/trak.fnl.all fort.30
+ ln -sf ../anl_pert_${pert}/storm_size_p fort.14
+ ln -sf ../anl_pert_${pert}/storm_sym fort.23
+ ln -sf ../anl_pert_${pert}/storm_pert_new fort.71
+ ln -sf ../split_${senv}/storm_env fort.26
+ ln -sf ../prep_${pert}/vi_inp_30deg0p02.bin ./fort.46 #roughness
+
+ # output
+ ln -sf storm_env_new fort.36
+ ln -sf storm_anl_combine fort.56
+
+ gesfhr=${gesfhr:-6}
+ basin=${pubbasin2:-AL}
+ gfs_flag=${gfs_flag:-6}
+ initopt=${initopt:-0}
+ ln -sf ${EXEChafs}/hafs_vi_anl_combine.x ./
+ echo ${gesfhr} ${basin} ${gfs_flag} ${initopt} | ${APRUNS} ./hafs_vi_anl_combine.x
+ if [ -s storm_anl_combine ]; then
+ cp -p storm_anl_combine storm_anl
+ fi
+
+ # If the combined storm is weaker than the tcvital intensity, add a small
+ # fraction of the composite storm to enhance the storm intensity so that it
+ # matches the tcvital intensity
+ if [ -s flag_file ] && [ -s storm_env_new ]; then
+ # anl_enhance
+ # input
+ #ln -sf ${tcvital} fort.11
+ #ln -sf ./flag_file flag_file
+ ln -sf ../anl_pert_${pert}/storm_sym fort.23
+ ln -sf storm_env_new fort.26
+ ln -sf ../prep_${pert}/vi_inp_30deg0p02.bin ./fort.46 #roughness
+ ln -sf ../split_${pert}/storm_radius fort.85
+
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.71
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.72
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.73
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.74
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.75
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.76
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_30 fort.77
+ ln -sf ${FIXhafs}/fix_vi/hafs_storm_axisy_47 fort.78
+
+ # output
+ ln -sf storm_anl_enhance fort.56
+
+ basin=${pubbasin2:-AL}
+ iflag_cold=${iflag_cold:-0}
+ ln -sf ${EXEChafs}/hafs_vi_anl_enhance.x ./
+ echo 6 ${basin} ${iflag_cold} | ${APRUNS} ./hafs_vi_anl_enhance.x
+ cp -p storm_anl_enhance storm_anl
+
+ fi
+
+fi
+
+if [ ! -s storm_anl ]; then
+ echo "FATAL ERROR: Stage3 did not produce storm_anl"
+ exit 1
+fi
+
+# Interpolate storm_anl back to HAFS restart files
+cd $DATA
+
+# post
+mkdir -p ${RESTARTout}
+if [ $senv = init ] ; then
+ RESTARTdst=${RESTARTinit}
+elif [ -d ${RESTARTmrg} ] ; then
+ RESTARTdst=${RESTARTmrg}
+else
+ RESTARTdst=${RESTARTinp}
+fi
+${NCP} -rp ${RESTARTdst}/${CDATE:0:8}.${CDATE:8:2}0000* ${RESTARTout}/
+${NCP} -rp ${RESTARTdst}/atmos_static*.nc ${RESTARTout}/
+${NCP} -rp ${RESTARTdst}/grid_*spec*.nc ${RESTARTout}/
+${NCP} -rp ${RESTARTdst}/oro_data*.nc ${RESTARTout}/
+
+for nd in $(seq 1 ${nest_grids})
+do
+
+${APRUNS} ${DATOOL} hafsvi_postproc --in_file=${DATA}/anl_storm/storm_anl \
+ --debug_level=11 --interpolation_points=5 \
+ --relaxzone=30 \
+ --infile_date=${CDATE:0:8}.${CDATE:8:2}0000 \
+ --nestdoms=$((${nd}-1)) \
+ --out_dir=${RESTARTout}
+# [--relaxzone=50 (grids, default is 30) ]
+# [--debug_level=10 (default is 1) ]
+# [--interpolation_points=5 (default is 4, range 1-500) ]
+
+done
+#===============================================================================
+
+exit
diff --git a/scripts/exhafs_emcgraphics1.sh b/scripts/exhafs_emcgraphics1.sh
index e2eff78e8..a4d43bbab 100755
--- a/scripts/exhafs_emcgraphics1.sh
+++ b/scripts/exhafs_emcgraphics1.sh
@@ -68,7 +68,7 @@ echo "skip graphics for forecast hour ${FHR3} valid at ${NEWDATE}"
# Otherwise run graphics for this forecast hour
else
-atcfFile=${COMhafs}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all
+atcfFile=${COMhafs}/${stormid}.${YMDH}.hafs.trak.atcfunix.all
prodlog=${WORKhafs}/hafs_product.log
FHRN=`expr $FHR + $NOUTHRS`
STRFHRN="New forecast hour:$( printf "%5d" "$FHRN" ):00"
@@ -107,9 +107,9 @@ touch $cmdfile
#==============================================================================
# Produce these figures only if product job is still running (not done yet).
-if [ ${IFHR} -eq 0 ] || [ ! -s ${CDNOSCRUB}/${SUBEXPT}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all.orig ]; then
+if [ ${IFHR} -eq 0 ] || [ ! -s ${CDNOSCRUB}/${SUBEXPT}/${stormid}.${YMDH}.hafs.trak.atcfunix.all.orig ]; then
-atcfFile=${COMhafs}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all
+atcfFile=${COMhafs}/${stormid}.${YMDH}.hafs.trak.atcfunix.all
cd ${WORKgraph}
@@ -176,7 +176,7 @@ fi
archbase="${COMgraph}/figures"
archdir="${archbase}/RT${yyyy}_${BASIN}/${STORMNM}${STID}/${STORMNM}${STID}.${YMDH}"
- storm_atcfFile=${WORKgraph}/${stormnm}${stid}.${YMDH}.trak.hafs.atcfunix
+ storm_atcfFile=${WORKgraph}/${stid}.${YMDH}.hafs.trak.atcfunix
grep "^${BASIN2C}, ${STORMNUM}," ${atcfFile} > ${storm_atcfFile}
if [ -s ${storm_atcfFile} ]; then
@@ -342,7 +342,7 @@ done
# Plot ATCF track and intensity figures after the product job is done
#==============================================================================
-atcfFile=${CDNOSCRUB}/${SUBEXPT}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all.orig
+atcfFile=${CDNOSCRUB}/${SUBEXPT}/${stormid}.${YMDH}.hafs.trak.atcfunix.all.orig
# Wait for atcfFile under ${CDNOSCRUB}/${SUBEXPT}
n=1
@@ -361,7 +361,7 @@ done
cd ${WORKgraph}
-atcfFile=${COMhafs}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all
+atcfFile=${COMhafs}/${stormid}.${YMDH}.hafs.trak.atcfunix.all
if [ -f ${atcfFile} ]; then
atcfFile=${atcfFile}
@@ -425,7 +425,7 @@ fi
archbase="${COMgraph}/figures"
archdir="${archbase}/RT${yyyy}_${BASIN}/${STORMNM}${STID}/${STORMNM}${STID}.${YMDH}"
- storm_atcfFile=${WORKgraph}/${stormnm}${stid}.${YMDH}.trak.hafs.atcfunix
+ storm_atcfFile=${WORKgraph}/${stid}.${YMDH}.hafs.trak.atcfunix
grep "^${BASIN2C}, ${STORMNUM}," ${atcfFile} > ${storm_atcfFile}
if [ -s ${storm_atcfFile} ]; then
@@ -451,7 +451,7 @@ cp ${WORKhafs}/intercom/hycominit/hycom_settings hycom_settings
export hycom_basin=$(grep RUNmodIDout ./hycom_settings | cut -c20-)
# Wait for hycompost and product output
-atcfFile=${CDNOSCRUB}/${SUBEXPT}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all.orig
+atcfFile=${CDNOSCRUB}/${SUBEXPT}/${stormid}.${YMDH}.hafs.trak.atcfunix.all.orig
n=1
while [ $n -le 600 ]
do
diff --git a/scripts/exhafs_emcgraphics2.sh b/scripts/exhafs_emcgraphics2.sh
index beeae908e..7ab3357b1 100755
--- a/scripts/exhafs_emcgraphics2.sh
+++ b/scripts/exhafs_emcgraphics2.sh
@@ -45,7 +45,7 @@ cd ${WORKgraph}
# Plot ATCF track and intensity figures after the product job is done
#==============================================================================
-atcfFile=${CDNOSCRUB}/${SUBEXPT}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all.orig
+atcfFile=${CDNOSCRUB}/${SUBEXPT}/${stormid}.${YMDH}.hafs.trak.atcfunix.all.orig
# Wait for atcfFile under ${CDNOSCRUB}/${SUBEXPT}
n=1
@@ -64,7 +64,7 @@ done
cd ${WORKgraph}
-atcfFile=${COMhafs}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all
+atcfFile=${COMhafs}/${stormid}.${YMDH}.hafs.trak.atcfunix.all
if [ -f ${atcfFile} ]; then
atcfFile=${atcfFile}
@@ -129,7 +129,7 @@ fi
archbase="${COMgraph}/figures"
archdir="${archbase}/RT${yyyy}_${BASIN}/${STORMNM}${STID}/${STORMNM}${STID}.${YMDH}"
- storm_atcfFile=${WORKgraph}/${stormnm}${stid}.${YMDH}.trak.hafs.atcfunix
+ storm_atcfFile=${WORKgraph}/${stid}.${YMDH}.hafs.trak.atcfunix
grep "^${BASIN2C}, ${STORMNUM}," ${atcfFile} > ${storm_atcfFile}
if [ -f ${storm_atcfFile} ]; then
@@ -325,7 +325,7 @@ cp ${WORKhafs}/intercom/hycominit/hycom_settings hycom_settings
export hycom_basin=$(grep RUNmodIDout ./hycom_settings | cut -c20-)
# Wait for hycompost and product output
-atcfFile=${CDNOSCRUB}/${SUBEXPT}/${storm}${stormid}.${YMDH}.trak.hafs.atcfunix.all.orig
+atcfFile=${CDNOSCRUB}/${SUBEXPT}/${stormid}.${YMDH}.hafs.trak.atcfunix.all.orig
n=1
while [ $n -le 600 ]
do
diff --git a/scripts/exhafs_enkf.sh b/scripts/exhafs_enkf.sh
index 834e6054e..dc7777813 100755
--- a/scripts/exhafs_enkf.sh
+++ b/scripts/exhafs_enkf.sh
@@ -54,6 +54,7 @@ export nens=${ENS_SIZE:-40}
export online_satbias=${online_satbias:-no}
export corrlength=${corrlength:-500}
export lnsigcutoff=${lnsigcutoff:-1.3}
+export nesttilestr=${nesttilestr:-""}
# Diagnostic files options
netcdf_diag=${netcdf_diag:-".true."}
@@ -75,15 +76,15 @@ export COMhafsprior=${COMhafsprior:-${COMhafs}/../../${CDATEprior}/${STORMID}}
export WORKhafsprior=${WORKhafsprior:-${WORKhafs}/../../${CDATEprior}/${STORMID}}
if [ ${RUN_GSI_VR_ENS} = YES ]; then
- #export RESTARTens_inp=${COMhafs}/RESTART_analysis_vr_ens
export RESTARTens_inp=${WORKhafs}/intercom/RESTART_analysis_vr_ens
else
export RESTARTens_inp=${COMhafsprior}/RESTART_ens
fi
-#export RESTARTens_anl=${COMhafs}/RESTART_analysis_ens
export RESTARTens_anl=${WORKhafs}/intercom/RESTART_analysis_ens
+export DIAGens_anl=${COMhafs}/DIAG_analysis_ens
mkdir -p ${RESTARTens_anl}
+mkdir -p ${DIAGens_anl}
DATA=${DATA:-${WORKhafs}/enkf_mean}
mkdir -p ${DATA}
@@ -137,8 +138,8 @@ else # enkf_recenter
${NCP} ${RESTARTens_anl}/ensmean/grid_spec.nc fv3sar_tile1_grid_spec.nc
${NCP} ${RESTARTens_anl}/ensmean/${PDY}.${cyc}0000.fv_core.res.nc fv3sar_tile1_akbk.nc
${NCP} ${RESTARTens_anl}/ensmean/${PDY}.${cyc}0000.coupler.res coupler.res
- ${NCP} ${COMhafs}/RESTART_analysis/${PDY}.${cyc}0000.fv_core.res.tile1.nc fv3_dynvars
- ${NCP} ${COMhafs}/RESTART_analysis/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc fv3_tracer
+ ${NCP} ${WORKhafs}/intercom/RESTART_analysis/${PDY}.${cyc}0000.fv_core.res.tile1.nc fv3_dynvars
+ ${NCP} ${WORKhafs}/intercom/RESTART_analysis/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc fv3_tracer
#dynvar_list="delp,DZ,phis,T,u,ua,v,va,W"
dynvar_list=$(ncks --trd -m fv3_dynvars | grep -E ': type' | cut -f 1 -d ' ' | sed 's/://' | sort | grep -v 'Time' | grep -v 'axis' | paste -sd "," -)
#tracer_list="cld_amt,graupel,ice_wat,liq_wat,o3mr,rainwat,snowwat,sphum"
@@ -178,15 +179,15 @@ fi
if [ $ldo_enscalc_option -eq 0 ]; then # enkf_update
rm -f cmdfile
memstr="ensmean"
- RADSTAT=${RESTARTens_anl}/${memstr}/analysis.radstat
- CNVSTAT=${RESTARTens_anl}/${memstr}/analysis.cnvstat
+ RADSTAT=${DIAGens_anl}/${memstr}/analysis.radstat
+ CNVSTAT=${DIAGens_anl}/${memstr}/analysis.cnvstat
echo "tar -xvf $RADSTAT" >> cmdfile
echo "tar -xvf $CNVSTAT" >> cmdfile
for memstr in $(seq -f "mem%03g" 1 $nens)
do
- RADSTAT=${RESTARTens_anl}/${memstr}/analysis.radstat
- CNVSTAT=${RESTARTens_anl}/${memstr}/analysis.cnvstat
+ RADSTAT=${DIAGens_anl}/${memstr}/analysis.radstat
+ CNVSTAT=${DIAGens_anl}/${memstr}/analysis.cnvstat
echo "tar -xvf $RADSTAT" >> cmdfile
echo "tar -xvf $CNVSTAT" >> cmdfile
done
@@ -231,13 +232,13 @@ ${NLN} ${PARMgsi}/hafs_convinfo.txt ./convinfo
# Workflow will read from previous cycles for satbias predictors if online_satbias is set to yes
if [ ${online_satbias} = "yes" ] && [ ${RUN_ENVAR} = "YES" ]; then
- if [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
+ if [ ! -s ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias ] && [ ! -s ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias_pc ]; then
echo "Prior cycle satbias data does not exist. Grabbing satbias data from GDAS"
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias satbias_in
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias_pc satbias_pc
- elif [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_out satbias_in
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out satbias_pc
+ elif [ -s ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias ] && [ -s ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias_pc ]; then
+ ${NLN} ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias satbias_in
+ ${NLN} ${COMhafsprior}/DIAG_analysis/hafs.${nesttilestr}abias_pc satbias_pc
else
echo "ERROR: Either source satbias_in or source satbias_pc does not exist. Exiting script."
exit 2
@@ -291,7 +292,10 @@ cp -p $ENKFEXEC ./enkf.x
# ${APRUNC} ./enkf.x < enkf.nml > stdout 2>&1
#fi
-${APRUNC} ./enkf.x < enkf.nml > stdout 2>&1
+#${APRUNC} ./enkf.x < enkf.nml > stdout 2>&1
+set -o pipefail
+${APRUNC} ./enkf.x < enkf.nml 2>&1 | tee stdout
+set +o pipefail
if [ $ldo_enscalc_option -eq 0 ]; then # enkf_update
rm -f cmdfile
@@ -349,7 +353,6 @@ set -x
cp ${RESTARTens_inp}/${memout}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ${RESTARTens_anl}/${memout}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc
ncks -A -v $tracer_list fv3sar_tile1_${memstr}_dynvartracer ${RESTARTens_anl}/${memout}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc
ncks --no_abc -O -x -v yaxis_2 ${RESTARTens_anl}/${memout}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ${RESTARTens_anl}/${memout}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc
- #cp ${COMhafs}/RESTART_analysis/{*grid_spec.nc,*sfc_data.nc,*coupler.res,gfs_ctrl.nc,fv_core.res.nc,*bndy*} ${RESTARTens_anl}/${memout}/
${NCP} ${RESTARTens_inp}/${memout}/${PDY}.${cyc}0000.coupler.res ${RESTARTens_anl}/${memout}/
${NCP} ${RESTARTens_inp}/${memout}/${PDY}.${cyc}0000.fv_core.res.nc ${RESTARTens_anl}/${memout}/
${NCP} ${RESTARTens_inp}/${memout}/${PDY}.${cyc}0000.fv_srf_wnd.res.tile1.nc ${RESTARTens_anl}/${memout}/
diff --git a/scripts/exhafs_enkf_hx.sh b/scripts/exhafs_enkf_hx.sh
index ba087a100..916e3793f 100755
--- a/scripts/exhafs_enkf_hx.sh
+++ b/scripts/exhafs_enkf_hx.sh
@@ -34,8 +34,8 @@ else
fi
export RUN_GSI_VR_ENS=${RUN_GSI_VR_ENS:-NO}
-export GRID_RATIO_ENS=${GRID_RATIO_ENS:-1}
export RUN_ENVAR=${RUN_ENVAR:-NO}
+export GRID_RATIO_ENS=${GRID_RATIO_ENS:-1}
export online_satbias=${online_satbias:-no}
TOTAL_TASKS=${TOTAL_TASKS:-2016}
@@ -89,26 +89,25 @@ hhprior=`echo ${CDATEprior} | cut -c9-10`
cycprior=`echo ${CDATEprior} | cut -c9-10`
PDYprior=`echo ${CDATEprior} | cut -c1-8`
-if [ ${RUN_FGAT} = YES ]; then
- CDATEtm03=`${NDATE} -3 $CDATE`
- PDYtm03=`echo ${CDATEtm03} | cut -c1-8`
- cyctm03=`echo ${CDATEtm03} | cut -c9-10`
- CDATEtm02=`${NDATE} -2 $CDATE`
- PDYtm02=`echo ${CDATEtm02} | cut -c1-8`
- cyctm02=`echo ${CDATEtm02} | cut -c9-10`
- CDATEtm01=`${NDATE} -1 $CDATE`
- PDYtm01=`echo ${CDATEtm01} | cut -c1-8`
- cyctm01=`echo ${CDATEtm01} | cut -c9-10`
- CDATEtp03=`${NDATE} +3 $CDATE`
- PDYtp03=`echo ${CDATEtp03} | cut -c1-8`
- cyctp03=`echo ${CDATEtp03} | cut -c9-10`
- CDATEtp02=`${NDATE} +2 $CDATE`
- PDYtp02=`echo ${CDATEtp02} | cut -c1-8`
- cyctp02=`echo ${CDATEtp02} | cut -c9-10`
- CDATEtp01=`${NDATE} +1 $CDATE`
- PDYtp01=`echo ${CDATEtp01} | cut -c1-8`
- cyctp01=`echo ${CDATEtp01} | cut -c9-10`
-fi
+CDATEtm03=`${NDATE} -3 $CDATE`
+PDYtm03=`echo ${CDATEtm03} | cut -c1-8`
+cyctm03=`echo ${CDATEtm03} | cut -c9-10`
+CDATEtm02=`${NDATE} -2 $CDATE`
+PDYtm02=`echo ${CDATEtm02} | cut -c1-8`
+cyctm02=`echo ${CDATEtm02} | cut -c9-10`
+CDATEtm01=`${NDATE} -1 $CDATE`
+PDYtm01=`echo ${CDATEtm01} | cut -c1-8`
+cyctm01=`echo ${CDATEtm01} | cut -c9-10`
+
+CDATEtp03=`${NDATE} +3 $CDATE`
+PDYtp03=`echo ${CDATEtp03} | cut -c1-8`
+cyctp03=`echo ${CDATEtp03} | cut -c9-10`
+CDATEtp02=`${NDATE} +2 $CDATE`
+PDYtp02=`echo ${CDATEtp02} | cut -c1-8`
+cyctp02=`echo ${CDATEtp02} | cut -c9-10`
+CDATEtp01=`${NDATE} +1 $CDATE`
+PDYtp01=`echo ${CDATEtp01} | cut -c1-8`
+cyctp01=`echo ${CDATEtp01} | cut -c9-10`
export COMhafsprior=${COMhafsprior:-${COMhafs}/../../${CDATEprior}/${STORMID}}
export WORKhafsprior=${WORKhafsprior:-${WORKhafs}/../../${CDATEprior}/${STORMID}}
@@ -142,27 +141,26 @@ export REDUCE_DIAG=".true."
if [ ${RUN_GSI_VR_ENS} = YES ]; then
if [ ${HX_ENS} != YES ]; then
- #export RESTARTens_inp=${COMhafs}/RESTART_analysis_ens/${MEMSTR}
export RESTARTens_inp=${WORKhafs}/intercom/RESTART_analysis_ens/${MEMSTR}
else
- #export RESTARTens_inp=${COMhafs}/RESTART_analysis_vr_ens/${MEMSTR}
export RESTARTens_inp=${WORKhafs}/intercom/RESTART_analysis_vr_ens/${MEMSTR}
fi
else
if [ ${HX_ENS} != YES ]; then
- #export RESTARTens_inp=${COMhafs}/RESTART_analysis_ens/${MEMSTR}
export RESTARTens_inp=${WORKhafs}/intercom/RESTART_analysis_ens/${MEMSTR}
else
export RESTARTens_inp=${COMhafsprior}/RESTART_ens/${MEMSTR}
fi
fi
-#export RESTARTens_anl=${COMhafs}/RESTART_analysis_ens/${MEMSTR}
export RESTARTens_anl=${WORKhafs}/intercom/RESTART_analysis_ens/${MEMSTR}
+export DIAGens_anl=${COMhafs}/DIAG_analysis_ens/${MEMSTR}
RESTARTinp=${RESTARTinp:-${RESTARTens_inp}}
RESTARTanl=${RESTARTanl:-${RESTARTens_anl}}
+DIAGanl=${DIAGanl:-${DIAGens_anl}}
mkdir -p ${RESTARTanl}
+mkdir -p ${DIAGanl}
## ObsInput file from ensemble mean
export SELECT_OBS=${SELECT_OBS:-${RESTARTanl}/../ensmean/obsinput.tar}
@@ -188,12 +186,12 @@ ${NCP} ${RESTARTinp}/atmos_static.nc ./fv3_atmos_static
${NCP} ${RESTARTinp}/grid_spec.nc ./fv3_grid_spec
# Stat files
-RADSTAT=${RADSTAT:-${RESTARTanl}/analysis.radstat}
-GSISTAT=${GSISTAT:-${RESTARTanl}/analysis.gsistat}
-PCPSTAT=${PCPSTAT:-${RESTARTanl}/analysis.pcpstat}
-CNVSTAT=${CNVSTAT:-${RESTARTanl}/analysis.cnvstat}
-OZNSTAT=${OZNSTAT:-${RESTARTanl}/analysis.oznstat}
-GSISOUT=${GSISOUT:-${RESTARTanl}/analysis.gsisout}
+RADSTAT=${RADSTAT:-${DIAGanl}/analysis.radstat}
+GSISTAT=${GSISTAT:-${DIAGanl}/analysis.gsistat}
+PCPSTAT=${PCPSTAT:-${DIAGanl}/analysis.pcpstat}
+CNVSTAT=${CNVSTAT:-${DIAGanl}/analysis.cnvstat}
+OZNSTAT=${OZNSTAT:-${DIAGanl}/analysis.oznstat}
+GSISOUT=${GSISOUT:-${DIAGanl}/analysis.gsisout}
# Obs diag
RUN_SELECT=${RUN_SELECT:-"NO"}
@@ -430,8 +428,8 @@ if [ -s ${WORKhafs}/intercom/obs_proc/hafs.prepbufr ]; then
${NCP} ${WORKhafs}/intercom/obs_proc/hafs.prepbufr prepbufr
fi
# cat tempdrop.prepbufr with drifting correction into prepbufr
-if [ -s ${WORKhafs}/intercom/obs_proc/tempdrop.prepbufr ]; then
- cat ${WORKhafs}/intercom/obs_proc/tempdrop.prepbufr >> prepbufr
+if [ -s ${WORKhafs}/intercom/obs_proc/hafs.tempdrop.prepbufr ]; then
+ cat ${WORKhafs}/intercom/obs_proc/hafs.tempdrop.prepbufr >> prepbufr
fi
COMINhafs_obs=${COMINhafs_obs:-${COMINhafs}/hafs.$PDY/$cyc/${atmos}}
${NLN} ${COMINhafs_obs}/hafs.t${cyc}z.hdob.tm00.bufr_d hdobbufr
@@ -442,13 +440,13 @@ fi #USE_SELECT
# Workflow will read from previous cycles for satbias predictors if online_satbias is set to yes
if [ ${online_satbias} = "yes" ] && [ ${RUN_ENVAR} = "YES" ]; then
- if [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ ! -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
+ if [ ! -s ${COMhafsprior}/DIAG_analysis/satbias_hafs_out ] && [ ! -s ${COMhafsprior}/DIAG_analysis/satbias_hafs_pc.out ]; then
echo "Prior cycle satbias data does not exist. Grabbing satbias data from GDAS"
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias satbias_in
${NLN} ${COMgfs}/gdas.$PDYprior/${hhprior}/${atmos}gdas.t${hhprior}z.abias_pc satbias_pc
- elif [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_out ] && [ -s ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out ]; then
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_out satbias_in
- ${NLN} ${COMhafsprior}/RESTART_analysis/satbias_hafs_pc.out satbias_pc
+ elif [ -s ${COMhafsprior}/DIAG_analysis/satbias_hafs_out ] && [ -s ${COMhafsprior}/DIAG_analysis/satbias_hafs_pc.out ]; then
+ ${NLN} ${COMhafsprior}/DIAG_analysis/satbias_hafs_out satbias_in
+ ${NLN} ${COMhafsprior}/DIAG_analysis/satbias_hafs_pc.out satbias_pc
else
echo "ERROR: Either source satbias_in or source satbias_pc does not exist. Exiting script."
exit 2
@@ -522,8 +520,9 @@ sed -e "s/_MITER_/${MITER:-2}/g" \
ANALYSISEXEC=${ANALYSISEXEC:-${EXEChafs}/hafs_gsi.x}
${NCP} -p ${ANALYSISEXEC} ./hafs_gsi.x
-${APRUNC} ./hafs_gsi.x 1> stdout 2>&1
-cat stdout
+set -o pipefail
+${APRUNC} ./hafs_gsi.x 2>&1 | tee ./stdout
+set +o pipefail
${NCP} -p ./stdout ${GSISOUT}
diff --git a/scripts/exhafs_forecast.sh b/scripts/exhafs_forecast.sh
index 25f1a3913..78a7bc2fb 100755
--- a/scripts/exhafs_forecast.sh
+++ b/scripts/exhafs_forecast.sh
@@ -18,7 +18,6 @@ yr=$(echo $CDATE | cut -c1-4)
mn=$(echo $CDATE | cut -c5-6)
dy=$(echo $CDATE | cut -c7-8)
hh=$(echo ${CDATE} | cut -c9-10)
-cyc=${cyc:-00}
STORM=${STORM:-FAKE}
STORMID=${STORMID:-00L}
@@ -34,6 +33,9 @@ FIXcrtm=${FIXcrtm:-${FIXhafs}/hafs-crtm-2.3.0}
FIXhycom=${FIXhycom:-${FIXhafs}/fix_hycom}
FORECASTEXEC=${FORECASTEXEC:-${EXEChafs}/hafs_forecast.x}
+ATPARSE=${ATPARSE:-${USHhafs}/hafs_atparse.sh}
+source ${ATPARSE}
+
out_prefix=${out_prefix:-$(echo "${STORM}${STORMID}.${YMDH}" | tr '[A-Z]' '[a-z]')}
satpost=${satpost:-.false.}
@@ -52,6 +54,14 @@ if [ "${ENSDA}" != YES ]; then
target_lon=${target_lon:--62.0}
target_lat=${target_lat:-22.0}
refine_ratio=${refine_ratio:-4}
+ nest_grids=${nest_grids:-1}
+ parent_grid_num=${parent_grid_num:-1}
+ parent_tile=${parent_tile:-6}
+ refine_ratio=${refine_ratio:-4}
+ istart_nest=${istart_nest:-46}
+ jstart_nest=${jstart_nest:-238}
+ iend_nest=${iend_nest:-1485}
+ jend_nest=${jend_nest:-1287}
deflate_level=${deflate_level:--1}
ccpp_suite_regional=${ccpp_suite_regional:-FV3_HAFS_v1}
ccpp_suite_glob=${ccpp_suite_glob:-FV3_HAFS_v1}
@@ -69,12 +79,28 @@ if [ "${ENSDA}" != YES ]; then
glob_layouty=${glob_layouty:-12}
glob_npx=${glob_npx:-769}
glob_npy=${glob_npy:-769}
+ glob_io_layoutx=${glob_io_layoutx:-1}
+ glob_io_layouty=${glob_io_layouty:-10}
+ glob_full_zs_filter=${glob_full_zs_filter:-.true.}
+ glob_n_zs_filter=${glob_n_zs_filter:-1}
+ glob_n_del2_weak=${glob_n_del2_weak:-20}
+ glob_max_slope=${glob_max_slope:-0.25}
+ glob_shal_cnv=${glob_shal_cnv:-.true.}
+ glob_do_deep=${glob_do_deep:-.true.}
k_split=${k_split:-4}
n_split=${n_split:-5}
layoutx=${layoutx:-40}
layouty=${layouty:-30}
npx=${npx:-2881}
npy=${npy:-1921}
+ io_layoutx=${io_layoutx:-1}
+ io_layouty=${io_layouty:-10}
+ full_zs_filter=${full_zs_filter:-.true.}
+ n_zs_filter=${n_zs_filter:-1}
+ n_del2_weak=${n_del2_weak:-20}
+ max_slope=${max_slope:-0.25}
+ shal_cnv=${shal_cnv:-.true.}
+ do_deep=${do_deep:-.true.}
npz=${npz:-64}
output_grid_dlon=${output_grid_dlon:-0.025}
output_grid_dlat=${output_grid_dlon:-0.025}
@@ -90,6 +116,14 @@ else
target_lon=${target_lon_ens:--62.0}
target_lat=${target_lat_ens:-22.0}
refine_ratio=${refine_ratio_ens:-4}
+# nest_grids=${nest_grids:-1}
+# parent_grid_num=${parent_grid_num:-1}
+# parent_tile=${parent_tile:-6}
+# refine_ratio=${refine_ratio:-4}
+# istart_nest=${istart_nest:-46}
+# jstart_nest=${jstart_nest:-238}
+# iend_nest=${iend_nest:-1485}
+# jend_nest=${jend_nest:-1287}
deflate_level=${deflate_level:-1}
ccpp_suite_regional=${ccpp_suite_regional_ens:-FV3_HAFS_v1}
ccpp_suite_glob=${ccpp_suite_glob_ens:-FV3_HAFS_v1}
@@ -107,12 +141,28 @@ else
glob_layouty=${glob_layouty_ens:-12}
glob_npx=${glob_npx_ens:-769}
glob_npy=${glob_npy_ens:-769}
+ glob_io_layoutx=${glob_io_layoutx_ens:-1}
+ glob_io_layouty=${glob_io_layouty_ens:-10}
+ glob_full_zs_filter=${glob_full_zs_filter_ens:-.true.}
+ glob_n_zs_filter=${glob_n_zs_filter_ens:-1}
+ glob_n_del2_weak=${glob_n_del2_weak_ens:-20}
+ glob_max_slope=${glob_max_slope_ens:-0.25}
+ glob_shal_cnv=${glob_shal_cnv_ens:-.true.}
+ glob_do_deep=${glob_do_deep_ens:-.true.}
k_split=${k_split_ens:-4}
n_split=${n_split_ens:-5}
layoutx=${layoutx_ens:-40}
layouty=${layouty_ens:-30}
npx=${npx_ens:-2881}
npy=${npy_ens:-1921}
+ io_layoutx=${io_layoutx_ens:-1}
+ io_layouty=${io_layouty_ens:-10}
+ full_zs_filter=${full_zs_filter_ens:-.true.}
+ n_zs_filter=${n_zs_filter_ens:-1}
+ n_del2_weak=${n_del2_weak_ens:-20}
+ max_slope=${max_slope_ens:-0.25}
+ shal_cnv=${shal_cnv_ens:-.true.}
+ do_deep=${do_deep_ens:-.true.}
npz=${npz_ens:-64}
output_grid_dlon_ens=${output_grid_dlon_ens:-$(awk "BEGIN {print ${output_grid_dlon:-0.025}*${GRID_RATIO_ENS:-1}}")}
output_grid_dlat_ens=${output_grid_dlat_ens:-$(awk "BEGIN {print ${output_grid_dlat:-0.025}*${GRID_RATIO_ENS:-1}}")}
@@ -120,15 +170,6 @@ else
output_grid_dlat=${output_grid_dlat_ens}
fi
-app_domain=${app_domain:-regional}
-output_grid=${output_grid:-rotated_latlon}
-output_grid_cen_lon=${output_grid_cen_lon:-${domlon}}
-output_grid_cen_lat=${output_grid_cen_lat:-${domlat}}
-output_grid_lon1=${output_grid_lon1:--35.0}
-output_grid_lat1=${output_grid_lat1:--30.0}
-output_grid_lon2=${output_grid_lon2:-35.0}
-output_grid_lat2=${output_grid_lat2:-30.0}
-
halo_blend=${halo_blend:-0}
nstf_n1=${nstf_n1:-2}
nstf_n2=${nstf_n2:-0}
@@ -136,6 +177,8 @@ nstf_n3=${nstf_n3:-0}
nstf_n4=${nstf_n4:-0}
nstf_n5=${nstf_n5:-0}
+levp=${LEVS}
+
# Set options for cold-start or warm-start
# Default is cold start from chgres_ic generated ic/bc
na_init=${na_init:-1}
@@ -152,63 +195,87 @@ if [ ${warm_start_opt} -eq 0 ]; then
RESTARTinp="UNNEEDED"
fi
+if [ ${run_init:-no} = no ]; then
+
# Different warm_start_opt options for determinist/ensemble forecast
if [ ${ENSDA} != "YES" ]; then # for deterministic forecast
-if [ ${warm_start_opt} -eq 1 ] && [ -s ${COMhafs}/RESTART_init/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${warm_start_opt} -eq -1 ] && [ -s ${COMhafsprior}/RESTART/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_init
+ RESTARTinp=${COMhafsprior}/RESTART
fi
-if [ ${warm_start_opt} -eq 2 ] && [ -s ${COMhafsprior}/RESTART/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_INIT} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_init/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafsprior}/RESTART
+ RESTARTinp=${WORKhafs}/intercom/RESTART_init
+ #warm_start_opt=1
fi
-if [ ${warm_start_opt} -eq 3 ] && [ -s ${COMhafs}/RESTART_vi/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_MERGE} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_merge/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_vi
+ RESTARTinp=${WORKhafs}/intercom/RESTART_merge
+ #warm_start_opt=2
fi
-if [ ${RUN_GSI_VR} = YES ] && [ -s ${COMhafs}/RESTART_analysis_vr/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_VI} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_vi/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_analysis_vr
- warm_start_opt=4
+ RESTARTinp=${WORKhafs}/intercom/RESTART_vi
+ #warm_start_opt=3
fi
-if [ ${RUN_GSI} = YES ] && [ -s ${COMhafs}/RESTART_analysis/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_GSI_VR} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_vr/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_analysis
- warm_start_opt=5
+ RESTARTinp=${WORKhafs}/intercom/RESTART_analysis_vr
+ #warm_start_opt=4
+fi
+if [ ${RUN_GSI} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
+ warmstart_from_restart=yes
+ RESTARTinp=${WORKhafs}/intercom/RESTART_analysis
+ #warm_start_opt=5
+fi
+if [ ${RUN_ANALYSIS_MERGE} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_merge/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
+ warmstart_from_restart=yes
+ RESTARTinp=${WORKhafs}/intercom/RESTART_analysis_merge
+ #warm_start_opt=6
fi
else # for ENSDA member forecast
-if [ ${warm_start_opt} -eq 1 ] && [ -s ${COMhafs}/RESTART_init_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${warm_start_opt} -eq -1 ] && [ -s ${COMhafsprior}/RESTART_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_init_ens/mem${ENSID}
+ RESTARTinp=${COMhafsprior}/RESTART_ens/mem${ENSID}
fi
-if [ ${warm_start_opt} -eq 2 ] && [ -s ${COMhafsprior}/RESTART_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_INIT_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafsprior}/RESTART_ens/mem${ENSID}
+ RESTARTinp=${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}
+ #warm_start_opt=1
fi
-if [ ${warm_start_opt} -eq 3 ] && [ -s ${COMhafs}/RESTART_vi_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_MERGE_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_merge_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- RESTARTinp=${COMhafs}/RESTART_vi_ens/mem${ENSID}
+ RESTARTinp=${WORKhafs}/intercom/RESTART_merge_ens/mem${ENSID}
+ #warm_start_opt=2
fi
-#if [ ${RUN_GSI_VR_ENS} = YES ] && [ -s ${COMhafs}/RESTART_analysis_vr_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
-if [ ${RUN_GSI_VR_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_vr_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ATM_VI_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_vi_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
+ warmstart_from_restart=yes
+ RESTARTinp=${WORKhafs}/intercom/RESTART_vi_ens/mem${ENSID}
+ #warm_start_opt=3
+fi
+if [ ${RUN_GSI_VR_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_vr_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- #RESTARTinp=${COMhafs}/RESTART_analysis_vr_ens/mem${ENSID}
RESTARTinp=${WORKhafs}/intercom/RESTART_analysis_vr_ens/mem${ENSID}
- warm_start_opt=4
+ #warm_start_opt=4
fi
-#if [ ${RUN_ENKF} = YES ] && [ -s ${COMhafs}/RESTART_analysis_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
-if [ ${RUN_ENKF} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_ens/mem${ENSID}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ]; then
+if [ ${RUN_ENKF} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
warmstart_from_restart=yes
- #RESTARTinp=${COMhafs}/RESTART_analysis_ens/mem${ENSID}
RESTARTinp=${WORKhafs}/intercom/RESTART_analysis_ens/mem${ENSID}
- warm_start_opt=5
+ #warm_start_opt=5
+fi
+if [ ${RUN_ANALYSIS_MERGE_ENS} = YES ] && [ -s ${WORKhafs}/intercom/RESTART_analysis_merge_ens/mem${ENSID}/${YMD}.${hh}0000.fv_core.res.tile1.nc ]; then
+ warmstart_from_restart=yes
+ RESTARTinp=${WORKhafs}/intercom/RESTART_analysis_merge_ens/mem${ENSID}
+ #warm_start_opt=6
fi
fi # ${ENSDA} != "YES"
+fi # ${run_init} = "no"
+
# For warm start from restart files
if [ ${warmstart_from_restart} = yes ]; then
na_init=0
@@ -256,16 +323,26 @@ mesh_atm=${mesh_atm:-''}
mesh_ocn=${mesh_ocn:-''}
if [ $gtype = regional ]; then
+ ATM_tasks=0
+ for n in $(seq 1 ${nest_grids})
+ do
+ layoutx_tmp=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_tmp=$( echo ${layouty} | cut -d , -f ${n} )
+ ATM_tasks=$(($ATM_tasks+$layoutx_tmp*$layouty_tmp ))
+ done
if [ $quilting = .true. ]; then
- ATM_tasks=$(($layoutx*$layouty+$write_groups*$write_tasks_per_group))
- else
- ATM_tasks=$(($layoutx*$layouty))
+ ATM_tasks=$(($ATM_tasks+$write_groups*$write_tasks_per_group))
fi
elif [ $gtype = nest ]; then
+ ATM_tasks=$(( ${glob_layoutx} * ${glob_layouty} * 6 ))
+ for n in $(seq 1 ${nest_grids})
+ do
+ layoutx_tmp=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_tmp=$( echo ${layouty} | cut -d , -f ${n} )
+ ATM_tasks=$(($ATM_tasks+$layoutx_tmp*$layouty_tmp ))
+ done
if [ $quilting = .true. ]; then
- ATM_tasks=$((6*$glob_layoutx*$glob_layouty+$layoutx*$layouty+$write_groups*$write_tasks_per_group))
- else
- ATM_tasks=$((6*$glob_layoutx*$glob_layouty+$layoutx*$layouty))
+ ATM_tasks=$(($ATM_tasks+$write_groups*$write_tasks_per_group))
fi
else
echo "FATAL ERROR: Unsupported gtype of ${gtype}. Currently onnly support gtype of nest or regional."
@@ -368,7 +445,7 @@ elif [[ $cpl_atm_wav = "cmeps"* ]]; then
cplwav=.true.
cplwav2atm=.true.
CPL_WND="CPL:native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n MED -> WAV :remapMethod=redist\n ATM\n WAV\n ATM -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_wav\n "
# CMEPS based one-way atm-wav coupling from atm to wav only
elif [ $cpl_atm_wav = cmeps_1way_1to2 ]; then
cplflx=.true.
@@ -376,7 +453,7 @@ elif [[ $cpl_atm_wav = "cmeps"* ]]; then
cplwav=.true.
cplwav2atm=.false.
CPL_WND="CPL:native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> WAV :remapMethod=redist\n ATM\n WAV\n ATM -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_wav\n "
# CMEPS based one-way atm-wav coupling from wav to atm only
elif [ $cpl_atm_wav = cmeps_1way_2to1 ]; then
cplflx=.true.
@@ -384,7 +461,7 @@ elif [[ $cpl_atm_wav = "cmeps"* ]]; then
cplwav=.true.
cplwav2atm=.true.
CPL_WND="native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n ATM\n WAV\n ATM -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_wav\n "
# CMEPS based atm-wav side by side run (no coupling)
elif [ $cpl_atm_wav = cmeps_sidebyside ]; then
cplflx=.true.
@@ -392,7 +469,7 @@ elif [[ $cpl_atm_wav = "cmeps"* ]]; then
cplwav=.true.
cplwav2atm=.false.
CPL_WND="native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n ATM\n WAV\n ATM -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_wav\n "
fi
# Currently unsupported coupling option combinations
else
@@ -439,7 +516,7 @@ elif [ $cpl_atm_ocn = cmeps_2way ] && [ $cpl_atm_wav = cmeps_2way ]; then
cplwav=.true.
cplwav2atm=.true.
CPL_WND="CPL:native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED -> OCN :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n MED -> OCN :remapMethod=redist\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV\n ATM -> MED :remapMethod=redist\n OCN -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_ocn\n MED med_phases_post_wav"
# CMEPS based two-way atm-ocn coupling and one-way atm-wav coupling from atm to wav only
elif [ $cpl_atm_ocn = cmeps_2way ] && [ $cpl_atm_wav = cmeps_1way_1to2 ]; then
cplflx=.true.
@@ -447,8 +524,7 @@ elif [ $cpl_atm_ocn = cmeps_2way ] && [ $cpl_atm_wav = cmeps_1way_1to2 ]; then
cplwav=.true.
cplwav2atm=.false.
CPL_WND="CPL:native"
- #runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED -> OCN :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED -> OCN :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n MED -> OCN :remapMethod=redist\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV\n ATM -> MED :remapMethod=redist\n OCN -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_ocn\n MED med_phases_post_wav"
# CMEPS based one-way atm-ocn coupling from atm to ocn only and two-way atm-wav coupling
elif [ $cpl_atm_ocn = cmeps_1way_1to2 ] && [ $cpl_atm_wav = cmeps_2way ]; then
cplflx=.true.
@@ -456,7 +532,7 @@ elif [ $cpl_atm_ocn = cmeps_1way_1to2 ] && [ $cpl_atm_wav = cmeps_2way ]; then
cplwav=.true.
cplwav2atm=.true.
CPL_WND="CPL:native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED -> OCN :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n MED -> OCN :remapMethod=redist\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV\n ATM -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_ocn\n MED med_phases_post_wav"
# CMEPS based one-way atm-ocn coupling from atm to ocn only and one-way atm-wav coupling from atm to wav only
elif [ $cpl_atm_ocn = cmeps_1way_1to2 ] && [ $cpl_atm_wav = cmeps_1way_1to2 ]; then
cplflx=.true.
@@ -464,7 +540,7 @@ elif [ $cpl_atm_ocn = cmeps_1way_1to2 ] && [ $cpl_atm_wav = cmeps_1way_1to2 ]; t
cplwav=.true.
cplwav2atm=.false.
CPL_WND="CPL:native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED -> OCN :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n MED -> OCN :remapMethod=redist\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV\n ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_ocn\n MED med_phases_post_wav"
# CMEPS based atm-ocn-wav side by side run
elif [ $cpl_atm_ocn = cmeps_sidebyside ] && [ $cpl_atm_wav = cmeps_sidebyside ]; then
cplflx=.true.
@@ -472,7 +548,7 @@ elif [ $cpl_atm_ocn = cmeps_sidebyside ] && [ $cpl_atm_wav = cmeps_sidebyside ];
cplwav=.true.
cplwav2atm=.false.
CPL_WND="native"
- runSeq_ALL="ATM -> MED :remapMethod=redist\n MED med_phases_post_atm\n OCN -> MED :remapMethod=redist\n MED med_phases_post_ocn\n WAV -> MED :remapMethod=redist\n MED med_phases_post_wav\n MED med_phases_prep_atm\n MED -> ATM :remapMethod=redist\n MED med_phases_prep_wav\n MED -> WAV :remapMethod=redist\n ATM\n OCN\n WAV"
+ runSeq_ALL="MED med_phases_prep_atm\n MED med_phases_prep_ocn_accum\n MED med_phases_prep_ocn_avg\n MED med_phases_prep_wav_accum\n MED med_phases_prep_wav_avg\n MED -> ATM :remapMethod=redist\n ATM\n OCN\n WAV\n ATM -> MED :remapMethod=redist\n OCN -> MED :remapMethod=redist\n WAV -> MED :remapMethod=redist\n MED med_phases_post_atm\n MED med_phases_post_ocn\n MED med_phases_post_wav"
# Currently unsupported coupling option combinations
else
echo "FATAL ERROR: Unsupported coupling options: cpl_atm_ocn=${cpl_atm_ocn}; cpl_atm_wav=${cpl_atm_wav}"
@@ -507,14 +583,19 @@ if [ ${ENSDA} = YES ]; then
RESTARTout=${RESTARTout:-${COMhafs}/RESTART_ens/mem${ENSID}}
mkdir -p ${RESTARTout}
${NLN} ${RESTARTout} RESTART
-elif [ ${RUN_GSI} = YES ] || [ ${RUN_GSI_VR} = YES ]; then
+elif [ ${RUN_GSI} = YES ] || [ ${RUN_GSI_VR} = YES ] || [ ${RUN_ATM_VI} = YES ] || [ ${RUN_ATM_MERGE} = YES ]; then
RESTARTout=${RESTARTout:-${COMhafs}/RESTART}
mkdir -p ${RESTARTout}
${NLN} ${RESTARTout} RESTART
else
RESTARTout=${RESTARTout:-./RESTART}
mkdir -p ${RESTARTout}
+ if [ ! -e ./RESTART ]; then
+ ${NLN} ${RESTARTout} RESTART
+ fi
fi
+# Clean up old RESTART files if exist
+rm -f RESTART/*
mkdir -p INPUT
@@ -528,6 +609,12 @@ fi
${NLN} ${INPdir}/*.nc INPUT/
+if [ ${run_init:-no} = yes ]; then
+ cd INPUT/
+ ${NLN} gfs_bndy.tile7.000.nc gfs_bndy.tile7.003.nc
+ cd ../
+fi
+
# Copy fix files
${NCP} $FIXam/global_solarconstant_noaa_an.txt solarconstant_noaa_an.txt
${NCP} $FIXam/ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77 global_o3prdlos.f77
@@ -558,39 +645,44 @@ for file in $(ls ${FIXam}/fix_co2_proj/global_co2historicaldata*); do
${NCP} $file $(echo $(basename $file) |sed -e "s/global_//g")
done
-# If needed, copy fix files needed by the hwrf ccpp physics suite
-if [[ ${ccpp_suite_regional} == *"hwrf"* ]] || [[ ${ccpp_suite_glob} == *"hwrf"* ]] || [[ ${ccpp_suite_nest} == *"hwrf"* ]]; then
- ${NCP} ${PARMhafs}/forecast/hwrf_physics_fix/* .
-fi
-
if [ $gtype = nest ]; then
- ntiles=7
-elif [ $gtype = regional ]; then
- ntiles=1
-elif [ $gtype = uniform ] || [ $gtype = stretch ]; then
- ntiles=6
-else
- echo "FATAL ERROR: Unsupported gtype of ${gtype}."
- exit 9
-fi
-if [ $gtype = nest ]; then
+cd ./INPUT
+
+ntiles=$((6 + ${nest_grids}))
# Copy grid and orography
-tile=1
-while [ $tile -le $ntiles ]; do
- ${NCP} $FIXgrid/${CASE}/${CASE}_oro_data.tile${tile}.nc INPUT/oro_data.tile${tile}.nc
- ${NCP} $FIXgrid/${CASE}/${CASE}_grid.tile${tile}.nc INPUT/${CASE}_grid.tile${tile}.nc
- let tile=tile+1
+for itile in $(seq 1 ${ntiles})
+do
+ cp $FIXgrid/${CASE}/${CASE}_oro_data.tile${itile}.nc ./oro_data.tile${itile}.nc
+ cp $FIXgrid/${CASE}/${CASE}_grid.tile${itile}.nc ./${CASE}_grid.tile${itile}.nc
+done
+${NCP} $FIXgrid/${CASE}/${CASE}_mosaic.nc ./grid_spec.nc
+
+for itile in $(seq 7 ${ntiles})
+do
+ inest=$(($itile - 5))
+ ${NLN} ${CASE}_grid.tile${itile}.nc grid.nest0${inest}.tile${itile}.nc
+ ${NLN} oro_data.tile${itile}.nc oro_data.nest0${inest}.tile${itile}.nc
+ ${NLN} gfs_data.tile${itile}.nc gfs_data.nest0${inest}.tile${itile}.nc
+ ${NLN} sfc_data.tile${itile}.nc sfc_data.nest0${inest}.tile${itile}.nc
done
-${NCP} $FIXgrid/${CASE}/${CASE}_mosaic.nc INPUT/grid_spec.nc
-cd ./INPUT
-#${NLN} ${CASE}_grid.tile7.nc ${CASE}_grid.nest02.tile7.nc
-${NLN} ${CASE}_grid.tile7.nc grid.nest02.tile7.nc
-${NLN} oro_data.tile7.nc oro_data.nest02.tile7.nc
-${NLN} gfs_data.tile7.nc gfs_data.nest02.tile7.nc
-${NLN} sfc_data.tile7.nc sfc_data.nest02.tile7.nc
+# moving nest
+if [[ "${is_moving_nest}" = *".true."* ]] || [[ "${is_moving_nest}" = *".T."* ]] ; then
+ mkdir -p moving_nest
+ cd moving_nest
+ rrtmp=$(echo ${refine_ratio} | rev | cut -d, -f1 | rev)
+ ${NLN} $FIXgrid/${CASE}/${CASE}_grid.tile6.nc grid.tile6.nc
+ ${NLN} $FIXgrid/${CASE}/${CASE}_oro_data.tile6.nc oro_data.tile6.nc
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/${CASE_mvnest1res}_grid.tile6.nc grid.tile6.${rrtmp}x.nc
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/${CASE_mvnest1res}_oro_data.tile6.nc oro_data.tile6.${rrtmp}x.nc
+ for var in facsf maximum_snow_albedo slope_type snowfree_albedo soil_type substrate_temperature vegetation_greenness vegetation_type; do
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/fix_sfc/${CASE_mvnest1res}.${var}.tile6.nc ${var}.tile6.${rrtmp}x.nc
+ done
+ cd ..
+fi
+
cd ..
# Prepare data_table, diag_table, field_table, input.nml, input_nest02.nml,
@@ -599,103 +691,86 @@ cd ..
${NCP} ${PARMforecast}/diag_table.tmp .
${NCP} ${PARMforecast}/field_table .
${NCP} ${PARMforecast}/input.nml.tmp .
-${NCP} ${PARMforecast}/input_nest02.nml.tmp .
+${NCP} ${PARMforecast}/input_nest.nml.tmp .
${NCP} ${PARMforecast}/model_configure.tmp .
${NCP} ${PARMforecast}/nems.configure.atmonly ./nems.configure
+ngrids=$(( ${nest_grids} + 1 ))
glob_pes=$(( ${glob_layoutx} * ${glob_layouty} * 6 ))
-nest_pes=$(( ${layoutx} * ${layouty} ))
-ioffset=$(( (istart_nest-1)/2 + 1))
-joffset=$(( (jstart_nest-1)/2 + 1))
-blocksize=$(( ${glob_npy}/${glob_layouty} ))
-
-sed -e "s/_blocksize_/${blocksize:-64}/g" \
- -e "s/_ccpp_suite_/${ccpp_suite_glob}/g" \
- -e "s/_deflate_level_/${deflate_level:--1}/g" \
- -e "s/_layoutx_/${glob_layoutx}/g" \
- -e "s/_layouty_/${glob_layouty}/g" \
- -e "s/_npx_/${glob_npx}/g" \
- -e "s/_npy_/${glob_npy}/g" \
- -e "s/_npz_/${npz}/g" \
- -e "s/_k_split_/${glob_k_split}/g" \
- -e "s/_n_split_/${glob_n_split}/g" \
- -e "s/_na_init_/${na_init}/g" \
- -e "s/_external_ic_/${external_ic}/g" \
- -e "s/_nggps_ic_/${nggps_ic}/g" \
- -e "s/_mountain_/${mountain}/g" \
- -e "s/_warm_start_/${warm_start}/g" \
- -e "s/_target_lat_/${target_lat}/g" \
- -e "s/_target_lon_/${target_lon}/g" \
- -e "s/_stretch_fac_/${stretch_fac}/g" \
- -e "s/_refinement_/${refine_ratio}/g" \
- -e "s/_ioffset_/${ioffset}/g" \
- -e "s/_joffset_/${joffset}/g" \
- -e "s/_glob_pes_/${glob_pes}/g" \
- -e "s/_nest_pes_/${nest_pes}/g" \
- -e "s/_levp_/${LEVS}/g" \
- -e "s/_fhswr_/${fhswr:-1800.}/g" \
- -e "s/_fhlwr_/${fhlwr:-1800.}/g" \
- -e "s/_nstf_n1_/${nstf_n1:-2}/g" \
- -e "s/_nstf_n2_/${nstf_n2:-0}/g" \
- -e "s/_nstf_n3_/${nstf_n3:-0}/g" \
- -e "s/_nstf_n4_/${nstf_n4:-0}/g" \
- -e "s/_nstf_n5_/${nstf_n5:-0}/g" \
- -e "s/_cplflx_/${cplflx:-.false.}/g" \
- -e "s/_cplocn2atm_/${cplocn2atm}/g" \
- -e "s/_cplwav_/${cplwav:-.false.}/g" \
- -e "s/_cplwav2atm_/${cplwav2atm:-.false.}/g" \
- -e "s/_merge_import_/${merge_import:-.false.}/g" \
- input.nml.tmp > input.nml
-
-blocksize=$(( ${npy}/${layouty} ))
-sed -e "s/_blocksize_/${blocksize:-64}/g" \
- -e "s/_ccpp_suite_/${ccpp_suite_nest}/g" \
- -e "s/_deflate_level_/${deflate_level:--1}/g" \
- -e "s/_layoutx_/${layoutx}/g" \
- -e "s/_layouty_/${layouty}/g" \
- -e "s/_npx_/${npx}/g" \
- -e "s/_npy_/${npy}/g" \
- -e "s/_npz_/${npz}/g" \
- -e "s/_k_split_/${k_split}/g" \
- -e "s/_n_split_/${n_split}/g" \
- -e "s/_na_init_/${na_init}/g" \
- -e "s/_external_ic_/${external_ic}/g" \
- -e "s/_nggps_ic_/${nggps_ic}/g" \
- -e "s/_mountain_/${mountain}/g" \
- -e "s/_warm_start_/${warm_start}/g" \
- -e "s/_target_lat_/${target_lat}/g" \
- -e "s/_target_lon_/${target_lon}/g" \
- -e "s/_stretch_fac_/${stretch_fac}/g" \
- -e "s/_refinement_/${refine_ratio}/g" \
- -e "s/_ioffset_/${ioffset}/g" \
- -e "s/_joffset_/${joffset}/g" \
- -e "s/_glob_pes_/${glob_pes}/g" \
- -e "s/_nest_pes_/${nest_pes}/g" \
- -e "s/_levp_/${LEVS}/g" \
- -e "s/_fhswr_/${fhswr:-1800.}/g" \
- -e "s/_fhlwr_/${fhlwr:-1800.}/g" \
- -e "s/_nstf_n1_/${nstf_n1:-2}/g" \
- -e "s/_nstf_n2_/${nstf_n2:-0}/g" \
- -e "s/_nstf_n3_/${nstf_n3:-0}/g" \
- -e "s/_nstf_n4_/${nstf_n4:-0}/g" \
- -e "s/_nstf_n5_/${nstf_n5:-0}/g" \
- -e "s/_cplflx_/${cplflx:-.false.}/g" \
- -e "s/_cplocn2atm_/${cplocn2atm}/g" \
- -e "s/_cplwav_/${cplwav:-.false.}/g" \
- -e "s/_cplwav2atm_/${cplwav2atm:-.false.}/g" \
- -e "s/_merge_import_/${merge_import:-.false.}/g" \
- input_nest02.nml.tmp > input_nest02.nml
+grid_pes="${glob_pes}"
+tile_coarse="0,${parent_tile}"
+refine="0,${refine_ratio}"
+for n in $(seq 1 ${nest_grids})
+do
+ layoutx_tmp=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_tmp=$( echo ${layouty} | cut -d , -f ${n} )
+ grid_pes="${grid_pes},$(( $layoutx_tmp * $layouty_tmp ))"
+done
+
+ioffset=1
+joffset=1
+for n in $(seq 1 ${nest_grids})
+do
+ inest=$(( ${n} + 1 ))
+ istart_nest_tmp=$( echo ${istart_nest} | cut -d , -f ${n} )
+ jstart_nest_tmp=$( echo ${jstart_nest} | cut -d , -f ${n} )
+ ioffset="$ioffset,$(( ($istart_nest_tmp-1)/2 + 1))"
+ joffset="$joffset,$(( ($jstart_nest_tmp-1)/2 + 1))"
+done
+
+ccpp_suite_nml=${ccpp_suite_glob}
+layoutx_nml=${glob_layoutx}
+layouty_nml=${glob_layouty}
+io_layoutx_nml=${glob_io_layoutx:-$layoutx_nml}
+io_layouty_nml=${glob_io_layouty:-$layouty_nml}
+npx_nml=${glob_npx}
+npy_nml=${glob_npy}
+k_split_nml=${glob_k_split}
+n_split_nml=${glob_n_split}
+full_zs_filter_nml=${glob_full_zs_filter:-.true.}
+n_zs_filter_nml=${glob_n_zs_filter:-1}
+n_del2_weak_nml=${glob_n_del2_weak:-20}
+max_slope_nml=${glob_max_slope:-0.25}
+shal_cnv_nml=${glob_shal_cnv:-.true.}
+do_deep_nml=${glob_do_deep:-.true.}
+
+blocksize=$(( ${npy_nml}/${layouty_nml} ))
+
+atparse < input.nml.tmp > input.nml
+
+for n in $(seq 1 ${nest_grids})
+do
+ inest=$(( ${n} + 1 ))
+ ccpp_suite_nml=${ccpp_suite_nest}
+ layoutx_nml=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_nml=$( echo ${layouty} | cut -d , -f ${n} )
+ io_layoutx_nml=$( echo ${io_layoutx} | cut -d , -f ${n} )
+ io_layouty_nml=$( echo ${io_layouty} | cut -d , -f ${n} )
+ npx_nml=$( echo ${npx} | cut -d , -f ${n} )
+ npy_nml=$( echo ${npy} | cut -d , -f ${n} )
+ k_split_nml=$( echo ${k_split} | cut -d , -f ${n} )
+ n_split_nml=$( echo ${n_split} | cut -d , -f ${n} )
+ full_zs_filter_nml=$( echo ${full_zs_filter} | cut -d , -f ${n} )
+ n_zs_filter_nml=$( echo ${n_zs_filter} | cut -d , -f ${n} )
+ n_del2_weak_nml=$( echo ${n_del2_weak} | cut -d , -f ${n} )
+ max_slope_nml=$( echo ${max_slope} | cut -d , -f ${n} )
+
+ blocksize=$(( ${npy_nml}/${layouty_nml} ))
+ atparse < input_nest.nml.tmp > input_nest0${inest}.nml
+
+done
elif [ $gtype = regional ]; then
+cd INPUT
+
# Prepare tile data and orography for regional
tile=7
# Copy grid and orog files (halo[034])
-${NCP} $FIXgrid/${CASE}/${CASE}_grid.tile${tile}.halo?.nc INPUT/.
-${NCP} $FIXgrid/${CASE}/${CASE}_oro_data.tile${tile}.halo?.nc INPUT/.
-${NCP} $FIXgrid/${CASE}/${CASE}_mosaic.nc INPUT/.
+${NCP} $FIXgrid/${CASE}/${CASE}_grid.tile${tile}.halo?.nc ./
+${NCP} $FIXgrid/${CASE}/${CASE}_oro_data.tile${tile}.halo?.nc ./
+${NCP} $FIXgrid/${CASE}/${CASE}_mosaic.nc ./
-cd INPUT
${NLN} ${CASE}_mosaic.nc grid_spec.nc
${NLN} ${CASE}_grid.tile7.halo0.nc grid.tile7.halo0.nc
${NLN} ${CASE}_grid.tile7.halo3.nc ${CASE}_grid.tile7.nc
@@ -705,21 +780,73 @@ ${NLN} ${CASE}_oro_data.tile7.halo4.nc oro_data.tile7.halo4.nc
${NLN} sfc_data.tile7.nc sfc_data.nc
${NLN} gfs_data.tile7.nc gfs_data.nc
+# regional with nests
+if [ $nest_grids -gt 1 ]; then
+
+ntiles=$((6 + ${nest_grids}))
+for itile in $(seq 8 ${ntiles})
+do
+ ${NCP} $FIXgrid/${CASE}/${CASE}_oro_data.tile${itile}.nc ./oro_data.tile${itile}.nc
+ ${NCP} $FIXgrid/${CASE}/${CASE}_grid.tile${itile}.nc ./${CASE}_grid.tile${itile}.nc
+done
+
+for itile in $(seq 8 ${ntiles})
+do
+ inest=$(($itile - 6))
+ ${NLN} ${CASE}_grid.tile${itile}.nc grid.nest0${inest}.tile${inest}.nc
+ ${NLN} oro_data.tile${itile}.nc oro_data.nest0${inest}.tile${inest}.nc
+ ${NLN} gfs_data.tile${itile}.nc gfs_data.nest0${inest}.tile${inest}.nc
+ ${NLN} sfc_data.tile${itile}.nc sfc_data.nest0${inest}.tile${inest}.nc
+done
+
+fi
+
+# moving nest
+if [[ "${is_moving_nest}" = *".true."* ]] || [[ "${is_moving_nest}" = *".T."* ]] ; then
+ mkdir -p moving_nest
+ cd moving_nest
+ rrtmp=$(echo ${refine_ratio} | rev | cut -d, -f1 | rev)
+ ${NLN} $FIXgrid/${CASE}/${CASE}_grid.tile7.halo0.nc grid.tile1.nc
+ ${NLN} $FIXgrid/${CASE}/${CASE}_oro_data.tile7.halo0.nc oro_data.tile1.nc
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/${CASE_mvnest1res}_grid.tile7.halo0.nc grid.tile1.${rrtmp}x.nc
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/${CASE_mvnest1res}_oro_data.tile7.halo0.nc oro_data.tile1.${rrtmp}x.nc
+ for var in facsf maximum_snow_albedo slope_type snowfree_albedo soil_type substrate_temperature vegetation_greenness vegetation_type; do
+ ${NLN} $FIXgrid/../grid_mvnest1res/${CASE_mvnest1res}/fix_sfc/${CASE_mvnest1res}.${var}.tile7.halo0.nc ${var}.tile1.${rrtmp}x.nc
+ done
+ cd ..
+fi
+
# For warm start from restart files (either before or after analysis)
if [ ${warmstart_from_restart} = yes ]; then
${NLN} ${RESTARTinp}/${YMD}.${hh}0000.coupler.res ./coupler.res
sed -i -e "2s/.*/ ${yr} $(echo ${mn}|sed 's/^0/ /') $(echo ${dy}|sed 's/^0/ /') $(echo ${hh}|sed 's/^0/ /') 0 0 Model start time: year, month, day, hour, minute, second/" ./coupler.res
sed -i -e "3s/.*/ ${yr} $(echo ${mn}|sed 's/^0/ /') $(echo ${dy}|sed 's/^0/ /') $(echo ${hh}|sed 's/^0/ /') 0 0 Current model time: year, month, day, hour, minute, second/" ./coupler.res
- ${NLN} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.nc ./fv_core.res.nc
- ${NLN} ${RESTARTinp}/${PDY}.${cyc}0000.fv_srf_wnd.res.tile1.nc ./fv_srf_wnd.res.tile1.nc
-# ${NLN} ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ./fv_core.res.tile1.nc
-# ${NLN} ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ./fv_tracer.res.tile1.nc
+ ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_core.res.nc ./fv_core.res.nc
+# ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_srf_wnd.res.tile1.nc ./fv_srf_wnd.res.tile1.nc
+# ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_core.res.tile1.nc ./fv_core.res.tile1.nc
+# ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_tracer.res.tile1.nc ./fv_tracer.res.tile1.nc
# Remove the checksum attribute for all restart variables, so that the
# forecast executable will not compare the checksum attribute against the
# checksum calculated from the actual data. This is because the DA/GSI
# currently only update the variable itself but not its checksum attribute.
- ncatted -a checksum,,d,, ${RESTARTinp}/${PDY}.${cyc}0000.fv_core.res.tile1.nc ./fv_core.res.tile1.nc
- ncatted -a checksum,,d,, ${RESTARTinp}/${PDY}.${cyc}0000.fv_tracer.res.tile1.nc ./fv_tracer.res.tile1.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_srf_wnd.res.tile1.nc ./fv_srf_wnd.res.tile1.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_core.res.tile1.nc ./fv_core.res.tile1.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_tracer.res.tile1.nc ./fv_tracer.res.tile1.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.phy_data.nc ./phy_data.nc
+# ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.sfc_data.nc ./sfc_data.nc
+
+ for n in $(seq 2 ${nest_grids}); do
+ ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_core.res.nest$(printf %02d ${n}).nc ./fv_core.res.nest$(printf %02d ${n}).nc
+ # if [ -e ${RESTARTinp}/${YMD}.${hh}0000.fv_BC_ne.res.nest$(printf %02d ${n}).nc ]; then
+ # ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_BC_ne.res.nest$(printf %02d ${n}).nc ./fv_BC_ne.res.nest$(printf %02d ${n}).nc
+ # ${NLN} ${RESTARTinp}/${YMD}.${hh}0000.fv_BC_sw.res.nest$(printf %02d ${n}).nc ./fv_BC_sw.res.nest$(printf %02d ${n}).nc
+ # fi
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_srf_wnd.res.nest$(printf %02d ${n}).tile${n}.nc ./fv_srf_wnd.res.nest$(printf %02d ${n}).tile${n}.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_core.res.nest$(printf %02d ${n}).tile${n}.nc ./fv_core.res.nest$(printf %02d ${n}).tile${n}.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.fv_tracer.res.nest$(printf %02d ${n}).tile${n}.nc ./fv_tracer.res.nest$(printf %02d ${n}).tile${n}.nc
+ ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.phy_data.nest$(printf %02d ${n}).tile${n}.nc ./phy_data.nest$(printf %02d ${n}).tile${n}.nc
+# ncatted -a checksum,,d,, ${RESTARTinp}/${YMD}.${hh}0000.sfc_data.nest$(printf %02d ${n}).tile${n}.nc ./sfc_data.nest$(printf %02d ${n}).tile${n}.nc
+ done
fi
cd ..
@@ -730,6 +857,7 @@ cd ..
${NCP} ${PARMforecast}/diag_table.tmp .
${NCP} ${PARMforecast}/field_table .
${NCP} ${PARMforecast}/input.nml.tmp .
+${NCP} ${PARMforecast}/input_nest.nml.tmp .
${NCP} ${PARMforecast}/model_configure.tmp .
if [ ${run_ocean} = yes ] || [ ${run_wave} = yes ]; then
@@ -759,41 +887,76 @@ fi
-e "s/_merge_import_/${merge_import:-.false.}/g" \
nems.configure.tmp > nems.configure
-blocksize=$(( ${npy}/${layouty} ))
-sed -e "s/_blocksize_/${blocksize:-64}/g" \
- -e "s/_ccpp_suite_/${ccpp_suite_regional}/g" \
- -e "s/_deflate_level_/${deflate_level:--1}/g" \
- -e "s/_layoutx_/${layoutx}/g" \
- -e "s/_layouty_/${layouty}/g" \
- -e "s/_npx_/${npx}/g" \
- -e "s/_npy_/${npy}/g" \
- -e "s/_npz_/${npz}/g" \
- -e "s/_k_split_/${k_split}/g" \
- -e "s/_n_split_/${n_split}/g" \
- -e "s/_na_init_/${na_init}/g" \
- -e "s/_external_ic_/${external_ic}/g" \
- -e "s/_nggps_ic_/${nggps_ic}/g" \
- -e "s/_mountain_/${mountain}/g" \
- -e "s/_warm_start_/${warm_start}/g" \
- -e "s/_target_lat_/${target_lat}/g" \
- -e "s/_target_lon_/${target_lon}/g" \
- -e "s/_stretch_fac_/${stretch_fac}/g" \
- -e "s/_bc_update_interval_/${NBDYHRS}/g" \
- -e "s/_nrows_blend_/${halo_blend}/g" \
- -e "s/_levp_/${LEVS}/g" \
- -e "s/_fhswr_/${fhswr:-1800.}/g" \
- -e "s/_fhlwr_/${fhlwr:-1800.}/g" \
- -e "s/_nstf_n1_/${nstf_n1:-2}/g" \
- -e "s/_nstf_n2_/${nstf_n2:-0}/g" \
- -e "s/_nstf_n3_/${nstf_n3:-0}/g" \
- -e "s/_nstf_n4_/${nstf_n4:-0}/g" \
- -e "s/_nstf_n5_/${nstf_n5:-0}/g" \
- -e "s/_cplflx_/${cplflx:-.false.}/g" \
- -e "s/_cplocn2atm_/${cplocn2atm}/g" \
- -e "s/_cplwav_/${cplwav:-.false.}/g" \
- -e "s/_cplwav2atm_/${cplwav2atm:-.false.}/g" \
- -e "s/_merge_import_/${merge_import:-.false.}/g" \
- input.nml.tmp > input.nml
+ngrids=${nest_grids}
+n=1
+layoutx_tmp=$( echo ${layoutx} | cut -d , -f ${n} )
+layouty_tmp=$( echo ${layouty} | cut -d , -f ${n} )
+grid_pes="$(( $layoutx_tmp * $layouty_tmp ))"
+tile_coarse=0
+refine=0
+ioffset=999
+joffset=999
+
+for n in $(seq 2 ${nest_grids})
+do
+ layoutx_tmp=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_tmp=$( echo ${layouty} | cut -d , -f ${n} )
+ grid_pes="${grid_pes},$(( $layoutx_tmp * $layouty_tmp ))"
+ ptile_tmp=$( echo ${parent_tile} | cut -d , -f ${n} )
+ tile_coarse="${tile_coarse},$(( $ptile_tmp - 6 ))"
+ refine="$refine,$( echo ${refine_ratio} | cut -d , -f ${n} )"
+ istart_nest_tmp=$( echo ${istart_nest} | cut -d , -f ${n} )
+ jstart_nest_tmp=$( echo ${jstart_nest} | cut -d , -f ${n} )
+ ioffset="$ioffset,$(( ($istart_nest_tmp-1)/2 + 1))"
+ joffset="$joffset,$(( ($jstart_nest_tmp-1)/2 + 1))"
+done
+
+n=1
+ccpp_suite_nml=${ccpp_suite_regional}
+layoutx_nml=$( echo ${layoutx} | cut -d , -f ${n} )
+layouty_nml=$( echo ${layouty} | cut -d , -f ${n} )
+io_layoutx_nml=$( echo ${io_layoutx} | cut -d , -f ${n} )
+io_layouty_nml=$( echo ${io_layouty} | cut -d , -f ${n} )
+npx_nml=$( echo ${npx} | cut -d , -f ${n} )
+npy_nml=$( echo ${npy} | cut -d , -f ${n} )
+k_split_nml=$( echo ${k_split} | cut -d , -f ${n} )
+n_split_nml=$( echo ${n_split} | cut -d , -f ${n} )
+full_zs_filter_nml=$( echo ${full_zs_filter} | cut -d , -f ${n} )
+n_zs_filter_nml=$( echo ${n_zs_filter} | cut -d , -f ${n} )
+n_del2_weak_nml=$( echo ${n_del2_weak} | cut -d , -f ${n} )
+max_slope_nml=$( echo ${max_slope} | cut -d , -f ${n} )
+shal_cnv_nml=$( echo ${shal_cnv} | cut -d , -f ${n} )
+do_deep_nml=$( echo ${do_deep} | cut -d , -f ${n} )
+
+bc_update_interval=${NBDYHRS}
+nrows_blend=${halo_blend}
+
+blocksize=$(( ${npy_nml}/${layouty_nml} ))
+atparse < input.nml.tmp > input.nml
+
+for n in $(seq 2 ${nest_grids})
+do
+ inest=$(( ${n} ))
+ ccpp_suite_nml=${ccpp_suite_nest}
+ layoutx_nml=$( echo ${layoutx} | cut -d , -f ${n} )
+ layouty_nml=$( echo ${layouty} | cut -d , -f ${n} )
+ io_layoutx_nml=$( echo ${io_layoutx} | cut -d , -f ${n} )
+ io_layouty_nml=$( echo ${io_layouty} | cut -d , -f ${n} )
+ npx_nml=$( echo ${npx} | cut -d , -f ${n} )
+ npy_nml=$( echo ${npy} | cut -d , -f ${n} )
+ k_split_nml=$( echo ${k_split} | cut -d , -f ${n} )
+ n_split_nml=$( echo ${n_split} | cut -d , -f ${n} )
+ full_zs_filter_nml=$( echo ${full_zs_filter} | cut -d , -f ${n} )
+ n_zs_filter_nml=$( echo ${n_zs_filter} | cut -d , -f ${n} )
+ n_del2_weak_nml=$( echo ${n_del2_weak} | cut -d , -f ${n} )
+ max_slope_nml=$( echo ${max_slope} | cut -d , -f ${n} )
+ shal_cnv_nml=$( echo ${shal_cnv} | cut -d , -f ${n} )
+ do_deep_nml=$( echo ${do_deep} | cut -d , -f ${n} )
+
+ blocksize=$(( ${npy_nml}/${layouty_nml} ))
+ atparse < input_nest.nml.tmp > input_nest0${inest}.nml
+
+done
fi # if regional
@@ -880,51 +1043,36 @@ if [ ${run_wave} = yes ]; then
./ww3_multi.inp_tmpl > ./ww3_multi.inp
fi #if [ ${run_wave} = yes ]; then
-# Pass along the grid_spec.nc, atmos_static.nc, oro_data.nc from the prior cycle if exist
+if [ ${run_init:-no} = no ]; then
+
+# Pass along the grid_spec.nc, atmos_static.nc, oro_data.nc
if [ ${ENSDA} = YES ]; then
- if [ -s ${COMhafsprior}/RESTART_ens/mem${ENSID}/grid_spec.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART_ens/mem${ENSID}/grid_spec.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/grid_spec.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/grid_spec*.nc RESTART/
fi
- if [ -s ${COMhafsprior}/RESTART_ens/mem${ENSID}/atmos_static.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART_ens/mem${ENSID}/atmos_static.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/atmos_static.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/atmos_static*.nc RESTART/
fi
- if [ -s ${COMhafsprior}/RESTART_ens/mem${ENSID}/oro_data.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART_ens/mem${ENSID}/oro_data.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/oro_data.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init_ens/mem${ENSID}/oro_data.n*c RESTART/
fi
else
- if [ -s ${COMhafsprior}/RESTART/grid_spec.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART/grid_spec.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init/grid_spec.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init/grid_spec*.nc RESTART/
fi
- if [ -s ${COMhafsprior}/RESTART/atmos_static.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART/atmos_static.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init/atmos_static.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init/atmos_static*.nc RESTART/
fi
- if [ -s ${COMhafsprior}/RESTART/oro_data.nc ]; then
- ${NCP} -p ${COMhafsprior}/RESTART/oro_data.nc RESTART/
+ if [ -s ${WORKhafs}/intercom/RESTART_init/oro_data.nc ]; then
+ ${NCP} -p ${WORKhafs}/intercom/RESTART_init/oro_data.n*c RESTART/
fi
fi
-fi #if [ $gtype = nest ]; then
-
-# Generate diag_table, model_configure from their tempelates
-yr=$(echo $CDATE | cut -c1-4)
-mn=$(echo $CDATE | cut -c5-6)
-dy=$(echo $CDATE | cut -c7-8)
-cat > temp << EOF
-${yr}${mn}${dy}.${cyc}Z.${CASE}.32bit.non-hydro
-$yr $mn $dy $cyc 0 0
-EOF
-
-enddate=`${NDATE} +${NHRS} $CDATE`
-endyr=`echo $enddate | cut -c1-4`
-
-if [ ${run_datm} = no ]; then
-cat temp diag_table.tmp > diag_table
fi
-#---------------------------------------------------
-# Copy CDEPS input, parm, and fix files if required.
-#---------------------------------------------------
+fi #if [ $gtype = nest ]; then
+# Copy CDEPS input, parm, and fix files if required.
if [ ${run_datm} = yes ]; then
datm_source=${DATM_SOURCE:-ERA5}
${NCP} ${PARMforecast}/model_configure.tmp .
@@ -938,6 +1086,7 @@ if [ ${run_datm} = yes ]; then
sed -i "/^stream_data_files01:/ s/$/\ \"INPUT\/$(basename $file)\"/" datm.streams
fi
done
+ endyr=$(${NDATE} +${NHRS} $CDATE | cut -c1-4)
sed -i "s/_yearFirst_/$yr/g" datm.streams
sed -i "s/_yearLast_/$endyr/g" datm.streams
sed -i "s/_mesh_atm_/INPUT\/DATM_ESMF_mesh.nc/g" datm.streams
@@ -963,6 +1112,7 @@ if [ ${run_datm} = yes ]; then
nems.configure.cdeps.tmp > nems.configure
elif [ ${run_docn} = yes ]; then
+
MAKE_MESH_OCN=$( echo "${make_mesh_ocn:-no}" | tr a-z A-Z )
${NLN} "$docn_input_path"/DOCN_input*nc INPUT/
@@ -979,6 +1129,7 @@ elif [ ${run_docn} = yes ]; then
# Generate docn.streams from template specific to the model:
${NCP} ${PARMhafs}/cdeps/docn_$( echo "$docn_source" | tr A-Z a-z ).streams docn.streams
+ endyr=$(${NDATE} +${NHRS} $CDATE | cut -c1-4)
sed -i "s/_yearFirst_/$yr/g" docn.streams
sed -i "s/_yearLast_/$endyr/g" docn.streams
sed -i "s/_mesh_ocn_/INPUT\/DOCN_ESMF_mesh.nc/g" docn.streams
@@ -1008,27 +1159,96 @@ elif [ ${run_docn} = yes ]; then
fi
-sed -e "s/_print_esmf_/${print_esmf:-.false.}/g" \
- -e "s/YR/$yr/g" -e "s/MN/$mn/g" -e "s/DY/$dy/g" \
- -e "s/H_R/$cyc/g" -e "s/NHRS/$NHRS/g" \
- -e "s/_dt_atmos_/${dt_atmos}/g" \
- -e "s/_restart_interval_/${restart_interval}/g" \
- -e "s/_quilting_/${quilting}/g" \
- -e "s/_write_groups_/${write_groups}/g" \
- -e "s/_write_tasks_per_group_/${write_tasks_per_group}/g" \
- -e "s/_write_dopost_/${write_dopost:-.false.}/g" \
- -e "s/_output_history_/${output_history:-.true.}/g" \
- -e "s/_app_domain_/${app_domain}/g" \
- -e "s/_OUTPUT_GRID_/$output_grid/g" \
- -e "s/_CEN_LON_/$output_grid_cen_lon/g" \
- -e "s/_CEN_LAT_/$output_grid_cen_lat/g" \
- -e "s/_LON1_/$output_grid_lon1/g" \
- -e "s/_LAT1_/$output_grid_lat1/g" \
- -e "s/_LON2_/$output_grid_lon2/g" \
- -e "s/_LAT2_/$output_grid_lat2/g" \
- -e "s/_DLON_/$output_grid_dlon/g" \
- -e "s/_DLAT_/$output_grid_dlat/g" \
- model_configure.tmp > model_configure
+# Generate model_configure
+SYEAR=${yr} SMONTH=${mn} SDAY=${dy} SHOUR=${hh}
+FHMAX=${NHRS} DT_ATMOS=${dt_atmos}
+RESTART_INTERVAL=${restart_interval}
+QUILTING=${quilting} WRITE_GROUP=${write_groups} WRTTASK_PER_GROUP=${write_tasks_per_group}
+WRITE_DOPOST=${write_dopost:-.false.} OUTPUT_HISTORY=${output_history:-.true.}
+NUM_FILES=2 FILENAME_BASE="'atm' 'sfc'" OUTPUT_FILE="'netcdf' 'netcdf'"
+IDEFLATE=1 NBITS=0
+NFHOUT=3 NFHMAX_HF=-1 NFHOUT_HF=3 NSOUT=-1 OUTPUT_FH=-1
+
+if [ $gtype = regional ]; then
+ ngrids=${nest_grids}
+elif [ $gtype = nest ]; then
+ ngrids=$(( ${nest_grids} + 1 ))
+else
+ echo "FATAL ERROR: Unsupported gtype of ${gtype}. Currently onnly support gtype of nest or regional."
+ exit 9
+fi
+
+for n in $(seq 1 ${ngrids})
+do
+ if [ $n -eq 1 ]; then
+ nstr=""
+ else
+ nstr="_${n}"
+ fi
+ outputgrid=$(echo ${output_grid} | cut -d , -f ${n})
+ clon=$(echo ${output_grid_cen_lon} | cut -d , -f ${n})
+ clat=$(echo ${output_grid_cen_lat} | cut -d , -f ${n})
+ if [[ "$outputgrid" = "rotated_latlon"* ]]; then
+ clontmp=0.0
+ clattmp=0.0
+ else
+ clontmp=${clon}
+ clattmp=${clat}
+ fi
+ lon_span=$(echo ${output_grid_lon_span} | cut -d , -f ${n})
+ lat_span=$(echo ${output_grid_lat_span} | cut -d , -f ${n})
+ dlon=$(echo ${output_grid_dlon} | cut -d , -f ${n})
+ dlat=$(echo ${output_grid_dlat} | cut -d , -f ${n})
+ lon1=$( printf "%.6f" $(bc <<< "scale=6; ${clontmp}-${lon_span}/2.0") )
+ lat1=$( printf "%.6f" $(bc <<< "scale=6; ${clattmp}-${lat_span}/2.0") )
+ lon2=$( printf "%.6f" $(bc <<< "scale=6; ${clontmp}+${lon_span}/2.0") )
+ lat2=$( printf "%.6f" $(bc <<< "scale=6; ${clattmp}+${lat_span}/2.0") )
+ imo=$( printf "%.0f" $(bc <<< "scale=6; ${lon_span}/${dlon} + 1") )
+ jmo=$( printf "%.0f" $(bc <<< "scale=6; ${lat_span}/${dlat} + 1") )
+ eval OUTPUT_GRID${nstr}=${outputgrid}
+ eval CEN_LON${nstr}=${clon}
+ eval CEN_LAT${nstr}=${clat}
+ eval LON1${nstr}=${lon1}
+ eval LAT1${nstr}=${lat1}
+ eval LON2${nstr}=${lon2}
+ eval LAT2${nstr}=${lat2}
+ eval DLON${nstr}=${dlon}
+ eval DLAT${nstr}=${dlat}
+ eval IMO${nstr}=${imo}
+ eval JMO${nstr}=${jmo}
+ eval STDLAT1${nstr}=$(echo ${output_grid_stdlat1:-""} | cut -d , -f ${n})
+ eval STDLAT2${nstr}=$(echo ${output_grid_stdlat2:-""} | cut -d , -f ${n})
+ eval NX${nstr}=$(echo ${output_grid_nx:-""} | cut -d , -f ${n})
+ eval NY${nstr}=$(echo ${output_grid_ny:-""} | cut -d , -f ${n})
+ eval DX${nstr}=$(echo ${output_grid_dx:-""} | cut -d , -f ${n})
+ eval DY${nstr}=$(echo ${output_grid_dy:-""} | cut -d , -f ${n})
+done
+
+for n in $(seq $((${ngrids}+1)) 6)
+do
+ nstr=$(printf "_%0.2d" $n)
+ sed -i -e "//,/<\/output_grid${nstr}>/d" model_configure.tmp
+done
+
+atparse < model_configure.tmp > model_configure
+
+# Generate diag_table
+if [ ${run_init:-no} = yes ]; then
+ GRID_MSPEC_INT=-1
+ ATMOS_DIAG_INT=-1
+else
+ GRID_MSPEC_INT=${GRID_MSPEC_INT:-3}
+ ATMOS_DIAG_INT=${ATMOS_DIAG_INT:-3}
+fi
+if [ ${run_datm} = no ]; then
+ atparse < diag_table.tmp > diag_table
+fi
+# Remove the grid_mspec lines if it is not a moving nesting configuration
+if [[ "${is_moving_nest:-".false."}" = *".true."* ]] || [[ "${is_moving_nest:-".false."}" = *".T."* ]] ; then
+ echo "This is a moving nesting configuration"
+else
+ sed -i -e "/grid_mspec/d" diag_table
+fi
# Copy fix files needed by inline_post
if [ ${write_dopost:-.false.} = .true. ]; then
@@ -1067,38 +1287,33 @@ ${NCP} ${HOMEhafs}/sorc/hafs_forecast.fd/tests/parm/fd_nems.yaml ./
# Copy the executable and run the forecast
FORECASTEXEC=${FORECASTEXEC:-${EXEChafs}/hafs_forecast.x}
${NCP} -p ${FORECASTEXEC} ./hafs_forecast.x
-${APRUNC} ./hafs_forecast.x 1>out.forecast 2>err.forecast
-
-# Cat out and err into job log
-cat ./out.forecast
-cat ./err.forecast
+#${APRUNC} ./hafs_forecast.x 1>forecast.out 2>forecast.err
+set -o pipefail
+${APRUNC} ./hafs_forecast.x 2>&1 | tee forecast.log
+set +o pipefail
if [ $gtype = regional ] && [ ${run_datm} = no ]; then
# Rename the restart files with a proper convention if needed
cd RESTART
-CDATEnhrs=`${NDATE} +${NHRS} $CDATE`
-PDYnhrs=`echo ${CDATEnhrs} | cut -c1-8`
-cycnhrs=`echo ${CDATEnhrs} | cut -c9-10`
+NHRStmp=$(printf "%.0f" ${NHRS})
+CDATEnhrs=`${NDATE} ${NHRStmp} $CDATE`
+YMDnhrs=`echo ${CDATEnhrs} | cut -c1-8`
+yrnhrs=$(echo $CDATEnhrs | cut -c1-4)
+mnnhrs=$(echo $CDATEnhrs | cut -c5-6)
+dynhrs=$(echo $CDATEnhrs | cut -c7-8)
+hhnhrs=$(echo ${CDATEnhrs} | cut -c9-10)
if [ -s fv_core.res.nc ]; then
- for file in $(/bin/ls -1 fv*.nc phy_data.nc sfc_data.nc coupler.res)
+ for file in $(/bin/ls -1 fv*.nc* phy_data*.nc* sfc_data*.nc* coupler.res)
do
- mv ${file} ${PDYnhrs}.${cycnhrs}0000.${file}
+ mv ${file} ${YMDnhrs}.${hhnhrs}0000.${file}
done
+ if [ ${run_init:-no} = yes ]; then
+ sed -i -e "3s/.*/ ${yrnhrs} $(echo ${mnnhrs}|sed 's/^0/ /') $(echo ${dynhrs}|sed 's/^0/ /') $(echo ${hhnhrs}|sed 's/^0/ /') 0 0 Current model time: year, month, day, hour, minute, second/" ${YMDnhrs}.${hhnhrs}0000.coupler.res
+ fi
fi
cd ${DATA}
-# Pass over the grid_spec.nc, atmos_static.nc, oro_data.nc if not yet exist
-if [ ! -s RESTART/grid_spec.nc ]; then
- ${NCP} -p grid_spec.nc RESTART/
-fi
-if [ ! -s RESTART/atmos_static.nc ]; then
- ${NCP} -p atmos_static.nc RESTART/
-fi
-if [ ! -s RESTART/oro_data.nc ]; then
- ${NCP} -pL INPUT/oro_data.nc RESTART/
-fi
-
fi # if [ $gtype = regional ] && [ ${run_datm} = no ]; then
exit
diff --git a/scripts/exhafs_hrdgraphics.sh b/scripts/exhafs_hrdgraphics.sh
index 73a48dc1c..e61cb5e70 100755
--- a/scripts/exhafs_hrdgraphics.sh
+++ b/scripts/exhafs_hrdgraphics.sh
@@ -28,9 +28,6 @@ COMhafs=${COMhafs:-/gpfs/hps3/ptmp/${USER}/${SUBEXPT}/com/${CDATE}/${STORMID}}
SENDCOM=${SENDCOM:-YES}
CDNOSCRUB="${CDNOSCRUB}"
-output_grid=${output_grid:-rotated_latlon}
-synop_gridspecs=${synop_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
-trker_gridspecs=${trker_gridspecs:-"latlon 246.6:4112:0.025 -2.4:1976:0.025"}
out_prefix=${out_prefix:-$(echo "${STORM}${STORMID}.${YMDH}" | tr '[A-Z]' '[a-z]')}
# GPLOT-specific variables (might go elsewhere)
diff --git a/scripts/exhafs_merge.sh b/scripts/exhafs_merge.sh
new file mode 100755
index 000000000..69f61690d
--- /dev/null
+++ b/scripts/exhafs_merge.sh
@@ -0,0 +1,240 @@
+#!/bin/sh
+
+set -xe
+
+FGAT_MODEL=${FGAT_MODEL:-gfs}
+FGAT_HR=${FGAT_HR:-00}
+
+export merge_method=${merge_method:-vortexreplace}
+export RESTARTsrc=${RESTARTsrc:-"${COMhafs}/RESTART_analysis"}
+export RESTARTdst=${RESTARTdst:-"${COMhafs}/RESTART_init"}
+export RESTARTmrg=${RESTARTmrg:-"${COMhafs}/RESTART_analysis_merge"}
+
+TOTAL_TASKS=${TOTAL_TASKS:-2016}
+NCTSK=${NCTSK:-12}
+NCNODE=${NCNODE:-24}
+OMP_NUM_THREADS=${OMP_NUM_THREADS:-2}
+APRUNC=${APRUNC:-"aprun -b -j1 -n${TOTAL_TASKS} -N${NCTSK} -d${OMP_NUM_THREADS} -cc depth"}
+if [ ${machine} = "wcoss_cray" ]; then
+ APRUNS=${APRUNS}
+else
+ APRUNS=time
+fi
+
+# Utilities
+NDATE=${NDATE:-ndate}
+export NCP=${NCP:-"/bin/cp"}
+export NMV=${NMV:-"/bin/mv"}
+export NLN=${NLN:-"/bin/ln -sf"}
+export MPISERIAL=${MPISERIAL:-${EXEChafs}/hafs_mpiserial.x}
+export DATOOL=${DATOOL:-${EXEChafs}/hafs_datool.x}
+
+PDY=`echo $CDATE | cut -c1-8`
+cyc=`echo $CDATE | cut -c9-10`
+yr=`echo $CDATE | cut -c1-4`
+mn=`echo $CDATE | cut -c5-6`
+dy=`echo $CDATE | cut -c7-8`
+hh=`echo $CDATE | cut -c9-10`
+
+cd ${DATA}
+
+mkdir -p ${RESTARTmrg}
+${NCP} -rp ${RESTARTdst}/* ${RESTARTmrg}/
+
+if [ -d ${RESTARTsrc} ] || [ -L ${RESTARTsrc} ] ; then
+
+if [ ${FGAT_HR} = 03 ]; then
+ tcvital=${WORKhafs}/tm03vit
+elif [ ${FGAT_HR} = 06 ]; then
+ tcvital=${WORKhafs}/tmpvit
+elif [ ${FGAT_HR} = 09 ]; then
+ tcvital=${WORKhafs}/tp03vit
+else
+ tcvital=${WORKhafs}/tmpvit
+fi
+if [ ${merge_method} = vortexreplace ]; then
+ MERGE_CMD="${DATOOL} vortexreplace --tcvital=${tcvital} --infile_date=${PDY}.${cyc}0000 --vortexradius=650:700"
+elif [ ${merge_method} = domainmerge ]; then
+ MERGE_CMD="${DATOOL} remap"
+else
+ echo "Error: unsupported merge_method: ${merge_method}"
+ exit 1
+fi
+
+# Regional single domain configuration
+if [[ $nest_grids -eq 1 ]]; then
+
+rm -f cmdfile_datool_merge
+#for var in fv_core.res.tile1 fv_tracer.res.tile1 fv_srf_wnd.res.tile1 sfc_data phy_data;
+for var in fv_core.res.tile1 fv_tracer.res.tile1 fv_srf_wnd.res.tile1 sfc_data;
+do
+ in_grid=${RESTARTsrc}/grid_spec.nc
+ out_grid=${RESTARTmrg}/grid_spec.nc
+ in_file=${RESTARTsrc}/${PDY}.${cyc}0000.${var}.nc
+ out_file=${RESTARTmrg}/${PDY}.${cyc}0000.${var}.nc
+ cat >> cmdfile_datool_merge << EOF
+ ${APRUNS} ${MERGE_CMD} \
+ --in_grid=${in_grid} \
+ --out_grid=${out_grid} \
+ --in_file=${in_file} \
+ --out_file=${out_file} \
+ > datool.${var}.log
+EOF
+done
+chmod +x cmdfile_datool_merge
+if [ ${machine} = "wcoss_cray" ]; then
+ time ./cmdfile_datool_merge
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_datool_merge
+fi
+cat datool.*.log
+
+# Regional with one nest configuration
+# The following steps are needed
+# Step 1: merge srcd01 into dstd02 (for atm_merge) or merge srcd02 into srcd01 (for analysis_merge)
+# Step 2: merge srcd01 into dstd01
+# Step 3: merge srcd02 into dstd02
+elif [[ $nest_grids -eq 2 ]]; then
+
+RESTARTtmp=${DATA}/RESTARTtmp
+mkdir -p ${RESTARTtmp}
+
+if [ ${MERGE_TYPE} = analysis ]; then
+
+# Step 1: merge src02 into src01 (for analysis_merge)
+${NCP} -rp ${RESTARTsrc}/* ${RESTARTtmp}/
+rm -f cmdfile_datool_merge.step1
+for var in fv_core.res fv_tracer.res fv_srf_wnd.res sfc_data;
+do
+ in_grid=${RESTARTtmp}/grid_mspec.nest02_${yr}_${mn}_${dy}_${hh}.tile2.nc
+ out_grid=${RESTARTtmp}/grid_mspec_${yr}_${mn}_${dy}_${hh}.nc
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.nest02.tile2.nc
+ if [[ $var = sfc_data ]]; then
+ out_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.nc
+ else
+ out_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.tile1.nc
+ fi
+ cat >> cmdfile_datool_merge.step1 << EOF
+ ${APRUNS} ${MERGE_CMD} \
+ --in_grid=${in_grid} \
+ --out_grid=${out_grid} \
+ --in_file=${in_file} \
+ --out_file=${out_file} \
+ > datool.${var}.step1.log
+EOF
+done
+chmod +x cmdfile_datool_merge.step1
+if [ ${machine} = "wcoss_cray" ]; then
+ time ./cmdfile_datool_merge.step1
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_datool_merge.step1
+fi
+cat datool.*.step1.log
+
+elif [ ${MERGE_TYPE} = init ]; then
+
+# Step 1: merge srcd02 into srcd01 (for atm_merge)
+${NLN} ${RESTARTsrc}/* ${RESTARTtmp}/
+rm -f cmdfile_datool_merge.step1
+for var in fv_core.res fv_tracer.res fv_srf_wnd.res sfc_data;
+do
+ in_grid=${RESTARTtmp}/grid_mspec_${yr}_${mn}_${dy}_${hh}.nc
+ out_grid=${RESTARTmrg}/grid_mspec.nest02_${yr}_${mn}_${dy}_${hh}.tile2.nc
+ if [[ $var = sfc_data ]]; then
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.nc
+ else
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.tile1.nc
+ fi
+ out_file=${RESTARTmrg}/${PDY}.${cyc}0000.${var}.nest02.tile2.nc
+ cat >> cmdfile_datool_merge.step1 << EOF
+ ${APRUNS} ${MERGE_CMD} \
+ --in_grid=${in_grid} \
+ --out_grid=${out_grid} \
+ --in_file=${in_file} \
+ --out_file=${out_file} \
+ > datool.${var}.step1.log
+EOF
+done
+chmod +x cmdfile_datool_merge.step1
+if [ ${machine} = "wcoss_cray" ]; then
+ time ./cmdfile_datool_merge.step1
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_datool_merge.step1
+fi
+cat datool.*.step1.log
+
+else
+ echo "Error unsupported MERGE_TYPE: ${MERGE_TYPE}"
+ exit 1
+fi
+
+# Step 2: merge srcd01 into dstd01
+rm -f cmdfile_datool_merge.step2
+for var in fv_core.res fv_tracer.res fv_srf_wnd.res sfc_data;
+do
+ in_grid=${RESTARTtmp}/grid_mspec_${yr}_${mn}_${dy}_${hh}.nc
+ out_grid=${RESTARTmrg}/grid_mspec_${yr}_${mn}_${dy}_${hh}.nc
+ if [[ $var = sfc_data ]]; then
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.nc
+ out_file=${RESTARTmrg}/${PDY}.${cyc}0000.${var}.nc
+ else
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.tile1.nc
+ out_file=${RESTARTmrg}/${PDY}.${cyc}0000.${var}.tile1.nc
+ fi
+ cat >> cmdfile_datool_merge.step2 << EOF
+ ${APRUNS} ${MERGE_CMD} \
+ --in_grid=${in_grid} \
+ --out_grid=${out_grid} \
+ --in_file=${in_file} \
+ --out_file=${out_file} \
+ > datool.${var}.step2.log
+EOF
+done
+chmod +x cmdfile_datool_merge.step2
+if [ ${machine} = "wcoss_cray" ]; then
+ time ./cmdfile_datool_merge.step2
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_datool_merge.step2
+fi
+cat datool.*.step2.log
+
+# Step 3: merge srcd02 into dstd02
+rm -f cmdfile_datool_merge.step3
+for var in fv_core.res fv_tracer.res fv_srf_wnd.res sfc_data;
+do
+ in_grid=${RESTARTtmp}/grid_mspec.nest02_${yr}_${mn}_${dy}_${hh}.tile2.nc
+ out_grid=${RESTARTmrg}/grid_mspec.nest02_${yr}_${mn}_${dy}_${hh}.tile2.nc
+ in_file=${RESTARTtmp}/${PDY}.${cyc}0000.${var}.nest02.tile2.nc
+ out_file=${RESTARTmrg}/${PDY}.${cyc}0000.${var}.nest02.tile2.nc
+ cat >> cmdfile_datool_merge.step3 << EOF
+ ${APRUNS} ${MERGE_CMD} \
+ --in_grid=${in_grid} \
+ --out_grid=${out_grid} \
+ --in_file=${in_file} \
+ --out_file=${out_file} \
+ > datool.${var}.step3.log
+EOF
+done
+chmod +x cmdfile_datool_merge.step3
+if [ ${machine} = "wcoss_cray" ]; then
+ time ./cmdfile_datool_merge.step3
+else
+ ${APRUNC} ${MPISERIAL} -m cmdfile_datool_merge.step3
+fi
+cat datool.*.step3.log
+
+else
+ echo "Error: only support nest_grids = 1 or 2"
+ echo "Error: nest_grids = $nest_grids"
+ echo "Error: exiting"
+ exit 1
+fi
+
+else
+
+echo "RESTARTsrc: ${RESTARTsrc} does not exist"
+echo "RESTARTmrg is the same as RESTARTdst"
+
+fi
+
+exit
diff --git a/scripts/exhafs_obs_proc.sh b/scripts/exhafs_obs_proc.sh
index 816d6f267..f950f52fa 100755
--- a/scripts/exhafs_obs_proc.sh
+++ b/scripts/exhafs_obs_proc.sh
@@ -78,7 +78,9 @@ ${NLN} -sf ./prepbufr.qm_typ ./fort.51
# Link and run the executable
${NCP} -p ${EXEChafs}/hafs_change_prepbufr_qm_typ.x ./hafs_change_prepbufr_qm_typ.x
-${APRUNS} ./hafs_change_prepbufr_qm_typ.x > ./hafs_change_prepbufr_qm_typ.out 2>&1
+set -o pipefail
+${APRUNS} ./hafs_change_prepbufr_qm_typ.x 2>&1 | tee ./hafs_change_prepbufr_qm_typ.out
+set +o pipefail
# Deliver to com
if [ $SENDCOM = YES ]; then
@@ -120,17 +122,19 @@ sed -e "s/_analdate_/${analdate}/g" \
# Link and run the executable
OBSPREPROCEXEC=${OBSPREPROCEXEC:-${EXEChafs}/hafs_obs_preproc.x}
${NCP} -p ${OBSPREPROCEXEC} ./hafs_obs_preproc.x
-${APRUNS} ./hafs_obs_preproc.x 1> ./hafs_obs_preproc.out 2>&1
+set -o pipefail
+${APRUNS} ./hafs_obs_preproc.x 2>&1 | tee ./hafs_obs_preproc.out
+set +o pipefail
# Deliver to com
if [ $SENDCOM = YES ]; then
mkdir -p ${COMhafs}
- ${NCP} -p ./tempdrop.prepbufr ${COMhafs}/${out_prefix}.tempdrop.prepbufr
+ ${NCP} -p ./tempdrop.prepbufr ${COMhafs}/${out_prefix}.hafs.tempdrop.prepbufr
fi
# Deliver to intercom
mkdir -p ${intercom}
-${NCP} -p ./tempdrop.prepbufr ${intercom}/tempdrop.prepbufr
+${NCP} -p ./tempdrop.prepbufr ${intercom}/hafs.tempdrop.prepbufr
fi # end if [ -s ./tempdrop.filelist ]; then
diff --git a/scripts/exhafs_product.sh b/scripts/exhafs_product.sh
index d0ce9f052..daa5b8514 100755
--- a/scripts/exhafs_product.sh
+++ b/scripts/exhafs_product.sh
@@ -20,6 +20,20 @@ else
export LEVS=${LEVS:-65}
fi
+out_prefix=${out_prefix:-$(echo "${STORM}${STORMID}.${CDATE}" | tr '[A-Z]' '[a-z]')}
+
+neststr=${neststr:-""} #".nest02"
+tilestr=${tilestr:-".tile1"} #".tile2"
+gridstr=${gridstr:-".grid01"} #".grid02"
+
+trk_atcfunix=${out_prefix}.hafs.trak.atcfunix
+all_atcfunix=${out_prefix}.hafs.trak.atcfunix.all
+fhr_atcfunix=${STORMID,,}.${CDATE}.hafs.trak.atcfunix.f
+
+trk_atcfunix_grid=${out_prefix}.hafs${gridstr}.trak.atcfunix
+all_atcfunix_grid=${out_prefix}.hafs${gridstr}.trak.atcfunix.all
+fhr_atcfunix_grid=${STORMID,,}.${CDATE}.hafs${gridstr}.trak.atcfunix.f
+
TOTAL_TASKS=${TOTAL_TASKS:-1}
NCTSK=${NCTSK:-1}
NCNODE=${NCNODE:-24}
@@ -47,19 +61,15 @@ COMhafs=${COMhafs:-/gpfs/hps3/ptmp/${USER}/${SUBEXPT}/com/${CDATE}/${STORMID}}
COMOUTproduct=${COMOUTproduct:-${COMhafs}}
-out_prefix=${out_prefix:-$(echo "${STORM}${STORMID}.${YMDH}" | tr '[A-Z]' '[a-z]')}
-trk_atcfunix=${out_prefix}.trak.hafs.atcfunix
-all_atcfunix=${out_prefix}.trak.hafs.atcfunix.all
-
tmp_vital=${WORKhafs}/tmpvit
old_vital=${WORKhafs}/oldvit
#===============================================================================
-# Run GFDL vortextracker
+# Run GFDL vortextracker
# *** Currently, the tave step is skipped (same as HMON). Need add it and make it the same as HWRF.
# *** Need add the capability of TC genesis tracking.
-DATA_tracker=${DATA}/tracker
+DATA_tracker=${DATA}/tracker${neststr}
mkdir -p ${DATA_tracker}
cd ${DATA_tracker}
@@ -78,13 +88,15 @@ FHR=0
FHR3=$( printf "%03d" "$FHR" )
while [ $FHR -le $NHRS ]
do
- echo "FHR3="${FHR3}
- FMIN=$(( ${FHR} * 60 ))
+ echo "FHR3="${FHR3}
+ FMIN=$(( ${FHR} * 60 ))
minstr=$( printf "%5.5d" "$FMIN" )
- hafstrk_grb2file=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}
- hafstrk_grb2indx=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}.ix
- ln -sf ${INPdir}/${hafstrk_grb2file} .
- ln -sf ${INPdir}/${hafstrk_grb2indx} .
+ trk_grb2file=${out_prefix}.hafs${gridstr}.trk.f${FHR3}.grb2
+ trk_grb2indx=${out_prefix}.hafs${gridstr}.trk.f${FHR3}.grb2.ix
+ tracker_grb2file=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}
+ tracker_grb2indx=${gmodname}.${rundescr}.${atcfdescr}.${CDATE}.f${minstr}.ix
+ ln -sf ${INPdir}/${trk_grb2file} ./${tracker_grb2file}
+ ln -sf ${INPdir}/${trk_grb2indx} ./${tracker_grb2indx}
IFHR=`expr $IFHR + 1`
LINE=$( printf "%4d %5d" "$IFHR" "$FMIN" )
echo "$LINE" >> input.fcst_minutes
@@ -95,16 +107,20 @@ done
rm -f fort.*
# Find and sort active storms for this cycle from known tcvitals file
-# This can potentially provide multiple tcvital messages to the tracker,
+# This can potentially provide multiple tcvital messages to the tracker,
# so that it can track multiple storms simultaneously.
# *** Currently, tcutil_multistorm_sort.py searches the tcvitals files
# specified in the script. Need to modify it to be able to deal with storm
# message files/dirs, as well as passing in tcvitals files.
-${USHhafs}/tcutil_multistorm_sort.py ${CDATE} | cut -c1-96 > allvit
+${USHhafs}/tcutil_multistorm_sort.py ${YMDH} | cut -c1-95 > allvit
# Prepare the input/output files
-cat ${tmp_vital} allvit > input.vitals
-#cat ${tmp_vital} > input.vitals
+rm -f input.vitals
+vitmsg=$(cat ${tmp_vital} | cut -c1-95)
+echo "${vitmsg}" > input.vitals
+if grep -v "${vitmsg}" allvit ; then
+ grep -v "${vitmsg}" allvit >> input.vitals
+fi
cp input.vitals tcvit_rsmc_storms.txt
ln -sf input.vitals fort.12
@@ -125,9 +141,36 @@ ln -sf output.fractwind fort.73
ln -sf output.ike fort.74
ln -sf output.pdfwind fort.76
-# The product atcf track file
-touch ${COMOUTproduct}/${all_atcfunix}
-ln -sf ${COMOUTproduct}/${all_atcfunix} output.atcfunix
+# Prepare ./deliver.sh, which will used in gettrk.x to deliver the atcfunix
+# track file to COMhafs as soon as it becomes available. It also delivers
+# atcfunix before forecast hour 12 into COMhafs for storm cycling.
+if [ "${tilestr}" = ".tile${nest_grids}" ]; then
+
+cat > ./deliver.sh< ./deliver.sh< namelist.gettrk
-
+sleep 3
# Run the vortex tracker gettrk.x
cp -p ${GETTRKEXEC} ./hafs_gettrk.x
#ln -sf ${GETTRKEXEC} ./hafs_gettrk.x
-${APRUNC} ./hafs_gettrk.x < namelist.gettrk
+set +e
+set -o pipefail
+time ./hafs_gettrk.x < namelist.gettrk 2>&1 | tee ./hafs_gettrk.out
+set +o pipefail
+set -e
+
+if grep "PROGRAM GETTRK HAS ENDED" ./hafs_gettrk.out ; then
+ echo "INFO: exhafs_product has run the vortex tracker successfully"
+else
+ echo "ERROR: exhafs_product failed running vortex tracker"
+ echo "ERROR: exitting..."
+ exit 1
+fi
# Extract the tracking records for tmpvit
STORMNUM=$(echo ${STORMID} | cut -c1-2)
STORMBS1=$(echo ${STORMID} | cut -c3)
-cp ${COMOUTproduct}/${all_atcfunix} ${COMOUTproduct}/${all_atcfunix}.orig
-if [ $STORMNUM == "00" ] ; then
-norig=`cat ${COMOUTproduct}/${all_atcfunix}.orig |wc -l `
-if [ $norig -eq 1 ] ; then
-> ${COMOUTproduct}/${all_atcfunix}
+cp ${COMOUTproduct}/${all_atcfunix_grid} ${COMOUTproduct}/${all_atcfunix_grid}.orig
+if [ -s ${COMOUTproduct}/${all_atcfunix_grid}.orig ]; then
+ if [ $STORMNUM == "00" ] ; then
+ if grep -v "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix_grid}.orig ; then
+ grep -v "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix_grid}.orig > ${COMOUTproduct}/${all_atcfunix_grid}
+ else
+ echo -n > ${COMOUTproduct}/${all_atcfunix_grid}
+ fi
+ else
+ grep "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix_grid} | grep -E "^${STORMBS1}.,|^.${STORMBS1}," > ${COMOUTproduct}/${trk_atcfunix_grid}
+ fi
else
-grep -v "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix}.orig > ${COMOUTproduct}/${all_atcfunix}
-fi
-else
-grep "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix} | grep -E "^${STORMBS1}.,|^.${STORMBS1}," > ${COMOUTproduct}/${trk_atcfunix}
+ if [ $STORMNUM == "00" ] ; then
+ echo -n > ${COMOUTproduct}/${all_atcfunix_grid}
+ else
+ echo -n > ${COMOUTproduct}/${trk_atcfunix_grid}
+ fi
fi
-if [ ${ENSDA} != YES ]; then
+if [ "${tilestr}" = ".tile${nest_grids}" ]; then
-# Deliver track file to NOSCRUB:
-mkdir -p ${CDNOSCRUB}/${SUBEXPT}
-cp -p ${COMhafs}/${all_atcfunix}.orig ${CDNOSCRUB}/${SUBEXPT}/.
-if [ -s ${COMhafs}/${all_atcfunix} ] ; then
-cp -p ${COMhafs}/${all_atcfunix} ${CDNOSCRUB}/${SUBEXPT}/.
+cp ${COMOUTproduct}/${all_atcfunix} ${COMOUTproduct}/${all_atcfunix}.orig
+if [ -s ${COMOUTproduct}/${all_atcfunix}.orig ]; then
+ if [ $STORMNUM == "00" ] ; then
+ if grep -v "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix}.orig ; then
+ grep -v "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix}.orig > ${COMOUTproduct}/${all_atcfunix}
+ else
+ echo -n > ${COMOUTproduct}/${all_atcfunix}
+ fi
+ else
+ grep "^.., ${STORMNUM}," ${COMOUTproduct}/${all_atcfunix} | grep -E "^${STORMBS1}.,|^.${STORMBS1}," > ${COMOUTproduct}/${trk_atcfunix}
+ fi
+else
+ if [ $STORMNUM == "00" ] ; then
+ echo -n > ${COMOUTproduct}/${all_atcfunix}
+ else
+ echo -n > ${COMOUTproduct}/${trk_atcfunix}
+ fi
fi
-if [ -s ${COMhafs}/${trk_atcfunix} ] && [ $STORMNUM != "00" ] ; then
-cp -p ${COMhafs}/${trk_atcfunix} ${CDNOSCRUB}/${SUBEXPT}/.
+
+if [ ${COMOUTproduct} = ${COMhafs} ]; then
+ # Deliver track file to NOSCRUB:
+ mkdir -p ${CDNOSCRUB}/${SUBEXPT}
+# cp -p ${COMhafs}/${all_atcfunix}.orig ${CDNOSCRUB}/${SUBEXPT}/.
+ if [ -s ${COMhafs}/${all_atcfunix} ]; then
+ cp -p ${COMhafs}/${all_atcfunix} ${CDNOSCRUB}/${SUBEXPT}/.
+ fi
+ if [ -s ${COMhafs}/${trk_atcfunix} ] && [ $STORMNUM != "00" ]; then
+ cp -p ${COMhafs}/${trk_atcfunix} ${CDNOSCRUB}/${SUBEXPT}/.
+ fi
+ # Deliver patcf file to NOSCRUB:
+ if [ -s ${COMhafs}/${out_prefix}.hafs.trak.patcf ]; then
+ cp -p ${COMhafs}/${out_prefix}.hafs.trak.patcf ${CDNOSCRUB}/${SUBEXPT}/.
+ fi
fi
fi
+
#===============================================================================
cd ${DATA}
echo "product job done"
-
-exit
diff --git a/sorc/build_forecast.sh b/sorc/build_forecast.sh
index 3595cdbd9..2fdd5f6db 100755
--- a/sorc/build_forecast.sh
+++ b/sorc/build_forecast.sh
@@ -15,6 +15,7 @@ else
fi
cd hafs_forecast.fd/tests
-./compile.sh "$target" "-DAPP=$app -DCCPP_SUITES=FV3_HAFS_v0_gfdlmp_tedmf_nonsst,FV3_HAFS_v0_gfdlmp_tedmf,FV3_HAFS_v0_thompson_tedmf_gfdlsf -D32BIT=ON" 32bit YES NO
+./compile.sh "$target" "-DAPP=HAFSW -DMOVING_NEST=ON -DCCPP_SUITES=FV3_HAFS_v0_gfdlmp_tedmf_nonsst,FV3_HAFS_v0_gfdlmp_tedmf,FV3_HAFS_v0_thompson_tedmf_gfdlsf -D32BIT=ON" 32bit YES NO
+#./compile.sh "$target" "-DAPP=$app -DCCPP_SUITES=FV3_HAFS_v0_gfdlmp_tedmf_nonsst,FV3_HAFS_v0_gfdlmp_tedmf,FV3_HAFS_v0_thompson_tedmf_gfdlsf -D32BIT=ON" 32bit YES NO
exit
diff --git a/sorc/build_tools.sh b/sorc/build_tools.sh
index 3d1f5ae9f..32808bdc1 100755
--- a/sorc/build_tools.sh
+++ b/sorc/build_tools.sh
@@ -37,6 +37,8 @@ export HDF5_INCLUDE=${HDF5_INCLUDE:-"-I${HDF5_INCLUDES:-"-I${HDF5}/include"}}"}
#export HDF5_LDFLAGS=${HDF5_LDFLAGS:-"-L${HDF5}/lib -lhdf5_hl -lhdf5hl_fortran -lhdf5 -lhdf5_fortran"}
export HDF5_LDFLAGS=${HDF5_LDFLAGS:-"-L${HDF5_LIBRARIES:-"${HDF5}/lib"} -lhdf5_hl -lhdf5"}
export BUFR_LDFLAGS="${BUFR_LIBd}"
+#export ZLIB_INCLUDE=${ZLIB_INCLUDE:-"-I${ZLIB_INCLUDES:--I${ZLIB_ROOT}/include}"}
+#export ZLIB_LDFLAGS=${ZLIB_LDFLAGS:-"-L${ZLIB_LIBRARIES:--L${ZLIB_ROOT}/lib} -lz -ldl -lm"}
TOOLS_PATH=${cwd}/hafs_tools.fd
export TOOLS_INC=${TOOLS_PATH}/include
@@ -60,4 +62,10 @@ cd ${TOOLS_PATH}/sorc
./build_hafs_utils.sh
+#cd ${TOOLS_PATH}/sorc/hafs_datool
+#./build_hafs_datool.sh
+
+#cd ${TOOLS_PATH}/sorc/hafs_vi
+#make
+
exit
diff --git a/sorc/hafs_forecast.fd b/sorc/hafs_forecast.fd
index 4604d7073..cb84926c5 160000
--- a/sorc/hafs_forecast.fd
+++ b/sorc/hafs_forecast.fd
@@ -1 +1 @@
-Subproject commit 4604d7073b83790bbb2995d5b1d0477931289fbe
+Subproject commit cb84926c571b86ecea3749df8a7777443ee880c9
diff --git a/sorc/hafs_gsi.fd b/sorc/hafs_gsi.fd
index 8b39f2c80..f59d808f2 160000
--- a/sorc/hafs_gsi.fd
+++ b/sorc/hafs_gsi.fd
@@ -1 +1 @@
-Subproject commit 8b39f2c8021e884c534a721d64ec8ec93f120069
+Subproject commit f59d808f2bd18673edce3b91d26c6555bae2cd8b
diff --git a/sorc/hafs_tools.fd/sorc/build_hafs_utils.sh b/sorc/hafs_tools.fd/sorc/build_hafs_utils.sh
index 0b10002ea..a0ef1b76f 100755
--- a/sorc/hafs_tools.fd/sorc/build_hafs_utils.sh
+++ b/sorc/hafs_tools.fd/sorc/build_hafs_utils.sh
@@ -43,6 +43,7 @@
## * Removing sources that are not needed or no longer used
## * Merging internal libraries into a single folder with a single driver script
## * Ported hafs_change_prepbufr under hafs_tools.fd from HWRF (2021-06-07)
+## Added hafs_datool & hafs_vi to CMake based build: Biju Thomas 2022-01-25
#################################################################################
set -x -e
@@ -177,6 +178,95 @@ _hafsutils_change_prepbufr (){
make install
}
+
+#----
+
+# FUNCTION:
+
+# _hafsutils_datool.sh
+
+# DESCRIPTION:
+
+# This function compiles and install the HAFS utility datool
+# application.
+
+# NOTE:
+
+# This function should never be called directly by the user and is for
+# internal use only within this script.
+
+_hafsutils_datool (){
+
+ # Remove the build dir if it exists from previous build
+ if [ -d "${HAFS_UTILS_SORC}/build" ]; then
+ rm -rf ${HAFS_UTILS_SORC}/build
+ fi
+
+ # Create a build directory for a fresh build
+ mkdir ${HAFS_UTILS_SORC}/build
+
+ cd ${HAFS_UTILS_SORC}/build
+
+ # Generate makefile using CMake for the application
+ # BUILD_TYPE supports RELEASE OR DEBUG MODE
+ if [[ $target = "wcoss_cray" ]]; then
+ cmake ../hafs_datool -DCMAKE_Fortran_COMPILER=ftn -DCMAKE_C_COMPILER=cc -DBUILD_TYPE=RELEASE
+ else
+ cmake ../hafs_datool -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=icc -DBUILD_TYPE=RELEASE
+ fi
+
+ # Build the hafs_datool application.
+ make all VERBOSE=3
+
+ # Move the hafs_datool application executable to the HAFS
+ # utility application executables path.
+ make install
+}
+
+#----
+
+# FUNCTION:
+
+# _hafsutils_vi.sh
+
+# DESCRIPTION:
+
+# This function compiles and install the HAFS utility vi
+# application.
+
+# NOTE:
+
+# This function should never be called directly by the user and is for
+# internal use only within this script.
+
+_hafsutils_vi (){
+
+ # Remove the build dir if it exists from previous build
+ if [ -d "${HAFS_UTILS_SORC}/build" ]; then
+ rm -rf ${HAFS_UTILS_SORC}/build
+ fi
+
+ # Create a build directory for a fresh build
+ mkdir ${HAFS_UTILS_SORC}/build
+
+ cd ${HAFS_UTILS_SORC}/build
+
+ # Generate makefile using CMake for the application
+ # BUILD_TYPE supports RELEASE OR DEBUG MODE
+ if [[ $target = "wcoss_cray" ]]; then
+ cmake ../hafs_vi -DCMAKE_Fortran_COMPILER=ftn -DCMAKE_C_COMPILER=cc -DBUILD_TYPE=RELEASE
+ else
+ cmake ../hafs_vi -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=icc -DBUILD_TYPE=RELEASE
+ fi
+
+ # Build the hafs_vi application.
+ make all VERBOSE=3
+
+ # Move the hafs_vi application executable to the HAFS
+ # utility application executables path.
+ make install
+}
+
#----
@@ -212,6 +302,13 @@ build_hafsutils (){
# Build the change_prepbufr application.
_hafsutils_change_prepbufr
+
+ # Build the datool application.
+
+ _hafsutils_datool
+
+ # Build the vi application
+ _hafsutils_vi
}
diff --git a/sorc/hafs_tools.fd/sorc/cmake/Modules/FindMKL.cmake b/sorc/hafs_tools.fd/sorc/cmake/Modules/FindMKL.cmake
new file mode 100644
index 000000000..c9451034d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/cmake/Modules/FindMKL.cmake
@@ -0,0 +1,76 @@
+# (C) Copyright 2011- ECMWF.
+#
+# This software is licensed under the terms of the Apache Licence Version 2.0
+# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
+# In applying this licence, ECMWF does not waive the privileges and immunities
+# granted to it by virtue of its status as an intergovernmental organisation
+# nor does it submit to any jurisdiction.
+
+# - Try to find MKL
+# Once done this will define
+#
+# MKL_FOUND - system has Intel MKL
+# MKL_INCLUDE_DIRS - the MKL include directories
+# MKL_LIBRARIES - link these to use MKL
+#
+# The following paths will be searched with priority if set in CMake or env
+#
+# MKLROOT - root directory of the MKL installation
+# MKL_PATH - root directory of the MKL installation
+# MKL_ROOT - root directory of the MKL installation
+
+option( MKL_PARALLEL "if mkl shoudl be parallel" OFF )
+
+if( MKL_PARALLEL )
+
+ set( __mkl_lib_par MKL_LIB_INTEL_THREAD )
+ set( __mkl_lib_name mkl_intel_thread )
+
+ find_package(Threads)
+
+else()
+
+ set( __mkl_lib_par MKL_LIB_SEQUENTIAL )
+ set( __mkl_lib_name mkl_sequential )
+
+endif()
+
+# Search with priority for MKLROOT, MKL_PATH and MKL_ROOT if set in CMake or env
+find_path(MKL_INCLUDE_DIR mkl.h
+ PATHS ${MKLROOT} ${MKL_PATH} ${MKL_ROOT} ENV MKLROOT ENV MKL_PATH ENV MKL_ROOT
+ PATH_SUFFIXES include NO_DEFAULT_PATH)
+find_path(MKL_INCLUDE_DIR mkl.h
+ PATH_SUFFIXES include)
+
+if( MKL_INCLUDE_DIR ) # use include dir to find libs
+
+ set( MKL_INCLUDE_DIRS ${MKL_INCLUDE_DIR} )
+
+ if( CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" )
+ get_filename_component( MKL_LIB_PATH ${MKL_INCLUDE_DIR}/../lib/intel64 ABSOLUTE )
+ set( __libsfx _lp64 )
+ else()
+ get_filename_component( MKL_LIB_PATH ${MKL_INCLUDE_DIR}/../lib/ia32 ABSOLUTE )
+ set( __libsfx "" )
+ endif()
+
+ find_library( MKL_LIB_INTEL NAMES mkl_intel${__libsfx} PATHS ${MKL_LIB_PATH} )
+ find_library( ${__mkl_lib_par} NAMES ${__mkl_lib_name} PATHS ${MKL_LIB_PATH} )
+ find_library( MKL_LIB_CORE NAMES mkl_core PATHS ${MKL_LIB_PATH} )
+
+ if( MKL_PARALLEL )
+ find_library( MKL_LIB_IOMP5 NAMES iomp5 PATHS ${MKL_LIB_PATH} )
+ endif()
+
+ if( MKL_LIB_INTEL AND ${__mkl_lib_par} AND MKL_LIB_CORE )
+ set( MKL_LIBRARIES ${MKL_LIB_INTEL} ${${__mkl_lib_par}} ${MKL_LIB_CORE} ${MKL_LIB_IOMP5} ${CMAKE_THREAD_LIBS_INIT} )
+ endif()
+
+endif()
+
+include(FindPackageHandleStandardArgs)
+
+find_package_handle_standard_args( MKL DEFAULT_MSG
+ MKL_LIBRARIES MKL_INCLUDE_DIRS )
+
+mark_as_advanced( MKL_INCLUDE_DIR MKL_LIB_LAPACK MKL_LIB_INTEL MKL_LIB_SEQUENTIAL MKL_LIB_CORE )
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_datool/CMakeLists.txt
new file mode 100644
index 000000000..f72c614a7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/CMakeLists.txt
@@ -0,0 +1,56 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+cmake_minimum_required(VERSION 3.15)
+project(
+ DATOOL
+ LANGUAGES C Fortran)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules/")
+
+if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU)$")
+ message(WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
+endif()
+
+if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU)$")
+ message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
+endif()
+
+find_package(NetCDF REQUIRED C Fortran)
+find_package(MPI REQUIRED)
+
+set(fortran_srcs
+ module_mpi.f90
+ module_structure.f90
+ sub_tcinfo.f90
+ sub_netcdf.f90
+ sub_tools.f90
+ sub_grids.f90
+ sub_wind_process.f90
+ sub_hafs_remap.f90
+ sub_hafsvi_proc.f90
+ hafs_datool.f90)
+
+set(exe_name hafs_datool.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_libraries(
+ ${exe_name} PRIVATE
+ NetCDF::NetCDF_Fortran
+ NetCDF::NetCDF_C
+ MPI::MPI_Fortran)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/build_datool_CMake.bash b/sorc/hafs_tools.fd/sorc/hafs_datool/build_datool_CMake.bash
new file mode 100755
index 000000000..b012e5079
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/build_datool_CMake.bash
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -xeu
+
+HOMEhafs="../../../../"
+source ${HOMEhafs}/sorc/machine-setup.sh > /dev/null 2>&1
+
+module use ${HOMEhafs}/modulefiles
+module load modulefile.hafs.${target}
+module list
+
+BuildDir=${HOMEhafs}/sorc/hafs_tools.fd/sorc/build
+if [ -d ${BuildDir} ]; then
+ rm -rf ${BuildDir}
+fi
+mkdir ${BuildDir}
+cd ${BuildDir}
+
+cmake ../hafs_datool -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=icc -DBUILD_TYPE=RELEASE
+make VERBOSE=3
+make install
+
+# ./build_datool_CMake.bash > build.log 2>&1 &
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/build_hafs_datool.sh b/sorc/hafs_tools.fd/sorc/hafs_datool/build_hafs_datool.sh
new file mode 100755
index 000000000..4bc940257
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/build_hafs_datool.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+set -xeu
+
+HOMEhafs="../../../../"
+source ${HOMEhafs}/sorc/machine-setup.sh > /dev/null 2>&1
+
+module use ${HOMEhafs}/modulefiles
+module load modulefile.hafs.${target}
+module list
+
+export NETCDF_INCLUDE="-I${NETCDF}/include"
+export NETCDF_LDFLAGS="-L${NETCDF}/lib -lnetcdff -lnetcdf"
+export HDF5_INCLUDE=${HDF5_INCLUDE:-"-I${HDF5_INCLUDES:--I${HDF5}/include}"}
+export HDF5_LDFLAGS=${HDF5_LDFLAGS:-"-L${HDF5_LIBRARIES:--L${HDF5}/lib} -lhdf5_hl -lhdf5"}
+export ZLIB_INCLUDE=${ZLIB_INCLUDE:-"-I${ZLIB_INCLUDES:--I${ZLIB_ROOT}/include}"}
+export ZLIB_LDFLAGS=${ZLIB_LDFLAGS:-"-L${ZLIB_LIBRARIES:--L${ZLIB_ROOT}/lib} -lz -ldl -lm"}
+
+rm -f *.o *.mod *.exe
+
+#FFLAGS="-O0 -g -traceback -check all -fp-model precise -assume byterecl -convert big_endian"
+#LDFLAGS="-O0 -g -traceback -check all -fp-model precise -assume byterecl -convert big_endian"
+ FFLAGS="-O3 -g -traceback -fp-model precise -assume byterecl -convert big_endian"
+ LDFLAGS="-O3 -g -traceback -fp-model precise -assume byterecl -convert big_endian"
+
+mpif90 -f90=ifort -c ${FFLAGS} module_mpi.f90
+mpif90 -f90=ifort -c ${FFLAGS} module_structure.f90
+mpif90 -f90=ifort -c ${FFLAGS} sub_tcinfo.f90
+mpif90 -f90=ifort -c ${FFLAGS} -I${NETCDF}/include sub_netcdf.f90
+mpif90 -f90=ifort -c ${FFLAGS} sub_tools.f90
+mpif90 -f90=ifort -c ${FFLAGS} sub_grids.f90
+mpif90 -f90=ifort -c ${FFLAGS} sub_wind_process.f90
+mpif90 -f90=ifort -c ${FFLAGS} -I${NETCDF}/include sub_hafs_remap.f90
+mpif90 -f90=ifort -c ${FFLAGS} -I${NETCDF}/include sub_hafsvi_proc.f90
+mpif90 -f90=ifort -c ${FFLAGS} hafs_datool.f90
+
+#mpif90 -f90=ifort -o hafs_datool.exe ${LDFLAGS} module_mpi.o module_structure.o sub_tcinfo.o sub_netcdf.o sub_tools.o sub_grids.o sub_hafs_remap.o sub_hafsvi_preproc.o hafs_datool.o -L${NETCDF}/lib -lnetcdff -lnetcdf -L${HDF5_LIBRARIES} -lhdf5_hl -lhdf5 -lz
+mpif90 -f90=ifort -o hafs_datool.exe ${LDFLAGS} module_mpi.o module_structure.o sub_tcinfo.o sub_netcdf.o sub_tools.o sub_grids.o sub_wind_process.o sub_hafs_remap.o sub_hafsvi_proc.o hafs_datool.o -L${NETCDF}/lib -lnetcdff -lnetcdf -L${HDF5_LIBRARIES} -lhdf5_hl -lhdf5 -lz
+
+cp -p hafs_datool.exe ../../exec/hafs_datool.x
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/hafs_datool.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/hafs_datool.f90
new file mode 100644
index 000000000..81e0727dc
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/hafs_datool.f90
@@ -0,0 +1,211 @@
+ program hafs_datool
+
+!=========================================================================
+! HAFS DA tool
+! Yonghui Weng, 20210201
+
+! command convention
+! hafs_datool.x FUNCTION --in_file=input_files \
+! --in_grid=input_grids_file \
+! --in_format=restart \
+! --out_grid=output_grid_file
+!
+! Usage and Examples:
+!
+! 1) FUNCTIONs:
+! remap: remap one grid file to another grid file
+! vortexreplace: cut an area around vortex from in file to replace the area in the dst file.
+! file_merge: merge nc files
+! domain_merge: merge different domain/coverage/h-resolution files into one specificed grid
+!
+!
+! 2) Arguments
+! --in_dir: input data folder
+! --in_file: inout file[s], if have multi files, use ":" to seperate them
+! if no dir info, then find the file[s] in in_dir folder;
+! --in_grid: input_grids_file, for FV3, it may be grid_spec.nc
+! if no this argument, then find grid information from in_file.
+!
+! 3) Examples
+! 3.1) remap
+! * hafs_datool.x remap --in_file=${in_dir}/20190829.060000.phy_data.nc \
+! --in_grid=${in_dir}/grid_spec.nc \
+! --out_grid=${out_dir}/grid_spec.nc
+! : interpolate 20190829.060000.phy_data.nc to grid_spec.nc grids, if grid_spec.nc
+! domain is bigger than input, then fill missing values.
+! * mpirun -np 32 hafs_datool.x remap \
+! --in_file=${in_dir}/20190829.060000.phy_data.nc \
+! --in_grid=${in_dir}/grid_spec.nc \
+! --out_grid=${out_dir}/grid_spec.nc \
+! --out_data=${out_dir}/20190829.060000.phy_data.nc \
+! --out_file=${out_dir}/20190829.060000.phy_data.nc_merged
+! : merge in_file and out_data to out_grid grids, and output the file as out_file.
+!
+! 3.2) vortexreplace
+! * hafs_datool.x vortexreplace --in_grid=${in_dir}/grid_spec.nc \
+! --vortexposition=${user_define_vortex_position_file} \
+! [--vortexradius=600:1200 ] \
+! [--tcvital=${tcvital_file} ] \
+! [--besttrack=${besttrackfile} ] \
+! --in_file=${in_dir}/20190829.060000.phy_data.nc \
+! --out_grid=${out_dir}/grid_spec.nc \
+! --out_file=20190829.060000.phy_data.nc
+!
+! 3.3) vi_preproc
+! * hafs_datool.x hafsvi_preproc --in_dir=HAFS_restart_folder --infile_date=20200825.180000 \
+! [--vortexposition=user_define_vortex_file --tcvital=tcvitalfile \
+! --besttrack=bdeckfile ] [--vortexradius=deg ] \
+! [--nestdoms=nestdoms ] \
+! [ --tc_date=tcvital_date] [--res=deg ] \
+! [--out_file=output_bin_file]
+!
+! 3.4) vi_postproc
+! * hafs_datool.x hafsvi_postproc --in_file=[hafs_vi rot-ll bin file] \
+! --out_dir=[hafs-restart subfolder] \
+! --infile_date=20200825.180000
+!=========================================================================
+ use module_mpi
+ use var_type
+ use netcdf
+
+ implicit none
+
+ !----parameter define
+ integer :: i, j, k, n, iind, iargc, rcode, ks, ke, nestdoms
+ character (len=2500) :: actions, arg, arg1
+ character (len=2500) :: in_dir='w', in_file='w', in_grid='w', &
+ vortex_position_file='w', tcvital_file='w', besttrackfile='w', &
+ out_dir='w', out_grid='w', out_data='w', out_file='w', infile_date='w'
+ character (len=50 ) :: vortexradius='w' ! for vortexreplace, vortexradius=600:900 km
+ ! for hafsvi_preproc, vortexradius=30 deg or 45 deg
+ character (len=50 ) :: relaxzone='' !
+ character (len=50 ) :: tc_date='w' !
+ character (len=50 ) :: res='w' !
+ character (len=50 ) :: debug_levelc='' !
+ character (len=50 ) :: interpolation_pointsc='' !
+ character (len=50 ) :: nestdomsc='' ! number for nest domains, 1-30, 1=nest02.tile2
+ ! in vi_preproc, combine all domains and output to one rot-ll grid.
+
+ real, dimension(3) :: center
+!----------------------------------------------------------------
+! 0 --- initialization
+! Initialize parallel stuff
+! call parallel_start()
+
+!----------------------------------------------------------------
+! 1 --- argc and usage
+! 1.1 --- get argc
+ if (iargc() .lt. 2) then
+ write(*,*)' usage: hafs_datool.x function --in_file=inputfile'
+ stop
+ else
+ call getarg(1, actions)
+
+ do i = 2, iargc()
+ call getarg(i, arg)
+ j=index(trim(arg),'=',.true.)
+ n=len_trim(arg)
+ select case (arg(1:j-1))
+ case ('--in_dir'); in_dir=arg(j+1:n)
+ case ('-i', '--in_file'); in_file=arg(j+1:n)
+ case ('--in_grid'); in_grid=arg(j+1:n)
+ case ('--out_dir'); out_dir=arg(j+1:n)
+ case ('--out_grid'); out_grid=arg(j+1:n)
+ case ('--out_data'); out_data=arg(j+1:n)
+ case ('--out_file'); out_file=arg(j+1:n)
+ case ('--vortexposition'); vortex_position_file=arg(j+1:n)
+ case ('--tcvital'); tcvital_file=arg(j+1:n)
+ case ('--besttrack'); besttrackfile=arg(j+1:n)
+ case ('--vortexradius'); vortexradius=arg(j+1:n)
+ case ('--infile_date'); infile_date=arg(j+1:n) !20210312.0930
+ case ('--relaxzone'); relaxzone=arg(j+1:n)
+ case ('--tc_date'); tc_date=arg(j+1:n) !20210312.0930
+ case ('--res'); res=arg(j+1:n) !0.02
+ case ('--debug_level'); debug_levelc=arg(j+1:n) !
+ case ('--interpolation_points'); interpolation_pointsc=arg(j+1:n) !
+ case ('--nestdoms'); nestdomsc=arg(j+1:n) !
+ end select
+ enddo
+ endif
+
+!----------------------------------------------------------------
+! 2 --- process args and initialization
+ tc%lat=-9999.0; tc%lon=-9999.0; tc%pmin=-9999.0; tc%vmax=-9999.0; tc%vortexreplace_r(1:2)=-9999.0
+
+! 2.1 --- relaxzone, debug_level, interpolation_points
+ gwt%relaxzone=-99; if (len_trim(relaxzone) > 0 ) read(relaxzone,*)gwt%relaxzone
+
+ if (len_trim(debug_levelc) > 1 .and. trim(debug_levelc) .ne. "w") read(debug_levelc,*)debug_level
+ if ( debug_level < 0 .or. debug_level > 999999 ) debug_level = 1
+
+ if (len_trim(interpolation_pointsc) > 0 .and. trim(interpolation_pointsc) .ne. "w") read(interpolation_pointsc,*)gwt%max_points
+ if ( gwt%max_points > 9999 .or. gwt%max_points < 1 ) gwt%max_points=4
+
+ nestdoms=0; if (len_trim(nestdomsc) > 0 ) read(nestdomsc,*)nestdoms
+ if ( nestdoms > 30 .or. nestdoms < 0 ) nestdoms=0
+
+! 2.2 --- tc info requirement
+ if ( trim(actions) == "vortexreplace" .or. trim(actions) == "hafsvi_preproc" ) then
+ if ( trim(vortex_position_file) == "w" .and. trim(tcvital_file) == "w" .and. trim(besttrackfile) == "w" ) then
+ write(*,'(a)')' vortexreplace and hafsvi_preproc functions require at least one vortex information, '
+ write(*,'(a)')' please add one of the following arg:'
+ write(*,'(a)')' --vortexposition=user_define_vortex_position_file.txt or '
+ write(*,'(a)')' --tcvital=TCvital_file or '
+ write(*,'(a)')' --besttrack=best-track-file'
+ stop
+ endif
+ if ( len_trim(infile_date) < 2 .and. len_trim(tc_date) < 2 .and. trim(vortex_position_file) == "w" ) then
+ write(*,'(a)')' vortexreplace and hafsvi_preproc functions require date information when read tcvital or besttrack , '
+ write(*,'(a)')' please add one of the following arg:'
+ write(*,'(a)')' --infile_date=input_file_date or/and'
+ write(*,'(a)')' --tc_date=tc_date'
+ stop
+ endif
+ endif
+
+ if ( trim(actions) == "hafsvi_preproc" ) then
+ if ( trim(infile_date) == "w" ) then
+ write(*,'(a)')' hafsvi_preproc function requires input file date for filename'
+ write(*,'(a)')' please add one of the following arg:'
+ write(*,'(a)')' --infile_date=input_file_date'
+ stop
+ endif
+ endif
+ if ( trim(tc_date) == "w" .and. len_trim(infile_date) > 1 ) then
+ tc_date=trim(infile_date)
+ endif
+
+! 2.3 --- tc/vortex info
+ if ( trim(actions) == "vortexreplace" ) then
+ tc%vortexrep=1
+ else
+ tc%vortexrep=0
+ endif
+ if ( trim(actions) == "vortexreplace" .or. trim(actions) == "hafsvi_preproc" ) then
+ call get_tc_info(trim(vortex_position_file), trim(tcvital_file), trim(besttrackfile), trim(tc_date), &
+ trim(vortexradius))
+ endif
+
+!----------------------------------------------------------------
+! 3.0 --- remap
+ if ( trim(actions) == "remap" .or. trim(actions) == "vortexreplace" ) then
+ write(*,'(a)')' --- call hafs_remap for '//trim(in_grid)//' and '//trim(out_grid)
+ call hafs_remap(trim(in_dir), trim(in_grid), trim(in_file), trim(out_dir), trim(out_grid), trim(out_data), trim(out_file))
+ endif
+
+!----------------------------------------------------------------
+! 4.0 --- HAFS VI
+ if ( trim(actions) == "hafsvi_preproc" ) then
+ write(*,'(a)')' --- call hafsvi_preproc/hafs_datool for '//trim(in_grid)
+ call hafsvi_preproc(trim(in_dir), trim(infile_date), nestdoms, trim(vortexradius), trim(res), trim(out_file))
+ endif
+
+ if ( trim(actions) == "hafsvi_postproc" ) then
+ write(*,'(a)')' --- call hafsvi_postproc/hafs_datool for '//trim(in_file)
+ call hafsvi_postproc(trim(in_file), trim(infile_date), trim(out_dir), nestdoms)
+ endif
+
+!----------------------------------------------------------------
+! call parallel_finish()
+
+ end program
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/module_mpi.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/module_mpi.f90
new file mode 100644
index 000000000..579b098af
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/module_mpi.f90
@@ -0,0 +1,80 @@
+
+
+module module_mpi
+
+!-----------------------------------------------------------------------------
+! PURPOSE: This module provides routines for parallelizing.
+!
+!------------------------------------------------------------------------------
+
+
+ use MPI
+
+
+ integer, parameter :: IO_NODE = 0
+ integer :: nprocs, my_proc_id, comm, ierr, request, nprocs_mod, tag
+ double precision :: time_start, time_end
+ integer, dimension(MPI_STATUS_SIZE) :: status
+
+ real :: mpisend
+ real, allocatable, dimension(: ) :: mpirecv
+
+ real, allocatable, dimension(: ) :: mpisend1d
+ real, allocatable, dimension(:,:) :: mpirecv1d
+
+ integer :: prev, next
+
+ contains
+
+!-----------------------------------------------------------------------------
+! PURPOSE: to basically set up a communicator for a rectangular mesh.
+!------------------------------------------------------------------------------
+ subroutine parallel_start()
+
+ implicit none
+
+ ! Arguments
+
+ ! Local variables
+
+ integer :: mpi_rank, mpi_size
+ integer :: mpi_ierr
+
+ ! Find out our rank and the total number of processors
+ call MPI_Init(mpi_ierr)
+ call MPI_Comm_rank(MPI_COMM_WORLD, mpi_rank, mpi_ierr)
+ call MPI_Comm_size(MPI_COMM_WORLD, mpi_size, mpi_ierr)
+ time_start = MPI_Wtime()
+
+ comm = MPI_COMM_WORLD
+ nprocs = mpi_size
+ my_proc_id = mpi_rank
+
+
+
+
+
+
+ end subroutine parallel_start
+
+!-----------------------------------------------------------------------------
+! PURPOSE: Free up, deallocate, and for MPI, finalize.
+!------------------------------------------------------------------------------
+ subroutine parallel_finish()
+
+ implicit none
+
+ ! Arguments
+
+ ! Local variables
+
+ integer :: mpi_ierr
+
+ time_end = MPI_Wtime()
+ call MPI_Finalize(mpi_ierr)
+
+
+ end subroutine parallel_finish
+
+
+end module module_mpi
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/module_structure.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/module_structure.f90
new file mode 100644
index 000000000..00f209c03
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/module_structure.f90
@@ -0,0 +1,66 @@
+module constants
+!-----------------------------------------------------------------------------
+! define all parameter and constants
+! Yonghui Weng, 20210204
+!-----------------------------------------------------------------------------
+ implicit none
+ real, parameter :: g=9.81, &! gravitational constant
+ r_earth=6374., &! radius of the earth
+ pi = 3.1415927, &!
+ deg2rad = pi/180.0, &!
+ rad2deg = 1.0/deg2rad, &!
+ cp=1004.5, &! specific heat
+ rd=287., &! dry air gas constant
+ rv=461.6, &! moist air gas constant
+ es_alpha = 611.2, &! saturation vaporpressure
+ es_beta = 17.67, &!
+ es_gamma = 243.5, &!
+ missing=9.999e+20 ! missing value
+! parameter to determine interpolation method
+! integer, parameter :: CONSERVE = 1
+! integer, parameter :: BILINEAR = 2
+! integer, parameter :: SPHERICA = 3
+! integer, parameter :: BICUBIC = 4
+
+end module constants
+
+!==============================================================================
+module var_type
+!-----------------------------------------------------------------------------
+! define var
+! Yonghui Weng, 20210204
+!-----------------------------------------------------------------------------
+ type grid2d_info
+ integer :: grid_x, grid_y, ntime, grid_xt, grid_yt
+ real*8, allocatable, dimension(:) :: times
+ character(len=80) :: times_unit
+ real, allocatable, dimension(:,:) :: grid_lon, grid_lat, grid_lont, grid_latt, grid_area
+ end type grid2d_info
+
+ type gridmap_info
+ integer :: src_points, dst_points
+ integer, allocatable, dimension(:) :: src_x, src_y !position in source grid
+ integer, allocatable, dimension(:) :: dst_x, dst_y !dst grids will be used for smooth, to reduce the gaps
+ real, allocatable, dimension(:) :: src_weight, dst_weight
+ end type gridmap_info
+
+ type grid_weight_info
+ integer :: max_points, relaxzone
+ type(gridmap_info),allocatable,dimension(:,:) :: gwt_t, gwt_u, gwt_v
+ real, allocatable, dimension(:,:) :: cangu, sangu, cangv, sangv
+ end type grid_weight_info
+
+ type(grid_weight_info) :: gwt
+
+ type tc_track_info
+ integer :: vortexrep ! 1=tc vortex-replacement, others are not
+ real :: lat, lon, pmin, vmax
+ real, dimension(2) :: vortexreplace_r
+ end type tc_track_info
+ type(tc_track_info) :: tc
+
+ integer :: debug_level ! default is 1, only print basic information
+ ! 2-9:
+
+end module var_type
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_grids.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_grids.f90
new file mode 100644
index 000000000..1438b5999
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_grids.f90
@@ -0,0 +1,269 @@
+!-----------------------------------------------------------------------+
+ subroutine rtll(rot_lon,rot_lat,geo_lon,geo_lat,cen_lon,cen_lat)
+
+!-- from https://github.com/NOAA-EMC/fv3atm/blob/cf0a73180b2d9ac55ebfce4785a7270d205423db/io/module_wrt_grid_comp.F90#L3545
+!-- called in fv3atm
+! else if ( trim(output_grid) == 'rotated_latlon' ) then
+! do j=lbound(lonPtr,2),ubound(lonPtr,2)
+! do i=lbound(lonPtr,1),ubound(lonPtr,1)
+! rot_lon = lon1 + (lon2-lon1)/(imo-1) * (i-1)
+! rot_lat = lat1 + (lat2-lat1)/(jmo-1) * (j-1)
+! call rtll(rot_lon, rot_lat, geo_lon, geo_lat, dble(cen_lon), dble(cen_lat))
+! if (geo_lon < 0.0) geo_lon = geo_lon + 360.0
+! lonPtr(i,j) = geo_lon
+! latPtr(i,j) = geo_lat
+! enddo
+! Enddo
+!
+!--------------
+ real, intent(in) :: rot_lon, rot_lat
+ real, intent(out) :: geo_lon, geo_lat
+ real, intent(in) :: cen_lat, cen_lon
+!
+ real, parameter :: pi=3.14159265358979323846
+ real, parameter :: dtr=pi/180.0
+!
+ real :: tph0, ctph0, stph0, tlm, tph, stph, ctph, ctlm, stlm, aph, cph
+ real :: xx, yy
+!--------------
+!
+!--- Convert all angles to radians
+ tph0=cen_lat*dtr
+ ctph0=cos(tph0)
+ stph0=sin(tph0)
+ tlm=rot_lon*dtr
+ tph=rot_lat*dtr
+!
+ stph=sin(tph)
+ ctph=cos(tph)
+ ctlm=cos(tlm)
+ stlm=sin(tlm)
+!
+ xx=stph0*ctph*ctlm+ctph0*stph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ aph=asin(xx)
+ cph=cos(aph)
+!
+ xx=(ctph0*ctph*ctlm-stph0*stph)/cph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ xx=acos(xx)/dtr
+ yy=ctph*stlm/cph
+ xx=sign(xx,yy)
+ geo_lon=cen_lon+xx
+
+ geo_lat=aph/dtr
+!
+ if (geo_lon > 180.0) then
+ geo_lon=geo_lon-360.0
+ end if
+ if (geo_lon < -180.0) then
+ geo_lon=geo_lon+360.0
+ end if
+!
+ return
+ end subroutine rtll
+
+!-----------------------------------------------------------------------+
+!--- from hwrf_wps.fd/geogrid/src/module_map_utils.f90
+!--- modified
+ subroutine ijll_rotlatlon(i, j, phi, lambda, ixdim, jydim, lat1, lon1, stagger, lat,lon)
+
+ implicit none
+
+ ! Arguments
+ real, intent(in) :: i, j
+ real, intent(in) :: phi ! For Rotated Lat/Lon -- domain half-extent in degrees latitude
+ real, intent(in) :: lambda ! For Rotated Lat/Lon -- domain half-extend in degrees longitude
+ integer, intent(in) :: ixdim ! For Rotated Lat/Lon -- number of mass points in an odd row
+ integer, intent(in) :: jydim ! For Rotated Lat/Lon -- number of rows
+ real, intent(in) :: lat1 ! SW latitude (1,1) in degrees (-90->90N)
+ real, intent(in) :: lon1 ! SW longitude (1,1) in degrees (-180->180E)
+ character (len=*), intent(in) :: stagger ! For Rotated Lat/Lon -- mass or velocity grid 'VV'/'T'
+ real, intent(out) :: lat, lon
+
+ ! Local variables
+ integer :: ih,jh
+ real :: jj
+ integer :: midcol,midrow,ncol,iadd1,iadd2,imt,jh2,knrow,krem,kv,nrow
+ real :: dphd,dlmd !Grid increments, degrees
+ real :: arg1,arg2,d2r,fctr,glatr,glatd,glond,pi, &
+ r2d,tlatd,tlond,tlatr,tlonr,tlm0,tph0
+ real :: col
+
+ jj = j
+ if ( (j - int(j)) .gt. 0.999) then
+ jj = j + 0.0002
+ endif
+
+ jh = int(jj)
+
+ dphd = phi/real((jydim-1)/2)
+ dlmd = lambda/real(ixdim-1)
+
+ pi = acos(-1.0)
+ d2r = pi/180.
+ r2d = 1./d2r
+ tph0 = lat1*d2r
+ tlm0 = -lon1*d2r
+
+ midrow = int((jydim+1)/2)
+ midcol = ixdim
+
+ col = 2*i-1+abs(mod(jh+1,2))
+ tlatd = (jj-midrow)*dphd
+ tlond = (col-midcol)*dlmd
+
+ if (trim(stagger) == 'VV') then
+ if (mod(jh,2) .eq. 0) then
+ tlond = tlond - dlmd
+ else
+ tlond = tlond + dlmd
+ end if
+ end if
+
+ tlatr = tlatd*d2r
+ tlonr = tlond*d2r
+ arg1 = sin(tlatr)*cos(tph0)+cos(tlatr)*sin(tph0)*cos(tlonr)
+ glatr = asin(arg1)
+
+ glatd = glatr*r2d
+
+ arg2 = cos(tlatr)*cos(tlonr)/(cos(glatr)*cos(tph0))-tan(glatr)*tan(tph0)
+ if (abs(arg2) > 1.) arg2 = abs(arg2)/arg2
+ fctr = 1.
+ if (tlond > 0.) fctr = -1.
+
+ glond = tlm0*r2d+fctr*acos(arg2)*r2d
+
+ lat = glatd
+ lon = -glond
+
+ if (lon > 180.) lon = lon - 360.
+ if (lon < -180.) lon = lon + 360.
+
+ return
+ end subroutine ijll_rotlatlon
+
+!-----------------------------------------------------------------------+
+!--- from vortex_init/hwrf_set_ijstart/swcorner_dynamic.F
+!--- modified
+ subroutine EARTH_LATLON ( HLAT,HLON,VLAT,VLON, & !Earth lat,lon at H and V points
+ DLMD1,DPHD1,WBD1,SBD1, & !input res,west & south boundaries,
+ CENTRAL_LAT,CENTRAL_LON, & ! central lat,lon, all in degrees
+ IDS,IDE,JDS,JDE,KDS,KDE, &
+ IMS,IME,JMS,JME,KMS,KME, &
+ ITS,ITE,JTS,JTE,KTS,KTE )
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN ) :: IDS,IDE,JDS,JDE,KDS,KDE
+ INTEGER, INTENT(IN ) :: IMS,IME,JMS,JME,KMS,KME
+ INTEGER, INTENT(IN ) :: ITS,ITE,JTS,JTE,KTS,KTE
+ REAL, INTENT(IN ) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL, INTENT(IN ) :: CENTRAL_LAT,CENTRAL_LON
+ REAL, DIMENSION(IMS:IME,JMS:JME), INTENT(OUT) :: HLAT,HLON,VLAT,VLON
+
+! local
+
+
+ INTEGER,PARAMETER :: KNUM=SELECTED_REAL_KIND(13)
+ INTEGER :: I,J
+ REAL(KIND=KNUM) :: WB,SB,DLM,DPH,TPH0,STPH0,CTPH0
+ REAL(KIND=KNUM) :: TDLM,TDPH,TLMH,TLMV,TLMH0,TLMV0,TPHH,TPHV,DTR
+ REAL(KIND=KNUM) :: STPH,CTPH,STPV,CTPV,PI_2
+ REAL(KIND=KNUM) :: SPHH,CLMH,FACTH,SPHV,CLMV,FACTV
+ REAL(KIND=KNUM), DIMENSION(IMS:IME,JMS:JME) :: GLATH,GLONH,GLATV,GLONV
+ REAL(KIND=KNUM) :: DLMD8,DPHD8,WBD8,SBD8,CLAT8,CLON8
+ REAL(KIND=KNUM) :: CPHH, CPHV
+!-------------------------------------------------------------------------
+ DLMD8=DLMD1
+ DPHD8=DPHD1
+ WBD8=WBD1
+ SBD8=SBD1
+ CLAT8=CENTRAL_LAT
+ CLON8=CENTRAL_LON
+!
+ PI_2 = ACOS(0.)
+ DTR = PI_2/90.
+ WB = WBD8 * DTR ! WB: western boundary in radians
+ SB = SBD8 * DTR ! SB: southern boundary in radians
+ DLM = DLMD8 * DTR ! DLM: dlamda in radians
+ DPH = DPHD8 * DTR ! DPH: dphi in radians
+ TDLM = DLM + DLM ! TDLM: 2.0*dlamda
+ TDPH = DPH + DPH ! TDPH: 2.0*DPH
+
+! For earth lat lon only
+
+ TPH0 = CLAT8*DTR ! TPH0: central lat in radians
+ STPH0 = SIN(TPH0)
+ CTPH0 = COS(TPH0)
+
+ ! .H
+ DO J = JTS,MIN(JTE,JDE-1) ! H./ This loop takes care of zig-zag
+! ! \.H starting points along j
+ TLMH0 = WB - TDLM + MOD(J+1,2) * DLM ! ./ TLMH (rotated lats at H points)
+ TLMV0 = WB - TDLM + MOD(J,2) * DLM ! H (//ly for V points)
+ TPHH = SB + (J-1)*DPH ! TPHH (rotated lons at H points) are simple trans.
+ TPHV = TPHH ! TPHV (rotated lons at V points) are simple trans.
+ STPH = SIN(TPHH)
+ CTPH = COS(TPHH)
+ STPV = SIN(TPHV)
+ CTPV = COS(TPHV)
+ ! .H
+ DO I = ITS,MIN(ITE,IDE-1) ! /
+ TLMH = TLMH0 + I*TDLM ! \.H .U .H
+! !H./ ----><----
+ SPHH = CTPH0 * STPH + STPH0 * CTPH * COS(TLMH) ! DLM + DLM
+ CPHH = sqrt(1-SPHH**2)
+ GLATH(I,J)=ASIN(SPHH) ! GLATH: Earth Lat in radians
+ !CLMH = CTPH*COS(TLMH)/(COS(GLATH(I,J))*CTPH0) &
+ ! - TAN(GLATH(I,J))*TAN(TPH0)
+ CLMH = (CTPH*COS(TLMH)-SPHH*STPH0) / (CPHH*CTPH0)
+ IF(CLMH .GT. 1.) CLMH = 1.0
+ IF(CLMH .LT. -1.) CLMH = -1.0
+ FACTH = 1.
+ IF(TLMH .GT. 0.) FACTH = -1.
+ GLONH(I,J) = -CLON8*DTR + FACTH*ACOS(CLMH)
+
+ ENDDO
+
+ DO I = ITS,MIN(ITE,IDE-1)
+ TLMV = TLMV0 + I*TDLM
+ SPHV = CTPH0 * STPV + STPH0 * CTPV * COS(TLMV)
+ CPHV = sqrt(1-SPHV**2)
+ GLATV(I,J) = ASIN(SPHV)
+ !CLMV = CTPV*COS(TLMV)/(COS(GLATV(I,J))*CTPH0) &
+ ! - TAN(GLATV(I,J))*TAN(TPH0)
+ CLMV = (CTPV*COS(TLMV)-SPHV*STPH0) / (CPHV*CTPH0)
+ IF(CLMV .GT. 1.) CLMV = 1.
+ IF(CLMV .LT. -1.) CLMV = -1.
+ FACTV = 1.
+ IF(TLMV .GT. 0.) FACTV = -1.
+ GLONV(I,J) = -CLON8*DTR + FACTV*ACOS(CLMV)
+
+ ENDDO
+
+ ENDDO
+
+! Conversion to degrees (may not be required, eventually)
+
+ DO J = JTS, MIN(JTE,JDE-1)
+ DO I = ITS, MIN(ITE,IDE-1)
+ HLAT(I,J) = GLATH(I,J) / DTR
+ HLON(I,J)= -GLONH(I,J)/DTR
+ IF(HLON(I,J) .GT. 180.) HLON(I,J) = HLON(I,J) - 360.
+ IF(HLON(I,J) .LT. -180.) HLON(I,J) = HLON(I,J) + 360.
+!
+ VLAT(I,J) = GLATV(I,J) / DTR
+ VLON(I,J) = -GLONV(I,J) / DTR
+ IF(VLON(I,J) .GT. 180.) VLON(I,J) = VLON(I,J) - 360.
+ IF(VLON(I,J) .LT. -180.) VLON(I,J) = VLON(I,J) + 360.
+
+ ENDDO
+ ENDDO
+
+END SUBROUTINE EARTH_LATLON
+
+!-----------------------------------------------------------------------+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafs_remap.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafs_remap.f90
new file mode 100644
index 000000000..3e322d49a
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafs_remap.f90
@@ -0,0 +1,340 @@
+!========================================================================================
+ subroutine hafs_remap(src_dir, src_grid, src_file, dst_dir, dst_grid, dst_file, out_file)
+
+!-----------------------------------------------------------------------------
+! HAFS DA tool - remap
+! Yonghui Weng, 20210201
+!
+! This subroutine drives the interpolation from one-grid to another grid.
+! src_file + dst_file -- > out_file in dst_grid: merge src_file and dst_file to out_file
+! src_file --> out_file: only interpolate src_file to out_fuile
+!
+! note: -- input files should are on the same grids, which means only read grid info once.
+! -- out_file is just one filename, which only out to one output file
+! --
+!-----------------------------------------------------------------------------
+
+ use netcdf
+ use module_mpi
+ use var_type
+
+ implicit none
+
+ character (len=*), intent(in) :: src_dir, src_grid, src_file, dst_dir, dst_grid, dst_file, out_file
+
+ integer :: i, j, k, n, i0, n_srcfl, n_dstfl, i1, j1, k1, n1, nf, nv
+ character (len=2500) :: srcdir, srcgridfl, dstdir, dstgridfl
+ character (len=2500),dimension(50) :: srcfiles, dstfiles
+
+ type(grid2d_info) :: grid_src, grid_dst
+
+ logical :: outside, if_fv_core_file
+ integer, allocatable, dimension(:,:) :: x_oini, y_oini
+ real :: dis, dis0, out_ave_dx, out_ave_dy
+ integer :: ixi, jxi, kxi, txi, ixo, jxo, kxo, txo
+ integer :: ncid, varid, ndims, nvars, xtype, dimids(5), vdim(5), u_stag, v_stag
+ character(len=nf90_max_name) :: varname, dimname
+ integer :: ivarid, vartype, nvardims, nvarAtts, dimlen
+ integer,dimension(nf90_max_var_dims) :: start, count, vdims, vardimids
+
+ real, allocatable, dimension(:,:,:,:) :: fdat_src, fdat_dst, fdat_out
+ real, allocatable, dimension(:,:) :: lat_src, lon_src, lat_dst, lon_dst
+ real*8, allocatable, dimension(:,:,:,:) :: ddat_src, ddat_dst, ddat_out
+ real, allocatable, dimension(:,:,:,:) :: u_src, v_src, u_dst, v_dst, u_out, v_out
+
+ integer :: ncid1, varid1, ndims1, nvars1, xtype1, rcode, noutfl, ncount
+
+!------------------------------------------------------------------------------
+! 1 --- arg process
+!
+! 1.1 --- source dir
+ if (len_trim(src_dir) < 2 .or. trim(src_dir) == 'w' .or. trim(src_dir) == 'null' ) then
+ srcdir='.'
+ else
+ srcdir=trim(src_dir)//' '
+ endif
+ write(*,'(a)')' --- source dir: '//trim(srcdir)
+
+! 1.2 --- source files
+ j=0; n_srcfl=0
+ do i = 1, len_trim(src_file)
+ if ( src_file(i:i) == ":" .or. i == len_trim(src_file) ) then
+ n_srcfl=n_srcfl+1
+ i0=1; if ( i == len_trim(src_file) ) i0=0
+ if (src_file(j+1:j+1) == '/' .or. src_file(j+1:j+2) == './' ) then
+ srcfiles(n_srcfl) = src_file(j+1:i-i0)
+ else
+ srcfiles(n_srcfl) = trim(srcdir)//'/'//src_file(j+1:i-i0)
+ endif
+ j=i
+ endif !if ( src_file(i:i) == ":"
+ enddo !do i = 1, len_trim(src_file)
+ write(*,'(a,i,a)')' --- there is', n_srcfl, ' source file(s)'
+
+! 1.3 --- source grid: one file includes grid-info, could be the same as the source files
+ if (len_trim(src_grid) < 2 ) then
+ srcgridfl=srcfiles(1)
+ else
+ if (src_grid(1:1) == '/' .or. src_grid(1:2) == './' ) then
+ srcgridfl=trim(src_grid)
+ else
+ srcgridfl=trim(srcdir)//'/'//trim(src_grid)
+ endif
+ endif
+
+! 1.4 --- destination dir : the files used for being-mergered.
+ if (len_trim(dst_dir) < 2 .or. trim(dst_dir) == 'w' .or. trim(dst_dir) == 'null' ) then
+ dstdir='.'
+ else
+ dstdir=trim(dst_dir)
+ endif
+ write(*,'(a)')' --- destination dir: '//trim(dstdir)
+
+! 1.5 --- will-be-merged data: if have, src_file+dst_file-->out_file
+! if not, src_file -->out_file
+!
+ j=0; n_dstfl=0
+ do i = 1, len_trim(dst_file)
+ if ( dst_file(i:i) == ":" .or. i == len_trim(dst_file) ) then
+ n_dstfl=n_dstfl+1
+ i0=1; if ( i == len_trim(dst_file) ) i0=0
+ if (dst_file(j+1:j+1) == '/' .or. dst_file(j+1:j+2) == './' ) then
+ dstfiles(n_dstfl) = dst_file(j+1:i-i0)
+ else
+ dstfiles(n_dstfl) = trim(dstdir)//'/'//dst_file(j+1:i-i0)
+ endif
+ j=i
+ endif !if ( dst_file(i:i) == ":"
+ enddo !do i = 1, len_trim(dst_file)
+ write(*,'(a,i,a)')' --- there is', n_dstfl, ' file(s) will be merged.'
+
+! 1.6 --- destination grid
+ if (len_trim(dst_grid) < 2 ) then
+ dstgridfl=dstfiles(1)
+ else
+ if ( dst_grid(1:1) == '/' .or. dst_grid(1:2) == './' ) then
+ dstgridfl=dst_grid
+ else
+ dstgridfl=trim(dst_dir)//'/'//trim(dst_grid)
+ endif
+ endif
+ write(*,'(a)')' --- remap to grid: '//trim(dstgridfl)
+
+
+! 1.7 --- out_file
+ if (len_trim(out_file) > 2) then !output to one file
+ if ( out_file(1:1) == '/' .or. out_file(1:2) == './' ) then
+ do j = 1, n_srcfl; dstfiles(j)=trim(out_file); enddo
+ else
+ do j = 1, n_srcfl; write(*,*)'j=',j
+ dstfiles(j)=trim(dstdir)//'/'//trim(out_file); enddo
+ endif
+ else
+ do j = 1, n_srcfl; dstfiles(j)=srcfiles(j)//'_remapped'; enddo
+ endif
+
+!------------------------------------------------------------------------------
+! 2 --- input grid info
+! read from grid file grid_spec.nc:
+ write(*,'(a)')' --- read grid info from '//trim(srcgridfl)
+ call rd_grid_spec_data(trim(srcgridfl), grid_src)
+
+!------------------------------------------------------------------------------
+! 3 --- output grid info
+ write(*,'(a)')' --- read grid info from '//trim(dstgridfl)
+ call rd_grid_spec_data(trim(dstgridfl), grid_dst)
+
+!------------------------------------------------------------------------------
+! 4 --- calculate output-grid in input-grid's positions (xin, yin), and each grid's weight to dst
+ call cal_src_dst_grid_weight(grid_src, grid_dst)
+
+!------------------------------------------------------------------------------
+! 5 --- inputfiles' loop
+ do_inputfiles_loop: do nf = 1, n_srcfl !srcfiles(nf)
+ call nccheck(nf90_open(trim(srcfiles(nf)), nf90_nowrite, ncid), 'wrong in open '//trim(srcfiles(nf)), .false.)
+ call nccheck(nf90_inquire(ncid, ndims, nvars), 'wrong in inquire ncid', .true.)
+ !dimensions of fv3 restart:
+ ! grid_spec.nc: grid_xt = 2880, grid_yt = 2400, grid_x = 2881, grid_y = 2401
+ ! fv_core.res.tile1.nc: xaxis_1 = 2880, yaxis_2 = 2400, xaxis_2 = 2881, yaxis_1 = 2401, zaxis_1 = 91
+ ! fv_srf_wnd.res.tile1.nc: xaxis_1 = 2880, yaxis_1 = 2400
+ ! fv_tracer.res.tile1.nc: xaxis_1 = 2880, yaxis_1 = 2400, zaxis_1 = 91
+ ! phy_data.nc: xaxis_1 = 2880, yaxis_1 = 2400, zaxis_1 = 91
+ ! sfc_data.nc: xaxis_1 = 2880, yaxis_1 = 2400, zaxis_1 = 4
+ ! for variables' dimensions:
+ ! grid_lon(2881,2401), grid_lat(2881,2401), grid_lont(2880,2400), grid_latt(2880,2400)
+ ! T(2880,2400,91,1), u(2880,2401,91,1), v(2881,2400,91,1)
+ !
+ !---check dimname to determine if fv_core.res.tile1.nc
+ !k=0; if_fv_core_file = .false.
+ !do n = 1, ndims
+ ! call nccheck(nf90_inquire_dimension(ncid,n,name=dimname, len=i), 'wrong in inquire_dimension', .true.)
+ ! if ( trim(dimname) == 'xaxis_1' .or. trim(dimname) == 'yaxis_2' .or. trim(dimname) == 'xaxis_2' .or. trim(dimname) == 'yaxis_1' ) &
+ ! k=k+1
+ !enddo
+ !if ( k == 4 ) if_fv_core_file = .true.
+
+! 5.1 --- variables' loop
+ do_input_var_loop: do nv=1, nvars
+
+ ! 5.1.1 --- get variable's dimension
+ dimids=-1; vdim=-1
+ call nccheck(nf90_inquire_variable(ncid,nv,varname,xtype,ndims,dimids), &
+ 'wrong in inquire_variable '//trim(varname), .false.)
+
+ do i = 1, ndims
+ call nccheck(nf90_inquire_dimension(ncid,dimids(i), len=vdim(i)), 'wrong in inquire '//trim(varname)//' dim', .false.)
+ enddo
+
+ write(*,'(a,9i6)')'nf90_inquire_variable: '//trim(varname), ndims, vdim(1:ndims), xtype
+ !write(*,'(a,2i6)')' NF90_FLOAT, NF90_DOUBLE=', NF90_FLOAT,NF90_DOUBLE
+
+ !---skip xaxis_1(xaxis_1), yaxis_1(yaxis_1), zaxis_1(zaxis_1)
+ if ( ndims < 2 ) cycle do_input_var_loop
+
+ ! 5.1.2 --- determine mass/u/v grids
+ u_stag=0; v_stag=0
+ if ( ndims == 4 ) then
+ ixi=vdim(1); jxi=vdim(2); kxi=vdim(3); txi=vdim(4)
+ else if ( ndims == 3) then
+ ixi=vdim(1); jxi=vdim(2); kxi=vdim(3); txi=1 !here kxi is time dimension
+ else if ( ndims == 2) then
+ ixi=vdim(1); jxi=vdim(2); kxi=1; txi=1 !grid_lon, grid_lat, grid_lont, grid_latt, area
+ else if ( ndims == 1) then
+ ixi=vdim(1); jxi=1; kxi=1; txi=1 !
+ else
+ write(*,*)' --- var '//trim(varname)//' could not be processed'
+ cycle do_input_var_loop
+ endif
+ if ( ixi /= grid_src%grid_x .and. ixi /= grid_src%grid_xt .and. ixi /= grid_src%grid_y .and. ixi /= grid_src%grid_yt ) then
+ write(*,*)' --- var '//trim(varname)//' dimension does not match the input grids'
+ write(*,'(a,2i5)')' --- input grids dimensions: ', grid_src%grid_xt, grid_src%grid_yt
+ write(*,'(a,2i5)')' --- '//trim(varname)//' dimension: ', ixi, jxi
+ cycle do_input_var_loop
+ endif
+ if (jxi == grid_src%grid_y ) u_stag=1
+ if (ixi == grid_src%grid_x ) v_stag=1
+
+ ! 5.1.3 --- get src data
+ write(*,'(a)')'---get '//trim(varname)//' from '//trim(srcfiles(nf))
+ call nccheck(nf90_inq_varid(ncid, trim(varname), varid), 'wrong in inquire '//trim(varname)//' varid', .false.)
+ allocate(fdat_src(ixi, jxi, kxi, txi))
+ if ( xtype == nf90_float .or. xtype == nf90_real .or. xtype == nf90_real4 ) then
+ call nccheck(nf90_get_var(ncid, varid, fdat_src), 'wrong in get '//trim(varname)//' from '//trim(srcfiles(nf)), .true.)
+ else if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ allocate(ddat_src(ixi, jxi, kxi, txi))
+ call nccheck(nf90_get_var(ncid, varid, ddat_src), 'wrong in get '//trim(varname)//' from '//trim(srcfiles(nf)), .true.)
+ fdat_src=real(ddat_src)
+ deallocate(ddat_src)
+ else
+ write(*,*)' !!!! please add ',xtype,' xtype data here '
+ stop
+ endif
+
+ ! 5.1.4 --- get dst data
+ ixo=grid_dst%grid_xt+v_stag; jxo=grid_dst%grid_yt+u_stag; kxo=kxi; txo=txi !current no vertical/time interpolation
+ allocate(fdat_dst(ixo,jxo,kxo,txo))
+
+ !---inqure the variables from dstfiles(n_dstfl)
+ if ( n_dstfl > 0 ) then
+ noutfl=-1
+ do_search_var_from_dstfiles: do n = 1, n_dstfl
+ call nccheck(nf90_open(trim(dstfiles(n)), nf90_nowrite, ncid1), 'wrong in open '//trim(dstfiles(n)), .false.)
+ rcode=nf90_inq_varid(ncid1, trim(varname), varid1)
+ write(*,'(a,2i6)')'---inq '//trim(varname), rcode, nf90_noerr
+ if ( rcode /= nf90_noerr ) then
+ call nccheck(nf90_close(ncid1), 'wrong in close '//trim(dstfiles(n)), .false.)
+ cycle do_search_var_from_dstfiles
+ else
+ !write(*,'(a,4i5)')'dst grid size: ', ixo,jxo,kxo,txo
+ if ( xtype == nf90_float .or. xtype == nf90_real .or. xtype == nf90_real4 ) then
+ call nccheck(nf90_get_var(ncid1, varid1, fdat_dst), 'wrong in get '//trim(varname)//' from '//trim(dstfiles(n)), .true.)
+ else if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ allocate(ddat_dst(ixo,jxo,kxo,txo))
+ call nccheck(nf90_get_var(ncid1, varid1, ddat_dst), 'wrong in get '//trim(varname)//' from '//trim(dstfiles(n)), .true.)
+ fdat_dst = real(ddat_dst)
+ deallocate(ddat_dst)
+ endif
+ call nccheck(nf90_close(ncid1), 'wrong in close '//trim(dstfiles(n)), .false.)
+ noutfl=n
+ write(*,'(a)')'---get '//trim(varname)//' from '//trim(dstfiles(n))
+ exit do_search_var_from_dstfiles
+ endif
+ enddo do_search_var_from_dstfiles
+ endif !if ( n_dstfl > 0 ) then
+
+ ! 5.1.5 --- merge dat_src + dat_dst --> data_merge: with distance-weightnening average
+ ! --- when output is out of input-grid: xin/yin < 0 or xin/yin > max, fill with output data
+ !----allocate gw, gw=gwt%gwt_t, gwt_u, gwt_v
+ ! fdat_out = sum(fdat_src(gwt%gwt_t%src_x(:),gwt%gwt_t%src_y(:))*gwt%gwt_t%src_weight)) + &
+ ! sum(fdat_dst(gwt%gwt_t%dst_x(:),gwt%gwt_t%dst_y(:))*gwt%gwt_t%dst_weight))
+ !write(*,'(a)')'---combine '//trim(varname)
+ allocate(fdat_out(ixo,jxo,kxo,txo))
+ if ( u_stag == 0 .and. v_stag == 0 ) then
+ call combine_grids_for_remap(ixi, jxi, kxi, txi, fdat_src, ixo, jxo, kxo, txo, fdat_dst, &
+ gwt%gwt_t, fdat_out)
+ !i=2; j=2
+ !write(*,'(a,30i6)')' gwt%gwt_t @ ', i, j, gwt%gwt_t(i,j)%src_points, gwt%gwt_t(i,j)%src_x(1:gwt%gwt_t(i,j)%src_points), &
+ ! gwt%gwt_t(i,j)%src_y(1:gwt%gwt_t(i,j)%src_points)
+ !write(*,'(a,3f10.2)')'src,dst,out =', fdat_src(gwt%gwt_t(i,j)%src_x(1),gwt%gwt_t(i,j)%src_y(1),1,1), &
+ ! fdat_dst(i,j,1,1), fdat_out(i,j,1,1)
+
+ else if ( u_stag == 1 .and. v_stag == 0 ) then
+ call combine_grids_for_remap(ixi, jxi, kxi, txi, fdat_src, ixo, jxo, kxo, txo, fdat_dst, &
+ gwt%gwt_u, fdat_out)
+ else if ( u_stag == 0 .and. v_stag == 1 ) then
+ call combine_grids_for_remap(ixi, jxi, kxi, txi, fdat_src, ixo, jxo, kxo, txo, fdat_dst, &
+ gwt%gwt_v, fdat_out)
+ endif
+ if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ allocate(ddat_out(ixo,jxo,kxo,txo))
+ ddat_out=dble(fdat_out)
+ endif
+
+! --- 5.2, 5.3 -->:
+! alternative method: call FV3 horiz_interp_new
+! calls like: sorc/hafs_forecast.fd/FMS/topography/topography.F90
+! call horiz_interp_new ( Interp, xdat, ydat(js:je+1), blon, blat ) --> horiz_interp_conserve_new_2dx2d
+! call horiz_interp ( Interp, zdat(:,js:je), zout ) --> horiz_interp_conserve_version2
+
+! 5.4 --- output nc4
+ if ( noutfl > 0 ) then
+ call nccheck(nf90_open(trim(dstfiles(noutfl)), nf90_write, ncid1), 'wrong in open '//trim(dstfiles(noutfl)), .false.)
+ call nccheck(nf90_inq_varid(ncid1, trim(varname), varid1), 'wrong in inq_varid '//trim(varname), .false.)
+ if ( xtype == nf90_float .or. xtype == nf90_real .or. xtype == nf90_real4 ) then
+ if ( ndims == 4 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, fdat_out), 'wrong in write '//trim(varname), .false.)
+ else if ( ndims == 3 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, reshape(fdat_out, (/ixo, jxo, kxo/))), 'wrong in write '//trim(varname), .false.)
+ else if ( ndims == 2 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, reshape(fdat_out, (/ixo, jxo/))), 'wrong in write '//trim(varname), .false.)
+ endif
+ else if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ if ( ndims == 4 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, ddat_out), 'wrong in write '//trim(varname), .false.)
+ else if ( ndims == 3 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, reshape(ddat_out, (/ixo, jxo, kxo/))), 'wrong in write '//trim(varname), .false.)
+ else if ( ndims == 2 ) then
+ call nccheck(nf90_put_var(ncid1, varid1, reshape(ddat_out, (/ixo, jxo/))), 'wrong in write '//trim(varname), .false.)
+ endif
+ endif
+ call nccheck(nf90_close(ncid1), 'wrong in close '//trim(dstfiles(noutfl)), .false.)
+
+ endif !if ( noutfl > 0 ) then
+
+! 5.5 --- deallocate
+ !write(*,*)'---clean up'
+ if (allocated(fdat_src)) deallocate(fdat_src)
+ if (allocated(ddat_src)) deallocate(ddat_src)
+ if (allocated(fdat_dst)) deallocate(fdat_dst)
+ if (allocated(ddat_dst)) deallocate(ddat_dst)
+ if (allocated(fdat_out)) deallocate(fdat_out)
+ if (allocated(ddat_out)) deallocate(ddat_out)
+
+ enddo do_input_var_loop
+
+ enddo do_inputfiles_loop
+!------------------------------------------------------------------------------
+
+ end subroutine hafs_remap
+
+!========================================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafsvi_proc.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafsvi_proc.f90
new file mode 100644
index 000000000..08f287542
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_hafsvi_proc.f90
@@ -0,0 +1,898 @@
+!========================================================================================
+ subroutine hafsvi_preproc(in_dir, in_date, nestdoms, radius, res, out_file)
+
+!-----------------------------------------------------------------------------
+! HAFS DA tool - hafsvi_preproc
+! Yonghui Weng, 20211210
+!
+! This subroutine read hafs restart files and output hafsvi needed input.
+! Variables needed:
+! WRITE(IUNIT) NX,NY,NZ
+! WRITE(IUNIT) lon1,lat1,lon2,lat2,cen_lon,cen_lat
+! WRITE(IUNIT) (((pf1(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1) ! 3D, NZ
+! WRITE(IUNIT) (((tmp(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+! WRITE(IUNIT) (((spfh(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+! WRITE(IUNIT) (((ugrd(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+! WRITE(IUNIT) (((vgrd(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+! WRITE(IUNIT) (((dzdt(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+!! WRITE(IUNIT) hgtsfc ! 2D
+! WRITE(IUNIT) (((z1(i,j,k),i=1,nx),j=1,ny),k=nz1,1,-1)
+! WRITE(IUNIT) glon,glat,glon,glat ! 2D
+! WRITE(IUNIT) (((ph1(i,j,k),i=1,nx),j=1,ny),k=nz1,1,-1) ! 3D, NZ+1
+! WRITE(IUNIT) pressfc1 ! 2D
+! WRITE(IUNIT) ak
+! WRITE(IUNIT) bk
+! WRITE(IUNIT) land ! =A101 = land sea mask, B101 = ZNT
+! WRITE(IUNIT) sfcr ! =B101 = Z0
+! WRITE(IUNIT) C101 ! =C101 = (10m wind speed)/(level 1 wind speed)
+!
+
+!-----------------------------------------------------------------------------
+
+ use constants
+ use netcdf
+ use module_mpi
+ use var_type
+
+ implicit none
+
+ character (len=*), intent(in) :: in_dir, in_date, radius, res, out_file
+ integer, intent(in) :: nestdoms
+!--- in_dir, HAFS_restart_folder, which holds grid_spec.nc, fv_core.res.tile1.nc,
+! fv_srf_wnd.res.tile1.nc, fv_tracer.res.tile1.nc, phy_data.nc, sfc_data.nc
+!--- in_date, HAFS_restart file date, like 20200825.120000
+!--- radius, to cut a square, default value is 40, which means a 40deg x 40deg square.
+!--- out_file: output file, default is bin format, if the file name is *.nc, then output nc format.
+!--- nestdoms: total nest domain number: 0-no nesting
+!--- 1-nest02.tile2 + 0
+!--- 2-nest03.tile3 + 1
+
+ character (len=2500) :: indir, infile
+ character (len=2500) :: infile_fvcore, infile_core, infile_tracer, infile_phy, infile_sfc, infile_grid, infile_grid2, infile_atmos, infile_oro
+ type(grid2d_info) :: dstgrid ! rot-ll grid for output
+ type(grid2d_info) :: ingrid ! hafs restart grid
+ real :: radiusf
+ logical :: file_exist
+
+!----for hafs restart
+ integer :: ix, iy, iz, kz, ndom, nd
+ character (len=50) :: nestfl, tilefl, tempfl
+ ! grid_spec.nc : grid_spec.nest02.tile2.nc
+ ! fv_core.res.tile1.nc : fv_core.res.nest02.tile2.nc
+ ! phy_data.nc : phy_data.nest02.tile2.nc
+
+!----for hafsvi
+ integer :: nx, ny, nz, filetype ! filetype: 1=bin, 2=nc
+ real :: lon1,lat1,lon2,lat2,cen_lat,cen_lon,dlat,dlon
+ real, allocatable, dimension(:,:) :: glon,glat
+
+ integer :: i, j, k, flid_in, flid_out, ncid, ndims, nrecord
+ real :: rot_lon, rot_lat, ptop
+ integer, dimension(nf90_max_var_dims) :: dims
+ real, allocatable, dimension(:,:,:,:) :: dat4, dat41, dat42, dat43, u, v
+ real, allocatable, dimension(:,:,:) :: dat3, dat31
+ real, allocatable, dimension(:,:) :: dat2, dat21, sfcp
+ real, allocatable, dimension(:) :: dat1
+
+ !real, allocatable, dimension(:) :: pfull, phalf
+ real, allocatable, dimension(:,:) :: cangu, sangu, cangv, sangv
+ real :: cputime1, cputime2, cputime3
+
+!------------------------------------------------------------------------------
+! 1 --- arg process
+!
+! 1.1 --- ndom
+ ndom=nestdoms+1
+
+
+! 1.2 --- input_dir
+ if (len_trim(in_dir) < 2 .or. trim(in_dir) == 'w' .or. trim(in_dir) == 'null') then
+ indir='.'
+ else
+ indir=trim(in_dir)
+ endif
+
+ if (trim(radius) == 'w' .or. trim(radius) == 'null') then
+ radiusf = 40. !deg
+ else
+ read(radius,*)i
+ radiusf = real(i)
+ if ( radiusf < 3. .or. radiusf > 70. ) then
+ write(*,'(a)')'!!! hafsvi cut radius number wrong: '//trim(radius)
+ write(*,'(a)')'!!! please call with --vortexradius=40 (75< 3)'
+ stop 'hafsvi_preproc'
+ endif
+ endif
+
+ if (trim(res) == 'w' .or. trim(res) == 'null') then
+ dlat=0.02
+ else
+ read(res,*)dlat
+ endif
+ dlon=dlat
+
+!------------------------------------------------------------------------------
+! 2 --- set dstgrid: rot-ll grid
+! 2.1 --- define rot-ll grid
+ cen_lat = tc%lat
+ cen_lon = tc%lon
+ nx = int(radiusf/2.0/dlon+0.5)*2+1
+ ny = int(radiusf/2.0/dlat+0.5)*2+1
+ lon1 = - radiusf/2.0
+ lat1 = - radiusf/2.0
+ lon2 = radiusf/2.0
+ lat2 = radiusf/2.0
+ !!--- get rot-ll grid
+ allocate(glon(nx,ny), glat(nx,ny))
+ do j = 1, ny; do i = 1, nx
+ rot_lon = lon1 + dlon*(i-1)
+ rot_lat = lat1 + dlat*(j-1)
+ call rtll(rot_lon, rot_lat, glon(i,j), glat(i,j), cen_lon, cen_lat)
+ enddo; enddo
+ write(*,'(a)')'---rot-ll grid: nx, ny, cen_lon, cen_lat, dlon, dlat, lon1, lon2, lat1, lat2'
+ write(*,'(15x,2i5,8f10.5)') nx, ny, cen_lon, cen_lat, dlon, dlat, lon1, lon2, lat1, lat2
+ !write(*,'(a,4f10.5)')'---rot-ll grid rot_lon:', glon(1,1), glon(1,ny), glon(nx,ny), glon(nx,1)
+ !write(*,'(a,4f10.5)')'---rot-ll grid rot_lat:', glat(1,1), glat(1,ny), glat(nx,ny), glat(nx,1)
+
+! 2.2 --- set dstgrid
+ dstgrid%grid_x = nx
+ dstgrid%grid_y = ny
+ dstgrid%ntime = 1
+ dstgrid%grid_xt = nx
+ dstgrid%grid_yt = ny
+ allocate(dstgrid%grid_lon (dstgrid%grid_x,dstgrid%grid_y))
+ allocate(dstgrid%grid_lont(dstgrid%grid_x,dstgrid%grid_y))
+ dstgrid%grid_lon = glon
+ dstgrid%grid_lont = glon
+ allocate(dstgrid%grid_lat (dstgrid%grid_x,dstgrid%grid_y))
+ allocate(dstgrid%grid_latt(dstgrid%grid_x,dstgrid%grid_y))
+ dstgrid%grid_lat = glat
+ dstgrid%grid_latt = glat
+
+!------------------------------------------------------------------------------
+! 3 --- process output file type: now is only for bin
+! i=len_trim(out_file)
+! if ( out_file(i-2:i) == '.nc' ) then
+! write(*,'(a)')' --- output to '//trim(out_file)
+! filetype=2
+! call nccheck(nf90_open(trim(out_file), nf90_write, flid), 'wrong in open '//trim(out_file), .true.)
+! else
+! filetype=1
+! flid=71
+! open(unit=flid,file=trim(out_file),form='unformatted',status='unknown')
+! endif
+
+!------------------------------------------------------------------------------
+!------------------------------------------------------------------------------
+! --- domain loop: from inner domain to outer domain, so the number is from max to 1
+ do_nestdom_loop: do nd = 1, ndom
+
+ !-------------------------------------------------------------------------
+ ! 3 --- initialization: clean ingrid, weight
+ ! ingrid%grid_x=-99; ingrid%grid_y=-99; ingrid%grid_xt=-99; ingrid%grid_yt=-99
+
+ !-------------------------------------------------------------------------
+ ! 4 --- input grid info
+ ! read from grid file grid_spec.nc:
+ ! nestfl, tilefl: infile_core, infile_tracer, infile_grid, infile_atmos, infile_oro
+ write(nestfl,'(a4,i2.2)')'nest',nd
+ write(tilefl,'(a4,i0)')'tile',nd
+ if ( nd == 1 ) then
+ infile_grid=trim(indir)//'/grid_spec.nc'
+ infile_grid2=trim(indir)//'/grid_mspec_'//in_date(1:4)//'_'//in_date(5:6)//'_'//in_date(7:8)//'_'//in_date(10:11)//'.nc'
+ infile_oro =trim(indir)//'/oro_data.nc'
+ infile_atmos=trim(indir)//'/atmos_static.nc'
+ infile_fvcore=trim(indir)//'/'//trim(in_date)//'.fv_core.res.nc'
+ infile_core=trim(indir)//'/'//trim(in_date)//'.fv_core.res.tile1.nc'
+ infile_tracer=trim(indir)//'/'//trim(in_date)//'.fv_tracer.res.tile1.nc'
+ infile_phy =trim(indir)//'/'//trim(in_date)//'.phy_data.nc'
+ infile_sfc =trim(indir)//'/'//trim(in_date)//'.sfc_data.nc'
+ else
+ infile_grid=trim(indir)//'/grid_spec.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_grid2=trim(indir)//'/grid_mspec.'//trim(nestfl)//'_'//in_date(1:4)//'_'//in_date(5:6)//'_'//in_date(7:8)//'_'//in_date(10:11)//'.'//trim(tilefl)//'.nc'
+ infile_oro =trim(indir)//'/oro_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_atmos=trim(indir)//'/atmos_static.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_fvcore=trim(indir)//'/'//trim(in_date)//'.fv_core.res.'//trim(nestfl)//'.nc'
+ infile_core=trim(indir)//'/'//trim(in_date)//'.fv_core.res.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_tracer=trim(indir)//'/'//trim(in_date)//'.fv_tracer.res.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_phy =trim(indir)//'/'//trim(in_date)//'.phy_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ infile_sfc =trim(indir)//'/'//trim(in_date)//'.sfc_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ endif
+
+ inquire(file=infile_grid2, exist=file_exist)
+ if ( file_exist ) infile_grid = infile_grid2
+
+ if ( debug_level > 10 ) write(*,'(a)')' --- read grid info from '//trim(infile_grid)
+ call rd_grid_spec_data(trim(infile_grid), ingrid)
+ ix=ingrid%grid_xt
+ iy=ingrid%grid_yt
+ if ( debug_level > 10 ) then
+ write(*,'(a,i,1x,i,1x,f,1x,f,1x,f,1x,f)')' --- ingrid info: ', ix, iy, &
+ ingrid%grid_lon(int(ix/2), int(iy/2)), ingrid%grid_lat(int(ix/2), int(iy/2)), &
+ ingrid%grid_lont(int(ix/2), int(iy/2)), ingrid%grid_latt(int(ix/2), int(iy/2))
+ endif
+
+ !---to add the test if the tc was inside of the domain
+
+
+ ! call FV3-grid cos and sin
+ allocate( cangu(ix,iy+1),sangu(ix,iy+1),cangv(ix+1,iy),sangv(ix+1,iy) )
+ call cal_uv_coeff_fv3(ix, iy, ingrid%grid_lat, ingrid%grid_lon, cangu, sangu, cangv, sangv)
+
+ !-------------------------------------------------------------------------
+ ! 5 --- calculate output-grid in input-grid's positions (xin, yin), and each grid's weight to dst
+ if ( debug_level > 10 ) then
+ write(*,'(a)')' --- call cal_src_dst_grid_weight'
+ write(*,'(a,2(I,1x),2(f,1x))')' --- dstgrid: ', nx, ny, &
+ dstgrid%grid_lont(int(nx/2),int(ny/2)), dstgrid%grid_latt(int(nx/2),int(ny/2))
+ endif
+ call cal_src_dst_grid_weight(ingrid, dstgrid)
+
+ !-------------------------------------------------------------------------
+ ! 6 --- dst files
+ flid_in=71 !inner domain rot-ll file
+ flid_out=72 !current domain rot-ll file
+ if ( nd == 1 ) then
+ open(unit=flid_out,file=trim(out_file),form='unformatted',status='unknown')
+ else
+ open(unit=flid_out,file=trim(out_file)//'_'//trim(nestfl),form='unformatted',status='unknown')
+ endif
+ if ( nd == 2 ) then !if ( nd >= 1 .and. nd < ndom .and. ndom > 1 ) then
+ open(unit=flid_in,file=trim(out_file),form='unformatted',status='old')
+ elseif ( nd > 2 ) then !if ( nd >= 1 .and. nd < ndom .and. ndom > 1 ) then
+ write(tempfl,'(a4,i2.2)')'nest',nd-1
+ open(unit=flid_in,file=trim(out_file)//'_'//trim(tempfl),form='unformatted',status='old')
+ endif
+
+ !-------------------------------------------------------------------------
+ ! 7 --- output
+ do_out_var_loop: do nrecord = 1, 17
+ !-----------------------------
+ !---7.1 record 1: nx, ny, nz
+ !---nx, ny, nz, & lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ call cpu_time(cputime1)
+ write(*,'(a,i3,f)')' --- record start cputime: ', nrecord, cputime1
+ if ( nrecord == 1 ) then
+ call get_var_dim(trim(infile_atmos), 'pfull', ndims, dims)
+ nz=dims(1)
+ iz=nz !same vertical levels
+
+ write(*,'(a,3i6)')'=== record1: ',nx, ny, nz
+ write(flid_out) nx, ny, nz
+ if ( nd > 1 ) read(flid_in)
+ endif
+
+ !-----------------------------
+ !---7.2 record 2: lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ if ( nrecord == 2 ) then
+ write(*,'(a,6f8.3)')'=== record2: ',lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ write(flid_out) lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ if ( nd > 1 ) read(flid_in)
+ endif
+
+ !-----------------------------
+ !---7.3 record 3: (((pf1(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ !--- hafs-VI/read_hafs_out.f90 pf:
+ !--- ph(k) = ak(k) + bk(k)*p_s --> half level pressure
+ !--- pf(k) = (ph(k+1) - ph(k)) / log(ph(k+1)/ph(k)) --> full level pressure
+ !---
+ !---seem pf1 is pressure on full level, use
+ !--- pf1(k) = phalf(1) + sum(delp(1:k))
+ if ( nrecord == 3 ) then
+ allocate(dat4(iz+1,1,1,1))
+ call get_var_data(trim(infile_atmos), 'phalf', iz+1, 1, 1, 1, dat4)
+ ptop=dat4(1,1,1,1)*100. !phalf:units = "mb" ;
+ deallocate(dat4)
+
+ allocate(dat4(ix, iy, iz,1))
+ allocate(dat41(ix, iy, iz,1))
+ allocate(dat2(ix, iy))
+ !write(*,'(a,3i5)')'delp: ',ix, iy, iz
+ call get_var_data(trim(infile_core), 'delp', ix, iy, iz,1, dat4)
+ dat2(:,:)=ptop
+ do k = 1, iz
+ dat41(:,:,k,1)=dat2(:,:)+dat4(:,:,k,1)/2.0
+ dat2(:,:)=dat2(:,:)+dat4(:,:,k,1)
+ enddo
+ allocate(sfcp(ix, iy))
+ sfcp=dat41(:,:,iz,1)
+ deallocate(dat2,dat4)
+ endif
+
+ !-----------------------------
+ !---7.4 record 4: (((tmp(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ if ( nrecord == 4 ) then
+ allocate(dat4(ix, iy, iz,1))
+ call get_var_data(trim(infile_core), 'T', ix, iy, iz,1, dat4)
+ !--- need any other processing?
+ allocate(dat41(ix, iy, iz,1))
+ dat41=dat4*1.0
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.5 record 5: (((spfh(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ if ( nrecord == 5 ) then
+ allocate(dat4(ix, iy, iz,1))
+ call get_var_data(trim(infile_tracer), 'sphum', ix, iy, iz,1, dat4)
+ allocate(dat41(ix, iy, iz,1))
+ dat41=dat4*1.0
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.6 record 6: (((ugrd(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ !---7.7 record 7: (((vgrd(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ if ( nrecord == 6 ) then
+ !---get u,v from restart
+ allocate(dat41(ix, iy+1, iz,1), dat42(ix+1, iy, iz, 1))
+ call get_var_data(trim(infile_core), 'u', ix, iy+1, iz, 1, dat41)
+ call get_var_data(trim(infile_core), 'v', ix+1, iy, iz, 1, dat42)
+
+ !---convert u,v from fv3grid to earth
+ allocate(u(ix, iy, iz,1), v(ix, iy, iz, 1))
+ allocate(dat2(ix, iy+1), dat21(ix+1, iy))
+ do k = 1, iz
+ call fv3uv2earth(ix, iy, dat41(:,:,k,1), dat42(:,:,k,1), cangu, sangu, cangv, sangv, dat2, dat21)
+ !---destage: C-/D- grid to A-grid
+ u(:,:,k,1) = (dat2 (:,1:iy)+dat2 (:,2:iy+1))/2.0
+ v(:,:,k,1) = (dat21(1:ix,:)+dat21(2:ix+1,:))/2.0
+ enddo
+
+ deallocate(dat41, dat42, dat2, dat21, cangu, sangu, cangv, sangv)
+ endif
+
+ !-----------------------------
+ !---7.8 record 8: (((dzdt(i,j,k),i=1,nx),j=1,ny),k=nz,1,-1)
+ if ( nrecord == 8 ) then
+ allocate(dat4(ix, iy+1, iz,1))
+ call get_var_data(trim(infile_core), 'W', ix, iy, iz,1, dat4)
+
+ !-- w (m/s) or omega (pa/s) is needed here?
+ allocate(dat41(ix, iy, iz,1))
+ dat41=dat4*1.0
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.9 record 9: (((z1(i,j,k),i=1,nx),j=1,ny),k=nz1,1,-1)
+ !--- hafs-VI/read_hafs_out.f90 z1:
+ !--- z1(I,J,K)=z1(I,J,K+1)+rdgas1*tmp(i,j,k)*(1.+0.608*spfh(i,j,k))*ALOG(ph1(i,j,k+1)/ph1(i,j,k))
+ !--- hgt: phis/g-sum(DZ)
+ if ( nrecord == 9 ) then
+ allocate(dat4(ix, iy, 1,1))
+ call get_var_data(trim(infile_core), 'phis', ix, iy, 1, 1, dat4)
+ allocate(dat41(ix, iy, iz+1, 1))
+ dat41(:,:,iz+1,1)=dat4(:,:,1,1)/g
+ deallocate(dat4)
+
+ allocate(dat4(ix, iy, iz, 1))
+ call get_var_data(trim(infile_core), 'DZ', ix, iy, iz, 1, dat4)
+ do k = iz, 1, -1
+ dat41(:,:,k,1)=dat41(:,:,k+1,1)-dat4(:,:,k,1)
+ enddo
+ !write(*,'(a,200f)')'z1: ',dat41(int(ix/2),int(iy/2),:,1)
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.10 record 10: glon,glat,glon,glat ! 2D
+ !--- glat=grid_yt*180./pi, grid_yt=1:2160, what is this?
+ if ( nrecord == 10 ) then
+ !write(*,'(a,4i8)')'=== record10: ',ix, iy, nx, ny
+ write(*,'(a,4f8.3)')'=== record10: ',glon(1,1), glat(1,1), glon(nx,ny), glat(nx,ny)
+ write(flid_out) glon,glat,glon,glat
+ if ( nd > 1 ) read(flid_in)
+ endif
+
+ !-----------------------------
+ !---7.11 record 11: (((ph1(i,j,k),i=1,nx),j=1,ny),k=nz1,1,-1)
+ !--- hafs-VI/read_hafs_out.f90 ph:
+ !--- ph(k) = ak(k) + bk(k)*p_s --> pressure in pa
+ !--- 64.270-->100570
+ !---seem ph1 is pressure on half level, use
+ !--- pf1(k) = phalf(1) + sum(delp(1:k))
+ if ( nrecord == 11 ) then
+ allocate(dat4(iz+1,1,1,1))
+ call get_var_data(trim(infile_atmos), 'phalf', iz+1, 1, 1, 1, dat4)
+ ptop=dat4(1,1,1,1)*100. !phalf:units = "mb" ;
+ deallocate(dat4)
+
+ allocate(dat4(ix, iy, iz,1))
+ allocate(dat41(ix, iy, iz+1,1))
+ call get_var_data(trim(infile_core), 'delp', ix, iy, iz,1, dat4)
+ dat41(:,:,1,1)=ptop
+ do k = 1, iz
+ dat41(:,:,k+1,1)=dat41(:,:,k,1)+dat4(:,:,k,1)
+ enddo
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.12 record 12: pressfc1 ! 2D
+ !--- use lowest-level pressure?
+ if ( nrecord == 12 ) then
+ allocate(dat41(ix, iy, 1, 1))
+ dat41(:,:,1,1)=sfcp(:,:)
+ deallocate(sfcp)
+ endif
+
+ !-----------------------------
+ !---7.13 record 13: ak
+ if ( nrecord == 13 ) then
+ allocate(dat4(iz+1,1,1,1))
+ call get_var_data(trim(infile_fvcore), 'ak', iz+1, 1, 1, 1, dat4)
+ write(*,'(a,200f12.1)')'=== record13: ', (dat4(k,1,1,1),k=1,iz+1)
+ write(flid_out) (dat4(k,1,1,1),k=1,iz+1)
+ if ( nd > 1 ) read(flid_in)
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.14 record 14: bk
+ if ( nrecord == 14 ) then
+ allocate(dat4(iz+1,1,1,1))
+ call get_var_data(trim(infile_fvcore), 'bk', iz+1, 1, 1, 1, dat4)
+ write(*,'(a,200f10.3)')'=== record14: ', (dat4(k,1,1,1),k=1,iz+1)
+ write(flid_out) (dat4(k,1,1,1),k=1,iz+1)
+ if ( nd > 1 ) read(flid_in)
+ deallocate(dat4)
+ endif
+
+ !-----------------------------
+ !---7.15 record 15: land ! =A101 = land sea mask, B101 = ZNT
+ !--- hafs-VI/read_hafs_out.f90 land:long_name = "sea-land-ice mask (0-sea, 1-land, 2-ice)" ;
+ !--- sfc_data.nc: slmsk
+ if ( nrecord == 15 ) then
+ allocate(dat41(ix, iy, 1,1))
+ call get_var_data(trim(infile_sfc), 'slmsk', ix, iy, 1, 1, dat41)
+ endif
+
+ !-----------------------------
+ !---7.16 record 16: sfcr ! =B101 = Z0
+ !---surface roughness
+ if ( nrecord == 16 ) then
+ allocate(dat41(ix, iy, 1,1))
+ call get_var_data(trim(infile_sfc), 'zorl', ix, iy, 1, 1, dat41)
+ ! convert from cm to m
+ dat41=dat41/100.
+ endif
+
+ !-----------------------------
+ !---7.17 record 17: C101 ! =C101 = (10m wind speed)/(level 1 wind speed)
+ !--- ! =C101 = f10m (in the sfc_data.nc)
+ if ( nrecord == 17 ) then
+ allocate(dat41(ix, iy, 1, 1))
+ call get_var_data(trim(infile_sfc), 'f10m', ix, iy, 1, 1, dat41)
+ endif
+
+ !-----------------------------
+ !---7.18 output 3d
+ if ( nrecord == 3 .or. nrecord == 4 .or. nrecord == 5 .or. &
+ nrecord == 8 .or. nrecord == 9 .or. nrecord ==11 .or. &
+ nrecord ==12 .or. nrecord ==15 .or. nrecord ==16 .or. nrecord ==17 ) then
+ kz=nz
+ if ( nrecord == 12 .or. nrecord == 15 .or. nrecord == 16 .or. nrecord ==17 ) then
+ kz=1
+ endif
+ if ( nrecord == 9 .or. nrecord == 11 ) then
+ kz=nz+1
+ endif
+ !--- map fv3 grid to rot-ll grid: ingrid-->dstgrid
+ !call cpu_time(cputime2)
+ !write(*,'(a,i3,f)')' --- read rot-ll grid for 1 record ', nrecord, cputime2
+ allocate(dat42(nx,ny,kz,1), dat43(nx,ny,kz,1))
+ if ( nd > 1 ) then
+ read(flid_in)dat43
+ do k = 1, kz
+ dat42(:,:,k,1)=dat43(:,:,kz-k+1,1)
+ enddo
+ dat43=-999999.
+ else
+ dat42=-9999999.;
+ endif
+ call combine_grids_for_remap(ix,iy,kz,1,dat41,nx,ny,kz,1,dat42,gwt%gwt_t,dat43)
+
+ !--- output
+ !write(*,'(a,i2.2,a,200f)')'=== record',nrecord,': ', dat43(int(nx/2),int(ny/2),:,1)
+ write(flid_out) (((dat43(i,j,k,1),i=1,nx),j=1,ny),k=kz,1,-1)
+ deallocate(dat41, dat42, dat43)
+ else if ( nrecord == 6 ) then !---u,v
+ kz=nz
+ !--- map u to rot-ll grid: ingrid-->dstgrid
+ allocate(dat42(nx,ny,kz,1), dat43(nx,ny,kz,1))
+ if ( nd > 1 ) then
+ !read(flid_in)(((dat42(i,j,k,1),i=1,nx),j=1,ny),k=kz,1,-1)
+ read(flid_in)dat43
+ do k = 1, kz
+ dat42(:,:,k,1)=dat43(:,:,kz-k+1,1)
+ enddo
+ dat43=-999999.
+ else
+ dat42=-9999999.; dat43=0.0
+ endif
+ call combine_grids_for_remap(ix,iy,kz,1,u,nx,ny,kz,1,dat42,gwt%gwt_t,dat43)
+ write(flid_out) (((dat43(i,j,k,1),i=1,nx),j=1,ny),k=kz,1,-1)
+ if ( nd > 1 ) then
+ !read(flid_in)(((dat42(i,j,k,1),i=1,nx),j=1,ny),k=kz,1,-1)
+ read(flid_in)dat43
+ do k = 1, kz
+ dat42(:,:,k,1)=dat43(:,:,kz-k+1,1)
+ enddo
+ dat43=-999999.
+ else
+ dat42=-9999999.; dat43=0.0
+ endif
+ call combine_grids_for_remap(ix,iy,kz,1,v,nx,ny,kz,1,dat42,gwt%gwt_t,dat43)
+ write(flid_out) (((dat43(i,j,k,1),i=1,nx),j=1,ny),k=kz,1,-1)
+ deallocate(u, v, dat42, dat43)
+ endif
+
+ enddo do_out_var_loop !: for nrecord = 1, 17
+
+ !-------------------------------------------------------------------------
+ ! 8 --- clean ingrid gwt
+ deallocate( ingrid%grid_lon, ingrid%grid_lat, ingrid%grid_lont, ingrid%grid_latt)
+ deallocate( gwt%gwt_t, gwt%gwt_u, gwt%gwt_v )
+
+ enddo do_nestdom_loop !: do nd = 1, ndom
+
+ return
+ end subroutine hafsvi_preproc
+
+!========================================================================================
+ subroutine hafsvi_postproc(in_file, in_date, out_dir, nestdoms)
+
+!-----------------------------------------------------------------------------
+! HAFS DA tool - hafsvi_postproc
+! Yonghui Weng, 20220121
+!
+! This subroutine reads hafs_vi binary output file and merge it to hafs restart files.
+! hafs_vi binary output:
+! WRITE(IUNIT) NX,NY,NZ,I360
+! WRITE(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+! WRITE(IUNIT) PMID1
+! WRITE(IUNIT) T1
+! WRITE(IUNIT) Q1
+! WRITE(IUNIT) U1
+! WRITE(IUNIT) V1
+! WRITE(IUNIT) DZDT
+! WRITE(IUNIT) Z1
+!! WRITE(IUNIT) GLON,GLAT
+! WRITE(IUNIT) HLON,HLAT,VLON,VLAT
+! WRITE(IUNIT) P1
+! WRITE(IUNIT) PD1
+! WRITE(IUNIT) ETA1
+! WRITE(IUNIT) ETA2
+!
+! ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+! ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+! ALLOCATE ( Z1(NX,NY,NZ+1),P1(NX,NY,NZ+1) )
+! ALLOCATE ( GLON(NX,NY),GLAT(NX,NY) )
+! ALLOCATE ( PD1(NX,NY),ETA1(NZ+1),ETA2(NZ+1) )
+! ALLOCATE ( USCM(NX,NY),VSCM(NX,NY) ) ! Env. wind at new grids
+! ALLOCATE ( HLON(NX,NY),HLAT(NX,NY) )
+! ALLOCATE ( VLON(NX,NY),VLAT(NX,NY) )
+! ALLOCATE ( PMID1(NX,NY,NZ),ZMID1(NX,NY,NZ) )
+
+!-----------------------------------------------------------------------------
+
+ use constants
+ use netcdf
+ use module_mpi
+ use var_type
+
+ implicit none
+
+ character (len=*), intent(in) :: in_file, & ! The VI output binary file on 30x30degree
+ in_date, & ! HAFS_restart file date, like 20200825.120000
+ out_dir ! HAFS_restart_folder, which holds grid_spec.nc, fv_core.res.tile1.nc,
+ ! fv_srf_wnd.res.tile1.nc, fv_tracer.res.tile1.nc, phy_data.nc, sfc_data.nc
+ integer, intent(in) :: nestdoms
+
+ type(grid2d_info) :: ingrid ! hafs restart grid
+ type(grid2d_info) :: dstgrid ! rot-ll grid for output
+
+!----for hafs restart
+ integer :: ix, iy, iz, kz, ndom, nd
+ character(len=2500) :: ncfile
+ character (len=2500) :: ncfile_fvcore, ncfile_core, ncfile_tracer, ncfile_phy, ncfile_sfc, ncfile_grid, ncfile_grid2, ncfile_atmos, ncfile_oro
+ character (len=50) :: nestfl, tilefl, tempfl
+ ! grid_spec.nc : grid_spec.nest02.tile2.nc
+ ! fv_core.res.tile1.nc : fv_core.res.nest02.tile2.nc
+ ! phy_data.nc : phy_data.nest02.tile2.nc
+
+
+!----for hafsvi
+ integer :: nx, ny, nz, i360, filetype ! filetype: 1=bin, 2=nc
+ real :: lon1,lat1,lon2,lat2,cen_lat,cen_lon,dlat,dlon
+ real, allocatable, dimension(:,:) :: hlon, hlat, vlon, vlat
+
+ integer :: i, j, k, n, flid, ncid, ndims, nrecord, iunit
+ real, allocatable, dimension(:,:,:,:) :: dat4, dat41, dat42, dat43, phis1, phis2, sfcp1, sfcp2, u1, v1, u, v
+ real, allocatable, dimension(:,:,:) :: dat3, dat31
+ real, allocatable, dimension(:,:) :: dat2, dat21
+ real, allocatable, dimension(:) :: dat1
+ real :: ptop
+ logical :: file_exist
+
+ real, allocatable, dimension(:,:) :: cangu, sangu, cangv, sangv
+
+!------------------------------------------------------------------------------
+! 1 --- arg process
+! 1.1 --- ndom
+ ndom=nestdoms+1
+
+!------------------------------------------------------------------------------
+! 2 --- input grid info
+
+ !-----------------------------
+ !---2.1 get input grid info from binary file
+ iunit=36
+ open(iunit, file=trim(in_file), form='unformatted')
+ read(iunit) nx, ny, nz, i360
+ write(*,'(a,4i5)')'nx, ny, nz, i360 = ',nx, ny, nz, i360
+ read(iunit) lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ write(*,'(a,6f10.3)')'lon1,lat1,lon2,lat2,cen_lon,cen_lat =', lon1,lat1,lon2,lat2,cen_lon,cen_lat
+
+ !!---add to test vortex-replacement
+ !tc%vortexrep=1
+ !tc%lat=cen_lat
+ !tc%lon=cen_lon
+ !!---add to test vortex-replacement
+
+ do i = 1, 7
+ read(iunit)
+ enddo
+ allocate(hlon(nx,ny), hlat(nx,ny), vlon(nx,ny), vlat(nx,ny))
+ read(iunit)hlon, hlat, vlon, vlat
+ write(*, '(a,8f10.3)')' hlon,hlat(1,1; nx,1; nx,ny; 1,ny) =', &
+ hlon(1,1), hlat(1,1), hlon(nx,1), hlat(nx,1), hlon(nx,ny), hlat(nx,ny), hlon(1,ny), hlat(1,ny)
+ write(*, '(a,8f10.3)')' vlon,vlat(1,1; nx,1; nx,ny; 1,ny) =', &
+ vlon(1,1), vlat(1,1), vlon(nx,1), vlat(nx,1), vlon(nx,ny), vlat(nx,ny), vlon(1,ny), vlat(1,ny)
+
+ !-----------------------------
+ !---2.2 define input rot-ll grids
+ ingrid%grid_x = nx
+ ingrid%grid_y = ny
+ ingrid%ntime = 1
+ ingrid%grid_xt = nx
+ ingrid%grid_yt = ny
+ allocate(ingrid%grid_lon (ingrid%grid_x,ingrid%grid_y))
+ allocate(ingrid%grid_lont(ingrid%grid_x,ingrid%grid_y))
+ ingrid%grid_lon = hlon
+ ingrid%grid_lont = vlon
+ allocate(ingrid%grid_lat (ingrid%grid_x,ingrid%grid_y))
+ allocate(ingrid%grid_latt(ingrid%grid_x,ingrid%grid_y))
+ ingrid%grid_lat = hlat
+ ingrid%grid_latt = vlat
+
+!------------------------------------------------------------------------------
+! --- domain loop: from inner domain to outer domain, so the number is from max to 1
+ do_nestdom_loop: do nd = ndom, ndom
+
+ !-------------------------------------------------------------------------
+ ! 3 --- input file
+ ! nestfl, tilefl: ncfile_core, ncfile_tracer, ncfile_grid, ncfile_atmos, ncfile_oro
+ write(nestfl,'(a4,i2.2)')'nest',nd
+ write(tilefl,'(a4,i0)')'tile',nd
+ if ( nd == 1 ) then
+ ncfile_grid=trim(out_dir)//'/grid_spec.nc'
+ ncfile_grid2=trim(out_dir)//'/grid_mspec_'//in_date(1:4)//'_'//in_date(5:6)//'_'//in_date(7:8)//'_'//in_date(10:11)//'.nc'
+ ncfile_oro =trim(out_dir)//'/oro_data.nc'
+ ncfile_atmos=trim(out_dir)//'/atmos_static.nc'
+ ncfile_fvcore=trim(out_dir)//'/'//trim(in_date)//'.fv_core.res.nc'
+ ncfile_core=trim(out_dir)//'/'//trim(in_date)//'.fv_core.res.tile1.nc'
+ ncfile_tracer=trim(out_dir)//'/'//trim(in_date)//'.fv_tracer.res.tile1.nc'
+ ncfile_phy =trim(out_dir)//'/'//trim(in_date)//'.phy_data.nc'
+ ncfile_sfc =trim(out_dir)//'/'//trim(in_date)//'.sfc_data.nc'
+ else
+ ncfile_grid=trim(out_dir)//'/grid_spec.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_grid2=trim(out_dir)//'/grid_mspec.'//trim(nestfl)//'_'//in_date(1:4)//'_'//in_date(5:6)//'_'//in_date(7:8)//'_'//in_date(10:11)//'.'//trim(tilefl)//'.nc'
+ ncfile_oro =trim(out_dir)//'/oro_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_atmos=trim(out_dir)//'/atmos_static.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_fvcore=trim(out_dir)//'/'//trim(in_date)//'.fv_core.res.'//trim(nestfl)//'.nc'
+ ncfile_core=trim(out_dir)//'/'//trim(in_date)//'.fv_core.res.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_tracer=trim(out_dir)//'/'//trim(in_date)//'.fv_tracer.res.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_phy =trim(out_dir)//'/'//trim(in_date)//'.phy_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ ncfile_sfc =trim(out_dir)//'/'//trim(in_date)//'.sfc_data.'//trim(nestfl)//'.'//trim(tilefl)//'.nc'
+ endif
+
+ !-------------------------------------------------------------------------
+ ! 4 --- input grid info
+ !---4.1 read from grid file grid_spec.nc:
+ inquire(file=ncfile_grid2, exist=file_exist)
+ if ( file_exist ) ncfile_grid = ncfile_grid2
+
+ if ( debug_level > 10 ) write(*,'(a)')' --- read grid info from '//trim(ncfile_grid)
+ call rd_grid_spec_data(trim(ncfile_grid), dstgrid)
+ ix=dstgrid%grid_xt
+ iy=dstgrid%grid_yt
+ if ( debug_level > 10 ) then
+ write(*,'(a,i,1x,i,1x,f,1x,f,1x,f,1x,f)')' --- dstgrid info: ', ix, iy, &
+ dstgrid%grid_lon(int(ix/2), int(iy/2)), dstgrid%grid_lat(int(ix/2), int(iy/2)), &
+ dstgrid%grid_lont(int(ix/2), int(iy/2)), dstgrid%grid_latt(int(ix/2), int(iy/2))
+ endif
+
+ !-----------------------------
+ !---4.2 call FV3-grid cos and sin
+ allocate( cangu(ix,iy+1),sangu(ix,iy+1),cangv(ix+1,iy),sangv(ix+1,iy) )
+ call cal_uv_coeff_fv3(ix, iy, dstgrid%grid_lat, dstgrid%grid_lon, cangu, sangu, cangv, sangv)
+
+ !-----------------------------
+ !---4.3 calculate output-grid in input-grid's positions (xin, yin), and each grid's weight to dst
+ call cal_src_dst_grid_weight(ingrid, dstgrid)
+
+ !-------------------------------------------------------------------------
+ ! 5 --- process record one-by-one
+ rewind(iunit)
+ do_record_loop: do nrecord = 1, 14
+
+ !-----------------------------
+ !---5.1 read data and derive out the var for restart
+ iz=-99
+
+ if ( nrecord == 1 .or. nrecord == 2 .or. nrecord == 3 .or. nrecord == 10 .or. &
+ nrecord == 12 .or. nrecord == 13 .or. nrecord == 14 ) then
+ !---ignore these records
+ !---record 1 : nx, ny, nz, i360
+ !---record 2 : lon1,lat1,lon2,lat2,cen_lon,cen_lat
+ !---record 3 : pmid1(nx,ny,nz): pressure on full level
+ !--- ignore, we use p1 to derive delp.
+ !---record 10: hlon, hlat, vlon, vlat
+ !---record 12: pd1, PD1(NX,NY): surface pressure
+ !---record 13: eta1, ETA1(NZ+1)
+ !---record 14: eta2, ETA2(NZ+1)
+ if ( nrecord == 12 ) then
+ allocate(dat2(nx,ny))
+ read(iunit)dat2
+ !write(*,'(a,200f10.1)')'pd1: ',dat2(int(nx/2),int(ny/2))
+ deallocate(dat2)
+ elseif ( nrecord == 13 .or. nrecord == 14 ) then
+ allocate(dat1(nz+1))
+ read(iunit)dat1
+ !if ( nrecord == 13 ) write(*,'(a3,i1,a,200f10.1)')'eta',nrecord-12,': ',dat1
+ !if ( nrecord == 14 ) write(*,'(a3,i1,a,200f10.6)')'eta',nrecord-12,': ',dat1
+ deallocate(dat1)
+ else
+ read(iunit)
+ endif
+ endif
+
+ ! ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+ ! ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+ ! ALLOCATE ( Z1(NX,NY,NZ+1),P1(NX,NY,NZ+1) )
+ if ( nrecord == 6 ) then !u,v - 6,7
+ iz=nz
+ allocate(dat3(nx,ny,iz), u1(nx,ny,iz,1), v1(nx,ny,iz,1))
+ read(iunit) dat3
+ do k = 1, nz
+ u1(:,:,nz-k+1,1)=dat3(:,:,k)
+ enddo
+ read(iunit) dat3
+ do k = 1, nz
+ v1(:,:,nz-k+1,1)=dat3(:,:,k)
+ enddo
+ deallocate(dat3)
+ endif !if ( nrecord == 6 ) then !u,v - 6,7
+
+ if ( nrecord == 4 .or. nrecord == 5 .or. nrecord == 8 .or. &
+ nrecord == 9 .or. nrecord == 11 ) then
+ !---record 4 : t1-->T
+ !---record 5 : Q1
+ !---record 6 : U1
+ !---record 7 : V1
+ !---record 8 : DZDT
+ !---record 9 : z1 --> DZ
+ !---record 11: p1-->delp, p1(nx,ny,nz+1): (((p1(i,j,k),i=1,nx),j=1,ny),k=nz+1,1,-1)
+ !--- p1-->ps
+ iz=nz
+ if ( nrecord == 9 .or. nrecord == 11 ) then
+ allocate(dat3(nx,ny,iz+1))
+ else
+ allocate(dat3(nx,ny,iz))
+ endif
+ read(iunit) dat3
+ allocate(dat41(nx,ny,iz,1))
+
+ if ( nrecord == 9 .or. nrecord == 11 ) then ! z1 to dz; p1 to delp
+ !---back pressure to delp on fv_core.res.tile1.nc
+ do k = 1, nz
+ dat41(:,:,nz-k+1,1)=dat3(:,:,k)-dat3(:,:,k+1)
+ enddo
+ !---phis
+ if ( nrecord == 9 ) then
+ allocate(phis1(nx,ny,1,1))
+ phis1(:,:,1,1)=dat3(:,:,1)*g
+ endif
+ else
+ do k = 1, iz
+ dat41(:,:,iz-k+1,1)=dat3(:,:,k)
+ enddo
+ endif
+ deallocate(dat3)
+ endif
+
+ !-----------------------------
+ !---5.2 merge hafs restart and update restart files
+ !--- note: need to change nesting domain's filenames
+ if ( nrecord == 4) then !T
+ allocate(dat42(ix, iy, iz, 1), dat43(ix, iy, iz, 1))
+ call get_var_data(trim(ncfile_core), 'T', ix, iy, iz,1, dat42)
+ call combine_grids_for_remap(nx,ny,nz,1,dat41,ix,iy,iz,1,dat42,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_core), 'T', ix, iy, iz, 1, dat43)
+ deallocate(dat41, dat42, dat43)
+ elseif ( nrecord == 5 ) then !sphum
+ allocate(dat42(ix, iy, iz, 1), dat43(ix, iy, iz, 1))
+ call get_var_data(trim(ncfile_tracer), 'sphum', ix, iy, iz,1, dat42)
+ call combine_grids_for_remap(nx,ny,nz,1,dat41,ix,iy,iz,1,dat42,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_tracer), 'sphum', ix, iy, iz, 1, dat43)
+ deallocate(dat41, dat42, dat43)
+ elseif ( nrecord == 6 ) then !u and v
+ !---get u,v
+ allocate(u(ix, iy+1, iz, 1))
+ call get_var_data(trim(ncfile_core), 'u', ix, iy+1, iz,1, u)
+ allocate(v(ix+1, iy, iz, 1))
+ call get_var_data(trim(ncfile_core), 'v', ix+1, iy, iz,1, v)
+
+ !---convert fv3grid to earth
+ allocate(dat42(ix, iy+1, iz, 1), dat43(ix+1, iy, iz, 1))
+ do k = 1, iz
+ call fv3uv2earth(ix, iy, u(:,:,k,1), v(:,:,k,1), cangu, sangu, cangv, sangv, dat42(:,:,k,1), dat43(:,:,k,1))
+ enddo
+
+ !---merge
+ u=0.; v=0.
+ call combine_grids_for_remap(nx,ny,nz,1,u1,ix,iy+1,iz,1,dat42,gwt%gwt_u,u)
+ call combine_grids_for_remap(nx,ny,nz,1,v1,ix+1,iy,iz,1,dat43,gwt%gwt_v,v)
+
+ !---convert earth wind to fv3grid wind
+ dat42=-999999.; dat43=-99999999.;
+ do k = 1, iz
+ call earthuv2fv3(ix, iy, u(:,:,k,1), v(:,:,k,1), cangu, sangu, cangv, sangv, dat42(:,:,k,1), dat43(:,:,k,1))
+ enddo
+
+ !---output
+ call update_hafs_restart(trim(ncfile_core), 'u', ix, iy+1, iz, 1, dat42)
+ call update_hafs_restart(trim(ncfile_core), 'v', ix+1, iy, iz, 1, dat43)
+ deallocate(u1, v1, u, v, dat42, dat43, cangu, sangu, cangv, sangv)
+ elseif ( nrecord == 8 ) then !W
+ allocate(dat42(ix, iy, iz, 1), dat43(ix, iy, iz, 1))
+ call get_var_data(trim(ncfile_core), 'W', ix, iy, iz,1, dat42)
+ call combine_grids_for_remap(nx,ny,nz,1,dat41,ix,iy,iz,1,dat42,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_core), 'W', ix, iy, iz, 1, dat43)
+ deallocate(dat41, dat42, dat43)
+ elseif ( nrecord == 9 ) then !DZ, phis
+ allocate(dat42(ix, iy, iz, 1), dat43(ix, iy, iz, 1))
+ call get_var_data(trim(ncfile_core), 'DZ', ix, iy, iz,1, dat42)
+ call combine_grids_for_remap(nx,ny,nz,1,dat41,ix,iy,iz,1,dat42,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_core), 'DZ', ix, iy, iz, 1, dat43)
+ deallocate(dat41, dat42, dat43)
+ allocate(phis2(ix, iy, 1, 1), dat43(ix, iy, 1, 1))
+ call get_var_data(trim(ncfile_core), 'phis', ix, iy, 1, 1, phis2)
+ call combine_grids_for_remap(nx,ny,1,1,phis1,ix,iy,1,1,phis2,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_core), 'phis', ix, iy, 1, 1, dat43)
+ deallocate(phis1, phis2, dat43)
+ elseif ( nrecord == 11 ) then !delp
+ allocate(dat42(ix, iy, iz, 1), dat43(ix, iy, iz, 1))
+ call get_var_data(trim(ncfile_core), 'delp', ix, iy, iz,1, dat42)
+ call combine_grids_for_remap(nx,ny,nz,1,dat41,ix,iy,iz,1,dat42,gwt%gwt_t,dat43)
+ call update_hafs_restart(trim(ncfile_core), 'delp', ix, iy, iz, 1, dat43)
+ deallocate(dat41, dat42, dat43)
+ endif
+
+ enddo do_record_loop
+
+ !-----------------------------
+ ! 6 --- clean
+ deallocate( dstgrid%grid_lon, dstgrid%grid_lat, dstgrid%grid_lont, dstgrid%grid_latt)
+ deallocate( gwt%gwt_t, gwt%gwt_u, gwt%gwt_v )
+
+ enddo do_nestdom_loop !: do nd = 1, ndom
+ close(iunit)
+ write(*,*)'--- hafsvi_postproc completed ---'
+
+ return
+ end subroutine hafsvi_postproc
+
+!========================================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_netcdf.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_netcdf.f90
new file mode 100644
index 000000000..ac2b516be
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_netcdf.f90
@@ -0,0 +1,221 @@
+!========================================================================================
+ subroutine rd_grid_spec_data(ncfile, grid)
+
+ use netcdf
+ use var_type
+ implicit none
+
+ character(len=*), intent(in) :: ncfile
+ type(grid2d_info) :: grid
+
+ integer :: i, j, n
+ integer :: ncid, varid, ndims, nvars, xtype, dimids(5), vdim(5)
+ character(len=50) :: varname, dimname
+
+ call nccheck(nf90_open(trim(ncfile), nf90_nowrite, ncid), 'wrong in open: '//trim(ncfile), .true.)
+ call nccheck(nf90_inquire(ncid, ndims, nvars), 'wrong in inquire ncid', .true.)
+ do n = 1, ndims
+ call nccheck(nf90_inquire_dimension(ncid,n,name=dimname, len=i), 'wrong in inquire_dimension', .true.)
+ select case (trim(dimname))
+ case ('grid_x', 'west_east_stag'); grid%grid_x = i
+ case ('grid_y') ; grid%grid_y = i
+ case ('time') ; grid%ntime = i
+ case ('grid_xt') ; grid%grid_xt = i
+ case ('grid_yt') ; grid%grid_yt = i
+ end select
+ enddo
+
+ if (allocated(grid%grid_lon)) deallocate(grid%grid_lon)
+ allocate(grid%grid_lon(grid%grid_x,grid%grid_y))
+ call nccheck(nf90_inq_varid(ncid, 'grid_lon', varid), 'wrong in nf90_inq_varid grid_lon', .false.)
+ call nccheck(nf90_get_var(ncid, varid, grid%grid_lon), 'wrong in get data of grid_lon', .false.)
+ where ( grid%grid_lon > 180. ) grid%grid_lon=grid%grid_lon-360.
+
+ if (allocated(grid%grid_lat)) deallocate(grid%grid_lat)
+ allocate(grid%grid_lat(grid%grid_x,grid%grid_y))
+ call nccheck(nf90_inq_varid(ncid, 'grid_lat', varid), 'wrong in nf90_inq_varid grid_lat', .false.)
+ call nccheck(nf90_get_var(ncid, varid, grid%grid_lat), 'wrong in get data of grid_lat', .false.)
+
+ if (allocated(grid%times)) deallocate(grid%times)
+ allocate(grid%times(grid%ntime))
+ call nccheck(nf90_inq_varid(ncid, 'time', varid), 'wrong in nf90_inq_varid time', .false.)
+ call nccheck(nf90_get_var(ncid, varid, grid%times), 'wrong in get data of time', .false.)
+ call nccheck(nf90_get_att(ncid, varid, 'units', grid%times_unit), 'wrong in get times_unit', .false.)
+
+ if (allocated(grid%grid_lont)) deallocate(grid%grid_lont)
+ allocate(grid%grid_lont(grid%grid_xt,grid%grid_yt))
+ call nccheck(nf90_inq_varid(ncid, 'grid_lont', varid), 'wrong in nf90_inq_varid grid_lont', .false.)
+ call nccheck(nf90_get_var(ncid, varid, grid%grid_lont), 'wrong in get data of grid_lont', .false.)
+ where ( grid%grid_lont > 180. ) grid%grid_lont=grid%grid_lont-360.
+
+ if (allocated(grid%grid_latt)) deallocate(grid%grid_latt)
+ allocate(grid%grid_latt(grid%grid_xt,grid%grid_yt))
+ call nccheck(nf90_inq_varid(ncid, 'grid_latt', varid), 'wrong in nf90_inq_varid grid_latt', .false.)
+ call nccheck(nf90_get_var(ncid, varid, grid%grid_latt), 'wrong in get data of grid_latt', .false.)
+
+ !if (allocated(grid%grid_area)) deallocate(grid%grid_area)
+ !allocate(grid%grid_area(grid%grid_xt,grid%grid_yt))
+ !call nccheck(nf90_inq_varid(ncid, 'grid_area', varid), 'wrong in nf90_inq_varid grid_area', .false.)
+ !call nccheck(nf90_get_var(ncid, varid, grid%grid_area), 'wrong in get data of grid_area', .false.)
+
+ write(*,'(a,i0,a,i0,a,i0,a,i0,a)')' domain dims: (1:1) --> (',grid%grid_xt,':1) --> (',grid%grid_xt,':',grid%grid_yt,') --> (1:',grid%grid_yt,')'
+ write(*,'(a, 2f7.2,a,2f7.2,a,2f7.2,a,2f7.2)')' T-cell:', grid%grid_lont(1,1),grid%grid_latt(1,1), '--->', &
+ grid%grid_lont(grid%grid_xt,1),grid%grid_latt(grid%grid_xt,1), '--->', &
+ grid%grid_lont(grid%grid_xt,grid%grid_yt),grid%grid_latt(grid%grid_xt,grid%grid_yt), '--->', &
+ grid%grid_lont(1,grid%grid_yt),grid%grid_latt(1,grid%grid_yt)
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')' grid_lont :',minval(grid%grid_lont),':',maxval(grid%grid_lont),' grid_latt :',minval(grid%grid_latt),':',maxval(grid%grid_latt)
+ write(*,'(a,i0,a,i0,a,i0,a,i0,a)')' domain dims: (1:1) --> (',grid%grid_x ,':1) --> (',grid%grid_x ,':',grid%grid_y ,') --> (1:',grid%grid_y ,')'
+ write(*,'(a, 2f7.2,a,2f7.2,a,2f7.2,a,2f7.2)')' :', grid%grid_lon (1,1),grid%grid_lat (1,1), '--->', &
+ grid%grid_lon (grid%grid_x ,1),grid%grid_lat (grid%grid_x ,1), '--->', &
+ grid%grid_lon (grid%grid_x ,grid%grid_y ),grid%grid_lat (grid%grid_x ,grid%grid_y ), '--->', &
+ grid%grid_lon (1,grid%grid_y ),grid%grid_lat (1,grid%grid_y )
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')' grid_lon :',minval(grid%grid_lon ),':',maxval(grid%grid_lon ),' grid_lat :',minval(grid%grid_lat ),':',maxval(grid%grid_lat)
+
+ call nccheck(nf90_close(ncid), 'wrong in close '//trim(ncfile), .true.)
+
+ return
+ end subroutine rd_grid_spec_data
+
+!========================================================================================
+ subroutine get_var_data (ncfile, var, ix, jx, kx, tx, data)
+
+ use netcdf
+ implicit none
+ character(len=*), intent(in) :: ncfile
+ character(len=*), intent(in) :: var
+ integer, intent(in) :: ix, jx, kx, tx
+ real, dimension(ix, jx, kx, tx) :: data
+
+ integer :: ncid, varid, dimid,xtype
+ real*8, allocatable, dimension(:,:,:,:) :: ddata
+ integer, allocatable, dimension(:,:,:,:) :: idata
+
+ write(*,'(a,4i5)')'---getting '//trim(var)//' :', ix, jx, kx, tx
+ call nccheck(nf90_open(trim(ncfile), nf90_nowrite, ncid), 'wrong in open '//trim(ncfile), .false.)
+ call nccheck(nf90_inq_varid(ncid, trim(var), varid), 'wrong in nf90_inq_varid '//trim(var), .false.)
+ call nccheck(nf90_inquire_variable(ncid, varid, xtype=xtype), 'wrong in nf90_inquire_variable'//trim(var), .false.)
+
+ if ( xtype == nf90_float .or. xtype == nf90_real .or. xtype == nf90_real4 ) then
+ call nccheck(nf90_get_var(ncid, varid, data), 'wrong in get data of '//trim(var), .false.)
+ else if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ allocate(ddata(ix, jx, kx, tx))
+ call nccheck(nf90_get_var(ncid, varid, ddata), 'wrong in get data of '//trim(var), .false.)
+ data=real(ddata)
+ deallocate(ddata)
+ else if ( xtype == nf90_int ) then
+ allocate(idata(ix, jx, kx, tx))
+ call nccheck(nf90_get_var(ncid, varid, idata), 'wrong in get data of '//trim(var), .false.)
+ data=real(idata)
+ deallocate(idata)
+ else
+ !---NF90_BYTE, NF90_CHAR, NF90_SHORT
+ write(*,*)' !!!! please add ',xtype,' xtype data here '
+ stop
+ endif
+ call nccheck(nf90_close(ncid), 'wrong in close '//trim(ncfile), .false.)
+
+ return
+ end subroutine get_var_data
+
+!========================================================================================
+ subroutine get_character_var(ncid, varname, dim_len, dimsize, values)
+
+ use netcdf
+ implicit none
+
+ integer, intent(in) :: ncid, dim_len, dimsize
+ character (len = *), intent(in) :: varname
+ character (len = 1), dimension(dim_len, dimsize), intent(out) :: values
+ character (len = nf90_max_name) :: vname
+ integer :: ivarid, vartype, nvardims, nvarAtts, dimlen
+ integer,dimension(nf90_max_var_dims) :: start, count, vdims, vardimids
+ character(len=nf90_max_name) :: dimname
+ integer :: lenstr, j
+
+ call nccheck( nf90_inq_varid(ncid, varname, ivarid), 'wrong in inq_varid '//trim(varname), .false.)
+ call nccheck( nf90_inquire_variable(ncid, ivarid, &
+ name = vname, &
+ xtype = vartype, &
+ ndims = nvardims, &
+ dimids = vardimids, &
+ natts = nvarAtts), 'wrong in inquire_variable '//trim(varname), .false.)
+
+ lenstr = 1
+
+ do j = 1, nvardims
+ call nccheck(nf90_inquire_dimension(ncid, vardimids(j), name = dimname, len = dimlen), 'wrong in inquire_dimension '//trim(varname), .false.)
+ lenstr = lenstr * dimlen
+ start(j) = 1
+ count(j) = dimlen
+ enddo
+
+ call nccheck( nf90_get_var(ncid, ivarid, values, start = start, count = count), 'wrong in get '//trim(varname), .false. )
+ !write(*, fmt = '(a, " filled")') varname
+
+ end subroutine get_character_var
+
+!========================================================================================
+ subroutine get_var_dim(ncfile, var, ndims, dims)
+
+ use netcdf
+ implicit none
+ character(len=*), intent(in) :: ncfile
+ character(len=*), intent(in) :: var
+ integer, intent(out) :: ndims
+ integer, dimension(nf90_max_var_dims), intent(out) :: dims
+
+ integer :: ncid, varid, i
+ integer, dimension(nf90_max_var_dims) :: dimids
+
+ call nccheck(nf90_open(trim(ncfile), nf90_nowrite, ncid), 'wrong in open '//trim(ncfile), .false.)
+ call nccheck(nf90_inq_varid(ncid, trim(var), varid), 'wrong in nf90_inq_varid '//trim(var), .false.)
+ call nccheck(nf90_inquire_variable(ncid, varid, ndims=ndims, dimids=dimids), 'wrong in inquire_variable '//trim(var), .false.)
+ dims=-999
+ do i = 1, ndims
+ call nccheck(nf90_inquire_dimension(ncid,dimids(i), len=dims(i)), 'wrong in inquire '//trim(var)//' dim', .false.)
+ enddo
+ call nccheck(nf90_close(ncid), 'wrong in close '//trim(ncfile), .false.)
+
+ return
+ end subroutine get_var_dim
+
+!========================================================================================
+ subroutine update_hafs_restart(ncfile, varname, ix, jx, kx, tx, dat4)
+
+ use netcdf
+ implicit none
+ character(len=*), intent(in) :: ncfile
+ character(len=*), intent(in) :: varname
+ integer, intent ( in) :: ix, jx, kx, tx ! -1=no-this-dim
+ real, dimension(abs(ix), abs(jx), abs(kx), abs(tx)), intent(in) :: dat4
+
+ integer :: ncid, varid, ndims, xtype, rcode
+
+ call nccheck(nf90_open(trim(ncfile), nf90_write, ncid), 'wrong in open '//trim(ncfile), .true.)
+ !---check variable's type: nf90_real, nf90_double
+ call nccheck(nf90_inq_varid(ncid, trim(varname), varid), 'wrong in inq_varid '//trim(varname), .true.)
+ call nccheck(nf90_inquire_variable(ncid, varid, xtype=xtype, ndims=ndims), 'wrong in inquire '//trim(varname)//' xtype', .false.)
+ if ( xtype == nf90_float .or. xtype == nf90_real .or. xtype == nf90_real4 ) then
+ call nccheck(nf90_put_var(ncid, varid, dat4), 'wrong in write '//trim(varname), .false.)
+ else if ( xtype == nf90_double .or. xtype == nf90_real8 ) then
+ call nccheck(nf90_put_var(ncid, varid, dble(dat4)), 'wrong in write '//trim(varname), .false.)
+ endif
+ call nccheck(nf90_close(ncid), 'wrong in close '//trim(ncfile), .true.)
+
+ return
+ end subroutine update_hafs_restart
+!========================================================================================
+ subroutine nccheck(status, states, ifstop)
+
+ use netcdf
+ implicit none
+ integer, intent ( in) :: status
+ character(len=*), intent(in) :: states
+ logical, intent ( in) :: ifstop
+
+ if (status /= nf90_noerr) then
+ write(*,*)trim(nf90_strerror(status)), ' '//trim(states)
+ if ( ifstop ) stop
+ end if
+ end subroutine nccheck
+!=======================================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tcinfo.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tcinfo.f90
new file mode 100644
index 000000000..0d35eb05d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tcinfo.f90
@@ -0,0 +1,268 @@
+!=======================================================================================
+ subroutine get_tc_info(vortex_position_file, tcvital_file, besttrackfile, file_date, &
+ vortexradius)
+
+ use var_type
+
+ implicit none
+ character (len=*), intent(in) :: vortex_position_file, tcvital_file, besttrackfile, file_date, &
+ vortexradius
+ character (len=13) :: time
+ real, dimension(4) :: center !lat, lon, pmin, vmax
+ character (len=300) :: temp
+ integer :: i, j, n
+ real :: xtemp
+
+ !---get info from file
+ center = -9999999.0
+ if ( len_trim(vortex_position_file) > 1 ) then
+ !--get user defind vortex center
+ call rd_vortex_position(trim(vortex_position_file), center(1:2))
+ else
+ !--need to get tc info from tcvital or best-track
+ if ( len_trim(file_date) < 11 ) then !20210312.09xx
+ time='99999999.9999'
+ elseif ( len_trim(file_date) >= 11 .and. len_trim(file_date) < 13 ) then
+ time=file_date(1:11)//'00'
+ else
+ time=file_date(1:13)
+ endif
+
+ if ( len_trim(tcvital_file) > 1 ) then
+ call rd_interp_besttrack(time, trim(tcvital_file), center)
+ else if ( len_trim(besttrackfile) > 1 ) then
+ call rd_interp_besttrack(time, trim(besttrackfile), center)
+ endif
+ endif
+
+ call check_tc_lon_lat(center(1), center(2))
+ if ( center(1) >= -85. .and. center(1) <= 85. ) tc%lat = center(1)
+ if ( center(2) > -180. .and. center(2) < 360. ) tc%lon = center(2)
+ if ( center(3) > 800. .and. center(3) < 1050. ) tc%pmin = center(3)
+ if ( center(4) > 0. .and. center(4) < 250. ) tc%vmax = center(4)
+
+ !---get tc%vortexreplace_r
+ if ( len_trim(vortexradius) > 3 ) then
+ temp=trim(vortexradius)
+ n=0
+ do i = 1, len_trim(temp)
+ if ( temp(i:i) == ':' .or. temp(i:i) == '-' ) then
+ temp(i:i) = ' '
+ n=n+1
+ endif
+ enddo
+ if ( n > 0 ) then
+ read(temp,*)i,j
+ else
+ read(temp,*)i
+ j=i
+ endif
+ if ( i > 5 .and. i < 8000 ) tc%vortexreplace_r(1) = real(i)
+ if ( j > 5 .and. j < 8000 ) tc%vortexreplace_r(2) = real(j)
+ if ( tc%vortexreplace_r(1) > 5 .and. tc%vortexreplace_r(1) < 8000 .and. &
+ tc%vortexreplace_r(2) > 5 .and. tc%vortexreplace_r(2) < 8000 .and. &
+ tc%vortexreplace_r(1) > tc%vortexreplace_r(2) ) then
+ xtemp = tc%vortexreplace_r(1)
+ tc%vortexreplace_r(1) = tc%vortexreplace_r(2)
+ tc%vortexreplace_r(2) = xtemp
+ endif
+ endif
+
+ write(*,'(a,2f8.2,2x,a)')'---vortex replacement info: ', tc%lon, tc%lat, trim(vortexradius)
+
+ return
+ end subroutine get_tc_info
+
+!=======================================================================================
+ subroutine check_tc_lon_lat(lat, lon)
+
+ implicit none
+ real, intent(inout) :: lon, lat
+ real :: temp1
+
+ if ( ((lat>85. .and. lat<=360.) .or. (lat<-85. .and. lat>= -180.)) .and. (lon>-65. .and. lon<65.) ) then
+ temp1 = lon
+ lon = lat
+ lat = temp1
+ endif
+
+ return
+ end subroutine check_tc_lon_lat
+
+!=======================================================================================
+ subroutine rd_vortex_position (filename, center )
+
+!-----------------------------------------------------------------------------
+! read user-define hurricane track information, i.e.,
+! -86.5 23.8
+!-----------------------------------------------------------------------------
+
+ implicit none
+ character (len=*), intent(in) :: filename
+ real, dimension(2), intent(out) :: center !lat, lon
+ real, dimension(2) :: dat
+ integer :: iost
+
+ open(39, file=trim(filename), status='old', form = 'formatted', iostat = iost )
+ if( iost .ne. 0 ) then
+ write(*,'(a)')'Cannot find the hurricane track file '//trim(filename)
+ center = -9999999.0
+ return
+ endif
+
+ do_get_track_loop : do
+ read(39, *, iostat = iost) dat(1:2) ! lat, lon
+ if ( iost .ne. 0 ) exit do_get_track_loop
+ center = dat
+ end do do_get_track_loop
+ close(39)
+ write(*,*)'vortex position is:',center
+
+ end subroutine rd_vortex_position
+!=======================================================================================
+
+ subroutine rd_interp_besttrack ( times, filename, center )
+
+ implicit none
+ character (len=*), intent(in) :: times !20210312.0900
+ character (len=*), intent(in) :: filename
+ real, dimension(4), intent(out) :: center
+
+ integer :: iost, hours_from_date, nrecord
+ integer, dimension(3) :: year, month, day, hour, dhour !1=current, 2=pre, 3=post
+ real, dimension(3) :: lat, lon, wsp, slp
+ integer :: iyear, imonth, iday, ihour, ilat, ilon, iwsp, islp, diff_hour
+ real :: awsp
+ character (len=1) :: clat, clon
+ character (len=3) :: nhc
+
+ dhour(1:3)=-999999
+ read(times, '(i4, i2, i2, 1x, i2)')year(1), month(1), day(1), hour(1)
+ dhour(1) = hours_from_date ( year(1), month(1), day(1), hour(1))
+
+ open(39, file=trim(filename), status='old', form = 'formatted', iostat = iost )
+ if ( iost .ne. 0 ) then
+ center = -9999999.0
+ write(*,*)'CANNOT find best-track file!!!!!!'
+ return
+ end if
+
+ read(39, '(a3)', iostat = iost)nhc
+ backspace(39)
+ nrecord=0
+ do_get_track_loop : do
+ if (nhc == "NHC" .or. nhc == "JTW" ) then !tcvital
+ !-----tcvitals
+ read(39, '(19x, i4,2i2,1x,i2,2x,i4, a1, i5, a1,9x,i4, 10x, i3)', iostat = iost) &
+ iyear, imonth, iday, ihour, ilat, clat, ilon, clon, islp, iwsp
+ else if (nhc == "AL," .or. nhc == "WP," .or. nhc == "EP" .or. nhc == "IO," .or. nhc == "SH," ) then ! best track
+ !-----Best Track --b-deck
+ read(39, '(8x, i4,3i2, 16x, i4, a1, 1x, i5, a1, 1x, i4, 1x, i5)', iostat = iost) &
+ iyear, imonth, iday, ihour, ilat, clat, ilon, clon, iwsp, islp
+ end if
+ awsp = iwsp*0.514444
+ !awsp = iwsp*1.0
+ if( iost .ne. 0 ) exit
+ if (clat == 'S') ilat = -ilat
+ if (clon == 'W') ilon = -ilon
+ if ( year(1) == 9999 .and. month(1) == 99 .and. day(1) == 99 .and. hour(1) == 99 ) then
+ !---use the last record
+ lat(2) = ilat/10.
+ lon(2) = ilon/10.
+ wsp(2) = awsp
+ slp(2) = islp*1.0
+ dhour(2) = 99999
+ lat(3) = ilat/10.
+ lon(3) = ilon/10.
+ wsp(3) = awsp
+ slp(3) = islp*1.0
+ dhour(3) = 99999
+ else
+ diff_hour = hours_from_date ( iyear, imonth, iday, ihour)
+ if (diff_hour == dhour(1) ) then
+ lat(2) = ilat/10.
+ lon(2) = ilon/10.
+ wsp(2) = awsp
+ slp(2) = islp*1.0
+ dhour(2) = 99999
+ lat(3) = ilat/10.
+ lon(3) = ilon/10.
+ wsp(3) = awsp
+ slp(3) = islp*1.0
+ dhour(3) = 99999
+ exit do_get_track_loop
+ else if (diff_hour < dhour(1) ) then
+ nrecord=nrecord+1
+ if ( nrecord <= 1 ) then
+ lat(2) = ilat/10.
+ lon(2) = ilon/10.
+ wsp(2) = awsp
+ slp(2) = islp*1.0
+ dhour(2) = diff_hour
+ lat(3) = ilat/10.
+ lon(3) = ilon/10.
+ wsp(3) = awsp
+ slp(3) = islp*1.0
+ dhour(3) = diff_hour
+ else
+ lat(2) = lat(3)
+ lon(2) = lon(3)
+ wsp(2) = wsp(3)
+ slp(2) = slp(3)
+ dhour(2) = dhour(3)
+ lat(3) = ilat/10.
+ lon(3) = ilon/10.
+ wsp(3) = awsp
+ slp(3) = islp*1.0
+ dhour(3) = diff_hour
+ endif
+ else if (diff_hour > dhour(1) ) then
+ lat(3) = ilat/10.
+ lon(3) = ilon/10.
+ wsp(3) = awsp
+ slp(3) = islp*1.0
+ dhour(3) = diff_hour
+ exit do_get_track_loop
+ end if
+ endif
+ end do do_get_track_loop
+ close(39)
+
+ if (dhour(2) < -9999 .or. dhour(3) < -9999 ) then
+ center(1:4) = -999999.0
+ else if ( abs(dhour(3)-dhour(2)) < 1 ) then
+ center(1) = lat(3)
+ center(2) = lon(3)
+ center(3) = slp(3)
+ center(4) = wsp(3)
+ else
+ !center(1) = lat(2)+(lat(3)-lat(2))*abs(dhour(2))/(abs(dhour(2))+abs(dhour(3)))
+ !center(2) = lon(2)+(lon(3)-lon(2))*abs(dhour(2))/(abs(dhour(2))+abs(dhour(3)))
+ !center(3) = slp(2)+(slp(3)-slp(2))*abs(dhour(2))/(abs(dhour(2))+abs(dhour(3)))
+ !center(4) = wsp(2)+(wsp(3)-wsp(2))*abs(dhour(2))/(abs(dhour(2))+abs(dhour(3)))
+ center(1) = lat(3) - (lat(3)-lat(2))/(dhour(3)-dhour(2))*(dhour(3)-dhour(1))
+ center(2) = lon(3) - (lon(3)-lon(2))/(dhour(3)-dhour(2))*(dhour(3)-dhour(1))
+ center(3) = slp(3) - (slp(3)-slp(2))/(dhour(3)-dhour(2))*(dhour(3)-dhour(1))
+ center(4) = wsp(3) - (wsp(3)-wsp(2))/(dhour(3)-dhour(2))*(dhour(3)-dhour(1))
+ end if
+
+ write(*,'(a,4f10.2)')'hurricane center from obs is:',center
+ return
+
+ end subroutine rd_interp_besttrack
+
+!==============================================================================
+ function hours_from_date(iyear, imonth, iday, ihour)
+ integer :: iyear, imonth, iday, ihour
+ integer :: hours_from_date
+ integer :: y, m, d, h
+
+ m = mod(imonth+9, 12)
+ y = iyear - int(m/10)
+ hours_from_date = 365*y + int(y/4) + int(y/100) + int(y/400) + int((m*306+5)/10) + iday - 1
+ hours_from_date = hours_from_date*24 + ihour
+ return
+ end function hours_from_date
+
+!=======================================================================================
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tools.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tools.f90
new file mode 100644
index 000000000..d50fc4622
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_tools.f90
@@ -0,0 +1,1000 @@
+!-----------------------------------------------------------------------+
+ function date2second1970 (yyyy, mm, dd, hh, minute, second) !result(second1970)
+ implicit none
+
+ integer,intent(in) :: yyyy, mm, dd, hh, minute, second
+ real*8 :: date2second1970
+
+ integer :: julian, julian_1970_01_01
+ julian_1970_01_01 = 2440588
+
+ julian = dd -32075 + 1461*(yyyy + 4800 + (mm - 14)/12)/4 + &
+ 367*(mm - 2 - ((mm - 14)/12)*12)/12 - &
+ 3*((yyyy + 4900 + (mm - 14)/12)/100)/4
+ !write(*,*)'julian =',julian
+
+ date2second1970 = (julian-julian_1970_01_01)*3600*24 + hh*3600 + minute*60 + second
+ return
+ end function date2second1970
+
+!-----------------------------------------------------------------------+
+ function date2second1970_str(cdate)
+ implicit none
+
+ character (len=*),intent(in) :: cdate
+ real*8 :: date2second1970_str
+
+ integer :: julian, julian_1970_01_01
+ integer :: yyyy, mm, dd, hh, minute, second
+ julian_1970_01_01 = 2440588
+
+ read(cdate,'(i4,5i2)')yyyy, mm, dd, hh, minute, second
+
+ julian = dd -32075 + 1461*(yyyy + 4800 + (mm - 14)/12)/4 + &
+ 367*(mm - 2 - ((mm - 14)/12)*12)/12 - &
+ 3*((yyyy + 4900 + (mm - 14)/12)/100)/4
+ !write(*,*)'julian =',julian
+
+ date2second1970_str = (julian-julian_1970_01_01)*3600*24 + hh*3600 + minute*60 + second
+ return
+ end function date2second1970_str
+
+!-----------------------------------------------------------------------+
+ subroutine second19702date(second1970, hdate, formatstr)
+
+ !---from http://fortranwiki.org/fortran/show/m_time
+
+ implicit none
+ real*8,intent(in) :: second1970
+ character(len=*),intent(in) :: formatstr
+ character(len=*),intent(out) :: hdate !YYYYMMDDHHmmss
+
+ integer :: year, month, day, hour, minute, second
+
+ real*8 :: julian
+ real :: secday
+ integer :: ijul, julian_1970_01_01, jalpha,ja,jb,jc,jd,je
+
+ secday = 24.0*3600.
+ julian_1970_01_01 = 2440588
+
+ julian = dble(second1970/secday)+dble(julian_1970_01_01)
+ ijul = int(julian)
+
+ second = int((julian-ijul)*secday+0.5)
+ minute=int(second/60.0) ! Integral minutes from beginning of day
+ second=second-minute*60 ! Seconds from beginning of minute
+ hour=minute/60 ! Integral hours from beginning of day
+ minute=minute-hour*60 ! Integral minutes from beginning of hour
+
+ !---------------------------------------------
+ jalpha=idint((dble(ijul-1867216)-0.25d0)/36524.25d0) ! Correction for Gregorian Calendar
+ ja=ijul+1+jalpha-idint(0.25d0*dble(jalpha))
+ !---------------------------------------------
+
+ jb=ja+1524
+ jc=idint(6680.d0+(dble(jb-2439870)-122.1d0)/365.25d0)
+ jd=365*jc+idint(0.25d0*dble(jc))
+ je=idint(dble(jb-jd)/30.6001d0)
+ day=jb-jd-idint(30.6001d0*dble(je))
+ month=je-1
+
+ if(month.gt.12)then
+ month=month-12
+ endif
+
+ year=jc-4715
+ if(month.gt.2)then
+ year=year-1
+ endif
+
+ if(year.le.0)then
+ year=year-1
+ endif
+
+ if ( trim(formatstr) == "YYYYMMDDHHmmss" ) then
+ write(hdate,'(i4.4,5i2.2)')year, month, day, hour, minute, second
+ else if ( trim(formatstr) == "YYYY-MM-DD hh:mm:ss" ) then
+ write(hdate,'(i4.4,5(a1,i2.2))')year, '-', month, '-', day, ' ', hour, ':', minute, ':', second
+ else if ( trim(formatstr) == "mm/dd/yyyy hh:mm") then
+ write(hdate,'(i,a1,i,a1,i,a1,i,a3)')month,'/',day,'/',year,' ',hour,':',minute
+ endif
+
+ return
+ end subroutine second19702date
+
+!-----------------------------------------------------------------------+
+ real function earth_dist(lon1, lat1, lon2, lat2)
+! earth_dist - function that calculates the earth distance between
+! two points.
+! lon1 - longitude of point 1
+! lat1 - latitude of point 1
+! lon2 - longitude of point 2
+! lat2 - latitude of point 2
+
+ real,intent(in) :: lon1, lat1, lon2, lat2
+ real :: pro
+ real, parameter :: R_earth = 6374.*1e3, pid=3.14159/180.
+
+ pro = sin(lat1*pid) * sin(lat2*pid) + &
+ cos(lat1*pid) * cos(lat2*pid) * &
+ cos((lon2-lon1)*pid)
+
+ if ( abs(pro) .gt. 1.001 ) then
+ print*,'In earth_dist, pro > 1, returning',pro
+ earth_dist = -9999999.
+ elseif ( abs(pro) .gt. 1 ) then
+ earth_dist = 0.
+ else
+ earth_dist = R_earth * acos(pro)
+ endif
+
+ return
+ end function
+
+
+!-----------------------------------------------------------------------+
+ integer function binarysearch(length, array, value, delta)
+ ! Given an array and a value, returns the index of the element that
+ ! is closest to, but less than, the given value.
+ ! Uses a binary search algorithm.
+ ! "delta" is the tolerance used to determine if two values are equal
+ ! if ( abs(x1 - x2) <= delta) then
+ ! assume x1 = x2
+ ! endif
+
+ implicit none
+ integer, intent(in) :: length
+ real, dimension(length), intent(in) :: array
+ !f2py depend(length) array
+ real, intent(in) :: value
+ real, intent(in), optional :: delta
+
+ integer :: left, middle, right
+ real :: d
+
+ if (present(delta) .eqv. .true.) then
+ d = delta
+ else
+ d = 1e-9
+ endif
+
+ if ( array(1) < array(length) ) then
+ left = 1
+ right = length
+ do
+ if (left > right) then
+ exit
+ endif
+ middle = nint((left+right) / 2.0)
+ if ( abs(array(middle) - value) <= d) then
+ binarySearch = middle
+ return
+ else if (array(middle) > value) then
+ right = middle - 1
+ else
+ left = middle + 1
+ end if
+ end do
+ binarysearch = right
+ else
+ right = 1
+ left = length
+ do
+ if (right > left) then
+ exit
+ endif
+ middle = nint((left+right) / 2.0)
+ if ( abs(array(middle) - value) <= d) then
+ binarySearch = middle
+ return
+ else if (array(middle) > value) then
+ right = middle + 1
+ else
+ left = middle -1
+ end if
+ end do
+ binarysearch = left
+ endif
+
+ end function binarysearch
+
+!-----------------------------------------------------------------------+
+ integer function beaufortscale(windspeed)
+
+ real, intent(in) :: windspeed !m/s
+ ! ref to: https://www.wikiwand.com/zh-cn/%E8%92%B2%E7%A6%8F%E6%B0%8F%E9%A2%A8%E7%B4%9A
+ ! https://www.skybrary.aero/index.php/Beaufort_wind_force_scale
+
+ beaufortscale = -99
+ if ( windspeed <= 0.2 ) then
+ beaufortscale = 0
+ else if ( windspeed > 0.3 .and. windspeed <= 1.5 ) then
+ beaufortscale = 1
+ else if ( windspeed > 1.6 .and. windspeed <= 3.3 ) then
+ beaufortscale = 2
+ else if ( windspeed > 3.4 .and. windspeed <= 5.4 ) then
+ beaufortscale = 3
+ else if ( windspeed > 5.4 .and. windspeed <= 7.9 ) then
+ beaufortscale = 4
+ else if ( windspeed > 7.9 .and. windspeed <= 10.7 ) then
+ beaufortscale = 5
+ else if ( windspeed > 10.7 .and. windspeed <= 13.8 ) then
+ beaufortscale = 6
+ else if ( windspeed > 13.8 .and. windspeed <= 17.1 ) then
+ beaufortscale = 7
+ else if ( windspeed > 17.1 .and. windspeed <= 20.7 ) then
+ beaufortscale = 8
+ else if ( windspeed > 20.7 .and. windspeed <= 24.4 ) then
+ beaufortscale = 9
+ else if ( windspeed > 24.4 .and. windspeed <= 28.4 ) then
+ beaufortscale = 10
+ else if ( windspeed > 28.4 .and. windspeed <= 32.6 ) then
+ beaufortscale = 11
+ else if ( windspeed > 32.6 .and. windspeed <= 36.9 ) then
+ beaufortscale = 12
+ else if ( windspeed > 36.9 .and. windspeed <= 41.4 ) then
+ beaufortscale = 13
+ else if ( windspeed > 41.4 .and. windspeed <= 46.1 ) then
+ beaufortscale = 14
+ else if ( windspeed > 46.1 .and. windspeed <= 50.9 ) then
+ beaufortscale = 15
+ else if ( windspeed > 50.9 .and. windspeed <= 56.0 ) then
+ beaufortscale = 16
+ else if ( windspeed > 56.0 .and. windspeed <= 61.2 ) then
+ beaufortscale = 17
+ else if ( windspeed > 61.2 ) then
+ beaufortscale = 18
+ endif
+
+ return
+ end function
+
+!-----------------------------------------------------------------------+
+ subroutine interp_fill_nan_1d(nlen, dat, radius, value_min, value_max)
+
+ integer, intent(in) :: nlen, radius
+ real, dimension(nlen), intent(inout) :: dat
+ real, intent(in) :: value_min, value_max
+
+ integer :: i, j, i1, i2, nbefore, nafter
+
+ do i = 1, nlen
+ if ( dat(i) < value_min .or. dat(i) > value_max ) then
+ !----search avialable points before/after i
+ i1=0
+ do_search_before: do j = 1, radius
+ if ( i-j < 1 ) exit do_search_before
+ if ( dat(i-j) >= value_min .and. dat(i-j) <= value_max ) then
+ i1 = i - j
+ exit do_search_before
+ endif
+ enddo do_search_before
+ i2=0
+ do_search_after: do j = 1, radius
+ if ( i+j > nlen ) exit do_search_after
+ if ( dat(i+j) >= value_min .and. dat(i+j) <= value_max ) then
+ i2 = i + j
+ exit do_search_after
+ endif
+ enddo do_search_after
+
+ !---interp
+ if ( i1 >= 1 .and. i1 < nlen .and. i2 > 1 .and. i2 <= nlen ) then
+ dat(i) = ((i2-i)*dat(i1) + (i-i1)*dat(i2))/(i2-i1)
+ endif
+ endif
+ enddo
+
+ return
+ end subroutine interp_fill_nan_1d
+
+!========================================================================================
+ subroutine cal_src_dst_grid_weight(grid_src, grid_dst)
+
+ use module_mpi
+ use var_type
+
+ implicit none
+
+ type(grid2d_info), intent(in) :: grid_src, grid_dst
+ integer, allocatable, dimension(:,:) :: x_oini, y_oini
+ real, allocatable, dimension(:,:) :: lat_src, lon_src, lat_dst, lon_dst
+ integer :: i, j
+
+!------------------------------------------------------------------------------
+! 1 --- T-grid position in nearest source grid
+ i=int(grid_dst%grid_xt/2);j=int(grid_dst%grid_yt/2)
+ if ( debug_level > 10 ) then
+ write(*,'(a,i0,a,i0)')'---- processing t-cell: ', grid_dst%grid_xt,':',grid_dst%grid_yt
+ write(*,'(a)')' --- i j lon lat'
+ write(*,'(a3,2i6, 2f11.2,2i11, 2f11.2)')' t:', i, j, grid_dst%grid_lont(i,j), grid_dst%grid_latt(i,j)
+ endif
+
+ allocate(x_oini(grid_dst%grid_xt, grid_dst%grid_yt), y_oini(grid_dst%grid_xt, grid_dst%grid_yt))
+ call search_nearst_grid(grid_src%grid_xt, grid_src%grid_yt, grid_src%grid_latt, grid_src%grid_lont, &
+ grid_dst%grid_xt, grid_dst%grid_yt, grid_dst%grid_latt, grid_dst%grid_lont, &
+ x_oini, y_oini)
+ if ( debug_level > 10 ) then
+ write(*,'(a)')' --- i j lon lat x y m(i,j)_lon m(i,j)_lat '
+ write(*,'(a3,2i6)')' t:', i, j
+ write(*,'(a3,2i6, 2f11.2,2i11, 2f11.2)')' t:', i, j, grid_dst%grid_lont(i,j), grid_dst%grid_latt(i,j), x_oini(i,j), y_oini(i,j), &
+ grid_src%grid_lont(x_oini(i,j),y_oini(i,j)), grid_src%grid_latt(x_oini(i,j),y_oini(i,j))
+ endif
+ !do j1=1,grid_dst%grid_yt; do i1=1,grid_dst%grid_xt
+ ! write(98,'(4i6)')i1,j1,x_oini(i1,j1),y_oini(i1,j1)
+ !enddo;enddo
+
+ !---find (x_oini(i,j), y_oini(i,j)) and its neighboring 8 points, and calculate distance and then weights
+ allocate(gwt%gwt_t(grid_dst%grid_xt, grid_dst%grid_yt)) !grid_weight_info
+ call cal_grid_weight(grid_src%grid_xt, grid_src%grid_yt, grid_src%grid_latt, grid_src%grid_lont, &
+ grid_dst%grid_xt, grid_dst%grid_yt, grid_dst%grid_latt, grid_dst%grid_lont, &
+ x_oini, y_oini, gwt%max_points, gwt%gwt_t)
+ deallocate(x_oini, y_oini)
+ write(*,'(a,30i6)')' gwt%gwt_t @ ', i, j, gwt%gwt_t(i,j)%src_points, gwt%gwt_t(i,j)%src_x(1:gwt%gwt_t(i,j)%src_points), &
+ gwt%gwt_t(i,j)%src_y(1:gwt%gwt_t(i,j)%src_points)
+
+ !---so for T-grid variables:
+ ! merged-grid = (1.0-dst_weight)*sum(gwt%gwt_t(i,j)%src_weight(:)*SRCVAR(gwt%gwt_t(i,j)%src_x(:), gwt%gwt_t(i,j)%src_y(:))) +
+ ! dst_weight*sum(gwt%gwt_t(i,j)%dst_weight(:)*DSTVAR(gwt%gwt_t(i,j)%dst_x(:),gwt%gwt_t(i,j)%dst_y(:)))
+
+ !---4.2, U-grid (grid_dst%grid_xt, grid_dst%grid_y)
+ write(*,'(a)')'---- processing u-cell ----'
+ allocate(x_oini(grid_dst%grid_xt, grid_dst%grid_y), y_oini(grid_dst%grid_xt, grid_dst%grid_y))
+ allocate(lon_src(grid_src%grid_xt, grid_src%grid_y), lat_src(grid_src%grid_xt, grid_src%grid_y))
+ if ( grid_src%grid_x-grid_src%grid_xt >= 1 ) then
+ lon_src(1:grid_src%grid_xt,1:grid_src%grid_y) = (grid_src%grid_lon(1:grid_src%grid_xt,1:grid_src%grid_y) + &
+ grid_src%grid_lon(2:grid_src%grid_x ,1:grid_src%grid_y))/2.0
+ lat_src(1:grid_src%grid_xt,1:grid_src%grid_y) = (grid_src%grid_lat(1:grid_src%grid_xt,1:grid_src%grid_y) + &
+ grid_src%grid_lat(2:grid_src%grid_x ,1:grid_src%grid_y))/2.0
+ else
+ lon_src(1:grid_src%grid_xt,1:grid_src%grid_y) = grid_src%grid_lon(1:grid_src%grid_xt,1:grid_src%grid_y)
+ lat_src(1:grid_src%grid_xt,1:grid_src%grid_y) = grid_src%grid_lat(1:grid_src%grid_xt,1:grid_src%grid_y)
+ endif
+ !write(*,'(a)')'last row src lat before: ------------------'
+ !write(*,'(15f8.2)')grid_src%grid_lat(488:grid_src%grid_xt,grid_src%grid_y-1)
+
+ allocate(lon_dst(grid_dst%grid_xt, grid_dst%grid_y), lat_dst(grid_dst%grid_xt, grid_dst%grid_y))
+ if ( grid_dst%grid_x-grid_dst%grid_xt >= 1 ) then
+ lon_dst(1:grid_dst%grid_xt,1:grid_dst%grid_y) = (grid_dst%grid_lon(1:grid_dst%grid_xt,1:grid_dst%grid_y) + &
+ grid_dst%grid_lon(2:grid_dst%grid_x ,1:grid_dst%grid_y))/2.0
+ lat_dst(1:grid_dst%grid_xt,1:grid_dst%grid_y) = (grid_dst%grid_lat(1:grid_dst%grid_xt,1:grid_dst%grid_y) + &
+ grid_dst%grid_lat(2:grid_dst%grid_x ,1:grid_dst%grid_y))/2.0
+ else
+ lon_dst(1:grid_dst%grid_xt,1:grid_dst%grid_y) = grid_dst%grid_lon(1:grid_dst%grid_xt,1:grid_dst%grid_y)
+ lat_dst(1:grid_dst%grid_xt,1:grid_dst%grid_y) = grid_dst%grid_lat(1:grid_dst%grid_xt,1:grid_dst%grid_y)
+ endif
+
+ !if (debug) then
+ write(*,'(a,2i8,4f10.3)')'src grid_lat: ', grid_src%grid_x , grid_src%grid_y, grid_src%grid_lat(1,1), &
+ grid_src%grid_lat(grid_src%grid_x,1), grid_src%grid_lat(grid_src%grid_x,grid_src%grid_y), &
+ grid_src%grid_lat(1,grid_src%grid_y)
+ write(*,'(a,2i8,4f10.3)')'src u lat: ', grid_src%grid_xt, grid_src%grid_y, lat_src(1,1),lat_src(grid_src%grid_xt,1), &
+ lat_src(grid_src%grid_xt,grid_src%grid_y), lat_src(1,grid_src%grid_y)
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')'src grid range:',minval(grid_src%grid_lon),':',maxval(grid_src%grid_lon), &
+ '; ',minval(grid_src%grid_lat),':',maxval(grid_src%grid_lat)
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')'src u-grid range:',minval(lon_src),':',maxval(lon_src),'; ',minval(lat_src),':',maxval(lat_src)
+ write(*,'(a,2i8,4f10.3)')'dst grid_lat: ', grid_dst%grid_x , grid_dst%grid_y, grid_dst%grid_lat(1,1), &
+ grid_dst%grid_lat(grid_dst%grid_x,1), grid_dst%grid_lat(grid_dst%grid_x,grid_dst%grid_y), &
+ grid_dst%grid_lat(1,grid_dst%grid_y)
+ write(*,'(a,2i8,4f10.3)')'dst u lat: ', grid_dst%grid_xt, grid_dst%grid_y, lat_dst(1,1),lat_dst(grid_dst%grid_xt,1),&
+ lat_dst(grid_dst%grid_xt,grid_dst%grid_y), lat_dst(1,grid_dst%grid_y)
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')'dst grid range:',minval(grid_dst%grid_lon),':',maxval(grid_dst%grid_lon), &
+ '; ',minval(grid_dst%grid_lat),':',maxval(grid_dst%grid_lat)
+ write(*,'(a,f7.2,a,f7.2,a,f7.2,a,f7.2)')'dst u-grid range:',minval(lon_dst),':',maxval(lon_dst),'; ',minval(lat_dst),':',maxval(lat_dst)
+ !endif !if (debug) then
+
+ call search_nearst_grid(grid_src%grid_xt, grid_src%grid_y, lat_src, lon_src, &
+ grid_dst%grid_xt, grid_dst%grid_y, lat_dst, lon_dst, x_oini, y_oini)
+
+ write(*,'(a3, 2i6, 2f11.2,2i11, 2f11.2)')' u:', i, j, lon_dst(i,j), lat_dst(i,j), x_oini(i,j), y_oini(i,j), &
+ lon_src(x_oini(i,j),y_oini(i,j)), lat_src(x_oini(i,j),y_oini(i,j))
+
+ allocate(gwt%gwt_u(grid_dst%grid_xt, grid_dst%grid_y)) !grid_weight_info
+ call cal_grid_weight(grid_src%grid_xt, grid_src%grid_y, lat_src, lon_src, &
+ grid_dst%grid_xt, grid_dst%grid_y, lat_dst, lon_dst, x_oini, y_oini, gwt%max_points, gwt%gwt_u)
+ deallocate(x_oini, y_oini, lon_src, lat_src, lon_dst, lat_dst)
+
+ !---4.3, V-grid
+ write(*,'(a)')'---- processing v-cell ----'
+ allocate(x_oini(grid_dst%grid_x, grid_dst%grid_yt), y_oini(grid_dst%grid_x, grid_dst%grid_yt))
+ allocate(lon_src(grid_src%grid_x, grid_src%grid_yt), lat_src(grid_src%grid_x , grid_src%grid_yt))
+ if ( grid_src%grid_y-grid_src%grid_yt >= 1 ) then
+ lon_src(1:grid_src%grid_x,1:grid_src%grid_yt) = (grid_src%grid_lon(1:grid_src%grid_x,1:grid_src%grid_yt) + &
+ grid_src%grid_lon(1:grid_src%grid_x,2:grid_src%grid_y))/2.0
+ lat_src(1:grid_src%grid_x,1:grid_src%grid_yt) = (grid_src%grid_lat(1:grid_src%grid_x,1:grid_src%grid_yt) + &
+ grid_src%grid_lat(1:grid_src%grid_x,2:grid_src%grid_y))/2.0
+ else
+ lon_src(1:grid_src%grid_x,1:grid_src%grid_yt) = grid_src%grid_lon(1:grid_src%grid_x,1:grid_src%grid_yt)
+ lat_src(1:grid_src%grid_x,1:grid_src%grid_yt) = grid_src%grid_lat(1:grid_src%grid_x,1:grid_src%grid_yt)
+ endif
+
+ allocate(lon_dst(grid_dst%grid_x, grid_dst%grid_yt), lat_dst(grid_dst%grid_x , grid_dst%grid_yt))
+ if ( grid_dst%grid_y-grid_dst%grid_yt >= 1 ) then
+ lon_dst(1:grid_dst%grid_x,1:grid_dst%grid_yt) = (grid_dst%grid_lon(1:grid_dst%grid_x,1:grid_dst%grid_yt) + &
+ grid_dst%grid_lon(1:grid_dst%grid_x,2:grid_dst%grid_y))/2.0
+ lat_dst(1:grid_dst%grid_x,1:grid_dst%grid_yt) = (grid_dst%grid_lat(1:grid_dst%grid_x,1:grid_dst%grid_yt) + &
+ grid_dst%grid_lat(1:grid_dst%grid_x,2:grid_dst%grid_y))/2.0
+ else
+ lon_dst(1:grid_dst%grid_x,1:grid_dst%grid_yt) = grid_dst%grid_lon(1:grid_dst%grid_x,1:grid_dst%grid_yt)
+ lat_dst(1:grid_dst%grid_x,1:grid_dst%grid_yt) = grid_dst%grid_lat(1:grid_dst%grid_x,1:grid_dst%grid_yt)
+ endif
+ call search_nearst_grid(grid_src%grid_x, grid_src%grid_yt, lat_src, lon_src, &
+ grid_dst%grid_x, grid_dst%grid_yt, lat_dst, lon_dst, x_oini, y_oini)
+
+ write(*,'(a3,2i6, 2f11.2,2i11, 2f11.2)')' v:', i, j, lon_dst(i,j), lat_dst(i,j), x_oini(i,j), y_oini(i,j), &
+ lon_src(x_oini(i,j),y_oini(i,j)), lat_src(x_oini(i,j),y_oini(i,j))
+
+ allocate(gwt%gwt_v(grid_dst%grid_x, grid_dst%grid_yt)) !grid_weight_info
+ call cal_grid_weight(grid_src%grid_x, grid_src%grid_yt, lat_src, lon_src, &
+ grid_dst%grid_x, grid_dst%grid_yt, lat_dst, lon_dst, x_oini, y_oini, gwt%max_points, gwt%gwt_v)
+ deallocate(x_oini, y_oini, lon_src, lat_src, lon_dst, lat_dst)
+
+ return
+ end subroutine cal_src_dst_grid_weight
+!========================================================================================
+!-----------------------------------------------------------------------+
+ subroutine search_nearst_grid0(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
+ dst_lat, dst_lon, dst_in_src_x, dst_in_src_y)
+
+ implicit none
+
+ integer, intent(in) :: src_ix, src_jx, dst_ix, dst_jx
+ real, dimension(src_ix, src_jx), intent(in) :: src_lat, src_lon
+ real, dimension(dst_ix, dst_jx), intent(in) :: dst_lat, dst_lon
+ integer, dimension(dst_ix, dst_jx), intent(out) :: dst_in_src_x, dst_in_src_y
+
+ real, allocatable, dimension(:) :: max_dx, max_dy
+ real :: dis, dis0
+ integer :: i, j, i1, j1
+
+ allocate(max_dy(src_jx))
+ do j = 1, src_jx
+ max_dy(j) = maxval(src_lat(:,j))-minval(src_lat(:,j))
+ enddo
+ allocate(max_dx(src_ix))
+ do i = 1, src_ix
+ max_dx(i) = maxval(src_lon(i,:))-minval(src_lon(i,:))
+ enddo
+
+ !out_ave_dx=abs( (dst_lon(1,int(dst_jx/2))-dst_lon(dst_ix,dst_jx))/real(dst_ix))
+ !out_ave_dy=abs( (dst_lat(int(dst_jx/2),1)-dst_lat(dst_ix,dst_jx))/real(dst_jx))
+ dst_in_src_x=-99; dst_in_src_y=-99
+ write(*,'(a,2f12.6)')'max dst grid dx/dy in deg:', maxval(max_dx), maxval(max_dy)
+
+ do j = 1,dst_jx; do i = 1,dst_ix
+ dis0=99999.0
+ do_search_src_grid_y: do j1 = 1, src_jx
+ !if( abs(dst_lat(i,j)-src_lat(int(src_ix/2),j1)) > 2.0*out_ave_dy ) cycle do_search_src_grid_y
+ !if( abs(dst_lat(i,j)-src_lat(int(src_ix/2),j1)) > 20.0*out_ave_dy .and. &
+ ! abs(dst_lat(i,j)-src_lat(1,j1)) > 20.0*out_ave_dy .and. &
+ ! abs(dst_lat(i,j)-src_lat(src_ix,j1)) > 20.0*out_ave_dy ) cycle do_search_src_grid_y
+ if ( abs(dst_lat(i,j)-src_lat(int(src_ix/2),j1)) > 2.0*max_dy(j1) ) cycle do_search_src_grid_y
+ do_search_src_grid_x: do i1 = 1, src_ix
+ !if ( abs(dst_lon(i,j)-src_lon(i1,j1)) > 1.0*out_ave_dx ) cycle do_search_src_grid_x
+ if ( abs(dst_lon(i,j)-src_lon(i1,j1)) > max_dx(i1) ) cycle do_search_src_grid_x
+ dis=(dst_lon(i,j)-src_lon(i1,j1))**2.0+(dst_lat(i,j)-src_lat(i1,j1))**2.0
+ if ( dis <= dis0 ) then
+ dis0 = dis
+ dst_in_src_x(i,j)=i1
+ dst_in_src_y(i,j)=j1
+ endif
+ enddo do_search_src_grid_x
+ enddo do_search_src_grid_y
+
+ enddo; enddo
+
+ deallocate(max_dy, max_dx)
+
+ return
+ end subroutine search_nearst_grid0
+
+!-----------------------------------------------------------------------+
+ subroutine search_nearst_grid(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
+ dst_lat, dst_lon, dst_in_src_x, dst_in_src_y)
+
+ implicit none
+
+ integer, intent(in) :: src_ix, src_jx, dst_ix, dst_jx
+ real, dimension(src_ix, src_jx), intent(in) :: src_lat, src_lon
+ real, dimension(dst_ix, dst_jx), intent(in) :: dst_lat, dst_lon
+ integer, dimension(dst_ix, dst_jx), intent(out) :: dst_in_src_x, dst_in_src_y
+
+ integer, allocatable, dimension(:,:,:) :: src_points_lon, src_points_lat
+ integer, allocatable, dimension(:,:) :: src_points
+ real, allocatable, dimension(:) :: ll_lon, ll_lat
+
+ integer :: i, j, ll_ix, ll_jx, i1, j1, max_points, i2, j2, i3, j3, n
+ real :: min_lon, min_lat, max_lon, max_lat, d_ll, dis, dis0, dis_src, dis_dst
+ logical :: src_in_bin
+ real :: earth_dist
+
+ !---define serach bins
+ d_ll = 0.1 !default bin size is 0.1 degx0.1 deg
+ i1=int(src_ix/2); j1=int(src_jx/2);
+ dis=sqrt((src_lon(i1,j1)-src_lon(i1+1,j1+1))**2.0+(src_lat(i1,j1)-src_lat(i1+1,j1+1))**2.0)
+ dis_src=int(dis*100.)/100.
+ d_ll=max(dis_src,d_ll)
+ i1=int(dst_ix/2); j1=int(dst_jx/2);
+ dis=sqrt((dst_lon(i1,j1)-dst_lon(i1+1,j1+1))**2.0+(dst_lat(i1,j1)-dst_lat(i1+1,j1+1))**2.0)
+ dis_dst=int(dis*100.)/100.
+ d_ll=max(dis_dst,d_ll)
+ !---determine max_points in each bin
+ max_points=min(max(10, 30*(int(d_ll/min(dis_src,dis_dst))+1)**2), 100000)
+
+ min_lon = min(minval(src_lon), minval(dst_lon)) - 5.*d_ll
+ min_lat = min(minval(src_lat), minval(dst_lat)) - 5.*d_ll
+ max_lon = max(maxval(src_lon), maxval(dst_lon)) + 5.*d_ll
+ max_lat = max(maxval(src_lat), maxval(dst_lat)) + 5.*d_ll
+ min_lon = int(min_lon*10)/10.0
+ max_lon = int((max_lon+0.5)*10)/10.0
+ min_lat = int(min_lat*10)/10.0
+ max_lat = int((max_lat+0.5)*10)/10.0
+
+ ll_ix = int((max_lon - min_lon)/d_ll) + 1
+ ll_jx = int((max_lat - min_lat)/d_ll) + 1
+ write(*,'(a,f,i )')'ll bin size d_ll and max_points:', d_ll, max_points
+ write(*,'(a,3f )')'min lon for src dst min:', minval(src_lon), minval(dst_lon), min_lon
+ write(*,'(a,3f,i)')'max lon for src dst max:', maxval(src_lon), maxval(dst_lon), max_lon, ll_ix
+ write(*,'(a,3f )')'min lat for src dst min:', minval(src_lat), minval(dst_lat), min_lat
+ write(*,'(a,3f,i)')'max lat for src dst max:', maxval(src_lat), maxval(dst_lat), max_lat, ll_jx
+ allocate ( ll_lon(ll_ix), ll_lat(ll_jx))
+ do i = 1, ll_ix
+ ll_lon(i) = min_lon + (i-1)*d_ll
+ enddo
+ do j = 1, ll_jx
+ ll_lat(j) = min_lat + (j-1)*d_ll
+ enddo
+ write(*,'(a,f10.3,a,f10.3,a,f10.3,a,f10.3)')'search grids: ', ll_lon(1),'-->',ll_lon(ll_ix),' : ', ll_lat(1), '-->', ll_lat(ll_jx)
+
+ !---sign src grids to search bins
+ allocate ( src_points(ll_ix,ll_jx))
+ allocate ( src_points_lon(ll_ix,ll_jx,max_points), src_points_lat(ll_ix,ll_jx,max_points))
+ src_points=0
+
+ !--- may need halo
+ write(*,'(a)')'---sign src to ll grids'
+ do j = 1, src_jx; do i = 1, src_ix
+ i1 = int((src_lon(i,j) - ll_lon(1))/d_ll) + 1
+ j1 = int((src_lat(i,j) - ll_lat(1))/d_ll) + 1
+ do i2 = -1, 1; do j2 = -1, 1; !add halo
+ i3=i1+i2; j3=j1+j2
+ if ( i3 >= 1 .and. i3 <= ll_ix .and. j3 >= 1 .and. j3 <= ll_jx ) then
+ if ( src_points(i3,j3) < max_points ) then
+ src_in_bin=.false.
+ do n=1,src_points(i3,j3)
+ if ( i .eq. src_points_lon(i3,j3,n) .and. &
+ j .eq. src_points_lat(i3,j3,n) ) then
+ !---src point already included, skip
+ src_in_bin=.true.
+ exit
+ endif
+ enddo
+ !---add the src point into the ll grid bin if it is not yet included
+ if ( .not. src_in_bin ) then
+ src_points(i3,j3) = src_points(i3,j3) + 1
+ src_points_lon(i3,j3,src_points(i3,j3)) = i
+ src_points_lat(i3,j3,src_points(i3,j3)) = j
+ endif
+ else
+ write(*,'(a,6i6,2f10.3)') 'WARNING: src_points(i3,j3) >= max_points at i3, j3, i, j, src_lon(i,j), src_lat(i,j)', &
+ src_points(i3,j3), max_points, i3, j3, i, j, src_lon(i,j), src_lat(i,j)
+ endif
+ !---may need add halo:
+ endif
+ enddo; enddo
+ enddo; enddo
+
+ !---search nearest src grid for each dst grid
+ write(*,'(a)')'---search nearest src grid for each dst grid'
+ do j = 1, dst_jx; do i = 1, dst_ix
+ !---calculate dst grid position in search-bin
+ i1 = int((dst_lon(i,j) - ll_lon(1))/d_ll) + 1
+ j1 = int((dst_lat(i,j) - ll_lat(1))/d_ll) + 1
+ if ( i1 < 1 .or. j1 < 1 ) then
+ write(*,'(a,4i6,4f10.3)')'i1j1---',i,j,i1,j1,ll_lon(1),ll_lat(1),dst_lon(i,j),dst_lat(i,j)
+ stop
+ endif
+ if ( src_points(i1,j1) > 0 .and. src_points(i1,j1) <= max_points ) then
+ !i2=i+1; if ( i2 > dst_ix) i2=i-1
+ !j2=j+1; if ( j2 > dst_jx) j2=j-1
+ dis0=999999.0
+ do n = 1, src_points(i1,j1)
+ if ( src_points_lon(i1,j1,n) < 1 .or. src_points_lon(i1,j1,n) > src_ix .or. src_points_lat(i1,j1,n) < 1 .or. src_points_lat(i1,j1,n) > src_jx ) then
+ write(*,'(7i8)')n, i, j, i1, j1, src_points_lon(i1,j1,n), src_points_lat(i1,j1,n)
+ endif
+ !dis=(dst_lon(i,j)-src_lon(src_points_lon(i1,j1,n),src_points_lat(i1,j1,n)))**2.0 + &
+ ! (dst_lat(i,j)-src_lat(src_points_lon(i1,j1,n),src_points_lat(i1,j1,n)))**2.0
+ !---calculate great circle earth distance in km
+ dis=earth_dist(src_lon(src_points_lon(i1,j1,n),src_points_lat(i1,j1,n)), &
+ src_lat(src_points_lon(i1,j1,n),src_points_lat(i1,j1,n)), &
+ dst_lon(i,j),dst_lat(i,j))/1000.
+ if ( dis < dis0 ) then
+ dis0 = dis
+ dst_in_src_x(i,j)=src_points_lon(i1,j1,n)
+ dst_in_src_y(i,j)=src_points_lat(i1,j1,n)
+ endif
+ enddo
+ else
+ dst_in_src_x(i,j)=-99
+ dst_in_src_y(i,j)=-99
+ endif
+ enddo; enddo
+
+ !---clean up
+ deallocate(ll_lon, ll_lat, src_points, src_points_lon, src_points_lat)
+ write(*,'(a)')'---search_nearst_grid finished'
+
+ return
+ end subroutine search_nearst_grid
+
+!-----------------------------------------------------------------------+
+ subroutine cal_grid_weight(src_ix, src_jx, src_lat, src_lon, dst_ix, dst_jx, &
+ dst_lat, dst_lon, dst_in_src_x, dst_in_src_y, max_points, gw )
+
+ use var_type
+ implicit none
+ integer, intent(in) :: src_ix, src_jx, dst_ix, dst_jx, max_points
+ real, dimension(src_ix, src_jx), intent(in) :: src_lat, src_lon
+ real, dimension(dst_ix, dst_jx), intent(in) :: dst_lat, dst_lon
+ integer, dimension(dst_ix, dst_jx), intent(in) :: dst_in_src_x, dst_in_src_y
+ type(gridmap_info), dimension(dst_ix, dst_jx), intent(inout) :: gw !gridweight
+
+ integer :: i, j, k, n, i1, j1, ixs, jxs, ixi, jxi, min_ij_src, min_ij_dst
+ real :: dst_weight, earth_dist, dis, lon180_1, lon180_2
+
+ do j = 1,dst_jx; do i = 1,dst_ix
+ ixs=dst_in_src_x(i,j) !the position in src grids
+ jxs=dst_in_src_y(i,j)
+
+ gw(i,j)%src_points=0
+ allocate(gw(i,j)%src_x(max_points), gw(i,j)%src_y(max_points), gw(i,j)%src_weight(max_points))
+ if ( ixs >= 1 .and. ixs <= src_ix .and. jxs >= 1 .and. jxs <= src_jx ) then
+ n=0 !gw(i,j)%src_points=0
+ do j1 = -1, 1; do i1 = -1, 1;
+ !do j1 = 0, 0; do i1 = 0, 0
+ if ( i1*j1 == 0 ) then !5-point
+ ixi=ixs+i1; jxi=jxs+j1
+ !---change left to center
+ if ( ixi < 1 ) ixi=3
+ if ( ixi > src_ix ) ixi=src_ix-2
+ if ( jxi < 1 ) jxi=3
+ if ( jxi > src_jx ) jxi=src_jx-2
+ if ( ixi >= 1 .and. ixi <= src_ix .and. jxi >= 1 .and. jxi <= src_jx ) then
+ n=n+1
+ gw(i,j)%src_x(n)=ixi
+ gw(i,j)%src_y(n)=jxi
+ !gw(i,j)%src_weight(n)=earth_dist(src_lon(ixi,jxi),src_lat(ixi,jxi),dst_lon(i,j),dst_lat(i,j))
+ !nolinear dis weight
+ !gw(i,j)%src_weight(n)=gw(i,j)%src_weight(n)*gw(i,j)%src_weight(n)
+ !---use the weighting function based on exp(-r/r_scale); here r_scale is hardcoded as 2km currently
+ gw(i,j)%src_weight(n)=exp(-earth_dist(src_lon(ixi,jxi),src_lat(ixi,jxi),dst_lon(i,j),dst_lat(i,j))/2000.)
+ endif !if ( ixi >= 1 .and. ixi <= src_ix .and. jxi >= 1 .and. jxi <= src_jx ) then
+ endif
+ enddo; enddo
+
+ !---convert earth_dist to weightening
+ gw(i,j)%src_points=n
+ if ( n > 0 ) then
+ dis=0.
+ do k = 1, n
+ dis=dis+gw(i,j)%src_weight(k)
+ enddo
+ if ( dis == 0. ) then
+ gw(i,j)%src_weight(1:n)=1.0/real(n)
+ else if (dis > 0. .and. dis < 9000000000. ) then
+ !gw(i,j)%src_weight(1:n)=gw(i,j)%src_weight(1:n)/dis
+ if ( n <= 1 ) then
+ gw(i,j)%src_weight(1:n)=1.0
+ else
+ !gw(i,j)%src_weight(1:n)=(dis-gw(i,j)%src_weight(1:n))/((n-1)*dis)
+ gw(i,j)%src_weight(1:n)=gw(i,j)%src_weight(1:n)/dis
+ endif
+ else
+ write(*,'(a)')'earth_dist calculation is wrong'
+ endif
+ endif
+ endif
+
+ !---select dst grids for smooth if needed
+ gw(i,j)%dst_points=0
+ dst_weight=0.0
+ allocate(gw(i,j)%dst_x(max_points), gw(i,j)%dst_y(max_points), gw(i,j)%dst_weight(max_points))
+
+ !if ( ixs > 1 .and. ixs < src_ix .and. jxs > 1 .and. jxs < src_jx ) then
+ ! !---when the grid is inside of src-domain, no dst grid is needed
+ ! !dst_weight=0.0
+ gw(i,j)%dst_points=1
+ gw(i,j)%dst_x(1)=i
+ gw(i,j)%dst_y(1)=j
+ gw(i,j)%dst_weight(1)=1.0
+ !else if ( (i==1 .and. ixs==1) .or. (i==dst_ix .and. ixs==src_ix) .or. (j==1 .and. jxs==1) .or. (j==dst_jx .and. jxs==src_jx) ) then
+ ! !---when the dst domain is the same as the src domain, no dst grid is needed too
+ ! !--- so just the outest circle
+ ! !dst_weight=0.0
+ ! gw(i,j)%dst_points=1
+ ! gw(i,j)%dst_x(1)=i
+ ! gw(i,j)%dst_y(1)=j
+ ! gw(i,j)%dst_weight(1)=1.0
+ !else
+ ! !if ( ixs <= 2 .or. ixs >= src_ix-1 .or. jxs >= 2 .or. jxs <= src_jx-1 ) then
+ ! !---add self
+ ! n=1
+ ! gw(i,j)%dst_x(n) = i
+ ! gw(i,j)%dst_y(n) = j
+ ! gw(i,j)%dst_weight(n) = 1.0
+ ! !dst_weight=0.3
+
+ ! if ( ixs == 1 .or. ixs == src_ix .or. jxs == 1 .or. jxs == src_jx ) then
+ ! !---if the grid is on the edge of the src domain, then add 9-point smooth.
+ ! do j1 = -1, 1; do i1 = -1, 1
+ ! if ( i1 /= 0 .and. j1 /= 0 ) then
+ ! ixi=i+i1; jxi=j+j1
+ ! if ( ixi >= 1 .and. ixi <= dst_ix .and. jxi >=1 .and. jxi <= dst_jx ) then
+ ! n=n+1; gw(i,j)%dst_x(n)=ixi; gw(i,j)%dst_y(n)=jxi; gw(i,j)%dst_weight(n)=0.5
+ ! endif
+ ! endif
+ ! enddo; enddo
+ ! !dst_weight=0.5
+ ! !elseif ( ixs < 1 .or. ixs > src_ix .or. jxs < 1 .or. jxs > src_jx ) then
+ ! !dst_weight=1.0
+ ! endif
+
+ ! gw(i,j)%dst_points=n
+ ! gw(i,j)%dst_weight(1:n)=gw(i,j)%dst_weight(1:n)/sum(gw(i,j)%dst_weight(1:n))
+ !endif
+
+ if ( ixs>=1 .and. ixs<=src_ix .and. jxs>=1 .and. jxs<=src_jx) then !inside src-domain
+ dst_weight=0.0
+ if ( gwt%relaxzone < 0 ) gwt%relaxzone = min(30, int(min(src_ix, src_jx, dst_ix, dst_jx)/10))
+ !--- find relaxzone: min (i,j) or max (i,j) grids to src (1,1) and src(ix,jx)
+ ! ixs, jxs
+ min_ij_src = min(ixs, jxs, src_ix-ixs, src_jx-jxs) ! shortest distance (grid not earth-distance) from SRC domain edge
+ min_ij_dst = min(i, j, dst_ix-i, dst_jx-j)
+ if ( min_ij_src <= gwt%relaxzone .and. min_ij_dst > 2 .and. gwt%relaxzone > 0 ) then
+ dst_weight = real(gwt%relaxzone - min_ij_src)/real(gwt%relaxzone)
+ if ( dst_weight < 0.0 .or. dst_weight > 1.0 ) then
+ write(*,'(a,7i6,f10.4)')'---relaxzone dst_weight:', i,j,ixs,jxs,min_ij_src,min_ij_dst,gwt%relaxzone,dst_weight
+ stop
+ endif
+ endif
+ else
+ dst_weight=1.0
+ endif
+
+ !--- find TC vortex relax zone
+ if ( tc%vortexrep==1 .and. tc%lat>-85. .and. tc%lat<85. .and. tc%lon>=-180. .and. tc%lon<=360. ) then
+ lon180_1=src_lon(ixs,jxs)
+ if ( lon180_1 > 180. ) lon180_1 = lon180_1 -360.
+ lon180_2=tc%lon
+ if ( lon180_2 > 180. ) lon180_2 = lon180_2 - 360.
+ dis = earth_dist(lon180_1,src_lat(ixs,jxs),lon180_2,tc%lat)/1000.
+
+ if ( abs(tc%vortexreplace_r(1)-tc%vortexreplace_r(2)) < 1.0 .or. tc%vortexreplace_r(1) < 1.0 .or. tc%vortexreplace_r(2) < 1.0 ) then
+ tc%vortexreplace_r(1)=600.
+ tc%vortexreplace_r(2)=900.
+ endif
+ if ( dis < tc%vortexreplace_r(1) ) then
+ dst_weight=0.0
+ else if ( dis > tc%vortexreplace_r(2) ) then
+ dst_weight=1.0
+ else
+ dst_weight=(dis-tc%vortexreplace_r(1))/(tc%vortexreplace_r(2)-tc%vortexreplace_r(1))
+ endif
+ !write(*,*)'----tc zone', tc%lon, tc%lat, dis, tc%vortexreplace_r(1:2), dst_weight
+ if ( dst_weight < 0.0 .or. dst_weight > 1.0 ) then
+ write(*,'(a,4i6,4f10.2)')'---vortex dst_weight:', i,j,ixs,jxs,tc%vortexreplace_r(1:2), dis, dst_weight
+ stop
+ endif
+ !else
+ ! write(*,*)'----tc zone', tc%lon, tc%lat, dis, tc%vortexreplace_r(1:2), dst_weight
+ ! stop
+ endif
+
+ !---combine src and dst weight
+ if ( gw(i,j)%src_points > 0 ) then
+ gw(i,j)%src_weight(1:gw(i,j)%src_points)=(1.0-dst_weight)*gw(i,j)%src_weight(1:gw(i,j)%src_points)
+ gw(i,j)%dst_weight(1:gw(i,j)%dst_points)= dst_weight *gw(i,j)%dst_weight(1:gw(i,j)%dst_points)
+ else
+ gw(i,j)%src_weight = 0.
+ endif
+
+ enddo; enddo
+
+ return
+ end subroutine cal_grid_weight
+
+!-----------------------------------------------------------------------+
+ subroutine combine_grids_for_remap(ixi, jxi, kxi, txi, fdat_src, ixo, jxo, kxo, txo, fdat_dst, gw, fdat_out)
+
+! --- remap: (src U dst) --> src
+! --- merge: (src U dst) --> dst
+
+ use constants
+ use var_type
+ implicit none
+ integer, intent(in) :: ixi, jxi, kxi, txi, ixo, jxo, kxo, txo
+ real, dimension(ixi, jxi, kxi, txi), intent(in) :: fdat_src
+ real, dimension(ixo, jxo, kxo, txo), intent(in) :: fdat_dst
+ type(gridmap_info), dimension(ixo, jxo), intent(in) :: gw
+ real, dimension(ixo, jxo, kxo, txo), intent(out) :: fdat_out
+
+ integer :: i, j, k, n, i1, j1, k1, n1, ncount
+
+ do n = 1, txo; do k = 1, kxo; do j = 1, jxo; do i = 1, ixo
+ fdat_out(i,j,k,n)=0.0
+ ncount=0
+ if ( gw(i,j)%src_points > 0 ) then
+ do_src_points_loop: do n1 = 1, gw(i,j)%src_points
+ i1=gw(i,j)%src_x(n1)
+ j1=gw(i,j)%src_y(n1)
+ if ( i1 < 1 .or. i1 > ixi .or. j1 < 1 .or. j1 > jxi ) cycle do_src_points_loop
+ if ( gw(i,j)%src_weight(n1) <= 0. .or. gw(i,j)%src_weight(n1) > 1.0 ) cycle do_src_points_loop
+ if ( fdat_src(i1,j1,k,n) < -99999. .or. fdat_src(i1,j1,k,n) > 90000000. ) cycle do_src_points_loop
+ fdat_out(i,j,k,n)=fdat_out(i,j,k,n)+gw(i,j)%src_weight(n1)*fdat_src(i1,j1,k,n)
+ ncount=ncount+1
+ enddo do_src_points_loop
+ endif
+ if ( gw(i,j)%dst_points > 0 ) then
+ do_dst_points_loop: do n1 = 1, gw(i,j)%dst_points
+ i1=gw(i,j)%dst_x(n1)
+ j1=gw(i,j)%dst_y(n1)
+ if ( i1 < 1 .or. i1 > ixo .or. j1 < 1 .or. j1 > jxo ) cycle do_dst_points_loop
+ if ( gw(i,j)%dst_weight(n1) <= 0. .or. gw(i,j)%dst_weight(n1) > 1.0 ) cycle do_dst_points_loop
+ if ( fdat_dst(i1,j1,k,n) < -99999. .or. fdat_dst(i1,j1,k,n) > 90000000. ) cycle do_dst_points_loop
+ fdat_out(i,j,k,n)=fdat_out(i,j,k,n)+gw(i,j)%dst_weight(n1)*fdat_dst(i1,j1,k,n)
+ ncount=ncount+1
+ enddo do_dst_points_loop
+ endif
+ if (ncount < 1 ) fdat_out(i,j,k,n)=missing
+
+ !---debug
+ !if ( (i == int(ixo/4) .or. i == int(ixo/2) .or. i == ixo-1) .and. &
+ ! (j == int(jxo/4) .or. j == int(jxo/2) .or. j == jxo-1) .and. k==1 .and. n==1 ) then
+ if ( i == int(ixo/2) .and.j == int(jxo/2) .and. k==1 .and. n==1 ) then
+ write(*,'(a, 5i10)')'--combine_grids_for_remap: ',i,j, gw(i,j)%src_points, gw(i,j)%dst_points, ncount
+ write(*,'(a, 90i10)')'-- src_points: ', ((gw(i,j)%src_x(n1), gw(i,j)%src_y(n1)),n1=1,gw(i,j)%src_points)
+ write(*,'(a,90f)') '-- src_weight: ', ((gw(i,j)%src_weight(n1)),n1=1,gw(i,j)%src_points)
+ write(*,'(a,90f)') '-- src_values: ', ( fdat_src(gw(i,j)%src_x(n1),gw(i,j)%src_y(n1),k,n),n1=1,gw(i,j)%src_points)
+ if ( gw(i,j)%dst_points > 0 ) then
+ write(*,'(a, 90i10)')'-- dst_points: ', ((gw(i,j)%dst_x(n1), gw(i,j)%dst_y(n1)),n1=1,gw(i,j)%dst_points)
+ write(*,'(a,90f10.4)')'-- dst_weight: ', ((gw(i,j)%dst_weight(n1)),n1=1,gw(i,j)%dst_points)
+ write(*,'(a, e)') '-- dst_values: ', ( fdat_dst(gw(i,j)%dst_x(n1),gw(i,j)%dst_y(n1),k,n),n1=1,gw(i,j)%dst_points)
+ else
+ write(*,'(a)') '-- no dst point'
+ endif
+ write(*,'(a, f)') '-- remaped value: ', fdat_out(i,j,k,n)
+ endif
+
+ enddo; enddo; enddo; enddo
+
+ return
+ end subroutine combine_grids_for_remap
+
+!-----------------------------------------------------------------------+
+ subroutine combine_grids_for_merge(ixi, jxi, kxi, txi, fdat_src, ixo, jxo, kxo, txo, fdat_dst, gw, fdat_out)
+
+! --- remap: (src U dst) --> src
+! --- merge: (src U dst) --> dst
+
+ use constants
+ use var_type
+ implicit none
+ integer, intent(in) :: ixi, jxi, kxi, txi, ixo, jxo, kxo, txo
+ real, dimension(ixi, jxi, kxi, txi), intent(in) :: fdat_src
+ real, dimension(ixo, jxo, kxo, txo), intent(in) :: fdat_dst
+ type(gridmap_info), dimension(ixo, jxo), intent(in) :: gw
+ real, dimension(ixo, jxo, kxo, txo), intent(out) :: fdat_out
+
+ integer :: i, j, k, n, i1, j1, k1, n1, ncount
+
+ do n = 1, txo; do k = 1, kxo; do j = 1, jxo; do i = 1, ixo
+ fdat_out(i,j,k,n)=0.0
+ ncount=0
+ if ( gw(i,j)%dst_points > 0 ) then
+ do_dst_points_loop: do n1 = 1, gw(i,j)%dst_points
+ i1=gw(i,j)%dst_x(n1)
+ j1=gw(i,j)%dst_y(n1)
+ if ( i1 < 1 .or. i1 > ixo .or. j1 < 1 .or. j1 > jxo ) cycle do_dst_points_loop
+ !if ( gw(i,j)%dst_weight(n1) <= 0. .or. gw(i,j)%dst_weight(n1) > 1.0 ) cycle do_dst_points_loop
+ if ( fdat_dst(i1,j1,k,n) < -99999. .or. fdat_dst(i1,j1,k,n) > 90000000. ) cycle do_dst_points_loop
+ !fdat_out(i,j,k,n)=fdat_out(i,j,k,n)+gw(i,j)%dst_weight(n1)*fdat_dst(i1,j1,k,n)
+ fdat_out(i,j,k,n)=fdat_out(i,j,k,n)+fdat_dst(i1,j1,k,n)
+ ncount=ncount+1
+ enddo do_dst_points_loop
+ endif
+ if ( ncount > 0 ) then
+ fdat_out(i,j,k,n)=fdat_out(i,j,k,n)/real(ncount)
+ else
+ if ( gw(i,j)%src_points > 0 ) then
+ do_src_points_loop: do n1 = 1, gw(i,j)%src_points
+ i1=gw(i,j)%src_x(n1)
+ j1=gw(i,j)%src_y(n1)
+ if ( i1 < 1 .or. i1 > ixi .or. j1 < 1 .or. j1 > jxi ) cycle do_src_points_loop
+ if ( gw(i,j)%src_weight(n1) <= 0. .or. gw(i,j)%src_weight(n1) > 1.0 ) cycle do_src_points_loop
+ if ( fdat_src(i1,j1,k,n) < -99999. .or. fdat_src(i1,j1,k,n) > 90000000. ) cycle do_src_points_loop
+ fdat_out(i,j,k,n)=fdat_out(i,j,k,n)+gw(i,j)%src_weight(n1)*fdat_src(i1,j1,k,n)
+ ncount=ncount+1
+ enddo do_src_points_loop
+ endif
+ endif
+ if (ncount < 1 ) fdat_out(i,j,k,n)=missing
+
+ !---debug
+ !if ( (i == int(ixo/4) .or. i == int(ixo/2) .or. i == ixo-1) .and. &
+ ! (j == int(jxo/4) .or. j == int(jxo/2) .or. j == jxo-1) .and. k==1 .and. n==1 ) then
+ if ( i == int(ixo/2) .and.j == int(jxo/2) .and. k==1 .and. n==1 ) then
+ write(*,'(a, 5i10)')'--combine_grids_for_merge: ',i,j, gw(i,j)%src_points, gw(i,j)%dst_points, ncount
+ write(*,'(a, 90i10)')'-- src_points: ', ((gw(i,j)%src_x(n1), gw(i,j)%src_y(n1)),n1=1,gw(i,j)%src_points)
+ write(*,'(a,90f)') '-- src_values: ', ( fdat_src(gw(i,j)%src_x(n1),gw(i,j)%src_y(n1),k,n),n1=1,gw(i,j)%src_points)
+ if ( gw(i,j)%dst_points > 0 ) then
+ write(*,'(a, 90i10)')'-- dst_points: ', ((gw(i,j)%dst_x(n1), gw(i,j)%dst_y(n1)),n1=1,gw(i,j)%dst_points)
+ write(*,'(a, e)') '-- dst_values: ', ( fdat_dst(gw(i,j)%dst_x(n1),gw(i,j)%dst_y(n1),k,n),n1=1,gw(i,j)%dst_points)
+ else
+ write(*,'(a)') '-- no dst point'
+ endif
+ write(*,'(a, f)') '-- remaped value: ', fdat_out(i,j,k,n)
+ endif
+
+ enddo; enddo; enddo; enddo
+
+ return
+ end subroutine combine_grids_for_merge
+
+!-----------------------------------------------------------------------+
+ function uppercase (cs)
+
+ implicit none
+ character(len=*), intent(in) :: cs
+ character(len=len(cs)),target :: uppercase
+ integer :: k,tlen
+ character, pointer :: ca
+ integer, parameter :: co=iachar('A')-iachar('a') ! case offset
+ !The transfer function truncates the string with xlf90_r
+ tlen = len_trim(cs)
+ if (tlen <= 0) then ! catch IBM compiler bug
+ uppercase = cs ! simply return input blank string
+ else
+ uppercase = cs(1:tlen)
+!#if defined _CRAYX1
+! do k=1, tlen
+! if(uppercase(k:k) >= "a" .and. uppercase(k:k) <= 'z') uppercase(k:k) = achar(ichar(uppercase(k:k))+co)
+! end do
+!#else
+ do k=1, tlen
+ ca => uppercase(k:k)
+ if(ca >= "a" .and. ca <= "z") ca = achar(ichar(ca)+co)
+ enddo
+!#endif
+ endif
+ end function uppercase
+
+!-----------------------------------------------------------------------+
+ function lowercase (cs)
+
+ implicit none
+ character(len=*), intent(in) :: cs
+ character(len=len(cs)),target :: lowercase
+ integer, parameter :: co=iachar('a')-iachar('A') ! case offset
+ integer :: k,tlen
+ character, pointer :: ca
+ ! The transfer function truncates the string with xlf90_r
+ tlen = len_trim(cs)
+ if (tlen <= 0) then ! catch IBM compiler bug
+ lowercase = cs ! simply return input blank string
+ else
+ lowercase = cs(1:tlen)
+!#if defined _CRAYX1
+! do k=1, tlen
+! if(lowercase(k:k) >= "A" .and. lowercase(k:k) <= 'Z') lowercase(k:k) = achar(ichar(lowercase(k:k))+co)
+! end do
+!#else
+ do k=1, tlen
+ ca => lowercase(k:k)
+ if(ca >= "A" .and. ca <= "Z") ca = achar(ichar(ca)+co)
+ enddo
+!#endif
+ endif
+ end function lowercase
+
+!-----------------------------------------------------------------------+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_datool/sub_wind_process.f90 b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_wind_process.f90
new file mode 100644
index 000000000..94ccbfb15
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_datool/sub_wind_process.f90
@@ -0,0 +1,229 @@
+!========================================================================================
+ subroutine cal_uv_coeff_fv3(nx, ny, grid_lat, grid_lon, cangu, sangu, cangv, sangv)
+!-----------------------------------------------------------------------------
+! This subroutine is adopated from gsi/mod_fv3_lola.f90
+! Yonghui Weng, 20210319
+! --
+!-----------------------------------------------------------------------------
+ use constants
+ implicit none
+
+ integer, intent(in) :: nx, ny
+ real,dimension(nx+1,ny+1), intent(in) :: grid_lat, grid_lon ! FV3
+! real, allocatable, dimension(:,:), intent(out) :: cangu, sangu, cangv, sangv
+ real, dimension(nx,ny+1), intent(out) :: cangu, sangu
+ real, dimension(nx+1,ny), intent(out) :: cangv, sangv
+
+ real, allocatable, dimension(:,:) :: x, y, z
+ integer :: i, j
+ real :: sq180, rlat, diff, rlon, xr, yr, zr, xu, yu, zu, uval, ewval, nsval, xv, yv, zv, vval
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!!! find coefficients for wind conversion btw FV3 & earth
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! allocate ( cangu(nx,ny+1),sangu(nx,ny+1),cangv(nx+1,ny),sangv(nx+1,ny) )
+
+! 1. compute x,y,z at cell cornor from grid_lon, grid_lat
+
+ allocate( x(nx+1,ny+1), y(nx+1,ny+1), z(nx+1,ny+1) )
+ do j=1,ny+1
+ do i=1,nx+1
+ x(i,j)=cos(grid_lat(i,j)*deg2rad)*cos(grid_lon(i,j)*deg2rad)
+ y(i,j)=cos(grid_lat(i,j)*deg2rad)*sin(grid_lon(i,j)*deg2rad)
+ z(i,j)=sin(grid_lat(i,j)*deg2rad)
+ enddo
+ enddo
+
+! 2 find angles to E-W and N-S for U edges
+ sq180=180.**2
+ do j=1,ny+1
+ do i=1,nx
+! center lat/lon of the edge
+ rlat=0.50*(grid_lat(i,j)+grid_lat(i+1,j))
+ diff=(grid_lon(i,j)-grid_lon(i+1,j))**2
+ if(diff < sq180)then
+ rlon=0.50*(grid_lon(i,j)+grid_lon(i+1,j))
+ else
+ rlon=0.50*(grid_lon(i,j)+grid_lon(i+1,j)-360.)
+ endif
+! vector to center of the edge
+ xr=cos(rlat*deg2rad)*cos(rlon*deg2rad)
+ yr=cos(rlat*deg2rad)*sin(rlon*deg2rad)
+ zr=sin(rlat*deg2rad)
+! vector of the edge
+ xu= x(i+1,j)-x(i,j)
+ yu= y(i+1,j)-y(i,j)
+ zu= z(i+1,j)-z(i,j)
+! find angle with cross product
+ uval=sqrt((xu**2+yu**2+zu**2))
+ ewval=sqrt((xr**2+yr**2))
+ nsval=sqrt((xr*zr)**2+(zr*yr)**2+(xr*xr+yr*yr)**2)
+ cangu(i,j)=(-yr*xu+xr*yu)/ewval/uval
+ sangu(i,j)=(-xr*zr*xu-zr*yr*yu+(xr*xr+yr*yr)*zu) / nsval/uval
+ enddo
+ enddo
+
+! 3 find angles to E-W and N-S for V edges
+ do j=1,ny
+ do i=1,nx+1
+ rlat=0.50*(grid_lat(i,j)+grid_lat(i,j+1))
+ diff=(grid_lon(i,j)-grid_lon(i,j+1))**2
+ if(diff < sq180)then
+ rlon=0.50*(grid_lon(i,j)+grid_lon(i,j+1))
+ else
+ rlon=0.50*(grid_lon(i,j)+grid_lon(i,j+1)-360.)
+ endif
+ xr=cos(rlat*deg2rad)*cos(rlon*deg2rad)
+ yr=cos(rlat*deg2rad)*sin(rlon*deg2rad)
+ zr=sin(rlat*deg2rad)
+ xv= x(i,j+1)-x(i,j)
+ yv= y(i,j+1)-y(i,j)
+ zv= z(i,j+1)-z(i,j)
+ vval=sqrt((xv**2+yv**2+zv**2))
+ ewval=sqrt((xr**2+yr**2))
+ nsval=sqrt((xr*zr)**2+(zr*yr)**2+(xr*xr+yr*yr)**2)
+ cangv(i,j)=(-yr*xv+xr*yv)/ewval/vval
+ sangv(i,j)=(-xr*zr*xv-zr*yr*yv+(xr*xr+yr*yr)*zv) / nsval/vval
+ enddo
+ enddo
+
+! 4, clean up
+ deallocate(x, y, z)
+
+ return
+ end subroutine cal_uv_coeff_fv3
+!========================================================================================
+ subroutine earthuv2fv3(nx, ny, u, v, cangu, sangu, cangv, sangv, u_out, v_out)
+!$$$ subprogram documentation block
+! . . . .
+! subprogram: earthuv2fv3
+! prgmmr: wu 2017-06-15
+!
+! abstract: project earth UV to fv3 UV and interpolate to edge of the cell
+!
+! program history log:
+!
+!
+! input argument list:
+! nx,ny - dimensions
+! u,v - earth wind components at center of the cell
+! cangu, sangu, cangv, sangv
+!
+! output argument list:
+! u_out,v_out - output fv3 winds on the cell boundaries
+!
+! attributes:
+! language: f90
+! machine:
+!
+!$$$ end documentation block
+
+ implicit none
+
+ integer, intent(in) :: nx,ny ! fv3 tile x- and y-dimensions
+ real, intent(in ) :: u(nx,ny+1),v(nx+1,ny)
+ real, intent(in ) :: cangu(nx,ny+1),sangu(nx,ny+1)
+ real, intent(in ) :: cangv(nx+1,ny), sangv(nx+1,ny)
+
+ real, intent( out) :: u_out(nx,ny+1),v_out(nx+1,ny)
+
+ integer :: i,j,i1,j1
+!!!!!!! earth u/v to covariant u/v
+! j=1
+! do i=1,nx
+! u_out(i,j)= u(i,j)*cangu(i,j)+v(i,j)*sangu(i,j)
+! end do
+!
+! do j=2,ny
+! do i=1,nx
+! u_out(i,j)=0.50*( (u(i,j)+u(i,j-1))*cangu(i,j)+(v(i,j)+v(i,j-1))*sangu(i,j) )
+! end do
+! end do
+! j=ny
+! do i=1,nx
+! u_out(i,j+1)= u(i,j)*cangu(i,j+1)+v(i,j)*sangu(i,j+1)
+! end do
+!
+! do j=1,ny
+! v_out(1,j)=u(1,j)*cangv(1,j)+v(1,j)*sangv(1,j)
+! do i=2,nx
+! v_out(i,j)=0.50*( (u(i,j)+u(i-1,j))*cangv(i,j)+(v(i,j)+v(i-1,j))*sangv(i,j) )
+! end do
+! v_out(nx+1,j)=u(nx,j)*cangv(nx+1,j)+v(nx,j)*sangv(nx+1,j)
+! end do
+
+ do j = 1, ny+1; do i = 1, nx
+ j1=min(j,ny)
+ u_out(i,j)= u(i,j)*cangu(i,j)+v(i,j1)*sangu(i,j)
+ enddo; enddo
+
+ do j = 1, ny; do i = 1, nx+1
+ i1=min(i,nx)
+ v_out(i,j)=u(i1,j)*cangv(i,j)+v(i,j)*sangv(i,j)
+ enddo; enddo
+
+ return
+ end subroutine earthuv2fv3
+!========================================================================================
+ subroutine fv3uv2earth(nx, ny, u, v, cangu, sangu, cangv, sangv, u_out, v_out)
+!$$$ subprogram documentation block
+! . . . .
+! subprogram: fv3uv2earth
+! prgmmr: wu 2017-06-15
+!
+! abstract: project fv3 UV to earth UV and interpolate to the center of the cells
+!
+! program history log:
+!
+!
+! input argument list:
+! nx,ny - dimensions
+! u,v - earth wind components at center of the cell
+! cangu, sangu, cangv, sangv
+!
+! output argument list:
+! u_out,v_out - output earth wind components at center of the cell
+!
+! attributes:
+! language: f90
+! machine:
+!
+!$$$ end documentation block
+
+ implicit none
+
+ integer, intent(in) :: nx,ny ! fv3 tile x- and y-dimensions
+ real, intent(in ) :: u(nx,ny+1),v(nx+1,ny)
+ real, intent(in ) :: cangu(nx,ny+1),sangu(nx,ny+1)
+ real, intent(in ) :: cangv(nx+1,ny), sangv(nx+1,ny)
+
+ real, intent( out) :: u_out(nx,ny+1),v_out(nx+1,ny)
+
+ integer :: i, j, i1, j1
+
+! do j=1,ny
+! do i=1,nx
+! u_out(i,j)=0.50 *( (u(i,j)*sangv(i,j)-v(i,j)*sangu(i,j))/(cangu(i,j)*sangv(i,j)-sangu(i,j)*cangv(i,j)) &
+! +(u(i,j+1)*sangv(i+1,j)-v(i+1,j)*sangu(i,j+1))/(cangu(i,j+1)*sangv(i+1,j)-sangu(i,j+1)*cangv(i+1,j)))
+! v_out(i,j)=0.50 *( (u(i,j)*cangv(i,j)-v(i,j)*cangu(i,j))/(sangu(i,j)*cangv(i,j)-cangu(i,j)*sangv(i,j)) &
+! +(u(i,j+1)*cangv(i+1,j)-v(i+1,j)*cangu(i,j+1))/(sangu(i,j+1)*cangv(i+1,j)-cangu(i,j+1)*sangv(i+1,j)))
+! end do
+! end do
+
+ do j = 1, ny+1; do i = 1, nx
+ j1=min(j,ny)
+ u_out(i,j)=(u(i,j)*sangv(i,j1)-v(i,j1)*sangu(i,j))/(cangu(i,j)*sangv(i,j1)-sangu(i,j)*cangv(i,j1))
+ enddo; enddo
+
+ do j = 1, ny; do i = 1, nx+1
+ i1=min(i,nx)
+ v_out(i,j)=(u(i1,j)*cangv(i,j)-v(i,j)*cangu(i1,j))/(sangu(i1,j)*cangv(i,j)-cangu(i1,j)*sangv(i,j))
+ enddo; enddo
+
+ return
+ end subroutine fv3uv2earth
+!========================================================================================
+! /work2/noaa/hwrf/noscrub/yweng/hafs_test/hafs_20211112/sorc/hafs_gsi.fd/src/gsi/general_tll2xy_mod.f90
+!========================================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/CMakeLists.txt
new file mode 100644
index 000000000..65ab3b661
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/CMakeLists.txt
@@ -0,0 +1,35 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+cmake_minimum_required(VERSION 3.15)
+project(
+ HAFS_VI
+ LANGUAGES C Fortran)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules/")
+
+message(CMAKE_MODULE_PATH " ${CMAKE_MODULE_PATH}")
+if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(Intel|GNU)$")
+ message(WARNING "Compiler not officially supported: ${CMAKE_Fortran_COMPILER_ID}")
+endif()
+
+if(NOT CMAKE_C_COMPILER_ID MATCHES "^(Intel|GNU)$")
+ message(WARNING "Compiler not officially supported: ${CMAKE_C_COMPILER_ID}")
+endif()
+
+
+#find_package(NetCDF REQUIRED C Fortran)
+#find_package(MPI REQUIRED)
+find_package(OpenMP REQUIRED)
+find_package(MKL REQUIRED)
+
+add_subdirectory(create_trak_guess)
+add_subdirectory(create_trak_init)
+add_subdirectory(split)
+add_subdirectory(anl_pert)
+add_subdirectory(anl_combine)
+add_subdirectory(anl_enhance)
+add_subdirectory(anl_bogus)
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/Makefile
new file mode 100644
index 000000000..673080b86
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/Makefile
@@ -0,0 +1,23 @@
+SHELL=/bin/sh
+include ./configure.vi
+
+SUBDIRS = create_trak_guess create_trak_init split anl_pert anl_combine anl_enhance anl_bogus
+
+all: $(SUBDIRS)
+ for dir in $(SUBDIRS); do \
+ ( cd $$dir; echo "Making $@ in `pwd`" ; make ); \
+ done
+
+cleanall: clean
+
+clean: $(SUBDIRS)
+ for dir in $(SUBDIRS); do \
+ ( cd $$dir; echo "Making $@ in `pwd`" ; \
+ make $@ ); \
+ done
+
+distclean: $(SUBDIRS)
+ for dir in $(SUBDIRS); do \
+ ( cd $$dir; echo "Making $@ in `pwd`" ; \
+ make $@ ); \
+ done
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/CMakeLists.txt
new file mode 100644
index 000000000..1d144e493
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/CMakeLists.txt
@@ -0,0 +1,27 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ anl_bogus.f90
+ convert_axi_xy.f90
+ correct_mat_2.f90
+ interp_coef_agrid.f90)
+
+set(exe_name hafs_vi_anl_bogus.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/Makefile
new file mode 100644
index 000000000..d29288145
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/Makefile
@@ -0,0 +1,15 @@
+include ../configure.vi
+
+OBJS = anl_bogus.o convert_axi_xy.o correct_mat_2.o interp_coef_agrid.o
+EXEC = ../../../exec/hafs_vi_anl_bogus.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/anl_bogus.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/anl_bogus.f90
new file mode 100644
index 000000000..4f94030f2
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/anl_bogus.f90
@@ -0,0 +1,1332 @@
+!??????????????????????????????????????????????????????????
+! SUBROUTINE STORM_RELOCATE(NX,NY,NZ,T1,Q1,U1,V1,Z1,
+! & GLON,GLAT,P1,PT,PDTOP,PD,ETA1,ETA2)
+! SUBPROGRAM
+! PRGRMMR
+!
+! ABSTRACT
+!
+! DECLARE VARIABLES
+!
+ INTEGER I,J,K,NX,NY,NZ,ICH
+!
+ PARAMETER (NST=5,IR=200)
+! PARAMETER (NX=158,NY=329,NZ=42,NST=5)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.)
+
+! PARAMETER (KMX=2*NZ+1)
+!
+ PARAMETER (NZ2=121,IR1=201)
+
+! Variables on 4x hybrid coordinate
+
+ REAL(4) DLMD,DPHD,PT,PDTOP
+ REAL(4) WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ REAL(4) LON1,LAT1,LON2,LAT2
+
+ REAL(4), ALLOCATABLE :: T1(:,:,:),Q1(:,:,:)
+ REAL(4), ALLOCATABLE :: U1(:,:,:),V1(:,:,:),DZDT(:,:,:)
+ REAL(4), ALLOCATABLE :: Z1(:,:,:),P1(:,:,:)
+ REAL(4), ALLOCATABLE :: GLON(:,:),GLAT(:,:)
+ REAL(4), ALLOCATABLE :: PD1(:,:),ETA1(:),ETA2(:)
+
+ REAL(4), ALLOCATABLE :: USCM(:,:),VSCM(:,:) ! Env. wind at new grids
+
+ REAL(4), ALLOCATABLE :: T4(:,:,:),Q4(:,:,:)
+
+! variables for hurricane component
+
+ REAL(4), ALLOCATABLE :: SLPE(:,:),SLP_1(:,:),TENV(:,:,:)
+ REAL(4), ALLOCATABLE :: T_1(:,:,:),Q_1(:,:,:)
+ REAL(4), ALLOCATABLE :: U_1(:,:,:),V_1(:,:,:)
+
+ REAL(4), ALLOCATABLE :: T_2(:,:,:),Q_2(:,:,:),SLP_2(:,:)
+ REAL(4), ALLOCATABLE :: U_2(:,:,:),V_2(:,:,:),SLPE2(:,:)
+
+ REAL(4), ALLOCATABLE :: U_2SB(:,:),T_2SB(:,:),SLP_2SB(:)
+ REAL(4), ALLOCATABLE :: Q_2SB(:,:),temp_e(:),TEK(:),RADIUS2(:)
+
+ REAL(4), ALLOCATABLE :: T_X(:,:,:),Q_X(:,:,:),SLP_X(:,:)
+ REAL(4), ALLOCATABLE :: work_1(:),work_2(:)
+
+! Variables for old domain
+
+ REAL(4) DLMD2,DPHD2,PT2,PDTOP2
+ REAL(4) WBD2,SBD2,CENTRAL_LON2,CENTRAL_LAT2
+
+! working array
+
+ REAL(4), ALLOCATABLE :: SLP1(:,:),RIJ(:,:)
+ REAL(4), ALLOCATABLE :: PMID1(:,:,:),ZMID1(:,:,:)
+ REAL(4), ALLOCATABLE :: ZS1(:,:),TS1(:,:),QS1(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON(:,:),HLAT(:,:)
+ REAL(4), ALLOCATABLE :: VLON(:,:),VLAT(:,:)
+
+ REAL(4), ALLOCATABLE :: U_S(:,:),V_S(:,:)
+ REAL(4), ALLOCATABLE :: U_A(:,:),V_A(:,:)
+
+ REAL(4), ALLOCATABLE :: USC(:,:),VSC(:,:) ! Env. wind at new grids
+ REAL(4), ALLOCATABLE :: USC_1(:,:),VSC_1(:,:) ! hurricane component wind at z=0
+ REAL(4), ALLOCATABLE :: USC1(:,:),VSC1(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: SLPV(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON1(:,:),HLAT1(:,:)
+ REAL(4), ALLOCATABLE :: VLON1(:,:),VLAT1(:,:)
+ REAL(4), ALLOCATABLE :: T21(:,:,:,:),Q21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: U21(:,:,:,:),V21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: SLP21(:,:,:)
+ REAL(4), ALLOCATABLE :: PMV1(:,:,:),PMV2(:,:,:)
+
+ REAL(4), ALLOCATABLE :: A101(:,:),B101(:,:),C101(:,:)
+
+ REAL(4), ALLOCATABLE :: T_4(:,:,:),Q_4(:,:,:)
+
+ REAL(8), ALLOCATABLE :: WRK1(:),WRK2(:),WRK3(:),WRK4(:)
+
+ REAL(4), ALLOCATABLE :: PCST(:),HP(:,:,:),HV(:,:,:)
+ REAL(4), ALLOCATABLE :: P_S(:,:),P_A(:,:)
+ REAL(4), ALLOCATABLE :: PCST1(:,:,:),PCST2(:)
+
+ REAL(4), ALLOCATABLE :: HBWGT1(:,:,:),VBWGT1(:,:,:)
+ integer(4), ALLOCATABLE :: IIH1(:,:),JJH1(:,:)
+ integer(4), ALLOCATABLE :: IIV1(:,:),JJV1(:,:)
+
+ REAL(4), ALLOCATABLE :: dist(:,:)
+
+ integer(4) IH1(4),JH1(4),IV1(4),JV1(4)
+
+ REAL(8) CLON_NEW,CLAT_NEW,CLON_NHC,CLAT_NHC
+
+ REAL(4) th1(IR1),rp(IR1) ! ,RMN
+
+ REAL(4) zmax,PW(121),PW_S(121),PW_M(121)
+
+ integer Ir_v4(4)
+ CHARACTER SN*1,EW*1,DEPTH*1
+
+ DATA PW_S/42*1.0,0.95,0.9,0.85,0.8,0.75,0.7, &
+ 0.65,0.6,0.55,0.5,0.45,0.4,0.35,0.3, &
+ 0.25,0.2,0.15,0.1,0.05,60*0./ ! 850-700mb
+
+ DATA PW_M/121*1.0/
+! DATA PW_M/40*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,35*0./ ! 850-300mb
+!zhang: added basin domain shift option
+ CHARACTER*2 basin
+
+ print*,'this is cold start'
+
+ COEF1=Rd/Cp
+ COEF3=Rd*GAMMA/G
+ COEF2=1./COEF3
+
+ GRD=G/Rd
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi
+ rad=1./pi_deg
+
+ arad=6.371E6*rad
+
+ READ(5,*)ITIM,basin
+
+
+! READ NEW GFS Env. DATA (New Domain)
+
+ IUNIT=20+ITIM
+
+ READ(IUNIT) NX,NY,NZ,I360
+
+ print*,'NX,NY,NZ=',NX,NY,NZ,I360
+
+ NX1=NX+1
+ NY1=NY+1
+ NZ1=NZ+1
+
+ KMX=121
+
+ ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+ ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+ ALLOCATE ( Z1(NX,NY,NZ+1),P1(NX,NY,NZ+1) )
+ ALLOCATE ( GLON(NX,NY),GLAT(NX,NY) )
+ ALLOCATE ( PD1(NX,NY),ETA1(NZ+1),ETA2(NZ+1) )
+ ALLOCATE ( USC(NX,NY),VSC(NX,NY) ) ! Env. wind at new grids
+
+ ALLOCATE ( T4(NX,NY,NZ),Q4(NX,NY,NZ) ) ! orginal data (GFS analysis data)
+
+ ALLOCATE ( TEK(NZ) )
+
+ ALLOCATE ( dist(NX,NY) )
+
+ ALLOCATE ( HLON(NX,NY),HLAT(NX,NY) )
+ ALLOCATE ( VLON(NX,NY),VLAT(NX,NY) )
+ ALLOCATE ( PMID1(NX,NY,NZ),ZMID1(NX,NY,NZ) )
+
+ READ(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) PMID1
+ READ(IUNIT) T1
+ READ(IUNIT) Q1
+ READ(IUNIT) U1
+ READ(IUNIT) V1
+ READ(IUNIT) DZDT
+ READ(IUNIT) Z1
+! READ(IUNIT) GLON,GLAT
+ READ(IUNIT) HLON,HLAT,VLON,VLAT
+ READ(IUNIT) P1
+ READ(IUNIT) PD1
+ READ(IUNIT) ETA1
+ READ(IUNIT) ETA2
+
+ READ(IUNIT) USC
+ READ(IUNIT) VSC
+
+ CLOSE(IUNIT)
+
+ IUNIT=30+ITIM ! Original GFS initial data
+
+ READ(IUNIT) ! NX,NY,NZ
+ READ(IUNIT) ! DLMD,DPHD,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) ! PT,PDTOP
+ READ(IUNIT) T4
+ READ(IUNIT) Q4
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+
+ CLOSE(IUNIT)
+
+ ALLOCATE ( SLP1(NX,NY),RIJ(NX,NY) )
+ ALLOCATE ( ZS1(NX,NY),TS1(NX,NY),QS1(NX,NY) )
+
+ ALLOCATE ( USCM(NX,NY),VSCM(NX,NY) )
+ ALLOCATE ( P_S(NX,NY),P_A(NX,NY) )
+
+!
+! First, compute variables at surface level (SLP1,TS1,QS1)
+
+ DO J=1,NY
+ DO I=1,NX
+ GLON(I,J)=HLON(I,J)
+ GLAT(I,J)=HLAT(I,J)
+ END DO
+ END DO
+
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+ TV1=T1(I,J,K)*(1.+D608*Q1(I,J,K))
+ ZMID1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5+ &
+ 0.5*TV1/GAMMA*(2.-(P1(I,J,K)/PMID1(I,J,K))**COEF3- &
+ (P1(I,J,K+1)/PMID1(I,J,K))**COEF3)
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ZMID1(I,J,K)=0.5*(Z1(I,J,K)+Z1(I,J,K+1))
+! THET1(I,J,K)=T1(I,J,K)*(1.E6/PMID1(I,J,K))**COEF1
+ ENDDO
+ ENDDO
+ ENDDO
+
+ DO J=1,NY ! given variables from domain 1
+ DO I=1,NX ! in case there is no data from domain 2
+ ZS1(I,J)=Z1(I,J,1)
+ TS1(I,J) =T1(I,J,1)+GAMMA*(ZMID1(I,J,1)-Z1(I,J,1))
+ QS1(I,J) =Q1(I,J,1)
+ ENDDO
+ ENDDO
+
+
+!C COMPUTE SEA LEVEL PRESSURE.
+!C
+ DO J=1,NY
+ DO I=1,NX
+ ZSF1 = ZMID1(I,J,1)
+ PSF1 = PMID1(I,J,1)
+ TV1 = T1(I,J,1)*(1.+D608*Q1(I,J,1))
+ A = (GAMMA * ZSF1) / TV1
+ SLP1(I,J) = PSF1*(1+A)**COEF2
+ ENDDO
+ ENDDO
+
+ SLP1_MEAN=0.
+ SUM11=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP1_MEAN=SLP1_MEAN+SLP1(I,J)
+ SUM11=SUM11+1
+ ENDDO
+ ENDDO
+
+ SLP1_MEAN=SLP1_MEAN/SUM11
+
+! correct to surface pert P
+
+ JM1=0.5*NY
+ IM1=0.5*NX
+
+ SLP_AVE=0.
+ SLP_SUM=0.
+ DO J=JM1-100,JM1+100
+ DO I=IM1-50,IM1+50
+ SLP_AVE=SLP_AVE+SLP1(I,J)
+ SLP_SUM=SLP_SUM+1.
+ END DO
+ END DO
+
+ print*,'SLP_TT,SLP_SUM=',SLP_AVE,SLP_SUM
+
+ SLP_AVE=SLP_AVE/SLP_SUM
+
+ print*,'SLP_AVE 1 =',SLP_AVE
+
+ SLP_MIN=1.E20
+ DO J=JM1-20,JM1+20
+ DO I=IM1-10,IM1+10
+ IF(SLP_MIN.GT.SLP1(I,J))THEN
+ SLP_MIN=SLP1(I,J)
+ END IF
+ END DO
+ END DO
+
+ DP_CT=min(0.,SLP_MIN-SLP_AVE)
+
+! compute 10m wind
+
+ IUNIT=40+ITIM
+
+ READ(IUNIT) JX,JY
+
+ ALLOCATE ( A101(JX,JY),B101(JX,JY),C101(JX,JY) )
+
+ READ(IUNIT) !LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) !PM1
+ READ(IUNIT) !T1
+ READ(IUNIT) !Q1
+ READ(IUNIT) !U1
+ READ(IUNIT) !V1
+ READ(IUNIT) !DZDT ! new
+ READ(IUNIT) !Z1
+ READ(IUNIT) !HLON,HLAT,VLON,VLAT
+ READ(IUNIT) !P1
+ READ(IUNIT) !PD ! surface pressure
+ READ(IUNIT) !ETA1
+ READ(IUNIT) !ETA2
+ READ(IUNIT) A101
+ READ(IUNIT) B101
+ READ(IUNIT) C101
+
+ CLOSE(IUNIT)
+
+ PRINT*,'JX,JY,NX,NY=',JX,JY,NX,NY
+
+
+ JX1=JX-1
+
+ DO J=1,NY
+ DO I=1,NX
+ USC(I,J)=U1(I,J,1)
+ VSC(I,J)=V1(I,J,1)
+ END DO
+ END DO
+
+! finsih compute 10m wind
+
+! WRITE(62)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(62)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(62)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(62)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(62)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(62)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(62)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+!
+ WBD=LON1
+ SBD=LAT1
+
+ write(*,*)'DLMD,DPHD,PT,PDTOP=',DLMD,DPHD,PT,PDTOP
+ write(*,*)'WBD,SBD,CENTRAL_LON,CENTRAL_LAT=', &
+ WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ do k=1,nz1
+ write(*,*)'K,ETA1,ETA2=',K,ETA1(k),ETA2(k)
+ end do
+
+ print*,'CLON,CLAT=',GLON(1+(NX-1)/2,1+(NY-1)/2), &
+ GLAT(1+(NX-1)/2,1+(NY-1)/2)
+ print*,'SLON,SLAT=',GLON(1,1), &
+ GLAT(1,1)
+
+
+! LON & LAT at U,V
+
+! CALL EARTH_LATLON ( HLAT,HLON,VLAT,VLON, & !Earth lat,lon at H and V points
+! DLMD,DPHD,WBD,SBD, & !input res,west & south boundaries,
+! CENTRAL_LAT,CENTRAL_LON, & ! central lat,lon, all in degrees
+! 1,NX1,1,NY1,1,1, &
+! 1,NX ,1,NY ,1,1, &
+! 1,NX ,1,NY ,1,1 )
+
+ print*,'HLAT,HLON,VLAT,VLON=', &
+ HLAT(1,1),HLON(1,1),VLAT(1,1),VLON(1,1)
+
+
+! write(70,*)
+! write(70,33)((HLON(I,J),I=1,NX,10),J=1,NY,20)
+! write(70,*)
+! write(70,33)((HLAT(I,J),I=1,NX,10),J=1,NY,20)
+! write(70,*)
+ 33 format(15F8.1)
+! 34 format(10F12.1)
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!!!!! READ TC vital
+
+ rewind 11
+
+ read(11,11)id_storm,ICLAT,SN,ICLON,EW,Ipsfc,Ipcls, &
+ Irmax,ivobs,Ir_vobs,(Ir_v4(I),I=1,4),DEPTH
+ 11 format(5x,I2,26x,I3,A1,I5,A1,9x,I4,1x,I4,1x,I4,I3,I4,4I5,1x,A1)
+
+ rewind 11
+
+ CLAT_NHC=ICLAT*0.1
+ CLON_NHC=ICLON*0.1
+ vobs=ivobs*1.0 ! m/s
+ vobs_o=vobs
+ VRmax=Ir_vobs*1. ! in km
+
+ if(VRmax.lt.19.)VRmax=19.
+
+! if(id_storm.lt.50.and.Ipsfc.gt.1005)Ipsfc=1005
+
+ psfc_obs=Ipsfc*100.
+ psfc_cls=Ipcls*100.
+
+ PRMAX=Irmax*1.
+ Rctp=Irmax*1. ! in km
+
+ cost=cos(CLAT_NHC*rad)
+
+ dp_obs=psfc_cls-psfc_obs
+
+ print*,'Ir_vobs,VRmax=',Ir_vobs,VRmax
+ print*,'10m vobs=',vobs,CLON_NHC,CLAT_NHC
+
+ vobs=vobs+0.1
+
+ print*,'VRmax=',VRmax
+
+ z0=(0.085*vobs-0.58)*1.E-3
+ delt_z1=0.5*(Z1(NX/2,NY/2,2)-Z1(NX/2,NY/2,1))
+
+! 7.2/1.944=3.7037
+
+ vobs_kt=1.944*vobs
+ IF(vobs_kt.gt.60.)then
+ vobs=(3.7037+vobs)/1.12*log(delt_z1/z0)/log(10./z0)
+ else
+ vobs=vobs*log(delt_z1/z0)/log(10./z0)
+ end if
+
+
+ print*,'level 1 vobs,z0=',vobs,z0,delt_z1
+
+
+ IF(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+ IF(EW.eq.'W')CLON_NHC=-CLON_NHC
+ if(I360.eq.360) then
+ IF(CLON_NHC.gt.0.)CLON_NHC=CLON_NHC-360.
+ endif
+
+ PW=1.
+ IF((DEPTH.eq.'S').or.(id_storm.ge.90))THEN
+ DO k=1,kmx
+ PW(k)=PW_S(k)
+ END DO
+ ELSE IF(DEPTH.eq.'M')THEN
+ DO k=1,kmx
+ PW(k)=PW_M(k)
+ END DO
+ ELSE
+ PW=1.
+ END IF
+
+ do k=1,kmx
+ print*,'K,PW=',K,PW(K)
+ end do
+
+
+ distm=1.E20
+ do j=1,ny
+ do i=1,nx
+ distt=((HLON(i,j)-CLON_NHC)*cost)**2+(HLAT(i,j)-CLAT_NHC)**2
+ if(distm.gt.distt)then
+ distm=distt
+ ictr=i
+ jctr=j
+ end if
+ end do
+ end do
+ imn1=ictr-2
+ imx1=ictr+2
+ jmn1=jctr-2
+ jmx1=jctr+2
+
+ do k=1,nz
+ tek(k)=T1(ictr,jctr,k)
+ end do
+
+
+ vt_c=0.
+ vt_n=0.
+ do j=jctr-10,jctr+10
+ do i=ictr-10,ictr+10
+ vt_c=vt_c+sqrt(usc(ictr,jctr)**2+vsc(ictr,jctr)**2)
+ vt_n=vt_n+1.
+ end do
+ end do
+ vt_c=vt_c/vt_n
+
+ vd_c=vobs-vt_c
+
+ pt_c=0.
+ sum1=0.
+ do j=jmn1,jmx1
+ do i=imn1,imx1
+! dist=(((HLON(i,j)-CLON_NHC)*cost)**2+ &
+! (HLAT(i,j)-CLAT_NHC)**2)
+ dist1=1.
+ sum1=sum1+dist1
+ pt_c=pt_c+slp1(i,j)*dist1
+ end do
+ end do
+
+ psfc_env=pt_c/(sum1+1.e-20)
+
+ psfc_obs1=min(-0.01,psfc_obs-psfc_env)
+
+! something wrong with the data
+
+ print*,'psfc_obs,psfc_env=',psfc_obs,psfc_env
+
+ REWIND(85)
+ READ(85)RMN
+
+! READ Hurricane Pert.
+
+ ALLOCATE ( PCST(KMX),HP(NX,NY,KMX),HV(NX,NY,KMX) )
+
+ ALLOCATE ( SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMX) )
+ ALLOCATE ( T_1(NX,NY,KMX),Q_1(NX,NY,KMX) )
+ ALLOCATE ( U_1(NX,NY,KMX),V_1(NX,NY,KMX) )
+
+ ALLOCATE ( U_S(NX,NY),V_S(NX,NY) )
+ ALLOCATE ( U_A(NX,NY),V_A(NX,NY) )
+
+ ALLOCATE ( USC_1(NX,NY),VSC_1(NX,NY) ) ! hurricane component wind at z=0
+ ALLOCATE ( USC1(NX,NY),VSC1(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( SLPV(NX,NY) )
+
+ ALLOCATE ( T21(NX,NY,KMX,4),Q21(NX,NY,KMX,4) )
+ ALLOCATE ( U21(NX,NY,KMX,4),V21(NX,NY,KMX,4) )
+ ALLOCATE ( SLP21(NX,NY,4) )
+ ALLOCATE ( PMV1(NX,NY,NZ),PMV2(NX,NY,NZ) )
+
+ ALLOCATE ( T_4(NX,NY,KMX),Q_4(NX,NY,KMX) )
+
+ ALLOCATE ( WRK1(KMX),WRK2(KMX),WRK3(KMX),WRK4(KMX) )
+
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+ ALLOCATE ( U_2SB(IR1,KMX),T_2SB(IR1,KMX),SLP_2SB(IR1) )
+ ALLOCATE ( Q_2SB(IR1,KMX),temp_e(KMX),RADIUS2(IR1) )
+!
+! READ the stored symmetric storm. Chanh added a modification
+! here for Southern Hemsiphere support.
+!
+ CALL axisym_xy_new(NX,NY,NZ,KMX,HLON,HLAT,VLON,VLAT, &
+ CLON_NHC,CLAT_NHC,SLP_1,T_1,Q_1,U_1,V_1, &
+ TH1,RP,SLPE,TENV,PCST,HP,HV,ZMAX,vd_c, &
+ dp_obs,vrmax,PRMAX,RMN, &
+ U_2SB,T_2SB,SLP_2SB,Q_2SB,temp_e,DEPTH,SN)
+
+ do m=1,IR1
+ RADIUS2(m)=RP(m)/arad
+ end do
+
+ print*,'RADIUS2(m)=',RADIUS2(1),RADIUS2(2)
+
+ ALLOCATE ( PCST1(NX,NY,KMX),PCST2(KMX) )
+
+ KST=1
+
+ CLON_NEW=CLON_NHC
+ CLAT_NEW=CLAT_NHC
+
+ print*,'zmax=',zmax
+
+ USC_1=0.
+ VSC_1=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ USC_1(I,J)=U_1(I,J,1)
+ VSC_1(I,J)=V_1(I,J,1)
+ END DO
+ END DO
+
+!!!
+
+
+
+! ENV. wind
+
+ USCM=USC
+ VSCM=VSC
+
+
+! hurricane component (approximate for pert only)
+
+ USC1=USC_1
+ VSC1=VSC_1
+
+ d_max=3.5
+ IF(vobs.gt.30..and.CLAT_NHC.gt.30.)d_max=4.5
+
+ d_max=min(d_max,0.8*RMN)
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ vmax2=sqrt(USC1(I,J)**2+VSC1(I,J)**2)*C101(I,J)
+ dist(i,j)=sqrt(((VLON(i,j)-CLON_NHC)*cost)**2+ &
+ (VLAT(i,j)-CLAT_NHC)**2)
+ if(vmax2.gt.vmax1.and.dist(i,j).lt.d_max)then
+ vmax1=vmax2
+ imax1=I
+ jmax1=j
+ end if
+ END DO
+ END DO
+
+ vmax_s=vmax1
+
+! crtn=vobs_o/vmax_s
+
+ crtn=1.0
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ vmax2=sqrt((USC1(I,J)*crtn+USCM(I,J))**2+ &
+ (VSC1(I,J)*crtn+VSCM(I,J))**2)*C101(I,J)
+ if(vmax2.gt.vmax1.and.dist(i,j).lt.d_max)then
+ vmax1=vmax2
+ imax1=I
+ jmax1=j
+ end if
+ END DO
+ END DO
+
+ vobs=vobs_o/(C101(imax1,jmax1)+1.E-10)
+
+ print*,'I,J,vmax,vobs=',imax1,jmax1,sqrt(vmax1),vobs
+
+ RMX_d=1.2*sqrt((VLON(imax1,jmax1)-CLON_NHC)**2+ &
+ (VLAT(imax1,jmax1)-CLAT_NHC)**2)
+
+ IF(RMX_d.gt.3.5)RMX_d=3.5
+ IF(RMX_d.lt.2.0)RMX_d=2.0
+
+!!!!!!!!!!!!!!!!!!!!
+
+ iter=0
+ beta=1.0
+
+ 876 CONTINUE
+
+ VMAX=0.
+ DO J=1,NY
+ DO I=1,NX
+! i=imax1
+! j=jmax1
+ UUT=beta*USC1(I,J)+USCM(I,J)
+ VVT=beta*VSC1(I,J)+VSCM(I,J)
+ FF=sqrt(UUT*UUT+VVT*VVT)*C101(I,J)
+ R_DIST=sqrt((VLON(I,J)-CLON_NHC)**2+ &
+ (VLAT(I,J)-CLAT_NHC)**2)
+ IF(VMAX.LT.FF.and.R_DIST.lt.RMX_d)THEN
+ VMAX=FF
+ IMV=I
+ JMV=J
+ END IF
+ END DO
+ END DO
+
+ vobs=vobs_o/(C101(IMV,JMV)+1.E-10)
+
+ PRINT*,'I,J,USC1,VSC1,USCM,VSCM=',USC1(IMV,JMV), &
+ VSC1(IMV,JMV),USCM(IMV,JMV),VSCM(IMV,JMV)
+ PRINT*,'I,J,VMAX=',IMV,JMV,SQRT(VMAX)
+
+ UU11=beta*USC1(IMV,JMV)
+ VV11=beta*VSC1(IMV,JMV)
+ UUM1=USCM(IMV,JMV)
+ VVM1=VSCM(IMV,JMV)
+ QQ=sqrt((uu11**2+vv11**2)*vobs**2-(vv11*uum1-uu11*vvm1)**2)
+
+ uv22=sqrt(uu11**2+vv11**2)
+
+ print*,'max hurricane pert=',uv22
+
+! if(uv22.lt.5.0)then
+! beta1=0.0
+! else
+ beta1=(-(uum1*uu11+vvm1*vv11)+QQ)/(uu11**2+vv11**2+1.E-20)
+! end if
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+ beta=beta*beta1
+ iter=iter+1
+
+ print*,'iter,beta=',iter,beta
+
+! IF(iter.lt.2)go to 876
+
+! if(beta.gt.1.25)beta=1.25 ! test
+
+! if(beta.gt.1.25) beta=max(1.25,sqrt(beta))
+
+ v_min=min(10.,max(8.,0.6*vobs))
+
+ if(abs(CLAT_NHC).lt.15.)then
+ v_min=min(10.,max(10.,0.6*vobs))
+ end if
+
+! v_min=8.
+
+ beta=max(beta,v_min/vmax_s) ! beta*vmax_s >=8 m/s
+
+ print*,'v_min,beta=',v_min,beta
+
+!!! beta=0.8
+
+! beta=1.
+
+! set storm pert T and Q =0
+
+! T_1=0.
+! Q_1=0.
+
+! now modify the horricane component (by beta)
+
+ T_4=T_1
+ Q_4=Q_1
+
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW,CLAT_NEW
+
+! read storm data and compute center surface pressure PS_C1
+
+
+ ALLOCATE ( T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY) )
+
+
+ PS_C1=min(-dp_obs,psfc_obs1)
+
+ ics=1
+ fact=1.0
+!
+! Chanh added a modification
+! here for Southern Hemsiphere support.
+!
+ CALL CORT_MAT_2(IR1,NX,NY,NZ,KMX,U_2SB, &
+ T_2SB,SLP_2SB,Q_2SB,RADIUS2,temp_e,TEK, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW,PS_C1, &
+ beta,fact,ics,SN)
+
+
+ do j=1,NY
+ do i=1,NX
+! SLP_1(i,j)=SLP_1(i,j)+SLP_X(i,j)
+ SLP_1(i,j)=SLP_X(i,j)
+ do k=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+ U_1(i,j,k)=U_1(i,j,k)*beta*PW(k)
+ V_1(i,j,k)=V_1(i,j,k)*beta*PW(k)
+! T_1(i,j,k)=(T_1(i,j,k)+T_X(i,j,k))*PW(k)
+! Q_1(i,j,k)=(Q_1(i,j,k)+Q_X(i,j,k))*PW(k)
+ T_1(i,j,k)=T_X(i,j,k)*PW(k)
+! Q_1(i,j,k)=Q_X(i,j,k)*PW(k)
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ end do
+ end do
+ end do
+
+
+ ps_min=1.E20
+ do j=1,NY
+ do i=1,NX
+ if(ps_min.gt.SLP_1(i,j))then
+ ps_min=SLP_1(i,j)
+ i_psm=i
+ j_psm=j
+ end if
+ end do
+ end do
+ print*,'storm center 4 =',HLON(i_psm,j_psm),HLAT(i_psm,j_psm),ps_min
+
+! CALL FIND_NEWCT1(NX,NY,U_1(1,1,10),V_1(1,1,10),HLON,HLAT,CLON_NEW,CLAT_NEW)
+
+
+! WRITE(25)((SLP_1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,KMX
+! WRITE(25)((T_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(25)((U_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(25)((V_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(25)((Q_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+
+! T_1=T_4
+! Q_1=Q_4
+
+! if(zmax.gt.250.)then
+! T_4=0.
+! Q_4=0.
+! end if
+
+
+ print*,'complete CORT'
+
+
+!??????????????????
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP1(I,J) = SLP1(I,J)+SLP_1(I,J)
+ TENV1 = TS1(I,J)
+ TS1(I,J) = TENV1+T_1(I,J,1)
+ T_OLD = T4(I,J,1)
+ Q_OLD = Q4(I,J,1)
+ ESRR = exp(4302.645*(TS1(I,J)-T_OLD)/ &
+ ((TS1(I,J)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ QS1(I,J) = Q_OLD + (ESRR-1.)*Q_OLD ! Assuming RH=CONST. before & after
+ ENDDO
+ ENDDO
+
+! WRITE(25)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! WRITE(25)((HLON(I,J),I=1,NX),J=1,NY,2)
+! WRITE(25)((HLAT(I,J),I=1,NX),J=1,NY,2)
+
+!
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+! DO K=1,NZ
+! DO J=1,NY
+! DO I=1,NX
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ENDDO
+! ENDDO
+! ENDDO
+
+! add hurricane components
+
+
+ DO J=1,NY
+ DO I=1,NX
+ DO N=1,KMX
+! PCST1(I,J,N)=HP(I,J,N)
+! PCST1(I,J,N)=PMID1(I,J,1)*PCST(N)/PCST(1)
+ PCST1(I,J,N)=PCST(N)*SLP1_MEAN/PCST(1)
+ END DO
+ END DO
+ END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ WRK1(K) = T_1(I,J,K)
+ WRK2(K) = Q_1(I,J,K)
+ END DO
+ DO N=1,NZ
+ TENV1 = T1(I,J,N)
+ QENV1 = Q1(I,J,N)
+ IF(PMID1(I,J,N).GE.PCST1(I,J,1))THEN ! Below PCST(1)
+ T1(I,J,N)=TENV1+WRK1(1)
+ Q1(I,J,N)=QENV1+WRK2(1)
+ ELSE IF(PMID1(I,J,N).LE.PCST1(I,J,KMX))THEN
+ T1(I,J,N)=TENV1+WRK1(KMX)
+ Q1(I,J,N)=QENV1+WRK2(KMX)
+ ELSE
+ DO K=1,KMX-1
+ IF(PMID1(I,J,N).LE.PCST1(I,J,K).and.PMID1(I,J,N).GT.PCST1(I,J,K+1))THEN
+ W1=ALOG(1.*PCST1(I,J,K+1))-ALOG(1.*PCST1(I,J,K))
+ W=(ALOG(1.*PMID1(I,J,N))-ALOG(1.*PCST1(I,J,K)))/W1
+ T1(I,J,N)=TENV1+WRK1(K)*(1.-W)+WRK1(K+1)*W
+ Q1(I,J,N)=QENV1+WRK2(K)*(1.-W)+WRK2(K+1)*W
+ GO TO 887
+ END IF
+ END DO
+ END IF
+ 887 CONTINUE
+
+ T_OLD = T4(I,J,N)
+ Q_OLD = Q4(I,J,N)
+ ESRR = exp(4302.645*(T1(I,J,N)-T_OLD)/ &
+ ((T1(I,J,N)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ Q1_GFS = Q_OLD + (ESRR-1.)*Q_OLD ! Assuming RH=CONST. before & after
+ Q1(I,J,N)=0.2*Q1(I,J,N)+0.8*Q1_GFS
+ END DO
+ ENDDO
+ ENDDO
+
+! based on Ts, Zs, SLP1 Recompute ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TS1(I,J) =T1(I,J,1)+GAMMA*(Z1(I,J,2)-Z1(I,J,1))*0.5
+ QS1(I,J) = Q1(I,J,1)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+! DO K=1,NZ
+! DO J=1,NY
+! DO I=1,NX
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ENDDO
+! ENDDO
+! ENDDO
+
+! add hurricane components
+
+! Compute Geopotentital height, INTEGRATE HEIGHT HYDROSTATICLY
+
+ do j = 1,ny
+ do i = 1,nx
+ Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)* &
+ (Q1(I,J,L-1)*0.608+1.0)*287.04* &
+ (ALOG(P1(I,J,L-1))-ALOG(P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ END DO
+
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+ ZMID1(I,J,K)=0.5*(Z1(I,J,K)+Z1(I,J,K+1))
+ ENDDO
+ ENDDO
+ ENDDO
+
+! interpolate vertically to P level in new coordinate (V Points)
+
+ PMV1=PMID1
+
+! DO J=2,NY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO K=1,NZ
+! DO I=2,NX-1
+! PMV1(I,J,K)=0.25*(PMID1(I,J,K)+PMID1(I+1,J,K)+ &
+! PMID1(I,J-1,K)+PMID1(I,J+1,K))
+! END DO
+! END DO
+! ELSE
+! DO K=1,NZ
+! DO I=2,NX-1
+! PMV1(I,J,K)=0.25*(PMID1(I-1,J,K)+PMID1(I,J,K)+ &
+! PMID1(I,J-1,K)+PMID1(I,J+1,K))
+! END DO
+! END DO
+! END IF
+! END DO
+
+
+
+ PRINT*,'test01'
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ WRK1(K) = U_1(I,J,K)
+ WRK2(K) = V_1(I,J,K)
+ END DO
+
+ DO N=1,KMX
+! PCST2(N)=HV(I,J,N)
+ PCST2(N)=PMV1(I,J,1)*PCST(N)/PCST(1)
+ END DO
+
+ DO N=1,NZ
+ IF(PMV1(I,J,N).GE.PCST2(1))THEN ! Below PCST(1)
+ U1(I,J,N)=U1(I,J,N)+WRK1(1)
+ V1(I,J,N)=V1(I,J,N)+WRK2(1)
+ ELSE IF(PMV1(I,J,N).LE.PCST2(KMX))THEN
+ U1(I,J,N)=U1(I,J,N)+WRK1(KMX)
+ V1(I,J,N)=V1(I,J,N)+WRK2(KMX)
+ ELSE
+ DO K=1,KMX-1
+ IF(PMV1(I,J,N).LE.PCST2(K).and.PMV1(I,J,N).GT.PCST2(K+1))THEN
+ W1=ALOG(1.*PCST2(K+1))-ALOG(1.*PCST2(K))
+ W=(ALOG(1.*PMV1(I,J,N))-ALOG(1.*PCST2(K)))/W1
+ U1(I,J,N)=U1(I,J,N)+WRK1(K)*(1.-W)+WRK1(K+1)*W
+ V1(I,J,N)=V1(I,J,N)+WRK2(K)*(1.-W)+WRK2(K+1)*W
+ GO TO 888
+ END IF
+ END DO
+ END IF
+ 888 CONTINUE
+ END DO
+ ENDDO
+ ENDDO
+
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+ PRINT*,'test02'
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+
+! WRITE(64)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(64)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(64)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! WRITE(64)((USCM(I,J),I=1,NX),J=1,NY,2)
+! WRITE(64)((VSCM(I,J),I=1,NX),J=1,NY,2)
+
+ IUNIT=50+ITIM
+
+ WRITE(IUNIT) NX,NY,NZ,I360
+ WRITE(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ WRITE(IUNIT) PMID1
+ WRITE(IUNIT) T1
+ WRITE(IUNIT) Q1
+ WRITE(IUNIT) U1
+ WRITE(IUNIT) V1
+ WRITE(IUNIT) DZDT
+ WRITE(IUNIT) Z1
+! WRITE(IUNIT) GLON,GLAT
+ WRITE(IUNIT) HLON,HLAT,VLON,VLAT
+ WRITE(IUNIT) P1
+ WRITE(IUNIT) PD1
+ WRITE(IUNIT) ETA1
+ WRITE(IUNIT) ETA2
+
+ CLOSE(IUNIT)
+
+! test
+
+! CALL FIND_NEWCT1(NX,NY,U_1(1,1,10),V_1(1,1,10),HLON,HLAT,CLON_NEW,CLAT_NEW)
+
+
+! print*,'storm center 2 =',CLON_NEW,CLAT_NEW
+
+! CALL FIND_NEWCT1(NX,NY,U_1(1,1,10),V_1(1,1,10),GLON,GLAT,CLON_NEW,CLAT_NEW)
+
+
+! print*,'storm center 3 =',CLON_NEW,CLAT_NEW
+
+
+
+ END
+
+
+!=============================================================================
+subroutine dbend(nit,x,y)
+!=============================================================================
+! Evaluate a smooth monotonic increasing blending function y from 0 to 1
+! for x in the interval [0,1] having continuity in at least the first nit
+! derivatives at the ends of this interval. (nit .ge. 0).
+!=============================================================================
+implicit none
+integer,intent(IN ):: nit
+real(8),intent(IN ):: x
+real(8),intent(OUT):: y
+!-----------------------------------------------------------------------------
+integer :: it
+!=============================================================================
+y=2*x-1; do it=1,nit; y=y*(3-y*y)/2; enddo; y=(y+1)/2
+end subroutine dbend
+
+ SUBROUTINE FIND_NEWCT1(IX,JX,UD,VD,GLON2,GLAT2, &
+ CLON_NEW1,CLAT_NEW1)
+
+! PARAMETER (IR=100,IT=24,IX=254,JX=254)
+ PARAMETER (IR=30,IT=24)
+ PARAMETER (ID=61,JD=61,DTX=0.05,DTY=0.05) ! Search x-Domain (ID-1)*DTX
+ REAL (4) UD(IX,JX),VD(IX,JX),GLON2(IX,JX),GLAT2(IX,JX)
+! DIMENSION RWM(IR+1),TWM(IR+1)
+ DIMENSION TNMX(ID,JD),RX(ID,JD),WTM(IR)
+ REAL (8) CLON_NEW1,CLAT_NEW1
+
+ PI=ASIN(1.)*2.
+ RAD=PI/180.
+
+ ddr=0.05
+
+ pi180=RAD
+ cost=cos(clat_new*pi180)
+
+ ix2=ix/2
+ jx2=jx/2
+ DDS=(((GLON2(ix2+1,jx2)-GLON2(ix2,jx2))*cost)**2+ &
+ (GLAT2(ix2,jx2+1)-GLAT2(ix2,jx2))**2)*1.5
+
+
+ print*,'ix,jx,ix2,jx2=',ix,jx,ix2,jx2
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW1,CLAT_NEW1
+ print*,'GLON2,GLAT2=',GLON2(1,1),GLAT2(1,1)
+
+
+ XLAT = CLAT_NEW1-(JD-1)*DTY/2.
+ XLON = CLON_NEW1-(ID-1)*DTX/2.
+
+!c print *,'STARTING LAT, LON AT FIND NEW CENTER ',XLAT,XLON
+
+ DO J=1,JD
+ DO I=1,ID
+ TNMX(I,J) = 0.
+ RX(i,j)=0.
+ BLON = XLON + (I-1)*DTX
+ BLAT = XLAT + (J-1)*DTY
+
+!.. CALCULATE TANGENTIAL WIND EVERY 0.2 deg INTERVAL
+!.. 10*10 deg AROUND 1ST GUESS VORTEX CENTER
+
+ DO 10 JL=1,IR
+ WTS= 0.
+ DO 20 IL=1,IT
+ DR = JL*ddr
+! DR = JL
+ DD = (IL-1)*15*RAD
+ DLON = DR*COS(DD)
+ DLAT = DR*SIN(DD)
+ TLON = BLON + DLON
+ TLAT = BLAT + DLAT
+
+!C.. INTERPOLATION U, V AT TLON,TLAT AND CLACULATE TANGENTIAL WIND
+
+ u1=0.
+ v1=0.
+ sum1=0.
+ DO j1=jx2-40,jx2+40
+ DO i1=ix2-40,ix2+40
+ dist=(((GLON2(i1,j1)-TLON)*cost)**2+(GLAT2(i1,j1)-TLAT)**2)
+ if(dist.lt.DDS)THEN
+ dist1=1./dist
+ sum1=sum1+dist1
+ u1=u1+UD(i1,j1)*dist1
+ v1=v1+VD(i1,j1)*dist1
+ end if
+ end do
+ end do
+
+ UT=u1/sum1
+ VT=v1/sum1
+
+!C.. TANGENTIAL WIND
+ WT = -SIN(DD)*UT + COS(DD)*VT
+ WTS = WTS+WT
+20 CONTINUE
+ WTM(JL) = WTS/24.
+10 CONTINUE
+
+!C Southern Hemisphere
+ IF(CLAT_NEW.LT.0)THEN
+ DO JL=1,IR
+ WTM(JL)=-WTM(JL)
+ END DO
+ END IF
+!C EnD SH
+
+! print*,'test1'
+
+ TX = -10000000.
+ DO KL = 1,IR
+ IF(WTM(KL).GE.TX) THEN
+ TX = WTM(KL)
+ RRX = KL*ddr
+ ENDIF
+ ENDDO
+! DO KL=1,IR
+! TWM(KL)=WTM(KL)
+! RWM(KL)=KL*ddr
+! END DO
+! TWM(IR+1)=TX
+! RWM(IR+1)=RRX
+
+ TNMX(I,J) = TX
+ RX(I,J)=RRX
+ ENDDO
+ ENDDO
+!C.. FIND NEW CENTER
+ TTX = -1000000.
+ DO I=1,ID
+ DO J=1,JD
+ IF(TNMX(I,J).GE.TTX) THEN
+ TTX = TNMX(I,J)
+ NIC = I
+ NJC = J
+ ENDIF
+ ENDDO
+ ENDDO
+
+! QLIU test
+! print*,XLAT+30*DTY,XLON+30*DTX,TNMX(30,30)
+ print*,'max WTM=',TTX
+
+ CLAT_NEW1 = XLAT + (NJC-1)*DTY
+ CLON_NEW1 = XLON + (NIC-1)*DTX
+
+! print *,'NEW CENTER, I, J IS ',NIC,NJC
+ print *,'NEW CENTER, LAT,LON IS ',CLAT_NEW1,CLON_NEW1
+! print *,'MAX TAN. WIND AT NEW CENTER IS ',TTX
+
+ RETURN
+ END
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/convert_axi_xy.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/convert_axi_xy.f90
new file mode 100644
index 000000000..a2b3461e7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/convert_axi_xy.f90
@@ -0,0 +1,778 @@
+!******************************************************************************
+
+ SUBROUTINE axisym_xy_new(NX,NY,NZ,KMX, &
+ HLON2,HLAT2,VLON2,VLAT2, &
+ CLON_NHC,CLAT_NHC, &
+ SLP_1,T_1,Q_1,U_1,V_1,th1,rp1, &
+ SLPE,TENV,PCST,HP,HV,ZMAX,vobs, &
+ dp_obs,vrmax,PRMAX,RMN, &
+ U_2SB,T_2SB,SLP_2SB,R_2SB,temp_e,DEPTH,SN)
+! SUBPROGRAM
+! PRGRMMR
+!
+! ABSTRACT
+!
+! All variables have the same vertical dimension (KMAX=121).
+!
+ INTEGER I,J,K,NX,NY,NZ,ICH
+!
+ PARAMETER (NST=5)
+! PARAMETER (NX=420,NY=820,NZ=42) !* E-grid dimensions
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.)
+ PARAMETER (IR=200,KMAX=121) !* Cylinder dimensions
+ PARAMETER (IR1=IR+1) !* unused extra point
+
+! READ Hurricane Pert.
+
+ REAL(4) HLON2(NX,NY),HLAT2(NX,NY)
+ REAL(4) VLON2(NX,NY),VLAT2(NX,NY) !* E-grid coord
+ REAL(4) PCST(KMAX),HP(NX,NY,KMAX),HV(NX,NY,KMAX)
+
+ REAL(4) SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMAX)
+ REAL(4) T_1(NX,NY,KMAX),Q_1(NX,NY,KMAX) !* adjusted vortex
+ REAL(4) U_1(NX,NY,KMAX),V_1(NX,NY,KMAX) !* on E-grid
+
+ REAL(8) CLON_NHC,CLAT_NHC !* storm lon, lat
+ REAL(8) delc,thac !* vortex lon, lat
+
+ DIMENSION rp(IR1),ps(IR),ps1(IR),ps2(IR),ps_1mb(IR)
+ DIMENSION q(KMAX),p(KMAX,IR) !* pressure on sigma-levels (q)
+ DIMENSION t(KMAX,IR),r(KMAX,IR),ur(KMAX,IR1),th(KMAX,IR1)
+ DIMENSION vrad(KMAX),vtan(KMAX) !^ bogus vortex
+
+ REAL(4), ALLOCATABLE :: RIJ1(:,:),RIJ2(:,:)
+ REAL(4), ALLOCATABLE :: W1(:,:),W2(:,:)
+ INTEGER, ALLOCATABLE :: IDX1(:,:)
+
+ REAL(4) SLPE1,temp_e(KMAX)
+ REAL(4) th1(IR1),rp1(IR1) ! ,RMN !* min radius for filtering
+
+ REAL(4) wrk1(IR),wrk2(IR),wrk3(IR),wrk4(IR)
+ REAL(4) work1(KMAX),WORK2(KMAX)
+
+ REAL(4) U_2SB(IR1,KMAX),T_2SB(IR1,KMAX),SLP_2SB(IR1)
+ REAL(4) V_2SB(IR1,KMAX),R_2SB(IR1,KMAX) !* sigma-level
+
+ DIMENSION RF(24)
+
+ CHARACTER DEPTH*1
+ CHARACTER SN*1,EW*1
+
+! rewind 11
+! read(11,11)ICLAT,SN,ICLON,EW
+! 11 format(33x,I3,A1,I5,A1)
+! rewind 11
+
+! CLAT_NHC=ICLAT*0.1
+! CLON_NHC=ICLON*0.1
+
+! IF(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+! IF(EW.eq.'W')CLON_NHC=-CLON_NHC
+
+! CLAT_NHC=25.
+! CLON_NHC=-60.
+
+ eps6=1.E-6
+ pi=4.*atan(1.0)
+ pi180=pi/180. !* deg -> rad
+ arad =6.371E6*pi180 !* deg -> m
+ deg2m=6.371E6*pi180 !* deg -> m
+ cost=cos(CLAT_NHC*pi180)
+
+ zmax=0.
+
+ NHCT=77
+ IF(DEPTH.eq.'S')THEN
+ NHCT=77
+ ELSE IF(DEPTH.eq.'M')THEN
+ NHCT=76
+ ELSE IF(DEPTH.eq.'D'.and.vobs.gt.27.)THEN
+ NHCT=75
+ END IF
+
+ READ(NHCT)delc,thac !* vortex lon, lat
+
+ READ(NHCT)SLPE1 !* environment SLP (1)
+ READ(NHCT)PCST !* vortex p-levels (kmax)
+ READ(NHCT)temp_e !* environment T (kmax)
+
+ SLPE=SLPE1 !* environment SLP (nx,ny)
+
+ print*,'delc,thac=',delc,thac
+
+ cost_old=cos(thac*pi180) !* vortex cos(lat)
+
+ READ(NHCT)(rp(i),i=1,IR1) !* vortex radius [deg]
+
+ do i=1,IR1
+ rp(i)=arad*rp(i) !* rp(i) = i*dr [m]
+ end do
+ print*,'rp1,2,200=',rp(1),rp(2),rp(IR)
+
+ do k=1,kmax
+ READ(NHCT)(ur(k,i),i=1,IR1) !* vortex radial wind
+ READ(NHCT)(th(k,i),i=1,IR1) !* vortex tangen wind
+ print*,'k,th1,2,200=',k,th(k,1),th(k,2),th(k,IR)
+ do i=1,IR1
+! ur(k,i)=ur(k,i)*0.1 !* reduce convergence
+ ur(k,i)=ur(k,i)*0.5 !* reduce convergence
+ end do
+ end do
+!
+! Chanh added Southern Hemisphere here to flip the sign of
+! tangetnial wind in the SH.
+!
+ if (SN.eq.'S') then
+ print*,'Southern Hemisphere sign flip of composite storm'
+ do k=1,kmax
+ do i=1,IR1
+ th(k,i) = -1*th(k,i)
+ enddo
+ enddo
+ endif
+
+ READ(NHCT)(ps(i),i=1,IR) !* vortex sfc pressure
+ print*,'ps1,2,200=',ps(1),ps(2),ps(IR)
+
+ do k=1,kmax
+ READ(NHCT)(t(k,i),i=1,IR) !* vortex temperature
+ print*,'k,t1,2,200=',k,t(k,1),t(k,2),t(k,IR)
+ end do
+
+ do k=1,kmax
+ READ(NHCT)(r(k,i),i=1,IR) !* vortex mixing ratio
+ print*,'k,r1,2,200=',k,r(k,1),r(k,2),r(k,IR)
+ end do
+
+ count_smth=0.
+
+ 999 continue !* smooth vortex for large & weak storm <---------------
+
+ TWMAX=1.e-6
+ do i=1,IR
+ th1(i)=th(1,i)
+! twsum=th(1,i)**2+ur(1,i)**2
+ twsum=th(1,i)**2
+ if (twsum.GT.TWMAX) then
+ TWMAX=twsum
+ RWMAX=rp(i)
+ end if
+ end do
+
+ TWMAX=sqrt(TWMAX) !* max tangen wind
+ Rmax_0=RWMAX*0.001 !* RMW (m -> km)
+
+ fact_v=vrmax/Rmax_0 !* alfa=RMW*/RMW
+!CWH print*,'fact=',fact,Rmax_0,vrmax,TWMAX
+
+ fact=fact_v
+ print*,'fact=',fact,Rmax_0,vrmax,TWMAX
+
+! fact=sqrt(fact) ! make it closer to 1
+
+ IF (fact.GT.1.1 .AND. TWMAX.GT.vobs) THEN ! smooth
+ wrk1(1)=(2.*ps(1)+ps(2))/3.
+! wrk1(IR)=(ps(IR-1)+2.*ps(IR))/3.
+ wrk1(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ps(i-1)+ps(i)+ps(i+1))/3.
+ end do
+ do i=1,IR
+ ps(i)=wrk1(i)
+ end do
+ DO k=1,kmax
+ wrk1(1)=(ur(k,1)+ur(k,2))/3.
+ wrk1(IR)=0.
+ wrk2(1)=(th(k,1)+th(k,2))/3.
+ wrk2(IR)=0.
+ wrk3(1)=(2.*t(k,1)+t(k,2))/3.
+! wrk3(IR)=(t(k,IR-1)+2.*t(k,IR))/3.
+ wrk3(IR)=0.
+ wrk4(1)=(2.*r(k,1)+r(k,2))/3.
+! wrk4(IR)=(r(k,IR-1)+2.*r(k,IR))/3.
+ wrk4(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ur(k,i-1)+ur(k,i)+ur(k,i+1))/3.
+ wrk2(i)=(th(k,i-1)+th(k,i)+th(k,i+1))/3.
+ wrk3(i)=(t(k,i-1)+t(k,i)+t(k,i+1))/3.
+ wrk4(i)=(r(k,i-1)+r(k,i)+r(k,i+1))/3.
+ end do
+ do i=1,IR
+ ur(k,i)=wrk1(i)
+ th(k,i)=wrk2(i)
+ t(k,i)=wrk3(i)
+ r(k,i)=wrk4(i)
+ end do
+ END DO
+ count_smth=count_smth+1
+ IF (count_smth.LE.250.) go to 999 !* ------------------------>
+ END IF
+
+ print*,'count_smth=',count_smth !* ===============================
+
+ go to 557
+
+ 556 continue !* UNUSED code for homogenizing ROCI with RMW <- - - - -
+
+ pres_ct=dp_obs/ps(1)
+ do i=1,IR
+ ps_1mb(i)=ps(i)*pres_ct
+ end do
+
+ IRAD_1=1
+ do i=1,IR
+ if (abs(ps_1mb(i)).GT.100.) then
+ IRAD_1=I
+ end if
+ end do
+
+ RAD_1=(IRAD_1+0.5)*(rp(2)-rp(1))*1.E-3
+ fact_p=PRMAX/RAD_1 !* alfa=ROCI*/ROCI
+
+! fact_p=0.5*(fact_p+fact_v)
+ fact_p=fact_v
+
+ print*,'fact,fact_p=',fact,fact_p,PRMAX,RAD_1
+
+ IF (fact .LT. fact_p) THEN !* smooth => fact_p = fact_v
+ wrk1(1)=(2.*ps(1)+ps(2))/3.
+ wrk1(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ps(i-1)+ps(i)+ps(i+1))/3.
+ end do
+ do i=1,IR
+ ps(i)=wrk1(i)
+ end do
+ do k=1,kmax
+ wrk3(1)=(2.*t(k,1)+t(k,2))/3.
+ wrk3(IR)=0.
+ wrk4(1)=(2.*r(k,1)+r(k,2))/3.
+ wrk4(IR)=0.
+ do i=2,IR-1
+ wrk3(i)=(t(k,i-1)+t(k,i)+t(k,i+1))/3.
+ wrk4(i)=(r(k,i-1)+r(k,i)+r(k,i+1))/3.
+ end do
+ do i=1,IR
+ t(k,i)=wrk3(i)
+ r(k,i)=wrk4(i)
+ end do
+ end do
+ go to 556 !* - - - - - - - - - - - - - - - - - - - - - - - - ->
+ END IF
+
+ 557 continue
+
+!* 50% contraint for bogus vortex stretch
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ if(fact.lt.0.5)fact=0.5
+ if(fact.gt.1.5)fact=1.5
+
+! fact=1.0
+
+! correct sea level pressure for diff. latitude (UNUSED ps1 by #386)
+
+ ps1=0.
+
+ FC2=2.*7.292E-5*SIN(CLAT_NHC*pi180)
+ FC1=2.*7.292E-5*SIN(thac*pi180)
+ DFC=FC2-FC1
+
+ density=1.1765 ! P/(RT)=101300/(287*300)
+
+ sum_vt=0.
+ do i=IR-1,1,-1
+ sum_vt=sum_vt+0.5*(th(1,i+1)+th(1,i))*(rp(i+1)-rp(i))
+ ps1(i)=ps1(i)+DFC*sum_vt*density
+ end do
+
+! correct sea level pressure for fact (UNUSED ps1 by #386)
+
+ fact1=1./fact-1.
+ sum_vt2=0.
+ do i=IR-1,1,-1
+ th_m=0.5*(th1(i+1)+th1(i))
+ sum_vt2=sum_vt2+th_m**2*(ALOG(rp(i)/rp(i+1)))
+ ps1(i)=ps1(i)+fact1*sum_vt2*density
+! print*,'i,ps1(i)=',i,ps1(i)
+ end do
+
+! * * * * * * * * * *
+
+!* RMW of bogus vortex
+!* ~~~~~~~~~~~~~~~~~~~
+ xxx = 1.E-6
+ DO i = 1,IR
+ yyy = th(1,i)**2
+ IF ( yyy .GT. xxx ) THEN
+ xxx = yyy
+ rmw1 = rp(i)
+ ENDIF
+ ENDDO
+
+!* ROCI of bogus vortex
+!* ~~~~~~~~~~~~~~~~~~~~
+ xxx=dp_obs/ps(1)
+ DO i = 1,IR
+ ps2(i)=ps(i)*xxx
+ ENDDO
+
+ DO i=1,IR
+ IF ( abs(ps2(i)) .GT. 50. ) THEN !* Bogus ROCI ?
+ roc1 = rp(i)
+ ENDIF
+ ENDDO
+
+ roc1 = roc1 + .5*(rp(2)-rp(1))
+ roc1 = max(roc1,2.*rmw1+1.)
+
+!* Observed RMW & ROCI
+!* ~~~~~~~~~~~~~~~~~~~
+ rmw2 = vrmax*1000. !* RMW (km -> m)
+ roc2 = prmax*1000. !* ROCI (km -> m)
+
+ PRINT*, 'Bogus RMW ,Observed RMW [km]: rmw1,vrmax =', rmw1*.001, vrmax
+ PRINT*, 'Bogus ROCI,Observed ROCI [km]: roc1,prmax =', roc1*.001, prmax
+
+!* Stretch factors in meters
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~
+ xxx = .5*rmw1 ; yyy = 1.5*rmw1 !* 50% Constraint
+ rmw2 = max(xxx,min(rmw2,yyy)) !* for bogus stretch
+ xxx = .5*roc1 ; yyy = 1.5*roc1 !* 50% Constraint
+ roc2 = max(xxx,min(roc2,yyy)) !* for bogus stretch
+
+ ddd = 1./(roc1*rmw1*(roc1-rmw1))
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+ bbb = max(-0.05/deg2m,min(bbb,0.05/deg2m))
+
+ aaa = max( 0.5, min(aaa,1.5) )
+
+ iparam = 2 !* Parameters for storm-size correction ?
+
+ IF ( iparam == 1 ) THEN !* ---------------------------------------
+
+ DO i=1,IR1
+ rp(i)=rp(i)*fact !* stretch with RMW only (fact = fact_v)
+ rp1(i)=rp(i)
+ ENDDO
+
+ PRINT*, 'Using 1 parameter for storm-size correction.'
+
+ ELSEIF ( iparam == 2 ) THEN !* -----------------------------------
+
+ DO i=1,IR1
+ rp(i)=aaa*rp(i) + .5*bbb*rp(i)**2 !* stretch with RMW & ROCI
+ rp1(i)=rp(i)
+ ENDDO
+
+ PRINT*, 'Using 2 parameters for storm-size correction.'
+ PRINT*, 'Bogus RMW , Target RMW [m]: rmw1, rmw2 =', rmw1, rmw2
+ PRINT*, 'Bogus ROCI, Target ROCI [m]: roc1, roc2 =', roc1, roc2
+ PRINT*, 'Bogus storm-size factors [m]: aaa, bbb =', aaa, bbb
+ PRINT*, 'Bogus stretch difference 0-10 deg: b*R/2 =', bbb*5.*deg2m
+
+ ENDIF !* ---------------------------------------------------------
+
+! * * * * * * * * * *
+
+! do i=1,IR
+! ps1(i)=ps1(i)*1.2 ! only correct 75%
+! end do
+
+! ps1=0.
+
+!* Correct vortex based on RMN (min radius for filtering)
+
+! rewind(85)
+! read(85)RMN
+! read(85)RF
+
+ print*,'RMN 1=',RMN
+
+! PRMAX2=PRMAX*1000./arad
+! RMN=min(RMN,2.*PRMAX2)
+
+ RMN1=RMN*arad
+
+ if (RMN1.LT.2.5*RWMAX) then
+ RMN1=2.5*RWMAX !* RMN1 >= 2.5*RMW
+ RMN=2.5*RWMAX/arad
+! rewind(85)
+! write(85)RMN
+! write(85)RF
+ print*,'new RMN=',RMN
+ end if
+
+ RMN2=0.5*(RMN1+vrmax*1000.) !* in meter
+ RMN2=max(1.1*PRMAX*1000.,RMN2) !* RMN2 >= ROCI*
+
+ do i=1,IR-1
+ if ( RMN2.GE.rp1(i) .AND. RMN2.LT.rp1(i+1) ) then
+ icut1=i+1 !* icut1 -> RMN2
+ end if
+ end do
+
+ go to 777 !* UNUSED cutoff beyond RMN2 - - - - - - - - - -
+
+ do i=1,icut1-1
+ ps(i)= ps(i)- ps(icut1)+ ps(IR)
+ ps1(i)=ps1(i)-ps1(icut1)+ps1(IR)
+ do k=1,kmax
+ ur(k,i)=ur(k,i)-ur(k,icut1)+ur(k,IR)
+ th(k,i)=th(k,i)-th(k,icut1)+th(k,IR)
+ t(k,i)=t(k,i)-t(k,icut1)+t(k,IR)
+ r(k,i)=max(0.,r(k,i)-r(k,icut1))+r(k,IR)
+ end do
+ end do
+
+ do i=icut1,IR
+ ps(i)= ps(IR)
+ ps1(i)=ps1(IR)
+ do k=1,kmax
+ ur(k,i)=ur(k,IR)
+ th(k,i)=th(k,IR)
+ t(k,i)=t(k,IR)
+ r(k,i)=r(k,IR)
+ end do
+ end do
+
+ 777 continue !* - - - - - - - - - - - - - - - - - - - - - - -
+
+ icut2=icut1+1.5*arad/(rp1(2)-rp1(1)) !* icut2 -> RMN2+3'
+
+ if (icut2.gt.IR) icut2=IR
+
+ print*,'icut1,icut2=',icut1,icut2
+
+! special treatment for ur (UNUSED spread of divergence)
+
+ do i=1,icut2
+ do k=1,kmax
+! ur(k,i)=ur(k,i)-ur(k,icut2)*rp1(i)/rp1(icut2)
+ ur(k,i)=ur(k,i)
+ end do
+ end do
+
+!* Cut off beyond RMN2+3'
+ do i=icut2,IR
+ ps(i)=ps(IR)
+ ps1(i)=ps1(IR)
+ do k=1,kmax
+ ur(k,i)=0.
+ th(k,i)=0.
+ t(k,i)=t(k,IR)
+ r(k,i)=r(k,IR)
+ end do
+ end do
+
+!* FADE from RMN2 to RMN2+3'
+ do i=icut1,icut2 !* cut_off = 1 -> 0
+ cut_off=FLOAT(icut2-i)/FLOAT(icut2-icut1)
+ cut_off=cut_off*cut_off*(3.-2.*cut_off)
+ print*,'i,cut_off=',i,cut_off
+ ps(i)=(ps(i)-ps(IR))*cut_off+ps(IR)
+ ps1(i)=(ps1(i)-ps1(IR))*cut_off+ps1(IR)
+ do k=1,kmax !* FADING t(k,i) -> t(k,IR)
+! ur(k,i)=(ur(k,i)-ur(k,IR))*cut_off
+ th(k,i)=(th(k,i)-th(k,IR))*cut_off
+ t(k,i)=(t(k,i)-t(k,IR))*cut_off+t(k,IR)
+ r(k,i)=(r(k,i)-r(k,IR))*cut_off+r(k,IR)
+ end do
+ end do
+
+! END correction
+
+ ps1=0. !* UNUSED SLP correction for location & stretching
+
+ do i=1,IR
+ ps(i)=ps(i)+ps1(i) ! new pert after correct latitude and fact
+ end do
+!
+
+ do k=1,kmax
+ q(k)=pcst(k)/pcst(1) !* sigma coord
+ end do
+
+
+ do i=1,IR
+ ps1(i)=ps(i)+pcst(1) !* ps1 = total sfc pressure
+! print*,'i,ps,ps1=',i,ps(i),ps1(i)
+ end do
+
+ do k=1,kmax
+ do i=1,IR
+ p(k,i)=ps1(i)*q(k) !* pressure at sigma level
+ end do
+ end do
+
+! Interpolate const P data onto const sigma level.
+
+!CWH do i=1,IR1
+!CWH SLP_2SB(i)=ps(i)
+!CWH end do
+ do i=1,IR
+ SLP_2SB(i)=ps(i)
+ end do
+ SLP_2SB(IR1)=0
+
+ go to 799 !* UNUSED p-to-sigma correction ------------------------
+
+ DO I=1,IR
+ DO N=1,KMAX
+ work1(N)=t(N,I)+temp_e(N) !* total temperature
+ END DO
+ DO K=1,kmax
+ IF (p(k,i).GE.pcst(1)) THEN
+ U_2SB(i,k)=th(1,i)
+ V_2SB(i,k)=ur(1,i)
+ T_2SB(i,k)=work1(1)
+ R_2SB(i,k)=r(1,i)
+ ELSEIF (p(k,i).LE.pcst(kmax)) THEN
+ U_2SB(i,k)=th(kmax,i)
+ V_2SB(i,k)=ur(kmax,i)
+ T_2SB(i,k)=work1(kmax)
+ R_2SB(i,k)=r(kmax,i)
+ ELSE !* p-to-sigma interpolation
+ DO N=1,kmax
+ if ( p(k,i).LE.pcst(N) .AND. p(k,i).GT.pcst(N+1) ) then
+ WT1=ALOG(1.*pcst(N+1))-ALOG(1.*pcst(N))
+ WT2=(ALOG(1.*p(k,i))-ALOG(1.*pcst(N)))/WT1
+ WT3=1.-WT2
+ U_2SB(i,k)=WT3*th(N,i)+WT2*th(N+1,i)
+ V_2SB(i,k)=WT3*ur(N,i)+WT2*ur(N+1,i)
+ T_2SB(i,k)=WT3*work1(N)+WT2*work1(N+1)
+ R_2SB(i,k)=WT3*r(N,i)+WT2*r(N+1,i)
+ GOTO 870
+ endif
+ ENDDO
+ 870 continue
+ ENDIF
+ END DO
+ END DO
+
+ TSUM1=0.
+ TSUM2=0.
+
+ DO I=1,IR
+ DO K=1,KMAX
+ TEK1=temp_e(K)+t(k,i) !* total temperature
+ TEK2=T_2SB(i,k)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ R_2SB(i,k)=ESRR*r(k,i)
+ T_2SB(i,k)=T_2SB(i,k)-temp_e(K) !* perturbation temperature
+! T_2SB(i,k)=0.5*(T_2SB(i,k)+t(k,i)) ! avg btw const P and const Sigma
+! T_2SB(i,k)=0.5*t(k,i) ! average between const P and const Sigma
+ TSUM1=TSUM1+t(k,i)
+ TSUM2=TSUM2+T_2SB(i,k)
+ END DO
+ END DO
+
+ print*,'TSUM1,TSUM2=',TSUM1,TSUM2
+
+ TSUM1=TSUM1+TSUM2
+
+ DO I=1,IR
+ DO K=1,KMAX
+ IF (ABS(TSUM1).GT.0.01) THEN
+ T_2SB(i,k)=(t(k,i)+T_2SB(i,k))*TSUM2/TSUM1
+ ELSE
+ T_2SB(i,k)=0.
+ END IF
+ th(k,i)=U_2SB(i,k)
+ ur(k,i)=V_2SB(i,k)
+ t(k,i)=T_2SB(i,k) !* perturbation temperature
+ r(k,i)=R_2SB(i,k)
+! print*,'T_2SB(i,k)=',i,k,T_2SB(i,k)
+ END DO
+ END DO
+
+ 799 CONTINUE !* ------------------------------------------------------
+
+!* Using p-level instead of sigma-level
+ DO I=1,IR
+ DO K=1,KMAX
+ U_2SB(i,k)=th(k,i) !* tangen wind !!
+ V_2SB(i,k)=ur(k,i) !* radial wind !!
+ T_2SB(i,k)=t(k,i)
+ R_2SB(i,k)=r(k,i)
+ END DO
+ END DO
+
+!* Interpolate from cylin to E-grid
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ALLOCATE ( RIJ1(NX,NY),RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ do k=1,kmax
+ do j=1,ny
+ do i=1,nx
+ TENV(i,j,k)=temp_e(k)
+ HP(i,j,k)=p(k,IR)
+ HV(i,j,k)=p(k,IR)
+ end do
+ end do
+ end do
+
+!* Presume grid points outside vortex
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+ IDX1=-1
+
+!* Interpolate winds to E-grid inside vortex
+
+ DO J=1,NY
+ DO I=1,NX !* Relocate the vortex to storm center
+ RIJ1(I,J)=arad*SQRT(((VLON2(I,J)-CLON_NHC)*cost)**2+ &
+ (VLAT2(I,J)-CLAT_NHC)**2 )
+ DO N=1,IR
+ DIF=rp(N)-RIJ1(I,J)
+ IF (DIF.GT.0.) THEN
+ IDX1(I,J)=N !* Grid point inside vortex
+ GO TO 15
+ ENDIF
+ ENDDO
+ 15 CONTINUE
+ IF (IDX1(I,J).GE.2) THEN
+ W1(I,J)=(RIJ1(I,J)-rp(IDX1(I,J)-1))/ &
+ (rp(IDX1(I,J))-rp(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ W1(I,J)=RIJ1(I,J)/rp(IDX1(I,J))
+ W2(I,J)=0.
+ ENDIF
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ if (IDX1(I,J).GT.0) then
+
+ IF (IDX1(I,J).GE.2) THEN
+ DO K=1,KMAX
+ vrad(K)=W1(I,J)*ur(k,IDX1(I,J))+W2(I,J)*ur(k,IDX1(I,J)-1)
+ vtan(K)=W1(I,J)*th(k,IDX1(I,J))+W2(I,J)*th(k,IDX1(I,J)-1)
+ END DO
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ DO K=1,KMAX
+ vrad(K)=W1(I,J)*ur(k,IDX1(I,J)) ! WT=0. at center
+ vtan(K)=W1(I,J)*th(k,IDX1(I,J))
+ END DO
+ ENDIF
+
+ DTX=cost*(VLON2(I,J)-CLON_NHC)
+ DTY=VLAT2(I,J)-CLAT_NHC
+ DTR=RIJ1(I,J)/arad
+
+!CWH DO K=1,KMAX
+!CWH U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+!CWH V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+!CWH HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+!CWH END DO
+
+ IF (IDX1(I,J).GE.2) THEN
+ DO K=1,KMAX
+ U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+ V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+ HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+ END DO
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ DO K=1,KMAX
+ U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+ V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+ HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))
+ END DO
+ ENDIF
+
+ endif
+ ENDDO
+ ENDDO
+
+!* Interpolate ps, T, r to E-grid
+
+ do i=1,IR
+ do k=1,kmax
+ if (r(k,i).LT.0.) r(k,i)=0. !* positive-definite
+ end do
+ end do
+
+ IDX1=-1 !* Presume grid point outside vortex
+
+ DO J=1,NY
+ DO I=1,NX !* Relocate the vortex to storm center
+ RIJ2(I,J)=arad*SQRT(((HLON2(I,J)-CLON_NHC)*cost)**2+ &
+ (HLAT2(I,J)-CLAT_NHC)**2 )
+ DO N=1,IR
+ DIF=rp(N)-RIJ2(I,J)
+ IF (DIF.GT.0.) THEN
+ IDX1(I,J)=N !* Grid point inside vortex
+ GO TO 25
+ ENDIF
+ ENDDO
+ 25 CONTINUE
+ IF (IDX1(I,J).GE.2) THEN
+ W1(I,J)=(RIJ2(I,J)-rp(IDX1(I,J)-1))/ &
+ (rp(IDX1(I,J))-rp(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE
+ W1(I,J)=1.
+ W2(I,J)=0.
+ ENDIF
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ if (IDX1(I,J).GT.0) then
+ IF (IDX1(I,J).GE.2) THEN
+ SLP_1(I,J)=W1(I,J)*ps(IDX1(I,J))+W2(I,J)*ps(IDX1(I,J)-1)
+ DO K=1,KMAX
+ T_1(I,J,K)=W1(I,J)*t(k,IDX1(I,J))+W2(I,J)*t(k,IDX1(I,J)-1)
+ Q_1(I,J,K)=W1(I,J)*r(k,IDX1(I,J))+W2(I,J)*r(k,IDX1(I,J)-1)
+ HP(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+ ENDDO
+ ELSE
+ SLP_1(I,J)=ps(IDX1(I,J))
+ DO K=1,KMAX
+ T_1(I,J,K)=t(k,IDX1(I,J))
+ Q_1(I,J,K)=r(k,IDX1(I,J))
+ HP(I,J,K)=P(k,IDX1(I,J))
+ ENDDO
+ ENDIF
+ endif
+ ENDDO
+ ENDDO
+
+ RIJ_m=1.e20
+ DO J=1,NY
+ DO I=1,NX
+ IF (RIJ2(I,J).LT.RIJ_m) THEN
+ RIJ_m=RIJ2(I,J) !* min R
+ II1=I
+ JJ1=J
+ ENDIF
+ ENDDO
+ ENDDO
+ print*,'center inside axisym_xy=',HLON2(II1,JJ1),HLAT2(II1,JJ1)
+
+ PIJ_m=1.e20
+ DO J=1,NY
+ DO I=1,NX
+ IF (SLP_1(I,J).LT.PIJ_m) THEN
+ PIJ_m=SLP_1(I,J) !* min Ps
+ II1=I
+ JJ1=J
+ ENDIF
+ ENDDO
+ ENDDO
+
+ print*,'center inside axisym_xy 2=',HLON2(II1,JJ1),HLAT2(II1,JJ1),PIJ_m
+
+ END
+
+!==============================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/correct_mat_2.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/correct_mat_2.f90
new file mode 100644
index 000000000..aa91104f2
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/correct_mat_2.f90
@@ -0,0 +1,299 @@
+
+ SUBROUTINE CORT_MAT_2(IR1,NX,NY,NZ,KMX,U_2S, &
+ T_2S,SLP_2S,Q_2S,RADIUS,temp_e,TEK, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW,PS_C1, &
+ beta,fact,ics,SN)
+
+! input: IR1,NX,NY,KMX
+! input: U_2S,T_2S,Q_2S,SLP_2S variables from guess storm
+! input: HLON,HLAT,VLON,VLAT,TEK,temp_e
+! input: RADIUS,CLON_NEW,CLAT_NEW,ics
+! output: T_X,Q_X,SLP_X - new axisymmetric part
+
+ real(4) HLON(NX,NY),HLAT(NX,NY)
+ real(4) VLON(NX,NY),VLAT(NX,NY)
+
+ REAL(8) CLON_NEW,CLAT_NEW
+
+ real(4) T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY)
+
+ real(4) RADIUS(IR1)
+ real(4) U_2S(IR1,KMX),T_2S(IR1,KMX)
+ real(4) Q_2S(IR1,KMX),SLP_2S(IR1)
+
+ real(4) TEK(NZ),temp_e(KMX)
+
+ REAL(4), ALLOCATABLE :: RKX1(:),WKX1(:,:)
+ REAL(4), ALLOCATABLE :: RKX2(:),WKX2(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:,:),strm2(:,:),funct(:,:)
+
+ REAL(4), ALLOCATABLE :: rpb(:),rpb1(:),rpb2(:)
+ REAL(4), ALLOCATABLE :: rmix(:,:)
+ REAL(4), ALLOCATABLE :: ctmp(:,:),cmix(:,:)
+
+ REAL(4), ALLOCATABLE :: test1(:,:),work1(:,:)
+
+ REAL(4), ALLOCATABLE :: RIJ2(:,:)
+!zhang REAL(4), ALLOCATABLE :: IDX1(:,:),W1(:,:),W2(:,:)
+ REAL(4), ALLOCATABLE :: W1(:,:),W2(:,:)
+ INTEGER, ALLOCATABLE :: IDX1(:,:)
+
+ REAL(4), ALLOCATABLE :: FUN1(:)
+ REAL(4), ALLOCATABLE :: NDX1(:),WT1(:),WT2(:)
+!
+! Chanh
+!
+ CHARACTER SN*1
+
+ IR=IR1-1
+ nm=NZ
+ kmx1=kmx-1
+
+ NXC=NX/2
+ NYC=NY/2
+
+ ALLOCATE ( RKX1(IR1),WKX1(IR1,NZ) )
+ ALLOCATE ( RKX2(IR1),WKX2(IR1,NZ) )
+ ALLOCATE ( strm1(IR1,nm),strm2(IR1,nm),funct(IR1,nm) )
+
+ ALLOCATE ( rpb(IR1),rpb1(IR1),rpb2(IR1) )
+ ALLOCATE ( rmix(IR1,NM) )
+ ALLOCATE ( ctmp(IR1,kmx),cmix(IR1,kmx) )
+
+ ALLOCATE ( FUN1(IR1) )
+ ALLOCATE ( NDX1(IR1),WT1(IR1),WT2(IR1) )
+
+ pi=4.*atan(1.)
+ pi180=pi/180.
+ pi_deg=180./pi
+ DST1=6.371E6*pi180
+
+ cost=cos(clat_new*pi180)
+
+ print*,'inside cort'
+ print*,'pi= ',pi
+
+! check max, min temp
+
+ do k=1,kmx
+ tmax=-1.E20
+ tmin=1.E20
+ do j=1,IR1
+ if(T_2S(j,k).gt.tmax)then
+ tmax=T_2S(j,k)
+ jmax3=j
+ end if
+ if(T_2S(j,k).lt.tmin)then
+ tmin=T_2S(j,k)
+ jmin=j
+ end if
+ end do
+ print*,'k,tmax,tmin=',k,tmax,tmin
+ end do
+
+ print*,'clon_new,clat_new=',clon_new,clat_new
+
+ ff0=2.*7.292E-5*sin(clat_new*pi180)
+
+ print*,'beta,fact,ff0=',beta,fact,ff0
+
+ RKX1=0.
+ DO n=1,IR1
+ RKX1(n)=RADIUS(n)*DST1
+! print*,'RKX1(n)=',RKX1(n),U_2S(n,10)
+ END DO
+
+ RKX2=0.
+ DO n=1,IR1
+ RKX2(n)=RKX1(n)
+ END DO
+
+ k=1
+ k1=2
+!
+! Chanh added modification here to recompute the stream
+! function for the Southern Hemisphere,
+!
+ WKX1=0.
+ DO n=1,IR1
+ WKX1(n,k)=U_2S(n,k1)
+ IF(WKX1(n,k).lt.0..and.SN.eq.'N') WKX1(n,k)=0.
+ IF(WKX1(n,k).gt.0..and.SN.eq.'S') WKX1(n,k)=0.
+ END DO
+
+ WKX2=0.
+ DO n=1,IR1
+ WKX2(n,1)=U_2S(n,2)*beta
+ IF(WKX2(n,1).lt.0..and.SN.eq.'N') WKX2(n,1)=0.
+ IF(WKX2(n,1).gt.0..and.SN.eq.'S') WKX2(n,1)=0.
+ END DO
+
+ strm1(IR1,k)=0.
+ strm2(IR1,k)=0.
+ DO n=IR,1,-1
+ force=(WKX1(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX1(n,k)
+ strm1(n,k)=strm1(n+1,k)-force*(RKX1(n+1)-RKX1(n))
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ end do
+
+ print*,'finish computing stream function'
+
+ IR_1=IR1
+ DO n=1,IR1
+ sum_str=strm1(n,1)
+ if(abs(sum_str).gt.0.01)then
+ IR_1=n
+ end if
+ END DO
+
+ do m=1,IR_1
+ str_cut=max(strm2(m,1),strm1(m,1))
+ if(str_cut.gt.-10.)then
+ str_m_rat=strm2(m,1)/(strm1(m,1)-1.E-20)
+ IR_2=m
+ go to 57
+ end if
+ end do
+
+ 57 continue
+
+ fun1=0.
+ do m=1,IR_2
+ fun1(m)=strm2(m,1)/(strm1(m,1)-1.E-20)
+ end do
+
+ do m=IR_2,IR_1
+ fun1(m)=min(str_m_rat,strm2(m,1)/(strm1(m,1)-1.E-20))
+ end do
+
+! adjust func1 based on the center surface pressure
+
+ adj_fun1=PS_C1/(fun1(1)*SLP_2S(1))
+
+ rpb=0.
+ do m=1,IR_1
+ fun1(m)=fun1(m)*adj_fun1
+ rpb(m) =fun1(m)*SLP_2S(m)
+! print*,'fun1(m)=',m,fun1(m),rpb(m),fun1(m)*T_2S(m,1)
+ end do
+
+ ctmp=0.
+ do k=1,kmx
+ do m=1,IR_1
+ ctmp(m,k) =fun1(m)*T_2S(m,k)
+ end do
+ end do
+
+!!!!!
+! correct mixing ratio
+
+ rmix=0.
+ do k=1,NZ
+ k1=2*k
+ if (k1 .le. 121) then
+ do m=1,IR_1
+ TEK1=temp_e(k1)+T_2S(m,k1)
+ TEK2=TEK(k)+ctmp(m,k1)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+! rmix(m,k)=ESRR*Q_2S(m,k1)-Q_2S(m,k1)
+ rmix(m,k)=ESRR*Q_2S(m,k1)
+ end do
+ else
+ do m=1,IR_1
+ rmix(m,k)=0.0
+ enddo
+ endif
+ end do
+
+ do m=1,IR_1
+! rpb(m) =rpb(m)-SLP_2S(m)
+ rpb(m) =rpb(m)
+ end do
+
+ do k=1,kmx
+ do m=1,IR_1
+! ctmp(m,k) =ctmp(m,k)-T_2S(m,k)
+ ctmp(m,k) =ctmp(m,k)
+ end do
+ end do
+
+ cmix=0.
+ do m=1,IR_1
+ cmix(m,1)=rmix(m,1)
+ cmix(m,kmx)=rmix(m,NZ)
+ do k=2,kmx1,2
+ k1=k/2
+ cmix(m,k)=rmix(m,k1)
+ end do
+ do k=3,kmx1-1,2
+ k1=(k-1)/2
+ cmix(m,k)=0.5*(rmix(m,k1)+rmix(m,k1+1))
+ end do
+ end do
+
+ do m=IR_1,IR1
+ rpb(m)=0.
+ do k=1,kmx
+ ctmp(m,k)=0.
+ cmix(m,k)=0.
+ end do
+ end do
+
+! interpolate correction to 3D
+
+ ALLOCATE ( RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ IDX1=-1
+
+ DO J=1,NY
+ DO I=1,NX
+ RIJ2(I,J)=SQRT(((HLON(I,J)-CLON_NEW)*cost)**2+ &
+ (HLAT(I,J)-CLAT_NEW)**2 )
+ DO N=1,IR_1
+ DIF=RADIUS(N)-RIJ2(I,J)
+ IF(DIF.GT.0.)THEN
+ IDX1(I,J)=N
+ GO TO 25
+ END IF
+ END DO
+ 25 CONTINUE
+ IF(IDX1(I,J).GE.2)THEN
+ W1(I,J)=(RIJ2(I,J)-RADIUS(IDX1(I,J)-1))/ &
+ (RADIUS(IDX1(I,J))-RADIUS(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE
+ W1(I,J)=1.
+ W2(I,J)=0.
+ END IF
+ END DO
+ END DO
+
+ SLP_X=0.
+ T_X=0.
+ Q_X=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ IF(IDX1(I,J).GT.0)THEN
+ IF(IDX1(I,J).GE.2)THEN
+ SLP_X(I,J)=W1(I,J)*rpb(IDX1(I,J))+W2(I,J)*rpb(IDX1(I,J)-1)
+ DO K=1,KMX
+ T_X(I,J,K)=W1(I,J)*ctmp(IDX1(I,J),k)+W2(I,J)*ctmp(IDX1(I,J)-1,k)
+ Q_X(I,J,K)=W1(I,J)*cmix(IDX1(I,J),k)+W2(I,J)*cmix(IDX1(I,J)-1,k)
+ END DO
+ ELSE
+ SLP_X(I,J)=rpb(IDX1(I,J))
+ DO K=1,KMX
+ T_X(I,J,K)=ctmp(IDX1(I,J),k)
+ Q_X(I,J,K)=cmix(IDX1(I,J),k)
+ END DO
+ END IF
+ END IF
+ END DO
+ END DO
+
+ return
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/interp_coef_agrid.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/interp_coef_agrid.f90
new file mode 100644
index 000000000..1c63766c7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_bogus/interp_coef_agrid.f90
@@ -0,0 +1,300 @@
+SUBROUTINE EARTH_LATLON_AGRID ( HLAT,HLON,VLAT,VLON, & !Earth lat,lon at H and V points
+ LON1,LAT1,LON2,LAT2, & !input res,west & south boundaries,
+ CENTRAL_LAT,CENTRAL_LON, & ! central lat,lon, all in degrees
+ IM,JM)
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ REAL(4), INTENT(IN) :: LON1,LAT1,LON2,LAT2
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(OUT) :: HLAT,HLON,VLAT,VLON
+
+! local
+
+ INTEGER,PARAMETER :: KNUM=8
+ INTEGER :: I,J
+ REAL(KNUM) :: rot_lon,rot_lat,geo_lon,geo_lat
+ REAL(KNUM) :: cen_lon, cen_lat
+!-------------------------------------------------------------------------
+
+ cen_lon = CENTRAL_LON
+ cen_lat = CENTRAL_LAT
+
+ do j=1,jm
+ do i=1,im
+ rot_lon = lon1 + (lon2-lon1)/(im-1) * (i-1)
+ rot_lat = lat1 + (lat2-lat1)/(jm-1) * (j-1)
+ call rtll(rot_lon, rot_lat, geo_lon, geo_lat, cen_lon, cen_lat)
+! if (geo_lon <0.0) geo_lon = geo_lon + 360.0
+ HLON(i,j) = geo_lon
+ HLAT(i,j) = geo_lat
+ enddo
+ enddo
+
+ VLON = HLON
+ VLAT = HLAT
+
+END SUBROUTINE EARTH_LATLON_AGRID
+
+!-----------------------------------------------------------------------------
+
+SUBROUTINE G2T2H_AGRID( IIH,JJH, & ! output grid index
+ HBWGT, & ! output weights in terms of parent grid
+ HLAT,HLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: HLAT,HLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: HBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIH,JJH
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(HLON(I,J),HLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1)/DLMD1 + 1
+ YI = (Y-SBD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIH(I,J,1)=I1
+ IIH(I,J,2)=I2
+ IIH(I,J,3)=I1
+ IIH(I,J,4)=I2
+ JJH(I,J,1)=J1
+ JJH(I,J,2)=J1
+ JJH(I,J,3)=J2
+ JJH(I,J,4)=J2
+ HBWGT(I,J,1)=(1-XF)*(1-YF)
+ HBWGT(I,J,2)=XF*(1-YF)
+ HBWGT(I,J,3)=(1-XF)*YF
+ HBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+END SUBROUTINE G2T2H_AGRID
+
+
+
+SUBROUTINE G2T2V_BGRID( IIV,JJV, & ! output grid index and weights
+ VBWGT, & ! output weights in terms of parent grid
+ VLAT,VLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: VLAT,VLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: VBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIV,JJV
+
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(VLON(I,J),VLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1-0.5*DLMD1)/DLMD1 + 1
+ YI = (Y-SBD1-0.5*DPHD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIV(I,J,1)=I1
+ IIV(I,J,2)=I2
+ IIV(I,J,3)=I1
+ IIV(I,J,4)=I2
+ JJV(I,J,1)=J1
+ JJV(I,J,2)=J1
+ JJV(I,J,3)=J2
+ JJV(I,J,4)=J2
+ VBWGT(I,J,1)=(1-XF)*(1-YF)
+ VBWGT(I,J,2)=XF*(1-YF)
+ VBWGT(I,J,3)=(1-XF)*YF
+ VBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+
+ RETURN
+ END SUBROUTINE G2T2V_BGRID
+
+ subroutine rtll(tlmd,tphd,almd,aphd,tlm0d,tph0d)
+!-------------------------------------------------------------------------------
+ INTEGER,PARAMETER :: KIND_R8=8
+
+ real(KIND_R8), intent(in) :: tlmd, tphd
+ real(KIND_R8), intent(out) :: almd, aphd
+ real(KIND_R8), intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real(KIND_R8), parameter :: pi=3.14159265358979323846
+ real(KIND_R8), parameter :: dtr=pi/180.0
+!
+ real(KIND_R8) :: tph0, ctph0, stph0, tlm, tph, stph, ctph, ctlm, stlm, aph, cph
+ real(KIND_R8) :: xx, yy
+!-------------------------------------------------------------------------------
+!
+ tph0=tph0d*dtr
+ ctph0=cos(tph0)
+ stph0=sin(tph0)
+!
+ tlm=tlmd*dtr
+ tph=tphd*dtr
+ stph=sin(tph)
+ ctph=cos(tph)
+ ctlm=cos(tlm)
+ stlm=sin(tlm)
+!
+ xx=stph0*ctph*ctlm+ctph0*stph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ aph=asin(xx)
+ cph=cos(aph)
+!
+ xx=(ctph0*ctph*ctlm-stph0*stph)/cph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ xx=acos(xx)/dtr
+ yy=ctph*stlm/cph
+ xx=sign(xx,yy)
+ almd=tlm0d+xx
+
+ aphd=aph/dtr
+!
+ if (almd > 180.0) then
+ almd=almd-360.0
+ end if
+ if (almd < -180.0) then
+ almd=almd+360.0
+ end if
+!
+ return
+!
+ end subroutine rtll
+
+
+ subroutine tll(almd,aphd,tlmd,tphd,tph0d,tlm0d)
+!-------------------------------------------------------------------------------
+ implicit none
+!-------------------------------------------------------------------------------
+ real, intent(in) :: almd, aphd
+ real(8), intent(out) :: tlmd, tphd
+ real, intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real, parameter :: pi=3.141592654
+ real(8), parameter :: dtr=pi/180.0
+!
+ real(8) :: tph0, ctph0, stph0, relm, srlm, crlm
+ real(8) :: aph, sph, cph, cc, anum, denom
+!-------------------------------------------------------------------------------
+!
+ if (tlm0d==0.0.and.tph0d==0.0) then
+ tlmd=almd
+ tphd=aphd
+ else
+
+ tph0=tph0d*dtr
+ ctph0=dcos(tph0)
+ stph0=dsin(tph0)
+!
+ relm=(almd-tlm0d)*dtr
+ srlm=dsin(relm)
+ crlm=dcos(relm)
+ aph=aphd*dtr
+ sph=dsin(aph)
+ cph=dcos(aph)
+ cc=cph*crlm
+ anum=cph*srlm
+ denom=ctph0*cc+stph0*sph
+!
+ tlmd=datan2(anum,denom)/dtr
+ tphd=dasin(ctph0*sph-stph0*cc)/dtr
+
+ end if
+!
+ return
+!
+ end subroutine tll
+
+
+!! subroutine 'get_eta_level' returns the interface and
+!! layer-mean pressures for reference.
+ subroutine get_eta_level(npz, p_s, pf, ph, ak, bk, pscale)
+ integer, intent(in) :: npz
+ real, intent(in) :: p_s !< unit: pascal
+ real, intent(in) :: ak(npz+1)
+ real, intent(in) :: bk(npz+1)
+ real, intent(in), optional :: pscale
+ real, intent(out) :: pf(npz)
+ real, intent(out) :: ph(npz+1)
+
+ real, parameter :: RDGAS = 287.05 !< Gas constant for dry air [J/kg/deg]
+ real, parameter :: CP_AIR = 1004.6 !< Specific heat capacity of dry air at constant pressure [J/kg/deg]
+ real, parameter :: KAPPA = RDGAS/CP_AIR !< RDGAS / CP_AIR [dimensionless]
+ integer k
+
+ ph(1) = ak(1)
+ do k=2,npz+1
+ ph(k) = ak(k) + bk(k)*p_s
+ enddo
+
+! if ( present(pscale) ) then
+! do k=1,npz+1
+! ph(k) = pscale*ph(k)
+! enddo
+! endif
+
+ if( ak(1) > 1.E-8 ) then
+ pf(1) = (ph(2) - ph(1)) / log(ph(2)/ph(1))
+ else
+ pf(1) = (ph(2) - ph(1)) * kappa/(kappa+1.)
+ endif
+
+ do k=2,npz
+ pf(k) = (ph(k+1) - ph(k)) / log(ph(k+1)/ph(k))
+ enddo
+
+ end subroutine get_eta_level
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/CMakeLists.txt
new file mode 100644
index 000000000..cb0a2daed
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/CMakeLists.txt
@@ -0,0 +1,32 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ anl_combine.f90
+ split_sym_asy.f90
+ correct_mat.f90
+ interp_coef_agrid.f90
+ fill_nmm_gridg.f90)
+
+set(exe_name hafs_vi_anl_combine.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_libraries(
+ ${exe_name} PRIVATE
+ OpenMP::OpenMP_Fortran)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/Makefile
new file mode 100644
index 000000000..bc9fe3313
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/Makefile
@@ -0,0 +1,19 @@
+include ../configure.vi
+include ../pure-openmp.inc
+
+OBJS = anl_combine.o split_sym_asy.o correct_mat.o interp_coef_agrid.o \
+ fill_nmm_gridg.o
+
+EXEC = ../../../exec/hafs_vi_anl_combine.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/anl_combine.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/anl_combine.f90
new file mode 100644
index 000000000..33dd50db8
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/anl_combine.f90
@@ -0,0 +1,2777 @@
+!******************************************************************************
+!
+! ABSTRACT: Correct storm size based on observation and model forecast
+!
+! ORIGINAL AUTHOR: QINGFU LIU, NCEP/EMC, 2007
+! REVISED AUTHOR: Kelvin Yeh (AOML/HRD), JULY 2010
+! : Extend the storm size correction to 2 parameters
+! REVISED AUTHOR: Qingfu Liu, 2013
+! : Storm size diagnoses moved to hwrf_pert_ct.f90
+! : ROCI is used only as reference, R34 calculation is fixed
+! REVISED AUTHOR: Mingjing Tong 2013
+! Added option (INITOPT) to do relcation only or to do full
+! vortex initialization. Modified to allow vortex
+! initialization at other time levels
+!______________________________________________________________________________
+
+! DECLARE VARIABLES
+
+ INTEGER I,J,K,NX,NY,NZ,IFLAG,NX2
+ INTEGER ITIM,IGFS_FLAG,INITOPT
+
+! PARAMETER (NX=215,NY=431,NZ=42,NST=5)
+ PARAMETER (NST=5)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.)
+
+! PARAMETER (KMX=2*NZ+1)
+
+! Variables on 4x hybrid coordinate (ENV)
+
+ REAL(4) DLMD,DPHD,PT,PDTOP
+ REAL(4) WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ REAL(4) LON1,LAT1,LON2,LAT2
+
+ REAL(4), ALLOCATABLE :: T1(:,:,:),Q1(:,:,:)
+ REAL(4), ALLOCATABLE :: U1(:,:,:),V1(:,:,:),DZDT(:,:,:)
+ REAL(4), ALLOCATABLE :: Z1(:,:,:),P1(:,:,:)
+ REAL(4), ALLOCATABLE :: GLON(:,:),GLAT(:,:)
+ REAL(4), ALLOCATABLE :: PD1(:,:),ETA1(:),ETA2(:)
+
+ REAL(4), ALLOCATABLE :: USCM(:,:),VSCM(:,:) ! Env. wind at new grids
+
+ REAL(4), ALLOCATABLE :: HLON(:,:),HLAT(:,:)
+ REAL(4), ALLOCATABLE :: VLON(:,:),VLAT(:,:)
+
+! variables for hurricane component
+
+ REAL(4), ALLOCATABLE :: HLON2(:,:),HLAT2(:,:)
+ REAL(4), ALLOCATABLE :: VLON2(:,:),VLAT2(:,:)
+
+ REAL(4), ALLOCATABLE :: SLPE(:,:),SLP_1(:,:),TENV(:,:,:)
+! REAL(4), ALLOCATABLE :: QENV(:,:,:)
+ REAL(4), ALLOCATABLE :: T_1(:,:,:),Q_1(:,:,:)
+ REAL(4), ALLOCATABLE :: U_1(:,:,:),V_1(:,:,:)
+
+ REAL(4), ALLOCATABLE :: U_850(:,:),V_850(:,:)
+! REAL(4), ALLOCATABLE :: SLP_2(:,:)
+
+ REAL(4), ALLOCATABLE :: DUM(:,:),DUMA(:,:)
+
+! working array
+
+ REAL(4), ALLOCATABLE :: SLP1(:,:),ANG2(:,:)
+ REAL(4), ALLOCATABLE :: PMID1(:,:,:),ZMID1(:,:,:)
+ REAL(4), ALLOCATABLE :: ZS1(:,:),TS1(:,:),QS1(:,:)
+
+ REAL(4), ALLOCATABLE :: U_S(:,:),U_A(:,:)
+ REAL(4), ALLOCATABLE :: V_S(:,:),V_A(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON3(:,:),HLAT3(:,:)
+ REAL(4), ALLOCATABLE :: VLON3(:,:),VLAT3(:,:)
+
+ REAL(4) CLON1,CLAT1
+
+ REAL(4), ALLOCATABLE :: USC_1(:,:),VSC_1(:,:) ! hurr comp wind at level 1
+ REAL(4), ALLOCATABLE :: USC1(:,:),VSC1(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: USC2(:,:),VSC2(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: SLPV(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON1(:,:),HLAT1(:,:)
+ REAL(4), ALLOCATABLE :: VLON1(:,:),VLAT1(:,:)
+ REAL(4), ALLOCATABLE :: T21(:,:,:,:),Q21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: U21(:,:,:,:),V21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: SLP21(:,:,:)
+ REAL(4), ALLOCATABLE :: PMV1(:,:,:)
+
+ REAL(4), ALLOCATABLE :: A101(:,:),B101(:,:),C101(:,:)
+
+ REAL(4), ALLOCATABLE :: U_2(:,:,:),V_2(:,:,:)
+ REAL(4), ALLOCATABLE :: U_3(:,:,:),V_3(:,:,:)
+ REAL(4), ALLOCATABLE :: T_4(:,:,:),Q_4(:,:,:)
+
+! REAL(8), ALLOCATABLE :: WRK1(:),WRK2(:),WRK3(:),WRK4(:)
+
+ REAL(4), ALLOCATABLE :: PCST(:),HP(:,:,:)
+
+ REAL(4), ALLOCATABLE :: PW(:)
+ REAL(4), ALLOCATABLE :: PFL(:),PHL(:)
+
+ REAL(4), ALLOCATABLE :: HBWGT1(:,:,:),VBWGT1(:,:,:)
+ integer(4), ALLOCATABLE :: IIH1(:,:,:),JJH1(:,:,:)
+ integer(4), ALLOCATABLE :: IIV1(:,:,:),JJV1(:,:,:)
+
+ REAL(4), ALLOCATABLE :: T_X(:,:,:),Q_X(:,:,:),SLP_X(:,:)
+
+ REAL(4), ALLOCATABLE :: dist(:,:)
+
+ integer(4) IH1(4),JH1(4),IV1(4),JV1(4),MLAT(7),MLON(7)
+
+ CHARACTER ST_NAME(NST)*3,SN*1,EW*1,DEPTH*1
+ REAL(8) CLON_NEW,CLAT_NEW,CLON_NHC,CLAT_NHC,CLON_NHC_6H,CLAT_NHC_6H
+ REAL(8) CLON_NEW1,CLAT_NEW1
+
+ DIMENSION TWM(101),RWM(101),TH1(200),RP(200)
+
+ REAL(4) zmax
+
+ integer Ir_v4(4), IR34_mod(4)
+ REAL R34_obs(4), R34_mod(4)
+ REAL(8) WRK1(150),WRK2(150),WRK3(150),WRK4(150)
+
+ CHARACTER PART1*2,basin*2,NUM*2
+!zhang: added basin domain shift option
+ CHARACTER*2 :: basin1
+ LOGICAL TSTH
+ REAL :: check_west, check_east
+
+ COEF1=Rd/Cp
+ COEF3=Rd*GAMMA/G
+ COEF2=1./COEF3
+
+ GRD=G/Rd
+ rdgas1=287.04/9.80
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi !* rad -> deg
+ pi180=pi/180. !* deg -> rad
+
+ DST1=6.371E6*pi180 !* deg -> m
+ arad=DST1 !* deg -> m
+
+ eps1 = 1.E-1
+ eps2 = 1.E-2
+ eps3 = 1.E-3
+ eps4 = 1.E-4
+ eps5 = 1.E-5
+ eps6 = 1.E-6
+ v34kt= 34./1.944 !* m/s
+ v50kt= 50./1.944 !* m/s
+ v64kt= 64./1.944 !* m/s
+ rad2deg= 180./pi !* rad -> deg
+ deg2rad= pi/180. !* deg -> rad
+ deg2km= deg2rad*6.371E3 !* deg -> km
+ deg2m = deg2rad*6.371E6 !* deg -> m
+
+ READ(5,*)ITIM,basin1,IGFS_FLAG,INITOPT
+
+ print*,'ITIM,basin1,IGFS_FLAG,INITOPT=',ITIM,basin1,IGFS_FLAG,INITOPT
+
+! Read TC vitals ...
+
+ READ(11,11) id_storm,ICLAT,SN,ICLON,EW,Ipsfc,Ipcls, &
+ Irmax,ivobs,Ir_vobs,(Ir_v4(I),I=1,4),DEPTH
+
+ 11 format(5x,I2,26x,I3,A1,I5,A1,9x,I4,1x,I4,1x,I4,I3,I4,4I5,1x,A1)
+
+ CLAT_NHC=ICLAT*0.1
+ CLON_NHC=ICLON*0.1
+
+ IF(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+ IF(EW.eq.'W')CLON_NHC=-CLON_NHC
+!
+!
+ psfc_obs = Ipsfc*100. !* pmin (Pa)
+ psfc_cls = Ipcls*100. !* pout (Pa)
+ delt_p=psfc_obs-psfc_cls
+ PRMAX = Irmax*1. !* ROCI (km)
+
+ vobs = ivobs*1.0 !* Vmax (m/s)
+ vobs_o= vobs
+ VRmax = Ir_vobs*1. !* RMW (km)
+ vobs = max(vobs,1.)
+ vrmax = max(vrmax,19.)
+
+ R34obs = 0.
+ R34obsm= 0.
+ acount = 0.
+ R34_obs= 0.
+ DO i = 1, 4
+ if ( Ir_v4(i) > 0 ) then
+! if(Ir_v4(i) < 0 ) Ir_v4(i) = 0
+ R34_obs(i) = Ir_v4(i)
+ R34obs = R34obs + Ir_v4(i)
+ acount = acount + 1.
+ if(R34obsm.lt.R34_obs(i)) R34obsm = R34_obs(i)
+ endif
+ ENDDO
+ IF ( acount > 0.5 ) R34obs = R34obs/acount !* avg R34 [km]
+
+ PRINT*, 'Obsereved Vmax: vobs [m/s], DEPTH =', vobs, DEPTH
+ PRINT*, 'Obsereved RMW: Ir_vobs, VRmax [km] =', Ir_vobs, VRmax
+ PRINT*, 'Obsereved R34: NE,SE,SW,NW,AVG [km] =', Ir_v4, R34obs,R34obsm
+ PRINT*, 'Obsereved ROCI: Irmax, PRmax [km] =', Irmax, PRmax
+ PRINT*, 'Obsereved Pressure: pmin, pout [Pa] =', psfc_obs, psfc_cls
+
+ REWIND 11
+
+! READ 4x area env. data HWRF
+
+ IUNIT=26
+
+ READ(IUNIT) NX,NY,NZ,I360
+
+ print*,'NX,NY,NZ=',NX,NY,NZ
+
+ NX1=NX+1
+ NY1=NY+1
+ NZ1=NZ+1
+ IF ( NZ <= 60 ) THEN
+ KMX=2*NZ+1
+ ELSE
+! Warning: currently hard wired to 121 due to memory limit
+ KMX=121
+ ENDIF
+
+ ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+ ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+ ALLOCATE ( Z1(NX,NY,NZ+1),P1(NX,NY,NZ+1) )
+ ALLOCATE ( GLON(NX,NY),GLAT(NX,NY) )
+ ALLOCATE ( PD1(NX,NY),ETA1(NZ+1),ETA2(NZ+1) )
+ ALLOCATE ( USCM(NX,NY),VSCM(NX,NY) ) ! Env. wind at new grids
+
+ ALLOCATE ( HLON(NX,NY),HLAT(NX,NY) )
+ ALLOCATE ( VLON(NX,NY),VLAT(NX,NY) )
+ ALLOCATE ( PMID1(NX,NY,NZ),ZMID1(NX,NY,NZ) )
+
+ ALLOCATE ( dist(NX,NY) )
+
+ READ(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT ! Domain res & center (deg)
+ READ(IUNIT) PMID1
+ READ(IUNIT) T1
+ READ(IUNIT) Q1
+ READ(IUNIT) U1
+ READ(IUNIT) V1
+ READ(IUNIT) DZDT
+ READ(IUNIT) Z1
+! READ(IUNIT) GLON,GLAT
+ READ(IUNIT) HLON,HLAT,VLON,VLAT
+ READ(IUNIT) P1
+ READ(IUNIT) PD1
+ READ(IUNIT) ETA1
+ READ(IUNIT) ETA2
+! READ(IUNIT) USCM
+! READ(IUNIT) VSCM
+
+ CLOSE(IUNIT)
+
+ if(I360.eq.360)then
+ IF(CLON_NHC.GT.0.)CLON_NHC=CLON_NHC-360.
+ endif
+
+ DO J=1,NY
+ DO I=1,NX
+ GLON(I,J)=HLON(I,J)
+ GLAT(I,J)=HLAT(I,J)
+ END DO
+ END DO
+!
+ ALLOCATE ( SLP1(NX,NY),ANG2(NX,NY) )
+! ALLOCATE ( PMID1(NX,NY,NZ),ZMID1(NX,NY,NZ) )
+ ALLOCATE ( ZS1(NX,NY),TS1(NX,NY),QS1(NX,NY) )
+
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+ TV1=T1(I,J,K)*(1.+D608*Q1(I,J,K))
+ ZMID1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5+ &
+ 0.5*TV1/GAMMA*(2.-(P1(I,J,K)/PMID1(I,J,K))**COEF3- &
+ (P1(I,J,K+1)/PMID1(I,J,K))**COEF3)
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ZMID1(I,J,K)=0.5*(Z1(I,J,K)+Z1(I,J,K+1))
+ ENDDO
+ ENDDO
+ ENDDO
+
+
+! Compute sea level pressure
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSF1 = ZMID1(I,J,1)
+ PSF1 = PMID1(I,J,1)
+ TV1 = T1(I,J,1)*(1.+D608*Q1(I,J,1))
+ A = (GAMMA * ZSF1) / TV1
+ SLP1(I,J) = PSF1*(1+A)**COEF2
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ ZS1(I,J) = Z1(I,J,1)
+ TS1(I,J) = T1(I,J,1)+GAMMA*(Z1(I,J,2)-Z1(I,J,1))*0.5
+ QS1(I,J) = Q1(I,J,1)
+ ENDDO
+ ENDDO
+
+! WRITE(61)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(61)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(61)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+! compute 10m wind
+
+ IUNIT=46
+
+ READ(IUNIT) JX,JY
+
+ ALLOCATE ( A101(JX,JY),B101(JX,JY),C101(JX,JY) )
+
+ READ(IUNIT) !LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) !PM1
+ READ(IUNIT) !T1
+ READ(IUNIT) !Q1
+ READ(IUNIT) !U1
+ READ(IUNIT) !V1
+ READ(IUNIT) !DZDT ! new
+ READ(IUNIT) !Z1
+ READ(IUNIT) !HLON,HLAT,VLON,VLAT
+ READ(IUNIT) !P1
+ READ(IUNIT) !PD ! surface pressure
+ READ(IUNIT) !ETA1
+ READ(IUNIT) !ETA2
+ READ(IUNIT) A101
+ READ(IUNIT) B101
+ READ(IUNIT) C101
+
+ CLOSE(IUNIT)
+
+ PRINT*,'JX,JY,NX,NY=',JX,JY,NX,NY
+
+! finsih compute 10m wind
+
+! WBD=-(NX-1)*DLMD
+! SBD=-((NY-1)/2)*DPHD
+ WBD = LON1
+ SBD = LAT1
+
+ write(*,*)'DLMD,DPHD,PT,PDTOP=',DLMD,DPHD,PT,PDTOP
+ write(*,*)'WBD,SBD,CENTRAL_LON,CENTRAL_LAT=', &
+ WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ do k=1,nz1
+ write(*,*)'K,ETA1,ETA2=',K,ETA1(k),ETA2(k)
+ end do
+
+ print*,'CLON,CLAT=',GLON(1+(NX-1)/2,1+(NY-1)/2), &
+ GLAT(1+(NX-1)/2,1+(NY-1)/2)
+ print*,'SLON,SLAT=',GLON(1,1), &
+ GLAT(1,1)
+
+! CLON1=HLON(1+(NX-1)/2,1+(NY-1)/2)
+! CLAT1=HLAT(1+(NX-1)/2,1+(NY-1)/2)
+ CLON1=CENTRAL_LON
+ CLAT1=CENTRAL_LAT
+
+ ALLOCATE ( HLON3(NX,NY),HLAT3(NX,NY) )
+ ALLOCATE ( VLON3(NX,NY),VLAT3(NX,NY) )
+
+! LON & LAT at U,V
+
+ DLMD = (LON2-LON1)/(NX-1)
+ DPHD = (LAT2-LAT1)/(NY-1)
+
+ CALL EARTH_LATLON_AGRID ( HLAT3,HLON3,VLAT3,VLON3, & ! lat, lon at H, V points
+ LON1,LAT1,LON2,LAT2, & ! input res, west & south bdry
+ CLAT1,CLON1, & ! central lat,lon, all in degree
+ NX,NY )
+
+ if(I360.eq.360) then
+ DO J=1,NY
+ DO I=1,NX
+ IF(HLON3(I,J).GT.0.)HLON3(I,J)=HLON3(I,J)-360.
+ IF(VLON3(I,J).GT.0.)VLON3(I,J)=VLON3(I,J)-360.
+ END DO
+ END DO
+ endif
+
+
+ print*,'HLAT,HLON,VLAT,VLON=', &
+ HLAT(1,1),HLON(1,1),VLAT(1,1),VLON(1,1)
+ print*,'HLAT3,HLON3,VLAT3,VLON3=', &
+ HLAT3(1,1),HLON3(1,1),VLAT3(1,1),VLON3(1,1)
+
+! * * * * * * * * * *
+
+! Read hurricane perturbation
+
+ ALLOCATE ( HLON2(NX,NY),HLAT2(NX,NY) )
+ ALLOCATE ( VLON2(NX,NY),VLAT2(NX,NY) )
+
+ ALLOCATE ( PCST(KMX),HP(NX,NY,KMX) )
+ ALLOCATE ( SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMX) )
+! ALLOCATE ( QENV(NX,NY,KMX) )
+ ALLOCATE ( T_1(NX,NY,KMX),Q_1(NX,NY,KMX) )
+ ALLOCATE ( U_1(NX,NY,KMX),V_1(NX,NY,KMX) )
+ ALLOCATE ( U_850(NX,NY),V_850(NX,NY) )
+! ALLOCATE ( SLP_2(NX,NY) )
+
+ ALLOCATE ( U_S(NX,NY),U_A(NX,NY) )
+ ALLOCATE ( V_S(NX,NY),V_A(NX,NY) )
+
+ ALLOCATE ( USC_1(NX,NY),VSC_1(NX,NY) ) ! hurr comp wind at level 1
+ ALLOCATE ( USC1(NX,NY),VSC1(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( USC2(NX,NY),VSC2(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( SLPV(NX,NY) )
+
+ ALLOCATE ( T21(NX,NY,KMX,4),Q21(NX,NY,KMX,4) )
+ ALLOCATE ( U21(NX,NY,KMX,4),V21(NX,NY,KMX,4) )
+ ALLOCATE ( SLP21(NX,NY,4) )
+ ALLOCATE ( PMV1(NX,NY,NZ) )
+
+ ALLOCATE ( T_4(NX,NY,KMX),Q_4(NX,NY,KMX) )
+
+ ALLOCATE ( T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY) )
+
+! ALLOCATE ( WRK1(KMX),WRK2(KMX),WRK3(KMX),WRK4(KMX) )
+
+ ALLOCATE ( PW(KMX) )
+ ALLOCATE ( PFL(NZ),PHL(NZ+1) )
+
+ IR1=120
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+ T_X=0.
+ Q_X=0.
+ SLP_X=0.
+
+ NCHT=71
+ READ(NCHT)KSTM
+ PRINT*,'test1',KSTM
+
+ READ(NCHT)HLAT2,HLON2
+ READ(NCHT)VLAT2,VLON2
+
+ print*,'HLAT2,HLON2=',HLAT2(1,1),HLON2(1,1)
+ print*,'VLAT2,VLON2=',VLAT2(1,1),VLON2(1,1)
+
+ deltp=1.e20
+
+ READ(NCHT)PCST
+ DO K=1,KMX
+ PRINT*,'K,PCST=',K,PCST(K)
+ deltp1=abs(PCST(K)-85000.)
+ IF (deltp1.LT.deltp) THEN
+ deltp=deltp1
+ k850=k
+ END IF
+ END DO
+
+ k850=1 ! use the surface wind
+
+ READ(NCHT)HP
+
+ KST=1
+ READ(NCHT) ST_NAME(KST)
+ PRINT*,'ST_NAME=',ST_NAME(KST)
+ READ(NCHT) CLON_NEW,CLAT_NEW
+!
+ if(I360.eq.360)then
+ IF (CLON_NEW.gt.0.) CLON_NEW=CLON_NEW-360.
+ endif
+
+ PRINT*,CLON_NEW,CLAT_NEW
+!
+ print*,'HLAT2,HLON2=',HLAT2(1,1),HLON2(1,1)
+ print*,'VLAT2,VLON2=',VLAT2(1,1),VLON2(1,1)
+
+ READ(NCHT) zmax
+ print*,'zmax=',zmax
+
+ READ(NCHT)IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ PRINT*,IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ READ(NCHT)((SLPE(I,J),I=1,NX),J=1,NY) ! SLP
+ READ(NCHT)((SLP_1(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1) ! pert SLP
+! WRITE(25)((SLP_1(I,J),I=1,NX),J=1,NY,2)
+ PRINT*,'TEST1'
+ DO K=1,KMX
+ READ(NCHT)((TENV(I,J,K),I=1,NX),J=1,NY)
+ READ(NCHT)((T_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+! WRITE(25) ((T_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,KMX
+ READ(NCHT)((U_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ READ(NCHT)((V_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+! WRITE(25)((U_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+! DO K=1,KMX
+! WRITE(25)((V_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+ PRINT*,'TEST31'
+ DO K=1,KMX
+!!! READ(NCHT)((QENV(I,J,K),I=1,NX),J=1,NY)
+ READ(NCHT)((Q_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+! WRITE(25) ((Q_1(I,J,K),I=1,NX),J=1,NY,2)
+ DO J=JWMIN1,JWMAX1
+ DO I=IWMIN1,IWMAX1
+ Q_1(I,J,K)=Q_1(I,J,K)*1.E-3
+ END DO
+ END DO
+ PRINT*,'K,TEST21',K
+ END DO
+
+ U_850=0.
+ V_850=0.
+
+ IF(IGFS_FLAG.EQ.1)THEN
+ K850=1
+ wt=0.
+ DO J=1,NY
+ DO I=1,NX
+ U_850(I,J)=U_1(I,J,K850)
+ V_850(I,J)=V_1(I,J,K850)
+ wt=max(wt,sqrt(U_850(I,J)*U_850(I,J)+V_850(I,J)*V_850(I,J)))
+ END DO
+ END DO
+ ELSE
+! READ(NCHT)((U_850(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+! READ(NCHT)((V_850(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ K850=1
+ wt=0.
+ DO J=1,NY
+ DO I=1,NX
+ U_850(I,J)=U_1(I,J,K850)
+ V_850(I,J)=V_1(I,J,K850)
+ wt=max(wt,sqrt(U_850(I,J)*U_850(I,J)+V_850(I,J)*V_850(I,J)))
+ END DO
+ END DO
+ END IF
+
+ PRINT*,'TEST41'
+
+ CLOSE(NCHT)
+
+ read(23) ! IR1,IR_1,NX,NY,NZ,KMX
+ read(23) ! RADUS
+ read(23) ! CLON_NEW,CLAT_NEW
+ read(23) ! U_2S,V_2S,U_2S1
+ read(23) ! T_2S,Q_2S,SLP_2S
+ read(23) ! CFT,PW,beta11
+ read(23) ! TEK,HP
+ read(23)aaa1,bbb1,SLP_T1
+ read(23)rmw1_mod,rmw2_obs
+! read(23)rmw1_mod,rmw2_obs,roc11,roc21
+! read(23)ftmin1,ftmax1,ctmin1,ctmax1
+
+ rewind(23)
+
+! READ forecast storm pressure
+
+ IF(ST_NAME(KST)(3:3).eq.'L') basin='AL'
+ IF(ST_NAME(KST)(3:3).eq.'W') basin='WP'
+ IF(ST_NAME(KST)(3:3).eq.'E') basin='EP'
+ IF(ST_NAME(KST)(3:3).eq.'C') basin='CP'
+
+ PMN06=-999.
+
+ acount = 0.
+ R34mod=0.
+ R34modm=0.
+ R34_mod=0.
+
+ DO I=1,100
+ READ(12,65,end=104)PART1,NUM,IDAT,IHOUR,IFH,LAT,SN,LON,EW,IVFT,IPFT,IV34,IR34_mod
+ IF(PART1.eq.basin.and.NUM.eq.ST_NAME(KST)(1:2))THEN
+ IF(IFH.eq.ITIM)THEN
+ VMX06=IVFT*0.514668039 ! 0.514668039=1./1.943
+ PMN06=IPFT*100.0
+ if(IV34.eq.34)then
+ print*,'IV34,IR34_mod=',IV34,IR34_mod
+ do j=1,4
+! R34_mod(j)=IR34_mod(j)*(vobs/VMX06)**2
+ R34_mod(j)=IR34_mod(j)*(vobs/VMX06)
+ if ( R34_mod(j) > 0 ) then
+! if ( R34_mod(j) < 0) R34_mod(j) = 0
+ R34mod = R34mod + R34_mod(j)
+ acount = acount + 1
+ if(R34modm.lt.R34_mod(j)) R34modm = R34_mod(j)
+ end if
+ end do
+ end if
+ END IF
+ END IF
+ END DO
+
+ 65 FORMAT(A2,2x,A2,4x,I6,I2,12x,I3,2x,I3,A1,2x,I4,A1,2X,I3,2x,I4,6x,I3,5x,4(1x,I5))
+
+ 104 CONTINUE
+
+ IF ( acount > 0.5 ) R34mod = R34mod/acount !* avg R34 [km]
+
+ psfc_obs2=psfc_obs
+
+ print*,'obs psfc_obs,PMN06=',psfc_obs,PMN06
+ print*,'VMX06,vobs=',VMX06,vobs
+
+! for 2008 version only (large error in P-W relationship)
+! for correct P-W relation: PMN06_ct=max(PMN06_ct,psfc_obs-1000.)
+
+! if(VMX06.gt.29..and.vobs.gt.29.)then
+ if(VMX06.gt.25..and.vobs.gt.25.)then
+ dpv_ct=-0.1515*(vobs)**0.628*(vobs-VMX06) ! slope*dv
+ PMN06_ct=PMN06+dpv_ct*100.
+ if(PMN06_ct.lt.psfc_obs)then
+! PMN06_ct=max(PMN06_ct,psfc_obs-7500.) ! max difference is set to be 75mb
+! PMN06_ct=max(PMN06_ct,psfc_obs-5500.) ! max difference is set to be 75mb
+! PMN06_ct=max(PMN06_ct,psfc_obs-3000.) ! max difference is set to be 30mb
+ PMN06_ct=max(PMN06_ct,psfc_obs-2500.) ! max difference is set to be 25mb
+! PMN06_ct=max(PMN06_ct,psfc_obs-2000.) ! max difference is set to be 20mb
+! psfc_obs=0.5*(psfc_obs+PMN06_ct) ! max difference is set to be 10mb
+ psfc_obs=PMN06_ct
+ end if
+ print*,'dpv_ct,PMN06_ct=',dpv_ct,PMN06_ct
+ end if
+
+ if(VMX06.gt.25..and.vobs.gt.25.)then
+ psfc_obs=min(SLP_T1,psfc_obs2)
+ end if
+ psfc_obs=max(psfc_obs,psfc_obs2+delt_p*0.10)
+
+ if(psfc_obs.lt.89500.)then
+ psfc_obs=min(89500.,psfc_obs2)
+ end if
+
+ print*,'cot psfc_obs,psfc_obs2,delt_p=',psfc_obs,psfc_obs2,delt_p
+
+! * * * * * * * * * *
+
+! CALL FIND_NEWCT1(NX,NY,U_1(1,1,k850),V_1(1,1,k850), &
+! VLON2,VLAT2,CLON_NEW,CLAT_NEW)
+
+ CALL Split_Sym_Asy(NX,NY,1,U_850,V_850,U_S,V_S,U_A,V_A, &
+ TWM,RWM,VLON2,VLAT2,CLON_NEW,CLAT_NEW,TWMAX,RWMAX,ASYM)
+
+ cost = cos(clat_new*pi180)
+ RMX_d = max(2.5*RWMAX,2.0)
+ d_max=3.5
+ IF(vobs.gt.30..and.CLAT_NHC.gt.30.)d_max=4.5
+ RMX_d = min(RMX_d,d_max)
+
+ PRINT*,'RMX_d0, RWMAX =', RMX_d, RWMAX !* RMW of symmetric component
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX !* Search RMW including asymmetric component
+ vmax2=U_850(I,J)**2+V_850(I,J)**2 !* 1st-level vortex wind
+! R05=SQRT((VLAT2(I,J)-CLAT_NEW)**2+((VLON2(I,J)-CLON_NEW)*cost)**2)
+ R05=SQRT((VLAT2(I,J)-CLAT_NEW)**2+((VLON2(I,J)-CLON_NEW)*cost)**2)
+ dist(i,j) = R05
+ IF (vmax2.GT.vmax1 .AND. R05.LT.RMX_d) THEN
+ vmax1=vmax2
+ R_MAX_W=R05
+ imax1=I
+ jmax1=j
+ END IF
+ END DO
+ END DO
+
+ vvmax = sqrt(vmax1) !* max 1st level vortex wind
+ PRINT*,'imax1, jmax1 =', imax1, jmax1
+ PRINT*,'vvmax, R_MAX_W =', vvmax, R_MAX_W
+
+ vmax1 = 0.
+ DO J=1,NY
+ DO I=1,NX !* Search max 1st-level symmetric vortex wind
+ vmax2 = U_S(I,J)**2+V_S(I,J)**2 !* 1st-level symmetric wind
+! R05 = SQRT((VLAT2(I,J)-CLAT_NEW)**2+((VLON2(I,J)-CLON_NEW)*cost)**2)
+ R05 = dist(i,j)
+ IF (vmax2.GT.vmax1 .AND. R05.LT.RMX_d) THEN
+ vmax1 = vmax2
+ END IF
+ END DO
+ END DO
+
+ vsmax = sqrt(vmax1) !* max 1st-level symmetric vortex wind
+ v34sym = v34kt*vsmax/vobs ; RMX_e = max(2.*R34obs/deg2km,6.)
+
+ R34deg = 0.
+ vmax1 = v34sym**2
+ DO J=1,NY
+ DO I=1,NX !* Search R34 with 1st-level symmetric vortex wind
+ vmax2 = U_S(I,J)**2+V_S(I,J)**2 !* 1st-level symmetric wind
+! R05 = SQRT((VLAT2(I,J)-CLAT_NEW)**2+((VLON2(I,J)-CLON_NEW)*cost)**2)
+ R05 = dist(i,j)
+ IF (vmax2.GE.vmax1 .AND. R05.GT.R34deg .AND. R05.LT.RMX_e) THEN
+ R34deg = R05
+ END IF
+ END DO
+ END DO
+
+ R34deg = R34deg*vvmax/vsmax
+ R34mod = R34deg*deg2km
+
+ PRINT*,'vsmax, v34sym =', vsmax, v34sym
+ PRINT*,'R34deg, R34mod =', R34deg, R34mod
+
+! PRINT*,'New R34obs, R34mod =', R34obs, R34mod
+
+! IF(VRmax.lt.50.)THEN
+
+! smax1=0.
+! DO J=1,NY
+! DO I=1,NX
+! R05 = dist(i,j)
+! smax2=SQRT((U1(I,J,1)+U_1(I,J,2))**2+(V1(I,J,1)+V_1(I,J,2))**2)*C101(I,J)
+! if (smax2.gt.smax1.and.R05.LT.RMX_d) then
+! smax1=smax2
+! R_MAX_W=R05
+! imax1=I
+! jmax1=j
+! end if
+! END DO
+! END DO
+
+! PRINT*,'imax1, jmax1 =', imax1, jmax1
+! PRINT*,'new R_MAX_W =', R_MAX_W
+
+! END IF
+
+ Rmax_01 = max(RWMAX,R_MAX_W)*111.12*cost
+! Rmax_01 = R_MAX_W*111.12*cost
+
+
+! artificial tests
+
+! Rmax_01 = Rmax_01 * 1.05
+! R34modm = R34modm * 1.05
+
+! finish artificial tests
+
+! IF(VRmax.lt.60..and.DEPTH.ne.'D')then
+ IF ( vobs.lt.v64kt.and.IGFS_FLAG.gt.2 ) THEN
+
+! IF(rmw1_mod.gt.0.5.and.rmw2_obs.0.5)THEN
+! flag_test=max(rmw1_mod,rmw2_obs)/min(rmw1_mod,rmw2_obs)
+ flag_test=rmw2_obs/rmw1_mod
+ if(flag_test.gt.16.3)then
+ print*,'flag_test=',flag_test,R34modm,R34obsm,vobs
+ IFLAG=2
+ PRINT*,'IFLAG2=',IFLAG
+! OPEN(69,file='flag_file2',form='formatted')
+! WRITE(69,*)IFLAG
+! write(69,*)K850
+! write(69,*)TWMAX,RWMAX1,fact,psfc_obs
+! CLOSE(69)
+ print*,'flag_test=',flag_test,R34modm,R34obsm
+! STOP
+! end if
+ END IF
+
+! ELSE
+
+! IF(R34modm.gt.5..and.R34obsm.GT.5.)THEN
+! flag_test=max(R34modm,R34obsm)/min(R34modm,R34obsm)
+! if(flag_test.gt.1.5)print*,'flag_test=',flag_test,R34modm,R34obsm,vobs
+! if(flag_test.gt.2..and.vobs.lt.24.)then
+! IFLAG=2
+! PRINT*,'IFLAG2=',IFLAG
+! OPEN(69,file='flag_file2',form='formatted')
+! WRITE(69,*)IFLAG
+! write(69,*)K850
+! CLOSE(69)
+! print*,'flag_test=',flag_test,R34modm,R34obsm
+! STOP
+! end if
+! END IF
+
+ END IF ! VRmax.lt.50..and.vobs.lt.v64kt
+
+ IF(R34modm.gt.5..and.R34modm.lt.Rmax_01)R34modm=Rmax_01+5.
+
+ R34obs = R34obsm
+ R34mod = R34modm
+
+ IF(R34modm.gt.5..and.R34obsm.GT.5.)THEN
+ RT_MAX=max(Rmax_01,VRmax)+150.
+ DR_VD=R34modm-RT_MAX
+ DR_VB=R34obsm-RT_MAX
+ DR_VT=min(DR_VD,DR_VB)
+
+ IF(DR_VT.LT.0.)THEN
+ IF(DR_VD.GT.DR_VB)THEN
+ R34modm=R34modm+RT_MAX-R34obs
+ R34obsm=RT_MAX
+ ELSE
+ R34obsm=R34obsm+RT_MAX-R34mod
+ R34modm=RT_MAX
+ END IF
+ END IF
+ END IF
+
+ print*,'qingfu test new, Rmax_01,R34modm=',Rmax_01,R34modm
+
+ TSTH=.TRUE.
+
+ RVMAX5=VRmax+5.
+ Rmax_04=Rmax_01+4.
+
+ IF(R34modm.gt.5..and.R34obsm.GT.5.)THEN
+ if(DEPTH.eq.'D')then
+ IF ( vobs > v64kt .AND. vvmax > v64kt ) THEN
+ TSTH=.FALSE.
+ ELSE IF ( vobs .GT. 22. )THEN
+ IF(VRmax.LT.50.)THEN
+! IF((R34modm.GT.VRmax).and.(R34obsm.GT.VRmax))THEN
+ IF((R34modm.GT.Rmax_01).and.(R34obsm.GT.RVMAX5))THEN
+ if(R34modm.lt.VRmax)then
+ R34obs=max(2.,VRmax-R34modm+2.)+R34obsm
+ R34mod=max(2.,VRmax-R34modm+2.)+R34modm
+ else
+ R34obs = R34obsm + 2.
+ R34mod = R34modm + 2.
+ end if
+ TSTH=.FALSE.
+ END IF
+ END IF
+ END IF
+ else
+ IF ( vobs > v64kt .AND. vvmax > v64kt ) THEN
+ TSTH=.FALSE.
+ ELSE IF ( vobs .GT. 22. )THEN
+! IF(VRmax.LT.60..and.VRmax.GE.50.)THEN
+! IF(R34obsm.GT.(VRmax+50.))then
+! IF((R34modm.GT.Rmax_01).and.(R34obsm.GT.RVMAX5))THEN
+! if(R34modm.lt.VRmax)then
+! R34obs=max(2.,VRmax-R34modm+2.)+R34obsm
+! R34mod=max(2.,VRmax-R34modm+2.)+R34modm
+! else
+! R34obs = R34obsm + 2.
+! R34mod = R34modm + 2.
+! end if
+! TSTH=.FALSE.
+! END IF
+! END IF
+! ELSE IF(VRmax.LT.50.)THEN
+ IF(VRmax.LT.50.)THEN
+! IF((R34modm.GT.VRmax).and.(R34obsm.GT.VRmax))THEN
+ IF((R34modm.GT.Rmax_01).and.(R34obsm.GT.RVMAX5))THEN
+! R34obs = 0.5*(R34obsm + R34modm) + 10.
+ if(R34modm.lt.VRmax)then
+ R34obs=max(2.,VRmax-R34modm+2.)+R34obsm
+ R34mod=max(2.,VRmax-R34modm+2.)+R34modm
+ else
+ R34obs = R34obsm + 2.
+ R34mod = R34modm + 2.
+ end if
+ TSTH=.FALSE.
+ END IF
+ END IF
+ END IF
+ end if
+
+ END IF
+
+ print*,'new test VRmax,TSTH=',VRmax,TSTH
+
+! Adjust storm asymmtry ...
+! cap the storm at 50% of the max mean circular flow (close to obs)
+
+! * * * * * * * * * *
+
+ iparam = 2 !* Parameters for storm-size correction ?
+
+ Rmax_0 = max(RWMAX,R_MAX_W)*111.12*cost
+ fact_v = 0.5*(VRmax+Rmax_0)/Rmax_0
+! fact_v = VRmax/Rmax_0
+! IF (DEPTH.eq.'D') fact_v = 0.5*(VRmax+Rmax_0)/Rmax_0
+ PRINT*, 'Observed 10-m wind speed [m/s]: vobs =', vobs
+ PRINT*, 'Model RMW ,Observed RMW [km]: Rmax_0,VRmax =', Rmax_0, VRmax
+ PRINT*, 'Model R34 ,Observed R34 [km]: R34mod,R34obs=', R34modm, R34obsm
+
+ READ(14,*) fact_p, PRMAX, RAD_1 !* from hwrf_pert_ct.f90
+ PRINT*, 'Model ROCI,Observed ROCI [km]: RAD_1,PRMAX =', RAD_1, PRMAX
+
+!* Stretch factor with RMW only
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ fact = fact_v
+
+
+! ftmin=0.9-(VRmax-20.)*0.0025
+! ftmax=1.15
+! if(VRmax.GE.40.)then
+! ftmin=0.85
+! else if(VRmax.LE.20.)then
+! ftmin=0.9
+! end if
+
+! max correction 15%
+! ftmin=0.9-(VRmax-20.)*0.0025
+! ftmax=1.15
+! if(VRmax.GE.40.)then
+! ftmin=0.85
+! else if(VRmax.LE.20.)then
+! ftmin=0.9
+! end if
+! if(Rmax_0.LT.20..and.VRmax.LT.20.)then
+! ftmin=1.0
+! end if
+
+! max correction 15%
+ ftmin=0.95-(Rmax_0-20.)*0.005
+ if(Rmax_0.GE.30.)then
+ ftmin=0.90
+ else if(Rmax_0.LE.20.)then
+ ftmin=0.95
+ end if
+ if(Rmax_0.LT.19..and.VRmax.LT.19.)then
+ ftmin=1.0
+ end if
+ if(ftmin.lt.0.9)ftmin=0.9
+ ftmax=1.15
+! ftmax=1.1
+
+ IF (DEPTH.eq.'S') THEN
+! ftmin=0.95-(Rmax_0-30.)*0.005
+! ftmin=0.9
+ ftmin=0.85
+ ftmax=1.15
+ if(Rmax_0.LE.50.)ftmin=0.9
+ if(Rmax_0.LE.40.)ftmin=0.95
+ ELSE IF (DEPTH.eq.'M') THEN
+ ftmin=0.85
+ ftmax=1.15
+ if(Rmax_0.LE.50.)ftmin=0.9
+ if(Rmax_0.LE.40.)ftmin=0.95
+ END IF
+! ftmax=1.1
+
+ IF( INITOPT > 0)THEN
+
+ fact=1.
+ ftmin=1.0
+ ftmax=1.0
+
+ END IF
+
+! qL test
+! ftmin=0.95
+! ftmax=1.05
+! qL
+
+ IF (fact.LT.ftmin) fact=ftmin
+ IF (fact.GT.ftmax) fact=ftmax
+! IF (fact.LT.0.85) fact=0.85 !* 15% Constraint for constant stretch
+! IF (fact.GT.1.15) fact=1.15 !* to avoid unrealistic outer circulation
+ PRINT*, 'Constant storm-size factors [deg]:fact_v,fact =', fact_v, fact
+
+ IF ( iparam == 2 ) THEN !* ---------------------------------------
+
+!* Stretch factors in degrees
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ rmw1 = max(Rmax_0/deg2km,0.01) !* model RMW [deg]
+ rmw2 = .5*(Rmax_0+VRmax)/deg2km !* target RMW [deg]
+! rmw2 = VRmax/deg2km !* target RMW [deg]
+! IF (DEPTH.eq.'D') rmw2 = .5*(Rmax_0+VRmax)/deg2km !* target RMW [deg]
+! xxx = .85*rmw1 ; yyy = 1.15*rmw1 !* Constraint for
+ xxx = ftmin*rmw1 ; yyy = ftmax*rmw1 !* Constraint for
+ rmw2 = max(xxx,min(rmw2,yyy)) !* RMW correction
+
+ PRINT*, 'Using 2 parameters for storm-size correction.'
+ PRINT*, 'Model RMW , Target RMW [deg]: rmw1, rmw2 =', rmw1, rmw2
+
+! IF ( 1 == 1 ) THEN !* Always use ROCI - - - - - - - -
+! IF ( vobs < v64kt .OR. vvmax < v64kt ) THEN !* - - - -
+ IF ( TSTH ) THEN !* - - - -
+
+ roc1 = max(RAD_1/deg2km,rmw1+.01) !* model ROCI [deg]
+ roc2 = max(PRMAX/deg2km,rmw2+.01) !* target ROCI [deg]
+! xxx = .70*roc1 ; yyy = 1.30*roc1 !* Constraint for
+! xxx = (1.-2.*(1.-ftmin))*roc1 ; yyy = (1.-2.*(1.-ftmax))*roc1 !* Constraint for
+! xxx = .90*roc1 ; yyy = 1.10*roc1 !* Constraint for
+ xxx = .85*roc1 ; yyy = 1.15*roc1 !* Constraint for
+ IF (DEPTH.eq.'S') THEN
+ xxx = .85*roc1 ; yyy = 1.15*roc1
+ ELSE IF (DEPTH.eq.'M') THEN
+ xxx = .85*roc1 ; yyy = 1.15*roc1
+ END IF
+! QL tests
+! xxx = .9*roc1 ; yyy = 1.1*roc1
+
+! roc2 = roc1 * rmw2 / rmw1
+! roc1 = roc2
+ if(VRmax.LT.50.)then
+ roc1 = roc2
+ else
+ roc2 = max(xxx,min(roc2,yyy)) !* ROCI correction
+ end if
+! if(Rmax_0.gt.VRmax.AND.R34modm.lt.R34obsm)then
+! rmw2 = 0.99*rmw1
+! end if
+! if(RAD_1.gt.PRMAX.AND.R34modm.lt.R34obsm)then
+! roc2 = 0.99*roc1
+! end if
+
+ PRINT*, 'NEW Model RMW , Target RMW [deg]: rmw1, rmw2 =', rmw1, rmw2
+ PRINT*, 'Model ROCI, Target ROCI [deg]: roc1, roc2 =', roc1, roc2
+ PRINT*, 'Using ROCI for the second storm-size parameter.'
+
+ ELSE !* Use R34 for hurricane wind - - - - - - - - - -
+
+ roc1 = max(R34mod/deg2km,rmw1+.01) !* model R34 [deg]
+ roc2 = max(R34obs/deg2km,rmw2+.01) !* target R34 [deg]
+! xxx = .70*roc1 ; yyy = 1.30*roc1 !* Constraint for
+! xxx = (1.-2.*(1.-ftmin))*roc1 ; yyy = (1.-2.*(1.-ftmax))*roc1 !* Constraint for
+ xxx = .85*roc1 ; yyy = 1.15*roc1 !* Constraint for
+! QL tests
+! xxx = .9*roc1 ; yyy = 1.1*roc1
+
+ roc2 = max(xxx,min(roc2,yyy)) !* R34 correction
+
+ PRINT*, 'Model R34 , Target R34 [deg]: roc1, roc2 =', roc1, roc2
+ PRINT*, 'Using R34 for the second storm-size parameter.'
+
+ ENDIF !* - - - - - - - - - - - - - - - - - - - - - - -
+
+ IF ( INITOPT > 0 )THEN
+ rmw2=rmw1
+ roc2=roc1
+ END IF
+
+ PRINT*, 'FINIAL Model RMW , Target RMW [deg]: rmw1, rmw2 =', rmw1, rmw2
+ PRINT*, 'FINIAL Model R34 , Target R34 [deg]: roc1, roc2 =', roc1, roc2
+
+ print*,'qqq fn test roc1,roc2,rmw1,rmw2=',roc1,roc2,rmw1,rmw2
+
+ ddd = 1./(roc1*rmw1*(roc1-rmw1))
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+
+ print*,'qqq fn test,not used: aa,bb,dd=',aaa,bbb,ddd
+
+ bbb_t1=0.1
+ bbb_t2=-0.1
+
+ if(bbb.gt.bbb_t1)then
+ IF ( vobs > v64kt .AND. vvmax > v64kt ) THEN
+ bbb=bbb_t1
+! rmw2=max(1.1*rmw2,rmw1)
+! rmw2=1.1*rmw2
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ print*,'qqqq test2, roc1,roc2,rmw1,rmw2=',roc1,roc2,rmw1,rmw2,VRMAX
+ ELSE
+ if(VRmax.lt.50..and.DEPTH.ne.'D')then
+! rmw2=max(1.1*rmw2,rmw1)
+ if(rmw2.lt.rmw1)rmw2=min(1.1*rmw2,rmw1)
+! roc2=max(0.9*roc2,roc1)
+! roc2=0.9*roc2
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+ if(bbb.gt.bbb_t1)then
+ bbb=bbb_t1
+! rmw2=max(1.1*rmw2,rmw1)
+ if(rmw2.lt.rmw1)rmw2=min(1.1*rmw2,rmw1)
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ end if
+ print*,'qqqq test31, roc1,roc2,rmw1,rmw2=',roc1,roc2,rmw1,rmw2,VRMAX
+ else
+ bbb=bbb_t1
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ print*,'qqqq test32, roc1,roc2,rmw1,rmw2=',roc1,roc2,rmw1,rmw2,VRMAX
+ end if
+ END IF
+ end if
+ if(bbb.lt.bbb_t2)then
+ bbb=bbb_t2
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ print*,'qqqq test4, roc1,roc2,rmw1,rmw2=',roc1,roc2,rmw1,rmw2,VRMAX
+ end if
+
+ if(aaa.lt.0.)then
+ print*,'aaa=',aaa
+ stop
+ end if
+
+ aaa = max( 0.85, min(aaa,1.15) )
+
+ IF ( INITOPT == 0 )THEN
+ aaa=aaa1
+ bbb=bbb1
+ END IF
+
+ print*,'new aaa, bbb=',aaa,bbb
+
+! qingfu test
+
+! aaa = 1.0 ; bbb = 0.
+
+! IF ( TSTH ) THEN
+! bbb = max(-0.10,min(bbb,0.10))
+
+! aaa = max( 0.85, min(aaa,1.15) )
+
+! ccc = abs(bbb)
+! IF ( ccc < eps5 ) THEN
+! bbb = 0.
+! ELSEIF ( bbb < 0. ) THEN
+! zzz = 25.0 ! Max radius of transform
+! xxx = eps5 ; yyy = aaa**2/(2.*zzz)
+! bbb = - max(xxx,min(ccc,yyy))
+! ENDIF
+
+! END IF
+
+! aaa = 1.5 ; bbb = 0.10 !* Special test
+ PRINT*, 'Variable storm-size factors [deg]: aaa, bbb =', aaa, bbb
+ PRINT*, 'Variable stretch difference 0-10 deg: b*R/2 =', bbb*5.
+
+ ENDIF !* ---------------------------------------------------------
+
+! * * * * * * * * * *
+
+ distm=1.E20
+ do j=1,ny
+ do i=1,nx !* Search for indices nearest to center of storm
+ distt=(HLON2(i,j)-CLON_NEW)**2+(HLAT2(i,j)-CLAT_NEW)**2
+ if (distm.GT.distt) then
+ distm=distt
+ icst=i
+ jcst=j
+ end if
+ end do
+ end do
+
+ PRINT*,'IWMIN1,IWMAX1,JWMIN1,JWMAX1 before=',IWMIN1,IWMAX1,JWMIN1,JWMAX1
+
+ ID_INDX=MAX(icst-IWMIN1,IWMAX1-icst) ! delete "*fact", OK
+ JD_INDX=MAX(jcst-JWMIN1,JWMAX1-jcst) ! delete "*fact", OK
+ IWMIN1=MAX(icst-ID_INDX,1)-8
+ IWMAX1=MIN(icst+ID_INDX,NX)+8
+ JWMIN1=MAX(jcst-JD_INDX,1)-8
+ JWMAX1=MIN(jcst+JD_INDX,NY)+8
+
+ PRINT*,'IWMIN1,IWMAX1,JWMIN1,JWMAX1 after=',IWMIN1,IWMAX1,JWMIN1,JWMAX1
+
+! * * * * * * * * * *
+
+! scale the coordinate
+
+! IF(ITIM /= 6)THEN
+! READ(30,442)(MLAT(J),MLON(J),J=1,7)
+!442 FORMAT(14x,14i4)
+! CLAT_NEW_6H=MLAT(4)*0.1
+! CLON_NEW_6H=-MLON(4)*0.1
+! if(I360.eq.180)then
+! IF(CLON_NEW_6H.LT.-180.)CLON_NEW_6H=360.+CLON_NEW_6H
+! end if
+! print *,'mtong CLAT_NEW_6H, CLON_NEW_6H=', CLAT_NEW_6H, CLON_NEW_6H
+! print *,'mtong CLAT_NHC, CLON_NHC=', CLAT_NHC, CLON_NHC
+! CLAT_NHC=CLAT_NHC-CLAT_NEW_6H+CLAT_NEW
+! CLON_NHC=CLON_NHC-CLON_NEW_6H+CLON_NEW
+! print *,'mtong new CLAT_NHC, CLON_NHC=', CLAT_NHC, CLON_NHC
+! END IF
+
+ IF ( iparam == 1 ) THEN !* ---------------------------------------
+
+ DO J=1,NY
+ DO I=1,NX
+ HLAT2(I,J)=(HLAT2(I,J)-CLAT_NEW)*fact+CLAT_NHC
+ HLON2(I,J)=(HLON2(I,J)-CLON_NEW)*fact+CLON_NHC
+ VLAT2(I,J)=(VLAT2(I,J)-CLAT_NEW)*fact+CLAT_NHC
+ VLON2(I,J)=(VLON2(I,J)-CLON_NEW)*fact+CLON_NHC
+ END DO
+ END DO
+
+ ELSEIF ( iparam == 2 ) THEN !* for inverse stretch ---------------
+
+ DO J=1,NY
+ DO I=1,NX
+ HLAT2(I,J)=(HLAT2(I,J)-CLAT_NEW)+CLAT_NHC
+ HLON2(I,J)=(HLON2(I,J)-CLON_NEW)+CLON_NHC
+ VLAT2(I,J)=(VLAT2(I,J)-CLAT_NEW)+CLAT_NHC
+ VLON2(I,J)=(VLON2(I,J)-CLON_NEW)+CLON_NHC
+ END DO
+ END DO
+
+ ENDIF !* ---------------------------------------------------------
+
+! * * * * * * * * * *
+
+ distm=1.E20
+ do j=1,ny
+ do i=1,nx
+ distt=((HLON(i,j)-CLON_NHC)*cost)**2+(HLAT(i,j)-CLAT_NHC)**2
+ if (distm.GT.distt) then
+ distm=distt
+ ictr=i
+ jctr=j
+ end if
+ end do
+ end do
+ imn1=ictr-2
+ imx1=ictr+2
+ jmn1=jctr-2
+ jmx1=jctr+2
+
+ delt_z1=0.
+ pt_c=0.
+ sum1=0.
+ do j=jmn1,jmx1
+ do i=imn1,imx1
+! dist=(((HLON(i,j)-CLON_NHC)*cost)**2+ &
+! (HLAT(i,j)-CLAT_NHC)**2)
+ dist1=1.
+ sum1=sum1+dist1
+ pt_c=pt_c+slp1(i,j)*dist1
+ delt_z1=delt_z1+0.5*(Z1(i,j,2)-Z1(i,j,1))
+ end do
+ end do
+
+ delt_z1=delt_z1/float((jmx1-jmn1+1)*(imx1-imn1+1))
+ psfc_env=pt_c/(sum1+1.e-20)
+
+ psfc_obs1=min(-0.01,psfc_obs-psfc_env)
+
+ print*,'delt_z1=',delt_z1
+
+! convert 10m wind to lowest level wind
+
+ if (A101(imax1,jmax1).LT.0.5) then ! A101 = land sea mask, B101 = ZNT
+ z0=B101(imax1,jmax1)
+ z0=max(z0,(0.085*vobs-0.58)*1.E-3)
+ else
+ z0=(0.085*vobs-0.58)*1.E-3
+ end if
+
+! 7.2/1.944=3.7037
+
+! vobs_kt=1.944*vobs
+! if (vobs_kt.gt.60.) then
+! vobs=(3.7037+vobs)/1.12*log(delt_z1/z0)/log(10./z0)
+! else
+! vobs=vobs*log(delt_z1/z0)/log(10./z0)
+! end if
+
+! vobs=vobs_o/(C101(imax1,jmax1)+1.E-10)
+
+! vobs=vobs+0.1 ! stats show
+
+ print*,'level vobs, z0=',vobs,z0,A101(imax1,jmax1)
+
+! First, compute variables at level 1
+
+ if (vobs.ge.5.) then
+ DO J=1,NY
+ DO I=1,NX
+ USC_1(I,J)=U_1(I,J,1)
+ VSC_1(I,J)=V_1(I,J,1)
+ END DO
+ END DO
+ else
+ DO J=1,NY
+ DO I=1,NX
+ USC_1(I,J)=U_850(I,J)
+ VSC_1(I,J)=V_850(I,J)
+ END DO
+ END DO
+ end if
+
+! * * * * * * * * * *
+
+ KNHC=1+(NX-1)/2
+ MNHC=1+(NY-1)/2
+ IC1=KNHC+1
+ JC1=MNHC+1
+ DDX=(GLON(IC1,MNHC)-GLON(KNHC,MNHC))
+ DDY=(GLAT(KNHC,JC1)-GLAT(KNHC,MNHC))
+ MDX=((CLON_NHC-CLON_NEW)/DDX)
+ MDY=((CLAT_NHC-CLAT_NEW)/DDY)
+
+ PRINT*,'DDX,DDY,MDX,MDY=',DDX,DDY,MDX,MDY
+ PRINT*,'IWMIN1,IWMAX1,JWMIN1,JWMAX1=', &
+ IWMIN1,IWMAX1,JWMIN1,JWMAX1
+
+ IF ( iparam == 1 ) THEN !* - - - - - - - - - - - - - - - - - - - -
+
+ DLMD2=DLMD*fact
+ DPHD2=DPHD*fact
+ WBD2=WBD*fact
+ SBD2=SBD*fact
+
+ ELSEIF ( iparam == 2 ) THEN !* for inverse stretch - - - - - - - -
+
+ DLMD2=DLMD
+ DPHD2=DPHD
+ WBD2=WBD
+ SBD2=SBD
+
+ ENDIF !* - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+! WBD2=-(NX-1)*DLMD2
+! SBD2=-((NY-1)/2)*DPHD2
+
+! CENTRAL_LON2=HLON2(1+(NX-1)/2,1+(NY-1)/2)
+! CENTRAL_LAT2=HLAT2(1+(NX-1)/2,1+(NY-1)/2)
+ CENTRAL_LON2=CENTRAL_LON
+ CENTRAL_LAT2=CENTRAL_LAT
+
+ PRINT*,'DLMD2,DPHD2,WBD2,SBD2,CENTRAL_LAT2,CENTRAL_LON2=', &
+ DLMD2,DPHD2,WBD2,SBD2,CENTRAL_LAT2,CENTRAL_LON2
+
+ NXT=IWMAX1-IWMIN1+1
+ NYT=JWMAX1-JWMIN1+1
+ NXT1=min(NXT+1,NX)
+ NYT1=min(NYT+1,NY)
+
+ ALLOCATE ( HLON1(NXT,NYT),HLAT1(NXT,NYT) )
+ ALLOCATE ( VLON1(NXT,NYT),VLAT1(NXT,NYT) )
+ ALLOCATE ( IIH1(NXT,NYT,4), JJH1(NXT,NYT,4) )
+ ALLOCATE ( IIV1(NXT,NYT,4), JJV1(NXT,NYT,4) )
+ ALLOCATE ( HBWGT1(NXT,NYT,4), VBWGT1(NXT,NYT,4) )
+
+ IF ( iparam == 1 ) THEN !* ---------------------------------------
+
+ DO J=1,NYT
+ DO I=1,NXT
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ HLAT1(I,J)=HLAT3(I1,J1)
+ HLON1(I,J)=HLON3(I1,J1)
+ VLAT1(I,J)=VLAT3(I1,J1)
+ VLON1(I,J)=VLON3(I1,J1)
+ END DO
+ END DO
+
+ PRINT*, 'Old storm-size correction with 1 parameter.'
+
+ ELSEIF ( iparam == 2 ) THEN !* inverse stretch -------------------
+
+! if ( abs(bbb) < eps5 ) then !* - - - - - - - - - - - - - - - -
+ if ( abs(bbb) < eps4 ) then !* - - - - - - - - - - - - - - - -
+
+ DO J=1,NYT
+ DO I=1,NXT
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ HLON1(I,J) = (HLON3(I1,J1)-CLON_NEW)/aaa + CLON_NEW
+ HLAT1(I,J) = (HLAT3(I1,J1)-CLAT_NEW)/aaa + CLAT_NEW
+ VLON1(I,J) = (VLON3(I1,J1)-CLON_NEW)/aaa + CLON_NEW
+ VLAT1(I,J) = (VLAT3(I1,J1)-CLAT_NEW)/aaa + CLAT_NEW
+ ENDDO
+ ENDDO
+
+ PRINT*, '2-parameter storm-size correction reduced to 1 parameter.'
+
+ else !* - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ PRINT*, 'Storm-size correction with 2 parameters.'
+
+ DO J=1,NYT
+ DO I=1,NXT
+
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+
+ xxx = HLON3(I1,J1)-CLON_NEW
+ yyy = HLAT3(I1,J1)-CLAT_NEW
+ zzz = sqrt(xxx**2 + yyy**2)
+ IF ( zzz < eps6 ) THEN
+ HLON1(I,J) = CLON_NEW
+ HLAT1(I,J) = CLAT_NEW
+ ELSE
+ ddd = aaa**2 + 2.*bbb*zzz
+ IF ( ddd < 0. ) THEN
+ HLON1(I,J) = xxx/aaa + CLON_NEW
+ HLAT1(I,J) = yyy/aaa + CLAT_NEW
+! PRINT*,'Storm center is too far off analysis domain center !'
+! PRINT*,'Constant inverse stretch for outer storm area.'
+ ELSE !* Variable inverse stretch
+ rrr = ( sqrt(ddd) - aaa )/bbb
+ HLON1(I,J) = rrr*xxx/zzz + CLON_NEW
+ HLAT1(I,J) = rrr*yyy/zzz + CLAT_NEW
+ ENDIF
+ ENDIF
+
+ xxx = VLON3(I1,J1)-CLON_NEW
+ yyy = VLAT3(I1,J1)-CLAT_NEW
+ zzz = sqrt(xxx**2 + yyy**2)
+ IF ( zzz < eps6 ) THEN
+ VLON1(I,J) = CLON_NEW
+ VLAT1(I,J) = CLAT_NEW
+ ELSE
+ ddd = aaa**2 + 2.*bbb*zzz
+ IF ( ddd < 0. ) THEN
+ VLON1(I,J) = xxx/aaa + CLON_NEW
+ VLAT1(I,J) = yyy/aaa + CLAT_NEW
+! PRINT*,'Storm center is too far off analysis domain center !'
+! PRINT*,'Constant inverse stretch for outer storm area.'
+ ELSE !* Variable inverse stretch
+ rrr = ( sqrt(ddd) - aaa )/bbb
+ VLON1(I,J) = rrr*xxx/zzz + CLON_NEW
+ VLAT1(I,J) = rrr*yyy/zzz + CLAT_NEW
+ ENDIF
+ ENDIF
+
+ ENDDO
+ ENDDO
+
+ endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ DO J=1,NYT
+ DO I=1,NXT
+ HLAT1(I,J)=HLAT1(I,J)+CLAT_NEW-CLAT_NHC
+ HLON1(I,J)=HLON1(I,J)+CLON_NEW-CLON_NHC
+ VLAT1(I,J)=VLAT1(I,J)+CLAT_NEW-CLAT_NHC
+ VLON1(I,J)=VLON1(I,J)+CLON_NEW-CLON_NHC
+ END DO
+ END DO
+
+ ENDIF !* ---------------------------------------------------------
+
+! CLAT_NEW1=CLAT_NEW
+! CLON_NEW1=CLON_NEW
+ CLAT_NEW=CLAT_NHC
+ CLON_NEW=CLON_NHC
+
+ print*,'domain 3=',HLON3(1,1),HLON3(NX,NY),HLAT3(1,1),HLAT3(NX,NY)
+ print*,'domain 1=',HLON1(1,1),HLON1(NXT,NYT),HLAT1(1,1),HLAT1(NXT,NYT)
+
+!* Calculate interpolating indices and weights from modified vortex
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+!* Input DLMD2,DPHD2,CENTRAL_LAT,CENTRAL_LON in degrees
+!* Input HLAT1,HLON1,VLAT1,VLON1 in degrees
+
+ IIH1=999999
+ JJH1=999999
+ IIV1=999999
+ JJV1=999999
+ HBWGT1=0.
+ VBWGT1=0.
+
+ CURRENT_DOMAIN_ID=2
+
+ CALL G2T2H_AGRID( IIH1,JJH1, & !* interp indices of source H points
+ HBWGT1, & !* interp weights to target H points
+ HLAT1,HLON1, & !* lat/lon of H points on target grid
+ DLMD2,DPHD2,WBD2,SBD2, & !* dlat/dlon, W/S bdry of source grid
+ CENTRAL_LAT2,CENTRAL_LON2, & !* central lat/lon of source grid
+ NX,NY, & !* x/y dimensions of source grid
+ NXT,NYT ) !* dimensions of target grid (nest)
+
+ CALL G2T2H_AGRID ( IIV1,JJV1, & !* interp indices of source V points
+ VBWGT1, & !* interp weights to target V points
+ VLAT1,VLON1, & !* lat/lon of V points on target grid
+ DLMD2,DPHD2,WBD2,SBD2, & !* dlat/dlon, W/S bdry of source grid
+ CENTRAL_LAT2,CENTRAL_LON2, & !* central lat/lon of source grid
+ NX,NY, & !* x/y dimensions of source grid
+ NXT,NYT ) !* dimensions of target grid (nest)
+
+ print*,'finish calculate index and coef'
+
+ DEALLOCATE( HLAT1, HLON1, VLAT1, VLON1 )
+
+! * * * * * * * * * *
+
+! Add hurricane component for surface wind (approximate for pert only)
+
+ U21=0.
+ V21=0.
+ USC1=USC_1
+ VSC1=VSC_1
+
+ NX_1=NX-1
+ NY_1=NY-1
+
+!$omp parallel do &
+!$omp& private(i,j,n1,IV1,JV1)
+ DO J=1,NYT
+ CYC_35: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_35
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_35
+ DO N1=1,4
+ IV1(N1)=IIV1(I,J,N1)
+ JV1(N1)=JJV1(I,J,N1)
+ END DO
+ DO N1=1,4
+ U21(I,J,1,N1)=USC_1(IV1(N1),JV1(N1))
+ V21(I,J,1,N1)=VSC_1(IV1(N1),JV1(N1))
+ END DO
+ ENDDO CYC_35
+ ENDDO
+
+!$omp parallel do &
+!$omp& private(i,j,i1,j1)
+ DO J=1,NYT
+ CYC_36: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_36
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_36
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ USC1(I1,J1) = &
+ + VBWGT1(I,J,1)*U21(I,J,1,1) &
+ + VBWGT1(I,J,2)*U21(I,J,1,2) &
+ + VBWGT1(I,J,3)*U21(I,J,1,3) &
+ + VBWGT1(I,J,4)*U21(I,J,1,4)
+ VSC1(I1,J1) = &
+ + VBWGT1(I,J,1)*V21(I,J,1,1) &
+ + VBWGT1(I,J,2)*V21(I,J,1,2) &
+ + VBWGT1(I,J,3)*V21(I,J,1,3) &
+ + VBWGT1(I,J,4)*V21(I,J,1,4)
+ END DO CYC_36
+ END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ USCM(I,J)=U1(I,J,1)
+ VSCM(I,J)=V1(I,J,1)
+ END DO
+ END DO
+
+ vmax1=0.
+ d_max=3.5
+ IF(vobs.gt.30..and.CLAT_NHC.gt.30.)d_max=4.5
+
+ dist=1.e20
+
+ DO J=1,NYT
+ J1=J+JWMIN1-1+MDY
+ DO I=1,NXT
+ I1=I+IWMIN1-1+MDX
+ vmax2=USC1(I1,J1)**2+VSC1(I1,J1)**2
+ R05=SQRT((VLAT(I1,J1)-CLAT_NEW)**2+((VLON(I1,J1)-CLON_NEW)*cost)**2)
+ dist(I1,J1)=R05
+ if (vmax2.gt.vmax1.and.R05.le.d_max) then
+ vmax1=vmax2
+ imax1=I1
+ jmax1=j1
+ end if
+ END DO
+ END DO
+
+ print*,'I,J,vmax=',imax1,jmax1,sqrt(vmax1)
+
+ RMX_d=1.2*sqrt(((VLON(imax1,jmax1)-CLON_NEW)*cost)**2+ &
+ (VLAT(imax1,jmax1)-CLAT_NEW)**2)
+
+ PRINT*,'RMX_d1=',RMX_d
+
+ RMX_d=2.*RWMAX*fact !* OK
+
+! RMX_d=max(RMX_d,2.0)
+ RMX_d=max(RMX_d,3.0)
+ IF(RMX_d.gt.3.5)RMX_d=3.5
+
+ PRINT*,'RMX_d2=',RMX_d
+
+ smax1=0.
+ PRINT*,'NYT, NXT=', NYT, NXT
+ DO J=1,NYT
+ J1=J+JWMIN1-1+MDY
+ DO I=1,NXT
+ I1=I+IWMIN1-1+MDX
+! R05=SQRT((VLAT(I1,J1)-CLAT_NEW)**2+((VLON(I1,J1)-CLON_NEW)*cost)**2)
+ R05=dist(I1,J1)
+ smax2=SQRT((USC1(I1,J1)+USCM(I1,J1))**2+(VSC1(I1,J1)+VSCM(I1,J1))**2)*C101(I1,J1)
+ if (smax2.gt.smax1.and.R05.LT.RMX_d) then
+ smax1=smax2
+ i_max=I1
+ j_max=J1
+ end if
+ END DO
+ END DO
+
+ vs_t=smax1
+ vmax_s=smax1
+ PRINT*, 'Observed initial wind [m/s] at 10m level: vobs =', vobs
+ PRINT*, 'Adjusted prev.6h wind [m/s] at 10m level: vs_t =', vs_t
+
+ DO J=1,NY
+ DO I=1,NX
+ USC2(I,J)=USC1(I,J)+USCM(I,J)
+ VSC2(I,J)=VSC1(I,J)+VSCM(I,J)
+ END DO
+ END DO
+
+ IFLAG=0
+ PRINT*,'IFLAG0=',IFLAG
+
+ RWMAX1=RWMAX*fact*111.12*cos(CLAT_NEW*pi180)
+ if (vobs.LE.24.) THEN
+! RWMAX1=VRmax
+ TWMAX=TWMAX
+ end if
+
+ IF ( vs_t .LT. vobs .and. INITOPT .EQ. 0 ) THEN !* -------------------------------------------->
+
+ IFLAG=1
+ PRINT*,'IFLAG1=',IFLAG
+ OPEN(69,file='flag_file',form='formatted')
+ WRITE(69,*)IFLAG
+ write(69,*)K850
+ write(69,*)TWMAX,RWMAX1,fact,psfc_obs
+ CLOSE(69)
+
+ PRINT*, 'Recycled vortex will be enhanced by bogus vortex.'
+
+ beta=1.0
+ ics=2
+
+ CALL CORT_MAT_1(IR1,NX,NY,NZ,KMX, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW, &
+ beta,fact,aaa,bbb,iparam,ics,SN)
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*beta+SLP_X(I,J)
+ END DO
+ END DO
+
+ pct_m=0.
+ DO J=1,NY
+ DO I=1,NX
+ IF (pct_m.GT.SLP_1(I,J)) THEN
+ pct_m=SLP_1(I,J)
+ END IF
+ END DO
+ END DO
+! pct_m=pct_m+50.
+
+ ps_rat2=psfc_obs1/(pct_m-100.) ! - 1mb
+
+ IF (ps_rat2.LT.1.0) THEN
+
+ print*,'ps_rat2=',ps_rat2,psfc_obs1,pct_m
+
+!$omp parallel do &
+!$omp& private(i,j,k,TEK1,TEK2,ESRR)
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*ps_rat2
+ DO K=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+ T_1(I,J,K)=(T_1(I,J,K)*beta+T_X(I,J,K))*ps_rat2
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ END DO
+ END DO
+ END DO
+
+ ELSE
+
+!$omp parallel do &
+!$omp& private(i,j,k,TEK1,TEK2,ESRR)
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+ T_1(I,J,K)=T_1(I,J,K)*beta+T_X(I,J,K)
+! Q_1(I,J,K)=Q_1(I,J,K)*beta+Q_X(I,J,K)
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ END DO
+ END DO
+ END DO
+
+ END IF
+
+! Add hurricane component and write the guess field out
+! the bogus program will add some of the storm increments
+
+ SLP21=0.
+ U21=0.
+ V21=0.
+ T21=0.
+ Q21=0.
+
+!$omp parallel do &
+!$omp& private(i,j,k,n1,IH1,JH1)
+ DO J=1,NYT
+ CYC_45: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_45
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_45
+ DO N1=1,4
+ IH1(N1)=IIH1(I,J,N1)
+ JH1(N1)=JJH1(I,J,N1)
+ END DO
+ DO N1=1,4
+ SLP21(I,J,N1)=SLP_1(IH1(N1),JH1(N1))
+ DO K=1,KMX
+ T21(I,J,K,N1)=T_1(IH1(N1),JH1(N1),K)
+ Q21(I,J,K,N1)=Q_1(IH1(N1),JH1(N1),K)
+ END DO
+ END DO
+ ENDDO CYC_45
+ ENDDO
+
+ print*,'NXT,NYT,IWMIN1,JWMIN1,MDX,MDY=',NXT,NYT,IWMIN1,JWMIN1,MDX,MDY
+
+
+ print*,'qliu test1'
+
+!$omp parallel do &
+!$omp& private(i,j,k,i1,j1,k1,n,WRK1,WRK2,TENV1,QENV1,W1,W)
+ DO J=1,NYT
+ CYC_46: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_46
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_46
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ SLP1(I1,J1)=SLP1(I1,J1)+ &
+ HBWGT1(I,J,1)*SLP21(I,J,1) &
+ + HBWGT1(I,J,2)*SLP21(I,J,2) &
+ + HBWGT1(I,J,3)*SLP21(I,J,3) &
+ + HBWGT1(I,J,4)*SLP21(I,J,4)
+ DO K=1,KMX
+ WRK1(K) = &
+ HBWGT1(I,J,1)*T21(I,J,K,1) &
+ + HBWGT1(I,J,2)*T21(I,J,K,2) &
+ + HBWGT1(I,J,3)*T21(I,J,K,3) &
+ + HBWGT1(I,J,4)*T21(I,J,K,4)
+ WRK2(K) = &
+ HBWGT1(I,J,1)*Q21(I,J,K,1) &
+ + HBWGT1(I,J,2)*Q21(I,J,K,2) &
+ + HBWGT1(I,J,3)*Q21(I,J,K,3) &
+ + HBWGT1(I,J,4)*Q21(I,J,K,4)
+ END DO
+ CYC_877: DO N=1,NZ
+ TENV1 = T1(I1,J1,N)
+ QENV1 = Q1(I1,J1,N)
+ IF (PMID1(I1,J1,N).GE.PCST(1)) THEN ! Below PCST(1)
+ T1(I1,J1,N)=TENV1+WRK1(1)
+ Q1(I1,J1,N)=QENV1+WRK2(1)
+ ELSE IF(PMID1(I1,J1,N).LE.PCST(KMX))THEN
+ T1(I1,J1,N)=TENV1+WRK1(KMX)
+ Q1(I1,J1,N)=QENV1+WRK2(KMX)
+ ELSE
+ DO K1=1,KMX-1
+ if(PMID1(I1,J1,N).LE.PCST(K1).and.PMID1(I1,J1,N).GT.PCST(K1+1))then
+ W1=ALOG(1.*PCST(K1+1))-ALOG(1.*PCST(K1))
+ W=(ALOG(1.*PMID1(I1,J1,N))-ALOG(1.*PCST(K1)))/W1
+ T1(I1,J1,N)=TENV1+WRK1(K1)*(1.-W)+WRK1(K1+1)*W
+ Q1(I1,J1,N)=QENV1+WRK2(K1)*(1.-W)+WRK2(K1+1)*W
+ CYCLE CYC_877
+ end if
+ END DO
+ END IF
+ END DO CYC_877
+ ENDDO CYC_46
+ ENDDO
+
+ print*,'qliu test2'
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+
+ DO J=1,NY
+ DO I=1,NX
+ CALL get_eta_level(NZ,PD1(I,J),PFL,PHL,ETA1,ETA2,1.0)
+ DO K=1,NZ
+ PMID1(I,J,K)=PFL(NZ+1-K)
+ END DO
+ DO K=1,NZ+1
+ P1(I,J,K)=PHL(NZ+2-K)
+ END DO
+ ENDDO
+ ENDDO
+
+ DO j = 1,ny
+ DO i = 1,nx
+ Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)* &
+ (Q1(I,J,L-1)*0.608+1.0)*287.04* &
+ (ALOG(P1(I,J,L-1))-ALOG(P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ ENDDO
+
+ PMV1=PMID1
+
+ print*,'qliu test3'
+!$omp parallel do &
+!$omp& private(i,j,k,n1,IV1,JV1)
+ DO J=1,NYT
+ CYC_55: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_55
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_55
+ DO N1=1,4
+ IV1(N1)=IIV1(I,J,N1)
+ JV1(N1)=JJV1(I,J,N1)
+ END DO
+ DO N1=1,4
+ DO K=1,KMX
+ U21(I,J,K,N1)=U_1(IV1(N1),JV1(N1),K)
+ V21(I,J,K,N1)=V_1(IV1(N1),JV1(N1),K)
+ END DO
+ END DO
+ ENDDO CYC_55
+ ENDDO
+
+!$omp parallel do &
+!$omp& private(i,j,i1,j1)
+ DO J=1,NYT
+ CYC_56: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_56
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_56
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ USCM(I1,J1) = USCM(I1,J1) &
+ + VBWGT1(I,J,1)*U21(I,J,1,1) &
+ + VBWGT1(I,J,2)*U21(I,J,1,2) &
+ + VBWGT1(I,J,3)*U21(I,J,1,3) &
+ + VBWGT1(I,J,4)*U21(I,J,1,4)
+ VSCM(I1,J1) = VSCM(I1,J1) &
+ + VBWGT1(I,J,1)*V21(I,J,1,1) &
+ + VBWGT1(I,J,2)*V21(I,J,1,2) &
+ + VBWGT1(I,J,3)*V21(I,J,1,3) &
+ + VBWGT1(I,J,4)*V21(I,J,1,4)
+ END DO CYC_56
+ END DO
+
+ print*,'qliu test4'
+
+!$omp parallel do &
+!$omp& private(i,j,k,i1,j1,k1,N,WRK1,WRK2,W1,W)
+ DO J=1,NYT
+ CYC_57: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_57
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_57
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ DO K=1,KMX
+ WRK1(K) = &
+ VBWGT1(I,J,1)*U21(I,J,K,1) &
+ + VBWGT1(I,J,2)*U21(I,J,K,2) &
+ + VBWGT1(I,J,3)*U21(I,J,K,3) &
+ + VBWGT1(I,J,4)*U21(I,J,K,4)
+ WRK2(K) = &
+ VBWGT1(I,J,1)*V21(I,J,K,1) &
+ + VBWGT1(I,J,2)*V21(I,J,K,2) &
+ + VBWGT1(I,J,3)*V21(I,J,K,3) &
+ + VBWGT1(I,J,4)*V21(I,J,K,4)
+ END DO
+ CYC_881: DO N=1,NZ
+ IF (PMV1(I1,J1,N).GE.PCST(1)) THEN ! Below PCST(1)
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(1)
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(1)
+ ELSE IF(PMV1(I1,J1,N).LE.PCST(KMX)) THEN
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(KMX)
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(KMX)
+ ELSE
+ DO K1=1,KMX-1
+ if(PMV1(I1,J1,N).LE.PCST(K1).and.PMV1(I1,J1,N).GT.PCST(K1+1))then
+ W1=ALOG(1.*PCST(K1+1))-ALOG(1.*PCST(K1))
+ W=(ALOG(1.*PMV1(I1,J1,N))-ALOG(1.*PCST(K1)))/W1
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(K1)*(1.-W)+WRK1(K1+1)*W
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(K1)*(1.-W)+WRK2(K1+1)*W
+ CYCLE CYC_881
+ end if
+ END DO
+ END IF
+ END DO CYC_881
+ ENDDO CYC_57
+ ENDDO
+
+ print*,'qliu test5'
+
+ DO J=1,NY
+ DO I=1,NX
+ U1(I,J,1)=USC2(I,J)
+ V1(I,J,1)=VSC2(I,J)
+ END DO
+ END DO
+
+! WRITE 4x area env. data HWRF
+
+ IUNIT=36
+
+ WRITE(IUNIT) NX,NY,NZ,I360
+
+ WRITE(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ WRITE(IUNIT) PMID1
+ WRITE(IUNIT) T1
+ WRITE(IUNIT) Q1
+ WRITE(IUNIT) U1
+ WRITE(IUNIT) V1
+ WRITE(IUNIT) DZDT
+ WRITE(IUNIT) Z1
+! WRITE(IUNIT) GLON,GLAT
+ WRITE(IUNIT) HLON,HLAT,VLON,VLAT
+ WRITE(IUNIT) P1
+ WRITE(IUNIT) PD1
+ WRITE(IUNIT) ETA1
+ WRITE(IUNIT) ETA2
+ WRITE(IUNIT) USCM ! no longer use
+ WRITE(IUNIT) VSCM
+
+ CLOSE(IUNIT)
+
+ print*,'NX,NY,NZ=',NX,NY,NZ,I360
+
+ print*,'PDTOP,PT=',PDTOP,PT
+
+ WRITE(63)((SLP1(I,J),I=1,NX),J=1,NY,2)
+ DO K=1,NZ+1
+ WRITE(63)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ+1
+ WRITE(63)((P1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(63)((T1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(63)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(63)((U1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(63)((V1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+
+ STOP
+
+ END IF !* <---------------------------------------------------------------
+
+ PRINT*, 'Recycled vortex will NOT be enhanced by bogus vortex.'
+
+ imax1=i_max
+ jmax1=j_max
+
+ print*,'I,J,vmax=',imax1,jmax1,sqrt(vmax1)
+
+ iter=0
+ beta=1.0
+
+ vobs=vobs_o/(C101(i_max,j_max)+1.E-10)
+
+ print*,'vobs_o,vobs,C101=',vobs_o,vobs,C101(i_max,j_max)
+
+ 876 CONTINUE
+
+ VMAX=0.
+! DO J=1,NYT
+! DO I=1,NXT
+! J1=J+JWMIN1-1+MDY
+! I1=I+IWMIN1-1+MDX
+ I1=i_max
+ J1=j_max
+ UUT=beta*USC1(I1,J1)+USCM(I1,J1)
+ VVT=beta*VSC1(I1,J1)+VSCM(I1,J1)
+ FF=UUT*UUT+VVT*VVT
+! R05=SQRT((VLAT(I1,J1)-CLAT_NHC)**2+((VLON(I1,J1)-CLON_NHC)*cost)**2)
+! R05=dist(i,j)
+! IF(VMAX.LT.FF.and.R05.LT.RMX_d)THEN
+ VMAX=FF
+ IMV=I1
+ JMV=J1
+! END IF
+! END DO
+! END DO
+
+ PRINT*,'I1,J1,I,J,VMAX=',i_max,j_max,IMV,JMV,SQRT(VMAX)
+
+ IMV=I1
+ JMV=J1
+
+ UU11=beta*USC1(IMV,JMV)
+ VV11=beta*VSC1(IMV,JMV)
+ UUM1=USCM(IMV,JMV)
+ VVM1=VSCM(IMV,JMV)
+ QQ=sqrt(amax1(( (uu11**2+vv11**2)*vobs**2-(vv11*uum1-uu11*vvm1)**2), &
+ 1.0e-20))
+
+ beta1=(-(uum1*uu11+vvm1*vv11)+QQ)/(uu11**2+vv11**2+1.E-20)
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+ if(beta1.gt.1.0.or.beta1.lt.0.)beta1=1.0
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+ beta=beta*beta1
+ iter=iter+1
+
+ print*,'iter,beta=',iter,beta
+
+! IF(iter.lt.2)go to 876
+
+! if(beta.gt.1.25) beta=1.25
+! if(beta.lt.0.75) beta=0.75
+
+! beta=1.0 ! test
+
+! IF(beta.lt.0.75.and.vobs.lt.24.)THEN
+! IF(beta.lt.0.5.and.vobs.lt.24.)THEN
+ IF(beta.lt.0.7.and.vobs.lt.v64kt)THEN
+ IFLAG=2
+ PRINT*,'IFLAG2=',IFLAG
+! OPEN(69,file='flag_file2',form='formatted')
+! WRITE(69,*)IFLAG
+! write(69,*)K850
+! write(69,*)TWMAX,RWMAX1,fact,psfc_obs
+! CLOSE(69)
+! STOP
+ END IF
+
+ uv21=sqrt(uu11**2+vv11**2)
+
+ uv22=beta*TWMAX
+
+ print*,'max hurricane pert, beta*TWMAX=',uv21,uv22
+ print*,'TWMAX=',TWMAX
+
+! IFLAG=0
+
+! IF (uv22.LT.(0.5*vobs)) IFLAG=1
+! IF (TWMAX.LT.10.)THEN
+! IF(beta.gt.1.2.or.beta.lt.0.8) IFLAG=1
+! ELSE
+! cut1=min(2.5,1.2+(TWMAX-10.)/15.)
+! cut2=max(0.5,0.8-(TWMAX-10.)/50.)
+! IF(beta.gt.cut1.or.beta.lt.cut2) IFLAG=1
+! END IF
+
+! beta=1.
+
+ beta=max(beta,10./vmax_s) ! beta*vmax_s > 10 m/s
+ if(beta.gt.1.)beta=1.0
+
+ print*,'new beta,vmax_s=',beta,vmax_s
+
+ pct_m=0.
+ DO J=1,NY
+ DO I=1,NX
+ IF (pct_m.GT.SLP_1(I,J)) THEN
+ pct_m=SLP_1(I,J)
+ END IF
+ END DO
+ END DO
+
+ if((pct_m+200.) .gt. psfc_obs1)beta=1.0
+
+ IF ( INITOPT > 0 )THEN
+ beta=1.0
+ END IF
+
+ print*,'finial beta=', beta
+
+! now modify the horricane component (by beta)
+
+ T_4=T_1
+ Q_4=Q_1
+
+ DO J=1,NY,10
+ write(*,33)(HLAT2(I,J),I=1,NX,10)
+ END DO
+ DO J=1,NY,10
+ write(*,33)(VLAT2(I,J),I=1,NX,10)
+ END DO
+ 33 format(15F8.1)
+
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW,CLAT_NEW
+
+! PW=1.0 ! no vertical weighting for storm pert
+
+ ddr = RWM(2)-RWM(1)
+
+ TH1=0.
+ do i=1,100
+ TH1(i)=TWM(i)
+ end do
+
+ do i=1,200
+ RP(i)=i*ddr*DST1
+ end do
+
+! correct wind
+
+ DO K=1,KMX
+ DO J=1,NY
+ DO I=1,NX
+ U_1(I,J,K)=U_1(I,J,K)*beta
+ V_1(I,J,K)=V_1(I,J,K)*beta
+ END DO
+ END DO
+ END DO
+!
+ DO J=1,NY
+ DO I=1,NX
+ USC2(I,J)=beta*USC1(I,J)+USCM(I,J)
+ VSC2(I,J)=beta*VSC1(I,J)+VSCM(I,J)
+ END DO
+ END DO
+!
+! correct temp, water vapor and sea-level press
+
+ ics=2
+! fact=1.0
+
+ CALL CORT_MAT_1(IR1,NX,NY,NZ,KMX, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW, &
+ beta,fact,aaa,bbb,iparam,ics,SN)
+
+ IF(INITOPT > 0)THEN
+ T_X=0.0
+ Q_X=0.0
+ SLP_X=0.0
+ END IF
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*beta+SLP_X(I,J)
+ END DO
+ END DO
+
+! correct surface press
+
+! sum1=0.
+! pct_m=0.
+! do j=jmn1,jmx1
+! do i=imn1,imx1
+! sum1=sum1+1.
+! pct_m=pct_m+SLP_1(I,J)
+! end do
+! end do
+! pct_m=pct_m/sum1
+
+ pct_m=0.
+ DO J=1,NY
+ DO I=1,NX
+ IF (pct_m.GT.SLP_1(I,J)) THEN
+ pct_m=SLP_1(I,J)
+ END IF
+ END DO
+ END DO
+ pct_m=pct_m+50.
+
+! ps_rat=0.5*(pct_m+psfc_obs1)/pct_m
+! ps_rat=min(pct_m,psfc_obs1)/pct_m
+ ps_rat=psfc_obs1/(pct_m-1.E-20)
+
+ print*,'ps_rat=',ps_rat,psfc_obs1,pct_m
+
+ if(ps_rat.gt.10.)ps_rat=10.0
+ if(ps_rat.lt.(-10.))ps_rat=-10.0
+
+ if(INITOPT > 0)ps_rat=1.0
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*ps_rat
+ END DO
+ END DO
+
+!$omp parallel do &
+!$omp& private(i,j,k,TEK1,TEK2,ESRR)
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+ T_1(I,J,K)=(T_1(I,J,K)*beta+T_X(I,J,K))*ps_rat
+! Q_1(I,J,K)=Q_1(I,J,K)*beta+Q_X(I,J,K)
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ END DO
+ END DO
+ END DO
+
+! T_1=T_4
+! Q_1=Q_4
+
+! if(zmax.gt.250.)then
+! T_4=0.
+! Q_4=0.
+! end if
+
+ PRINT*,'complete CORT' ! ---------------------
+
+ SLP21=0.
+ U21=0. ! working array for T_4
+ V21=0. ! working array for Q_4
+ T21=0.
+ Q21=0.
+
+! DO J=1,NYT
+! DO I=1,NXT
+! J1=J+JWMIN1-1+MDY
+! I1=I+IWMIN1-1+MDX
+! PRINT*,'IIH1,JJH1,IIV1,JJV1=',I,J,IIH1(I,J),JJH1(I,J),IIV1(I,J),JJV1(I,J)
+! END DO
+! END DO
+
+!$omp parallel do &
+!$omp& private(i,j,k,i1,j1,k1,n1,IH1,JH1,PDIF1,FACT1)
+ DO J=1,NYT
+ CYC_66: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_66
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_66
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ DO N1=1,4
+ IH1(N1)=IIH1(I,J,N1)
+ JH1(N1)=JJH1(I,J,N1)
+ END DO
+ DO N1=1,4
+ SLP21(I,J,N1)=SLP_1(IH1(N1),JH1(N1))
+ END DO
+ K=1 ! surface
+ CYC_58: DO N1=1,4
+ IF (P1(I1,J1,K).GE.PCST(1)) THEN
+ U21(I,J,K,N1)=T_4(IH1(N1),JH1(N1),1) ! old temp
+ V21(I,J,K,N1)=Q_4(IH1(N1),JH1(N1),1) ! old q
+ T21(I,J,K,N1)=T_1(IH1(N1),JH1(N1),1)
+! Q21(I,J,K,N1)=Q_1(IH1(N1),JH1(N1),1)
+ ELSE IF(P1(I1,J1,K).LE.PCST(KMX))THEN
+ U21(I,J,K,N1)=T_4(IH1(N1),JH1(N1),KMX)
+ V21(I,J,K,N1)=Q_4(IH1(N1),JH1(N1),KMX)
+ T21(I,J,K,N1)=T_1(IH1(N1),JH1(N1),KMX)
+! Q21(I,J,K,N1)=Q_1(IH1(N1),JH1(N1),KMX)
+ ELSE
+ DO K1=2,KMX
+ PDIF1=P1(I1,J1,K)-PCST(K1)
+ !CWH if (ZDIF1.GE.0.) then
+ if (PDIF1.GE.0.) then
+ FACT1=PDIF1/(PCST(K1-1)-PCST(K1))
+ U21(I,J,K,N1)=T_4(IH1(N1),JH1(N1),K1)*(1.-FACT1) &
+ +T_4(IH1(N1),JH1(N1),K1-1)*FACT1
+ V21(I,J,K,N1)=Q_4(IH1(N1),JH1(N1),K1)*(1.-FACT1) &
+ +Q_4(IH1(N1),JH1(N1),K1-1)*FACT1
+ T21(I,J,K,N1)=T_1(IH1(N1),JH1(N1),K1)*(1.-FACT1) &
+ +T_1(IH1(N1),JH1(N1),K1-1)*FACT1
+! Q21(I,J,K,N1)=Q_1(IH1(N1),JH1(N1),K1)*(1.-FACT1) &
+! +Q_1(IH1(N1),JH1(N1),K1-1)*FACT1
+ CYCLE CYC_58
+ end if
+ END DO
+ END IF
+ END DO CYC_58
+ ENDDO CYC_66
+ ENDDO
+
+!$omp parallel do &
+!$omp& private(i,j,i1,j1,TENV1,T_OLD,Q_OLD,ESRR)
+ DO J=1,NYT
+ CYC_67: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_67
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_67
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ SLP1(I1,J1) = SLP1(I1,J1) &
+ + HBWGT1(I,J,1)*SLP21(I,J,1) &
+ + HBWGT1(I,J,2)*SLP21(I,J,2) &
+ + HBWGT1(I,J,3)*SLP21(I,J,3) &
+ + HBWGT1(I,J,4)*SLP21(I,J,4)
+ TENV1 = TS1(I1,J1)
+ TS1(I1,J1) = TENV1 &
+ + HBWGT1(I,J,1)*T21(I,J,1,1) &
+ + HBWGT1(I,J,2)*T21(I,J,1,2) &
+ + HBWGT1(I,J,3)*T21(I,J,1,3) &
+ + HBWGT1(I,J,4)*T21(I,J,1,4)
+ T_OLD = TENV1 &
+ + HBWGT1(I,J,1)*U21(I,J,1,1) &
+ + HBWGT1(I,J,2)*U21(I,J,1,2) &
+ + HBWGT1(I,J,3)*U21(I,J,1,3) &
+ + HBWGT1(I,J,4)*U21(I,J,1,4)
+ Q_OLD = QS1(I1,J1) &
+ + HBWGT1(I,J,1)*V21(I,J,1,1) &
+ + HBWGT1(I,J,2)*V21(I,J,1,2) &
+ + HBWGT1(I,J,3)*V21(I,J,1,3) &
+ + HBWGT1(I,J,4)*V21(I,J,1,4)
+ ESRR = exp(4302.645*(TS1(I1,J1)-T_OLD)/ &
+ ((TS1(I1,J1)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ QS1(I1,J1) = Q_OLD + (ESRR-1.)*Q_OLD ! Assume RH=CONST before & after
+ ENDDO CYC_67
+ ENDDO
+
+! WRITE(25)((SLP1(I,J),I=1,NX),J=1,NY,2)
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ CALL get_eta_level(NZ,PD1(I,J),PFL,PHL,ETA1,ETA2,1.0)
+ DO K=1,NZ
+ PMID1(I,J,K)=PFL(NZ+1-K)
+ END DO
+ DO K=1,NZ+1
+ P1(I,J,K)=PHL(NZ+2-K)
+ END DO
+ ENDDO
+ ENDDO
+
+ do j = 1,ny
+ do i = 1,nx
+ Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)* &
+ (Q1(I,J,L-1)*0.608+1.0)*287.04* &
+ (ALOG(P1(I,J,L-1))-ALOG(P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ END DO
+
+! interpolate vertically to P level in new coordinate (V Points)
+
+ PMV1=PMID1
+
+! WRITE(63)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(63)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(63)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(63)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(63)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(63)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(63)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+ PRINT*,'test0'
+
+! add hurricane components
+
+ SLP21=0.
+ U21=0.
+ V21=0.
+ T21=0.
+ Q21=0.
+
+!$omp parallel do &
+!$omp& private(i,j,k,n1,IH1,JH1)
+ DO J=1,NYT
+ CYC_76: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_76
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_76
+ DO N1=1,4
+ IH1(N1)=IIH1(I,J,N1)
+ JH1(N1)=JJH1(I,J,N1)
+ END DO
+ DO N1=1,4
+ SLP21(I,J,N1)=SLP_1(IH1(N1),JH1(N1))
+ DO K=1,KMX
+ T21(I,J,K,N1)=T_1(IH1(N1),JH1(N1),K)
+ Q21(I,J,K,N1)=Q_4(IH1(N1),JH1(N1),K)
+ U21(I,J,K,N1)=T_4(IH1(N1),JH1(N1),K)
+! Q21(I,J,K,N1)=Q_1(IH1(N1),JH1(N1),K)
+ END DO
+ END DO
+ ENDDO CYC_76
+ ENDDO
+
+!$omp parallel do &
+!$omp& private(i,j,k,i1,j1,k1,n,WRK1,WRK2,WRK3,TENV1,QENV1,Q_OLD,T_OLD,W1,W,ESRR)
+ DO J=1,NYT
+ CYC_77: DO I=1,NXT
+ IF(IIH1(I,J,1).LT.1.or.IIH1(I,J,1).GT.NX_1)CYCLE CYC_77
+ IF(JJH1(I,J,1).LT.1.or.JJH1(I,J,1).GT.NY_1)CYCLE CYC_77
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ SLP1(I1,J1)=SLP1(I1,J1) ! already add the storm pert before
+! SLP1(I1,J1)=SLP1(I1,J1)+ &
+! HBWGT1(I,J,1)*SLP21(I,J,1) &
+! + HBWGT1(I,J,2)*SLP21(I,J,2) &
+! + HBWGT1(I,J,3)*SLP21(I,J,3) &
+! + HBWGT1(I,J,4)*SLP21(I,J,4)
+ DO K=1,KMX
+ WRK1(K) = &
+ HBWGT1(I,J,1)*T21(I,J,K,1) &
+ + HBWGT1(I,J,2)*T21(I,J,K,2) &
+ + HBWGT1(I,J,3)*T21(I,J,K,3) &
+ + HBWGT1(I,J,4)*T21(I,J,K,4)
+ WRK2(K) = &
+ HBWGT1(I,J,1)*Q21(I,J,K,1) &
+ + HBWGT1(I,J,2)*Q21(I,J,K,2) &
+ + HBWGT1(I,J,3)*Q21(I,J,K,3) &
+ + HBWGT1(I,J,4)*Q21(I,J,K,4)
+ WRK3(K) = &
+ HBWGT1(I,J,1)*U21(I,J,K,1) &
+ + HBWGT1(I,J,2)*U21(I,J,K,2) &
+ + HBWGT1(I,J,3)*U21(I,J,K,3) &
+ + HBWGT1(I,J,4)*U21(I,J,K,4)
+ END DO
+ CYC_887: DO N=1,NZ
+ TENV1 = T1(I1,J1,N)
+ QENV1 = Q1(I1,J1,N)
+ IF (PMID1(I1,J1,N).GE.PCST(1)) THEN ! Below PCST(1)
+ T1(I1,J1,N)=TENV1+WRK1(1)
+ Q_OLD=QENV1+WRK2(1)
+ T_OLD=TENV1+WRK3(1)
+! Q1(I1,J1,N)=QENV1+WRK2(1)
+ ESRR = exp(4302.645*(T1(I1,J1,N)-T_OLD)/ &
+ ((T1(I1,J1,N)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ Q1(I1,J1,N) = Q_OLD+(ESRR-1.)*Q_OLD ! Assume RH=CONST before & after
+ ELSE IF(PMID1(I1,J1,N).LE.PCST(KMX)) THEN
+ T1(I1,J1,N)=TENV1+WRK1(KMX)
+! Q1(I1,J1,N)=QENV1+WRK2(KMX)
+ Q_OLD=QENV1+WRK2(KMX)
+ T_OLD=TENV1+WRK3(KMX)
+ ESRR = exp(4302.645*(T1(I1,J1,N)-T_OLD)/ &
+ ((T1(I1,J1,N)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ Q1(I1,J1,N) = Q_OLD+(ESRR-1.)*Q_OLD ! Assume RH=CONST before & after
+ ELSE
+ DO K1=1,KMX-1
+ if(PMID1(I1,J1,N).LE.PCST(K1).and.PMID1(I1,J1,N).GT.PCST(K1+1))then
+ W1=ALOG(1.*PCST(K1+1))-ALOG(1.*PCST(K1))
+ W=(ALOG(1.*PMID1(I1,J1,N))-ALOG(1.*PCST(K1)))/W1
+ T1(I1,J1,N)=TENV1+WRK1(K1)*(1.-W)+WRK1(K1+1)*W
+! Q1(I1,J1,N)=QENV1+WRK2(K1)*(1.-W)+WRK2(K1+1)*W
+ Q_OLD=QENV1+WRK2(K1)*(1.-W)+WRK2(K1+1)*W
+ T_OLD=TENV1+WRK3(K1)*(1.-W)+WRK3(K1+1)*W
+ ESRR = exp(4302.645*(T1(I1,J1,N)-T_OLD)/ &
+ ((T1(I1,J1,N)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ Q1(I1,J1,N) = Q_OLD+(ESRR-1.)*Q_OLD ! Assume RH=CONST before & after
+ CYCLE CYC_887
+ end if
+ END DO
+ END IF
+ END DO CYC_887
+ ENDDO CYC_77
+ ENDDO
+
+ PRINT*,'test01'
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+ PRINT*,'test02'
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ CALL get_eta_level(NZ,PD1(I,J),PFL,PHL,ETA1,ETA2,1.0)
+ DO K=1,NZ
+ PMID1(I,J,K)=PFL(NZ+1-K)
+ END DO
+ DO K=1,NZ+1
+ P1(I,J,K)=PHL(NZ+2-K)
+ END DO
+ ENDDO
+ ENDDO
+
+ DO j = 1,ny
+ DO i = 1,nx
+ Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)* &
+ (Q1(I,J,L-1)*0.608+1.0)*287.04* &
+ (ALOG(P1(I,J,L-1))-ALOG(P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ ENDDO
+
+ U21=0.
+ V21=0.
+
+!$omp parallel do &
+!$omp& private(i,j,k,n1,IV1,JV1)
+ DO J=1,NYT
+ CYC_86: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_86
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_86
+ DO N1=1,4
+ IV1(N1)=IIV1(I,J,N1)
+ JV1(N1)=JJV1(I,J,N1)
+ END DO
+ DO N1=1,4
+ DO K=1,KMX
+ U21(I,J,K,N1)=U_1(IV1(N1),JV1(N1),K)
+ V21(I,J,K,N1)=V_1(IV1(N1),JV1(N1),K)
+ END DO
+ END DO
+ ENDDO CYC_86
+ ENDDO
+
+ PRINT*,'test03'
+
+!$omp parallel do &
+!$omp& private(i,j,k,i1,j1,k1,n,WRK1,WRK2,W1,W)
+ DO J=1,NYT
+ CYC_87: DO I=1,NXT
+ IF(IIV1(I,J,1).LT.1.or.IIV1(I,J,1).GT.NX_1)CYCLE CYC_87
+ IF(JJV1(I,J,1).LT.1.or.JJV1(I,J,1).GT.NY_1)CYCLE CYC_87
+ J1=J+JWMIN1-1+MDY
+ I1=I+IWMIN1-1+MDX
+ DO K=1,KMX
+ WRK1(K) = &
+ VBWGT1(I,J,1)*U21(I,J,K,1) &
+ + VBWGT1(I,J,2)*U21(I,J,K,2) &
+ + VBWGT1(I,J,3)*U21(I,J,K,3) &
+ + VBWGT1(I,J,4)*U21(I,J,K,4)
+ WRK2(K) = &
+ VBWGT1(I,J,1)*V21(I,J,K,1) &
+ + VBWGT1(I,J,2)*V21(I,J,K,2) &
+ + VBWGT1(I,J,3)*V21(I,J,K,3) &
+ + VBWGT1(I,J,4)*V21(I,J,K,4)
+ END DO
+
+ CYC_888: DO N=1,NZ
+ IF (PMV1(I1,J1,N).GE.PCST(1)) THEN ! Below PCST(1)
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(1)
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(1)
+ ELSE IF (PMV1(I1,J1,N).LE.PCST(KMX)) THEN
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(KMX)
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(KMX)
+ ELSE
+ DO K1=1,KMX-1
+ if(PMV1(I1,J1,N).LE.PCST(K1).and.PMV1(I1,J1,N).GT.PCST(K1+1))then
+ W1=ALOG(1.*PCST(K1+1))-ALOG(1.*PCST(K1))
+ W=(ALOG(1.*PMV1(I1,J1,N))-ALOG(1.*PCST(K1)))/W1
+ U1(I1,J1,N)=U1(I1,J1,N)+WRK1(K1)*(1.-W)+WRK1(K1+1)*W
+ V1(I1,J1,N)=V1(I1,J1,N)+WRK2(K1)*(1.-W)+WRK2(K1+1)*W
+ CYCLE CYC_888
+ end if
+ END DO
+ END IF
+ END DO CYC_888
+ ENDDO CYC_87
+ ENDDO
+
+ DEALLOCATE ( IIH1, JJH1, IIV1, JJV1, HBWGT1, VBWGT1 )
+
+ DO J=1,NY
+ DO I=1,NX
+ U1(I,J,1)=USC2(I,J)
+ V1(I,J,1)=VSC2(I,J)
+ END DO
+ END DO
+
+! WRITE(64)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(64)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(64)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! WRITE(64)((USCM(I,J),I=1,NX),J=1,NY,2)
+! WRITE(64)((VSCM(I,J),I=1,NX),J=1,NY,2)
+
+ IUNIT=56
+
+ WRITE(IUNIT) NX,NY,NZ,I360
+ WRITE(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ WRITE(IUNIT) PMID1
+ WRITE(IUNIT) T1
+ WRITE(IUNIT) Q1
+ WRITE(IUNIT) U1
+ WRITE(IUNIT) V1
+ WRITE(IUNIT) DZDT
+ WRITE(IUNIT) Z1
+! WRITE(IUNIT) GLON,GLAT
+ WRITE(IUNIT) HLON,HLAT,VLON,VLAT
+ WRITE(IUNIT) P1
+ WRITE(IUNIT) PD1
+ WRITE(IUNIT) ETA1
+ WRITE(IUNIT) ETA2
+
+ CLOSE(IUNIT)
+
+ NX2=NX*2-1
+
+ END
+
+!==============================================================================
+
+ SUBROUTINE FIND_NEWCT1(IX,JX,UD,VD,GLON2,GLAT2, &
+ CLON_NEW1,CLAT_NEW1)
+
+! PARAMETER (IR=100,IT=24,IX=254,JX=254)
+ PARAMETER (IR=60,IT=24)
+ PARAMETER (ID=31,JD=31,DTX=0.1,DTY=0.1) ! Search x-Domain (ID-1)*DTX
+ REAL (4) UD(IX,JX),VD(IX,JX),GLON2(IX,JX),GLAT2(IX,JX)
+! DIMENSION RWM(IR+1),TWM(IR+1)
+ DIMENSION TNMX(ID,JD),RX(ID,JD),WTM(IR)
+ REAL (8) CLON_NEW1,CLAT_NEW1
+
+ PI=ASIN(1.)*2.
+ RAD=PI/180.
+
+ ddr=0.1
+
+ pi180=RAD
+ cost=cos(clat_new*pi180)
+
+ ix2=ix/2
+ jx2=jx/2
+ DDS=(((GLON2(ix2+1,jx2)-GLON2(ix2,jx2))*cost)**2+ &
+ (GLAT2(ix2,jx2+1)-GLAT2(ix2,jx2))**2)*1.5
+
+
+ print*,'ix,jx,ix2,jx2=',ix,jx,ix2,jx2
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW1,CLAT_NEW1
+ print*,'GLON2,GLAT2=',GLON2(1,1),GLAT2(1,1)
+
+
+ XLAT = CLAT_NEW1-(JD-1)*DTY/2.
+ XLON = CLON_NEW1-(ID-1)*DTX/2.
+
+! print *,'STARTING LAT, LON AT FIND NEW CENTER ',XLAT,XLON
+
+ DO J=1,JD
+ DO I=1,ID
+ TNMX(I,J) = 0.
+ RX(i,j)=0.
+ BLON = XLON + (I-1)*DTX
+ BLAT = XLAT + (J-1)*DTY
+
+!.. CALCULATE TANGENTIAL WIND EVERY 0.2 deg INTERVAL
+!.. 10*10 deg AROUND 1ST GUESS VORTEX CENTER
+
+ DO 10 JL=1,IR
+ WTS= 0.
+ DO 20 IL=1,IT
+ DR = JL*ddr
+! DR = JL
+ DD = (IL-1)*15*RAD
+ DLON = DR*COS(DD)
+ DLAT = DR*SIN(DD)
+ TLON = BLON + DLON
+ TLAT = BLAT + DLAT
+
+!.. INTERPOLATION U, V AT TLON,TLAT AND CLACULATE TANGENTIAL WIND
+
+ u1=0.
+ v1=0.
+ sum1=0.
+ DO j1=1,JX
+ DO i1=1,IX
+ dist=(((GLON2(i1,j1)-TLON)*cost)**2+(GLAT2(i1,j1)-TLAT)**2)
+ IF (dist.LT.DDS) THEN
+ dist1=1./dist
+ sum1=sum1+dist1
+ u1=u1+UD(i1,j1)*dist1
+ v1=v1+VD(i1,j1)*dist1
+ END IF
+ END DO
+ END DO
+
+ UT=u1/sum1
+ VT=v1/sum1
+
+!.. TANGENTIAL WIND
+ WT = -SIN(DD)*UT + COS(DD)*VT
+ WTS = WTS+WT
+20 CONTINUE
+ WTM(JL) = WTS/24.
+10 CONTINUE
+
+! Southern Hemisphere
+ IF (CLAT_NEW.LT.0) THEN
+ DO JL=1,IR
+ WTM(JL)=-WTM(JL)
+ END DO
+ END IF
+! EnD SH
+
+! print*,'test1'
+
+ TX = -10000000.
+ DO KL = 1,IR
+ IF(WTM(KL).GE.TX) THEN
+ TX = WTM(KL)
+ RRX = KL*ddr
+ ENDIF
+ ENDDO
+! DO KL=1,IR
+! TWM(KL)=WTM(KL)
+! RWM(KL)=KL*ddr
+! END DO
+! TWM(IR+1)=TX
+! RWM(IR+1)=RRX
+
+ TNMX(I,J) = TX
+ RX(I,J)=RRX
+ ENDDO
+ ENDDO
+!C.. FIND NEW CENTER
+ TTX = -1000000.
+ DO I=1,ID
+ DO J=1,JD
+ IF(TNMX(I,J).GE.TTX) THEN
+ TTX = TNMX(I,J)
+ NIC = I
+ NJC = J
+ ENDIF
+ ENDDO
+ ENDDO
+
+! QLIU test
+! print*,XLAT+30*DTY,XLON+30*DTX,TNMX(30,30)
+ print*,'max WTM=',TNMX(30,30),RX(30,30)
+
+ CLAT_NEW1 = XLAT + (NJC-1)*DTY
+ CLON_NEW1 = XLON + (NIC-1)*DTX
+
+! print *,'NEW CENTER, I, J IS ',NIC,NJC
+ print *,'NEW CENTER, LAT,LON IS ',CLAT_NEW1,CLON_NEW1
+! print *,'MAX TAN. WIND AT NEW CENTER IS ',TTX
+
+ RETURN
+ END
+
+!==============================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/correct_mat.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/correct_mat.f90
new file mode 100644
index 000000000..b50d9c8bb
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/correct_mat.f90
@@ -0,0 +1,396 @@
+
+ SUBROUTINE CORT_MAT_1(IR1,NX,NY,NZ,KMX, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW, &
+ beta,fact,aaa,bbb,iparam,ics,SN)
+
+! input: IR1,NX,NY,KMX
+! input: U_2S,T_2S,Q_2S,SLP_2S variables from guess storm
+! input: HLON,HLAT,VLON,VLAT,TEK,HP
+! input: RADIUS,CLON_NEW,CLAT_NEW,ics
+! input: U_2S1,RADIUS1 - Variables after wind and size correction
+! output: T_X,Q_X,SLP_X - new axisymmetric part
+! output: CFT - correlation coef
+
+ real(4) HLON(NX,NY),HLAT(NX,NY)
+ real(4) VLON(NX,NY),VLAT(NX,NY)
+
+!zhang REAL(4) CLON_NEW,CLAT_NEW
+ REAL(8) CLON_NEW,CLAT_NEW
+
+ real(4) T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY)
+
+ REAL(4), ALLOCATABLE :: RADIUS(:),RADIUS1(:)
+ REAL(4), ALLOCATABLE :: U_2S(:,:),V_2S(:,:),U_2S1(:,:)
+ REAL(4), ALLOCATABLE :: T_2S(:,:),Q_2S(:,:),SLP_2S(:)
+ REAL(4), ALLOCATABLE :: TEK(:),HP(:,:,:)
+
+ REAL(4), ALLOCATABLE :: RKX1(:),WKX1(:,:)
+ REAL(4), ALLOCATABLE :: RKX2(:),WKX2(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:,:),strm2(:,:),strm3(:,:)
+
+ REAL(4), ALLOCATABLE :: rpb(:),rpb1(:),rpb2(:)
+ REAL(4), ALLOCATABLE :: rtmp(:,:),rtmp1(:,:),rtmp2(:,:),rtmp3(:,:)
+ REAL(4), ALLOCATABLE :: rmix(:,:)
+ REAL(4), ALLOCATABLE :: ctmp(:,:),cmix(:,:)
+
+ REAL(4), ALLOCATABLE :: test1(:,:),work1(:,:)
+
+ REAL(4), ALLOCATABLE :: RIJ2(:,:)
+!zhang REAL(4), ALLOCATABLE :: IDX1(:,:),W1(:,:),W2(:,:)
+ REAL(4), ALLOCATABLE :: W1(:,:),W2(:,:)
+ INTEGER, ALLOCATABLE :: IDX1(:,:)
+
+ REAL(4), ALLOCATABLE :: CFT(:),FUN1(:),PW(:)
+ REAL(4), ALLOCATABLE :: NDX1(:),WT1(:),WT2(:)
+!Chanh
+ CHARACTER SN*1
+
+ IR=IR1-1
+ nm=NZ
+ kmx1=kmx-1
+
+ NXC=NX/2
+ NYC=NY/2
+
+ ALLOCATE ( RADIUS(IR1),RADIUS1(IR1) )
+ ALLOCATE ( U_2S(IR1,KMX),V_2S(IR1,KMX),U_2S1(IR1,KMX) )
+ ALLOCATE ( T_2S(IR1,KMX),Q_2S(IR1,KMX),SLP_2S(IR1) )
+ ALLOCATE ( TEK(KMX),HP(NX,NY,KMX) )
+
+ ALLOCATE ( RKX1(IR1),WKX1(IR1,NZ) )
+ ALLOCATE ( RKX2(IR1),WKX2(IR1,NZ) )
+ ALLOCATE ( strm1(IR1,nm),strm2(IR1,nm),strm3(IR1,nm) )
+
+ ALLOCATE ( rpb(IR1),rpb1(IR1),rpb2(IR1) )
+ ALLOCATE ( rtmp(IR1,NM),rtmp1(IR1,NM),rtmp2(IR1,NM),rtmp3(IR1,NM) )
+ ALLOCATE ( rmix(IR1,NM) )
+ ALLOCATE ( ctmp(IR1,kmx),cmix(IR1,kmx) )
+
+ ALLOCATE ( CFT(IR1),FUN1(IR1),PW(KMX) )
+ ALLOCATE ( NDX1(IR1),WT1(IR1),WT2(IR1) )
+
+ eps4 = 1.E-4
+ eps5 = 1.E-5
+ pi=4.*atan(1.)
+ pi180=pi/180.
+ pi_deg=180./pi
+ DST1=6.371E6*pi180 !* deg -> m
+
+ cost=cos(clat_new*pi180)
+
+ print*,'inside cort'
+ print*,'pi=,kmx= ',pi,kmx
+
+ read(23)IR1,IR_1,JX,JY,JZ,KMX
+ print*,'IR1,IR_1,JX,JY,JZ,KMX=',IR1,IR_1,JX,JY,JZ,KMX
+ read(23)RADIUS
+ print*,'test1=RADIUS',RADIUS(1),RADIUS(2)
+ read(23)CLON_NEW,CLAT_NEW
+ print*,'test1=CLON_NEW,CLAT_NEW'
+ read(23)U_2S,V_2S,U_2S1
+ print*,'test1=U_2S,V_2S,U_2S1'
+ read(23)T_2S,Q_2S,SLP_2S
+ print*,'test1=T_2S,Q_2S,SLP_2S'
+ read(23)CFT,PW,beta11
+ print*,'test1=CFT,PW,beta11',CFT(1),CFT(2)
+ read(23)
+
+ rewind(23)
+
+! check max, min temp
+
+ do k=1,kmx
+ tmax=-1.E20
+ tmin=1.E20
+ DO j=1,IR1
+ if (T_2S(j,k).GT.tmax) then
+ tmax=T_2S(j,k)
+ jmax3=j
+ end if
+ if (T_2S(j,k).LT.tmin) then
+ tmin=T_2S(j,k)
+ jmin=j
+ end if
+ END DO
+ print*,'k,tmax,tmin=',k,tmax,tmin
+ end do
+
+ print*,'clon_new,clat_new=',clon_new,clat_new
+
+ ff0=2.*7.292E-5*sin(clat_new*pi180)
+
+ print*,'beta,fact,ff0=',beta,fact,ff0
+
+ RKX1=0.
+ DO n=1,IR1
+ RKX1(n)=RADIUS(n)*DST1 !* deg -> m
+ print*,'RKX1(n)=',RKX1(n),U_2S(n,10)
+ END DO
+
+ IF ( iparam == 1 ) THEN !* ---------------------------------------
+
+ RKX2=0.
+ DO n=1,IR1
+ RADIUS1(n) = RADIUS(n)*fact
+ RKX2(n) = RADIUS1(n)*DST1 !* deg -> m
+ END DO
+
+ PRINT*, 'Adjustment for old storm-size correction with 1 parameter.'
+
+ ELSEIF ( iparam == 2 ) THEN !* -----------------------------------
+
+! if ( abs(bbb) < eps5 ) then !* - - - - - - - - - - - - - - - -
+ if ( abs(bbb) < eps4 ) then !* - - - - - - - - - - - - - - - -
+
+ RKX2=0.
+ DO n=1,IR1
+ RADIUS1(n) = aaa*RADIUS(n)
+ RKX2(n) = RADIUS1(n)*DST1 !* deg -> m
+ END DO
+
+ PRINT*, 'Adjustment for storm-size correction reduced to 1 parameter.'
+
+ else !* - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ RKX2=0.
+ DO n=1,IR1
+ RADIUS1(n) = aaa*RADIUS(n) + .5*bbb*RADIUS(n)**2
+ RKX2(n) = RADIUS1(n)*DST1 !* deg -> m
+ END DO
+
+ PRINT*, 'Adjustment for storm-size correction with 2 parameters.'
+
+ endif !* - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ ENDIF !* ---------------------------------------------------------
+
+ k=1
+ k1=2
+
+!
+! Chanh added modification here to recompute the stream
+! function for the Southern Hemisphere,
+!
+ WKX1=0.
+ DO n=1,IR1
+ WKX1(n,k)=U_2S1(n,k1)
+ IF(WKX1(n,k).lt.0..and.SN.eq.'N') WKX1(n,k)=0.
+ IF(WKX1(n,k).gt.0..and.SN.eq.'S') WKX1(n,k)=0.
+ END DO
+
+ WKX2=0.
+ DO n=1,IR1
+ WKX2(n,1)=U_2S1(n,2)*beta
+ IF(WKX2(n,1).lt.0..and.SN.eq.'N') WKX2(n,1)=0.
+ IF(WKX2(n,1).gt.0..and.SN.eq.'S') WKX2(n,1)=0.
+ END DO
+
+ strm1(IR1,k)=0.
+ strm2(IR1,k)=0.
+ DO n=IR,1,-1
+ force=(WKX1(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX1(n,k)
+ strm1(n,k)=strm1(n+1,k)-force*(RKX1(n+1)-RKX1(n))
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ END DO
+
+! Interpolate from RADIUS1 to RADIUS grid
+
+! IF (abs(fact-1.0).GT.0.01) THEN
+ strm3=0.
+ JST1=1
+ DO J=1,IR1
+ DIF=RADIUS1(1)-RADIUS(J)
+ IF (DIF.GE.0.) THEN
+ strm3(J,k)=strm2(1,k)
+ JST1=J+1
+ END IF
+ END DO
+ DO J=JST1,IR1
+ DO N=2,IR1
+ DIF=RADIUS1(N)-RADIUS(J)
+ IF (DIF.GE.0.) THEN
+ WT11=(RADIUS(J)-RADIUS1(N-1))/(RADIUS1(N)-RADIUS1(N-1))
+ WT12=1.-WT11
+ strm3(J,k)=WT11*strm2(n,k)+WT12*strm2(n-1,k)
+ GO TO 55
+ END IF
+ END DO
+ 55 CONTINUE
+ END DO
+ DO n=1,IR1
+ strm2(n,k)=strm3(n,k)
+ END DO
+! END IF
+
+ PRINT*,'finish computing stream function'
+
+ do m=1,IR_1
+ str_cut=max(strm2(m,1),strm1(m,1))
+ IF (str_cut.GT.-10.) THEN
+ str_m_rat=strm2(m,1)/(strm1(m,1)-1.E-20)
+ IR_2=m
+ go to 57
+ END IF
+ end do
+ 57 continue
+
+
+ print*,'IR_1,IR_2=',IR_1,IR_2
+
+ fun1=0.
+ do m=1,IR_2
+ fun1(m)=cft(m)*strm2(m,1)/(strm1(m,1)-1.E-20)
+ end do
+
+ do m=IR_2,IR_1
+ fun1(m)=cft(m)*min(str_m_rat,strm2(m,1)/(strm1(m,1)-1.E-20))
+ end do
+
+
+ rpb=0.
+ do m=1,IR_1
+! print*,'fun1(m),cft(m),strm2(m,1),strm1(m,1)=',m,fun1(m),cft(m),strm2(m,1),strm1(m,1)
+ rpb(m) =fun1(m)*SLP_2S(m)
+ end do
+
+ rtmp=0.
+ do k=1,NZ
+ k1=2*k
+ if (k1 .le. 121) then
+ do m=1,IR_1
+ rtmp(m,k) =fun1(m)*T_2S(m,k1)
+! if(k.eq.15)print*,'m,fun1(m),T_2S(m,k1)=',m,fun1(m),T_2S(m,k1)
+ end do
+ else
+ do m=1,IR_1
+ rtmp(m,k) = 0.0
+ end do
+ endif
+ end do
+
+!!!!!
+! correct mixing ratio
+
+ rmix=0.
+ TEK=273.0
+ do k=1,NZ
+ k1=2*k
+ if ( k1 .le. 121 ) then
+ do m=1,IR_1
+ TEK1=TEK(k1)+T_2S(m,k1)
+ TEK2=TEK(k1)+rtmp(m,k) ! do not change k back to k1
+ TEK3=TEK(k1)+T_2S(m,k1)*cft(m)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ ESR1=exp(4302.645*(TEK3-TEK1)/((TEK3-29.66)*(TEK1-29.66)))
+ rmix(m,k)=ESRR*Q_2S(m,k1)-ESR1*Q_2S(m,k1) ! will recompute
+ end do
+ else
+ do m=1,IR_1
+ rmix(m,k)=0.0 ! will recompute
+ end do
+ endif
+ end do
+
+ do m=1,IR_1
+ print*,'rpb(m)=',m,rpb(m),cft(m),SLP_2S(m)
+ rpb(m) =rpb(m)-cft(m)*SLP_2S(m)*beta
+ end do
+
+ do k=1,nz
+ k1=2*k
+ if ( k1 .le. 121 ) then
+ do m=1,IR_1
+ rtmp(m,k) =rtmp(m,k)-cft(m)*T_2S(m,k1)*beta
+ end do
+ else
+ do m=1,IR_1
+ rtmp(m,k) = 0.0
+ end do
+ endif
+ end do
+
+ ctmp=0.
+ cmix=0.
+
+ do m=1,IR_1
+ ctmp(m,1)=rtmp(m,1)
+ ctmp(m,kmx)=rtmp(m,NZ)
+ cmix(m,1)=rmix(m,1)
+ cmix(m,kmx)=rmix(m,NZ)
+ do k=2,kmx1,2
+ k1=k/2
+ ctmp(m,k)=rtmp(m,k1)
+ cmix(m,k)=rmix(m,k1)
+ end do
+ do k=3,kmx1-1,2
+ k1=(k-1)/2
+ ctmp(m,k)=0.5*(rtmp(m,k1)+rtmp(m,k1+1))
+ cmix(m,k)=0.5*(rmix(m,k1)+rmix(m,k1+1))
+ end do
+ end do
+
+ DO K=1,KMX
+ DO m=1,IR_1
+ ctmp(m,k)=ctmp(m,k)*PW(k)
+ cmix(m,k)=cmix(m,k)*PW(k)
+ END DO
+ END DO
+
+! interpolate correction to 3D
+
+ ALLOCATE ( RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ IDX1=-1
+
+ DO J=1,NY
+ DO I=1,NX
+ RIJ2(I,J)=SQRT(((HLON(I,J)-CLON_NEW)*cost)**2+ &
+ (HLAT(I,J)-CLAT_NEW)**2 )
+ DO N=1,IR_1
+ DIF=RADIUS(N)-RIJ2(I,J)
+ IF (DIF.GT.0.) THEN
+ IDX1(I,J)=N
+ GO TO 25
+ END IF
+ END DO
+ 25 CONTINUE
+ IF (IDX1(I,J).GE.2) THEN
+ W1(I,J)=(RIJ2(I,J)-RADIUS(IDX1(I,J)-1))/ &
+ (RADIUS(IDX1(I,J))-RADIUS(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE
+ W1(I,J)=1.
+ W2(I,J)=0.
+ END IF
+ END DO
+ END DO
+
+ SLP_X=0.
+ T_X=0.
+ Q_X=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ IF (IDX1(I,J).GT.0) THEN
+ if (IDX1(I,J).GE.2) then
+ SLP_X(I,J)=W1(I,J)*rpb(IDX1(I,J))+W2(I,J)*rpb(IDX1(I,J)-1)
+ DO K=1,KMX
+ T_X(I,J,K)=W1(I,J)*ctmp(IDX1(I,J),k)+W2(I,J)*ctmp(IDX1(I,J)-1,k)
+ Q_X(I,J,K)=W1(I,J)*cmix(IDX1(I,J),k)+W2(I,J)*cmix(IDX1(I,J)-1,k)
+ END DO
+ else
+ SLP_X(I,J)=rpb(IDX1(I,J))
+ DO K=1,KMX
+ T_X(I,J,K)=ctmp(IDX1(I,J),k)
+ Q_X(I,J,K)=cmix(IDX1(I,J),k)
+ END DO
+ end if
+ END IF
+ END DO
+ END DO
+
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/fill_nmm_gridg.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/fill_nmm_gridg.f90
new file mode 100644
index 000000000..0281e5e07
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/fill_nmm_gridg.f90
@@ -0,0 +1,92 @@
+subroutine fill_nmm_gridg(gin,nx,ny,b,igtype)
+
+! convert input staggered grid to output filled grid
+
+! --> gin: input staggered grid
+! --> nx,ny: input grid dimensions
+! <-- b: output filled grid
+! --> igtype: =1, then (1,1) on staggered grid is at corner of grid
+! =2, then (1,1) is staggered
+
+implicit none
+
+integer nx,ny,igtype
+real(4) gin(nx,ny),b(2*nx-1,ny)
+
+integer i,im,ip,j,jm,jp
+real(4) fill,test
+
+fill=.95*huge(fill) ; test=.95*fill
+do j=1,ny
+ do i=1,2*nx-1
+ b(i,j)=fill
+ end do
+end do
+
+! first transfer all staggered points to appropriate
+! points on filled output grid
+
+if(igtype.eq.1) then
+ do j=1,ny,2
+ do i=1,nx
+ b(2*i-1,j)=gin(i,j)
+ end do
+ end do
+ do j=2,ny,2
+ do i=1,nx-1
+ b(2*i,j)=gin(i,j)
+ end do
+ end do
+else
+ do j=1,ny,2
+ do i=1,nx-1
+ b(2*i,j)=gin(i,j)
+ end do
+ end do
+ do j=2,ny,2
+ do i=1,nx
+ b(2*i-1,j)=gin(i,j)
+ end do
+ end do
+end if
+
+! now fill in holes
+
+! top and bottom rows:
+
+do j=1,ny,ny-1
+ do i=1,2*nx-1
+ if(b(i,j).gt.test) then
+ ip=i+1 ; if(ip.gt.2*nx-1) ip=i-1
+ im=i-1 ; if(im.lt.1) im=i+1
+ b(i,j)=.5*(b(im,j)+b(ip,j))
+ end if
+ end do
+end do
+
+! left and right rows:
+
+do j=1,ny
+ jp=j+1 ; if(jp.gt.ny) jp=j-1
+ jm=j-1 ; if(jm.lt.1) jm=j+1
+ do i=1,2*nx-1,2*nx-2
+ if(b(i,j).gt.test) b(i,j)=.5*(b(i,jm)+b(i,jp))
+ end do
+end do
+
+! interior points
+
+do j=1,ny
+ jp=j+1 ; if(jp.gt.ny) jp=j-1
+ jm=j-1 ; if(jm.lt.1) jm=j+1
+ do i=1,2*nx-1
+ if(b(i,j).gt.test) then
+ ip=i+1 ; if(ip.gt.2*nx-1) ip=i-1
+ im=i-1 ; if(im.lt.1) im=i+1
+ b(i,j)=.25*(b(ip,j)+b(im,j)+b(i,jp)+b(i,jm))
+ end if
+ end do
+end do
+
+end subroutine fill_nmm_gridg
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/interp_coef_agrid.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/interp_coef_agrid.f90
new file mode 100644
index 000000000..1c63766c7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/interp_coef_agrid.f90
@@ -0,0 +1,300 @@
+SUBROUTINE EARTH_LATLON_AGRID ( HLAT,HLON,VLAT,VLON, & !Earth lat,lon at H and V points
+ LON1,LAT1,LON2,LAT2, & !input res,west & south boundaries,
+ CENTRAL_LAT,CENTRAL_LON, & ! central lat,lon, all in degrees
+ IM,JM)
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ REAL(4), INTENT(IN) :: LON1,LAT1,LON2,LAT2
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(OUT) :: HLAT,HLON,VLAT,VLON
+
+! local
+
+ INTEGER,PARAMETER :: KNUM=8
+ INTEGER :: I,J
+ REAL(KNUM) :: rot_lon,rot_lat,geo_lon,geo_lat
+ REAL(KNUM) :: cen_lon, cen_lat
+!-------------------------------------------------------------------------
+
+ cen_lon = CENTRAL_LON
+ cen_lat = CENTRAL_LAT
+
+ do j=1,jm
+ do i=1,im
+ rot_lon = lon1 + (lon2-lon1)/(im-1) * (i-1)
+ rot_lat = lat1 + (lat2-lat1)/(jm-1) * (j-1)
+ call rtll(rot_lon, rot_lat, geo_lon, geo_lat, cen_lon, cen_lat)
+! if (geo_lon <0.0) geo_lon = geo_lon + 360.0
+ HLON(i,j) = geo_lon
+ HLAT(i,j) = geo_lat
+ enddo
+ enddo
+
+ VLON = HLON
+ VLAT = HLAT
+
+END SUBROUTINE EARTH_LATLON_AGRID
+
+!-----------------------------------------------------------------------------
+
+SUBROUTINE G2T2H_AGRID( IIH,JJH, & ! output grid index
+ HBWGT, & ! output weights in terms of parent grid
+ HLAT,HLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: HLAT,HLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: HBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIH,JJH
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(HLON(I,J),HLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1)/DLMD1 + 1
+ YI = (Y-SBD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIH(I,J,1)=I1
+ IIH(I,J,2)=I2
+ IIH(I,J,3)=I1
+ IIH(I,J,4)=I2
+ JJH(I,J,1)=J1
+ JJH(I,J,2)=J1
+ JJH(I,J,3)=J2
+ JJH(I,J,4)=J2
+ HBWGT(I,J,1)=(1-XF)*(1-YF)
+ HBWGT(I,J,2)=XF*(1-YF)
+ HBWGT(I,J,3)=(1-XF)*YF
+ HBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+END SUBROUTINE G2T2H_AGRID
+
+
+
+SUBROUTINE G2T2V_BGRID( IIV,JJV, & ! output grid index and weights
+ VBWGT, & ! output weights in terms of parent grid
+ VLAT,VLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: VLAT,VLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: VBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIV,JJV
+
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(VLON(I,J),VLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1-0.5*DLMD1)/DLMD1 + 1
+ YI = (Y-SBD1-0.5*DPHD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIV(I,J,1)=I1
+ IIV(I,J,2)=I2
+ IIV(I,J,3)=I1
+ IIV(I,J,4)=I2
+ JJV(I,J,1)=J1
+ JJV(I,J,2)=J1
+ JJV(I,J,3)=J2
+ JJV(I,J,4)=J2
+ VBWGT(I,J,1)=(1-XF)*(1-YF)
+ VBWGT(I,J,2)=XF*(1-YF)
+ VBWGT(I,J,3)=(1-XF)*YF
+ VBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+
+ RETURN
+ END SUBROUTINE G2T2V_BGRID
+
+ subroutine rtll(tlmd,tphd,almd,aphd,tlm0d,tph0d)
+!-------------------------------------------------------------------------------
+ INTEGER,PARAMETER :: KIND_R8=8
+
+ real(KIND_R8), intent(in) :: tlmd, tphd
+ real(KIND_R8), intent(out) :: almd, aphd
+ real(KIND_R8), intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real(KIND_R8), parameter :: pi=3.14159265358979323846
+ real(KIND_R8), parameter :: dtr=pi/180.0
+!
+ real(KIND_R8) :: tph0, ctph0, stph0, tlm, tph, stph, ctph, ctlm, stlm, aph, cph
+ real(KIND_R8) :: xx, yy
+!-------------------------------------------------------------------------------
+!
+ tph0=tph0d*dtr
+ ctph0=cos(tph0)
+ stph0=sin(tph0)
+!
+ tlm=tlmd*dtr
+ tph=tphd*dtr
+ stph=sin(tph)
+ ctph=cos(tph)
+ ctlm=cos(tlm)
+ stlm=sin(tlm)
+!
+ xx=stph0*ctph*ctlm+ctph0*stph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ aph=asin(xx)
+ cph=cos(aph)
+!
+ xx=(ctph0*ctph*ctlm-stph0*stph)/cph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ xx=acos(xx)/dtr
+ yy=ctph*stlm/cph
+ xx=sign(xx,yy)
+ almd=tlm0d+xx
+
+ aphd=aph/dtr
+!
+ if (almd > 180.0) then
+ almd=almd-360.0
+ end if
+ if (almd < -180.0) then
+ almd=almd+360.0
+ end if
+!
+ return
+!
+ end subroutine rtll
+
+
+ subroutine tll(almd,aphd,tlmd,tphd,tph0d,tlm0d)
+!-------------------------------------------------------------------------------
+ implicit none
+!-------------------------------------------------------------------------------
+ real, intent(in) :: almd, aphd
+ real(8), intent(out) :: tlmd, tphd
+ real, intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real, parameter :: pi=3.141592654
+ real(8), parameter :: dtr=pi/180.0
+!
+ real(8) :: tph0, ctph0, stph0, relm, srlm, crlm
+ real(8) :: aph, sph, cph, cc, anum, denom
+!-------------------------------------------------------------------------------
+!
+ if (tlm0d==0.0.and.tph0d==0.0) then
+ tlmd=almd
+ tphd=aphd
+ else
+
+ tph0=tph0d*dtr
+ ctph0=dcos(tph0)
+ stph0=dsin(tph0)
+!
+ relm=(almd-tlm0d)*dtr
+ srlm=dsin(relm)
+ crlm=dcos(relm)
+ aph=aphd*dtr
+ sph=dsin(aph)
+ cph=dcos(aph)
+ cc=cph*crlm
+ anum=cph*srlm
+ denom=ctph0*cc+stph0*sph
+!
+ tlmd=datan2(anum,denom)/dtr
+ tphd=dasin(ctph0*sph-stph0*cc)/dtr
+
+ end if
+!
+ return
+!
+ end subroutine tll
+
+
+!! subroutine 'get_eta_level' returns the interface and
+!! layer-mean pressures for reference.
+ subroutine get_eta_level(npz, p_s, pf, ph, ak, bk, pscale)
+ integer, intent(in) :: npz
+ real, intent(in) :: p_s !< unit: pascal
+ real, intent(in) :: ak(npz+1)
+ real, intent(in) :: bk(npz+1)
+ real, intent(in), optional :: pscale
+ real, intent(out) :: pf(npz)
+ real, intent(out) :: ph(npz+1)
+
+ real, parameter :: RDGAS = 287.05 !< Gas constant for dry air [J/kg/deg]
+ real, parameter :: CP_AIR = 1004.6 !< Specific heat capacity of dry air at constant pressure [J/kg/deg]
+ real, parameter :: KAPPA = RDGAS/CP_AIR !< RDGAS / CP_AIR [dimensionless]
+ integer k
+
+ ph(1) = ak(1)
+ do k=2,npz+1
+ ph(k) = ak(k) + bk(k)*p_s
+ enddo
+
+! if ( present(pscale) ) then
+! do k=1,npz+1
+! ph(k) = pscale*ph(k)
+! enddo
+! endif
+
+ if( ak(1) > 1.E-8 ) then
+ pf(1) = (ph(2) - ph(1)) / log(ph(2)/ph(1))
+ else
+ pf(1) = (ph(2) - ph(1)) * kappa/(kappa+1.)
+ endif
+
+ do k=2,npz
+ pf(k) = (ph(k+1) - ph(k)) / log(ph(k+1)/ph(k))
+ enddo
+
+ end subroutine get_eta_level
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/split_sym_asy.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/split_sym_asy.f90
new file mode 100644
index 000000000..905e1fb24
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_combine/split_sym_asy.f90
@@ -0,0 +1,230 @@
+ SUBROUTINE Split_Sym_Asy(IX,JX,KX,UD,VD,US,VS,UA,VA,TWM,RWM, &
+ GLON,GLAT,CLON_NEW,CLAT_NEW,TWMAX,RWMAX,ASYM)
+
+
+! IX,JX must be less than IX1,JX1
+
+! PARAMETER (IX1=2000,JX1=2000)
+ PARAMETER (IR=100, IT=24, DDR=0.1)
+ PARAMETER (IR1=IR+1)
+ REAL(8) CLON_NEW,CLAT_NEW
+ REAL(4) UD(IX,JX,KX),VD(IX,JX,KX),GLON(IX,JX),GLAT(IX,JX)
+ REAL(4) US(IX,JX,KX),VS(IX,JX,KX),UA(IX,JX,KX),VA(IX,JX,KX)
+ DIMENSION RWM(IR1),TWM(IR1)
+ real, dimension(:,:), allocatable :: RIJ,W1,W2
+ integer, dimension(:,:), allocatable :: IDX1
+ integer :: IX1,JX1
+! DIMENSION RIJ(IX1,JX1),W1(IX1,JX1),W2(IX1,JX1)
+! INTEGER IDX1(IX1,JX1)
+
+ IX1=IX
+ JX1=JX
+
+ allocate(RIJ(IX1,JX1),W1(IX1,JX1),W2(IX1,JX1),IDX1(IX1,JX1))
+
+ pi=4.*atan(1.)
+ pi180=pi/180.
+ cost=cos(clat_new*pi180)
+
+ US=0.
+ VS=0.
+ IDX1=-1
+ W1=0.
+ W2=0.
+
+ DO N=1,IR
+ RWM(N)=N*DDR
+ END DO
+ DO J=1,JX
+ DO I=1,IX
+ RIJ(I,J)=SQRT(((GLON(I,J)-CLON_NEW)*cost)**2+ &
+ (GLAT(I,J)-CLAT_NEW)**2 )
+ DO N=1,IR
+ DIF=RWM(N)-RIJ(I,J)
+ IF(DIF.GT.0.)THEN
+ IDX1(I,J)=N
+ GO TO 15
+ END IF
+ END DO
+ 15 CONTINUE
+ IF(IDX1(I,J).GE.2)THEN
+ W1(I,J)=(RIJ(I,J)-RWM(IDX1(I,J)-1))/ &
+ (RWM(IDX1(I,J))-RWM(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE IF(IDX1(I,J).EQ.1)THEN
+ W1(I,J)=RIJ(I,J)/RWM(IDX1(I,J))
+! W2(I,J)=1.-W1(I,J)
+ END IF
+ END DO
+ END DO
+
+
+ DO K=1,KX
+ CALL FIND_WT1(IX,JX,UD(1,1,K),VD(1,1,K),GLON,GLAT, &
+ TWM,RWM,ASYM,CLON_NEW,CLAT_NEW)
+
+ IF(K.eq.1)THEN
+ TWMAX=TWM(IR1)
+ RWMAX=RWM(IR1)
+ END IF
+
+ DO J=1,JX
+ DO I=1,IX
+
+ IF(IDX1(I,J).GT.0)THEN
+ IF(IDX1(I,J).GE.2)THEN
+ UTT=W1(I,J)*TWM(IDX1(I,J))+W2(I,J)*TWM(IDX1(I,J)-1)
+ ELSE
+ UTT=W1(I,J)*TWM(IDX1(I,J)) ! WT=0. at center
+ END IF
+
+ DTX=GLON(I,J)-CLON_NEW
+ DTY=GLAT(I,J)-CLAT_NEW
+ DTR=RIJ(I,J)
+
+ US(I,J,K)=-UTT*DTY/(DTR+1.E-20)
+ VS(I,J,K)= UTT*DTX/(DTR+1.E-20)
+ END IF
+
+ UA(I,J,K)=UD(I,J,K)-US(I,J,K)
+ VA(I,J,K)=VD(I,J,K)-VS(I,J,K)
+
+ END DO
+ END DO
+ END DO
+
+ print*,'max speed & radius at surface=',TWMAX,RWMAX
+
+ deallocate(RIJ,W1,W2,IDX1)
+ RETURN
+ END
+
+
+
+
+ SUBROUTINE FIND_WT1(IX,JX,UD,VD,GLON2,GLAT2,TWM,RWM,ASYM, &
+ CLON_NEW,CLAT_NEW)
+! PARAMETER (IR=75,IT=24,ddr=0.2)
+ PARAMETER (IR=100,IT=24,ddr=0.1)
+ PARAMETER (IR1=IR+1)
+ DIMENSION UD(IX,JX),VD(IX,JX)
+ REAL(4) GLON2(IX,JX),GLAT2(IX,JX)
+ DIMENSION WTM(IR),RWM(IR1),TWM(IR1),WTM2(IR,IT),WTM1(IT)
+ REAL(8) CLON_NEW,CLAT_NEW
+
+!
+ PI=ASIN(1.)*2.
+ RAD=PI/180.
+ pi180=RAD
+ cost=cos(clat_new*pi180)
+!
+ ix2=ix/2
+ jx2=jx/2
+ DDS=(((GLON2(ix2+1,jx2)-GLON2(ix2,jx2))*cost)**2+ &
+ (GLAT2(ix2,jx2+1)-GLAT2(ix2,jx2))**2)
+! & (GLAT2(ix2,jx2+1)-GLAT2(ix2,jx2))**2)*1.5
+
+ print*,'ix,jx,ix2,jx2=',ix,jx,ix2,jx2
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW,CLAT_NEW
+ print*,'GLON2,GLAT2=',GLON2(1,1),GLAT2(1,1)
+
+ WTM=0.
+ WTM2=0.
+
+ BLON = CLON_NEW
+ BLAT = CLAT_NEW
+
+!.. CALCULATE TANGENTIAL WIND EVERY 0.1 deg INTERVAL
+!.. 20*20 deg AROUND 1ST GUESS VORTEX CENTER
+
+ DO 10 JL=1,IR
+ WTS= 0.
+ DR = JL*ddr
+ DO 20 IL=1,IT
+ DD = (IL-1)*15*RAD
+ DLON = DR*COS(DD)
+ DLAT = DR*SIN(DD)
+ TLON = BLON + DLON
+ TLAT = BLAT + DLAT
+
+!.. INTERPOLATION U, V AT TLON,TLAT AND CLACULATE TANGENTIAL WIND
+
+ u1=0.
+ v1=0.
+ sum1=0.
+ DO j=1,JX
+ DO i=1,IX
+ dist=(((GLON2(i,j)-TLON)*cost)**2+(GLAT2(i,j)-TLAT)**2)
+ if(dist.lt.DDS)THEN
+ dist1=1./(sqrt(dist)+1.E-20)
+ sum1=sum1+dist1
+ u1=u1+UD(i,j)*dist1
+ v1=v1+VD(i,j)*dist1
+ end if
+ end do
+ end do
+
+ UT=u1/(sum1+1.e-20)
+ VT=v1/(sum1+1.e-20)
+
+!.. TANGENTIAL WIND
+ WT = -SIN(DD)*UT + COS(DD)*VT
+ WTS = WTS+WT
+ WTM2(JL,IL)=WT
+20 CONTINUE
+ WTM(JL) = WTS/24.
+! print*,'JL,WTM(JL)=',JL,WTM(JL)
+10 CONTINUE
+
+! Southern Hemisphere
+ IF(CLAT_NEW.LT.0)THEN
+ DO JL=1,IR
+ WTM(JL)=-WTM(JL)
+ END DO
+ END IF
+! EnD SH
+
+ TX = -10000000.
+ DO KL = 1,IR
+ IF(WTM(KL).GE.TX) THEN
+ TX = WTM(KL)
+ RRX = KL*ddr
+ KLM=KL
+ ENDIF
+ ENDDO
+
+ DO KL=1,IR
+ TWM(KL)=WTM(KL)
+ RWM(KL)=KL*ddr
+ END DO
+ TWM(IR1)=TX
+ RWM(IR1)=RRX
+
+ DO IL=1,IT
+ WSUM=0.
+ DO KL=1,IR
+ WSUM=WSUM+WTM2(KL,IL)*RWM(KL) ! area
+ END DO
+ WTM1(IL)=WSUM
+ END DO
+
+ WT_S=0.
+ DO IL=1,IT
+ WT_S=WT_S+WTM1(IL)
+ END DO
+ WT_S=WT_S/24.
+
+ W_MAX=-1.E20
+ W_MIN=1.E20
+ DO IL=1,IT
+ IF(WTM1(IL).GT.W_MAX)W_MAX=WTM1(IL)
+ IF(WTM1(IL).LT.W_MIN)W_MIN=WTM1(IL)
+ END DO
+ ASYM=(W_MAX-W_MIN)/WT_S
+
+ PRINT*,'Asym=',ASYM,W_MAX,W_MIN,WT_S
+
+
+ RETURN
+ END
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/CMakeLists.txt
new file mode 100644
index 000000000..db4e98184
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/CMakeLists.txt
@@ -0,0 +1,31 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ anl_enhance.f90
+ convert_axi_xy.f90
+ correct_mat_2.f90
+ interp_coef_agrid.f90)
+
+set(exe_name hafs_vi_anl_enhance.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_libraries(
+ ${exe_name} PRIVATE
+ OpenMP::OpenMP_Fortran)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/Makefile
new file mode 100644
index 000000000..6743544df
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/Makefile
@@ -0,0 +1,18 @@
+include ../configure.vi
+include ../pure-openmp.inc
+
+OBJS = anl_enhance.o convert_axi_xy.o correct_mat_2.o interp_coef_agrid.o
+
+EXEC = ../../../exec/hafs_vi_anl_enhance.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/anl_enhance.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/anl_enhance.f90
new file mode 100644
index 000000000..754077f84
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/anl_enhance.f90
@@ -0,0 +1,1423 @@
+!
+! ABSTRACT: Adding a small fraction of the composite storm to make
+! the storm intensity match the observation
+!
+! ORIGINAL AUTHOR: QINGFU LIU, NCEP/EMC, 2007
+! REVISED AUTHOR: QINGFU LIU, 2013
+! : Use observed ROCI and Rmax to correct the composite storm
+! : (old version uses the averaged values from obs and model)
+!
+! DECLARE VARIABLES
+!
+ INTEGER I,J,K,NX,NY,NZ,ICH
+!
+ PARAMETER (NST=5,IR=200)
+! PARAMETER (NX=158,NY=329,NZ=42,NST=5)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.,IR1=IR+1)
+
+! PARAMETER (KMX=2*NZ+1)
+!
+ PARAMETER (NZ2=121)
+
+! Variables on 4x hybrid coordinate
+
+ REAL(4) DLMD,DPHD,PT,PDTOP
+ REAL(4) WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ REAL(4) LON1,LAT1,LON2,LAT2
+
+ REAL(4), ALLOCATABLE :: T1(:,:,:),Q1(:,:,:)
+ REAL(4), ALLOCATABLE :: U1(:,:,:),V1(:,:,:),DZDT(:,:,:)
+ REAL(4), ALLOCATABLE :: Z1(:,:,:),P1(:,:,:)
+ REAL(4), ALLOCATABLE :: GLON(:,:),GLAT(:,:)
+ REAL(4), ALLOCATABLE :: PD1(:,:),ETA1(:),ETA2(:)
+
+ REAL(4), ALLOCATABLE :: USCM(:,:),VSCM(:,:) ! Env. wind at new grids
+
+ REAL(4), ALLOCATABLE :: TEK(:),TEK42(:)
+ REAL(4), ALLOCATABLE :: PCK(:)
+
+! variables for hurricane component
+
+ REAL(4), ALLOCATABLE :: SLPE(:,:),SLP_1(:,:),TENV(:,:,:)
+ REAL(4), ALLOCATABLE :: T_1(:,:,:),Q_1(:,:,:)
+ REAL(4), ALLOCATABLE :: U_1(:,:,:),V_1(:,:,:)
+
+ REAL(4), ALLOCATABLE :: T_X(:,:,:),Q_X(:,:,:),SLP_X(:,:)
+
+! Variables for old domain
+
+ REAL(4) DLMD2,DPHD2,PT2,PDTOP2
+ REAL(4) WBD2,SBD2,CENTRAL_LON2,CENTRAL_LAT2
+
+! working array
+
+ REAL(4), ALLOCATABLE :: SLP1(:,:),RIJ(:,:)
+ REAL(4), ALLOCATABLE :: PMID1(:,:,:),ZMID1(:,:,:)
+ REAL(4), ALLOCATABLE :: ZS1(:,:),TS1(:,:),QS1(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON(:,:),HLAT(:,:)
+ REAL(4), ALLOCATABLE :: VLON(:,:),VLAT(:,:)
+
+ REAL(4), ALLOCATABLE :: U_S(:,:),V_S(:,:)
+ REAL(4), ALLOCATABLE :: U_A(:,:),V_A(:,:)
+
+ REAL(4), ALLOCATABLE :: USC(:,:),VSC(:,:) ! Env. wind at new grids
+ REAL(4), ALLOCATABLE :: USC_1(:,:),VSC_1(:,:) ! hurricane component wind at z=0
+ REAL(4), ALLOCATABLE :: USC1(:,:),VSC1(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: USC11(:,:),VSC11(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: USC2(:,:),VSC2(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: SLPV(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON1(:,:),HLAT1(:,:)
+ REAL(4), ALLOCATABLE :: VLON1(:,:),VLAT1(:,:)
+ REAL(4), ALLOCATABLE :: T21(:,:,:,:),Q21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: U21(:,:,:,:),V21(:,:,:,:)
+ REAL(4), ALLOCATABLE :: SLP21(:,:,:)
+ REAL(4), ALLOCATABLE :: PMV1(:,:,:),PMV2(:,:,:)
+
+ REAL(4), ALLOCATABLE :: A101(:,:),B101(:,:),C101(:,:)
+
+ REAL(4), ALLOCATABLE :: T_4(:,:,:),Q_4(:,:,:)
+
+ REAL(4), ALLOCATABLE :: U_2SB(:,:),T_2SB(:,:),SLP_2SB(:)
+ REAL(4), ALLOCATABLE :: R_2SB(:,:),temp_e(:),RADIUS2(:)
+
+ REAL(4), ALLOCATABLE :: U_2S(:,:),U_2S1(:,:),U_2S2(:)
+ REAL(4), ALLOCATABLE :: T_2S(:,:),SLP_2S(:),Q_2S(:,:)
+ REAL(4), ALLOCATABLE :: RKX1(:),RADIUS(:),CFT(:),V_2S(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:),strm2(:)
+
+ REAL(8), ALLOCATABLE :: WRK1(:),WRK2(:),WRK3(:),WRK4(:)
+ REAL(4), ALLOCATABLE :: work_1(:),work_2(:)
+
+ REAL(4), ALLOCATABLE :: PCST(:),HP(:,:,:),HV(:,:,:)
+ REAL(4), ALLOCATABLE :: P_S(:,:),P_A(:,:)
+ REAL(4), ALLOCATABLE :: PCST1(:,:,:),PCST2(:),PCSK(:)
+
+ REAL(4), ALLOCATABLE :: HBWGT1(:,:,:),VBWGT1(:,:,:)
+ integer(4), ALLOCATABLE :: IIH1(:,:),JJH1(:,:)
+ integer(4), ALLOCATABLE :: IIV1(:,:),JJV1(:,:)
+
+ REAL(4), ALLOCATABLE :: dist(:,:),PW1(:)
+
+ integer(4) IH1(4),JH1(4),IV1(4),JV1(4)
+
+ REAL(8) CLON_NEW,CLAT_NEW,CLON_NHC,CLAT_NHC
+ REAL(4) CLON_NEW1,CLAT_NEW1
+
+ REAL(4) th1(IR1),rp(IR1) ! ,RMN
+
+ REAL(4) zmax,PW(121)
+ REAL(4) PW_S(121),PW_M(121)
+! REAL(4) PW_S(85),PW_M(85),PW_D(85)
+
+ integer Ir_v4(4)
+ CHARACTER SN*1,EW*1,DEPTH*1
+!zhang:added basin domain shift option
+ CHARACTER*2 :: basin
+
+! DATA PW_S/30*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,45*0./
+ DATA PW_S/42*1.0,0.95,0.9,0.85,0.8,0.75,0.7, &
+ 0.65,0.6,0.55,0.5,0.45,0.4,0.35,0.3, &
+ 0.25,0.2,0.15,0.1,0.05,60*0./
+! DATA PW_S/30*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,45*0./ ! 850-700mb
+! DATA PW_M/38*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,37*0./ ! 850-400mb
+ DATA PW_M/50*1.0,0.95,0.9,0.85,0.8,0.75,0.7, &
+ 0.65,0.6,0.55,0.5,0.45,0.4,0.35,0.3, &
+ 0.25,0.2,0.15,0.1,0.05,52*0./
+
+ COEF1=Rd/Cp
+ COEF3=Rd*GAMMA/G
+ COEF2=1./COEF3
+
+ GRD=G/Rd
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi
+ rad=1./pi_deg
+
+ arad=6.371E6*rad
+ DST1=6.371E6*rad
+
+ READ(5,*)ITIM,basin,iflag_cold
+
+
+! READ NEW GFS Env. DATA (New Domain)
+
+ IUNIT=20+ITIM
+
+ READ(IUNIT) NX,NY,NZ,I360
+
+ print*,'NX,NY,NZ=',NX,NY,NZ,I360
+
+ NX1=NX+1
+ NY1=NY+1
+ NZ1=NZ+1
+
+ KMX=121
+ KMX2=60
+
+ ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+ ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+ ALLOCATE ( Z1(NX,NY,NZ+1),P1(NX,NY,NZ+1) )
+ ALLOCATE ( GLON(NX,NY),GLAT(NX,NY) )
+ ALLOCATE ( PD1(NX,NY),ETA1(NZ+1),ETA2(NZ+1) )
+ ALLOCATE ( USC(NX,NY),VSC(NX,NY) ) ! Env. wind at new grids
+
+ ALLOCATE ( HLON(NX,NY),HLAT(NX,NY) )
+ ALLOCATE ( VLON(NX,NY),VLAT(NX,NY) )
+
+ ALLOCATE ( PCK(NZ),TEK(NZ),TEK42(KMX2) )
+ ALLOCATE ( dist(NX,NY) )
+ ALLOCATE ( PMID1(NX,NY,NZ),ZMID1(NX,NY,NZ) )
+
+ READ(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) PMID1
+ READ(IUNIT) T1
+ READ(IUNIT) Q1
+ READ(IUNIT) U1
+ READ(IUNIT) V1
+ READ(IUNIT) DZDT
+ READ(IUNIT) Z1
+! READ(IUNIT) GLON,GLAT
+ READ(IUNIT) HLON,HLAT,VLON,VLAT
+ READ(IUNIT) P1
+ READ(IUNIT) PD1
+ READ(IUNIT) ETA1
+ READ(IUNIT) ETA2
+
+ READ(IUNIT) USC
+ READ(IUNIT) VSC
+
+ CLOSE(IUNIT)
+
+ ALLOCATE ( SLP1(NX,NY),RIJ(NX,NY) )
+ ALLOCATE ( ZS1(NX,NY),TS1(NX,NY),QS1(NX,NY) )
+
+ ALLOCATE ( USCM(NX,NY),VSCM(NX,NY) )
+ ALLOCATE ( P_S(NX,NY),P_A(NX,NY) )
+
+ ALLOCATE ( T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY) )
+
+! First, compute variables at surface level (SLP1,TS1,QS1)
+
+
+ DO J=1,NY
+ DO I=1,NX
+ GLON(I,J)=HLON(I,J)
+ GLAT(I,J)=HLAT(I,J)
+ END DO
+ END DO
+
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ZMID1(I,J,K)=0.5*(Z1(I,J,K)+Z1(I,J,K+1))
+ TV1=T1(I,J,K)*(1.+D608*Q1(I,J,K))
+ ZMID1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5+ &
+ 0.5*TV1/GAMMA*(2.-(P1(I,J,K)/PMID1(I,J,K))**COEF3- &
+ (P1(I,J,K+1)/PMID1(I,J,K))**COEF3)
+! THET1(I,J,K)=T1(I,J,K)*(1.E6/PMID1(I,J,K))**COEF1
+ ENDDO
+ ENDDO
+ ENDDO
+
+ DO J=1,NY ! given variables from domain 1
+ DO I=1,NX ! in case there is no data from domain 2
+ ZS1(I,J)=Z1(I,J,1)
+ TS1(I,J) =T1(I,J,1)+GAMMA*(ZMID1(I,J,1)-Z1(I,J,1))
+ QS1(I,J) =Q1(I,J,1)
+ ENDDO
+ ENDDO
+
+
+!C COMPUTE SEA LEVEL PRESSURE.
+!C
+ DO J=1,NY
+ DO I=1,NX
+ ZSF1 = ZMID1(I,J,1)
+ PSF1 = PMID1(I,J,1)
+ TV1 = T1(I,J,1)*(1.+D608*Q1(I,J,1))
+ A = (GAMMA * ZSF1) / TV1
+ SLP1(I,J) = PSF1*(1+A)**COEF2
+ ENDDO
+ ENDDO
+
+ SLP1_MEAN=0.
+ SUM11=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP1_MEAN=SLP1_MEAN+SLP1(I,J)
+ SUM11=SUM11+1.
+ ENDDO
+ ENDDO
+
+ SLP1_MEAN=SLP1_MEAN/SUM11
+
+! correct to surface pert P
+
+ JM1=0.5*NY
+ IM1=0.5*NX
+
+ SLP_AVE=0.
+ SLP_SUM=0.
+ DO J=JM1-100,JM1+100
+ DO I=IM1-50,IM1+50
+ SLP_AVE=SLP_AVE+SLP1(I,J)
+ SLP_SUM=SLP_SUM+1.
+ END DO
+ END DO
+
+ SLP_AVE=SLP_AVE/SLP_SUM
+
+ SLP_MIN=1.E20
+ DO J=JM1-20,JM1+20
+ DO I=IM1-10,IM1+10
+ IF(SLP_MIN.GT.SLP1(I,J))THEN
+ SLP_MIN=SLP1(I,J)
+ END IF
+ END DO
+ END DO
+
+ DP_CT=min(0.,SLP_MIN-SLP_AVE)
+
+! compute 10m wind
+
+ IUNIT=40+ITIM
+
+ READ(IUNIT) JX,JY
+
+ ALLOCATE ( A101(JX,JY),B101(JX,JY),C101(JX,JY) )
+
+ READ(IUNIT) !LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) !PM1
+ READ(IUNIT) !T1
+ READ(IUNIT) !Q1
+ READ(IUNIT) !U1
+ READ(IUNIT) !V1
+ READ(IUNIT) !DZDT ! new
+ READ(IUNIT) !Z1
+ READ(IUNIT) !HLON,HLAT,VLON,VLAT
+ READ(IUNIT) !P1
+ READ(IUNIT) !PD ! surface pressure
+ READ(IUNIT) !ETA1
+ READ(IUNIT) !ETA2
+ READ(IUNIT) A101
+ READ(IUNIT) B101
+ READ(IUNIT) C101
+
+ CLOSE(IUNIT)
+
+ PRINT*,'JX,JY,NX,NY=',JX,JY,NX,NY
+
+ DO J=1,NY
+ DO I=1,NX
+ USC(I,J)=U1(I,J,1)
+ VSC(I,J)=V1(I,J,1)
+ END DO
+ END DO
+
+! finsih compute 10m wind
+
+
+ WRITE(62)((SLP1(I,J),I=1,NX),J=1,NY,2)
+ DO K=1,NZ+1
+ WRITE(62)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ+1
+ WRITE(62)((P1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(62)((T1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(62)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(62)((U1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(62)((V1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+
+ WBD=-(NX-1)*DLMD
+ SBD=-((NY-1)/2)*DPHD
+
+ write(*,*)'DLMD,DPHD,PT,PDTOP=',DLMD,DPHD,PT,PDTOP
+ write(*,*)'WBD,SBD,CENTRAL_LON,CENTRAL_LAT=', &
+ WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+ do k=1,nz1
+ write(*,*)'K,ETA1,ETA2=',K,ETA1(k),ETA2(k)
+ end do
+
+! print*,'CLON,CLAT=',GLON(1+(NX-1)/2,1+(NY-1)/2), &
+! GLAT(1+(NX-1)/2,1+(NY-1)/2)
+ print*,'CLON,CLAT=',GLON(1+(NX-1)/2,1+(NY-1)/2), &
+ GLAT(1+(NX-1)/2,1+(NY-1)/2)
+ print*,'SLON,SLAT=',GLON(1,1), &
+ GLAT(1,1)
+
+
+! LON & LAT at U,V
+
+ print*,'HLAT,HLON,VLAT,VLON=', &
+ HLAT(1,1),HLON(1,1),VLAT(1,1),VLON(1,1)
+
+! write(70,*)
+! write(70,33)((HLON(I,J),I=1,NX,10),J=1,NY,20)
+! write(70,*)
+! write(70,33)((HLAT(I,J),I=1,NX,10),J=1,NY,20)
+! write(70,*)
+ 33 format(15F8.1)
+! 34 format(10F12.1)
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+!!!!! READ TC vital
+
+ rewind 11
+
+ read(11,11)id_storm,ICLAT,SN,ICLON,EW,Ipsfc,Ipcls, &
+ Irmax,ivobs,Ir_vobs,(Ir_v4(I),I=1,4),DEPTH
+ 11 format(5x,I2,26x,I3,A1,I5,A1,9x,I4,1x,I4,1x,I4,I3,I4,4I5,1x,A1)
+
+ rewind 11
+
+ CLAT_NHC=ICLAT*0.1
+ CLON_NHC=ICLON*0.1
+ vobs=ivobs*1.0 ! m/s
+ vobs_o=vobs
+ VRmax=Ir_vobs*1. ! in km
+
+ if(VRmax.lt.19.)VRmax=19.
+
+! if(id_storm.lt.50.and.Ipsfc.gt.1005)Ipsfc=1005
+
+ psfc_obs=Ipsfc*100.
+ psfc_cls=Ipcls*100.
+
+ PRMAX=Irmax*1.
+ Rctp=Irmax*1. ! in km
+
+ cost=cos(CLAT_NHC*rad)
+
+ print*,'vobs=',vobs
+
+ OPEN(69,file='flag_file',form='formatted')
+ READ(69,*)IFLAG
+ READ(69,*)K850
+ READ(69,*)TWMAX1,RWMAX1,fact_v,psfc_obs
+ CLOSE(69)
+
+ PRINT*,'IFLAG,K850=',IFLAG,K850
+ PRINT*,'TWMAX1,RWMAX1=',TWMAX1,RWMAX1
+
+ dp_obs=psfc_cls-psfc_obs
+
+ print*,'Ir_vobs,VRmax=',Ir_vobs,VRmax
+
+ IF(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+ IF(EW.eq.'W')CLON_NHC=-CLON_NHC
+ if(I360.eq.360) then
+ IF(CLON_NHC.gt.0.)CLON_NHC=CLON_NHC-360.
+ endif
+
+! PW=1.
+! IF(DEPTH.eq.'S')THEN
+! DO k=1,kmx
+! PW(k)=PW_S(k)
+! END DO
+! ELSE IF(DEPTH.eq.'M')THEN
+! DO k=1,kmx
+! PW(k)=PW_M(k)
+! END DO
+! ELSE
+! PW=1.
+! END IF
+
+ distm=1.E20
+ do j=1,ny
+ do i=1,nx
+ distt=((HLON(i,j)-CLON_NHC)*cost)**2+(HLAT(i,j)-CLAT_NHC)**2
+ if(distm.gt.distt)then
+ distm=distt
+ ictr=i
+ jctr=j
+ end if
+ end do
+ end do
+ imn1=ictr-2
+ imx1=ictr+2
+ jmn1=jctr-2
+ jmx1=jctr+2
+
+
+ do k=1,nz
+ tek(k)=T1(ictr,jctr,k)
+ pck(K)=EXP((ALOG(P1(ictr,jctr,K))+ALOG(P1(ictr,jctr,K+1)))*0.5)
+ end do
+
+ delt_z1=0.
+ pt_c=1.e20
+ sum1=0.
+ do j=jmn1,jmx1
+ do i=imn1,imx1
+! dist=(((HLON(i,j)-CLON_NHC)*cost)**2+ &
+! (HLAT(i,j)-CLAT_NHC)**2)
+ dist1=1.
+ sum1=sum1+dist1
+ if(pt_c.gt.slp1(i,j))pt_c=slp1(i,j)
+ delt_z1=delt_z1+0.5*(Z1(i,j,2)-Z1(i,j,1))
+ end do
+ end do
+
+ delt_z1=delt_z1/float((jmx1-jmn1+1)*(imx1-imn1+1))
+ psfc_env=pt_c
+
+ psfc_obs1=min(0.,psfc_obs-psfc_env)
+
+! something wrong with the data
+
+ print*,'psfc_obs,psfc_env=',psfc_obs,psfc_env
+
+! existing hurricane component (approximate only)
+
+ vobs_kt=1.944*vobs
+ vmax1=0.
+ d_max=3.5
+ IF(vobs.gt.30..and.CLAT_NHC.gt.30.)d_max=4.5
+
+ DO J=1,NY
+ DO I=1,NX
+! if(A101(I,J).LT.0.5)then ! A101 = land sea mask, B101 = ZNT
+! z0=B101(I,J)
+! z0=max(z0,(0.085*vobs-0.58)*1.E-3)
+! else
+! z0=(0.085*vobs-0.58)*1.E-3
+! end if
+! IF(vobs_kt.gt.60.)then
+! ct_10m=1.12*log(10./z0)/log(delt_z1/z0)
+! u10=USC(I,J)*ct_10m-3.7037
+! v10=VSC(I,J)*ct_10m-3.7037
+! else
+! ct_10m=log(10./z0)/log(delt_z1/z0)
+! u10=USC(I,J)*ct_10m
+! v10=VSC(I,J)*ct_10m
+! end if
+! vmax2=u10**2+v10**2
+ vmax2=sqrt(USC(I,J)**2+VSC(I,J)**2)*C101(I,J)
+ dist(i,j)=sqrt(((VLON(i,j)-CLON_NHC)*cost)**2+ &
+ (VLAT(i,j)-CLAT_NHC)**2)
+ if(vmax2.gt.vmax1.and.dist(i,j).lt.d_max)then
+ vmax1=vmax2
+ imax1=I
+ jmax1=j
+ end if
+ END DO
+ END DO
+
+ print*,'I,J,vmax=',imax1,jmax1,vmax1
+
+ RMX_d=1.2*sqrt(((VLON(imax1,jmax1)-CLON_NHC)*cost)**2+ &
+ (VLAT(imax1,jmax1)-CLAT_NHC)**2)
+
+
+ IF(RMX_d.gt.3.5)RMX_d=3.5
+ IF(RMX_d.lt.2.0)RMX_d=2.0
+! IF(RMX_d.lt.3.0)RMX_d=3.0
+
+ IF(vobs.gt.30..and.CLAT_NHC.gt.30.)RMX_d=min(RMX_d,4.5)
+
+! convert 10m wind to lowest level wind
+
+ if(A101(imax1,jmax1).LT.0.5)then ! A101 = land sea mask, B101 = ZNT
+ z0=B101(imax1,jmax1)
+ z0=max(z0,(0.085*vobs-0.58)*1.E-3)
+ else
+ z0=(0.085*vobs-0.58)*1.E-3
+ end if
+
+! 7.2/1.944=3.7037
+
+! vobs_kt=1.944*vobs
+! IF(vobs_kt.gt.60.)then
+! vobs=(3.7037+vobs)/1.12*log(delt_z1/z0)/log(10./z0)
+! else
+! vobs=vobs*log(delt_z1/z0)/log(10./z0)
+! end if
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ if(dist(i,j).lt.RMX_d)then
+ vmax2=sqrt(USC(I,J)**2+VSC(I,J)**2)*C101(I,J)
+ if(vmax2.gt.vmax1)then
+ vmax1=vmax2
+ imax1=I
+ jmax1=j
+ end if
+ end if
+ END DO
+ END DO
+
+ vmax_s_b=vmax1
+
+ vobs=vobs_o/(C101(imax1,jmax1)+1.E-10)
+
+ vobs=vobs+0.1
+
+ print*,'level 1 vobs, z0=',vobs,z0,A101(imax1,jmax1)
+
+! READ Hurricane Pert.
+
+ ALLOCATE ( PCST(KMX),HP(NX,NY,KMX),HV(NX,NY,KMX) )
+
+ ALLOCATE ( SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMX) )
+ ALLOCATE ( T_1(NX,NY,KMX),Q_1(NX,NY,KMX) )
+ ALLOCATE ( U_1(NX,NY,KMX),V_1(NX,NY,KMX) )
+
+ ALLOCATE ( U_S(NX,NY),V_S(NX,NY) )
+ ALLOCATE ( U_A(NX,NY),V_A(NX,NY) )
+
+ ALLOCATE ( USC_1(NX,NY),VSC_1(NX,NY) ) ! hurricane component wind at z=0
+ ALLOCATE ( USC1(NX,NY),VSC1(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( USC11(NX,NY),VSC11(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( USC2(NX,NY),VSC2(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( SLPV(NX,NY) )
+
+ ALLOCATE ( T21(NX,NY,KMX,4),Q21(NX,NY,KMX,4) )
+ ALLOCATE ( U21(NX,NY,KMX,4),V21(NX,NY,KMX,4) )
+ ALLOCATE ( SLP21(NX,NY,4) )
+ ALLOCATE ( PMV1(NX,NY,NZ),PMV2(NX,NY,NZ) )
+
+ ALLOCATE ( T_4(NX,NY,KMX),Q_4(NX,NY,KMX) )
+
+ ALLOCATE ( WRK1(KMX),WRK2(KMX),WRK3(KMX),WRK4(KMX) )
+
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+
+ RMX_d=RMX_d*fact_v
+
+ print*,'inside hwrf_anl_cs_10m.f RMX_d=',RMX_d
+
+ vobs1=vobs-TWMAX1
+
+! make the composite storm to have the same radius as the analysis
+
+! fact=RWMAX1/RWMAX ! vrmax=RWMAX1
+
+ RWMAX1=vrmax
+
+! if(fact.gt.1.5)fact=1.5
+! if(fact.lt.0.5)fact=0.5
+
+! READ the stored symmetric storm
+
+
+ ALLOCATE ( U_2SB(IR1,KMX),T_2SB(IR1,KMX),SLP_2SB(IR1) )
+ ALLOCATE ( R_2SB(IR1,KMX),temp_e(KMX),RADIUS2(IR1) )
+
+ REWIND(85)
+ READ(85)RMN
+
+ CALL axisym_xy_new(NX,NY,NZ,KMX,HLON,HLAT,VLON,VLAT, &
+ CLON_NHC,CLAT_NHC,SLP_1,T_1,Q_1,U_1,V_1, &
+ TH1,RADIUS2,SLPE,TENV,PCST,HP,HV,ZMAX,vobs1, &
+ dp_obs,psfc_obs,RWMAX1,PRMAX,RMN, &
+ U_2SB,T_2SB,SLP_2SB,R_2SB,temp_e,DEPTH,SN)
+
+ k850=1 ! use surface wind
+
+
+ ALLOCATE ( PCST1(NX,NY,KMX),PCST2(KMX),PCSK(KMX2) )
+
+ KST=1
+
+ CLON_NEW=CLON_NHC
+ CLAT_NEW=CLAT_NHC
+
+ print*,'zmax=',zmax
+
+!!!!!!!!!!!!!!!!!!!!
+
+
+ USC_1=0.
+ VSC_1=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ USC_1(I,J)=U_1(I,J,1)
+ VSC_1(I,J)=V_1(I,J,1)
+ END DO
+ END DO
+
+ USC1=USC_1
+ VSC1=VSC_1
+
+ DO N=1,KMX2
+ PCSK(N)=PCST(2*N)*SLP1_MEAN/PCST(1)
+ END DO
+
+ DO N=1,KMX2
+ IF(PCSK(N).GE.PCK(1))THEN ! Below PCK(1)
+ TEK42(N)=TEK(1)
+ ELSE IF (PCSK(N).LE.PCK(NZ))THEN
+ TEK42(N)=TEK(NZ)
+ ELSE
+! DO K=1,KMX2-1
+ DO K=1,NZ-1
+ IF(PCSK(N).LE.PCK(K).and.PCSK(N).GT.PCK(K+1))THEN
+ W1=ALOG(1.*PCK(K+1))-ALOG(1.*PCK(K))
+ W=(ALOG(1.*PCSK(N))-ALOG(1.*PCK(K)))/W1
+ TEK42(N)=TEK(K)*(1.-W)+TEK(K+1)*W
+ GO TO 447
+ END IF
+ END DO
+ END IF
+ 447 CONTINUE
+ ENDDO
+
+! ENV. wind
+
+ USCM=USC
+ VSCM=VSC
+
+!!!!!!!!!!!!!!!!!!!!
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ vmax2=sqrt(USC1(I,J)**2+VSC1(I,J)**2)*C101(I,J)
+ if(vmax2.gt.vmax1.and.dist(i,j).lt.RMX_d)then
+ vmax1=vmax2
+ end if
+ END DO
+ END DO
+
+ vmax_s=vmax1
+
+! crtn=max(vobs_o-vmax_s_b,0.)/vmax_s
+ crtn=1.0
+
+ print*,'hwrf_anl_cs, crtn=',crtn
+
+ vmax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ USC11(I,J)=USC1(I,J)*crtn
+ VSC11(I,J)=VSC1(I,J)*crtn
+! vmax2=sqrt((USC11(I,J)+USCM(I,J))**2+ &
+! (VSC11(I,J)+VSCM(I,J))**2)*C101(I,J)
+ vmax2=sqrt((USCM(I,J))**2+ &
+ (VSCM(I,J))**2)*C101(I,J)
+ if(vmax2.gt.vmax1.and.dist(i,j).lt.RMX_d)then
+ vmax1=vmax2
+ imax1=I
+ jmax1=j
+ end if
+ END DO
+ END DO
+
+ vobs=vobs_o/(C101(imax1,jmax1)+1.E-10)
+
+ print*,'I,J,vmax,vobs=',imax1,jmax1,vmax1,vobs
+
+ iter=0
+ beta=1.0
+
+ 876 CONTINUE
+
+ VMAX=0.
+ DO J=1,NY
+ DO I=1,NX
+! I=imax1
+! J=jmax1
+ UUT=beta*USC11(I,J)+USCM(I,J)
+ VVT=beta*VSC11(I,J)+VSCM(I,J)
+ FF=SQRT((UUT*UUT+VVT*VVT))*C101(I,J)
+! R_DIST=sqrt(((VLON(I,J)-CLON_NHC)*cost)**2+ &
+! (VLAT(I,J)-CLAT_NHC)**2)
+ R_DIST=dist(i,j)
+ IF(VMAX.LT.FF.and.R_DIST.lt.RMX_d)THEN
+ VMAX=FF
+ IMV=I
+ JMV=J
+ END IF
+ END DO
+ END DO
+
+ PRINT*,'I,J,USC11,VSC11,USCM,VSCM=',USC11(IMV,JMV), &
+ VSC11(IMV,JMV),USCM(IMV,JMV),VSCM(IMV,JMV)
+ PRINT*,'I,J,VMAX=',IMV,JMV,SQRT(VMAX)
+
+! IMV=imax1
+! JMV=jmax1
+
+ vobs=vobs_o/(C101(IMV,JMV)+1.E-10)
+
+! UU11=beta*USC11(IMV,JMV)
+! VV11=beta*VSC11(IMV,JMV)
+ UU11=USC11(IMV,JMV)
+ VV11=VSC11(IMV,JMV)
+ UUM1=USCM(IMV,JMV)
+ VVM1=VSCM(IMV,JMV)
+ QQ1=(uu11**2+vv11**2)*vobs**2-(vv11*uum1-uu11*vvm1)**2
+! QQ=sqrt((uu11**2+vv11**2)*vobs**2-(vv11*uum1-uu11*vvm1)**2)
+
+ uv22=sqrt(uu11**2+vv11**2)
+
+ print*,'max hurricane pert=',uv22
+
+ if(QQ1.lt.0.)then
+ QQ=0.
+ beta1=0.0
+ else
+ QQ=sqrt(QQ1)
+ beta1=(-(uum1*uu11+vvm1*vv11)+QQ)/(uu11**2+vv11**2+1.E-20)
+ end if
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+! beta=beta*beta1
+ beta=beta1
+ iter=iter+1
+ print*,'iter,beta=',iter,beta
+
+!zhan based in Qingfu's comment IF(iter.lt.3)go to 876
+ IF(iter.lt.1)go to 876
+
+ beta=beta*crtn
+
+ print*,'iter,beta=',iter,beta
+
+ if(beta.lt.0.)beta=0.
+
+! if(beta.gt.1.25) beta=max(1.25,sqrt(beta))
+
+!!! beta=0.8
+
+
+! if(vobs.lt.24.)then
+! if(abs(CLAT_NHC).lt.15.)beta=max(beta,10./vmax_s)
+! end if
+
+ vmax_1=0.
+ DO J=1,NY
+ DO I=1,NX
+ USC2(I,J)=beta*USC1(I,J)+USCM(I,J)
+ VSC2(I,J)=beta*VSC1(I,J)+VSCM(I,J)
+ ff=sqrt(USC2(I,J)**2+VSC2(I,J)**2)*C101(I,J)
+ IF(vmax_1.lt.ff.and.dist(i,j).lt.RMX_d)THEN
+ vmax_1=ff
+ imax12=i
+ jmax12=j
+ end if
+ END DO
+ END DO
+
+ print*,'after beta correction'
+ print*,'10m vmax,i,j=',vmax_1,imax12,jmax12
+
+! now modify the horricane component (by beta)
+
+! for analysis, set T_1=0. Q_1=0.
+
+! T_1=0.
+! Q_1=0.
+
+!
+ T_4=T_1
+ Q_4=Q_1
+
+ print*,'CLON_NEW,CLAT_NEW=',CLON_NEW,CLAT_NEW
+
+ ff0=2.*7.292E-5*sin(clat_new*rad)
+
+ ps_min=1.E20
+ do j=1,NY
+ do i=1,NX
+ if(ps_min.gt.SLP_1(i,j))then
+ ps_min=SLP_1(i,j)
+ i_psm=i
+ j_psm=j
+ end if
+ end do
+ end do
+ print*,'storm center 3 =',HLON(i_psm,j_psm),HLAT(i_psm,j_psm),ps_min
+
+! compute central surface pressure based on the model correlation PS_C1
+
+ rewind(23)
+
+ read(23)IR2,IR_1,JX,JY,JZ,KMX1
+
+ print*,'KMX,KMX1=',KMX,KMX1
+
+ ALLOCATE ( RADIUS(IR2),U_2S(IR2,KMX1),V_2S(IR2,KMX1) )
+ ALLOCATE ( T_2S(IR2,KMX1),Q_2S(IR2,KMX1),SLP_2S(IR2) )
+ ALLOCATE ( CFT(IR2),RKX1(IR2),U_2S1(IR2,KMX1),U_2S2(IR2) )
+ ALLOCATE ( strm1(IR2),strm2(IR2),PW1(KMX1) )
+
+ read(23)RADIUS
+ read(23)CLON_NEW1,CLAT_NEW1
+ read(23)U_2S,V_2S,U_2S1
+ read(23)T_2S,Q_2S,SLP_2S
+ read(23)CFT,PW1,beta11
+ read(23)
+
+ PW=1.0
+
+ IF((iflag_cold.eq.1).and.DEPTH.eq.'M')THEN
+ DO k=1,kmx
+ PW(k)=PW_M(k)
+ END DO
+ END IF
+ IF((DEPTH.eq.'S').or.(id_storm.ge.90))THEN
+ DO k=1,kmx
+ PW(k)=PW_S(k)
+ END DO
+ END IF
+
+ do k=1,kmx
+ print*,'PW(k)=',k,PW(k)
+ end do
+
+ RKX1=0.
+ DO n=1,IR2
+ RKX1(n)=RADIUS(n)*DST1
+ END DO
+
+ DO n=1,IR1
+ RADIUS2(n)=RADIUS2(n)/DST1
+ END DO
+
+ print*,'RADIUS,RADIUS2=',RADIUS(1),RADIUS2(1)
+
+ U_2S2=0.
+
+ JST1=1
+ DO J=1,IR2
+ DIF=RADIUS2(1)-RADIUS(J)
+ IF(DIF.GE.0.)THEN
+ U_2S2(J)=U_2SB(1,1)
+ JST1=J
+ END IF
+ END DO
+
+ print*,'test JST1=',JST1
+
+ DO J=JST1,IR2
+ U_2S3=0.
+ DO N=2,IR1
+ DIF=RADIUS2(N)-RADIUS(J)
+ IF(DIF.GE.0.)THEN
+ WT1=(RADIUS(J)-RADIUS2(N-1))/ &
+ (RADIUS2(N)-RADIUS2(N-1))
+ WT2=1.-WT1
+ U_2S3=WT1*U_2SB(N,1)+WT2*U_2SB(N-1,1)
+ GO TO 55
+ END IF
+ END DO
+ 55 CONTINUE
+ U_2S2(J)=U_2S1(J,1)+beta*U_2S3
+ END DO
+
+ print*,'test3333'
+
+ k=1
+ k1=2
+
+ strm1=0.
+ strm2=0.
+ DO n=IR2-1,1,-1
+ strm11=max(0.,U_2S(n,1))
+ strm22=max(0.,U_2S2(n))
+ force=(strm11/(RKX1(n)+1.E-20)+ff0)*strm11
+ strm1(n)=strm1(n+1)-force*(RKX1(n+1)-RKX1(n))
+ force2=(strm22/(RKX1(n)+1.E-20)+ff0)*strm22
+ strm2(n)=strm2(n+1)-force2*(RKX1(n+1)-RKX1(n))
+ END DO
+
+ print*,'strm2(1),strm1(1)=',strm2(1),strm1(1)
+
+ PS_C2=SLP_2S(1)*strm2(1)/(strm1(1)-1.E-20)
+
+ PS_C1=PS_C2-SLP_2S(1)*cft(1)
+
+ PS_C1=psfc_obs1
+
+ print*,'PS_C1=',PS_C1
+
+
+ ics=1
+ fact=1.0
+
+ DO K=1,KMX
+ DO J=1,NY
+ DO I=1,NX
+ U_1(I,J,K)=U_1(I,J,K)*beta*PW(k)
+ V_1(I,J,K)=V_1(I,J,K)*beta*PW(k)
+ END DO
+ END DO
+ END DO
+
+
+ CALL CORT_MAT_2(IR1,NX,NY,KMX2,KMX,U_2SB, &
+ T_2SB,SLP_2SB,R_2SB,RADIUS2,temp_e,TEK42, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW,PS_C1, &
+ beta,fact,ics,SN)
+
+ DO J=1,NY
+ DO I=1,NX
+! SLP_1(I,J)=SLP_1(I,J)+SLP_X(I,J)
+ SLP_1(I,J)=SLP_X(I,J)
+ END DO
+ END DO
+
+! new
+! pt_c1=0.
+! sum1=0.
+! do j=jmn1,jmx1
+! do i=imn1,imx1
+! sum1=sum1+1.
+! pt_c1=pt_c1+SLP_1(I,J)
+! end do
+! end do
+
+! pt_c1=pt_c1/sum1
+
+ pt_c1=0.
+ DO J=1,NY
+ DO I=1,NX
+ IF(pt_c1.LT.SLP_1(I,J))THEN
+ pt_c1=SLP_1(I,J)
+ END IF
+ END DO
+ END DO
+! pt_c1=pt_c1+50.
+
+! ps_rat=0.5*(psfc_obs1+PS_C1)/PS_C1
+
+! ps_rat=0.5*(psfc_obs1+pt_c1)/(pt_c1-1.e-20)
+
+ ps_rat=1.0
+ if(abs(pt_c1).lt.20.)then
+ ps_rat=1.0
+ else
+ ps_rat=psfc_obs1/(pt_c1-1.e-20)
+ end if
+
+ print*,'ps_rat=',ps_rat,psfc_obs1,pt_c1
+
+ if(ps_rat.gt.10.)ps_rat=10.0
+ if(ps_rat.lt.(-10.))ps_rat=-10.0
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*ps_rat
+ END DO
+ END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+! T_1(I,J,K)=(T_1(I,J,K)+T_X(I,J,K))*PW(k)
+! Q_1(I,J,K)=(Q_1(I,J,K)+Q_X(I,J,K))*PW(k)
+ T_1(I,J,K)=T_X(I,J,K)*PW(k)*ps_rat
+! Q_1(I,J,K)=Q_X(I,J,K)*PW(k)
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ END DO
+ END DO
+ END DO
+
+ T_4=0. ! using guess field temp & water vapor instead of double count
+ Q_4=0.
+
+
+ print*,'complete CORT'
+
+
+
+!??????????????????
+
+ DO J=1,NY
+ DO I=1,NX
+ SLP1(I,J) = SLP1(I,J)+SLP_1(I,J)
+ TENV1 = TS1(I,J)
+ TS1(I,J) = TENV1+T_1(I,J,1)
+ T_OLD = TENV1+T_4(I,J,1)
+ Q_OLD = QS1(I,J)+Q_4(I,J,1)
+ ESRR = exp(4302.645*(TS1(I,J)-T_OLD)/ &
+ ((TS1(I,J)-29.66)*(T_OLD-29.66))) ! 4302.645=17.67*243.5
+ QS1(I,J) = Q_OLD + (ESRR-1.)*Q_OLD ! Assuming RH=CONST. before & after
+ ENDDO
+ ENDDO
+
+! WRITE(25)((SLP1(I,J),I=1,NX),J=1,NY,2)
+
+
+!
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+! DO K=1,NZ
+! DO J=1,NY
+! DO I=1,NX
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ENDDO
+! ENDDO
+! ENDDO
+
+! add hurricane wind components
+
+ DO J=1,NY
+ DO I=1,NX
+ DO N=1,KMX
+! PCST1(I,J,N)=HP(I,J,N)
+! PCST1(I,J,N)=PMID1(I,J,1)*PCST(N)/PCST(1)
+ PCST1(I,J,N)=PCST(N)*SLP1_MEAN/PCST(1)
+ END DO
+ END DO
+ END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ WRK1(K) = T_1(I,J,K)
+ WRK2(K) = Q_1(I,J,K)
+ END DO
+ DO N=1,NZ
+ TENV1 = T1(I,J,N)
+ QENV1 = Q1(I,J,N)
+ IF(PMID1(I,J,N).GE.PCST1(I,J,1))THEN ! Below PCST(1)
+ T1(I,J,N)=TENV1+WRK1(1)
+ Q1(I,J,N)=QENV1+WRK2(1)
+ ELSE IF(PMID1(I,J,N).LE.PCST1(I,J,KMX))THEN
+ T1(I,J,N)=TENV1+WRK1(KMX)
+ Q1(I,J,N)=QENV1+WRK2(KMX)
+ ELSE
+ DO K=1,KMX-1
+ IF(PMID1(I,J,N).LE.PCST1(I,J,K).and.PMID1(I,J,N).GT.PCST1(I,J,K+1))THEN
+ W1=ALOG(1.*PCST1(I,J,K+1))-ALOG(1.*PCST1(I,J,K))
+ W=(ALOG(1.*PMID1(I,J,N))-ALOG(1.*PCST1(I,J,K)))/W1
+ T1(I,J,N)=TENV1+WRK1(K)*(1.-W)+WRK1(K+1)*W
+ Q1(I,J,N)=QENV1+WRK2(K)*(1.-W)+WRK2(K+1)*W
+ GO TO 887
+ END IF
+ END DO
+ END IF
+ 887 CONTINUE
+! IF(N.EQ.1)THEN
+! IF(ZMID(I,J,1).GT.10..and.SLP1(I,J).GT.PMID1(I,J,1))THEN
+! PRINT*,'before T1(I,J,1)=',T(I,J,1)
+! T1(I,J,1)=GAMMA*ZMID(I,J,1)/((SLP1(I,J)/PMID1(I,J,1))**COEF3-1.)
+! T1(I,J,1)=T1(I,J,1)/(1.+D608*Q1(I,J,1))
+! PRINT*,'After T1(I,J,1)=',T(I,J,1)
+! TS1(I,J)=T1(I,J,1)+GAMMA*(Z1(I,J,2)-Z1(I,J,1))*0.5
+! END IF
+! END IF
+ ESRR = exp(4302.645*(T1(I,J,N)-TENV1)/ &
+ ((T1(I,J,N)-29.66)*(TENV1-29.66)))
+ Q1(I,J,N)=QENV1+(ESRR-1.)*QENV1
+ END DO
+ ENDDO
+ ENDDO
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TS1(I,J) = T1(I,J,1)+GAMMA*(Z1(I,J,2)-Z1(I,J,1))*0.5
+ QS1(I,J) = Q1(I,J,1)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+! DO K=1,NZ
+! DO J=1,NY
+! DO I=1,NX
+! PMID1(I,J,K)=EXP((ALOG(P1(I,J,K))+ALOG(P1(I,J,K+1)))*0.5)
+! ENDDO
+! ENDDO
+! ENDDO
+
+! Compute Geopotentital height, INTEGRATE HEIGHT HYDROSTATICLY
+
+ do j = 1,ny
+ do i = 1,nx
+ Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)* &
+ (Q1(I,J,L-1)*0.608+1.0)*287.04* &
+ (ALOG(P1(I,J,L-1))-ALOG(P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ END DO
+
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+! ZMID1(I,J,K)=0.5*(Z1(I,J,K)+Z1(I,J,K+1))
+ TV1=T1(I,J,K)*(1.+D608*Q1(I,J,K))
+ ZMID1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5+ &
+ 0.5*TV1/GAMMA*(2.-(P1(I,J,K)/PMID1(I,J,K))**COEF3- &
+ (P1(I,J,K+1)/PMID1(I,J,K))**COEF3)
+ ENDDO
+ ENDDO
+ ENDDO
+
+! interpolate vertically to P level in new coordinate (V Points)
+
+ PMV1=PMID1
+
+! DO J=2,NY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO K=1,NZ
+! DO I=2,NX-1
+! PMV1(I,J,K)=0.25*(PMID1(I,J,K)+PMID1(I+1,J,K)+ &
+! PMID1(I,J-1,K)+PMID1(I,J+1,K))
+! END DO
+! END DO
+! ELSE
+! DO K=1,NZ
+! DO I=2,NX-1
+! PMV1(I,J,K)=0.25*(PMID1(I-1,J,K)+PMID1(I,J,K)+ &
+! PMID1(I,J-1,K)+PMID1(I,J+1,K))
+! END DO
+! END DO
+! END IF
+! END DO
+
+
+ PRINT*,'test01'
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ WRK1(K) = U_1(I,J,K)
+ WRK2(K) = V_1(I,J,K)
+ END DO
+
+ DO N=1,KMX
+! PCST2(N)=HV(I,J,N)
+ PCST2(N)=PMV1(I,J,1)*PCST(N)/PCST(1)
+ END DO
+
+ DO N=1,NZ
+ IF(PMV1(I,J,N).GE.PCST2(1))THEN ! Below PCST(1)
+ U1(I,J,N)=U1(I,J,N)+WRK1(1)
+ V1(I,J,N)=V1(I,J,N)+WRK2(1)
+ ELSE IF(PMV1(I,J,N).LE.PCST2(KMX))THEN
+ U1(I,J,N)=U1(I,J,N)+WRK1(KMX)
+ V1(I,J,N)=V1(I,J,N)+WRK2(KMX)
+ ELSE
+ DO K=1,KMX-1
+ IF(PMV1(I,J,N).LE.PCST2(K).and.PMV1(I,J,N).GT.PCST2(K+1))THEN
+ W1=ALOG(1.*PCST2(K+1))-ALOG(1.*PCST2(K))
+ W=(ALOG(1.*PMV1(I,J,N))-ALOG(1.*PCST2(K)))/W1
+ U1(I,J,N)=U1(I,J,N)+WRK1(K)*(1.-W)+WRK1(K+1)*W
+ V1(I,J,N)=V1(I,J,N)+WRK2(K)*(1.-W)+WRK2(K+1)*W
+ GO TO 888
+ END IF
+ END DO
+ END IF
+ 888 CONTINUE
+ END DO
+ ENDDO
+ ENDDO
+
+
+! based on Ts, Zs, SLP1 ==> PS1 ==> P1
+ PRINT*,'test02'
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = ZS1(I,J)
+ TSFC = TS1(I,J)*(1.+D608*QS1(I,J))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP1(I,J)/(1+A)**COEF2
+ PD1(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD1(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PMID1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD1(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+
+
+ press1=1.E20
+ DO J=1,NY
+ DO I=1,NX
+ if(press1.gt.SLP1(I,J))press1=SLP1(I,J)
+ END DO
+ END DO
+
+ print*,'surgace pressure=',press1
+
+ DO J=1,NY
+ DO I=1,NX
+ U1(I,J,1)=USC2(I,J)
+ V1(I,J,1)=VSC2(I,J)
+ END DO
+ END DO
+
+! WRITE(64)((SLP1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,NZ+1
+! WRITE(64)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(64)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(64)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! WRITE(64)((USCM(I,J),I=1,NX),J=1,NY,2)
+! WRITE(64)((VSCM(I,J),I=1,NX),J=1,NY,2)
+
+ IUNIT=50+ITIM
+
+ WRITE(IUNIT) NX,NY,NZ,I360
+ WRITE(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ WRITE(IUNIT) PMID1
+ WRITE(IUNIT) T1
+ WRITE(IUNIT) Q1
+ WRITE(IUNIT) U1
+ WRITE(IUNIT) V1
+ WRITE(IUNIT) DZDT
+ WRITE(IUNIT) Z1
+! WRITE(IUNIT) GLON,GLAT
+ WRITE(IUNIT) HLON,HLAT,VLON,VLAT
+ WRITE(IUNIT) P1
+ WRITE(IUNIT) PD1
+ WRITE(IUNIT) ETA1
+ WRITE(IUNIT) ETA2
+
+ CLOSE(IUNIT)
+
+ END
+
+
+!=============================================================================
+subroutine dbend(nit,x,y)
+!=============================================================================
+! Evaluate a smooth monotonic increasing blending function y from 0 to 1
+! for x in the interval [0,1] having continuity in at least the first nit
+! derivatives at the ends of this interval. (nit .ge. 0).
+!=============================================================================
+implicit none
+integer,intent(IN ):: nit
+real(4),intent(IN ):: x
+real(4),intent(OUT):: y
+!-----------------------------------------------------------------------------
+integer :: it
+!=============================================================================
+y=2*x-1; do it=1,nit; y=y*(3-y*y)/2; enddo; y=(y+1)/2
+end subroutine dbend
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/convert_axi_xy.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/convert_axi_xy.f90
new file mode 100644
index 000000000..1acb8fe60
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/convert_axi_xy.f90
@@ -0,0 +1,786 @@
+!******************************************************************************
+
+ SUBROUTINE axisym_xy_new(NX,NY,NZ,KMX, &
+ HLON2,HLAT2,VLON2,VLAT2, &
+ CLON_NHC,CLAT_NHC, &
+ SLP_1,T_1,Q_1,U_1,V_1,th1,rp1, &
+ SLPE,TENV,PCST,HP,HV,ZMAX,vobs, &
+ dp_obs,p_obs,vrmax,PRMAX,RMN, &
+ U_2SB,T_2SB,SLP_2SB,R_2SB,temp_e,DEPTH,SN)
+! SUBPROGRAM
+! PRGRMMR
+!
+! ABSTRACT
+!
+! All variables have the same vertical dimension (KMAX=121).
+!
+ INTEGER I,J,K,NX,NY,NZ,ICH
+!
+ PARAMETER (NST=5)
+! PARAMETER (NX=420,NY=820,NZ=42) !* E-grid dimensions
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.)
+ PARAMETER (IR=200,KMAX=121) !* Cylinder dimensions
+ PARAMETER (IR1=IR+1) !* unused extra point
+
+! READ Hurricane Pert.
+
+ REAL(4) HLON2(NX,NY),HLAT2(NX,NY)
+ REAL(4) VLON2(NX,NY),VLAT2(NX,NY) !* E-grid coord
+ REAL(4) PCST(KMAX),HP(NX,NY,KMAX),HV(NX,NY,KMAX)
+
+ REAL(4) SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMAX)
+ REAL(4) T_1(NX,NY,KMAX),Q_1(NX,NY,KMAX) !* adjusted vortex
+ REAL(4) U_1(NX,NY,KMAX),V_1(NX,NY,KMAX) !* on E-grid
+
+ REAL(8) CLON_NHC,CLAT_NHC !* storm lon, lat
+ REAL(8) delc,thac !* vortex lon, lat
+
+ DIMENSION rp(IR1),ps(IR),ps1(IR),ps2(IR),ps_1mb(IR)
+ DIMENSION q(KMAX),p(KMAX,IR) !* pressure on sigma-levels (q)
+ DIMENSION t(KMAX,IR),r(KMAX,IR),ur(KMAX,IR1),th(KMAX,IR1)
+ DIMENSION vrad(KMAX),vtan(KMAX) !^ bogus vortex
+
+ REAL(4), ALLOCATABLE :: RIJ1(:,:),RIJ2(:,:)
+ REAL(4), ALLOCATABLE :: W1(:,:),W2(:,:)
+ INTEGER, ALLOCATABLE :: IDX1(:,:)
+
+ REAL(4) SLPE1,temp_e(KMAX)
+ REAL(4) th1(IR1),rp1(IR1) ! ,RMN !* min radius for filtering
+
+ REAL(4) wrk1(IR),wrk2(IR),wrk3(IR),wrk4(IR)
+ REAL(4) work1(KMAX),WORK2(KMAX)
+
+ REAL(4) U_2SB(IR1,KMAX),T_2SB(IR1,KMAX),SLP_2SB(IR1)
+ REAL(4) V_2SB(IR1,KMAX),R_2SB(IR1,KMAX) !* sigma-level
+
+ DIMENSION RF(24)
+
+ CHARACTER DEPTH*1,SN*1
+! CHARACTER SN*1,EW*1
+
+! rewind 11
+! read(11,11)ICLAT,SN,ICLON,EW
+! 11 format(33x,I3,A1,I5,A1)
+! rewind 11
+
+! CLAT_NHC=ICLAT*0.1
+! CLON_NHC=ICLON*0.1
+
+! IF(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+! IF(EW.eq.'W')CLON_NHC=-CLON_NHC
+
+! CLAT_NHC=25.
+! CLON_NHC=-60.
+
+ eps6=1.E-6
+ pi=4.*atan(1.0)
+ pi180=pi/180. !* deg -> rad
+ arad =6.371E6*pi180 !* deg -> m
+ deg2m=6.371E6*pi180 !* deg -> m
+ cost=cos(CLAT_NHC*pi180)
+
+ zmax=0.
+
+ NHCT=77
+ IF(DEPTH.eq.'S')THEN
+ NHCT=77
+ ELSE IF(DEPTH.eq.'M')THEN
+ NHCT=76
+ ELSE IF(DEPTH.eq.'D'.and.vobs.gt.20.)THEN
+ NHCT=75
+ END IF
+
+ if(p_obs.lt.89510.)then
+ NHCT=77
+ print*,'minimum pressure < 900 mb', p_obs
+ end if
+
+ READ(NHCT)delc,thac !* vortex lon, lat
+
+ READ(NHCT)SLPE1 !* environment SLP (1)
+ READ(NHCT)PCST !* vortex p-levels (kmax)
+ READ(NHCT)temp_e !* environment T (kmax)
+
+ SLPE=SLPE1 !* environment SLP (nx,ny)
+
+ print*,'delc,thac=',delc,thac
+
+ cost_old=cos(thac*pi180) !* vortex cos(lat)
+
+ READ(NHCT)(rp(i),i=1,IR1) !* vortex radius [deg]
+
+ do i=1,IR1
+ rp(i)=arad*rp(i) !* rp(i) = i*dr [m]
+ end do
+ print*,'rp1,2,200=',rp(1),rp(2),rp(IR)
+
+ do k=1,kmax
+ READ(NHCT)(ur(k,i),i=1,IR1) !* vortex radial wind
+ READ(NHCT)(th(k,i),i=1,IR1) !* vortex tangen wind
+ print*,'k,th1,2,200=',k,th(k,1),th(k,2),th(k,IR)
+ if(p_obs.lt.89510.)then
+ do i=1,IR1
+! ur(k,i)=ur(k,i)*0.1 !* reduce convergence
+ ur(k,i)=ur(k,i)*0.5 !* reduce convergence
+ end do
+ else
+ do i=1,IR1
+ ur(k,i)=ur(k,i)*0.1 !* reduce convergence
+ end do
+ end if
+ end do
+
+ READ(NHCT)(ps(i),i=1,IR) !* vortex sfc pressure
+ print*,'ps1,2,200=',ps(1),ps(2),ps(IR)
+
+ do k=1,kmax
+ READ(NHCT)(t(k,i),i=1,IR) !* vortex temperature
+ print*,'k,t1,2,200=',k,t(k,1),t(k,2),t(k,IR)
+ end do
+
+ do k=1,kmax
+ READ(NHCT)(r(k,i),i=1,IR) !* vortex mixing ratio
+ print*,'k,r1,2,200=',k,r(k,1),r(k,2),r(k,IR)
+ end do
+
+ count_smth=0.
+
+ 999 continue !* smooth vortex for large & weak storm <---------------
+
+ TWMAX=1.e-6
+ do i=1,IR
+ th1(i)=th(1,i)
+! twsum=th(1,i)**2+ur(1,i)**2
+ twsum=th(1,i)**2
+ if (twsum.GT.TWMAX) then
+ TWMAX=twsum
+ RWMAX=rp(i)
+ end if
+ end do
+
+ TWMAX=sqrt(TWMAX) !* max tangen wind
+ Rmax_0=RWMAX*0.001 !* RMW (m -> km)
+
+ fact_v=vrmax/Rmax_0 !* alfa=RMW*/RMW
+!CWH print*,'fact=',fact,Rmax_0,vrmax,TWMAX
+
+ fact=fact_v
+ print*,'fact=',fact,Rmax_0,vrmax,TWMAX
+
+! fact=sqrt(fact) ! make it closer to 1
+
+ IF (fact.GT.1.1 .AND. TWMAX.GT.vobs) THEN ! smooth
+ wrk1(1)=(2.*ps(1)+ps(2))/3.
+! wrk1(IR)=(ps(IR-1)+2.*ps(IR))/3.
+ wrk1(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ps(i-1)+ps(i)+ps(i+1))/3.
+ end do
+ do i=1,IR
+ ps(i)=wrk1(i)
+ end do
+ DO k=1,kmax
+ wrk1(1)=(ur(k,1)+ur(k,2))/3.
+ wrk1(IR)=0.
+ wrk2(1)=(th(k,1)+th(k,2))/3.
+ wrk2(IR)=0.
+ wrk3(1)=(2.*t(k,1)+t(k,2))/3.
+! wrk3(IR)=(t(k,IR-1)+2.*t(k,IR))/3.
+ wrk3(IR)=0.
+ wrk4(1)=(2.*r(k,1)+r(k,2))/3.
+! wrk4(IR)=(r(k,IR-1)+2.*r(k,IR))/3.
+ wrk4(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ur(k,i-1)+ur(k,i)+ur(k,i+1))/3.
+ wrk2(i)=(th(k,i-1)+th(k,i)+th(k,i+1))/3.
+ wrk3(i)=(t(k,i-1)+t(k,i)+t(k,i+1))/3.
+ wrk4(i)=(r(k,i-1)+r(k,i)+r(k,i+1))/3.
+ end do
+ do i=1,IR
+ ur(k,i)=wrk1(i)
+ th(k,i)=wrk2(i)
+ t(k,i)=wrk3(i)
+ r(k,i)=wrk4(i)
+ end do
+ END DO
+ count_smth=count_smth+1
+ IF (count_smth.LE.250.) go to 999 !* ------------------------>
+ END IF
+
+ print*,'count_smth=',count_smth !* ===============================
+
+ go to 557
+
+ 556 continue !* UNUSED code for homogenizing ROCI with RMW <- - - - -
+
+ pres_ct=dp_obs/ps(1)
+ do i=1,IR
+ ps_1mb(i)=ps(i)*pres_ct
+ end do
+
+ IRAD_1=1
+ do i=1,IR
+ if (abs(ps_1mb(i)).GT.100.) then
+ IRAD_1=I
+ end if
+ end do
+
+ RAD_1=(IRAD_1+0.5)*(rp(2)-rp(1))*1.E-3
+ fact_p=PRMAX/RAD_1 !* alfa=ROCI*/ROCI
+
+! fact_p=0.5*(fact_p+fact_v)
+ fact_p=fact_v
+
+ print*,'fact,fact_p=',fact,fact_p,PRMAX,RAD_1
+
+ IF (fact .LT. fact_p) THEN !* smooth => fact_p = fact_v
+ wrk1(1)=(2.*ps(1)+ps(2))/3.
+ wrk1(IR)=0.
+ do i=2,IR-1
+ wrk1(i)=(ps(i-1)+ps(i)+ps(i+1))/3.
+ end do
+ do i=1,IR
+ ps(i)=wrk1(i)
+ end do
+ do k=1,kmax
+ wrk3(1)=(2.*t(k,1)+t(k,2))/3.
+ wrk3(IR)=0.
+ wrk4(1)=(2.*r(k,1)+r(k,2))/3.
+ wrk4(IR)=0.
+ do i=2,IR-1
+ wrk3(i)=(t(k,i-1)+t(k,i)+t(k,i+1))/3.
+ wrk4(i)=(r(k,i-1)+r(k,i)+r(k,i+1))/3.
+ end do
+ do i=1,IR
+ t(k,i)=wrk3(i)
+ r(k,i)=wrk4(i)
+ end do
+ end do
+ go to 556 !* - - - - - - - - - - - - - - - - - - - - - - - - ->
+ END IF
+
+ 557 continue
+
+!* 50% contraint for bogus vortex stretch
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ if(fact.lt.0.5)fact=0.5
+ if(fact.gt.1.5)fact=1.5
+
+! fact=1.0
+
+! correct sea level pressure for diff. latitude (UNUSED ps1 by #386)
+
+ ps1=0.
+
+ FC2=2.*7.292E-5*SIN(CLAT_NHC*pi180)
+ FC1=2.*7.292E-5*SIN(thac*pi180)
+ DFC=FC2-FC1
+
+ density=1.1765 ! P/(RT)=101300/(287*300)
+
+ sum_vt=0.
+ do i=IR-1,1,-1
+ sum_vt=sum_vt+0.5*(th(1,i+1)+th(1,i))*(rp(i+1)-rp(i))
+ ps1(i)=ps1(i)+DFC*sum_vt*density
+ end do
+
+! correct sea level pressure for fact (UNUSED ps1 by #386)
+
+ fact1=1./fact-1.
+ sum_vt2=0.
+ do i=IR-1,1,-1
+ th_m=0.5*(th1(i+1)+th1(i))
+ sum_vt2=sum_vt2+th_m**2*(ALOG(rp(i)/rp(i+1)))
+ ps1(i)=ps1(i)+fact1*sum_vt2*density
+! print*,'i,ps1(i)=',i,ps1(i)
+ end do
+
+! * * * * * * * * * *
+
+!* RMW of bogus vortex
+!* ~~~~~~~~~~~~~~~~~~~
+ xxx = 1.E-6
+ DO i = 1,IR
+ yyy = th(1,i)**2
+ IF ( yyy .GT. xxx ) THEN
+ xxx = yyy
+ rmw1 = rp(i)
+ ENDIF
+ ENDDO
+
+!* ROCI of bogus vortex
+!* ~~~~~~~~~~~~~~~~~~~~
+ xxx=dp_obs/ps(1)
+ DO i = 1,IR
+ ps2(i)=ps(i)*xxx
+ ENDDO
+
+ DO i=1,IR
+ IF ( abs(ps2(i)) .GT. 50. ) THEN !* Bogus ROCI ?
+ roc1 = rp(i)
+ ENDIF
+ ENDDO
+
+ roc1 = roc1 + .5*(rp(2)-rp(1))
+ roc1 = max(roc1,2.*rmw1+1.)
+
+!* Observed RMW & ROCI
+!* ~~~~~~~~~~~~~~~~~~~
+ rmw2 = vrmax*1000. !* RMW (km -> m)
+ roc2 = prmax*1000. !* ROCI (km -> m)
+
+ PRINT*, 'Bogus RMW ,Observed RMW [km]: rmw1,vrmax =', rmw1*.001, vrmax
+ PRINT*, 'Bogus ROCI,Observed ROCI [km]: roc1,prmax =', roc1*.001, prmax
+
+!* Stretch factors in meters
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~
+ xxx = .5*rmw1 ; yyy = 1.5*rmw1 !* 50% Constraint
+ rmw2 = max(xxx,min(rmw2,yyy)) !* for bogus stretch
+ xxx = .5*roc1 ; yyy = 1.5*roc1 !* 50% Constraint
+ roc2 = max(xxx,min(roc2,yyy)) !* for bogus stretch
+
+ ddd = 1./(roc1*rmw1*(roc1-rmw1))
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+ bbb = max(-0.05/deg2m,min(bbb,0.05/deg2m))
+
+ aaa = max( 0.5, min(aaa,1.5) )
+
+ iparam = 2 !* Parameters for storm-size correction ?
+
+ IF ( iparam == 1 ) THEN !* ---------------------------------------
+
+ DO i=1,IR1
+ rp(i)=rp(i)*fact !* stretch with RMW only (fact = fact_v)
+ rp1(i)=rp(i)
+ ENDDO
+
+ PRINT*, 'Using 1 parameter for storm-size correction.'
+
+ ELSEIF ( iparam == 2 ) THEN !* -----------------------------------
+
+ DO i=1,IR1
+ rp(i)=aaa*rp(i) + .5*bbb*rp(i)**2 !* stretch with RMW & ROCI
+ rp1(i)=rp(i)
+ ENDDO
+
+ PRINT*, 'Using 2 parameters for storm-size correction.'
+ PRINT*, 'Bogus RMW , Target RMW [m]: rmw1, rmw2 =', rmw1, rmw2
+ PRINT*, 'Bogus ROCI, Target ROCI [m]: roc1, roc2 =', roc1, roc2
+ PRINT*, 'Bogus storm-size factors [m]: aaa, bbb =', aaa, bbb
+ PRINT*, 'Bogus stretch difference 0-10 deg: b*R/2 =', bbb*5.*deg2m
+
+ ENDIF !* ---------------------------------------------------------
+
+! * * * * * * * * * *
+
+! do i=1,IR
+! ps1(i)=ps1(i)*1.2 ! only correct 75%
+! end do
+
+! ps1=0.
+
+!* Correct vortex based on RMN (min radius for filtering)
+
+! rewind(85)
+! read(85)RMN
+! read(85)RF
+
+ print*,'RMN 1=',RMN
+
+! PRMAX2=PRMAX*1000./arad
+! RMN=min(RMN,2.*PRMAX2)
+
+ RMN1=RMN*arad
+
+ if (RMN1.LT.2.5*RWMAX) then
+ RMN1=2.5*RWMAX !* RMN1 >= 2.5*RMW
+ RMN=2.5*RWMAX/arad
+! rewind(85)
+! write(85)RMN
+! write(85)RF
+ print*,'new RMN=',RMN
+ end if
+
+! RMN2=0.5*(RMN1+vrmax*1000.) !* in meter
+! RMN2=max(PRMAX*1000.,RMN2) !* RMN2 >= ROCI*
+ RMN2=0.9*PRMAX*1000.
+
+ do i=1,IR-1
+ if ( RMN2.GE.rp1(i) .AND. RMN2.LT.rp1(i+1) ) then
+ icut1=i+1 !* icut1 -> RMN2
+ end if
+ end do
+
+ go to 777 !* UNUSED cutoff beyond RMN2 - - - - - - - - - -
+
+ do i=1,icut1-1
+ ps(i)= ps(i)- ps(icut1)+ ps(IR)
+ ps1(i)=ps1(i)-ps1(icut1)+ps1(IR)
+ do k=1,kmax
+ ur(k,i)=ur(k,i)-ur(k,icut1)+ur(k,IR)
+ th(k,i)=th(k,i)-th(k,icut1)+th(k,IR)
+ t(k,i)=t(k,i)-t(k,icut1)+t(k,IR)
+ r(k,i)=max(0.,r(k,i)-r(k,icut1))+r(k,IR)
+ end do
+ end do
+
+ do i=icut1,IR
+ ps(i)= ps(IR)
+ ps1(i)=ps1(IR)
+ do k=1,kmax
+ ur(k,i)=ur(k,IR)
+ th(k,i)=th(k,IR)
+ t(k,i)=t(k,IR)
+ r(k,i)=r(k,IR)
+ end do
+ end do
+
+ 777 continue !* - - - - - - - - - - - - - - - - - - - - - - -
+
+ icut2=icut1+1.5*arad/(rp1(2)-rp1(1)) !* icut2 -> RMN2+3'
+
+ if (icut2.gt.IR) icut2=IR
+
+ print*,'icut1,icut2=',icut1,icut2
+
+! special treatment for ur (UNUSED spread of divergence)
+
+ do i=1,icut2
+ do k=1,kmax
+! ur(k,i)=ur(k,i)-ur(k,icut2)*rp1(i)/rp1(icut2)
+ ur(k,i)=ur(k,i)
+ end do
+ end do
+
+!* Cut off beyond RMN2+3'
+ do i=icut2,IR
+ ps(i)=ps(IR)
+ ps1(i)=ps1(IR)
+ do k=1,kmax
+ ur(k,i)=0.
+ th(k,i)=0.
+ t(k,i)=t(k,IR)
+ r(k,i)=r(k,IR)
+ end do
+ end do
+
+!* FADE from RMN2 to RMN2+3'
+ do i=icut1,icut2 !* cut_off = 1 -> 0
+ cut_off=FLOAT(icut2-i)/FLOAT(icut2-icut1)
+ cut_off=cut_off*cut_off*(3.-2.*cut_off)
+ print*,'i,cut_off=',i,cut_off
+ ps(i)=(ps(i)-ps(IR))*cut_off+ps(IR)
+ ps1(i)=(ps1(i)-ps1(IR))*cut_off+ps1(IR)
+ do k=1,kmax !* FADING t(k,i) -> t(k,IR)
+! ur(k,i)=(ur(k,i)-ur(k,IR))*cut_off
+ th(k,i)=(th(k,i)-th(k,IR))*cut_off
+ t(k,i)=(t(k,i)-t(k,IR))*cut_off+t(k,IR)
+ r(k,i)=(r(k,i)-r(k,IR))*cut_off+r(k,IR)
+ end do
+ end do
+
+! END correction
+
+ ps1=0. !* UNUSED SLP correction for location & stretching
+
+ do i=1,IR
+ ps(i)=ps(i)+ps1(i) ! new pert after correct latitude and fact
+ end do
+!
+
+ do k=1,kmax
+ q(k)=pcst(k)/pcst(1) !* sigma coord
+ end do
+
+
+ do i=1,IR
+ ps1(i)=ps(i)+pcst(1) !* ps1 = total sfc pressure
+! print*,'i,ps,ps1=',i,ps(i),ps1(i)
+ end do
+
+ do k=1,kmax
+ do i=1,IR
+ p(k,i)=ps1(i)*q(k) !* pressure at sigma level
+ end do
+ end do
+
+! Interpolate const P data onto const sigma level.
+
+!CWH do i=1,IR1
+!CWH SLP_2SB(i)=ps(i)
+!CWH end do
+ do i=1,IR
+ SLP_2SB(i)=ps(i)
+ end do
+ SLP_2SB(IR1)=0
+
+ go to 799 !* UNUSED p-to-sigma correction ------------------------
+
+ DO I=1,IR
+ DO N=1,KMAX
+ work1(N)=t(N,I)+temp_e(N) !* total temperature
+ END DO
+ DO K=1,kmax
+ IF (p(k,i).GE.pcst(1)) THEN
+ U_2SB(i,k)=th(1,i)
+ V_2SB(i,k)=ur(1,i)
+ T_2SB(i,k)=work1(1)
+ R_2SB(i,k)=r(1,i)
+ ELSEIF (p(k,i).LE.pcst(kmax)) THEN
+ U_2SB(i,k)=th(kmax,i)
+ V_2SB(i,k)=ur(kmax,i)
+ T_2SB(i,k)=work1(kmax)
+ R_2SB(i,k)=r(kmax,i)
+ ELSE !* p-to-sigma interpolation
+ DO N=1,kmax
+ if ( p(k,i).LE.pcst(N) .AND. p(k,i).GT.pcst(N+1) ) then
+ WT1=ALOG(1.*pcst(N+1))-ALOG(1.*pcst(N))
+ WT2=(ALOG(1.*p(k,i))-ALOG(1.*pcst(N)))/WT1
+ WT3=1.-WT2
+ U_2SB(i,k)=WT3*th(N,i)+WT2*th(N+1,i)
+ V_2SB(i,k)=WT3*ur(N,i)+WT2*ur(N+1,i)
+ T_2SB(i,k)=WT3*work1(N)+WT2*work1(N+1)
+ R_2SB(i,k)=WT3*r(N,i)+WT2*r(N+1,i)
+ GOTO 870
+ endif
+ ENDDO
+ 870 continue
+ ENDIF
+ END DO
+ END DO
+
+ TSUM1=0.
+ TSUM2=0.
+
+ DO I=1,IR
+ DO K=1,KMAX
+ TEK1=temp_e(K)+t(k,i) !* total temperature
+ TEK2=T_2SB(i,k)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ R_2SB(i,k)=ESRR*r(k,i)
+ T_2SB(i,k)=T_2SB(i,k)-temp_e(K) !* perturbation temperature
+! T_2SB(i,k)=0.5*(T_2SB(i,k)+t(k,i)) ! avg btw const P and const Sigma
+! T_2SB(i,k)=0.5*t(k,i) ! average between const P and const Sigma
+ TSUM1=TSUM1+t(k,i)
+ TSUM2=TSUM2+T_2SB(i,k)
+ END DO
+ END DO
+
+ print*,'TSUM1,TSUM2=',TSUM1,TSUM2
+
+ TSUM1=TSUM1+TSUM2
+
+ DO I=1,IR
+ DO K=1,KMAX
+ IF (ABS(TSUM1).GT.0.01) THEN
+ T_2SB(i,k)=(t(k,i)+T_2SB(i,k))*TSUM2/TSUM1
+ ELSE
+ T_2SB(i,k)=0.
+ END IF
+ th(k,i)=U_2SB(i,k)
+ ur(k,i)=V_2SB(i,k)
+ t(k,i)=T_2SB(i,k) !* perturbation temperature
+ r(k,i)=R_2SB(i,k)
+! print*,'T_2SB(i,k)=',i,k,T_2SB(i,k)
+ END DO
+ END DO
+
+ 799 CONTINUE !* ------------------------------------------------------
+
+ if(SN.eq.'S')then
+ do k=1,kmax
+ do i=1,IR1
+ th(k,i)=-th(k,i)
+ end do
+ end do
+ end if
+
+!* Using p-level instead of sigma-level
+ DO I=1,IR
+ DO K=1,KMAX
+ U_2SB(i,k)=th(k,i) !* tangen wind !!
+ V_2SB(i,k)=ur(k,i) !* radial wind !!
+ T_2SB(i,k)=t(k,i)
+ R_2SB(i,k)=r(k,i)
+ END DO
+ END DO
+
+!* Interpolate from cylin to E-grid
+!* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ALLOCATE ( RIJ1(NX,NY),RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ do k=1,kmax
+ do j=1,ny
+ do i=1,nx
+ TENV(i,j,k)=temp_e(k)
+ HP(i,j,k)=p(k,IR)
+ HV(i,j,k)=p(k,IR)
+ end do
+ end do
+ end do
+
+!* Presume grid points outside vortex
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+ IDX1=-1
+
+!* Interpolate winds to E-grid inside vortex
+
+ DO J=1,NY
+ DO I=1,NX !* Relocate the vortex to storm center
+ RIJ1(I,J)=arad*SQRT(((VLON2(I,J)-CLON_NHC)*cost)**2+ &
+ (VLAT2(I,J)-CLAT_NHC)**2 )
+ DO N=1,IR
+ DIF=rp(N)-RIJ1(I,J)
+ IF (DIF.GT.0.) THEN
+ IDX1(I,J)=N !* Grid point inside vortex
+ GO TO 15
+ ENDIF
+ ENDDO
+ 15 CONTINUE
+ IF (IDX1(I,J).GE.2) THEN
+ W1(I,J)=(RIJ1(I,J)-rp(IDX1(I,J)-1))/ &
+ (rp(IDX1(I,J))-rp(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ W1(I,J)=RIJ1(I,J)/rp(IDX1(I,J))
+ W2(I,J)=0.
+ ENDIF
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ if (IDX1(I,J).GT.0) then
+
+ IF (IDX1(I,J).GE.2) THEN
+ DO K=1,KMAX
+ vrad(K)=W1(I,J)*ur(k,IDX1(I,J))+W2(I,J)*ur(k,IDX1(I,J)-1)
+ vtan(K)=W1(I,J)*th(k,IDX1(I,J))+W2(I,J)*th(k,IDX1(I,J)-1)
+ END DO
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ DO K=1,KMAX
+ vrad(K)=W1(I,J)*ur(k,IDX1(I,J)) ! WT=0. at center
+ vtan(K)=W1(I,J)*th(k,IDX1(I,J))
+ END DO
+ ENDIF
+
+ DTX=cost*(VLON2(I,J)-CLON_NHC)
+ DTY=VLAT2(I,J)-CLAT_NHC
+ DTR=RIJ1(I,J)/arad
+
+!CWH DO K=1,KMAX
+!CWH U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+!CWH V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+!CWH HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+!CWH END DO
+
+ IF (IDX1(I,J).GE.2) THEN
+ DO K=1,KMAX
+ U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+ V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+ HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+ END DO
+ ELSEIF (IDX1(I,J).EQ.1) THEN
+ DO K=1,KMAX
+ U_1(I,J,K)=(vrad(K)*DTX-vtan(K)*DTY)/(DTR+1.E-20)
+ V_1(I,J,K)=(vrad(K)*DTY+vtan(K)*DTX)/(DTR+1.E-20)
+ HV(I,J,K)=W1(I,J)*P(k,IDX1(I,J))
+ END DO
+ ENDIF
+
+ endif
+ ENDDO
+ ENDDO
+
+!* Interpolate ps, T, r to E-grid
+
+ do i=1,IR
+ do k=1,kmax
+ if (r(k,i).LT.0.) r(k,i)=0. !* positive-definite
+ end do
+ end do
+
+ IDX1=-1 !* Presume grid point outside vortex
+
+ DO J=1,NY
+ DO I=1,NX !* Relocate the vortex to storm center
+ RIJ2(I,J)=arad*SQRT(((HLON2(I,J)-CLON_NHC)*cost)**2+ &
+ (HLAT2(I,J)-CLAT_NHC)**2 )
+ DO N=1,IR
+ DIF=rp(N)-RIJ2(I,J)
+ IF (DIF.GT.0.) THEN
+ IDX1(I,J)=N !* Grid point inside vortex
+ GO TO 25
+ ENDIF
+ ENDDO
+ 25 CONTINUE
+ IF (IDX1(I,J).GE.2) THEN
+ W1(I,J)=(RIJ2(I,J)-rp(IDX1(I,J)-1))/ &
+ (rp(IDX1(I,J))-rp(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE
+ W1(I,J)=1.
+ W2(I,J)=0.
+ ENDIF
+ ENDDO
+ ENDDO
+
+ DO J=1,NY
+ DO I=1,NX
+ if (IDX1(I,J).GT.0) then
+ IF (IDX1(I,J).GE.2) THEN
+ SLP_1(I,J)=W1(I,J)*ps(IDX1(I,J))+W2(I,J)*ps(IDX1(I,J)-1)
+ DO K=1,KMAX
+ T_1(I,J,K)=W1(I,J)*t(k,IDX1(I,J))+W2(I,J)*t(k,IDX1(I,J)-1)
+ Q_1(I,J,K)=W1(I,J)*r(k,IDX1(I,J))+W2(I,J)*r(k,IDX1(I,J)-1)
+ HP(I,J,K)=W1(I,J)*P(k,IDX1(I,J))+W2(I,J)*P(k,IDX1(I,J)-1)
+ ENDDO
+ ELSE
+ SLP_1(I,J)=ps(IDX1(I,J))
+ DO K=1,KMAX
+ T_1(I,J,K)=t(k,IDX1(I,J))
+ Q_1(I,J,K)=r(k,IDX1(I,J))
+ HP(I,J,K)=P(k,IDX1(I,J))
+ ENDDO
+ ENDIF
+ endif
+ ENDDO
+ ENDDO
+
+ RIJ_m=1.e20
+ DO J=1,NY
+ DO I=1,NX
+ IF (RIJ2(I,J).LT.RIJ_m) THEN
+ RIJ_m=RIJ2(I,J) !* min R
+ II1=I
+ JJ1=J
+ ENDIF
+ ENDDO
+ ENDDO
+ print*,'center inside axisym_xy=',HLON2(II1,JJ1),HLAT2(II1,JJ1)
+
+ PIJ_m=1.e20
+ DO J=1,NY
+ DO I=1,NX
+ IF (SLP_1(I,J).LT.PIJ_m) THEN
+ PIJ_m=SLP_1(I,J) !* min Ps
+ II1=I
+ JJ1=J
+ ENDIF
+ ENDDO
+ ENDDO
+
+ print*,'center inside axisym_xy 2=',HLON2(II1,JJ1),HLAT2(II1,JJ1),PIJ_m
+
+ END
+
+!==============================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/correct_mat_2.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/correct_mat_2.f90
new file mode 100644
index 000000000..7c412ca9b
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/correct_mat_2.f90
@@ -0,0 +1,316 @@
+
+ SUBROUTINE CORT_MAT_2(IR1,NX,NY,NZ,KMX,U_2S, &
+ T_2S,SLP_2S,Q_2S,RADIUS,temp_e,TEK, &
+ T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ CLON_NEW,CLAT_NEW,PS_C1, &
+ beta,fact,ics,SN)
+
+! input: IR1,NX,NY,KMX
+! input: U_2S,T_2S,Q_2S,SLP_2S variables from guess storm
+! input: HLON,HLAT,VLON,VLAT,TEK,temp_e
+! input: RADIUS,CLON_NEW,CLAT_NEW,ics
+! output: T_X,Q_X,SLP_X - new axisymmetric part
+
+ real(4) HLON(NX,NY),HLAT(NX,NY)
+ real(4) VLON(NX,NY),VLAT(NX,NY)
+
+ REAL(8) CLON_NEW,CLAT_NEW
+
+ real(4) T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY)
+
+ real(4) RADIUS(IR1)
+ real(4) U_2S(IR1,KMX),T_2S(IR1,KMX)
+ real(4) Q_2S(IR1,KMX),SLP_2S(IR1)
+
+ real(4) TEK(NZ),temp_e(KMX)
+
+ REAL(4), ALLOCATABLE :: RKX1(:),WKX1(:,:)
+ REAL(4), ALLOCATABLE :: RKX2(:),WKX2(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:,:),strm2(:,:),funct(:,:)
+
+ REAL(4), ALLOCATABLE :: rpb(:),rpb1(:),rpb2(:)
+ REAL(4), ALLOCATABLE :: rmix(:,:)
+ REAL(4), ALLOCATABLE :: ctmp(:,:),cmix(:,:)
+
+ REAL(4), ALLOCATABLE :: test1(:,:),work1(:,:)
+
+ REAL(4), ALLOCATABLE :: RIJ2(:,:)
+!zhang REAL(4), ALLOCATABLE :: IDX1(:,:),W1(:,:),W2(:,:)
+ REAL(4), ALLOCATABLE :: W1(:,:),W2(:,:)
+ INTEGER, ALLOCATABLE :: IDX1(:,:)
+
+ REAL(4), ALLOCATABLE :: FUN1(:)
+ REAL(4), ALLOCATABLE :: NDX1(:),WT1(:),WT2(:)
+ CHARACTER SN*1
+
+ IR=IR1-1
+ nm=NZ
+ kmx1=kmx-1
+
+ NXC=NX/2
+ NYC=NY/2
+
+ ALLOCATE ( RKX1(IR1),WKX1(IR1,NZ) )
+ ALLOCATE ( RKX2(IR1),WKX2(IR1,NZ) )
+ ALLOCATE ( strm1(IR1,nm),strm2(IR1,nm),funct(IR1,nm) )
+
+ ALLOCATE ( rpb(IR1),rpb1(IR1),rpb2(IR1) )
+ ALLOCATE ( rmix(IR1,NM) )
+ ALLOCATE ( ctmp(IR1,kmx),cmix(IR1,kmx) )
+
+ ALLOCATE ( FUN1(IR1) )
+ ALLOCATE ( NDX1(IR1),WT1(IR1),WT2(IR1) )
+
+ pi=4.*atan(1.)
+ pi180=pi/180.
+ pi_deg=180./pi
+ DST1=6.371E6*pi180
+
+ cost=cos(clat_new*pi180)
+
+ print*,'inside cort'
+ print*,'pi= ',pi
+
+! check max, min temp
+
+ do k=1,kmx
+ tmax=-1.E20
+ tmin=1.E20
+ do j=1,IR1
+ if(T_2S(j,k).gt.tmax)then
+ tmax=T_2S(j,k)
+ jmax3=j
+ end if
+ if(T_2S(j,k).lt.tmin)then
+ tmin=T_2S(j,k)
+ jmin=j
+ end if
+ end do
+ print*,'k,tmax,tmin=',k,tmax,tmin
+ end do
+
+ print*,'clon_new,clat_new=',clon_new,clat_new
+
+ ff0=2.*7.292E-5*sin(clat_new*pi180)
+
+ print*,'beta,fact,ff0=',beta,fact,ff0
+
+ RKX1=0.
+ DO n=1,IR1
+ RKX1(n)=RADIUS(n)*DST1
+ print*,'RKX1(n)=',RKX1(n),U_2S(n,2)
+ END DO
+
+ RKX2=0.
+ DO n=1,IR1
+ RKX2(n)=RKX1(n)
+ END DO
+
+ k=1
+ k1=2
+
+!
+! Chanh added modification here to recompute the stream
+! function for the Southern Hemisphere,
+!
+ WKX1=0.
+ DO n=1,IR1
+ WKX1(n,k)=U_2S(n,k1)
+ IF(WKX1(n,k).lt.0..and.SN.eq.'N') WKX1(n,k)=0.
+ IF(WKX1(n,k).gt.0..and.SN.eq.'S') WKX1(n,k)=0.
+ END DO
+
+ WKX2=0.
+ DO n=1,IR1
+ WKX2(n,1)=U_2S(n,2)*beta
+ IF(WKX2(n,1).lt.0..and.SN.eq.'N') WKX2(n,1)=0.
+ IF(WKX2(n,1).gt.0..and.SN.eq.'S') WKX2(n,1)=0.
+ END DO
+
+ strm1(IR1,k)=0.
+ strm2(IR1,k)=0.
+ DO n=IR,1,-1
+ force=(WKX1(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX1(n,k)
+ strm1(n,k)=strm1(n+1,k)-force*(RKX1(n+1)-RKX1(n))
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ end do
+
+ print*,'finish computing stream function'
+
+ IR_1=IR1
+ DO n=1,IR1
+ sum_str=strm1(n,1)
+ if(abs(sum_str).gt.0.01)then
+ IR_1=n
+ end if
+ END DO
+
+ IR_1=IR1
+ DO n=1,IR1
+ sum_str=strm1(n,1)
+ if(abs(sum_str).gt.5.0)then
+ IR_5=n
+ end if
+ END DO
+
+ print*,'IR_5,IR_1=',IR_5,IR_1
+
+ do m=1,IR_1
+ str_cut=max(strm2(m,1),strm1(m,1))
+ if(str_cut.gt.-10.)then
+ str_m_rat=strm2(m,1)/(strm1(m,1)-1.E-20)
+ IR_2=m
+ go to 57
+ end if
+ end do
+ 57 continue
+
+ print*,'IR_2,IR_1=',IR_2,IR_1
+
+ IF(IR_2.EQ.1)then
+ fun1=0.0
+ adj_fun1=0.
+ ELSE
+
+ fun1=0.
+ do m=1,IR_2
+ fun1(m)=strm2(m,1)/(strm1(m,1)-1.E-20)
+ end do
+
+ do m=IR_2,IR_1
+ fun1(m)=min(str_m_rat,strm2(m,1)/(strm1(m,1)-1.E-20))
+ end do
+
+! IF(IR_1.GT.IR_5)THEN
+! do m=IR_5,IR_1
+! fun1(m)=fun1(m)*(m-IR_5)/float(IR_1-IR_5)
+! end do
+! END IF
+
+! adjust func1 based on the center surface pressure
+
+ adj_fun1=PS_C1/(fun1(1)*SLP_2S(1))
+
+ END IF
+
+ rpb=0.
+ do m=1,IR_1
+ fun1(m)=fun1(m)*adj_fun1
+ rpb(m) =fun1(m)*SLP_2S(m)
+ end do
+
+ ctmp=0.
+ do k=1,kmx
+ do m=1,IR_1
+ ctmp(m,k) =fun1(m)*T_2S(m,k)
+ if(k.eq.30)print*,'m,fun1(m),T_2S(m,k)=',m,fun1(m),T_2S(m,k)
+ end do
+ end do
+
+!!!!!
+! correct mixing ratio
+
+ rmix=0.
+ do k=1,NZ
+ k1=2*k
+ if (k1 .le. 121) then
+ do m=1,IR_1
+ TEK1=temp_e(k1)+T_2S(m,k1)
+ TEK2=TEK(k)+ctmp(m,k1)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+! rmix(m,k)=ESRR*Q_2S(m,k1)-Q_2S(m,k1)
+ rmix(m,k)=ESRR*Q_2S(m,k1)
+ end do
+ else
+ do m=1,IR_1
+ rmix(m,k)=0.0
+ enddo
+ endif
+ end do
+
+ do m=1,IR_1
+! rpb(m) =rpb(m)-SLP_2S(m)
+ rpb(m) =rpb(m)
+ end do
+
+ do k=1,kmx
+ do m=1,IR_1
+! ctmp(m,k) =ctmp(m,k)-T_2S(m,k)
+ ctmp(m,k) =ctmp(m,k)
+ end do
+ end do
+
+ cmix=0.
+ do m=1,IR_1
+ cmix(m,1)=rmix(m,1)
+ cmix(m,kmx)=rmix(m,NZ)
+ do k=2,kmx1,2
+ k1=k/2
+ cmix(m,k)=rmix(m,k1)
+ end do
+ do k=3,kmx1-1,2
+ k1=(k-1)/2
+ cmix(m,k)=0.5*(rmix(m,k1)+rmix(m,k1+1))
+ end do
+ end do
+
+! interpolate correction to 3D
+
+ ALLOCATE ( RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ IDX1=-1
+
+ DO J=1,NY
+ DO I=1,NX
+ RIJ2(I,J)=SQRT(((HLON(I,J)-CLON_NEW)*cost)**2+ &
+ (HLAT(I,J)-CLAT_NEW)**2 )
+ DO N=1,IR_1
+ DIF=RADIUS(N)-RIJ2(I,J)
+ IF(DIF.GT.0.)THEN
+ IDX1(I,J)=N
+ GO TO 25
+ END IF
+ END DO
+ 25 CONTINUE
+ IF(IDX1(I,J).GE.2)THEN
+ W1(I,J)=(RIJ2(I,J)-RADIUS(IDX1(I,J)-1))/ &
+ (RADIUS(IDX1(I,J))-RADIUS(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE IF(IDX1(I,J).EQ.1)THEN
+ W1(I,J)=1.
+ W2(I,J)=0.
+ ELSE
+ W1(I,J)=0.
+ W2(I,J)=0.
+ END IF
+ END DO
+ END DO
+
+ SLP_X=0.
+ T_X=0.
+ Q_X=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ IF(IDX1(I,J).GT.0)THEN
+ IF(IDX1(I,J).GE.2)THEN
+ SLP_X(I,J)=W1(I,J)*rpb(IDX1(I,J))+W2(I,J)*rpb(IDX1(I,J)-1)
+ DO K=1,KMX
+ T_X(I,J,K)=W1(I,J)*ctmp(IDX1(I,J),k)+W2(I,J)*ctmp(IDX1(I,J)-1,k)
+ Q_X(I,J,K)=W1(I,J)*cmix(IDX1(I,J),k)+W2(I,J)*cmix(IDX1(I,J)-1,k)
+ END DO
+ ELSE
+ SLP_X(I,J)=rpb(IDX1(I,J))
+ DO K=1,KMX
+ T_X(I,J,K)=ctmp(IDX1(I,J),k)
+ Q_X(I,J,K)=cmix(IDX1(I,J),k)
+ END DO
+ END IF
+ END IF
+ END DO
+ END DO
+
+ return
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/interp_coef_agrid.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/interp_coef_agrid.f90
new file mode 100644
index 000000000..1c63766c7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_enhance/interp_coef_agrid.f90
@@ -0,0 +1,300 @@
+SUBROUTINE EARTH_LATLON_AGRID ( HLAT,HLON,VLAT,VLON, & !Earth lat,lon at H and V points
+ LON1,LAT1,LON2,LAT2, & !input res,west & south boundaries,
+ CENTRAL_LAT,CENTRAL_LON, & ! central lat,lon, all in degrees
+ IM,JM)
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ REAL(4), INTENT(IN) :: LON1,LAT1,LON2,LAT2
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(OUT) :: HLAT,HLON,VLAT,VLON
+
+! local
+
+ INTEGER,PARAMETER :: KNUM=8
+ INTEGER :: I,J
+ REAL(KNUM) :: rot_lon,rot_lat,geo_lon,geo_lat
+ REAL(KNUM) :: cen_lon, cen_lat
+!-------------------------------------------------------------------------
+
+ cen_lon = CENTRAL_LON
+ cen_lat = CENTRAL_LAT
+
+ do j=1,jm
+ do i=1,im
+ rot_lon = lon1 + (lon2-lon1)/(im-1) * (i-1)
+ rot_lat = lat1 + (lat2-lat1)/(jm-1) * (j-1)
+ call rtll(rot_lon, rot_lat, geo_lon, geo_lat, cen_lon, cen_lat)
+! if (geo_lon <0.0) geo_lon = geo_lon + 360.0
+ HLON(i,j) = geo_lon
+ HLAT(i,j) = geo_lat
+ enddo
+ enddo
+
+ VLON = HLON
+ VLAT = HLAT
+
+END SUBROUTINE EARTH_LATLON_AGRID
+
+!-----------------------------------------------------------------------------
+
+SUBROUTINE G2T2H_AGRID( IIH,JJH, & ! output grid index
+ HBWGT, & ! output weights in terms of parent grid
+ HLAT,HLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: HLAT,HLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: HBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIH,JJH
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(HLON(I,J),HLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1)/DLMD1 + 1
+ YI = (Y-SBD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIH(I,J,1)=I1
+ IIH(I,J,2)=I2
+ IIH(I,J,3)=I1
+ IIH(I,J,4)=I2
+ JJH(I,J,1)=J1
+ JJH(I,J,2)=J1
+ JJH(I,J,3)=J2
+ JJH(I,J,4)=J2
+ HBWGT(I,J,1)=(1-XF)*(1-YF)
+ HBWGT(I,J,2)=XF*(1-YF)
+ HBWGT(I,J,3)=(1-XF)*YF
+ HBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+END SUBROUTINE G2T2H_AGRID
+
+
+
+SUBROUTINE G2T2V_BGRID( IIV,JJV, & ! output grid index and weights
+ VBWGT, & ! output weights in terms of parent grid
+ VLAT,VLON, & ! target (nest) input lat lon in degrees
+ DLMD1,DPHD1,WBD1,SBD1, & ! parent res, west and south boundaries
+ CENTRAL_LAT,CENTRAL_LON, & ! parent central lat,lon, all in degrees
+ P_IM,P_JM, & ! parent imax and jmax
+ IM,JM) ! target (nest) dimensions
+!
+!============================================================================
+!
+ IMPLICIT NONE
+ INTEGER, INTENT(IN) :: IM,JM
+ INTEGER, INTENT(IN) :: P_IM,P_JM
+ REAL(4), INTENT(IN) :: DLMD1,DPHD1,WBD1,SBD1
+ REAL(4), INTENT(IN) :: CENTRAL_LAT,CENTRAL_LON
+ REAL(4), DIMENSION(IM,JM), INTENT(IN) :: VLAT,VLON
+ REAL(4), DIMENSION(IM,JM,4), INTENT(OUT) :: VBWGT
+ INTEGER, DIMENSION(IM,JM,4), INTENT(OUT) :: IIV,JJV
+
+! local
+
+ INTEGER :: I,J
+ INTEGER :: I1,I2,J1,J2
+ REAL(8) :: X,Y,XI,YI,XF,YF
+!-------------------------------------------------------------------------
+
+ DO J = 1,JM
+ DO I = 1,IM
+
+ CALL TLL(VLON(I,J),VLAT(I,J),X,Y,CENTRAL_LAT,CENTRAL_LON)
+
+ XI = (X-WBD1-0.5*DLMD1)/DLMD1 + 1
+ YI = (Y-SBD1-0.5*DPHD1)/DPHD1 + 1
+ IF(abs(XI-1.).lt.0.005)XI=1.0
+ I1 = XI
+ I2 = I1+1
+ IF(abs(YI-1.).lt.0.005)YI=1.0
+ J1 = YI
+ J2 = J1+1
+ XF=XI-I1
+ YF=YI-J1
+ IIV(I,J,1)=I1
+ IIV(I,J,2)=I2
+ IIV(I,J,3)=I1
+ IIV(I,J,4)=I2
+ JJV(I,J,1)=J1
+ JJV(I,J,2)=J1
+ JJV(I,J,3)=J2
+ JJV(I,J,4)=J2
+ VBWGT(I,J,1)=(1-XF)*(1-YF)
+ VBWGT(I,J,2)=XF*(1-YF)
+ VBWGT(I,J,3)=(1-XF)*YF
+ VBWGT(I,J,4)=XF*YF
+
+ ENDDO
+ ENDDO
+
+
+ RETURN
+ END SUBROUTINE G2T2V_BGRID
+
+ subroutine rtll(tlmd,tphd,almd,aphd,tlm0d,tph0d)
+!-------------------------------------------------------------------------------
+ INTEGER,PARAMETER :: KIND_R8=8
+
+ real(KIND_R8), intent(in) :: tlmd, tphd
+ real(KIND_R8), intent(out) :: almd, aphd
+ real(KIND_R8), intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real(KIND_R8), parameter :: pi=3.14159265358979323846
+ real(KIND_R8), parameter :: dtr=pi/180.0
+!
+ real(KIND_R8) :: tph0, ctph0, stph0, tlm, tph, stph, ctph, ctlm, stlm, aph, cph
+ real(KIND_R8) :: xx, yy
+!-------------------------------------------------------------------------------
+!
+ tph0=tph0d*dtr
+ ctph0=cos(tph0)
+ stph0=sin(tph0)
+!
+ tlm=tlmd*dtr
+ tph=tphd*dtr
+ stph=sin(tph)
+ ctph=cos(tph)
+ ctlm=cos(tlm)
+ stlm=sin(tlm)
+!
+ xx=stph0*ctph*ctlm+ctph0*stph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ aph=asin(xx)
+ cph=cos(aph)
+!
+ xx=(ctph0*ctph*ctlm-stph0*stph)/cph
+ xx=max(xx,-1.0)
+ xx=min(xx, 1.0)
+ xx=acos(xx)/dtr
+ yy=ctph*stlm/cph
+ xx=sign(xx,yy)
+ almd=tlm0d+xx
+
+ aphd=aph/dtr
+!
+ if (almd > 180.0) then
+ almd=almd-360.0
+ end if
+ if (almd < -180.0) then
+ almd=almd+360.0
+ end if
+!
+ return
+!
+ end subroutine rtll
+
+
+ subroutine tll(almd,aphd,tlmd,tphd,tph0d,tlm0d)
+!-------------------------------------------------------------------------------
+ implicit none
+!-------------------------------------------------------------------------------
+ real, intent(in) :: almd, aphd
+ real(8), intent(out) :: tlmd, tphd
+ real, intent(in) :: tph0d, tlm0d
+!-------------------------------------------------------------------------------
+ real, parameter :: pi=3.141592654
+ real(8), parameter :: dtr=pi/180.0
+!
+ real(8) :: tph0, ctph0, stph0, relm, srlm, crlm
+ real(8) :: aph, sph, cph, cc, anum, denom
+!-------------------------------------------------------------------------------
+!
+ if (tlm0d==0.0.and.tph0d==0.0) then
+ tlmd=almd
+ tphd=aphd
+ else
+
+ tph0=tph0d*dtr
+ ctph0=dcos(tph0)
+ stph0=dsin(tph0)
+!
+ relm=(almd-tlm0d)*dtr
+ srlm=dsin(relm)
+ crlm=dcos(relm)
+ aph=aphd*dtr
+ sph=dsin(aph)
+ cph=dcos(aph)
+ cc=cph*crlm
+ anum=cph*srlm
+ denom=ctph0*cc+stph0*sph
+!
+ tlmd=datan2(anum,denom)/dtr
+ tphd=dasin(ctph0*sph-stph0*cc)/dtr
+
+ end if
+!
+ return
+!
+ end subroutine tll
+
+
+!! subroutine 'get_eta_level' returns the interface and
+!! layer-mean pressures for reference.
+ subroutine get_eta_level(npz, p_s, pf, ph, ak, bk, pscale)
+ integer, intent(in) :: npz
+ real, intent(in) :: p_s !< unit: pascal
+ real, intent(in) :: ak(npz+1)
+ real, intent(in) :: bk(npz+1)
+ real, intent(in), optional :: pscale
+ real, intent(out) :: pf(npz)
+ real, intent(out) :: ph(npz+1)
+
+ real, parameter :: RDGAS = 287.05 !< Gas constant for dry air [J/kg/deg]
+ real, parameter :: CP_AIR = 1004.6 !< Specific heat capacity of dry air at constant pressure [J/kg/deg]
+ real, parameter :: KAPPA = RDGAS/CP_AIR !< RDGAS / CP_AIR [dimensionless]
+ integer k
+
+ ph(1) = ak(1)
+ do k=2,npz+1
+ ph(k) = ak(k) + bk(k)*p_s
+ enddo
+
+! if ( present(pscale) ) then
+! do k=1,npz+1
+! ph(k) = pscale*ph(k)
+! enddo
+! endif
+
+ if( ak(1) > 1.E-8 ) then
+ pf(1) = (ph(2) - ph(1)) / log(ph(2)/ph(1))
+ else
+ pf(1) = (ph(2) - ph(1)) * kappa/(kappa+1.)
+ endif
+
+ do k=2,npz
+ pf(k) = (ph(k+1) - ph(k)) / log(ph(k+1)/ph(k))
+ enddo
+
+ end subroutine get_eta_level
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/CMakeLists.txt
new file mode 100644
index 000000000..8120c4b5d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/CMakeLists.txt
@@ -0,0 +1,31 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ anl_pert.f90
+ correct_mat.f90
+ fill_nmm_gridg.f90
+ grads.f90)
+
+set(exe_name hafs_vi_anl_pert.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_libraries(
+ ${exe_name} PRIVATE
+ OpenMP::OpenMP_Fortran)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/Makefile
new file mode 100644
index 000000000..499c7fc90
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/Makefile
@@ -0,0 +1,18 @@
+include ../configure.vi
+include ../pure-openmp.inc
+
+OBJS = anl_pert.o correct_mat.o fill_nmm_gridg.o grads.o
+
+EXEC = ../../../exec/hafs_vi_anl_pert.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/anl_pert.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/anl_pert.f90
new file mode 100644
index 000000000..7616a2c42
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/anl_pert.f90
@@ -0,0 +1,1843 @@
+!******************************************************************************
+!
+! ABSTRACT: Smooth the model vortex, and calculate the axi-symmetric vortex
+!
+! ORIGINAL AUTHOR: QINGFU LIU, NCEP/EMC, 2007
+! REVISED AUTHOR: Qingfu Liu, 2013
+! : Add the calculation of R34 and Rmax
+! : Calcualte the size correction coeffs: a and b
+!
+! DECLARE VARIABLES
+!
+ INTEGER I,J,K,NX,NY,NZ,IFLAG,NX2
+!
+! PARAMETER (NX=215,NY=431,NZ=42,NST=5)
+ PARAMETER (NST=5)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,Rd=287.05,D608=0.608)
+ PARAMETER (Cp=1004.)
+
+! PARAMETER (KMX=2*NZ+1)
+!
+! Variables on 4x hybrid coordinate (ENV)
+
+ REAL(4) DLMD,DPHD,PT,PDTOP
+ REAL(4) WBD,SBD,CENTRAL_LON,CENTRAL_LAT
+
+ REAL(4), ALLOCATABLE :: T1(:,:,:),Q1(:,:,:)
+ REAL(4), ALLOCATABLE :: U1(:,:,:),V1(:,:,:)
+ REAL(4), ALLOCATABLE :: Z1(:,:,:),P1(:,:,:)
+ REAL(4), ALLOCATABLE :: GLON(:,:),GLAT(:,:)
+ REAL(4), ALLOCATABLE :: PD1(:,:),ETA1(:),ETA2(:)
+
+ REAL(4), ALLOCATABLE :: USCT(:,:)
+ REAL(4), ALLOCATABLE :: U10(:,:),V10(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON(:,:),HLAT(:,:)
+ REAL(4), ALLOCATABLE :: VLON(:,:),VLAT(:,:)
+
+! variables for hurricane component
+
+ REAL(4), ALLOCATABLE :: HLON2(:,:),HLAT2(:,:)
+ REAL(4), ALLOCATABLE :: VLON2(:,:),VLAT2(:,:)
+
+ REAL(4), ALLOCATABLE :: SLPE(:,:),SLP_1(:,:),TENV(:,:,:),TEK(:)
+! REAL(4), ALLOCATABLE :: QENV(:,:,:)
+ REAL(4), ALLOCATABLE :: T_1(:,:,:),Q_1(:,:,:)
+ REAL(4), ALLOCATABLE :: U_1(:,:,:),V_1(:,:,:)
+
+! REAL(4), ALLOCATABLE :: T_5(:,:,:),Q_5(:,:,:)
+! REAL(4), ALLOCATABLE :: U_5(:,:,:),V_5(:,:,:),SLP_5(:,:)
+
+ REAL(4), ALLOCATABLE :: U_850(:,:),V_850(:,:)
+
+ REAL(4), ALLOCATABLE :: DUM(:,:),DUMA(:,:)
+
+! working array
+
+ REAL(4), ALLOCATABLE :: SLP1(:,:),RIJ(:,:),RIJ2(:,:),ANG2(:,:)
+ REAL(4), ALLOCATABLE :: PMID1(:,:,:),ZMID1(:,:,:)
+ REAL(4), ALLOCATABLE :: ZS1(:,:),TS1(:,:),QS1(:,:)
+
+ REAL(4), ALLOCATABLE :: U_S(:,:),U_A(:,:)
+ REAL(4), ALLOCATABLE :: V_S(:,:),V_A(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON3(:,:),HLAT3(:,:)
+ REAL(4), ALLOCATABLE :: VLON3(:,:),VLAT3(:,:)
+
+ REAL(4) CLON0,CLAT0
+
+ REAL(4), ALLOCATABLE :: USC_1(:,:),VSC_1(:,:) ! hurr comp wind at level 1
+ REAL(4), ALLOCATABLE :: USC1(:,:),VSC1(:,:) ! Hurricane wind at new grids
+ REAL(4), ALLOCATABLE :: SLPV(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON1(:,:),HLAT1(:,:)
+ REAL(4), ALLOCATABLE :: VLON1(:,:),VLAT1(:,:)
+
+ REAL(4), ALLOCATABLE :: A101(:,:),B101(:,:),C101(:,:)
+
+ REAL(4), ALLOCATABLE :: U_2(:,:,:),V_2(:,:,:)
+ REAL(4), ALLOCATABLE :: T_4(:,:,:),Q_4(:,:,:)
+
+ REAL(4), ALLOCATABLE :: U_2S(:,:),V_2S(:,:)
+ REAL(4), ALLOCATABLE :: T_2S(:,:),Q_2S(:,:),SLP_2S(:,:)
+
+ REAL(4), ALLOCATABLE :: U_2S1(:,:)
+
+ REAL(4), ALLOCATABLE :: RKX1(:),RKX2(:),WKX1(:,:),WKX2(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:,:),strm2(:,:),strm3(:,:)
+
+ REAL(4), ALLOCATABLE :: PCST(:),HP(:,:,:)
+
+ REAL(4), ALLOCATABLE :: PW(:),v_maxk(:)
+
+ REAL(4), ALLOCATABLE :: HBWGT1(:,:,:),VBWGT1(:,:,:)
+ integer(4), ALLOCATABLE :: IIH1(:,:),JJH1(:,:)
+ integer(4), ALLOCATABLE :: IIV1(:,:),JJV1(:,:)
+
+ REAL(4), ALLOCATABLE :: WTCT1(:,:,:,:),WTSM1(:,:)
+ REAL(4), ALLOCATABLE :: WTCT2(:,:,:,:),WTSM2(:,:)
+
+ REAL(4), ALLOCATABLE :: RADUS(:),ANGL(:),GLON1(:,:),GLAT1(:,:)
+!zhang REAL(4), ALLOCATABLE :: INDX1(:,:,:),INDY1(:,:,:)
+!zhang REAL(4), ALLOCATABLE :: INDX2(:,:,:),INDY2(:,:,:)
+ INTEGER, ALLOCATABLE :: INDX1(:,:,:),INDY1(:,:,:)
+ INTEGER, ALLOCATABLE :: INDX2(:,:,:),INDY2(:,:,:)
+ REAL(4), ALLOCATABLE :: WTXY1(:,:,:),WTXY2(:,:,:)
+
+!zhang REAL(4), ALLOCATABLE :: IJ_COUNT1(:,:),IJ_COUNT2(:,:)
+ INTEGER, ALLOCATABLE :: IJ_COUNT1(:,:),IJ_COUNT2(:,:)
+
+ REAL(4), ALLOCATABLE :: T_X(:,:,:),Q_X(:,:,:),SLP_X(:,:)
+! REAL(4), ALLOCATABLE :: A11(:,:),B11(:,:),C11(:)
+ REAL(4), ALLOCATABLE :: CFT(:)
+
+ REAL(4), ALLOCATABLE :: RADIUS1(:)
+
+ integer(4) IH1(4),JH1(4),IV1(4),JV1(4)
+
+ CHARACTER ST_NAME(NST)*3,SN*1,EW*1,DEPTH*1
+
+!zhang REAL(8) CLON_NEW,CLAT_NEW,CLON_NHC,CLAT_NHC
+!zhang REAL(8) CLON_NEW1,CLAT_NEW1
+ REAL(8) :: CLON_NHC,CLAT_NHC
+ REAL(8) :: CLON_NEW,CLAT_NEW
+
+ DIMENSION TWM(101),RWM(101),TH1(200),RP(200)
+
+ REAL(4) zmax
+
+ integer id_storm
+ integer Ir_v4(4)
+ REAL R34_obs(4)
+
+ integer I34_F(4),J34_F(4)
+ REAL R34_F(4)
+
+ CHARACTER PART1*2,basin*2,NUM*2
+!zhang:added basin domain shift otpion
+ CHARACTER*2 :: basin1
+
+ REAL(4) PW_S(85),PW_M(85)
+
+! DATA PW_S/28*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,47*0./ ! 850-700mb
+! DATA PW_M/38*1.0,0.95,0.9,0.8,0.7, &
+! 0.6,0.5,0.4,0.3,0.2,0.1,37*0./ ! 850-400mb
+! DATA PW_S/36*1.0,0.8,0.6,0.4,0.2, &
+! 45*0./ ! 600-500mb
+ DATA PW_S/38*1.0,0.8,0.6,0.4,0.2, &
+ 43*0./ ! 600-500mb
+!2 DATA PW_S/32*1.0,0.8,0.6,0.4,0.2, &
+!2 49*0./ ! 850-700mb
+!1 DATA PW_S/28*1.0,0.95,0.9,0.8,0.7, &
+!1 0.6,0.5,0.4,0.3,0.2,0.1,47*0./ ! 850-700mb
+ DATA PW_M/32*1.0,0.95,0.9,0.8,0.7, &
+ 0.6,0.5,0.4,0.3,0.2,0.1,43*0./ ! 850-400mb
+
+ COEF1=Rd/Cp
+ COEF3=Rd*GAMMA/G
+ COEF2=1./COEF3
+
+ GRD=G/Rd
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi
+ pi180=1./pi_deg
+
+ DST1=6.371E3*pi180 !* deg -> km
+
+ READ(5,*)ITIM,basin1,INITOPT
+
+
+! READ 4x area env. data HWRF
+
+ IUNIT=20+ITIM
+
+ READ(IUNIT) NX,NY,NZ,I360
+
+ print*,'NX,NY,NZ,I360=',NX,NY,NZ,I360
+
+ NX1=NX+1
+ NY1=NY+1
+ NZ1=NZ+1
+ IF ( NZ <= 60 ) THEN
+ KMX=2*NZ+1
+ ELSE
+! Warning: currently hard wired to 121 due to memory limit
+ KMX=121
+ ENDIF
+
+ ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ) )
+ ALLOCATE ( USCT(NX,NY) )
+ ALLOCATE ( U10(NX,NY),V10(NX,NY) )
+
+ READ(IUNIT) ! DLMD,DPHD,CENTRAL_LON,CENTRAL_LAT ! Domain res & center (deg)
+ READ(IUNIT) ! PT,PDTOP,WBD,SBD
+ READ(IUNIT) ! T1
+ READ(IUNIT) ! Q1
+ READ(IUNIT) U1
+ READ(IUNIT) V1
+ READ(IUNIT) ! Z1
+ READ(IUNIT) ! HLON,HLAT,VLON,VLAT
+ READ(IUNIT) ! P1
+ READ(IUNIT) ! PD1
+ READ(IUNIT) ! ETA1
+ READ(IUNIT) ! ETA2
+
+ CLOSE(IUNIT)
+
+! compute 10m wind
+
+ IUNIT=40+ITIM
+
+ READ(IUNIT) JX,JY
+
+ ALLOCATE ( A101(JX,JY),B101(JX,JY),C101(JX,JY) )
+
+ READ(IUNIT) !LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) !PM1
+ READ(IUNIT) !T1
+ READ(IUNIT) !Q1
+ READ(IUNIT) !U1
+ READ(IUNIT) !V1
+ READ(IUNIT) !DZDT ! new
+ READ(IUNIT) !Z1
+ READ(IUNIT) !HLON,HLAT,VLON,VLAT
+ READ(IUNIT) !P1
+ READ(IUNIT) !PD ! surface pressure
+ READ(IUNIT) !ETA1
+ READ(IUNIT) !ETA2
+ READ(IUNIT) A101
+ READ(IUNIT) B101
+ READ(IUNIT) C101
+
+ CLOSE(IUNIT)
+
+ cmax=0.
+ DO J=1,JY
+ DO I=1,JX
+ cmax=max(cmax,C101(I,j))
+ END DO
+ END DO
+
+ if(cmax.lt.0.01)then
+ print*,'cmax=',cmax
+ stop
+ end if
+
+ PRINT*,'JX,JY,NX,NY=',JX,JY,NX,NY
+
+!!!!!!!!!!!!!!!!!!* Read TC vitals ...
+ read(11,11)id_storm,ICLAT,SN,ICLON,EW,Ipsfc,Ipcls, &
+ Irmax,ivobs,Ir_vobs,(Ir_v4(I),I=1,4),DEPTH
+ 11 format(5x,I2,26x,I3,A1,I5,A1,9x,I4,1x,I4,1x,I4,I3,I4,4I5,1x,A1)
+
+ CLAT_NHC=ICLAT*0.1
+ CLON_NHC=ICLON*0.1
+
+ if(SN.eq.'S')CLAT_NHC=-CLAT_NHC
+ if(EW.eq.'W')CLON_NHC=-CLON_NHC
+
+ if(I360.eq.360) then
+ if(CLON_NHC.gt.0.)CLON_NHC=CLON_NHC-360.
+ end if
+!
+ vobs=ivobs*1.0 !* Vmax (m/s)
+ vobs_o= vobs
+ VRmax=Ir_vobs*1. !* RMW (km)
+
+ if (VRmax.lt.19.) VRmax=19.
+
+ VRmax_deg=VRmax/DST1
+
+! if(id_storm.lt.50.and.Ipsfc.gt.1005)Ipsfc=1005
+
+ psfc_obs=Ipsfc*100. !* pmin (Pa)
+ psfc_cls=Ipcls*100. !* pout (Pa)
+
+ PRMAX=Irmax*1. !* ROCI (km)
+
+ R34obs = 0.
+ R34obsm= 0.
+ acount = 0.
+ R34_obs= 0.
+ DO i = 1, 4
+! if ( Ir_v4(i) > 0 ) then
+ if ( Ir_v4(i) < 0 ) Ir_v4(i)=0
+ R34_obs(i) = Ir_v4(i)
+ R34obs = R34obs + Ir_v4(i)
+ acount = acount + 1.
+ if(R34obsm.lt.R34_obs(i)) R34obsm = R34_obs(i)
+! endif
+ ENDDO
+ IF ( acount > 0. ) R34obs = R34obs/acount !* avg R34 [km]
+
+ PRINT*, 'Obsereved Vmax: vobs [m/s], DEPTH =', vobs, DEPTH
+ PRINT*, 'Obsereved RMW: Ir_vobs, VRmax [km] =', Ir_vobs, VRmax
+ PRINT*, 'Obsereved R34: NE,SE,SW,NW,AVG [km] =', Ir_v4, R34obs,R34obsm
+ PRINT*, 'Obsereved ROCI: Irmax, PRmax [km] =', Irmax, PRmax
+ PRINT*, 'Obsereved Pressure: pmin, pout [Pa] =', psfc_obs, psfc_cls
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+! READ Hurricane Pert.
+
+ ALLOCATE ( HLON2(NX,NY),HLAT2(NX,NY) )
+ ALLOCATE ( VLON2(NX,NY),VLAT2(NX,NY) )
+
+ ALLOCATE ( PCST(KMX),HP(NX,NY,KMX) )
+ ALLOCATE ( SLPE(NX,NY),SLP_1(NX,NY),TENV(NX,NY,KMX),TEK(KMX) )
+! ALLOCATE ( QENV(NX,NY,KMX) )
+ ALLOCATE ( T_1(NX,NY,KMX),Q_1(NX,NY,KMX) )
+ ALLOCATE ( U_1(NX,NY,KMX),V_1(NX,NY,KMX) )
+ ALLOCATE ( U_850(NX,NY),V_850(NX,NY) )
+
+ ALLOCATE ( U_S(NX,NY),U_A(NX,NY) )
+ ALLOCATE ( V_S(NX,NY),V_A(NX,NY) )
+
+ ALLOCATE ( USC_1(NX,NY),VSC_1(NX,NY) ) ! hurr comp wind at level 1
+ ALLOCATE ( USC1(NX,NY),VSC1(NX,NY) ) ! Hurricane wind at new grids
+ ALLOCATE ( SLPV(NX,NY) )
+
+ ALLOCATE ( RIJ2(NX,NY),ANG2(NX,NY) )
+
+ ALLOCATE ( PW(KMX),v_maxk(KMX) )
+
+ PW=1.
+
+ SLP_1=0.
+ T_1=0.
+ Q_1=0.
+ U_1=0.
+ V_1=0.
+
+ NCHT=71
+ READ(NCHT)KSTM
+ PRINT*,'test1',KSTM
+
+ READ(NCHT)HLAT2,HLON2
+ READ(NCHT)VLAT2,VLON2
+
+ print*,'HLAT2,HLON2=',HLAT2(1,1),HLON2(1,1)
+ print*,'VLAT2,VLON2=',VLAT2(1,1),VLON2(1,1)
+
+ deltp=1.e20
+
+ READ(NCHT)PCST
+ DO K=1,KMX
+ PRINT*,'K,PCST=',K,PCST(K)
+ deltp1=abs(PCST(K)-85000.)
+ IF (deltp1.LT.deltp) THEN
+ deltp=deltp1
+ k850=k
+ END IF
+ END DO
+
+ k850=1 ! use the surface wind
+
+ READ(NCHT)HP
+
+!.. DO KST=1,KSTM
+ KST=1
+
+ READ(NCHT)ST_NAME(KST)
+ PRINT*,'ST_NAME=',ST_NAME(KST)
+ READ(NCHT)CLON_NEW,CLAT_NEW
+!
+ PRINT*,CLON_NEW,CLAT_NEW
+
+ READ(NCHT)zmax
+
+ print*,'zmax=',zmax
+
+ READ(NCHT)IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ PRINT*,IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ READ(NCHT)((SLPE(I,J),I=1,NX),J=1,NY) ! SLP
+ READ(NCHT)((SLP_1(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1) ! pert SLP
+ WRITE(25)((SLP_1(I,J),I=1,NX),J=1,NY,2)
+ PRINT*,'TEST1'
+ DO K=1,KMX
+ READ(NCHT)((TENV(I,J,K),I=1,NX),J=1,NY)
+ READ(NCHT)((T_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ WRITE(25)((T_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,KMX
+ READ(NCHT)((U_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ READ(NCHT)((V_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ WRITE(25)((U_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,KMX
+ WRITE(25)((V_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+
+ PRINT*,'TEST31'
+ DO K=1,KMX
+!!! READ(NCHT)((QENV(I,J,K),I=1,NX),J=1,NY)
+ READ(NCHT)((Q_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ WRITE(25)((Q_1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+
+! read(NCHT)imn1,imx1,jmn1,jmx1
+! do k=1,kmx
+! read(NCHT)((U_1(i,j,k),i=imn1,imx1),j=jmn1,jmx1) ! U_1
+! read(NCHT)((V_1(i,j,k),i=imn1,imx1),j=jmn1,jmx1) ! V_1
+! end do
+
+! READ(NCHT)((SLPE(I,J),I=1,NX),J=1,NY) ! SLP
+! DO K=1,KMX
+! READ(NCHT)((TENV(I,J,K),I=1,NX),J=1,NY)
+! END DO
+ PRINT*,'TEST41'
+!.. END DO
+
+ CLOSE(NCHT)
+
+! grads output
+
+ NX2=NX*2-1
+
+ ALLOCATE( DUM(NX,NY) )
+ ALLOCATE( DUMA(NX2,NY) )
+
+! call open_grads('storm_pert_in',NX2,NY,KMX,1.0,1.0,1.0,1.0)
+ call open_grads('storm_pert_in',NX,NY,KMX,1.0,1.0,1.0,1.0)
+
+ open(91,file='storm_pert_in',form='unformatted')
+ rewind 91
+
+ do K=1,KMX
+ call load(U_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(V_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(T_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(Q_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ write(91) SLP_1
+! call fill_nmm_gridg(SLP_1,NX,NY,DUMA,1)
+! write(91) DUMA
+
+ close(91)
+
+ DEALLOCATE( DUM, DUMA )
+
+! grads output
+
+
+! save original data for later use
+
+! ALLOCATE ( T_5(NX,NY,KMX),Q_5(NX,NY,KMX) )
+! ALLOCATE ( U_5(NX,NY,KMX),V_5(NX,NY,KMX),SLP_5(NX,NY) )
+
+ ALLOCATE ( T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY) )
+! ALLOCATE ( A11(NZ,3),B11(NZ,3),C11(3) )
+
+! U_5=U_1
+! V_5=V_1
+! T_5=T_1
+! Q_5=Q_1
+! SLP_5=SLP_1
+!
+
+! find storm center TENV
+
+ cost=cos(pi180*CLAT_NEW)
+
+ RIJ2=0.
+ distm=1.E20
+ do j=1,ny
+ do i=1,nx
+ distt=((HLON2(i,j)-CLON_NEW)*cost)**2+(HLAT2(i,j)-CLAT_NEW)**2
+ RIJ2(I,J)=SQRT(distt)
+ if (distm.GT.distt) then
+ distm=distt
+ ictr=i
+ jctr=j
+ end if
+ end do
+ end do
+
+ DO K=1,KMX
+ TEK(K)=TENV(ictr,jctr,K)
+ END DO
+
+
+ DO K=1,KMX
+ v_maxk(k)=0.
+ DO J=JWMIN1,JWMAX1
+ DO I=IWMIN1,IWMAX1
+ v_max1=U_1(I,J,K)*U_1(I,J,K)+V_1(I,J,K)*V_1(I,J,K)
+ if (v_maxk(k).LT.v_max1) v_maxk(k)=v_max1
+ END DO
+ END DO
+ v_maxk(k)=sqrt(v_maxk(k))
+ print*,'K,v_maxk=',K,v_maxk(k)
+ END DO
+
+
+ DO J=1,NY
+ DO I=1,NX
+ U_850(I,J)=U_1(I,J,K850)
+ V_850(I,J)=V_1(I,J,K850)
+ END DO
+ END DO
+
+ ismth_01=0
+
+! IF(IFLAG_Z.LT.10)THEN ! smooth
+! IF(vobs.lt.24..and.DEPTH.ne.'S')THEN
+!!!!!! IF(vobs.lt.24.)THEN
+ IF (vobs .GT. 5.) THEN !* -------------------------------------------->
+
+! go to 665
+
+! smooth first
+
+ ALLOCATE ( T_4(NX,NY,KMX),Q_4(NX,NY,KMX) )
+
+ N_smth=0
+ 667 CONTINUE
+
+ IF (INITOPT .EQ. 0 .and. ismth_01.EQ.1) THEN
+
+ print*,'smooth uv'
+
+ T_4=0.
+ Q_4=0. ! borrow array
+
+!$omp parallel do &
+!$omp& private(i,j,k)
+ DO J=JWMIN1,JWMAX1
+ IF(mod(J,2) .ne. 0)THEN
+ DO I=IWMIN1,IWMAX1
+ DO K=1,KMX
+! T_4(I,J,K)=0.2*(U_1(I,J-1,K)+U_1(I+1,J-1,K)+ &
+! U_1(I,J,K)+U_1(I,J+1,K)+U_1(I+1,J+1,K))
+! Q_4(I,J,K)=0.2*(V_1(I,J-1,K)+V_1(I+1,J-1,K)+ &
+! V_1(I,J,K)+V_1(I,J+1,K)+V_1(I+1,J+1,K))
+ T_4(I,J,K)=(U_1(I,J-1,K)+U_1(I+1,J-1,K)+ &
+ U_1(I,J,K)+U_1(I,J+1,K)+U_1(I+1,J+1,K)+ &
+ U_1(I,J-2,K)+U_1(I,J+2,K)+U_1(I-1,J,K)+ &
+ U_1(I+1,J,K))/9.
+ Q_4(I,J,K)=(V_1(I,J-1,K)+V_1(I+1,J-1,K)+ &
+ V_1(I,J,K)+V_1(I,J+1,K)+V_1(I+1,J+1,K)+ &
+ V_1(I,J-2,K)+V_1(I,J+2,K)+V_1(I-1,J,K)+ &
+ V_1(I+1,J,K))/9.
+ END DO
+ END DO
+ ELSE
+ DO I=IWMIN1,IWMAX1
+ DO K=1,KMX
+! T_4(I,J,K)=0.2*(U_1(I-1,J-1,K)+U_1(I,J-1,K)+ &
+! U_1(I,J,K)+U_1(I-1,J+1,K)+U_1(I,J+1,K))
+! Q_4(I,J,K)=0.2*(V_1(I-1,J-1,K)+V_1(I,J-1,K)+ &
+! V_1(I,J,K)+V_1(I-1,J+1,K)+V_1(I,J+1,K))
+ T_4(I,J,K)=(U_1(I-1,J-1,K)+U_1(I,J-1,K)+ &
+ U_1(I,J,K)+U_1(I-1,J+1,K)+U_1(I,J+1,K)+ &
+ U_1(I,J-2,K)+U_1(I,J+2,K)+U_1(I-1,J,K)+ &
+ U_1(I+1,J,K))/9.
+ Q_4(I,J,K)=(V_1(I-1,J-1,K)+V_1(I,J-1,K)+ &
+ V_1(I,J,K)+V_1(I-1,J+1,K)+V_1(I,J+1,K)+ &
+ V_1(I,J-2,K)+V_1(I,J+2,K)+V_1(I-1,J,K)+ &
+ V_1(I+1,J,K))/9.
+ END DO
+ END DO
+ END IF
+ END DO
+
+ U_1=T_4
+ V_1=Q_4
+
+ print*,'smooth tq'
+
+ T_4=0.
+ Q_4=0. ! borrow array
+
+!$omp parallel do &
+!$omp& private(i,j,k)
+ DO J=JWMIN1,JWMAX1
+ IF(mod(J,2) .ne. 0)THEN
+ DO I=IWMIN1,IWMAX1
+ DO K=1,KMX
+! T_4(I,J,K)=0.2*(T_1(I-1,J-1,K)+T_1(I,J-1,K)+ &
+! T_1(I,J,K)+T_1(I-1,J+1,K)+T_1(I,J+1,K))
+! Q_4(I,J,K)=0.2*(Q_1(I-1,J-1,K)+Q_1(I,J-1,K)+ &
+! Q_1(I,J,K)+Q_1(I-1,J+1,K)+Q_1(I,J+1,K))
+ T_4(I,J,K)=(T_1(I-1,J-1,K)+T_1(I,J-1,K)+ &
+ T_1(I,J,K)+T_1(I-1,J+1,K)+T_1(I,J+1,K)+ &
+ T_1(I,J-2,K)+T_1(I,J+2,K)+T_1(I-1,J,K)+ &
+ T_1(I+1,J,K))/9.
+ Q_4(I,J,K)=(Q_1(I-1,J-1,K)+Q_1(I,J-1,K)+ &
+ Q_1(I,J,K)+Q_1(I-1,J+1,K)+Q_1(I,J+1,K)+ &
+ Q_1(I,J-2,K)+Q_1(I,J+2,K)+Q_1(I-1,J,K)+ &
+ Q_1(I+1,J,K))/9.
+ END DO
+ END DO
+ ELSE
+ DO I=IWMIN1,IWMAX1
+ DO K=1,KMX
+! T_4(I,J,K)=0.2*(T_1(I,J-1,K)+T_1(I+1,J-1,K)+ &
+! T_1(I,J,K)+T_1(I,J+1,K)+T_1(I+1,J+1,K))
+! Q_4(I,J,K)=0.2*(Q_1(I,J-1,K)+Q_1(I+1,J-1,K)+ &
+! Q_1(I,J,K)+Q_1(I,J+1,K)+Q_1(I+1,J+1,K))
+ T_4(I,J,K)=(T_1(I,J-1,K)+T_1(I+1,J-1,K)+ &
+ T_1(I,J,K)+T_1(I,J+1,K)+T_1(I+1,J+1,K)+ &
+ T_1(I,J-2,K)+T_1(I,J+2,K)+T_1(I-1,J,K)+ &
+ T_1(I+1,J,K))/9.
+ Q_4(I,J,K)=(Q_1(I,J-1,K)+Q_1(I+1,J-1,K)+ &
+ Q_1(I,J,K)+Q_1(I,J+1,K)+Q_1(I+1,J+1,K)+ &
+ Q_1(I,J-2,K)+Q_1(I,J+2,K)+Q_1(I-1,J,K)+ &
+ Q_1(I+1,J,K))/9.
+ END DO
+ END DO
+ END IF
+ END DO
+
+ T_1=T_4
+ Q_1=Q_4
+
+! smooth slp
+
+ T_4=0.
+
+!$omp parallel do &
+!$omp& private(i,j)
+ DO J=JWMIN1,JWMAX1
+ IF(mod(J,2) .ne. 0)THEN
+ DO I=IWMIN1,IWMAX1
+! T_4(I,J,1)=0.2*(SLP_1(I-1,J-1)+SLP_1(I,J-1)+ &
+! SLP_1(I,J)+SLP_1(I-1,J+1)+SLP_1(I,J+1))
+ T_4(I,J,1)=(SLP_1(I-1,J-1)+SLP_1(I,J-1)+ &
+ SLP_1(I,J)+SLP_1(I-1,J+1)+SLP_1(I,J+1)+ &
+ SLP_1(I,J-2)+SLP_1(I,J+2)+SLP_1(I-1,J)+ &
+ SLP_1(I+1,J))/9.
+ END DO
+ ELSE
+ DO I=IWMIN1,IWMAX1
+! T_4(I,J,1)=0.2*(SLP_1(I,J-1)+SLP_1(I+1,J-1)+ &
+! SLP_1(I,J)+SLP_1(I,J+1)+SLP_1(I+1,J+1))
+ T_4(I,J,1)=(SLP_1(I,J-1)+SLP_1(I+1,J-1)+ &
+ SLP_1(I,J)+SLP_1(I,J+1)+SLP_1(I+1,J+1)+ &
+ SLP_1(I,J-2)+SLP_1(I,J+2)+SLP_1(I-1,J)+ &
+ SLP_1(I+1,J))/9.
+ END DO
+ END IF
+ END DO
+
+ DO J=JWMIN1,JWMAX1
+ DO I=IWMIN1,IWMAX1
+ SLP_1(I,J)=T_4(I,J,1)
+ END DO
+ END DO
+ END IF
+
+ K=1
+! DO K=1,KMX
+ v_maxk(k)=0.
+ DO J=JWMIN1,JWMAX1
+ DO I=IWMIN1,IWMAX1
+ v_max1=U_1(I,J,K)*U_1(I,J,K)+V_1(I,J,K)*V_1(I,J,K)
+ if (v_maxk(k).LT.v_max1) then
+ v_maxk(k)=v_max1
+ I_max1=I
+ J_max1=J
+ end if
+ END DO
+ END DO
+ v_maxk(k)=sqrt(v_maxk(k))
+ print*,'after smooth K,v_maxk=',K,v_maxk(k)
+! END DO
+
+ IF (INITOPT .EQ. 0 .and. ismth_01.EQ.1) THEN
+
+ N_smth=N_smth+1
+ print*,'N_smth=',N_smth
+ IF(N_smth.lt.2)go to 667
+ IF((N_smth.lt.15.and.VRmax_deg.lt.1.5) &
+ .and.RIJ2(I_max1,J_max1).lt.VRmax_deg)THEN
+ print*,'N_smth,RIJ2,VRmax_deg=',N_smth,RIJ2(I_max1,J_max1),VRmax_deg
+ go to 667
+ END IF
+
+ END IF
+
+ DEALLOCATE ( T_4,Q_4 )
+
+ 665 continue
+
+ RMX_d=max(2.0,3.*VRmax/DST1)
+! RMX_d=max(RMX_d,3.0)
+ IF(RMX_d.gt.3.5)RMX_d=3.5
+
+ PRINT*,'RMX_d2=',RMX_d
+
+ smax1=0.
+ DO J=1,NY
+ DO I=1,NX
+! RIJ2(I,J)=SQRT((VLAT(I,J)-CLAT_NEW)**2+((VLON(I,J)-CLON_NEW)*cost)**2)
+ R05=RIJ2(I,J)
+ smax2=SQRT((U_1(I,J,1)+U1(I,J,1))**2+(V_1(I,J,1)+V1(I,J,1))**2)*C101(I,J)
+ if (smax2.gt.smax1.and.R05.LT.RMX_d) then
+ smax1=smax2
+ i_max=I
+ j_max=J
+ end if
+ END DO
+ END DO
+
+ PRINT*,'10m max wind speed=',i_max,j_max,smax1,C101(i_max,j_max)
+
+ IMV=i_max
+ JMV=j_max
+
+ vobs=vobs_o/(C101(i_max,j_max)+1.E-10)
+
+ beta=1.0
+ UU11=beta*U_1(IMV,JMV,1)
+ VV11=beta*V_1(IMV,JMV,1)
+ UUM1=U1(IMV,JMV,1)
+ VVM1=V1(IMV,JMV,1)
+ QQ=sqrt((uu11**2+vv11**2)*vobs**2-(vv11*uum1-uu11*vvm1)**2)
+
+ beta1=(-(uum1*uu11+vvm1*vv11)+QQ)/(uu11**2+vv11**2+1.E-20)
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+ beta1=min(1.5,max(0.5,beta1))
+
+ print*,'UU11,VV11,UUM1,VVM1,QQ,beta1=',UU11,VV11,UUM1,VVM1,QQ,beta1
+
+ beta=beta*beta1
+
+! estimated final 10m wind
+
+ DO J=1,NY
+ DO I=1,NX
+ U10(I,J)=(beta*U_1(I,J,1)+U1(I,J,1))*C101(I,J)
+ V10(I,J)=(beta*V_1(I,J,1)+V1(I,J,1))*C101(I,J)
+ USCT(I,J)=SQRT((U10(I,J))**2+(V10(I,J))**2)
+ END DO
+ END DO
+
+ smax1=0.
+ DO J=1,NY
+ DO I=1,NX
+ R05=RIJ2(I,J)
+ smax2=USCT(I,J)
+! smax2=SQRT(U_1(I,J,1)**2+V_1(I,J,1)**2)
+ if (smax2.gt.smax1.and.R05.LT.RMX_d) then
+ smax1=smax2
+ i_max=I
+ j_max=J
+ end if
+ END DO
+ END DO
+
+ PRINT*,'10m max wind speed after correction=',i_max,j_max,smax1
+
+ JCTRM1=jctr-1
+ JCTRP1=jctr+1
+ ICTRM1=ictr-1
+ ICTRP1=ictr+1
+
+ PRMAX2=0.95*PRMAX
+
+! look for max R34 in first quadrat
+
+ v34kt= 34./1.944 !* m/s
+ v50kt= 50./1.944 !* m/s
+ v64kt= 64./1.944 !* m/s
+
+ DO J=1,NY
+ DO I=1,NX
+ RIJ2(I,J)=RIJ2(I,J)*DST1
+ END DO
+ END DO
+
+ R34_F=0.
+ I34_F=0
+ J34_F=0
+ DO J=JCTRP1,NY
+ DO I=ICTRP1,NX
+ IF(RIJ2(I,J).LT.PRMAX2)THEN
+ IF((USCT(I,J).GT.v34kt).and.(RIJ2(I,J).GT.R34_F(1)))THEN
+ R34_F(1)=RIJ2(I,J)
+ I34_F(1)=I
+ J34_F(1)=J
+ END IF
+ END IF
+ END DO
+ END DO
+
+! look for max R34 in second quadrant
+
+ DO J=JCTRP1,NY
+ DO I=1,ICTRM1
+ IF(RIJ2(I,J).LT.PRMAX2)THEN
+ IF((USCT(I,J).GT.v34kt).and.(RIJ2(I,J).GT.R34_F(2)))THEN
+ R34_F(2)=RIJ2(I,J)
+ I34_F(2)=I
+ J34_F(2)=J
+ END IF
+ END IF
+ END DO
+ END DO
+
+! look for max R34 in third quadrant
+
+ DO J=1,JCTRM1
+ DO I=1,ICTRM1
+ IF(RIJ2(I,J).LT.PRMAX2)THEN
+ IF((USCT(I,J).GT.v34kt).and.(RIJ2(I,J).GT.R34_F(3)))THEN
+ R34_F(3)=RIJ2(I,J)
+ I34_F(3)=I
+ J34_F(3)=J
+ END IF
+ END IF
+ END DO
+ END DO
+
+! look for max R34 in fourth quadrant
+
+ DO J=1,JCTRM1
+ DO I=ICTRP1,NX
+ IF(RIJ2(I,J).LT.PRMAX2)THEN
+ IF((USCT(I,J).GT.v34kt).and.(RIJ2(I,J).GT.R34_F(4)))THEN
+ R34_F(4)=RIJ2(I,J)
+ I34_F(4)=I
+ J34_F(4)=J
+ END IF
+ END IF
+ END DO
+ END DO
+
+ print*,'I34_F(1),J34_F(1),R34_F(1)=',I34_F(1),J34_F(1),R34_F(1)
+ print*,'I34_F(2),J34_F(2),R34_F(2)=',I34_F(2),J34_F(2),R34_F(2)
+ print*,'I34_F(3),J34_F(3),R34_F(3)=',I34_F(3),J34_F(3),R34_F(3)
+ print*,'I34_F(4),J34_F(4),R34_F(4)=',I34_F(4),J34_F(4),R34_F(4)
+
+!
+! computer correlation using cylindrical grid
+
+ IR1=120
+ IR =120-1
+ DR1=0.1
+! IT1=180
+! DA1=2.*pi180 ! 1 degree
+ IT1=72
+ DA1=5.*pi180 ! 1 degree
+
+ IR0=3
+ IT2=IT1+1
+
+ ALLOCATE ( RADUS(IR1),ANGL(IT2) )
+ ALLOCATE ( GLON1(IR1,IT1),GLAT1(IR1,IT1) )
+ ALLOCATE ( INDX1(IR1,IT1,50),INDY1(IR1,IT1,50) ) ! for H grid
+ ALLOCATE ( WTXY1(IR1,IT1,50),WTSM1(IR1,IT1) ) ! for H grid
+ ALLOCATE ( INDX2(IR1,IT1,50),INDY2(IR1,IT1,50) ) ! for V grid
+ ALLOCATE ( WTXY2(IR1,IT1,50),WTSM2(IR1,IT1) ) ! for V grid
+
+ ALLOCATE ( IJ_COUNT1(IR1,IT1),IJ_COUNT2(IR1,IT1) )
+
+ ALLOCATE ( U_2(IR1,IT2,KMX),V_2(IR1,IT2,KMX) )
+ ALLOCATE ( U_2S(IR1,KMX),V_2S(IR1,KMX) )
+ ALLOCATE ( T_2S(IR1,KMX),Q_2S(IR1,KMX),SLP_2S(IR1,2) )
+
+ ALLOCATE ( U_2S1(IR1,KMX),RADIUS1(IR1),CFT(IR1) )
+ ALLOCATE ( RKX1(IR1),RKX2(IR1),WKX1(IR1,KMX),WKX2(IR1,KMX) )
+ ALLOCATE ( strm1(IR1,KMX),strm2(IR1,KMX),strm3(IR1,KMX) )
+
+ INDX1=0
+ INDY1=0
+ WTXY1=0.
+ WTSM1=0.
+
+ INDX2=0
+ INDY2=0
+ WTXY2=0.
+ WTSM2=0.
+
+ IJ_COUNT1=0
+ IJ_COUNT2=0
+
+ DO I=1,IR1
+ RADUS(I)=DR1*I
+ END DO
+ DO J=1,IT2
+ ANGL(J)=DA1*(J-1)
+! print*,'ANGL=',ANGL(J)
+ END DO
+
+
+ DO J=1,IT1
+ DO I=1,IR1
+ GLON1(I,J)=CLON_NEW+RADUS(I)*COS(ANGL(J))
+ GLAT1(I,J)=CLAT_NEW+RADUS(I)*SIN(ANGL(J))
+ END DO
+ END DO
+
+ cost=cos(pi180*CLAT_NEW)
+
+! compute weight for cylindrical coord
+
+ RCT=0.05
+ RCT2=RCT*RCT
+
+!$omp parallel do &
+!$omp& private(i,j,i2,j2,DSTX,DSTY,RDT2)
+ DO J=1,IT1
+ DO I=1,IR1
+ DO J2=1,NY
+ DO I2=1,NX
+!.. DO J2=JWMIN1,JWMAX1
+!.. DO I2=IWMIN1,IWMAX1
+ DSTX=(GLON1(I,J)-HLON2(I2,J2))*cost ! H point
+ DSTY=GLAT1(I,J)-HLAT2(I2,J2)
+ RDT2=DSTX*DSTX+DSTY*DSTY
+ IF (RDT2.LT.RCT2) THEN
+ IJ_COUNT1(I,J)=IJ_COUNT1(I,J)+1
+ INDX1(I,J,IJ_COUNT1(I,J))=I2
+ INDY1(I,J,IJ_COUNT1(I,J))=J2
+! WTXY1(I,J,IJ_COUNT1(I,J))=0.3+0.7*(RCT2-RDT2)/(RCT2+RDT2)
+ WTXY1(I,J,IJ_COUNT1(I,J))=1.0
+ WTSM1(I,J)=WTSM1(I,J)+WTXY1(I,J,IJ_COUNT1(I,J))
+ END IF
+ END DO
+ END DO
+ END DO
+ END DO
+!$omp parallel do &
+!$omp& private(i,j,i2,j2,DSTX,DSTY,RDT2)
+ DO J=1,IT1
+ DO I=IR0,IR1
+ DO J2=1,NY
+ DO I2=1,NX
+!.. DO J2=JWMIN1,JWMAX1
+!.. DO I2=IWMIN1,IWMAX1
+ DSTX=(GLON1(I,J)-VLON2(I2,J2))*cost ! V point
+ DSTY=GLAT1(I,J)-VLAT2(I2,J2)
+ RDT2=DSTX*DSTX+DSTY*DSTY
+ IF (RDT2.LT.RCT2) THEN
+ IJ_COUNT2(I,J)=IJ_COUNT2(I,J)+1
+ INDX2(I,J,IJ_COUNT2(I,J))=I2
+ INDY2(I,J,IJ_COUNT2(I,J))=J2
+! WTXY2(I,J,IJ_COUNT2(I,J))=0.3+0.7*(RCT2-RDT2)/(RCT2+RDT2)
+ WTXY2(I,J,IJ_COUNT2(I,J))=1.0
+ WTSM2(I,J)=WTSM2(I,J)+WTXY2(I,J,IJ_COUNT2(I,J))
+ END IF
+ END DO
+ END DO
+ END DO
+ END DO
+
+! compute tangential wind & radial wind
+
+ KM1=3
+! KM1=60
+
+ U_2=0.
+ V_2=0. ! borrow array
+
+!$omp parallel do &
+!$omp& private(i,j,k,i2,j2,m1)
+ DO J=1,IT1
+ DO I=IR0,IR1
+ DO M1=1,IJ_COUNT2(I,J)
+ I2=INDX2(I,J,M1)
+ J2=INDY2(I,J,M1)
+ DO K=1,KM1
+ U_2(I,J,K)=U_2(I,J,K)+U_1(I2,J2,K)*WTXY2(I,J,M1)
+ V_2(I,J,K)=V_2(I,J,K)+V_1(I2,J2,K)*WTXY2(I,J,M1)
+ END DO
+ END DO
+ END DO
+ END DO
+!$omp parallel do &
+!$omp& private(i,j,k)
+ DO J=1,IT1
+ DO I=IR0,IR1
+ DO K=1,KM1
+ U_2(I,J,K)=U_2(I,J,K)/(WTSM2(I,J)+1.E-20)
+ V_2(I,J,K)=V_2(I,J,K)/(WTSM2(I,J)+1.E-20)
+ END DO
+ END DO
+ END DO
+
+!$omp parallel do &
+!$omp& private(i,j,k,UT1,VT1)
+ DO K=1,KM1
+ DO J=1,IT1
+ DO I=IR0,IR1
+ UT1=-sin(ANGL(J))*U_2(I,J,K)+cos(ANGL(J))*V_2(I,J,K)
+ VT1= cos(ANGL(J))*U_2(I,J,K)+sin(ANGL(J))*V_2(I,J,K)
+ U_2(I,J,K)=UT1 ! U_2 becomes tangential wind
+ V_2(I,J,K)=VT1 ! V_2 becomes radial wind
+ END DO
+ END DO
+ END DO
+
+! computer axi_symmetry storm
+
+ U_2S=0.
+ V_2S=0.
+ DO K=1,KM1
+ DO I=IR0,IR1
+ usum=0.
+ vsum=0.
+ DO J=1,IT1
+ usum=usum+U_2(I,J,K)
+ vsum=vsum+V_2(I,J,K)
+ END DO
+ U_2S(I,K)=usum/float(IT1)
+ V_2S(I,K)=vsum/float(IT1)
+ END DO
+ END DO
+
+ DO I=1,IR0
+ r_wt=RADUS(I)/RADUS(IR0)
+ DO K=1,KM1
+ U_2S(I,K)=U_2S(IR0,K)*r_wt
+ V_2S(I,K)=V_2S(IR0,K)*r_wt
+ END DO
+ END DO
+
+! check the asymmetry of the storm
+
+! asym_11=0.
+! asym_12=0.
+! asym_21=0.
+! asym_22=0.
+! asym_31=0.
+! asym_32=0.
+! DO I=1,IR1
+! usum=0.
+! DO J=1,IT1
+! usum=usum+abs(U_2(I,J,3)-U_2S(I,3))
+! END DO
+! asym_11=asym_11+usum/IT1
+! asym_12=asym_12+abs(U_2S(I,3))
+! asym_21=asym_21+usum/IT1*sqrt(RADUS(I))
+! asym_22=asym_22+abs(U_2S(I,3))*sqrt(RADUS(I))
+! asym_31=asym_31+abs(U_2S(I,3))*RADUS(I)
+! asym_32=asym_32+abs(U_2S(I,3))*RADUS(I)
+! END DO
+! print*,'T-wind, asym_11,12=',asym_11,asym_12,asym_11/(asym_12+1.E-20)
+! print*,'T-wind, asym_21,22=',asym_21,asym_22,asym_21/(asym_22+1.E-20)
+! print*,'T-wind, asym_31,32=',asym_31,asym_32,asym_31/(asym_32+1.E-20)
+
+!
+ print*,'smooth t,r'
+
+ U_2=0.
+ V_2=0. ! borrow array
+
+!$omp parallel do &
+!$omp& private(i,j,k,i2,j2,m1)
+ DO J=1,IT1
+ DO I=1,IR1
+ DO M1=1,IJ_COUNT1(I,J)
+ I2=INDX1(I,J,M1)
+ J2=INDY1(I,J,M1)
+ DO K=1,KMX
+ U_2(I,J,K)=U_2(I,J,K)+T_1(I2,J2,K)*WTXY1(I,J,M1)
+ V_2(I,J,K)=V_2(I,J,K)+Q_1(I2,J2,K)*WTXY1(I,J,M1)
+ END DO
+ END DO
+ END DO
+ END DO
+!$omp parallel do &
+!$omp& private(i,j,k)
+ DO J=1,IT1
+ DO I=1,IR1
+ DO K=1,KMX
+ U_2(I,J,K)=U_2(I,J,K)/(WTSM1(I,J)+1.E-20)
+ V_2(I,J,K)=V_2(I,J,K)/(WTSM1(I,J)+1.E-20)
+ END DO
+ END DO
+ END DO
+
+! computer axi_symmetry storm
+
+ T_2S=0.
+ Q_2S=0.
+ DO K=1,KMX
+ DO I=1,IR1
+ usum=0.
+ vsum=0.
+ DO J=1,IT1
+ usum=usum+U_2(I,J,K)
+ vsum=vsum+V_2(I,J,K)
+ END DO
+ T_2S(I,K)=usum/float(IT1)
+ Q_2S(I,K)=vsum/float(IT1)
+ END DO
+ END DO
+
+
+! smooth slp
+
+ print*,'test4='
+
+ U_2=0.
+
+!$omp parallel do &
+!$omp& private(i,j,i2,j2,m1)
+ DO J=1,IT1
+ DO I=1,IR1
+ DO M1=1,IJ_COUNT1(I,J)
+ I2=INDX1(I,J,M1)
+ J2=INDY1(I,J,M1)
+ U_2(I,J,1)=U_2(I,J,1)+SLP_1(I2,J2)*WTXY1(I,J,M1)
+ END DO
+ END DO
+ END DO
+
+ DO J=1,IT1
+ DO I=1,IR1
+ U_2(I,J,1)=U_2(I,J,1)/(WTSM1(I,J)+1.E-20)
+ END DO
+ END DO
+
+! computer axi_symmetry storm
+
+ SLP_2S=0.
+ DO I=1,IR1
+ usum=0.
+ DO J=1,IT1
+ usum=usum+U_2(I,J,1)
+ END DO
+ SLP_2S(I,1)=usum/IT1
+ print*,'SLP_2S(I,1)=',I,SLP_2S(I,1)
+ END DO
+
+! check the asymmetry of the storm
+
+! asym_11=0.
+! asym_12=0.
+! asym_21=0.
+! asym_22=0.
+! asym_31=0.
+! asym_32=0.
+! DO I=1,IR1
+! usum=0.
+! DO J=1,IT1
+! usum=usum+abs(U_2(I,J,1)-SLP_2S(I,1))
+! END DO
+! asym_11=asym_11+usum/IT1
+! asym_12=asym_12+abs(SLP_2S(I,1))
+! asym_21=asym_21+usum/IT1*sqrt(RADUS(I))
+! asym_22=asym_22+abs(SLP_2S(I,1))*sqrt(RADUS(I))
+! asym_31=asym_31+usum/IT1*RADUS(I)
+! asym_32=asym_32+abs(SLP_2S(I,1))*RADUS(I)
+! END DO
+! print*,'MSLP asym_11,12=',asym_11,asym_12,asym_11/(asym_12+1.E-20)
+! print*,'MSLP asym_21,22=',asym_21,asym_22,asym_21/(asym_22+1.E-20)
+! print*,'MSLP asym_31,32=',asym_31,asym_32,asym_31/(asym_32+1.E-20)
+
+! computer fact (size)
+
+ print*,'model center pressure=',SLP_2S(1,1)
+
+ pres_ct=(Psfc_obs-Psfc_cls)/SLP_2S(1,1)
+
+ print*,'pres_ct=',pres_ct
+
+ DO I=1,IR1
+ SLP_2S(I,2)=SLP_2S(I,1)*pres_ct
+ END DO
+
+ IRAD_1=1
+ DO I=1,IR1
+ IF ( abs(SLP_2S(I,2)) .GT. 20. ) THEN !* Model ROCI ?
+ IRAD_1=I
+ END IF
+ END DO
+
+ RAD_1=(IRAD_1+0.5)*DR1*DST1 !* model ROCI
+
+ fact_p=2.*PRMAX/(PRMAX+RAD_1)
+
+ PRINT*, 'fact_p, PRMAX, RAD_1 = ', fact_p, PRMAX, RAD_1
+
+
+! compute weight
+
+ END IF !* <------------------------------------------------------------
+
+! small correction to make the wind speed close to observation
+
+! v_max=0.
+
+! DO J=JWMIN1,JWMAX1
+! DO I=IWMIN1,IWMAX1
+! v_max1=U_1(I,J,1)*U_1(I,J,1)+V_1(I,J,1)*V_1(I,J,1)
+! if(v_max.lt.v_max1)v_max=v_max1
+! END DO
+! END DO
+ v_max=v_maxk(1)/1.15
+
+ print*,'estimate v_max_1=',v_max
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+! STORM SIZE CORRECTION
+
+ R34mod=0.
+ R34modm=0.
+ acount = 0.
+
+ do j=1,4
+ if ( R34_F(j).le.10. ) R34_F(j)=0.
+! if ( R34_F(j) > 10. ) then
+ R34mod=R34mod+R34_F(j)
+ acount = acount + 1.
+ if(R34modm.lt.R34_F(j)) R34modm = R34_F(j)
+! end if
+ end do
+ IF ( acount > 0. ) R34mod = R34mod/acount !* avg R34 [km]
+
+ print*,'model storm size,R34mod,R34modm=',R34mod,R34modm
+
+ deg2rad= pi/180.
+ deg2m = deg2rad*6.371E6 !* deg -> m
+ deg2km = deg2rad*6.371E3 !* deg -> m
+
+ n_iter=0
+ max_iter=10
+ ftmin=0.85
+! ftmax=1.15
+ ftmax=1.12
+! ctmin=0.85
+! ctmax=1.15
+ ctmin=0.85
+ ctmax=1.1
+ dmin=min(150.,0.8*prmax)/deg2km
+ roc_add=max(300.,0.8*prmax)/deg2km
+
+! model RMW & ROCI
+
+! Rmax_0=RIJ2(i_max,j_max)*1.05
+! Rmax_0=RIJ2(i_max,j_max)*1.1
+ Rmax_0=RIJ2(i_max,j_max)
+
+ print*,'vobs,vobs_o,USCT(i_max,j_max)=',vobs,vobs_o,USCT(i_max,j_max)
+
+! if(USCT(i_max,j_max).gt.v64kt)then
+! roc1=R34mod
+! roc2=R34obs
+! else
+! roc1=R34modm
+! roc2=R34obsm
+! end if
+! roc1=R34modm*1.25
+ roc1=R34modm
+ roc2=R34obsm
+
+ if(roc1.lt.50..or.roc2.lt.50.)then
+ roc1=50.
+ roc2=50.
+ end if
+
+!* Observed RMW & ROCI
+!* ~~~~~~~~~~~~~~~~~~~
+! rmw2 = vrmax
+! roc2 = prmax
+
+ rmw1 = max(Rmax_0/deg2km,0.01)
+! rmw2 = (0.3*Rmax_0+0.7*VRmax)/deg2km !* target RMW [deg]
+ rmw2 = 0.5*(rmw1+VRmax/deg2km) !* target RMW [deg]
+! rmw2 = (0.3*rmw1+0.7*VRmax/deg2km) !* target RMW [deg]
+
+ rmw_rat=rmw2/rmw1
+ rmw2_limit=19./deg2km
+
+ roc1=roc1/deg2km
+ roc2=roc2/deg2km
+ roc1_t=roc1
+ roc2_t=roc2
+
+ roc_rat=roc2/roc1
+
+ roc_max=max(3.3,0.95*prmax/deg2km)
+
+! max corection 15%
+ ftmin=0.95-(Rmax_0-20.)*0.005
+ if(Rmax_0.GE.40.)then
+ ftmin=0.85
+ else if(Rmax_0.LE.20.)then
+ ftmin=0.95
+ end if
+! ftmax=1.1
+
+ IF (DEPTH.eq.'S') THEN
+ ftmin=1.0-(Rmax_0-20.)*0.005
+ if(Rmax_0.GE.50.)then
+ ftmin=0.85
+ else if(Rmax_0.LE.30.)then
+ ftmin=0.95
+ end if
+ ELSE IF (DEPTH.eq.'M') THEN
+ ftmin=1.0-(Rmax_0-20.)*0.005
+ if(Rmax_0.GE.50.)then
+ ftmin=0.85
+ else if(Rmax_0.LE.30.)then
+ ftmin=0.95
+ end if
+ END IF
+
+ print*,'before adjusted storm size'
+ print*,'model rmw1,roc1=',rmw1,roc1
+ print*,'observed rmw2,roc2=',rmw2,roc2
+
+! if(roc1.lt.15..or.roc2.lt.15..or.vobs_o.lt.v64kt)then
+ if(vobs_o.le.v64kt)then
+ ftmin=1.0-(Rmax_0-20.)*0.005
+ if(Rmax_0.GE.50.)then
+ ftmin=0.85
+ else if(Rmax_0.LE.30.)then
+ ftmin=0.95
+ end if
+! rmw2 = 0.5*(rmw1+VRmax/deg2km) !* target RMW [deg]
+! if(roc2.gt.1.3*roc1)then
+! roc1=roc_add
+! roc2=roc_rat*roc1
+! if(rmw2.lt.0.9*rmw1)rmw2=0.9*rmw1
+! end if
+! if(roc1_t.gt.0.5.and.roc2_t.gt.0.5)then
+! if(rmw_rat.gt.1.0)then
+! roc2=0.5*(roc_rat+rmw_rat)*roc1
+! end if
+! end if
+ end if
+
+ if(Rmax_0.LT.19..and.VRmax.LT.19.)then
+ ftmin=1.0
+ end if
+ if(ftmin.lt.0.85)ftmin=0.85
+! ftmax=1.15
+ ftmax=1.12
+ roc_rat1=max(0.7,min(1.3,roc1/roc2))
+ roc1=roc_rat1*roc2
+
+ if((roc1.lt.(rmw1+dmin)).or.(roc2.lt.(rmw2+dmin)))then
+ dmax=max(rmw1-roc1,rmw2-roc2)
+ roc1=roc1+dmax+dmin
+ roc2=roc2+dmax+dmin
+ if(roc1_t.gt.0.5.and.roc2_t.gt.0.5)then
+ roc1=max(roc1,(0.7*roc_rat1+0.3*roc1/roc2)*roc2)
+! if(rmw_rat.gt.1.0.and.vobs_o.le.v64kt)then
+! roc2=0.5*(roc_rat+rmw_rat)*roc1
+! end if
+ else
+ roc1=roc1+dmax+roc_add
+ roc2=roc2+dmax+roc_add
+ end if
+ end if
+
+ print*,'dmax,roc_add=',dmax,roc_add
+
+ print*,'adjusted storm size'
+ print*,'model rmw1,roc1=',rmw1,roc1
+ print*,'observed rmw2,roc2=',rmw2,roc2
+
+ rmw1_mod=rmw1
+ roc1_mod=roc1
+ rmw2_obs=rmw2
+ roc2_obs=roc2
+
+ RKX1=0.
+ DO n=1,IR1
+ RKX1(n)=RADUS(n)*deg2m !* deg -> m
+! print*,'RKX1(n)=',RKX1(n),U_2S(n,1)
+ END DO
+
+ k=1
+ k1=2
+ WKX1=0.
+ DO n=1,IR1
+ WKX1(n,1)=U_2S(n,1)
+!
+! Chanh fixed here the dateline issue for SH streamline
+!
+ if (CLAT_NEW.lt.0) then
+ IF(WKX1(n,k).gt.0.)WKX1(n,k)=0.
+ else
+ IF(WKX1(n,k).lt.0.)WKX1(n,k)=0.
+ endif
+ END DO
+
+ WKX2=0.
+ DO n=1,IR1
+ WKX2(n,1)=U_2S(n,1)*beta
+!
+! Chanh fixed here the dateline issue for SH streamline
+!
+ if (CLAT_NEW.lt.0) then
+ IF(WKX2(n,1).gt.0.)WKX2(n,1)=0.
+ else
+ IF(WKX2(n,1).lt.0.)WKX2(n,1)=0.
+ endif
+ END DO
+
+ ff0=2.*7.292E-5*sin(clat_new*pi180)
+
+ strm1=0.
+ strm3=0.
+ DO n=IR,1,-1
+ force=(WKX1(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX1(n,k)
+ strm1(n,k)=strm1(n+1,k)-force*(RKX1(n+1)-RKX1(n))
+ force3=(WKX2(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm3(n,k)=strm3(n+1,k)-force3*(RKX1(n+1)-RKX1(n))
+ END DO
+
+ SLP_MD=SLP_2S(1,1)*strm3(1,1)/(strm1(1,1)-1.E-20)+SLPE(ictr,jctr)
+! SLP_MD=SLP_1(ictr,jctr)+SLPE(ictr,jctr)
+
+ print*,'SLP_2S(1,1),SLP_1(ictr,jctr)=',SLP_2S(1,1),SLP_1(ictr,jctr)
+
+! IF((SLP_MD-Psfc_obs).GE.(-100.0))THEN
+! rmw_min=min(rmw1,rmw2_obs)
+! if(rmw1.lt.1.0.and.rmw_min.lt.0.8)then
+! rmw2=rmw2_obs
+! roc2=roc2_obs
+! rmw1=rmw_min
+! roc1=min(roc1,roc2)
+! end if
+! ELSE
+! if(rmw_rat.lt.1.)then
+! roc1=max(roc2/rmw_rat,roc1)
+! else
+! rmw1=max(rmw1,rmw2)
+! roc1=max(roc1,roc2)
+! end if
+! ddd = 1./(roc1*rmw1*(roc1-rmw1))
+! aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+! bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+! END IF
+
+! if(roc1.gt.roc_max)roc1=roc_max
+! if(roc2.gt.roc_max)roc2=roc_max
+ IF(roc1.gt.roc_max.or.roc2.gt.roc_max)THEN
+ rocx_rat=roc_max/max(roc1,roc2)
+ roc1=rocx_rat*roc1
+ roc2=rocx_rat*roc2
+ if(roc2.gt.roc1)roc2=0.5*(roc1+roc2)
+ ELSE IF(roc1.lt.2.5.or.roc2.lt.2.5)THEN
+ rocx_rat=5./(roc1+roc2)
+ roc1=rocx_rat*roc1
+ roc2=rocx_rat*roc2
+ if(roc2.gt.roc1)roc2=0.5*(roc1+roc2)
+ ELSE
+ if(roc2.gt.roc1)roc2=0.5*(roc1+roc2)
+ END IF
+
+ rmw2_0=rmw2
+ roc2_0=roc2
+
+ REWIND(65)
+ READ(65)RMN_HWRF
+ IF(RMN_HWRF.lt.(PRMAX/deg2km))THEN
+ if(roc1.gt.roc2)roc2=roc1
+ if(rmw1.gt.rmw2)rmw2=rmw1
+ END IF
+
+ xxx = ftmin*rmw1 ; yyy = ftmax*rmw1 !* 50% Constraint
+ rmw2 = max(xxx,min(rmw2,yyy)) !* for bogus stretch
+ xxx = ctmin*roc1 ; yyy = ctmax*roc1 !* 50% Constraint
+ roc2 = max(xxx,min(roc2,yyy)) !* for bogus stretch
+
+! if(beta.lt.1.)then
+! if(roc1_t.gt.0.5.and.roc2_t.gt.0.5)then
+! if(rmw2.gt.rmw1)rmw2=rmw1
+! if(roc2.gt.roc1)roc2=roc1
+! end if
+! end if
+
+ ddd = 1./(roc1*rmw1*(roc1-rmw1))
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+
+ print*,'model rmw1,roc1=',rmw1,roc1
+ print*,'observed rmw2,roc2=',rmw2,roc2
+ print*,'First Guess: aaa,bbb=',aaa,bbb
+
+ if(bbb.gt.0.1)then
+ bbb=0.1
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa=(rmw2*roc1**2-rmw1**2*roc2)*ddd
+ else if(bbb.lt.(-0.1))then
+ bbb=-0.1
+ roc2=0.5*bbb*roc1*(roc1-rmw1)+roc1*rmw2/rmw1
+ aaa=(rmw2*roc1**2-rmw1**2*roc2)*ddd
+ end if
+
+! bbb = max(-0.3,min(bbb,0.3))
+ aaa = max( 0.85, min(aaa,1.15) )
+
+ print*,'adjusted aaa,bbb=',aaa,bbb
+
+ RKX2=0.
+ DO n=1,IR1
+ RADIUS1(n) = aaa*RADUS(n) + .5*bbb*RADUS(n)**2
+ RKX2(n) = RADIUS1(n)*deg2m !* deg -> m
+ END DO
+
+ k=1
+ k1=2
+ strm2=0.
+ DO n=IR,1,-1
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ END DO
+
+ SLP_T=SLP_2S(1,1)*strm2(1,1)/(strm1(1,1)-1.E-20)+SLPE(ictr,jctr)
+
+ print*,'SLP_2S(1,1),SLPE(ictr,jctr)=',SLP_2S(1,1),SLPE(ictr,jctr)
+ print*,'SLP_T,Psfc_obs,=',SLP_T,Psfc_obs
+ print*,'strm2(1,1),strm1(1,1)=',strm2(1,1),strm1(1,1)
+
+ diff_p=SLP_T-Psfc_obs
+ diff_p_x=200.
+ diff_p_n=-200.
+ it_flag=3
+
+ IF(diff_p.lt.diff_p_n)THEN
+
+ 969 CONTINUE
+
+ n_iter=n_iter+1
+
+ xxx = ftmin*rmw1 ; yyy = ftmax*rmw1 !* 50% Constraint
+ rmw2 = max(xxx,min(rmw2,yyy)) !* for bogus stretch
+ xxx = ctmin*roc1 ; yyy = ctmax*roc1 !* 50% Constraint
+ roc2 = max(xxx,min(roc2,yyy)) !* for bogus stretch
+
+ ddd = 1./(roc1*rmw1*(roc1-rmw1))
+ aaa = (rmw2*roc1**2-rmw1**2*roc2)*ddd
+ bbb = 2.*(roc2*rmw1-roc1*rmw2)*ddd
+
+ print*,'final adjusted storm size', n_iter
+ print*,'model rmw1,roc1=',rmw1,roc1
+ print*,'observed rmw2,roc2=',rmw2,roc2
+
+ print*,'aaa,bbb=',aaa,bbb
+
+ bbb = max(-0.1,min(bbb,0.1))
+ aaa = max( 0.85, min(aaa,1.15) )
+
+ print*,'after aconstraint: aaa,bbb=',aaa,bbb
+
+ if(n_iter.le.max_iter)then
+
+ RKX2=0.
+ DO n=1,IR1
+ RADIUS1(n) = aaa*RADUS(n) + .5*bbb*RADUS(n)**2
+ RKX2(n) = RADIUS1(n)*deg2m !* deg -> m
+ END DO
+
+ k=1
+ k1=2
+ strm2=0.
+ DO n=IR,1,-1
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ END DO
+! need to define variables
+
+ SLP_T=SLP_2S(1,1)*strm2(1,1)/(strm1(1,1)-1.E-20)+SLPE(ictr,jctr)
+ DELT_P=(Psfc_cls-Psfc_obs)
+ diff_p=SLP_T-Psfc_obs
+
+ print*,'SLP_2S(1,1),strm2(1,1),strm1(1,1),SLPE(ictr,jctr)=', &
+ SLP_2S(1,1),strm2(1,1),strm1(1,1),SLPE(ictr,jctr)
+ print*,'SLP_T,Psfc_obs,Psfc_cls,DELT_P=',SLP_T,Psfc_obs,Psfc_cls,DELT_P
+
+ if(diff_p.gt.diff_p_x.and.it_flag.eq.1)then
+ ftmax=ftmax+0.005
+ rmw1_new=ftmax*rmw1
+ if(rmw1_new.gt.rmw2_0)then
+ rmw2=min(rmw1_new,(1.+0.005*n_iter)*rmw2_0)
+ end if
+ ctmax=ctmax+0.01
+ roc1_new=ctmax*roc1
+ if(roc1_new.gt.roc2_0)then
+ roc2=min(roc1_new,(1.+0.01*n_iter)*roc2_0)
+ end if
+ go to 969
+ else if (diff_p.lt.diff_p_n.and.it_flag.eq.2)then
+! if(Rmax_0.gt.40.)then
+ ftmin=ftmin-0.005
+ rmw1_new=ftmin*rmw1
+ if(rmw1_new.lt.rmw2_0)then
+ rmw2=max(rmw1_new,(1.-0.005*n_iter)*rmw2_0)
+ rmw2=max(rmw2_limit,rmw2)
+ end if
+! end if
+ ctmin=ctmin-0.02
+ roc1_new=ctmin*roc1
+ if(roc1_new.lt.roc2_0)then
+ roc2=max(roc1_new,(1.-0.02*n_iter)*roc2_0)
+ end if
+ go to 969
+ end if
+
+ end if
+
+ END IF
+
+
+ print*,'aaa,bbb=',aaa,bbb
+ print*,'ftmin,ftmax,ctmin,ctmax=',ftmin,ftmax,ctmin,ctmax
+ print*,'rmw2_0,roc2_0=',rmw2_0,roc2_0
+ print*,'model storm size,R34mod,R34modm=',R34mod,R34modm
+ print*,'observed storm size,R34obs,R34obsm=',R34obs,R34obsm
+ print*,'rmw1,rmw2,roc1,roc2=',rmw1,rmw2,roc1,roc2
+ print*,'SLP_T,Psfc_obs,Psfc_cls=',SLP_T,Psfc_obs,Psfc_cls
+
+! save aaa,bbb,rmw1,rmw2, will be used in size correction.
+
+
+ scale1=1.0 ! qingfu test
+ beta_ct=1.0 ! qingfu test
+
+ print*,'correction factor scale,beta_ct=',scale1,beta_ct
+
+
+ beta11=beta_ct*scale1
+ fact=1.0
+
+ U_2S1=0.
+ DO K=1,KM1
+ DO I=1,IR1
+ U_2S1(I,K)=U_2S(I,K)*beta11
+ END DO
+ END DO
+
+ DO I=1,IR1
+! RADIUS1(I)=RADUS(I)*DST*1.E3
+ RADIUS1(I)=RADUS(I)
+ END DO
+
+ print*,'before call CORT_MAT, beta11=',beta11
+
+! if(abs(beta11-1.).gt.0.01)then
+
+ CALL CORT_MAT(IR1,NX,NY,NZ,KMX,U_2S,T_2S,Q_2S,SLP_2S(1,1), &
+ U_2S1,T_X,Q_X,SLP_X,HLON2,HLAT2,VLON2,VLAT2, &
+ TEK,PCST,RADUS,RADIUS1,CLON_NEW,CLAT_NEW, &
+ CFT,beta11,IR_1,IFLAG,KM1)
+
+ print*,'after call CORT_MAT'
+
+ IF (INITOPT .EQ. 0) THEN
+!$omp parallel do &
+!$omp& private(i,j,k,TEK1,TEK2,ESRR)
+ DO J=1,NY
+ DO I=1,NX
+ SLP_1(I,J)=SLP_1(I,J)*beta11+SLP_X(I,J)
+ DO K=1,KMX
+ TEK1=TENV(I,J,K)+T_1(I,J,K)
+ T_1(I,J,K)=T_1(I,J,K)*beta11+T_X(I,J,K)
+ ! Q_1(I,J,K)=Q_1(I,J,K)*beta11+Q_X(I,J,K)
+ TEK2=TENV(I,J,K)+T_1(I,J,K)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+ Q_1(I,J,K)=ESRR*Q_1(I,J,K)
+ END DO
+ END DO
+ END DO
+ END IF
+!
+! save data
+
+ print*,'IR1,IR_1,NX,NY,NZ,KMX=',IR1,IR_1,NX,NY,NZ,KMX
+ print*,'RADUS=',RADUS(1),RADUS(2)
+
+! conver Q_2S to orginial unit
+
+ DO K=1,KMX
+ DO I=1,IR1
+ Q_2S(I,K)=Q_2S(I,K)*1.E-3
+ END DO
+ END DO
+
+ write(23)IR1,IR_1,NX,NY,NZ,KMX
+ write(23)RADUS
+ write(23)CLON_NEW,CLAT_NEW
+ write(23)U_2S,V_2S,U_2S1
+ write(23)T_2S,Q_2S,SLP_2S
+ write(23)CFT,PW,beta11
+ write(23)TEK,HP
+ write(23)aaa,bbb,SLP_T
+ write(23)rmw1,rmw2,roc1,roc2
+ write(23)ftmin,ftmax,ctmin,ctmax
+
+ v_max=0.
+
+ DO J=JWMIN1,JWMAX1
+ DO I=IWMIN1,IWMAX1
+ v_max1=U_1(I,J,1)*U_1(I,J,1)+V_1(I,J,1)*V_1(I,J,1)
+ if(v_max.lt.v_max1)v_max=v_max1
+ END DO
+ END DO
+ v_max=sqrt(v_max)/1.15
+
+ print*,'v_max_2=',v_max
+
+
+ write(14,*)fact_p,PRMAX,RAD_1 !* Add PRMAX,RAD_1
+
+ if(INITOPT > 0)PW=1.
+
+ do k=1,kmx
+ do J=1,NY
+ do I=1,NX
+ U_1(I,J,K)=U_1(I,J,K)*PW(k)
+ V_1(I,J,K)=V_1(I,J,K)*PW(k)
+ T_1(I,J,K)=T_1(I,J,K)*PW(k)
+ Q_1(I,J,K)=Q_1(I,J,K)*PW(k)
+ end do
+ end do
+ end do
+
+
+ print*,'test8='
+
+ NCHT=58
+ WRITE(NCHT)KSTM
+
+ WRITE(NCHT)HLAT2,HLON2
+ WRITE(NCHT)VLAT2,VLON2
+
+ WRITE(NCHT)PCST
+
+ WRITE(NCHT)HP
+
+ KST=1
+
+ WRITE(NCHT)ST_NAME(KST)
+ WRITE(NCHT)CLON_NEW,CLAT_NEW
+
+ WRITE(NCHT)zmax
+
+ WRITE(NCHT)IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ WRITE(NCHT)((SLPE(I,J),I=1,NX),J=1,NY) ! SLP
+ WRITE(NCHT)((SLP_1(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1) ! pert SLP
+ PRINT*,'TEST1'
+ DO K=1,KMX
+ WRITE(NCHT)((TENV(I,J,K),I=1,NX),J=1,NY)
+ WRITE(NCHT)((T_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ END DO
+ DO K=1,KMX
+ WRITE(NCHT)((U_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ WRITE(NCHT)((V_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ END DO
+
+ DO K=1,KMX
+ WRITE(NCHT)((Q_1(I,J,K),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ END DO
+
+ WRITE(NCHT) ((U_850(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+ WRITE(NCHT) ((V_850(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+
+ CLOSE(NCHT)
+
+! grads output
+
+ NX2=NX*2-1
+
+ ALLOCATE( DUM(NX,NY) )
+ ALLOCATE( DUMA(NX2,NY) )
+
+! call open_grads('storm_pert_out',NX2,NY,KMX,1.0,1.0,1.0,1.0)
+ call open_grads('storm_pert_out',NX,NY,KMX,1.0,1.0,1.0,1.0)
+
+ open(91,file='storm_pert_out',form='unformatted')
+ rewind 91
+
+ do K=1,KMX
+ call load(U_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(V_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(T_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ do K=1,KMX
+ call load(Q_1,NX,NY,KMX,K,DUM)
+ write(91) DUM
+! call fill_nmm_gridg(DUM,NX,NY,DUMA,2)
+! write(91) DUMA
+ end do
+ write(91) SLP_1
+! call fill_nmm_gridg(SLP_1,NX,NY,DUMA,1)
+! write(91) DUMA
+
+ close(91)
+
+ DEALLOCATE( DUM, DUMA )
+
+! grads output
+
+! WRITE(35)((SLP_1(I,J),I=1,NX),J=1,NY,2)
+! DO K=1,KMX
+! WRITE(35)((T_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(35)((U_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(35)((V_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(35)((Q_1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+ END
+
+!==============================================================================
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/correct_mat.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/correct_mat.f90
new file mode 100644
index 000000000..84d64e092
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/correct_mat.f90
@@ -0,0 +1,405 @@
+
+ SUBROUTINE CORT_MAT(IR1,NX,NY,NZ,KMX,U_2S,T_2S,Q_2S,SLP_2S, &
+ U_2S1,T_X,Q_X,SLP_X,HLON,HLAT,VLON,VLAT, &
+ TEK,PCST,RADIUS,RADIUS1,CLON_NEW,CLAT_NEW, &
+ CFT,beta11,IR_1,IFLAG,KM1)
+
+! input: IR1,NX,NY,KMX
+! input: U_2S,T_2S,Q_2S,SLP_2S variables from guess storm
+! input: HLON,HLAT,VLON,VLAT,TEK,PCST
+! input: RADIUS,CLON_NEW,CLAT_NEW,IFLAG
+! input: U_2S1,RADIUS1 - Variables after wind and size correction
+! output: T_X,Q_X,SLP_X - new axisymmetric part
+! output: A11,B11,C11 - correlation coef
+
+ real(4) U_2S(IR1,KMX),U_2S1(IR1,KMX)
+ real(4) T_2S(IR1,KMX),Q_2S(IR1,KMX),SLP_2S(IR1)
+ real(4) HLON(NX,NY),HLAT(NX,NY)
+ real(4) VLON(NX,NY),VLAT(NX,NY)
+ real(4) RADIUS(IR1),RADIUS1(IR1),CFT(IR1)
+
+ REAL(8) CLON_NEW,CLAT_NEW
+
+ real(4) T_X(NX,NY,KMX),Q_X(NX,NY,KMX),SLP_X(NX,NY)
+ real(4) TEK(KMX),PCST(KMX)
+
+ real(4) A11(NZ,3),B11(NZ,3),C11(3)
+ real(4) D11(3,3),f11(3)
+
+ REAL(4), ALLOCATABLE :: RKX1(:),WKX1(:,:)
+ REAL(4), ALLOCATABLE :: RKX2(:),WKX2(:,:)
+ REAL(4), ALLOCATABLE :: strm1(:,:),strm2(:,:),funct(:,:),RLOGP(:)
+
+ REAL(4), ALLOCATABLE :: rpb(:),rpb1(:),rpb2(:)
+ REAL(4), ALLOCATABLE :: rtmp(:,:),rtmp1(:,:),rtmp2(:,:),rtmp3(:,:)
+ REAL(4), ALLOCATABLE :: rmix(:,:)
+ REAL(4), ALLOCATABLE :: ctmp(:,:),cmix(:,:)
+
+ REAL(4), ALLOCATABLE :: test1(:,:),work1(:,:)
+
+ REAL(4), ALLOCATABLE :: RIJ2(:,:)
+ REAL(4), ALLOCATABLE :: IDX1(:,:),W1(:,:),W2(:,:)
+
+ IR=IR1-1
+ nm=NZ
+ kmx1=kmx-1
+
+ NXC=NX/2
+ NYC=NY/2
+
+ ALLOCATE ( RKX1(IR1),WKX1(IR1,NZ) )
+ ALLOCATE ( RKX2(IR1),WKX2(IR1,NZ) )
+ ALLOCATE ( strm1(IR1,nm),strm2(IR1,nm),funct(IR1,nm),RLOGP(KMX) )
+
+ ALLOCATE ( rpb(IR1),rpb1(IR1),rpb2(IR1) )
+ ALLOCATE ( rtmp(IR1,NM),rtmp1(IR1,NM),rtmp2(IR1,NM),rtmp3(IR1,NM) )
+ ALLOCATE ( rmix(IR1,NM) )
+ ALLOCATE ( ctmp(IR1,kmx),cmix(IR1,kmx) )
+
+ pi=4.*atan(1.)
+ pi180=pi/180.
+ pi_deg=180./pi
+ DST1=6.371E6*pi180
+
+ cost=cos(clat_new*pi180)
+
+ print*,'inside cort'
+ print*,'pi= ',pi
+
+! check max, min temp
+
+ do k=1,kmx
+ tmax=-1.E20
+ tmin=1.E20
+ do j=1,IR1
+ if(T_2S(j,k).gt.tmax)then
+ tmax=T_2S(j,k)
+ jmax3=j
+ end if
+ if(T_2S(j,k).lt.tmin)then
+ tmin=T_2S(j,k)
+ jmin=j
+ end if
+ end do
+ print*,'k,tmax,tmin=',k,tmax,tmin,TEK(k)
+ end do
+
+ do k=1,kmx
+ RLOGP(k)=287.*ALOG(PCST(k)) ! R=287
+ print*,'RLOGP(k)=',K,RLOGP(k)
+ end do
+
+ print*,'clon_new,clat_new=',clon_new,clat_new
+
+ ff0=2.*7.292E-5*sin(clat_new*pi180)
+
+!CWH print*,'beta11,fact,ff0=',beta11,fact,ff0
+ print*,'beta11,ff0=',beta11,ff0
+
+ RKX1=0.
+ DO n=1,IR1
+ RKX1(n)=RADIUS(n)*DST1
+ RKX2(n)=RADIUS1(n)*DST1
+! print*,'RKX1(n)=',RKX1(n),U_2S(n,10)
+ END DO
+
+ print*,'KM1(should be 3)=',KM1
+ KM2=KM1/2
+
+ WKX1=0.
+! do k1=2,kmx1,2
+ do k1=2,KM1,2
+ k=K1/2
+ DO n=1,IR1
+ WKX1(n,k)=U_2S(n,k1)
+ IF(WKX1(n,k).lt.0.)WKX1(n,k)=0.
+ END DO
+ END DO
+
+ WKX2=0.
+ do k1=2,KM1,2
+ k=K1/2
+ DO n=1,IR1
+ WKX2(n,k)=U_2S1(n,k1)
+ IF(WKX2(n,k).lt.0.)WKX2(n,k)=0.
+ END DO
+ END DO
+
+
+ do k=1,KM2
+ strm1(IR1,k)=0.
+ strm2(IR1,k)=0.
+ DO n=IR,1,-1
+ force=(WKX1(n,k)/(RKX1(n)+1.E-20)+ff0)*WKX1(n,k)
+ strm1(n,k)=strm1(n+1,k)-force*(RKX1(n+1)-RKX1(n))
+ force2=(WKX2(n,k)/(RKX2(n)+1.E-20)+ff0)*WKX2(n,k)
+ strm2(n,k)=strm2(n+1,k)-force2*(RKX2(n+1)-RKX2(n))
+ end do
+ end do
+
+! do k=1,NZ
+! print*,'strm1(1,k),strm2(1,k)=',k,strm1(1,k),strm2(1,k)
+! end do
+
+ IR_1=IR1
+
+ DO n=1,IR1
+ sum_str=0.
+ do k=1,KM2
+ sum_str=sum_str+strm1(n,k)
+ end do
+ if(abs(sum_str).gt.0.001)then
+ IR_1=n
+ end if
+! write(*,222)n,strm2(n,1),strm1(n,1),strm2(n,1)/(-1.e-20+strm1(n,1))
+ END DO
+
+ print*,'finish computing stream function'
+
+! rtmp1(n,1) not exactly the same level (half level above K=1 for NZ=42)
+
+ k=1
+ k1=2
+
+ DO n=1,IR_1
+ str_cut=max(strm2(n,1),strm1(n,1))
+ if(str_cut.gt.-10.)then
+ str_m_rat=strm2(n,1)/(strm1(n,1)-1.E-20)
+ IR_2=n
+ go to 57
+ end if
+ end do
+ 57 continue
+
+ CFT=0.
+ DO n=1,IR_2
+ CFT(n)=strm2(n,1)/(strm1(n,1)-1.E-20)
+ end do
+
+ DO n=IR_2,IR_1
+ CFT(n)=min(str_m_rat,strm2(n,1)/(strm1(n,1)-1.E-20))
+ end do
+
+ if(abs(beta11-1.).gt.0.01)then
+
+ DO n=1,IR_1
+! rtmp1(n,1)=(strm1(n,2)-strm1(n,1))/(RLOGP(4)-RLOGP(2))
+! rtmp3(n,1)=(strm2(n,2)-strm2(n,1))/(RLOGP(4)-RLOGP(2))
+! CFT(n)=strm2(n,1)/(strm1(n,1)-1.E-20)
+ rtmp1(n,1)=T_2S(n,2)
+ rtmp3(n,1)=T_2S(n,2)*CFT(n)
+! print*,'n,rtmp1(n,2)=',strm2(n,k),strm1(n,k),strm2(n,k)/(strm1(n,k)-1.E-20)
+ END DO
+ do k=2,NZ
+ k1=2*k
+ if (k1 .le. 121) then
+ DO n=1,IR_1
+! rtmp1(n,k)=(strm1(n,k+1)-strm1(n,k-1))/(RLOGP(k1+2)-RLOGP(k1-2))
+! rtmp3(n,k)=(strm2(n,k+1)-strm2(n,k-1))/(RLOGP(k1+2)-RLOGP(k1-2))
+ rtmp1(n,k)=T_2S(n,k1)
+ rtmp3(n,k)=T_2S(n,k1)*CFT(n)
+ END DO
+ else
+ DO n=1,IR_1
+ rtmp1(n,k)=0.0
+ rtmp3(n,k)=0.0
+ enddo
+ endif
+ end do
+
+! new replacement
+ rpb2=0.
+ rpb=0.
+ do m=1,IR_1
+ rpb2(m)=SLP_2S(m)
+ rpb(m) =SLP_2S(m)*CFT(m)
+ end do
+
+ rtmp2=0.
+ rtmp=0.
+ do k=1,NZ
+ k1=k*2
+ do m=1,IR_1
+ rtmp2(m,k)=T_2S(m,k1)
+! rtmp(m,k) =T_2S(m,k1)*rtmp3(m,k)/(rtmp1(m,k)-1.E-20)
+ rtmp(m,k) =T_2S(m,k1)*CFT(m)
+ end do
+ end do
+
+! new replacement
+
+ pms1=0.
+ pms2=0.
+ pms3=0.
+
+ do m=1,IR1
+ pms1=pms1+slp_2s(m)**2
+ pms2=pms2+rpb2(m)**2
+ pms3=pms3+(slp_2s(m)-rpb2(m))**2
+ end do
+ print*,'pms=',sqrt(pms1),sqrt(pms2),sqrt(pms2)/sqrt(pms1)
+ print*,'pms3=',sqrt(pms3)
+
+ tmp4=0
+ tmp5=0.
+ tmp6=0.
+ tmpdiff1=0.
+ do k=1,NZ
+ k1=k*2
+ tmp1=0.
+ tmp2=0.
+ tmp3=0.
+ do m=1,IR1
+ tmp1=tmp1+T_2S(m,k1)**2
+ tmp2=tmp2+rtmp2(m,k)**2
+ tmp3=tmp3+(T_2S(m,k1)-rtmp2(m,k))**2
+ end do
+ tmp4=tmp4+tmp1
+ tmp5=tmp5+tmp2
+ tmp6=tmp6+tmp3
+ print*,'tmp1=',k,sqrt(tmp1),sqrt(tmp2),sqrt(tmp2)/sqrt(tmp1),sqrt(tmp3)
+ end do
+
+! print*,'tmp6=',sqrt(tmp6/tmp4)
+
+! correct mixing ratio
+
+ rmix=0.
+
+ do k=1,nz
+ k1=2*k
+ if (k1 .le. 121) then
+ do m=1,IR_1
+ TEK1=TEK(k1)+T_2S(m,k1)
+ TEK2=TEK(k1)+rtmp(m,k)
+ ESRR=exp(4302.645*(TEK2-TEK1)/((TEK2-29.66)*(TEK1-29.66)))
+! rmix(m,k)=ESRR*Q_2S(m,k)-Q_2S(m,k)
+ rmix(m,k)=ESRR*Q_2S(m,k)-Q_2S(m,k)*beta11 ! will recompute
+ end do
+ else
+ do m=1,IR_1
+ rmix(m,k)=0.0
+ enddo
+ endif
+ end do
+
+ do m=1,IR_1
+ print*,'rpb(m),SLP_2S(m)',m,rpb(m),SLP_2S(m),CFT(m)
+ rpb(m)=rpb(m)-SLP_2S(m)*beta11
+ end do
+ do k=1,nz
+ k1=2*k
+ if (k1 .le. 121) then
+ do m=1,IR_1
+ rtmp(m,k)=rtmp(m,k)-T_2S(m,k1)*beta11
+! print*,'m,k,rtmp(m,k),T_2S(m,k1)=',m,k,rtmp(m,k),T_2S(m,k1)
+ end do
+ else
+ do m=1,IR_1
+ rtmp(m,k)=0.0
+ enddo
+ endif
+ end do
+
+ ctmp=0.
+ cmix=0.
+
+ do m=1,IR_1
+ ctmp(m,1)=rtmp(m,1)
+ ctmp(m,kmx)=rtmp(m,NZ)
+ cmix(m,1)=rmix(m,1)
+ cmix(m,kmx)=rmix(m,NZ)
+ do k=2,kmx1,2
+ k1=k/2
+ ctmp(m,k)=rtmp(m,k1)
+ cmix(m,k)=rmix(m,k1)
+ end do
+ do k=3,kmx1-1,2
+ k1=(k-1)/2
+ ctmp(m,k)=0.5*(rtmp(m,k1)+rtmp(m,k1+1))
+ cmix(m,k)=0.5*(rmix(m,k1)+rmix(m,k1+1))
+ end do
+ end do
+
+ do m=1,IR1
+ print*,'ctmp,cmix,test1111=',m,ctmp(m,1),cmix(m,1)
+ end do
+
+
+! interpolate correction to 3D
+
+ ALLOCATE ( RIJ2(NX,NY) )
+ ALLOCATE ( IDX1(NX,NY),W1(NX,NY),W2(NX,NY) )
+
+ IDX1=-1
+
+! print*,'HLON(1,1),HLAT(1,1),CLON_NEW,CLAT_NEW=', &
+! HLON(1,1),HLAT(1,1),CLON_NEW,CLAT_NEW
+! print*,'RADIUS(1)=',RADIUS(1)
+
+ DO J=1,NY
+ DO I=1,NX
+ RIJ2(I,J)=SQRT(((HLON(I,J)-CLON_NEW)*cost)**2+ &
+ (HLAT(I,J)-CLAT_NEW)**2 )
+ DO N=1,IR_1
+ DIF=RADIUS(N)-RIJ2(I,J)
+ IF(DIF.GT.0.)THEN
+ IDX1(I,J)=N
+ GO TO 25
+ END IF
+ END DO
+ 25 CONTINUE
+ END DO
+ END DO
+ DO J=1,NY
+ DO I=1,NX
+ IF(IDX1(I,J).GE.2)THEN
+ W1(I,J)=(RIJ2(I,J)-RADIUS(IDX1(I,J)-1))/ &
+ (RADIUS(IDX1(I,J))-RADIUS(IDX1(I,J)-1))
+ W2(I,J)=1.-W1(I,J)
+ ELSE IF(IDX1(I,J).EQ.1)THEN
+ W1(I,J)=1.
+ W2(I,J)=0.
+ ELSE
+ W1(I,J)=0.
+ W2(I,J)=0.
+ END IF
+ END DO
+ END DO
+
+ SLP_X=0.
+ T_X=0.
+ Q_X=0.
+
+ DO J=1,NY
+ DO I=1,NX
+ IF(IDX1(I,J).GT.0)THEN
+ IF(IDX1(I,J).GE.2)THEN
+ SLP_X(I,J)=W1(I,J)*rpb(IDX1(I,J))+W2(I,J)*rpb(IDX1(I,J)-1)
+! IF(I.EQ.NX/2)print*,'SLP_X(I,J),W1(I,J),IDX1(I,J)=', &
+! SLP_X(I,J),W1(I,J),IDX1(I,J)
+ DO K=1,KMX
+ T_X(I,J,K)=W1(I,J)*ctmp(IDX1(I,J),k)+W2(I,J)*ctmp(IDX1(I,J)-1,k)
+ Q_X(I,J,K)=W1(I,J)*cmix(IDX1(I,J),k)+W2(I,J)*cmix(IDX1(I,J)-1,k)
+ END DO
+ ELSE
+ SLP_X(I,J)=rpb(IDX1(I,J))
+ DO K=1,KMX
+ T_X(I,J,K)=ctmp(IDX1(I,J),k)
+ Q_X(I,J,K)=cmix(IDX1(I,J),k)
+ END DO
+ END IF
+ END IF
+ END DO
+ END DO
+
+ else
+
+ SLP_X=0.
+ T_X=0.
+ Q_X=0.
+
+ end if
+
+ return
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/fill_nmm_gridg.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/fill_nmm_gridg.f90
new file mode 100644
index 000000000..0281e5e07
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/fill_nmm_gridg.f90
@@ -0,0 +1,92 @@
+subroutine fill_nmm_gridg(gin,nx,ny,b,igtype)
+
+! convert input staggered grid to output filled grid
+
+! --> gin: input staggered grid
+! --> nx,ny: input grid dimensions
+! <-- b: output filled grid
+! --> igtype: =1, then (1,1) on staggered grid is at corner of grid
+! =2, then (1,1) is staggered
+
+implicit none
+
+integer nx,ny,igtype
+real(4) gin(nx,ny),b(2*nx-1,ny)
+
+integer i,im,ip,j,jm,jp
+real(4) fill,test
+
+fill=.95*huge(fill) ; test=.95*fill
+do j=1,ny
+ do i=1,2*nx-1
+ b(i,j)=fill
+ end do
+end do
+
+! first transfer all staggered points to appropriate
+! points on filled output grid
+
+if(igtype.eq.1) then
+ do j=1,ny,2
+ do i=1,nx
+ b(2*i-1,j)=gin(i,j)
+ end do
+ end do
+ do j=2,ny,2
+ do i=1,nx-1
+ b(2*i,j)=gin(i,j)
+ end do
+ end do
+else
+ do j=1,ny,2
+ do i=1,nx-1
+ b(2*i,j)=gin(i,j)
+ end do
+ end do
+ do j=2,ny,2
+ do i=1,nx
+ b(2*i-1,j)=gin(i,j)
+ end do
+ end do
+end if
+
+! now fill in holes
+
+! top and bottom rows:
+
+do j=1,ny,ny-1
+ do i=1,2*nx-1
+ if(b(i,j).gt.test) then
+ ip=i+1 ; if(ip.gt.2*nx-1) ip=i-1
+ im=i-1 ; if(im.lt.1) im=i+1
+ b(i,j)=.5*(b(im,j)+b(ip,j))
+ end if
+ end do
+end do
+
+! left and right rows:
+
+do j=1,ny
+ jp=j+1 ; if(jp.gt.ny) jp=j-1
+ jm=j-1 ; if(jm.lt.1) jm=j+1
+ do i=1,2*nx-1,2*nx-2
+ if(b(i,j).gt.test) b(i,j)=.5*(b(i,jm)+b(i,jp))
+ end do
+end do
+
+! interior points
+
+do j=1,ny
+ jp=j+1 ; if(jp.gt.ny) jp=j-1
+ jm=j-1 ; if(jm.lt.1) jm=j+1
+ do i=1,2*nx-1
+ if(b(i,j).gt.test) then
+ ip=i+1 ; if(ip.gt.2*nx-1) ip=i-1
+ im=i-1 ; if(im.lt.1) im=i+1
+ b(i,j)=.25*(b(ip,j)+b(im,j)+b(i,jp)+b(i,jm))
+ end if
+ end do
+end do
+
+end subroutine fill_nmm_gridg
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/grads.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/grads.f90
new file mode 100644
index 000000000..56873664a
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/anl_pert/grads.f90
@@ -0,0 +1,75 @@
+subroutine open_grads(label,nlon,nlat,nsig,startx,starty,xinc,yinc)
+
+ character(*) label
+ integer nlon,nlat,nsig
+ integer i,k,ntime
+ real(4) undef
+ character(1) blank
+ character(80) datdes(15)
+ integer unit_des
+ character(80) label_dat
+ character(80) label_des
+ real(4) startx,starty,startp,xinc,yinc,pinc
+
+ blank=' '
+ undef=-9.99e33
+
+! create names of grads control and data files
+
+ write(label_des,'(a,".ctl")')trim(label)
+ write(label_dat,'(a)')trim(label)
+
+! find unused unit number
+
+ unit_des=80
+ print *,'startx, starty, xinc, yinc=', startx, starty, xinc, yinc
+
+! initialize counters for this set of output fields
+
+ startp=1.
+ pinc=1.
+ ntime=1
+ do i=1,15
+ write(datdes(i),'(80a1)')(blank,k=1,80)
+ end do
+ write(datdes(1),'("DSET ",a)')trim(label_dat)
+ write(datdes(2),'("options big_endian sequential")')
+ write(datdes(3),'("TITLE ",a)')trim(label)
+ write(datdes(4),'("UNDEF ",e11.2)')undef
+ write(datdes(5),'("XDEF ",i5," LINEAR ",f7.2,f7.2)')nlon,startx,xinc
+ write(datdes(6),'("YDEF ",i5," LINEAR ",f7.2,f7.2)')nlat,starty,yinc
+ write(datdes(7),'("ZDEF ",i5," LINEAR ",f7.2,f7.2)')nsig,startp,pinc
+ write(datdes(8),'("TDEF ",i5," LINEAR 0Z23may1992 24hr")')ntime
+ write(datdes(9),'("VARS 5")')
+ write(datdes(10),'("u ",i5," 99 u ")')nsig
+ write(datdes(11),'("v ",i5," 99 v ")')nsig
+ write(datdes(12),'("t ",i5," 99 t ")')nsig
+ write(datdes(13),'("q ",i5," 99 q ")')nsig
+ write(datdes(14),'("slp ",i5," 99 slp ")')1
+ write(datdes(15),'("ENDVARS")')
+! write out datdes
+
+ write(*,'(a80)')datdes(7)
+
+ open(unit_des,file=label_des,form='formatted')
+ rewind unit_des
+ write(unit_des,'(a80)')datdes
+ close(unit_des)
+
+end subroutine open_grads
+
+subroutine load(a,ni,nj,nk,n,dum)
+
+ integer :: ni,nj,nk,n,i,j
+ real(4) :: a(ni,nj,nk)
+ real(4) :: dum(ni,nj)
+
+ do j=1,nj
+ do i=1,ni
+ dum(i,j)=a(i,j,n)
+ end do
+ end do
+
+ return
+end subroutine load
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/build_vi_CMake.bash b/sorc/hafs_tools.fd/sorc/hafs_vi/build_vi_CMake.bash
new file mode 100755
index 000000000..16d1c143c
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/build_vi_CMake.bash
@@ -0,0 +1,22 @@
+#!/bin/bash
+set -xeu
+
+HOMEhafs="../../../../"
+source ${HOMEhafs}/sorc/machine-setup.sh > /dev/null 2>&1
+
+module use ${HOMEhafs}/modulefiles
+module load modulefile.hafs.${target}
+module list
+
+BuildDir=${HOMEhafs}/sorc/hafs_tools.fd/sorc/build
+if [ -d ${BuildDir} ]; then
+ rm -rf ${BuildDir}
+fi
+mkdir ${BuildDir}
+cd ${BuildDir}
+
+cmake ../hafs_vi -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_COMPILER=icc -DBUILD_TYPE=RELEASE
+make VERBOSE=3
+make install
+
+# ./build_vi_CMake.bash > build.log 2>&1 &
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/configure.vi b/sorc/hafs_tools.fd/sorc/hafs_vi/configure.vi
new file mode 100644
index 000000000..d9fbf60ef
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/configure.vi
@@ -0,0 +1,86 @@
+
+SHELL = /bin/sh
+
+NETCDF_INCLUDE = -I${NETCDF}/include
+NETCDF_LDFLAGS = -L${NETCDF}/lib -lnetcdff -lnetcdf
+HDF5_INCLUDE = ${HDF5_INCLUDE:-"-I${HDF5_INCLUDES:--I${HDF5}/include}"}
+HDF5_LDFLAGS = ${HDF5_LDFLAGS:-"-L${HDF5_LIBRARIES:--L${HDF5}/lib} -lhdf5_hl -lhdf5"}
+ZLIB_INCLUDE = ${ZLIB_INCLUDE:-"-I${ZLIB_INCLUDES:--I${ZLIB_ROOT}/include}"}
+ZLIB_LDFLAGS = ${ZLIB_LDFLAGS:-"-L${ZLIB_LIBRARIES:--L${ZLIB_ROOT}/lib} -lz -ldl -lm"}
+
+SFC = ifort
+SF90 = ifort -free
+SCC = icc
+OMP_FFLAGS = -qopenmp
+DEBUG_FLAGS = -g -traceback -check all -fp-model precise -assume byterecl -convert big_endian
+FFLAGS = -O3 -g -traceback -fp-model precise -assume byterecl -convert big_endian
+FFLAGS_DOUBLE2 = -integer-size 64 -real-size 64
+FFLAGS_DOUBLE = -integer-size 32 -real-size 64
+FFLAGS_SINGLE = -integer-size 32 -real-size 32
+CFLAGS =
+DEBUG_CFLAGS =
+LDFLAGS =
+CPP = /lib/cpp
+CPPFLAGS = -P -traditional-cpp
+FPPFLAGS = $(CPPFLAGS) -traditional-cpp
+FPP = /lib/cpp -P -traditional-cpp
+FDEFS =
+ARFLAGS = -ruv
+
+DM_FC = mpif90 -f90=ifort
+DM_F90 = mpif90 -free -f90=ifort
+DM_CC = mpicc -cc=icc
+
+FC = $(DM_FC)
+F90 = $(DM_F90)
+CC = $(DM_CC)
+
+ESSLLIB = -mkl=sequential
+MASSLIB =
+WRF_DIR = /work/noaa/hwrf/save/bliu/hwrftrunk202108/sorc/hwrf-utilities/../WRFV3
+
+###########################################################
+#
+# Macros, these should be generic for all machines
+
+LN = ln -sf
+MAKE = make -i -r
+RM = /bin/rm -f
+CP = /bin/cp
+AR = ar
+MKDIR = /bin/mkdir -p
+RANLIB = ranlib
+
+.IGNORE:
+.SUFFIXES: .c .f .F .F90 .f90 .o .fpp
+
+# There is probably no reason to modify these rules
+.c.o:
+ $(RM) $@
+ $(CC) $(CFLAGS) -c $<
+
+.f.o:
+ $(RM) $@ $*.mod
+ $(FC) $(FFLAGS) -c $<
+
+.fpp.o:
+ $(RM) $@ $*.mod $*.f
+ $(CPP) $(FPPFLAGS) $(FDEFS) $< > $*.f && \
+ $(FC) $(FFLAGS) -c $*.f && \
+ $(RM) $*.f
+
+.F.o:
+ $(RM) $@ $*.mod
+ $(CPP) $(FPPFLAGS) $(FDEFS) $< > $*.f90 && \
+ $(F90) $(FFLAGS) -c $*.f90 && \
+ $(RM) $*.f90
+
+.F90.o:
+ $(RM) $@ $*.mod
+ $(CPP) $(FPPFLAGS) $(FDEFS) $< > $*.f90 && \
+ $(F90) $(FFLAGS) -c $*.f90 && \
+ $(RM) $*.f90
+
+.f90.o:
+ $(RM) $@ $*.mod
+ $(F90) $(FFLAGS) -c $<
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/CMakeLists.txt
new file mode 100644
index 000000000..827cc7c04
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/CMakeLists.txt
@@ -0,0 +1,24 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ create_trak_guess.f90)
+
+set(exe_name hafs_vi_create_trak_guess.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/Makefile
new file mode 100644
index 000000000..b5e36f4d6
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/Makefile
@@ -0,0 +1,16 @@
+include ../configure.vi
+
+OBJS = create_trak_guess.o
+EXEC = ../../../exec/hafs_vi_create_trak_guess.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/create_trak_guess.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/create_trak_guess.f90
new file mode 100644
index 000000000..8c38d3447
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_guess/create_trak_guess.f90
@@ -0,0 +1,84 @@
+!---------------------------------------------------------------------------------------------------------
+! This code is designed to replace create_trak_guess.f90 of HWRF: 2022 JungHoon Shin
+! Usage example:
+! ./hafs_vi_create_trak_guess.x storm_id
+! e.g., ./hafs_vi_create_trak_guess.x 13L
+! Input:
+! fort.11: tcvitals message for the current forecast cycle
+! fort.12: ATCF track file from previous cycle 6-h HAFS forecast
+! Output:
+! fort.30: contains the HAFS storm position at 3-, 6-, and 9-h, needed for splitting or merging HAFS vortex
+!
+! Output (fort.30: trak.fnl.all) looks like below
+! 72HDAS[cycle] AAA BBB9999999999999999 CCC DDD9999999999999999 EEE FFF 0 0 0 0 0 0 [storm ID]
+! AAA&BBB (lat/lon): TC center at 3-h, CCC&DDD (lat/lon): TC center at 6-h, EEE&FFF (lat/lon): TC center at 9-h
+! For example, for the cycle 2020082500 of Laura 13L looks like this..
+! 72HDAS20082418 217 8199999999999999999 222 8269999999999999999 227 836 0 0 0 0 0 0 13L
+!---------------------------------------------------------------------------------------------------------
+program create_trak_guess
+ implicit none
+ character(len=2) :: part1,num,basin
+ character(len=3) :: part2,storm_id
+ character(len=1) :: ns,ew
+ integer :: idat,ihour,ifh,lat,lon,ih,j,stat
+ integer,dimension(7) :: lathr,lonhr
+
+ integer :: iargc
+
+ if (iargc() .lt. 1) then
+ write(*,*)' usage: ./hafs_vi_create_trak_guess.x storm_id'
+ write(*,*)' example: ./hafs_vi_create_trak_guess.x 13L'
+ stop
+ else
+ call getarg(1, storm_id)
+ endif
+
+ if(storm_id(3:3).eq.'L') basin='AL'
+ if(storm_id(3:3).eq.'W') basin='WP'
+ if(storm_id(3:3).eq.'E') basin='EP'
+ if(storm_id(3:3).eq.'C') basin='CP'
+ if(storm_id(3:3).eq.'A') basin='AA'
+ if(storm_id(3:3).eq.'B') basin='BB'
+ if(storm_id(3:3).eq.'P') basin='SP'
+ if(storm_id(3:3).eq.'S') basin='SI'
+
+ ! Set null vaules for the output (fort.30)
+ lathr=9999
+ lonhr=9999
+
+ ! Reading fort.12 (previous HAFS forecast ATCF file)
+ do
+ read(12,65,iostat=stat) part1,num,idat,ihour,ifh,lat,ns,lon,ew
+ if(ns.eq.'S')lat=-lat
+ if(ew.eq.'E')lon=3600-lon
+ if(ifh.ge.3 .and. ifh.le.9) then ! We only need 3-,6-,9-h HAFS storm postion
+ lathr(ifh-2)=lat
+ lonhr(ifh-2)=lon
+ end if
+ !If we find 9-h information or reach the end of file WITHOUT 9-h data, exit the do loop
+ if(stat /= 0 .or. ifh.eq.9) exit
+ enddo
+
+ ! If there are no valid lat/lon locations from fort.12, then using the lat/lon
+ ! values from fort.11 to fill the FGAT hours
+ read(11,13) part2,idat,ihour,lat,ns,lon,ew
+ if(ns.eq.'S')lat=-lat
+ if(ew.eq.'E')lon=3600-lon
+ do ih=1,7,3
+ if(abs(lathr(ih)).eq.9999 .or. abs(lonhr(ih)).eq.9999) then
+ print*, 'ih,lathr(ih),lonhr(ih)=',ih,lathr(ih),lonhr(ih)
+ print*, 'Using lat/lon from tcvitals to overwrite'
+ lathr(ih)=lat
+ lonhr(ih)=lon
+ endif
+ enddo
+
+ write(*,15) idat,ihour,(lathr(j),lonhr(j),j=1,7),storm_id
+ write(30,15) idat,ihour,(lathr(j),lonhr(j),j=1,7),storm_id
+
+ 13 format(5x,A3,13x,I6,1x,I2,3x,I3,A1,1x,I4,A1) ! Input fort.11 (tcvital) format
+ 65 format(A2,2x,A2,4x,I6,I2,12x,I3,2x,I3,A1,2x,I4,A1) ! Input fort.12 (ATCF) format
+ 15 format('72HDAS',I6,I2,14I5,' 0 0 0 0 0 0',1x,3A) ! Output(trak.fnl.all) format
+
+end program create_trak_guess
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/CMakeLists.txt
new file mode 100644
index 000000000..777223fb0
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/CMakeLists.txt
@@ -0,0 +1,24 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ create_trak_init.f90)
+
+set(exe_name hafs_vi_create_trak_init.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian)
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/Makefile
new file mode 100644
index 000000000..d460c8082
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/Makefile
@@ -0,0 +1,16 @@
+include ../configure.vi
+
+OBJS = create_trak_init.o
+EXEC = ../../../exec/hafs_vi_create_trak_init.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(LDFLAGS) -o $@ $(OBJS)
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS)
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/create_trak_init.f90 b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/create_trak_init.f90
new file mode 100644
index 000000000..f5ecb8ab1
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/create_trak_init/create_trak_init.f90
@@ -0,0 +1,85 @@
+!---------------------------------------------------------------------------------------------------------
+! This code is designed to replace create_trak_fnl.f90 of HWRF: 2022 JungHoon Shin
+! Usage example:
+! ./hafs_vi_create_trak_init.x storm_id
+! e.g., ./hafs_vi_create_trak_init.x 13L
+! Input:
+! fort.11: tcvitals message for the current forecast cycle
+! fort.12: ATCF track file tracked from GFS and GDAS at FGAT time
+! Output:
+! fort.30: contains TC center of GFS and GDAS at FGAT time, needed for splitting or merging GFS/GDAS vortex
+!
+! Output (fort.30) has the format as shown in below
+! AAA&BBB (lat/lon) is the TC center from atcfunix file. It REPEATS same storm center information
+! 72HDAS[cycle] AAA BBB AAA BBB AAA BBB AAA BBB AAA BBB AAA BBB AAA BBB 0 0 0 0 0 0 [storm ID]
+! For example, for the Laura 13L at 2020081918 at FGAT-3 looks like this..
+! 72HDAS20081915 124 443 124 443 124 443 124 443 124 443 124 443 124 443 0 0 0 0 0 0 13L
+!---------------------------------------------------------------------------------------------------------
+program create_trak_init
+ implicit none
+ character(len=2) :: part1,num,basin
+ character(len=3) :: part2,storm_id
+ character(len=1) :: ns,ew
+ integer :: ihour,idat,ifh,lat,lon,stat
+
+ integer :: iargc
+
+ if (iargc() .lt. 1) then
+ write(*,*)' usage: ./hafs_vi_create_trak_init.x storm_id'
+ write(*,*)' example: ./hafs_vi_create_trak_init.x 13L'
+ stop
+ else
+ call getarg(1, storm_id)
+ endif
+
+ if(storm_id(3:3).eq.'L') basin='AL'
+ if(storm_id(3:3).eq.'W') basin='WP'
+ if(storm_id(3:3).eq.'E') basin='EP'
+ if(storm_id(3:3).eq.'C') basin='CP'
+ if(storm_id(3:3).eq.'A') basin='AA'
+ if(storm_id(3:3).eq.'B') basin='BB'
+ if(storm_id(3:3).eq.'P') basin='SP'
+ if(storm_id(3:3).eq.'S') basin='SI'
+
+ ! Set null vaules for the output (fort.30)
+ lat=9999
+ lon=9999
+ ifh=-1
+
+ ! Reading fort.12 (atcfunix: GFS/GDAS vortex center)
+ do
+ read(12,65,iostat=stat) part1,num,idat,ihour,ifh,lat,ns,lon,ew
+ if(ns.eq.'S')lat=-lat
+ if(ew.eq.'E')lon=3600-lon
+ ! If we find the correct information, finish the do loop, with stat=0
+ if(part1.eq.basin .and. num.eq.storm_id(1:2) .and. ifh.eq.0) exit
+ ! exit the do loop if stat is NOT 0
+ if( stat /= 0 ) exit
+ enddo
+
+ ! Checking the status of fort.12.
+ ! If lat & lon values are good (i.e., stat=0), which is normal case, we use the fort.12 as is.
+ ! If lat & lon are odd in the fort.12 (as shown in below if statement),
+ ! OR fort.12 (atcfunix) does not have correct information (i.e., stat is NOT 0)
+ ! this code read and output lat & lon values from tcvitals (fort.11) for trak.fnl.all_gfs (fort.30).
+ ! But don't worry. Normally fort.12 are good & below part will not be used in most or normal case
+
+ if(abs(lat).eq.9999 .or. abs(lon).eq.9999 .or. stat /= 0) then
+ if( stat /= 0 )then
+ print*, 'Using tcvital information because atcfunix does not have correct information'
+ else
+ print*, 'Using tcvital information because lat and lon values of atcfunix is odd'
+ endif
+ read(11,13) part2,idat,ihour,lat,ns,lon,ew
+ if(ns.eq.'S')lat=-lat
+ if(ew.eq.'E')lon=3600-lon
+ endif
+
+ write(*,15) idat,ihour,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,storm_id
+ write(30,15) idat,ihour,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,lat,lon,storm_id
+
+ 13 format(5x,A3,13x,I6,1x,I2,3x,I3,A1,1x,I4,A1) ! Input fort.11(tcvital) format
+ 65 format(A2,2x,A2,4x,I6,I2,12x,I3,2x,I3,A1,2x,I4,A1) ! Input fort.12(ATCF) format
+ 15 format('72HDAS',I6,I2,14I5,' 0 0 0 0 0 0',1x,3A) ! Output(trak.fnl.all_gfs) format
+
+end program create_trak_init
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/pure-openmp.inc b/sorc/hafs_tools.fd/sorc/hafs_vi/pure-openmp.inc
new file mode 100644
index 000000000..458739a13
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/pure-openmp.inc
@@ -0,0 +1,9 @@
+# This is a Makefile include that should be used by the per-program or
+# per-library Makefiles to compile and link code that uses OpenMP but
+# not MPI.
+
+FFLAGS+=$(OMP_FFLAGS)
+LDFLAGS+=$(OMP_FFLAGS)
+FC=$(SFC)
+F90=$(SF90)
+CC=$(SCC)
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/BOUND.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/BOUND.f
new file mode 100644
index 000000000..6cd1ead9e
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/BOUND.f
@@ -0,0 +1,28 @@
+ SUBROUTINE BOUND(NMX,XR,ro)
+C
+ PARAMETER (IMX=41 , JMX=41)
+C
+ DIMENSION XR(NMX),ro(nmx)
+ COMMON /XXX/ XF(IMX,JMX),XC,YC,DX,DY
+ COMMON /POSIT/ XOLD,YOLD
+ PI = 4.*ATAN(1.0)
+c fact=cos(yold*pi/180.)
+ fact=1.0
+ DO 10 I=1,NMX
+ THETA= 2.*PI*FLOAT(I-1)/FLOAT(NMX)
+ X=RO(i)/fact*COS(THETA)+XC +1.
+ Y=RO(i)*SIN(THETA)+YC +1.
+ IX=INT(X/DX)
+ IY=INT(Y/DY)
+ IX1=IX+1
+ IY1=IY+1
+ P=X/DX-FLOAT(IX)
+ Q=Y/DY-FLOAT(IY)
+ XR(I)=(1.-P)*(1.-Q)*XF(IX,IY) +(1.-P)*Q*XF(IX,IY+1)
+ 1 + (1.-Q)*P*XF(IX+1,IY) + P*Q*XF(IX+1,IY+1)
+c PRINT*,'QLIU TEST, BOUND=',XR(I),XF(IX,IY),XF(IX,IY+1),
+c 2 XF(IX+1,IY),XF(IX+1,IY+1),I
+
+10 CONTINUE
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/CMakeLists.txt b/sorc/hafs_tools.fd/sorc/hafs_vi/split/CMakeLists.txt
new file mode 100644
index 000000000..0f311b615
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/CMakeLists.txt
@@ -0,0 +1,34 @@
+#=======================================================================
+#$$$ CMAKEFILE DOCUMENTATION BLOCK
+# Biju Thomas
+# Email: biju.thomas@noaa.gov
+#=======================================================================
+
+
+set(fortran_srcs
+ modules.f split.f BOUND.f fft99.f sig_p_convt.f
+ SEPAR.f WNLIT.f FDUMP.f H12.f I1MACH.f J4SAVE.f XGETUA.f
+ WNLSM.f WNNLS.f XERABT.f XERCTL.f XERPRT.f XERROR.f XERRWV.f
+ XERSAV.f srotm.f srotmg.f amatrix.f rodist.f landcmsk.f
+ create_rel_domain.f)
+
+
+set(exe_name hafs_vi_split.x)
+set(exec_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../../exec)
+
+add_executable(${exe_name} ${fortran_srcs})
+
+target_compile_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian -integer-size 32 -real-size 64 )
+
+target_link_options(${exe_name} PRIVATE
+ $<$:-g -check all> $<$:-O3>
+ -traceback -fp-model precise -assume byterecl -convert big_endian -integer-size 32 -real-size 64 )
+
+target_link_libraries(
+ ${exe_name} PRIVATE
+ OpenMP::OpenMP_Fortran
+ ${MKL_LIBRARIES})
+
+install(TARGETS ${exe_name} DESTINATION ${exec_dir})
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/FDUMP.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/FDUMP.f
new file mode 100644
index 000000000..644e933fd
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/FDUMP.f
@@ -0,0 +1,24 @@
+ SUBROUTINE FDUMP
+C***BEGIN PROLOGUE FDUMP
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. Z
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Symbolic dump (should be locally written).
+C***DESCRIPTION
+C ***Note*** Machine Dependent Routine
+C FDUMP is intended to be replaced by a locally written
+C version which produces a symbolic dump. Failing this,
+C it should be replaced by a version which prints the
+C subprogram nesting list. Note that this dump must be
+C printed on each of up to five files, as indicated by the
+C XGETUA routine. See XSETUA and XGETUA for details.
+C
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C Latest revision --- 23 May 1979
+C***ROUTINES CALLED (NONE)
+C***END PROLOGUE FDUMP
+C***FIRST EXECUTABLE STATEMENT FDUMP
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/H12.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/H12.f
new file mode 100644
index 000000000..3a3323436
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/H12.f
@@ -0,0 +1,137 @@
+ SUBROUTINE H12(MODE,LPIVOT,L1,M,U,IUE,UP,C,ICE,ICV,NCV)
+C***BEGIN PROLOGUE H12
+C***REFER TO HFTI,LSEI,WNNLS
+C
+C SUBROUTINE H12 (MODE,LPIVOT,L1,M,U,IUE,UP,C,ICE,ICV,NCV)
+C
+C C.L.Lawson and R.J.Hanson, Jet Propulsion Laboratory, 1973 Jun 12
+C to appear in 'Solving Least Squares Problems', Prentice-Hall, 1974
+C
+C Modified at SANDIA LABS, May 1977, to --
+C
+C 1) Remove double precision accumulation, and
+C 2) Include usage of the Basic Linear Algebra Package for
+C vectors longer than a particular threshold.
+C
+C Construction and/or application of a single
+C Householder transformation.. Q = I + U*(U**T)/B
+C
+C MODE = 1 or 2 to select algorithm H1 or H2 .
+C LPIVOT is the index of the pivot element.
+C L1,M If L1 .LE. M the transformation will be constructed to
+C zero elements indexed from L1 through M. If L1 GT. M
+C THE SUBROUTINE DOES AN IDENTITY TRANSFORMATION.
+C U(),IUE,UP On entry to H1 U() contains the pivot vector.
+C IUE is the storage increment between elements.
+C On exit from H1 U() and UP
+C contain quantities defining the vector U of the
+C Householder transformation. On entry to H2 U()
+C and UP should contain quantities previously computed
+C by H1. These will not be modified by H2.
+C C() On entry to H1 or H2 C() contains a matrix which will be
+C regarded as a set of vectors to which the Householder
+C transformation is to be applied. On exit C() contains the
+C set of transformed vectors.
+C ICE Storage increment between elements of vectors in C().
+C ICV Storage increment between vectors in C().
+C NCV Number of vectors in C() to be transformed. If NCV .LE. 0
+C no operations will be done on C().
+C***ROUTINES CALLED SAXPY,SDOT,SSWAP
+C***END PROLOGUE H12
+c
+ USE setparms
+c
+ DIMENSION U(IUE,M), C(1)
+C***FIRST EXECUTABLE STATEMENT H12
+ ONE=1.
+C
+ IF (0.GE.LPIVOT.OR.LPIVOT.GE.L1.OR.L1.GT.M) RETURN
+ CL=ABS(U(1,LPIVOT))
+ IF (MODE.EQ.2) GO TO 60
+C ****** CONSTRUCT THE TRANSFORMATION. ******
+ DO 10 J=L1,M
+ 10 CL=AMAX1(ABS(U(1,J)),CL)
+ IF (CL) 130,130,20
+ 20 CLINV=ONE/CL
+ SM=(U(1,LPIVOT)*CLINV)**2
+ DO 30 J=L1,M
+ 30 SM=SM+(U(1,J)*CLINV)**2
+ CL=CL*SQRT(SM)
+ IF (U(1,LPIVOT)) 50,50,40
+ 40 CL=-CL
+ 50 UP=U(1,LPIVOT)-CL
+ U(1,LPIVOT)=CL
+ GO TO 70
+C ****** APPLY THE TRANSFORMATION I+U*(U**T)/B TO C. ******
+C
+ 60 IF (CL) 130,130,70
+ 70 IF (NCV.LE.0) RETURN
+ B=UP*U(1,LPIVOT)
+C B MUST BE NONPOSITIVE HERE. IF B = 0., RETURN.
+C
+ IF (B) 80,130,130
+ 80 B=ONE/B
+ MML1P2=M-L1+2
+ IF (MML1P2.GT.20) GO TO 140
+ I2=1-ICV+ICE*(LPIVOT-1)
+ INCR=ICE*(L1-LPIVOT)
+ DO 120 J=1,NCV
+ I2=I2+ICV
+ I3=I2+INCR
+ I4=I3
+ SM=C(I2)*UP
+ DO 90 I=L1,M
+ SM=SM+C(I3)*U(1,I)
+ 90 I3=I3+ICE
+ IF (SM) 100,120,100
+ 100 SM=SM*B
+ C(I2)=C(I2)+SM*UP
+ DO 110 I=L1,M
+ C(I4)=C(I4)+SM*U(1,I)
+ 110 I4=I4+ICE
+ 120 CONTINUE
+ 130 RETURN
+ 140 CONTINUE
+ L1M1=L1-1
+ KL1=1+(L1M1-1)*ICE
+ KL2=KL1
+ KLP=1+(LPIVOT-1)*ICE
+ UL1M1=U(1,L1M1)
+ U(1,L1M1)=UP
+ IF (LPIVOT.EQ.L1M1) GO TO 150
+ if (kind(C) == real_single) then
+ CALL SSWAP(NCV,C(KL1),ICV,C(KLP),ICV)
+ else if (kind(C) == real_double) then
+ CALL DSWAP(NCV,C(KL1),ICV,C(KLP),ICV)
+ endif
+
+ 150 CONTINUE
+
+ if (kind(U) == real_single .and. kind(C) == real_single) then
+ do J=1,NCV
+ SM=SDOT(MML1P2,U(1,L1M1),IUE,C(KL1),ICE)
+ SM=SM*B
+ CALL SAXPY (MML1P2,SM,U(1,L1M1),IUE,C(KL1),ICE)
+ KL1=KL1+ICV
+ enddo
+ else if (kind(U) == real_double .and. kind(C) == real_double) then
+ do J=1,NCV
+ SM=DDOT(MML1P2,U(1,L1M1),IUE,C(KL1),ICE)
+ SM=SM*B
+ CALL DAXPY (MML1P2,SM,U(1,L1M1),IUE,C(KL1),ICE)
+ KL1=KL1+ICV
+ enddo
+ endif
+
+ U(1,L1M1)=UL1M1
+ IF (LPIVOT.EQ.L1M1) RETURN
+ KL1=KL2
+
+ if (kind(C) == real_single) then
+ CALL SSWAP(NCV,C(KL1),ICV,C(KLP),ICV)
+ else if (kind(C) == real_double) then
+ CALL DSWAP(NCV,C(KL1),ICV,C(KLP),ICV)
+ endif
+
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/I1MACH.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/I1MACH.f
new file mode 100644
index 000000000..09dd15ae6
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/I1MACH.f
@@ -0,0 +1,108 @@
+ INTEGER FUNCTION I1MACH(I)
+C***BEGIN PROLOGUE I1MACH
+C***DATE WRITTEN 750101 (YYMMDD)
+C***REVISION DATE 910131 (YYMMDD)
+C***CATEGORY NO. R1
+C***KEYWORDS MACHINE CONSTANTS
+C***AUTHOR FOX, P. A., (BELL LABS)
+C HALL, A. D., (BELL LABS)
+C SCHRYER, N. L., (BELL LABS)
+C***PURPOSE Returns integer machine dependent constants
+C***DESCRIPTION
+C
+C This is the CMLIB version of I1MACH, the integer machine
+C constants subroutine originally developed for the PORT library.
+C
+C I1MACH can be used to obtain machine-dependent parameters
+C for the local machine environment. It is a function
+C subroutine with one (input) argument, and can be called
+C as follows, for example
+C
+C K = I1MACH(I)
+C
+C where I=1,...,16. The (output) value of K above is
+C determined by the (input) value of I. The results for
+C various values of I are discussed below.
+C
+C I/O unit numbers.
+C I1MACH( 1) = the standard input unit.
+C I1MACH( 2) = the standard output unit.
+C I1MACH( 3) = the standard punch unit.
+C I1MACH( 4) = the standard error message unit.
+C
+C Words.
+C I1MACH( 5) = the number of bits per integer storage unit.
+C I1MACH( 6) = the number of characters per integer storage unit.
+C
+C Integers.
+C assume integers are represented in the S-digit, base-A form
+C
+C sign ( X(S-1)*A**(S-1) + ... + X(1)*A + X(0) )
+C
+C where 0 .LE. X(I) .LT. A for I=0,...,S-1.
+C I1MACH( 7) = A, the base.
+C I1MACH( 8) = S, the number of base-A digits.
+C I1MACH( 9) = A**S - 1, the largest magnitude.
+C
+C Floating-Point Numbers.
+C Assume floating-point numbers are represented in the T-digit,
+C base-B form
+C sign (B**E)*( (X(1)/B) + ... + (X(T)/B**T) )
+C
+C where 0 .LE. X(I) .LT. B for I=1,...,T,
+C 0 .LT. X(1), and EMIN .LE. E .LE. EMAX.
+C I1MACH(10) = B, the base.
+C
+C Single-Precision
+C I1MACH(11) = T, the number of base-B digits.
+C I1MACH(12) = EMIN, the smallest exponent E.
+C I1MACH(13) = EMAX, the largest exponent E.
+C
+C Double-Precision
+C I1MACH(14) = T, the number of base-B digits.
+C I1MACH(15) = EMIN, the smallest exponent E.
+C I1MACH(16) = EMAX, the largest exponent E.
+C
+C To alter this function for a particular environment,
+C the desired set of DATA statements should be activated by
+C removing the C from column 1. Also, the values of
+C I1MACH(1) - I1MACH(4) should be checked for consistency
+C with the local operating system.
+C***REFERENCES FOX P.A., HALL A.D., SCHRYER N.L.,*FRAMEWORK FOR A
+C PORTABLE LIBRARY*, ACM TRANSACTIONS ON MATHEMATICAL
+C SOFTWARE, VOL. 4, NO. 2, JUNE 1978, PP. 177-188.
+C***ROUTINES CALLED (NONE)
+C***END PROLOGUE I1MACH
+C
+ INTEGER IMACH(16),OUTPUT
+ EQUIVALENCE (IMACH(4),OUTPUT)
+C
+C MACHINE CONSTANTS FOR THE IBM RS 6000
+C USING THE 32 BIT INTEGER COMPILER OPTION
+C
+C === MACHINE = 1 .32-BIT-INTEGER
+ DATA IMACH( 1) / 5 /
+ DATA IMACH( 2) / 6 /
+ DATA IMACH( 3) / 6 /
+ DATA IMACH( 4) / 0 /
+ DATA IMACH( 5) / 32 /
+ DATA IMACH( 6) / 4 /
+ DATA IMACH( 7) / 2 /
+ DATA IMACH( 8) / 31 /
+ DATA IMACH( 9) / 2147483647 /
+ DATA IMACH(10) / 2 /
+ DATA IMACH(11) / 24 /
+ DATA IMACH(12) / -125 /
+ DATA IMACH(13) / 128 /
+ DATA IMACH(14) / 53 /
+ DATA IMACH(15) / -1021 /
+ DATA IMACH(16) / 1024 /
+c
+C***FIRST EXECUTABLE STATEMENT I1MACH
+ IF (I .LT. 1 .OR. I .GT. 16)
+ 1 CALL XERROR ( 'I1MACH -- I OUT OF BOUNDS',25,1,2)
+C
+ I1MACH=IMACH(I)
+ RETURN
+C
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/J4SAVE.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/J4SAVE.f
new file mode 100644
index 000000000..630238cda
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/J4SAVE.f
@@ -0,0 +1,51 @@
+ FUNCTION J4SAVE(IWHICH,IVALUE,ISET)
+C***BEGIN PROLOGUE J4SAVE
+C***REFER TO XERROR
+C Abstract
+C J4SAVE saves and recalls several global variables needed
+C by the library error handling routines.
+C
+C Description of Parameters
+C --Input--
+C IWHICH - Index of item desired.
+C = 1 Refers to current error number.
+C = 2 Refers to current error control flag.
+C = 3 Refers to current unit number to which error
+C messages are to be sent. (0 means use standard.)
+C = 4 Refers to the maximum number of times any
+C message is to be printed (as set by XERMAX).
+C = 5 Refers to the total number of units to which
+C each error message is to be written.
+C = 6 Refers to the 2nd unit for error messages
+C = 7 Refers to the 3rd unit for error messages
+C = 8 Refers to the 4th unit for error messages
+C = 9 Refers to the 5th unit for error messages
+C IVALUE - The value to be set for the IWHICH-th parameter,
+C if ISET is .TRUE. .
+C ISET - If ISET=.TRUE., the IWHICH-th parameter will BE
+C given the value, IVALUE. If ISET=.FALSE., the
+C IWHICH-th parameter will be unchanged, and IVALUE
+C is a dummy parameter.
+C --Output--
+C The (old) value of the IWHICH-th parameter will be returned
+C in the function value, J4SAVE.
+C
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C Adapted from Bell Laboratories PORT Library Error Handler
+C Latest revision --- 23 MAY 1979
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED (NONE)
+C***END PROLOGUE J4SAVE
+ LOGICAL ISET
+ INTEGER IPARAM(9)
+ SAVE IPARAM
+ DATA IPARAM(1),IPARAM(2),IPARAM(3),IPARAM(4)/0,2,0,10/
+ DATA IPARAM(5)/1/
+ DATA IPARAM(6),IPARAM(7),IPARAM(8),IPARAM(9)/0,0,0,0/
+C***FIRST EXECUTABLE STATEMENT J4SAVE
+ J4SAVE = IPARAM(IWHICH)
+ IF (ISET) IPARAM(IWHICH) = IVALUE
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/Makefile b/sorc/hafs_tools.fd/sorc/hafs_vi/split/Makefile
new file mode 100644
index 000000000..aa40f5fea
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/Makefile
@@ -0,0 +1,33 @@
+include ../configure.vi
+include ../pure-openmp.inc
+
+SRCS = modules.f split.f BOUND.f fft99.f sig_p_convt.f \
+ SEPAR.f WNLIT.f FDUMP.f H12.f I1MACH.f J4SAVE.f XGETUA.f \
+ WNLSM.f WNNLS.f XERABT.f XERCTL.f XERPRT.f XERROR.f XERRWV.f \
+ XERSAV.f srotm.f srotmg.f amatrix.f rodist.f landcmsk.f \
+ create_rel_domain.f
+
+OBJS = modules.o split.o BOUND.o fft99.o sig_p_convt.o \
+ SEPAR.o WNLIT.o FDUMP.o H12.o I1MACH.o J4SAVE.o XGETUA.o \
+ WNLSM.o WNNLS.o XERABT.o XERCTL.o XERPRT.o XERROR.o XERRWV.o \
+ XERSAV.o srotm.o srotmg.o amatrix.o rodist.o landcmsk.o \
+ create_rel_domain.o
+
+# Requires either essl or blas library.
+LIBS = $(ESSLLIB)
+EXEC = ../../../exec/hafs_vi_split.x
+
+$(EXEC): $(OBJS)
+ $(SFC) $(FFLAGS) $(FFLAGS_DOUBLE) $(LDFLAGS) -o $(@) $(OBJS) $(LIBS)
+
+.f.o:
+ $(SFC) $(FFLAGS) $(FFLAGS_DOUBLE) -c $<
+
+.PHONY: clean
+
+clean:
+ $(RM) $(OBJS) *.mod
+
+distclean: clean
+ $(RM) $(EXEC)
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/SEPAR.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/SEPAR.f
new file mode 100644
index 000000000..c3fa9b219
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/SEPAR.f
@@ -0,0 +1,146 @@
+ SUBROUTINE SEPAR(XD,XM)
+C
+C SEPERATES A FIELD INTO HURRICANE COMPONENT AND REMAINDER
+C
+
+ PARAMETER( NMX=24,nmx1=nmx+1,nmx2=nmx*2,nmx6=nmx*6)
+ PARAMETER (IMX=41 , JMX=41)
+ DIMENSION XR(NMX),XD(IMX,JMX)
+CC
+ COMMON /POSIT/ XOLD,YOLD,XCORN,YCORN
+ COMMON /XXX/ XF(IMX,JMX),XC,YC,DX,DY
+ dimension XM(IMX,JMX)
+C
+c new arrays
+ dimension b(nmx),w(nmx),ab(nmx,nmx1),ipvt(nmx)
+ 1 ,wrk(nmx6),iwrk(nmx2)
+ common /matrix/ a(nmx,nmx),capd2
+ common /vect/rovect(nmx),xvect(nmx),yvect(nmx)
+c
+ DATA XR/24*0./
+C
+C XC,YC ARE HURRICANE COORDINATES
+C RO IS RADIUS AT WHICH HURRICANE COMPONENT OF FIELD GOES TO ZERO
+C XR ARRAY CONTAINS THE FIELD VALUES OF 12 EQUALLY SPACED POINTS
+C ON CIRCLE OF RADIUS RO CENTERED AT XC,YC
+C
+c set ro to be max value of rovect
+c
+ ro=0.
+ do 22 i=1,nmx
+ ro=amax1(ro,rovect(i))
+22 continue
+ PI = 4.*ATAN(1.0)
+ PI180 = 4.*ATAN(1.0)/180.
+c qliu FACT = COS(YOLD*PI180)
+ FACT = 1.0
+c DDEL=1.0*PI180
+c DTHA=1.0*PI180
+CC
+CC XC IS THE I POSITION OF THE CENTER OF THE OLD VORTEX
+CC YC IS THE J POSITION OF THE CENTER OF THE OLD VORTEX
+CC DDEL IS THE LONG. IN RADIANS OF THE OUTER NEST
+CC DTHA IS THE LAT. IN RADIANS OF THE OUTER NEST
+CC
+c no fact here
+c DX=FACT*DDEL/PI180
+c
+c dx=ddel/pi180
+c DY=DTHA/PI180
+ dx=1.0
+ DY=1.0
+cc
+ XC = (XOLD-XCORN)*DX
+ YC = (YOLD-YCORN)*DY
+ IS=INT((XC-RO/fact)/DX) +1.
+ IE=INT((XC+RO/fact)/DX + 1.)
+ JS=INT((YC-RO)/DY) +1.
+ JE=INT((YC+RO)/DY + 1.)
+C
+ DO 1 J = 1 , JMX
+ DO 1 I = 1 , IMX
+ XF(I,J) = XD(I,J)
+1 CONTINUE
+C
+C SUBROUTINE BOUND COMPUTES FIELD VALUES OF ARRAY XR USING
+C BILINEAR INTERPOLATION
+C
+c
+ CALL BOUND(NMX,XR,rovect)
+
+C
+c xrop(nmx) are the interpolated values of the disturbance
+c field at the rovect pts
+c
+c romax is the maximum value in rovect(nmx). Within the loop a local
+c ro is computed for use in the separation. At the start of the loop
+c ro is again set to romax to define the domain.
+c
+c
+c
+ w=0.
+ romax=ro
+C
+ DO 10 IX=IS,IE
+ DO 11 JY=JS,JE
+ ro=romax
+c X=XC-RO +DX*(IX-IS)
+c Y=YC-RO +DY*(JY-JS)
+ X= DX*float(IX) -1.
+ Y= DY*float(JY) -1.
+ delx=(x-xc)*fact
+ dely=(y-yc)
+ DR=SQRT((delx)**2 +(dely)**2)
+ IF(DR.GT.RO)GOTO11
+ IF(delx.ne.0.) THETA=ATAN((dely)/(delx))
+ if(delx.eq.0..and.dely.lt.0.)theta=270.*pi180
+ if(delx.eq.0..and.dely.gt.0.)theta=90. *pi180
+ IF(delx.LT.0.)THETA=THETA+PI
+ IF(THETA.LT.0.)THETA=2.*PI+THETA
+ N1=INT(THETA*NMX/(2.*PI))
+ IF(N1.GT.nmx)PRINT*,N1,THETA*57.296
+ IF(N1.LT.0)PRINT*,N1,THETA*57.296
+ N2=N1+2
+ IF(N2.GT.NMX)N2=N2-NMX
+ DELTH=THETA- 2.*PI*FLOAT(N1)/FLOAT(NMX)
+c
+ ro=delth*float(nmx)/(2.*pi)*(rovect(n2)-rovect(n1+1))
+ 1 +rovect(n1+1)
+ IF(DR.GT.ro)GOTO11
+ XRO=DELTH*FLOAT(NMX)/(2.*PI)*(XR(N2)-XR(N1+1)) +XR(N1+1)
+CC
+c Now add new code to compute distance from each gridpt. to rovect pts
+c
+ do 12 ip=1,nmx
+ dpij= (fact*(x-xvect(ip)))**2 +(y-yvect(ip))**2
+ b(ip)=exp(-dpij/capd2)
+12 continue
+c
+c
+ do 44 ip=1,nmx
+ do 43 jp=1,nmx
+43 ab(ip,jp)=a(ip,jp)
+ ab(ip,nmx1)=b(ip)
+44 continue
+c
+c solve system using constrained least squares method
+c
+ call wnnls(ab,nmx,0,nmx,nmx,0,1.,w,rnm,md,iwrk,wrk)
+c
+ temp=0.
+ do 20 ip=1,nmx
+ temp=temp +w(ip)*xr(ip)
+20 continue
+c xh(ix,jy)=xf(ix,jy)-temp
+c qliu xd(ix,jy)=temp
+ xm(ix,jy)=temp
+11 CONTINUE
+10 CONTINUE
+c print*,'qliu test2'
+ do j=1,jmx
+ do i=1,imx
+c print*,xf(i,j),xd(i,j),xf(i,j)-xd(i,j),i,j
+ end do
+ end do
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLIT.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLIT.f
new file mode 100644
index 000000000..16c218215
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLIT.f
@@ -0,0 +1,437 @@
+ SUBROUTINE WNLIT(W,MDW,M,N,L,IPIVOT,ITYPE,H,SCALE,RNORM,IDOPE,
+ 1 DOPE,DONE)
+C***BEGIN PROLOGUE WNLIT
+C***REFER TO WNNLS
+C
+C This is a companion subprogram to WNNLS( ).
+C The documentation for WNNLS( ) has more complete
+C usage instructions.
+C
+C Note The M by (N+1) matrix W( , ) contains the rt. hand side
+C B as the (N+1)st col.
+C
+C Triangularize L1 by L1 subsystem, where L1=MIN(M,L), with
+C col interchanges.
+C Revised March 4, 1982.
+C***ROUTINES CALLED H12,ISAMAX,SCOPY,SROTM,SROTMG,SSCAL,SSWAP
+C***END PROLOGUE WNLIT
+C
+C THE EDITING REQUIRED TO CONVERT THIS SUBROUTINE FROM SINGLE TO
+C DOUBLE PRECISION INVOLVES THE FOLLOWING CHARACTER STRING CHANGES.
+C USE AN EDITING COMMAND (CHANGE) /STRING-1/(TO)STRING-2/.
+C (BEGIN CHANGES AT LINE WITH C++ IN COLS. 1-3.)
+C /REAL (12 BLANKS)/DOUBLE PRECISION/,/SCOPY/DCOPY/,/SROTM/DROTM/,
+C /SSCAL/DSCAL/,
+C /SSWAP/DSWAP/,/AMAX1/DMAX1/,/ISAMAX/IDAMAX/,/.E-/.D-/,/E0/D0/
+C
+C++
+ USE setparms
+c
+ REAL W(MDW,1), H(1), SCALE(1), DOPE(4), SPARAM(5)
+ REAL ALSQ, AMAX, EANORM, FAC, FACTOR, HBAR, ONE, RN
+ REAL RNORM, SN, T, TAU, TENM3, ZERO
+ REAL AMAX1
+ INTEGER ITYPE(1), IPIVOT(1), IDOPE(8)
+ integer(kind = int_single) ISAMAX,IDAMAX
+ LOGICAL INDEP, DONE, RECALC
+ DATA TENM3 /1.E-3/, ZERO /0.E0/, ONE /1.E0/
+C
+C***FIRST EXECUTABLE STATEMENT WNLIT
+ ME = IDOPE(1)
+ MEP1 = IDOPE(2)
+ KRANK = IDOPE(3)
+ KRP1 = IDOPE(4)
+ NSOLN = IDOPE(5)
+ NIV = IDOPE(6)
+ NIV1 = IDOPE(7)
+ L1 = IDOPE(8)
+C
+ ALSQ = DOPE(1)
+ EANORM = DOPE(2)
+ FAC = DOPE(3)
+ TAU = DOPE(4)
+ NP1 = N + 1
+ LB = MIN0(M-1,L)
+ RECALC = .TRUE.
+ RNORM = ZERO
+ KRANK = 0
+C WE SET FACTOR=1.E0 SO THAT THE HEAVY WEIGHT ALAMDA WILL BE
+C INCLUDED IN THE TEST FOR COL INDEPENDENCE.
+ FACTOR = 1.E0
+ I = 1
+ IP1 = 2
+ LEND = L
+ 10 IF (.NOT.(I.LE.LB)) GO TO 150
+C
+C SET IR TO POINT TO THE I-TH ROW.
+ IR = I
+ MEND = M
+ ASSIGN 20 TO IGO996
+ GO TO 460
+C
+C UPDATE-COL-SS-AND-FIND-PIVOT-COL
+ 20 ASSIGN 30 TO IGO993
+ GO TO 560
+C
+C PERFORM-COL-INTERCHANGE
+C
+C SET IC TO POINT TO I-TH COL.
+ 30 IC = I
+ ASSIGN 40 TO IGO990
+ GO TO 520
+C
+C TEST-INDEP-OF-INCOMING-COL
+ 40 IF (.NOT.(INDEP)) GO TO 110
+C
+C ELIMINATE I-TH COL BELOW DIAG. USING MOD. GIVENS TRANSFORMATIONS
+C APPLIED TO (A B).
+ J = M
+ DO 100 JJ=IP1,M
+ JM1 = J - 1
+ JP = JM1
+C WHEN OPERATING NEAR THE ME LINE, USE THE LARGEST ELT.
+C ABOVE IT AS THE PIVOT.
+ IF (.NOT.(J.EQ.MEP1)) GO TO 80
+ IMAX = ME
+ AMAX = SCALE(ME)*W(ME,I)**2
+ 50 IF (.NOT.(JP.GE.I)) GO TO 70
+ T = SCALE(JP)*W(JP,I)**2
+ IF (.NOT.(T.GT.AMAX)) GO TO 60
+ IMAX = JP
+ AMAX = T
+ 60 JP = JP - 1
+ GO TO 50
+ 70 JP = IMAX
+ 80 IF (.NOT.(W(J,I).NE.ZERO)) GO TO 90
+ CALL SROTMG(SCALE(JP), SCALE(J), W(JP,I), W(J,I), SPARAM)
+ W(J,I) = ZERO
+ CALL SROTM(NP1-I, W(JP,IP1), MDW, W(J,IP1), MDW, SPARAM)
+ 90 J = JM1
+ 100 CONTINUE
+ GO TO 140
+ 110 CONTINUE
+ IF (.NOT.(LEND.GT.I)) GO TO 130
+C
+C COL I IS DEPENDENT. SWAP WITH COL LEND.
+ MAX = LEND
+C
+C PERFORM-COL-INTERCHANGE
+ ASSIGN 120 TO IGO993
+ GO TO 560
+ 120 CONTINUE
+ LEND = LEND - 1
+C
+C FIND COL IN REMAINING SET WITH LARGEST SS.
+ if (kind(H) == real_single) then
+ MAX = ISAMAX(LEND-I+1,H(I),1) + I - 1
+ else if (kind(H) == real_double) then
+ MAX = IDAMAX(LEND-I+1,H(I),1) + I - 1
+ endif
+ HBAR = H(MAX)
+ GO TO 30
+ 130 CONTINUE
+ KRANK = I - 1
+ GO TO 160
+ 140 I = IP1
+ IP1 = IP1 + 1
+ GO TO 10
+ 150 KRANK = L1
+ 160 CONTINUE
+ KRP1 = KRANK + 1
+ IF (.NOT.(KRANK.LT.ME)) GO TO 290
+ FACTOR = ALSQ
+ DO 170 I=KRP1,ME
+ IF (L.GT.0) W(I,1) = ZERO
+ if (kind(W) == real_single) then
+ CALL SCOPY(L, W(I,1), 0, W(I,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DCOPY(L, W(I,1), 0, W(I,1), MDW)
+ endif
+ 170 CONTINUE
+C
+C DETERMINE THE RANK OF THE REMAINING EQUALITY CONSTRAINT
+C EQUATIONS BY ELIMINATING WITHIN THE BLOCK OF CONSTRAINED
+C VARIABLES. REMOVE ANY REDUNDANT CONSTRAINTS.
+ LP1 = L + 1
+ RECALC = .TRUE.
+ LB = MIN0(L+ME-KRANK,N)
+ I = LP1
+ IP1 = I + 1
+ 180 IF (.NOT.(I.LE.LB)) GO TO 280
+ IR = KRANK + I - L
+ LEND = N
+ MEND = ME
+ ASSIGN 190 TO IGO996
+ GO TO 460
+C
+C UPDATE-COL-SS-AND-FIND-PIVOT-COL
+ 190 ASSIGN 200 TO IGO993
+ GO TO 560
+C
+C PERFORM-COL-INTERCHANGE
+C
+C ELIMINATE ELEMENTS IN THE I-TH COL.
+ 200 J = ME
+ 210 IF (.NOT.(J.GT.IR)) GO TO 230
+ JM1 = J - 1
+ IF (.NOT.(W(J,I).NE.ZERO)) GO TO 220
+ CALL SROTMG(SCALE(JM1), SCALE(J), W(JM1,I), W(J,I), SPARAM)
+ W(J,I) = ZERO
+ CALL SROTM(NP1-I, W(JM1,IP1), MDW, W(J,IP1), MDW, SPARAM)
+ 220 J = JM1
+ GO TO 210
+C
+C SET IC=I=COL BEING ELIMINATED
+ 230 IC = I
+ ASSIGN 240 TO IGO990
+ GO TO 520
+C
+C TEST-INDEP-OF-INCOMING-COL
+ 240 IF (INDEP) GO TO 270
+C
+C REMOVE ANY REDUNDANT OR DEPENDENT EQUALITY CONSTRAINTS.
+ JJ = IR
+ 250 IF (.NOT.(IR.LE.ME)) GO TO 260
+ W(IR,1) = ZERO
+
+ if (kind(W) == real_single) then
+ CALL SCOPY(N, W(IR,1), 0, W(IR,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DCOPY(N, W(IR,1), 0, W(IR,1), MDW)
+ endif
+
+ RNORM = RNORM + (SCALE(IR)*W(IR,NP1)/ALSQ)*W(IR,NP1)
+ W(IR,NP1) = ZERO
+ SCALE(IR) = ONE
+C RECLASSIFY THE ZEROED ROW AS A LEAST SQUARES EQUATION.
+ ITYPE(IR) = 1
+ IR = IR + 1
+ GO TO 250
+C
+C REDUCE ME TO REFLECT ANY DISCOVERED DEPENDENT EQUALITY
+C CONSTRAINTS.
+ 260 CONTINUE
+ ME = JJ - 1
+ MEP1 = ME + 1
+ GO TO 300
+ 270 I = IP1
+ IP1 = IP1 + 1
+ GO TO 180
+ 280 CONTINUE
+ 290 CONTINUE
+ 300 CONTINUE
+ IF (.NOT.(KRANK.LT.L1)) GO TO 420
+C
+C TRY TO DETERMINE THE VARIABLES KRANK+1 THROUGH L1 FROM THE
+C LEAST SQUARES EQUATIONS. CONTINUE THE TRIANGULARIZATION WITH
+C PIVOT ELEMENT W(MEP1,I).
+C
+ RECALC = .TRUE.
+C
+C SET FACTOR=ALSQ TO REMOVE EFFECT OF HEAVY WEIGHT FROM
+C TEST FOR COL INDEPENDENCE.
+ FACTOR = ALSQ
+ KK = KRP1
+ I = KK
+ IP1 = I + 1
+ 310 IF (.NOT.(I.LE.L1)) GO TO 410
+C
+C SET IR TO POINT TO THE MEP1-ST ROW.
+ IR = MEP1
+ LEND = L
+ MEND = M
+ ASSIGN 320 TO IGO996
+ GO TO 460
+C
+C UPDATE-COL-SS-AND-FIND-PIVOT-COL
+ 320 ASSIGN 330 TO IGO993
+ GO TO 560
+C
+C PERFORM-COL-INTERCHANGE
+C
+C ELIMINATE I-TH COL BELOW THE IR-TH ELEMENT.
+ 330 IRP1 = IR + 1
+ J = M
+ DO 350 JJ=IRP1,M
+ JM1 = J - 1
+ IF (.NOT.(W(J,I).NE.ZERO)) GO TO 340
+ CALL SROTMG(SCALE(JM1), SCALE(J), W(JM1,I), W(J,I), SPARAM)
+ W(J,I) = ZERO
+ CALL SROTM(NP1-I, W(JM1,IP1), MDW, W(J,IP1), MDW, SPARAM)
+ 340 J = JM1
+ 350 CONTINUE
+C
+C TEST IF NEW PIVOT ELEMENT IS NEAR ZERO. IF SO, THE COL IS
+C DEPENDENT.
+ T = SCALE(IR)*W(IR,I)**2
+ INDEP = T.GT.TAU**2*EANORM**2
+ IF (.NOT.INDEP) GO TO 380
+C
+C COL TEST PASSED. NOW MUST PASS ROW NORM TEST TO BE CLASSIFIED
+C AS INDEPENDENT.
+ RN = ZERO
+ DO 370 I1=IR,M
+ DO 360 J1=IP1,N
+ RN = AMAX1(RN,SCALE(I1)*W(I1,J1)**2)
+ 360 CONTINUE
+ 370 CONTINUE
+ INDEP = T.GT.TAU**2*RN
+C
+C IF INDEPENDENT, SWAP THE IR-TH AND KRP1-ST ROWS TO MAINTAIN THE
+C TRIANGULAR FORM. UPDATE THE RANK INDICATOR KRANK AND THE
+C EQUALITY CONSTRAINT POINTER ME.
+ 380 IF (.NOT.(INDEP)) GO TO 390
+ if (kind(W) == real_single) then
+ CALL SSWAP(NP1, W(KRP1,1), MDW, W(IR,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(NP1, W(KRP1,1), MDW, W(IR,1), MDW)
+ endif
+ if (kind(SCALE) == real_single) then
+ CALL SSWAP(1, SCALE(KRP1), 1, SCALE(IR), 1)
+ else if (kind(SCALE) == real_double) then
+ CALL DSWAP(1, SCALE(KRP1), 1, SCALE(IR), 1)
+ endif
+C RECLASSIFY THE LEAST SQ. EQUATION AS AN EQUALITY CONSTRAINT AND
+C RESCALE IT.
+ ITYPE(IR) = 0
+ T = SQRT(SCALE(KRP1))
+
+ if (kind(W) == real_single) then
+ CALL SSCAL(NP1, T, W(KRP1,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSCAL(NP1, T, W(KRP1,1), MDW)
+ endif
+
+ SCALE(KRP1) = ALSQ
+ ME = MEP1
+ MEP1 = ME + 1
+ KRANK = KRP1
+ KRP1 = KRANK + 1
+ GO TO 400
+ 390 GO TO 430
+ 400 I = IP1
+ IP1 = IP1 + 1
+ GO TO 310
+ 410 CONTINUE
+ 420 CONTINUE
+ 430 CONTINUE
+C
+C IF PSEUDORANK IS LESS THAN L, APPLY HOUSEHOLDER TRANS.
+C FROM RIGHT.
+ IF (.NOT.(KRANK.LT.L)) GO TO 450
+ DO 440 I=1,KRANK
+ J = KRP1 - I
+ CALL H12(1, J, KRP1, L, W(J,1), MDW, H(J), W, MDW, 1, J-1)
+ 440 CONTINUE
+ 450 NIV = KRANK + NSOLN - L
+ NIV1 = NIV + 1
+ IF (L.EQ.N) DONE = .TRUE.
+C
+C END OF INITIAL TRIANGULARIZATION.
+ IDOPE(1) = ME
+ IDOPE(2) = MEP1
+ IDOPE(3) = KRANK
+ IDOPE(4) = KRP1
+ IDOPE(5) = NSOLN
+ IDOPE(6) = NIV
+ IDOPE(7) = NIV1
+ IDOPE(8) = L1
+ RETURN
+ 460 CONTINUE
+C
+C TO UPDATE-COL-SS-AND-FIND-PIVOT-COL
+C
+C THE COL SS VECTOR WILL BE UPDATED AT EACH STEP. WHEN
+C NUMERICALLY NECESSARY, THESE VALUES WILL BE RECOMPUTED.
+C
+ IF (.NOT.(IR.NE.1 .AND. (.NOT.RECALC))) GO TO 480
+C UPDATE COL SS =SUM OF SQUARES.
+ DO 470 J=I,LEND
+ H(J) = H(J) - SCALE(IR-1)*W(IR-1,J)**2
+ 470 CONTINUE
+C
+C TEST FOR NUMERICAL ACCURACY.
+ if (kind(H) == real_single) then
+ MAX = ISAMAX(LEND-I+1,H(I),1) + I - 1
+ else if (kind(H) == real_double) then
+ MAX = IDAMAX(LEND-I+1,H(I),1) + I - 1
+ endif
+ RECALC = HBAR + TENM3*H(MAX).EQ.HBAR
+C
+C IF REQUIRED, RECALCULATE COL SS, USING ROWS IR THROUGH MEND.
+ 480 IF (.NOT.(RECALC)) GO TO 510
+ DO 500 J=I,LEND
+ H(J) = ZERO
+ DO 490 K=IR,MEND
+ H(J) = H(J) + SCALE(K)*W(K,J)**2
+ 490 CONTINUE
+ 500 CONTINUE
+C
+C FIND COL WITH LARGEST SS.
+ if (kind(H) == real_single) then
+ MAX = ISAMAX(LEND-I+1,H(I),1) + I - 1
+ else if (kind(H) == real_double) then
+ MAX = IDAMAX(LEND-I+1,H(I),1) + I - 1
+ endif
+
+ HBAR = H(MAX)
+ 510 GO TO 600
+ 520 CONTINUE
+C
+C TO TEST-INDEP-OF-INCOMING-COL
+C
+C TEST THE COL IC TO DETERMINE IF IT IS LINEARLY INDEPENDENT
+C OF THE COLS ALREADY IN THE BASIS. IN THE INIT TRI
+C STEP, WE USUALLY WANT THE HEAVY WEIGHT ALAMDA TO
+C BE INCLUDED IN THE TEST FOR INDEPENDENCE. IN THIS CASE THE
+C VALUE OF FACTOR WILL HAVE BEEN SET TO 1.E0 BEFORE THIS
+C PROCEDURE IS INVOKED. IN THE POTENTIALLY RANK DEFICIENT
+C PROBLEM, THE VALUE OF FACTOR WILL HAVE BEEN
+C SET TO ALSQ=ALAMDA**2 TO REMOVE THE EFFECT OF THE HEAVY WEIGHT
+C FROM THE TEST FOR INDEPENDENCE.
+C
+C WRITE NEW COL AS PARTITIONED VECTOR
+C (A1) NUMBER OF COMPONENTS IN SOLN SO FAR = NIV
+C (A2) M-NIV COMPONENTS
+C AND COMPUTE SN = INVERSE WEIGHTED LENGTH OF A1
+C RN = INVERSE WEIGHTED LENGTH OF A2
+C CALL THE COL INDEPENDENT WHEN RN .GT. TAU*SN
+ SN = ZERO
+ RN = ZERO
+ DO 550 J=1,MEND
+ T = SCALE(J)
+ IF (J.LE.ME) T = T/FACTOR
+ T = T*W(J,IC)**2
+ IF (.NOT.(J.LT.IR)) GO TO 530
+ SN = SN + T
+ GO TO 540
+ 530 RN = RN + T
+ 540 CONTINUE
+ 550 CONTINUE
+ INDEP = RN.GT.TAU**2*SN
+ GO TO 590
+ 560 CONTINUE
+C
+C TO PERFORM-COL-INTERCHANGE
+C
+ IF (.NOT.(MAX.NE.I)) GO TO 570
+C EXCHANGE ELEMENTS OF PERMUTED INDEX VECTOR AND PERFORM COL
+C INTERCHANGES.
+ ITEMP = IPIVOT(I)
+ IPIVOT(I) = IPIVOT(MAX)
+ IPIVOT(MAX) = ITEMP
+
+ if (kind(W) == real_single) then
+ CALL SSWAP(M, W(1,MAX), 1, W(1,I), 1)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(M, W(1,MAX), 1, W(1,I), 1)
+ endif
+
+ T = H(MAX)
+ H(MAX) = H(I)
+ H(I) = T
+ 570 GO TO 580
+ 580 GO TO IGO993, (30, 200, 330, 120)
+ 590 GO TO IGO990, (40, 240)
+ 600 GO TO IGO996, (20, 190, 320)
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLSM.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLSM.f
new file mode 100644
index 000000000..b5bce80f6
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNLSM.f
@@ -0,0 +1,822 @@
+ SUBROUTINE WNLSM(W,MDW,MME,MA,N,L,PRGOPT,X,RNORM,MODE,IPIVOT,
+ 1 ITYPE,WD,H,SCALE,Z,TEMP,D)
+C***BEGIN PROLOGUE WNLSM
+C***REFER TO WNNLS
+C
+C This is a companion subprogram to WNNLS( ).
+C The documentation for WNNLS( ) has more complete
+C usage instructions.
+C
+C Written by Karen H. Haskell, Sandia Laboratories,
+C with the help of R.J. Hanson, Sandia Laboratories,
+C December 1976 - January 1978.
+C Revised March 4, 1982.
+C
+C In addition to the parameters discussed in the prologue to
+C subroutine WNNLS, the following work arrays are used in
+C subroutine WNLSM (they are passed through the calling
+C sequence from WNNLS for purposes of variable dimensioning).
+C Their contents will in general be of no interest to the user.
+C
+C IPIVOT(*)
+C An array of length N. Upon completion it contains the
+C pivoting information for the cols of W(*,*).
+C
+C ITYPE(*)
+C An array of length M which is used to keep track
+C of the classification of the equations. ITYPE(I)=0
+C denotes equation I as an equality constraint.
+C ITYPE(I)=1 denotes equation I as a least squares
+C equation.
+C
+C WD(*)
+C An array of length N. Upon completion it contains the
+C dual solution vector.
+C
+C H(*)
+C An array of length N. Upon completion it contains the
+C pivot scalars of the Householder transformations performed
+C in the case KRANK.LT.L.
+C
+C SCALE(*)
+C An array of length M which is used by the subroutine
+C to store the diagonal matrix of weights.
+C These are used to apply the modified Givens
+C transformations.
+C
+C Z(*),TEMP(*)
+C Working arrays of length N.
+C
+C D(*)
+C An array of length N that contains the
+C column scaling for the matrix (E).
+C (A)
+C***ROUTINES CALLED H12,ISAMAX,SASUM,SAXPY,SCOPY,SNRM2,SROTM,SROTMG,
+C SSCAL,SSWAP,WNLIT,XERROR
+C***END PROLOGUE WNLSM
+C
+C THE EDITING REQUIRED TO CONVERT THIS SUBROUTINE FROM SINGLE TO
+C DOUBLE PRECISION INVOLVES THE FOLLOWING CHARACTER STRING CHANGES.
+C USE AN EDITING COMMAND (CHANGE) /STRING-1/(TO)STRING-2/.
+C (BEGIN CHANGES AT LINE WITH C++ IN COLS. 1-3.)
+C /REAL (12 BLANKS)/DOUBLE PRECISION/,/SASUM/DASUM/,/SROTMG/DROTMG/,
+C /SNRM2/DNRM2/,/ SQRT/ DSQRT/,/SROTM/DROTM/,/AMAX1/DMAX1/,
+C /SCOPY/DCOPY/,/SSCAL/DSCAL/,/SAXPY/DAXPY/,/E0/D0/,/SSWAP/DSWAP/,
+C /ISAMAX/IDAMAX/,/SRELPR/DRELPR/
+C
+C SUBROUTINE WNLSM (W,MDW,MME,MA,N,L,PRGOPT,X,RNORM,MODE,
+C 1 IPIVOT,ITYPE,WD,H,SCALE,Z,TEMP,D)
+C++
+ USE setparms
+c
+ REAL W(MDW,1), X(1), WD(1), H(1), SCALE(1), DOPE(4)
+ REAL Z(1), TEMP(1), PRGOPT(1), D(1), SPARAM(5)
+ REAL ALAMDA, ALPHA, ALSQ, AMAX, BNORM, EANORM
+ REAL SRELPR, FAC, ONE, BLOWUP
+ REAL RNORM, SM, T, TAU, TWO, WMAX, ZERO, ZZ, Z2
+ REAL AMAX1, SQRT, SNRM2, SASUM, DNRM2, DASUM
+
+ INTEGER IPIVOT(1), ITYPE(1), IDOPE(8)
+ integer(kind = int_single) ISAMAX,IDAMAX
+ LOGICAL HITCON, FEASBL, DONE, POS
+ DATA ZERO /0.E0/, ONE /1.E0/, TWO /2.E0/, SRELPR /0.E0/
+C
+C INITIALIZE-VARIABLES
+C***FIRST EXECUTABLE STATEMENT WNLSM
+ ASSIGN 10 TO IGO998
+ GO TO 180
+C
+C PERFORM INITIAL TRIANGULARIZATION IN THE SUBMATRIX
+C CORRESPONDING TO THE UNCONSTRAINED VARIABLES USING
+C THE PROCEDURE INITIALLY-TRIANGULARIZE.
+ 10 ASSIGN 20 TO IGO995
+ GO TO 280
+C
+C PERFORM WNNLS ALGORITHM USING THE FOLLOWING STEPS.
+C
+C UNTIL(DONE)
+C
+C COMPUTE-SEARCH-DIRECTION-AND-FEASIBLE-POINT
+C
+C WHEN (HITCON) ADD-CONSTRAINTS
+C
+C ELSE PERFORM-MULTIPLIER-TEST-AND-DROP-A-CONSTRAINT
+C
+C FIN
+C
+C COMPUTE-FINAL-SOLUTION
+C
+ 20 IF (DONE) GO TO 80
+C
+ ASSIGN 30 TO IGO991
+ GO TO 300
+C
+C COMPUTE-SEARCH-DIRECTION-AND-FEASIBLE-POINT
+C
+ 30 IF (.NOT.(HITCON)) GO TO 50
+ ASSIGN 40 TO IGO986
+ GO TO 370
+ 40 GO TO 70
+C
+C WHEN (HITCON) ADD-CONSTRAINTS
+C
+ 50 ASSIGN 60 TO IGO983
+ GO TO 640
+ 60 CONTINUE
+C
+C ELSE PERFORM-MULTIPLIER-TEST-AND-DROP-A-CONSTRAINT
+C
+ 70 GO TO 20
+C
+ 80 ASSIGN 90 TO IGO980
+ GO TO 1000
+C
+C COMPUTE-FINAL-SOLUTION
+C
+ 90 RETURN
+ 100 CONTINUE
+C
+C TO PROCESS-OPTION-VECTOR
+ FAC = 1.E-4
+C
+C THE NOMINAL TOLERANCE USED IN THE CODE,
+ TAU = SQRT(SRELPR)
+C
+C THE NOMINAL BLOW-UP FACTOR USED IN THE CODE.
+ BLOWUP = TAU
+C
+C THE NOMINAL COLUMN SCALING USED IN THE CODE IS
+C THE IDENTITY SCALING.
+ D(1) = ONE
+ if (kind(D) == real_single) then
+ CALL SCOPY(N, D, 0, D, 1)
+ else if (kind(D) == real_double) then
+ CALL DCOPY(N, D, 0, D, 1)
+ endif
+C
+C DEFINE BOUND FOR NUMBER OF OPTIONS TO CHANGE.
+ NOPT = 1000
+C
+C DEFINE BOUND FOR POSITIVE VALUE OF LINK.
+ NLINK = 100000
+ NTIMES = 0
+ LAST = 1
+ LINK = PRGOPT(1)
+ IF (.NOT.(LINK.LE.0 .OR. LINK.GT.NLINK)) GO TO 110
+ NERR = 3
+ IOPT = 1
+ CALL XERROR( 'WNNLS( ) THE OPTION VECTOR IS UNDEFINED', 39, NERR,
+ 1 IOPT)
+ MODE = 2
+ RETURN
+ 110 IF (.NOT.(LINK.GT.1)) GO TO 160
+ NTIMES = NTIMES + 1
+ IF (.NOT.(NTIMES.GT.NOPT)) GO TO 120
+ NERR = 3
+ IOPT = 1
+ CALL XERROR( 'WNNLS( ). THE LINKS IN THE OPTION VECTOR ARE CYCLING
+ 1.', 53, NERR, IOPT)
+ MODE = 2
+ RETURN
+ 120 KEY = PRGOPT(LAST+1)
+ IF (.NOT.(KEY.EQ.6 .AND. PRGOPT(LAST+2).NE.ZERO)) GO TO 140
+
+ if (kind(W) == real_single) then
+ do J=1,N
+ T = SNRM2(M,W(1,J),1)
+ IF (T.NE.ZERO) T = ONE/T
+ D(J) = T
+ enddo
+ else if (kind(W) == real_double) then
+ do J=1,N
+ T = DNRM2(M,W(1,J),1)
+ IF (T.NE.ZERO) T = ONE/T
+ D(J) = T
+ enddo
+ endif
+
+ 140 IF (KEY.EQ.7) then
+ if (kind(PRGOPT) == real_single) then
+ CALL SCOPY(N, PRGOPT(LAST+2), 1, D, 1)
+ else if (kind(PRGOPT) == real_double) then
+ CALL DCOPY(N, PRGOPT(LAST+2), 1, D, 1)
+ endif
+ endif
+ IF (KEY.EQ.8) TAU = AMAX1(SRELPR,PRGOPT(LAST+2))
+ IF (KEY.EQ.9) BLOWUP = AMAX1(SRELPR,PRGOPT(LAST+2))
+ NEXT = PRGOPT(LINK)
+ IF (.NOT.(NEXT.LE.0 .OR. NEXT.GT.NLINK)) GO TO 150
+ NERR = 3
+ IOPT = 1
+ CALL XERROR( 'WNNLS( ) THE OPTION VECTOR IS UNDEFINED', 39, NERR,
+ 1 IOPT)
+ MODE = 2
+ RETURN
+ 150 LAST = LINK
+ LINK = NEXT
+ GO TO 110
+
+ 160 if (kind(W) == real_single) then
+ do J=1,N
+ CALL SSCAL(M, D(J), W(1,J), 1)
+ enddo
+ else if (kind(W) == real_double) then
+ do J=1,N
+ CALL DSCAL(M, D(J), W(1,J), 1)
+ enddo
+ endif
+
+ GO TO 1260
+ 180 CONTINUE
+C
+C TO INITIALIZE-VARIABLES
+C
+C SRELPR IS THE PRECISION FOR THE PARTICULAR MACHINE
+C BEING USED. THIS LOGIC AVOIDS RECOMPUTING IT EVERY ENTRY.
+ IF (.NOT.(SRELPR.EQ.ZERO)) GO TO 210
+c*** changed back by BROSS
+c*** changed by RF Boisvert, 19-Feb-92 (fails on HP 9000 Series 300)
+cross srelpr = r1mach(4)
+ SRELPR = ONE
+ 190 IF (ONE+SRELPR.EQ.ONE) GO TO 200
+ SRELPR = SRELPR/TWO
+ GO TO 190
+ 200 SRELPR = SRELPR*TWO
+cross
+ 210 M = MA + MME
+ ME = MME
+ MEP1 = ME + 1
+ ASSIGN 220 TO IGO977
+ GO TO 100
+C
+C PROCESS-OPTION-VECTOR
+ 220 DONE = .FALSE.
+ ITER = 0
+ ITMAX = 3*(N-L)
+ MODE = 0
+ LP1 = L + 1
+ NSOLN = L
+ NSP1 = NSOLN + 1
+ NP1 = N + 1
+ NM1 = N - 1
+ L1 = MIN0(M,L)
+C
+C COMPUTE SCALE FACTOR TO APPLY TO EQUAL. CONSTRAINT EQUAS.
+
+ if (kind(W) == real_single) then
+ do J=1,N
+ WD(J) = SASUM(M,W(1,J),1)
+ enddo
+ IMAX = ISAMAX(N,WD,1)
+ EANORM = WD(IMAX)
+ BNORM = SASUM(M,W(1,NP1),1)
+ else if (kind(W) == real_double) then
+ do J=1,N
+ WD(J) = DASUM(M,W(1,J),1)
+ enddo
+ IMAX = IDAMAX(N,WD,1)
+ EANORM = WD(IMAX)
+ BNORM = DASUM(M,W(1,NP1),1)
+ endif
+
+ ALAMDA = EANORM/(SRELPR*FAC)
+C
+C DEFINE SCALING DIAG MATRIX FOR MOD GIVENS USAGE AND
+C CLASSIFY EQUATION TYPES.
+ ALSQ = ALAMDA**2
+ DO 260 I=1,M
+C
+C WHEN EQU I IS HEAVILY WEIGHTED ITYPE(I)=0, ELSE ITYPE(I)=1.
+ IF (.NOT.(I.LE.ME)) GO TO 240
+ T = ALSQ
+ ITEMP = 0
+ GO TO 250
+ 240 T = ONE
+ ITEMP = 1
+ 250 SCALE(I) = T
+ ITYPE(I) = ITEMP
+ 260 CONTINUE
+C
+C SET THE SOLN VECTOR X(*) TO ZERO AND THE COL INTERCHANGE
+C MATRIX TO THE IDENTITY.
+ X(1) = ZERO
+ if (kind(X) == real_single) then
+ CALL SCOPY(N, X, 0, X, 1)
+ else if (kind(X) == real_double) then
+ CALL DCOPY(N, X, 0, X, 1)
+ endif
+ DO 270 I=1,N
+ IPIVOT(I) = I
+ 270 CONTINUE
+ GO TO 1230
+ 280 CONTINUE
+C
+C TO INITIALLY-TRIANGULARIZE
+C
+C SET FIRST L COMPS. OF DUAL VECTOR TO ZERO BECAUSE
+C THESE CORRESPOND TO THE UNCONSTRAINED VARIABLES.
+ IF (.NOT.(L.GT.0)) GO TO 290
+ WD(1) = ZERO
+ if (kind(WD) == real_single) then
+ CALL SCOPY(L, WD, 0, WD, 1)
+ else if (kind(WD) == real_double) then
+ CALL DCOPY(L, WD, 0, WD, 1)
+ endif
+C
+C THE ARRAYS IDOPE(*) AND DOPE(*) ARE USED TO PASS
+C INFORMATION TO WNLIT(). THIS WAS DONE TO AVOID
+C A LONG CALLING SEQUENCE OR THE USE OF COMMON.
+ 290 IDOPE(1) = ME
+ IDOPE(2) = MEP1
+ IDOPE(3) = 0
+ IDOPE(4) = 1
+ IDOPE(5) = NSOLN
+ IDOPE(6) = 0
+ IDOPE(7) = 1
+ IDOPE(8) = L1
+C
+ DOPE(1) = ALSQ
+ DOPE(2) = EANORM
+ DOPE(3) = FAC
+ DOPE(4) = TAU
+ CALL WNLIT(W, MDW, M, N, L, IPIVOT, ITYPE, H, SCALE, RNORM,
+ 1 IDOPE, DOPE, DONE)
+ ME = IDOPE(1)
+ MEP1 = IDOPE(2)
+ KRANK = IDOPE(3)
+ KRP1 = IDOPE(4)
+ NSOLN = IDOPE(5)
+ NIV = IDOPE(6)
+ NIV1 = IDOPE(7)
+ L1 = IDOPE(8)
+ GO TO 1240
+ 300 CONTINUE
+C
+C TO COMPUTE-SEARCH-DIRECTION-AND-FEASIBLE-POINT
+C
+C SOLVE THE TRIANGULAR SYSTEM OF CURRENTLY NON-ACTIVE
+C VARIABLES AND STORE THE SOLUTION IN Z(*).
+C
+C SOLVE-SYSTEM
+ ASSIGN 310 TO IGO958
+ GO TO 1110
+C
+C INCREMENT ITERATION COUNTER AND CHECK AGAINST MAX. NUMBER
+C OF ITERATIONS.
+ 310 ITER = ITER + 1
+ IF (.NOT.(ITER.GT.ITMAX)) GO TO 320
+ MODE = 1
+ DONE = .TRUE.
+C
+C CHECK TO SEE IF ANY CONSTRAINTS HAVE BECOME ACTIVE.
+C IF SO, CALCULATE AN INTERPOLATION FACTOR SO THAT ALL
+C ACTIVE CONSTRAINTS ARE REMOVED FROM THE BASIS.
+ 320 ALPHA = TWO
+ HITCON = .FALSE.
+ IF (.NOT.(L.LT.NSOLN)) GO TO 360
+ DO 350 J=LP1,NSOLN
+ ZZ = Z(J)
+ IF (.NOT.(ZZ.LE.ZERO)) GO TO 340
+ T = X(J)/(X(J)-ZZ)
+ IF (.NOT.(T.LT.ALPHA)) GO TO 330
+ ALPHA = T
+ JCON = J
+ 330 HITCON = .TRUE.
+ 340 CONTINUE
+ 350 CONTINUE
+ 360 GO TO 1220
+ 370 CONTINUE
+C
+C TO ADD-CONSTRAINTS
+C
+C USE COMPUTED ALPHA TO INTERPOLATE BETWEEN LAST
+C FEASIBLE SOLUTION X(*) AND CURRENT UNCONSTRAINED
+C (AND INFEASIBLE) SOLUTION Z(*).
+ IF (.NOT.(LP1.LE.NSOLN)) GO TO 390
+ DO 380 J=LP1,NSOLN
+ X(J) = X(J) + ALPHA*(Z(J)-X(J))
+ 380 CONTINUE
+ 390 FEASBL = .FALSE.
+ GO TO 410
+ 400 IF (FEASBL) GO TO 610
+C
+C REMOVE COL JCON AND SHIFT COLS JCON+1 THROUGH N TO THE
+C LEFT. SWAP COL JCON INTO THE N-TH POSITION. THIS ACHIEVES
+C UPPER HESSENBERG FORM FOR THE NONACTIVE CONSTRAINTS AND
+C LEAVES AN UPPER HESSENBERG MATRIX TO RETRIANGULARIZE.
+ 410 DO 420 I=1,M
+ T = W(I,JCON)
+! if (kind(W) == real_single) then
+! CALL SCOPY(N-JCON, W(I,JCON+1), MDW, W(I,JCON), MDW)
+! else if (kind(W) == real_double) then
+! CALL DCOPY(N-JCON, W(I,JCON+1), MDW, W(I,JCON), MDW)
+! endif
+ do j=jcon,n-1
+ w(i,j)=w(i,j+1)
+ end do
+ W(I,N) = T
+ 420 CONTINUE
+C
+C UPDATE PERMUTED INDEX VECTOR TO REFLECT THIS SHIFT AND SWAP.
+ ITEMP = IPIVOT(JCON)
+ IF (.NOT.(JCON.LT.N)) GO TO 440
+ DO 430 I=JCON,NM1
+ IPIVOT(I) = IPIVOT(I+1)
+ 430 CONTINUE
+ 440 IPIVOT(N) = ITEMP
+C
+C SIMILARLY REPERMUTE X(*) VECTOR.
+! if (kind(X) == real_single) then
+! CALL SCOPY(N-JCON, X(JCON+1), 1, X(JCON), 1)
+! else if (kind(X) == real_double) then
+! CALL DCOPY(N-JCON, X(JCON+1), 1, X(JCON), 1)
+! endif
+ do j=jcon,n-1
+ X(j)=X(J+1)
+ end do
+
+ X(N) = ZERO
+ NSP1 = NSOLN
+ NSOLN = NSOLN - 1
+ NIV1 = NIV
+ NIV = NIV - 1
+C
+C RETRIANGULARIZE UPPER HESSENBERG MATRIX AFTER ADDING CONSTRAINTS.
+ J = JCON
+ I = KRANK + JCON - L
+ 450 IF (.NOT.(J.LE.NSOLN)) GO TO 570
+ IF (.NOT.(ITYPE(I).EQ.0 .AND. ITYPE(I+1).EQ.0)) GO TO 470
+ ASSIGN 460 TO IGO938
+ GO TO 620
+C
+C (ITYPE(I).EQ.0 .AND. ITYPE(I+1).EQ.0) ZERO-IP1-TO-I-IN-COL-J
+ 460 GO TO 560
+ 470 IF (.NOT.(ITYPE(I).EQ.1 .AND. ITYPE(I+1).EQ.1)) GO TO 490
+ ASSIGN 480 TO IGO938
+ GO TO 620
+C
+C (ITYPE(I).EQ.1 .AND. ITYPE(I+1).EQ.1) ZERO-IP1-TO-I-IN-COL-J
+ 480 GO TO 560
+ 490 IF (.NOT.(ITYPE(I).EQ.1 .AND. ITYPE(I+1).EQ.0)) GO TO 510
+ if (kind(W) == real_single) then
+ CALL SSWAP(NP1, W(I,1), MDW, W(I+1,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(NP1, W(I,1), MDW, W(I+1,1), MDW)
+ endif
+ if (kind(SCALE) == real_single) then
+ CALL SSWAP(1, SCALE(I), 1, SCALE(I+1), 1)
+ else if (kind(SCALE) == real_double) then
+ CALL DSWAP(1, SCALE(I), 1, SCALE(I+1), 1)
+ endif
+ ITEMP = ITYPE(I+1)
+ ITYPE(I+1) = ITYPE(I)
+ ITYPE(I) = ITEMP
+C
+C SWAPPED ROW WAS FORMERLY A PIVOT ELT., SO IT WILL
+C BE LARGE ENOUGH TO PERFORM ELIM.
+ ASSIGN 500 TO IGO938
+ GO TO 620
+C
+C ZERO-IP1-TO-I-IN-COL-J
+ 500 GO TO 560
+ 510 IF (.NOT.(ITYPE(I).EQ.0 .AND. ITYPE(I+1).EQ.1)) GO TO 550
+ T = SCALE(I)*W(I,J)**2/ALSQ
+ IF (.NOT.(T.GT.TAU**2*EANORM**2)) GO TO 530
+ ASSIGN 520 TO IGO938
+ GO TO 620
+ 520 GO TO 540
+ 530 if (kind(W) == real_single) then
+ CALL SSWAP(NP1, W(I,1), MDW, W(I+1,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(NP1, W(I,1), MDW, W(I+1,1), MDW)
+ endif
+ if (kind(SCALE) == real_single) then
+ CALL SSWAP(1, SCALE(I), 1, SCALE(I+1), 1)
+ else if (kind(SCALE) == real_double) then
+ CALL DSWAP(1, SCALE(I), 1, SCALE(I+1), 1)
+ endif
+
+ ITEMP = ITYPE(I+1)
+ ITYPE(I+1) = ITYPE(I)
+ ITYPE(I) = ITEMP
+ W(I+1,J) = ZERO
+ 540 CONTINUE
+ 550 CONTINUE
+ 560 I = I + 1
+ J = J + 1
+ GO TO 450
+C
+C SEE IF THE REMAINING COEFFS IN THE SOLN SET ARE FEASIBLE. THEY
+C SHOULD BE BECAUSE OF THE WAY ALPHA WAS DETERMINED. IF ANY ARE
+C INFEASIBLE IT IS DUE TO ROUNDOFF ERROR. ANY THAT ARE NON-
+C POSITIVE WILL BE SET TO ZERO AND REMOVED FROM THE SOLN SET.
+ 570 IF (.NOT.(LP1.LE.NSOLN)) GO TO 590
+ DO 580 JCON=LP1,NSOLN
+ IF (X(JCON).LE.ZERO) GO TO 600
+ 580 CONTINUE
+ 590 FEASBL = .TRUE.
+ 600 CONTINUE
+ GO TO 400
+ 610 GO TO 1200
+ 620 CONTINUE
+C
+C TO ZERO-IP1-TO-I-IN-COL-J
+ IF (.NOT.(W(I+1,J).NE.ZERO)) GO TO 630
+ CALL SROTMG(SCALE(I), SCALE(I+1), W(I,J), W(I+1,J), SPARAM)
+ W(I+1,J) = ZERO
+ CALL SROTM(NP1-J, W(I,J+1), MDW, W(I+1,J+1), MDW, SPARAM)
+ 630 GO TO 1290
+ 640 CONTINUE
+C
+C TO PERFORM-MULTIPLIER-TEST-AND-DROP-A-CONSTRAINT
+ if (kind(Z) == real_single) then
+ CALL SCOPY(NSOLN, Z, 1, X, 1)
+ else if (kind(Z) == real_double) then
+ CALL DCOPY(NSOLN, Z, 1, X, 1)
+ endif
+
+ IF (.NOT.(NSOLN.LT.N)) GO TO 650
+ X(NSP1) = ZERO
+ if (kind(X) == real_single) then
+ CALL SCOPY(N-NSOLN, X(NSP1), 0, X(NSP1), 1)
+ else if (kind(X) == real_double) then
+ CALL DCOPY(N-NSOLN, X(NSP1), 0, X(NSP1), 1)
+ endif
+
+ 650 I = NIV1
+ 660 IF (.NOT.(I.LE.ME)) GO TO 690
+C
+C RECLASSIFY LEAST SQUARES EQATIONS AS EQUALITIES AS
+C NECESSARY.
+ IF (.NOT.(ITYPE(I).EQ.0)) GO TO 670
+ I = I + 1
+ GO TO 680
+ 670 if (kind(W) == real_single) then
+ CALL SSWAP(NP1, W(I,1), MDW, W(ME,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(NP1, W(I,1), MDW, W(ME,1), MDW)
+ endif
+ if (kind(SCALE) == real_single) then
+ CALL SSWAP(1, SCALE(I), 1, SCALE(ME), 1)
+ else if (kind(SCALE) == real_double) then
+ CALL DSWAP(1, SCALE(I), 1, SCALE(ME), 1)
+ endif
+
+ ITEMP = ITYPE(I)
+ ITYPE(I) = ITYPE(ME)
+ ITYPE(ME) = ITEMP
+ MEP1 = ME
+ ME = ME - 1
+ 680 GO TO 660
+C
+C FORM INNER PRODUCT VECTOR WD(*) OF DUAL COEFFS.
+ 690 IF (.NOT.(NSP1.LE.N)) GO TO 730
+ DO 720 J=NSP1,N
+ SM = ZERO
+ IF (.NOT.(NSOLN.LT.M)) GO TO 710
+ DO 700 I=NSP1,M
+ SM = SM + SCALE(I)*W(I,J)*W(I,NP1)
+ 700 CONTINUE
+ 710 WD(J) = SM
+ 720 CONTINUE
+ 730 GO TO 750
+ 740 IF (POS .OR. DONE) GO TO 970
+C
+C FIND J SUCH THAT WD(J)=WMAX IS MAXIMUM. THIS DETERMINES
+C THAT THE INCOMING COL J WILL REDUCE THE RESIDUAL VECTOR
+C AND BE POSITIVE.
+ 750 WMAX = ZERO
+ IWMAX = NSP1
+ IF (.NOT.(NSP1.LE.N)) GO TO 780
+ DO 770 J=NSP1,N
+ IF (.NOT.(WD(J).GT.WMAX)) GO TO 760
+ WMAX = WD(J)
+ IWMAX = J
+ 760 CONTINUE
+ 770 CONTINUE
+ 780 IF (.NOT.(WMAX.LE.ZERO)) GO TO 790
+ DONE = .TRUE.
+ GO TO 960
+C
+C SET DUAL COEFF TO ZERO FOR INCOMING COL.
+ 790 WD(IWMAX) = ZERO
+C
+C WMAX .GT. ZERO, SO OKAY TO MOVE COL IWMAX TO SOLN SET.
+C PERFORM TRANSFORMATION TO RETRIANGULARIZE, AND TEST
+C FOR NEAR LINEAR DEPENDENCE.
+C SWAP COL IWMAX INTO NSOLN-TH POSITION TO MAINTAIN UPPER
+C HESSENBERG FORM OF ADJACENT COLS, AND ADD NEW COL TO
+C TRIANGULAR DECOMPOSITION.
+ NSOLN = NSP1
+ NSP1 = NSOLN + 1
+ NIV = NIV1
+ NIV1 = NIV + 1
+ IF (.NOT.(NSOLN.NE.IWMAX)) GO TO 800
+ if (kind(W) == real_single) then
+ CALL SSWAP(M, W(1,NSOLN), 1, W(1,IWMAX), 1)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(M, W(1,NSOLN), 1, W(1,IWMAX), 1)
+ endif
+ WD(IWMAX) = WD(NSOLN)
+ WD(NSOLN) = ZERO
+ ITEMP = IPIVOT(NSOLN)
+ IPIVOT(NSOLN) = IPIVOT(IWMAX)
+ IPIVOT(IWMAX) = ITEMP
+C
+C REDUCE COL NSOLN SO THAT THE MATRIX OF NONACTIVE
+C CONSTRAINTS VARIABLES IS TRIANGULAR.
+ 800 J = M
+ 810 IF (.NOT.(J.GT.NIV)) GO TO 870
+ JM1 = J - 1
+ JP = JM1
+C
+C WHEN OPERATING NEAR THE ME LINE, TEST TO SEE IF THE PIVOT ELT.
+C IS NEAR ZERO. IF SO, USE THE LARGEST ELT. ABOVE IT AS THE PIVOT.
+C THIS IS TO MAINTAIN THE SHARP INTERFACE BETWEEN WEIGHTED AND
+C NON-WEIGHTED ROWS IN ALL CASES.
+ IF (.NOT.(J.EQ.MEP1)) GO TO 850
+ IMAX = ME
+ AMAX = SCALE(ME)*W(ME,NSOLN)**2
+ 820 IF (.NOT.(JP.GE.NIV)) GO TO 840
+ T = SCALE(JP)*W(JP,NSOLN)**2
+ IF (.NOT.(T.GT.AMAX)) GO TO 830
+ IMAX = JP
+ AMAX = T
+ 830 JP = JP - 1
+ GO TO 820
+ 840 JP = IMAX
+ 850 IF (.NOT.(W(J,NSOLN).NE.ZERO)) GO TO 860
+ CALL SROTMG(SCALE(JP), SCALE(J), W(JP,NSOLN), W(J,NSOLN), SPARAM)
+ W(J,NSOLN) = ZERO
+ CALL SROTM(NP1-NSOLN, W(JP,NSP1), MDW, W(J,NSP1), MDW, SPARAM)
+ 860 J = JM1
+ GO TO 810
+C
+C SOLVE FOR Z(NSOLN)=PROPOSED NEW VALUE FOR X(NSOLN).
+C TEST IF THIS IS NONPOSITIVE OR TOO LARGE.
+C IF THIS WAS TRUE OR IF THE PIVOT TERM WAS ZERO REJECT
+C THE COL AS DEPENDENT.
+ 870 IF (.NOT.(W(NIV,NSOLN).NE.ZERO)) GO TO 890
+ ISOL = NIV
+ ASSIGN 880 TO IGO897
+ GO TO 980
+C
+C TEST-PROPOSED-NEW-COMPONENT
+ 880 GO TO 940
+ 890 IF (.NOT.(NIV.LE.ME .AND. W(MEP1,NSOLN).NE.ZERO)) GO TO 920
+C
+C TRY TO ADD ROW MEP1 AS AN ADDITIONAL EQUALITY CONSTRAINT.
+C CHECK SIZE OF PROPOSED NEW SOLN COMPONENT.
+C REJECT IT IF IT IS TOO LARGE.
+ ISOL = MEP1
+ ASSIGN 900 TO IGO897
+ GO TO 980
+C
+C TEST-PROPOSED-NEW-COMPONENT
+ 900 IF (.NOT.(POS)) GO TO 910
+C
+C SWAP ROWS MEP1 AND NIV, AND SCALE FACTORS FOR THESE ROWS.
+
+ if (kind(W) == real_single) then
+ CALL SSWAP(NP1, W(MEP1,1), MDW, W(NIV,1), MDW)
+ else if (kind(W) == real_double) then
+ CALL DSWAP(NP1, W(MEP1,1), MDW, W(NIV,1), MDW)
+ endif
+ if (kind(SCALE) == real_single) then
+ CALL SSWAP(1, SCALE(MEP1), 1, SCALE(NIV), 1)
+ else if (kind(SCALE) == real_double) then
+ CALL DSWAP(1, SCALE(MEP1), 1, SCALE(NIV), 1)
+ endif
+
+ ITEMP = ITYPE(MEP1)
+ ITYPE(MEP1) = ITYPE(NIV)
+ ITYPE(NIV) = ITEMP
+ ME = MEP1
+ MEP1 = ME + 1
+ 910 GO TO 930
+ 920 POS = .FALSE.
+ 930 CONTINUE
+ 940 IF (POS) GO TO 950
+ NSP1 = NSOLN
+ NSOLN = NSOLN - 1
+ NIV1 = NIV
+ NIV = NIV - 1
+ 950 CONTINUE
+ 960 GO TO 740
+ 970 GO TO 1250
+ 980 CONTINUE
+C
+C TO TEST-PROPOSED-NEW-COMPONENT
+ Z2 = W(ISOL,NP1)/W(ISOL,NSOLN)
+ Z(NSOLN) = Z2
+ POS = Z2.GT.ZERO
+ IF (.NOT.(Z2*EANORM.GE.BNORM .AND. POS)) GO TO 990
+ POS = .NOT.(BLOWUP*Z2*EANORM.GE.BNORM)
+ 990 GO TO 1280
+ 1000 CONTINUE
+C TO COMPUTE-FINAL-SOLUTION
+C
+C SOLVE SYSTEM, STORE RESULTS IN X(*).
+C
+ ASSIGN 1010 TO IGO958
+ GO TO 1110
+C SOLVE-SYSTEM
+ 1010 if (kind(Z) == real_single) then
+ CALL SCOPY(NSOLN, Z, 1, X, 1)
+ else if (kind(Z) == real_double) then
+ CALL DCOPY(NSOLN, Z, 1, X, 1)
+ endif
+C
+C APPLY HOUSEHOLDER TRANSFORMATIONS TO X(*) IF KRANK.LT.L
+ IF (.NOT.(0.LT.KRANK .AND. KRANK.LT.L)) GO TO 1030
+ DO 1020 I=1,KRANK
+ CALL H12(2, I, KRP1, L, W(I,1), MDW, H(I), X, 1, 1, 1)
+ 1020 CONTINUE
+C
+C FILL IN TRAILING ZEROES FOR CONSTRAINED VARIABLES NOT IN SOLN.
+ 1030 IF (.NOT.(NSOLN.LT.N)) GO TO 1040
+ X(NSP1) = ZERO
+ if (kind(X) == real_single) then
+ CALL SCOPY(N-NSOLN, X(NSP1), 0, X(NSP1), 1)
+ else if (kind(X) == real_double) then
+ CALL DCOPY(N-NSOLN, X(NSP1), 0, X(NSP1), 1)
+ endif
+C
+C REPERMUTE SOLN VECTOR TO NATURAL ORDER.
+ 1040 DO 1070 I=1,N
+ J = I
+ 1050 IF (IPIVOT(J).EQ.I) GO TO 1060
+ J = J + 1
+ GO TO 1050
+ 1060 IPIVOT(J) = IPIVOT(I)
+ IPIVOT(I) = J
+ if (kind(X) == real_single) then
+ CALL SSWAP(1, X(J), 1, X(I), 1)
+ else if (kind(X) == real_double) then
+ CALL DSWAP(1, X(J), 1, X(I), 1)
+ endif
+ 1070 CONTINUE
+C
+C RESCALE THE SOLN USING THE COL SCALING.
+ DO 1080 J=1,N
+ X(J) = X(J)*D(J)
+ 1080 CONTINUE
+ IF (.NOT.(NSOLN.LT.M)) GO TO 1100
+ DO 1090 I=NSP1,M
+ T = W(I,NP1)
+ IF (I.LE.ME) T = T/ALAMDA
+ T = (SCALE(I)*T)*T
+ RNORM = RNORM + T
+ 1090 CONTINUE
+ 1100 RNORM = SQRT(RNORM)
+ GO TO 1210
+C
+C TO SOLVE-SYSTEM
+C
+ 1110 CONTINUE
+ IF (.NOT.(DONE)) GO TO 1120
+ ISOL = 1
+ GO TO 1130
+ 1120 ISOL = LP1
+ 1130 IF (.NOT.(NSOLN.GE.ISOL)) GO TO 1190
+C
+C COPY RT. HAND SIDE INTO TEMP VECTOR TO USE OVERWRITING METHOD.
+ if (kind(W) == real_single) then
+ CALL SCOPY(NIV, W(1,NP1), 1, TEMP, 1)
+ else if (kind(W) == real_double) then
+ CALL DCOPY(NIV, W(1,NP1), 1, TEMP, 1)
+ endif
+
+ DO 1180 JJ=ISOL,NSOLN
+ J = NSOLN - JJ + ISOL
+ IF (.NOT.(J.GT.KRANK)) GO TO 1140
+ I = NIV - JJ + ISOL
+ GO TO 1150
+ 1140 I = J
+ 1150 IF (.NOT.(J.GT.KRANK .AND. J.LE.L)) GO TO 1160
+ Z(J) = ZERO
+ GO TO 1170
+ 1160 Z(J) = TEMP(I)/W(I,J)
+
+ if (kind(W) == real_single .and. kind(TEMP) == real_single)
+ & then
+ CALL SAXPY(I-1, -Z(J), W(1,J), 1, TEMP, 1)
+ else if (kind(W) == real_double .and. kind(TEMP) == real_double)
+ & then
+ CALL DAXPY(I-1, -Z(J), W(1,J), 1, TEMP, 1)
+ endif
+
+ 1170 CONTINUE
+ 1180 CONTINUE
+ 1190 GO TO 1270
+ 1200 GO TO IGO986, (40)
+ 1210 GO TO IGO980, (90)
+ 1220 GO TO IGO991, (30)
+ 1230 GO TO IGO998, (10)
+ 1240 GO TO IGO995, (20)
+ 1250 GO TO IGO983, (60)
+ 1260 GO TO IGO977, (220)
+ 1270 GO TO IGO958, (310, 1010)
+ 1280 GO TO IGO897, (880, 900)
+ 1290 GO TO IGO938, (460, 480, 500, 520)
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNNLS.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNNLS.f
new file mode 100644
index 000000000..27b7f0a0d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/WNNLS.f
@@ -0,0 +1,356 @@
+ SUBROUTINE WNNLS(W,MDW,ME,MA,N,L,PRGOPT,X,RNORM,MODE,IWORK,WORK)
+C***BEGIN PROLOGUE WNNLS
+C***DATE WRITTEN 790701 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. K1A2A
+C***KEYWORDS CONSTRAINED LEAST SQUARES,CURVE FITTING,DATA FITTING,
+C EQUALITY CONSTRAINTS,INEQUALITY CONSTRAINTS,
+C NONNEGATIVITY CONSTRAINTS,QUADRATIC PROGRAMMING
+C***AUTHOR HANSON, R. J., (SNLA)
+C HASKELL, K. H., (SNLA)
+C***PURPOSE Solve a linearly constrained least squares problem with
+C equality constraints and nonnegativity constraints on
+C selected variables.
+C***DESCRIPTION
+C
+C DIMENSION W(MDW,N+1),PRGOPT(*),X(N),IWORK(M+N),WORK(M+5*N)
+C
+C Written by Karen H. Haskell, Sandia Laboratories,
+C and R.J. Hanson, Sandia Laboratories.
+C
+C Abstract
+C
+C This subprogram solves a linearly constrained least squares
+C problem. Suppose there are given matrices E and A of
+C respective dimensions ME by N and MA by N, and vectors F
+C and B of respective lengths ME and MA. This subroutine
+C solves the problem
+C
+C EX = F, (equations to be exactly satisfied)
+C
+C AX = B, (equations to be approximately satisfied,
+C in the least squares sense)
+C
+C subject to components L+1,...,N nonnegative
+C
+C Any values ME.GE.0, MA.GE.0 and 0.LE. L .LE.N are permitted.
+C
+C The problem is reposed as problem WNNLS
+C
+C (WT*E)X = (WT*F)
+C ( A) ( B), (least squares)
+C subject to components L+1,...,N nonnegative.
+C
+C The subprogram chooses the heavy weight (or penalty parameter) WT.
+C
+C The parameters for WNNLS are
+C
+C INPUT..
+C
+C W(*,*),MDW, The array W(*,*) is double subscripted with first
+C ME,MA,N,L dimensioning parameter equal to MDW. For this
+C discussion let us call M = ME + MA. Then MDW
+C must satisfy MDW.GE.M. The condition MDW.LT.M
+C is an error.
+C
+C The array W(*,*) contains the matrices and vectors
+C
+C (E F)
+C (A B)
+C
+C in rows and columns 1,...,M and 1,...,N+1
+C respectively. Columns 1,...,L correspond to
+C unconstrained variables X(1),...,X(L). The
+C remaining variables are constrained to be
+C nonnegative. The condition L.LT.0 or L.GT.N is
+C an error.
+C
+C PRGOPT(*) This real-valued array is the option vector.
+C If the user is satisfied with the nominal
+C subprogram features set
+C
+C PRGOPT(1)=1 (or PRGOPT(1)=1.0)
+C
+C Otherwise PRGOPT(*) is a linked list consisting of
+C groups of data of the following form
+C
+C LINK
+C KEY
+C DATA SET
+C
+C The parameters LINK and KEY are each one word.
+C The DATA SET can be comprised of several words.
+C The number of items depends on the value of KEY.
+C The value of LINK points to the first
+C entry of the next group of data within
+C PRGOPT(*). The exception is when there are
+C no more options to change. In that
+C case LINK=1 and the values KEY and DATA SET
+C are not referenced. The general layout of
+C PRGOPT(*) is as follows.
+C
+C ...PRGOPT(1)=LINK1 (link to first entry of next group)
+C . PRGOPT(2)=KEY1 (key to the option change)
+C . PRGOPT(3)=DATA VALUE (data value for this change)
+C . .
+C . .
+C . .
+C ...PRGOPT(LINK1)=LINK2 (link to the first entry of
+C . next group)
+C . PRGOPT(LINK1+1)=KEY2 (key to the option change)
+C . PRGOPT(LINK1+2)=DATA VALUE
+C ... .
+C . .
+C . .
+C ...PRGOPT(LINK)=1 (no more options to change)
+C
+C Values of LINK that are nonpositive are errors.
+C A value of LINK.GT.NLINK=100000 is also an error.
+C This helps prevent using invalid but positive
+C values of LINK that will probably extend
+C beyond the program limits of PRGOPT(*).
+C Unrecognized values of KEY are ignored. The
+C order of the options is arbitrary and any number
+C of options can be changed with the following
+C restriction. To prevent cycling in the
+C processing of the option array a count of the
+C number of options changed is maintained.
+C Whenever this count exceeds NOPT=1000 an error
+C message is printed and the subprogram returns.
+C
+C OPTIONS..
+C
+C KEY=6
+C Scale the nonzero columns of the
+C entire data matrix
+C (E)
+C (A)
+C to have length one. The DATA SET for
+C this option is a single value. It must
+C be nonzero if unit length column scaling is
+C desired.
+C
+C KEY=7
+C Scale columns of the entire data matrix
+C (E)
+C (A)
+C with a user-provided diagonal matrix.
+C The DATA SET for this option consists
+C of the N diagonal scaling factors, one for
+C each matrix column.
+C
+C KEY=8
+C Change the rank determination tolerance from
+C the nominal value of SQRT(SRELPR). This quantity
+C can be no smaller than SRELPR, The arithmetic-
+C storage precision. The quantity used
+C here is internally restricted to be at
+C least SRELPR. The DATA SET for this option
+C is the new tolerance.
+C
+C KEY=9
+C Change the blow-up parameter from the
+C nominal value of SQRT(SRELPR). The reciprocal of
+C this parameter is used in rejecting solution
+C components as too large when a variable is
+C first brought into the active set. Too large
+C means that the proposed component times the
+C reciprocal of the parameter is not less than
+C the ratio of the norms of the right-side
+C vector and the data matrix.
+C This parameter can be no smaller than SRELPR,
+C the arithmetic-storage precision.
+C
+C For example, suppose we want to provide
+C a diagonal matrix to scale the problem
+C matrix and change the tolerance used for
+C determining linear dependence of dropped col
+C vectors. For these options the dimensions of
+C PRGOPT(*) must be at least N+6. The FORTRAN
+C statements defining these options would
+C be as follows.
+C
+C PRGOPT(1)=N+3 (link to entry N+3 in PRGOPT(*))
+C PRGOPT(2)=7 (user-provided scaling key)
+C
+C CALL SCOPY(N,D,1,PRGOPT(3),1) (copy the N
+C scaling factors from a user array called D(*)
+C into PRGOPT(3)-PRGOPT(N+2))
+C
+C PRGOPT(N+3)=N+6 (link to entry N+6 of PRGOPT(*))
+C PRGOPT(N+4)=8 (linear dependence tolerance key)
+C PRGOPT(N+5)=... (new value of the tolerance)
+C
+C PRGOPT(N+6)=1 (no more options to change)
+C
+C
+C IWORK(1), The amounts of working storage actually allocated
+C IWORK(2) for the working arrays WORK(*) and IWORK(*),
+C respectively. These quantities are compared with
+C the actual amounts of storage needed for WNNLS( ).
+C Insufficient storage allocated for either WORK(*)
+C or IWORK(*) is considered an error. This feature
+C was included in WNNLS( ) because miscalculating
+C the storage formulas for WORK(*) and IWORK(*)
+C might very well lead to subtle and hard-to-find
+C execution errors.
+C
+C The length of WORK(*) must be at least
+C
+C LW = ME+MA+5*N
+C This test will not be made if IWORK(1).LE.0.
+C
+C The length of IWORK(*) must be at least
+C
+C LIW = ME+MA+N
+C This test will not be made if IWORK(2).LE.0.
+C
+C OUTPUT..
+C
+C X(*) An array dimensioned at least N, which will
+C contain the N components of the solution vector
+C on output.
+C
+C RNORM The residual norm of the solution. The value of
+C RNORM contains the residual vector length of the
+C equality constraints and least squares equations.
+C
+C MODE The value of MODE indicates the success or failure
+C of the subprogram.
+C
+C MODE = 0 Subprogram completed successfully.
+C
+C = 1 Max. number of iterations (equal to
+C 3*(N-L)) exceeded. Nearly all problems
+C should complete in fewer than this
+C number of iterations. An approximate
+C solution and its corresponding residual
+C vector length are in X(*) and RNORM.
+C
+C = 2 Usage error occurred. The offending
+C condition is noted with the error
+C processing subprogram, XERROR( ).
+C
+C User-designated
+C Working arrays..
+C
+C WORK(*) A real-valued working array of length at least
+C M + 5*N.
+C
+C IWORK(*) An integer-valued working array of length at least
+C M+N.
+C***REFERENCES K.H. HASKELL AND R.J. HANSON, *AN ALGORITHM FOR
+C LINEAR LEAST SQUARES PROBLEMS WITH EQUALITY AND
+C NONNEGATIVITY CONSTRAINTS*, SAND77-0552, JUNE 1978.
+C K.H. HASKELL AND R.J. HANSON, *SELECTED ALGORITHMS FOR
+C THE LINEARLY CONSTRAINED LEAST SQUARES PROBLEM--
+C A USERS GUIDE*, SAND78-1290, AUGUST 1979.
+C K.H. HASKELL AND R.H. HANSON, *AN ALGORITHM FOR
+C LINEAR LEAST SQUARES PROBLEMS WITH EQUALITY AND
+C NONNEGATIVITY CONSTRAINTS*, MATH. PROG. 21 (1981),
+C PP. 98-118.
+C R.J. HANSON AND K.H. HASKELL, *TWO ALGORITHMS FOR THE
+C LINEARLY CONSTRAINED LEAST SQUARES PROBLEM*, ACM
+C TRANS. ON MATH. SOFTWARE, SEPT. 1982.
+C***ROUTINES CALLED WNLSM,XERROR,XERRWV
+C***END PROLOGUE WNNLS
+C
+C THE EDITING REQUIRED TO CONVERT THIS SUBROUTINE FROM SINGLE TO
+C DOUBLE PRECISION INVOLVES THE FOLLOWING CHARACTER STRING CHANGES.
+C USE AN EDITING COMMAND (CHANGE) /STRING-1/(TO)STRING-2/.
+C (START AT LINE WITH C++ IN COLS. 1-3.)
+C /REAL (12 BLANKS)/DOUBLE PRECISION/,/, DUMMY/,SNGL(DUMMY)/
+C
+C WRITTEN BY KAREN H. HASKELL, SANDIA LABORATORIES,
+C AND R.J. HANSON, SANDIA LABORATORIES.
+C REVISED FEB.25, 1982.
+C
+C SUBROUTINES CALLED BY WNNLS( )
+C
+C++
+C WNLSM COMPANION SUBROUTINE TO WNNLS( ), WHERE
+C MOST OF THE COMPUTATION TAKES PLACE.
+C
+C XERROR,XERRWV FROM SLATEC ERROR PROCESSING PACKAGE.
+C THIS IS DOCUMENTED IN SANDIA TECH. REPT.,
+C SAND78-1189.
+C
+C REFERENCES
+C
+C 1. SOLVING LEAST SQUARES PROBLEMS, BY C.L. LAWSON
+C AND R.J. HANSON. PRENTICE-HALL, INC. (1974).
+C
+C 2. BASIC LINEAR ALGEBRA SUBPROGRAMS FOR FORTRAN USAGE, BY
+C C.L. LAWSON, R.J. HANSON, D.R. KINCAID, AND F.T. KROGH.
+C TOMS, V. 5, NO. 3, P. 308. ALSO AVAILABLE AS
+C SANDIA TECHNICAL REPORT NO. SAND77-0898.
+C
+C 3. AN ALGORITHM FOR LINEAR LEAST SQUARES WITH EQUALITY
+C AND NONNEGATIVITY CONSTRAINTS, BY K.H. HASKELL AND
+C R.J. HANSON. AVAILABLE AS SANDIA TECHNICAL REPORT NO.
+C SAND77-0552, AND MATH. PROGRAMMING, VOL. 21, (1981), P. 98-118.
+C
+C 4. SLATEC COMMON MATH. LIBRARY ERROR HANDLING
+C PACKAGE. BY R. E. JONES. AVAILABLE AS SANDIA
+C TECHNICAL REPORT SAND78-1189.
+C
+ REAL DUMMY, W(MDW,1), PRGOPT(1), X(1), WORK(1), RNORM
+ INTEGER IWORK(*)
+C
+C
+C***FIRST EXECUTABLE STATEMENT WNNLS
+ MODE = 0
+ iwork(1)=mdw*6
+ iwork(2)=mdw*2
+ IF (MA+ME.LE.0 .OR. N.LE.0) RETURN
+ IF (.NOT.(IWORK(1).GT.0)) GO TO 20
+ LW = ME + MA + 5*N
+ IF (.NOT.(IWORK(1).LT.LW)) GO TO 10
+ NERR = 2
+ IOPT = 1
+ print*,'work array',iwork(1),lw
+ CALL XERRWV( 'WNNLS( ), INSUFFICIENT STORAGE ALLOCATED FOR WORK(*)
+ 1, NEED LW=I1 BELOW', 70, NERR, IOPT, 1, LW, 0, 0, DUMMY, DUMMY)
+ MODE = 2
+ RETURN
+ 10 CONTINUE
+ 20 IF (.NOT.(IWORK(2).GT.0)) GO TO 40
+ LIW = ME + MA + N
+ IF (.NOT.(IWORK(2).LT.LIW)) GO TO 30
+ NERR = 2
+ IOPT = 1
+ CALL XERRWV( 'WNNLS( ), INSUFFICIENT STORAGE ALLOCATED FOR IWORK(*
+ 1), NEED LIW=I1 BELOW', 72, NERR, IOPT, 1, LIW, 0, 0, DUMMY, DUMMY)
+ MODE = 2
+ RETURN
+ 30 CONTINUE
+ 40 IF (.NOT.(MDW.LT.ME+MA)) GO TO 50
+ NERR = 1
+ IOPT = 1
+ CALL XERROR( 'WNNLS( ), THE VALUE MDW.LT.ME+MA IS AN ERROR', 44,
+ 1 NERR, IOPT)
+ MODE = 2
+ RETURN
+ 50 IF (0.LE.L .AND. L.LE.N) GO TO 60
+ NERR = 2
+ IOPT = 1
+ CALL XERROR( 'WNNLS( ), L.LE.0.AND.L.LE.N IS REQUIRED', 39, NERR,
+ 1 IOPT)
+ MODE = 2
+ RETURN
+C
+C THE PURPOSE OF THIS SUBROUTINE IS TO BREAK UP THE ARRAYS
+C WORK(*) AND IWORK(*) INTO SEPARATE WORK ARRAYS
+C REQUIRED BY THE MAIN SUBROUTINE WNLSM( ).
+C
+ 60 L1 = N + 1
+ L2 = L1 + N
+ L3 = L2 + ME + MA
+ L4 = L3 + N
+ L5 = L4 + N
+C
+ CALL WNLSM(W, MDW, ME, MA, N, L, PRGOPT, X, RNORM, MODE, IWORK,
+ 1 IWORK(L1), WORK(1), WORK(L1), WORK(L2), WORK(L3), WORK(L4),
+ 2 WORK(L5))
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERABT.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERABT.f
new file mode 100644
index 000000000..95990ae70
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERABT.f
@@ -0,0 +1,31 @@
+ SUBROUTINE XERABT(MESSG,NMESSG)
+C***BEGIN PROLOGUE XERABT
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. R3C
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Aborts program execution and prints error message.
+C***DESCRIPTION
+C Abstract
+C ***Note*** machine dependent routine
+C XERABT aborts the execution of the program.
+C The error message causing the abort is given in the calling
+C sequence, in case one needs it for printing on a dayfile,
+C for example.
+C
+C Description of Parameters
+C MESSG and NMESSG are as in XERROR, except that NMESSG may
+C be zero, in which case no message is being supplied.
+C
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C Latest revision --- 19 MAR 1980
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED (NONE)
+C***END PROLOGUE XERABT
+ CHARACTER*(*) MESSG
+C***FIRST EXECUTABLE STATEMENT XERABT
+ STOP
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERCTL.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERCTL.f
new file mode 100644
index 000000000..6020d5558
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERCTL.f
@@ -0,0 +1,47 @@
+ SUBROUTINE XERCTL(MESSG1,NMESSG,NERR,LEVEL,KONTRL)
+C***BEGIN PROLOGUE XERCTL
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. R3C
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Allows user control over handling of individual errors.
+C***DESCRIPTION
+C Abstract
+C Allows user control over handling of individual errors.
+C Just after each message is recorded, but before it is
+C processed any further (i.e., before it is printed or
+C a decision to abort is made), a call is made to XERCTL.
+C If the user has provided his own version of XERCTL, he
+C can then override the value of KONTROL used in processing
+C this message by redefining its value.
+C KONTRL may be set to any value from -2 to 2.
+C The meanings for KONTRL are the same as in XSETF, except
+C that the value of KONTRL changes only for this message.
+C If KONTRL is set to a value outside the range from -2 to 2,
+C it will be moved back into that range.
+C
+C Description of Parameters
+C
+C --Input--
+C MESSG1 - the first word (only) of the error message.
+C NMESSG - same as in the call to XERROR or XERRWV.
+C NERR - same as in the call to XERROR or XERRWV.
+C LEVEL - same as in the call to XERROR or XERRWV.
+C KONTRL - the current value of the control flag as set
+C by a call to XSETF.
+C
+C --Output--
+C KONTRL - the new value of KONTRL. If KONTRL is not
+C defined, it will remain at its original value.
+C This changed value of control affects only
+C the current occurrence of the current message.
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED (NONE)
+C***END PROLOGUE XERCTL
+ CHARACTER*20 MESSG1
+C***FIRST EXECUTABLE STATEMENT XERCTL
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERPRT.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERPRT.f
new file mode 100644
index 000000000..6370bc017
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERPRT.f
@@ -0,0 +1,34 @@
+ SUBROUTINE XERPRT(MESSG,NMESSG)
+C***BEGIN PROLOGUE XERPRT
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. Z
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Prints error messages.
+C***DESCRIPTION
+C Abstract
+C Print the Hollerith message in MESSG, of length NMESSG,
+C on each file indicated by XGETUA.
+C Latest revision --- 19 MAR 1980
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED I1MACH,S88FMT,XGETUA
+C***END PROLOGUE XERPRT
+ INTEGER LUN(5)
+ CHARACTER*(*) MESSG
+C OBTAIN UNIT NUMBERS AND WRITE LINE TO EACH UNIT
+C***FIRST EXECUTABLE STATEMENT XERPRT
+ CALL XGETUA(LUN,NUNIT)
+ LENMES = LEN(MESSG)
+ DO 20 KUNIT=1,NUNIT
+ IUNIT = LUN(KUNIT)
+ IF (IUNIT.EQ.0) IUNIT = I1MACH(4)
+ DO 10 ICHAR=1,LENMES,72
+ LAST = MIN0(ICHAR+71 , LENMES)
+ WRITE (IUNIT,'(1X,A)') MESSG(ICHAR:LAST)
+ 10 CONTINUE
+ 20 CONTINUE
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERROR.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERROR.f
new file mode 100644
index 000000000..56b0f9800
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERROR.f
@@ -0,0 +1,51 @@
+ SUBROUTINE XERROR(MESSG,NMESSG,NERR,LEVEL)
+C***BEGIN PROLOGUE XERROR
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. R3C
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Processes an error (diagnostic) message.
+C***DESCRIPTION
+C Abstract
+C XERROR processes a diagnostic message, in a manner
+C determined by the value of LEVEL and the current value
+C of the library error control flag, KONTRL.
+C (See subroutine XSETF for details.)
+C
+C Description of Parameters
+C --Input--
+C MESSG - the Hollerith message to be processed, containing
+C no more than 72 characters.
+C NMESSG- the actual number of characters in MESSG.
+C NERR - the error number associated with this message.
+C NERR must not be zero.
+C LEVEL - error category.
+C =2 means this is an unconditionally fatal error.
+C =1 means this is a recoverable error. (I.e., it is
+C non-fatal if XSETF has been appropriately called.)
+C =0 means this is a warning message only.
+C =-1 means this is a warning message which is to be
+C printed at most once, regardless of how many
+C times this call is executed.
+C
+C Examples
+C CALL XERROR('SMOOTH -- NUM WAS ZERO.',23,1,2)
+C CALL XERROR('INTEG -- LESS THAN FULL ACCURACY ACHIEVED.',
+C 43,2,1)
+C CALL XERROR('ROOTER -- ACTUAL ZERO OF F FOUND BEFORE INTERVAL F
+C 1ULLY COLLAPSED.',65,3,0)
+C CALL XERROR('EXP -- UNDERFLOWS BEING SET TO ZERO.',39,1,-1)
+C
+C Latest revision --- 19 MAR 1980
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED XERRWV
+C***END PROLOGUE XERROR
+ CHARACTER*(*) MESSG
+C***FIRST EXECUTABLE STATEMENT XERROR
+ CALL XERRWV(MESSG,NMESSG,NERR,LEVEL,0,0,0,0,0.,0.)
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERRWV.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERRWV.f
new file mode 100644
index 000000000..7dfa41267
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERRWV.f
@@ -0,0 +1,153 @@
+ SUBROUTINE XERRWV(MESSG,NMESSG,NERR,LEVEL,NI,I1,I2,NR,R1,R2)
+C***BEGIN PROLOGUE XERRWV
+C***DATE WRITTEN 800319 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. R3C
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Processes error message allowing 2 integer and two real
+C values to be included in the message.
+C***DESCRIPTION
+C Abstract
+C XERRWV processes a diagnostic message, in a manner
+C determined by the value of LEVEL and the current value
+C of the library error control flag, KONTRL.
+C (See subroutine XSETF for details.)
+C In addition, up to two integer values and two real
+C values may be printed along with the message.
+C
+C Description of Parameters
+C --Input--
+C MESSG - the Hollerith message to be processed.
+C NMESSG- the actual number of characters in MESSG.
+C NERR - the error number associated with this message.
+C NERR must not be zero.
+C LEVEL - error category.
+C =2 means this is an unconditionally fatal error.
+C =1 means this is a recoverable error. (I.e., it is
+C non-fatal if XSETF has been appropriately called.)
+C =0 means this is a warning message only.
+C =-1 means this is a warning message which is to be
+C printed at most once, regardless of how many
+C times this call is executed.
+C NI - number of integer values to be printed. (0 to 2)
+C I1 - first integer value.
+C I2 - second integer value.
+C NR - number of real values to be printed. (0 to 2)
+C R1 - first real value.
+C R2 - second real value.
+C
+C Examples
+C CALL XERRWV('SMOOTH -- NUM (=I1) WAS ZERO.',29,1,2,
+C 1 1,NUM,0,0,0.,0.)
+C CALL XERRWV('QUADXY -- REQUESTED ERROR (R1) LESS THAN MINIMUM (
+C 1R2).,54,77,1,0,0,0,2,ERRREQ,ERRMIN)
+C
+C Latest revision --- 19 MAR 1980
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED FDUMP,I1MACH,J4SAVE,XERABT,XERCTL,XERPRT,XERSAV,
+C XGETUA
+C***END PROLOGUE XERRWV
+ CHARACTER*(*) MESSG
+ CHARACTER*20 LFIRST
+ CHARACTER*37 FORM
+ DIMENSION LUN(5)
+C GET FLAGS
+C***FIRST EXECUTABLE STATEMENT XERRWV
+ LKNTRL = J4SAVE(2,0,.FALSE.)
+ MAXMES = J4SAVE(4,0,.FALSE.)
+C CHECK FOR VALID INPUT
+ IF ((NMESSG.GT.0).AND.(NERR.NE.0).AND.
+ 1 (LEVEL.GE.(-1)).AND.(LEVEL.LE.2)) GO TO 10
+ IF (LKNTRL.GT.0) CALL XERPRT('FATAL ERROR IN...',17)
+ CALL XERPRT('XERROR -- INVALID INPUT',23)
+ IF (LKNTRL.GT.0) CALL FDUMP
+ IF (LKNTRL.GT.0) CALL XERPRT('JOB ABORT DUE TO FATAL ERROR.',
+ 1 29)
+ IF (LKNTRL.GT.0) CALL XERSAV(' ',0,0,0,KDUMMY)
+ CALL XERABT('XERROR -- INVALID INPUT',23)
+ RETURN
+ 10 CONTINUE
+C RECORD MESSAGE
+ JUNK = J4SAVE(1,NERR,.TRUE.)
+ CALL XERSAV(MESSG,NMESSG,NERR,LEVEL,KOUNT)
+C LET USER OVERRIDE
+ LFIRST = MESSG
+ LMESSG = NMESSG
+ LERR = NERR
+ LLEVEL = LEVEL
+ CALL XERCTL(LFIRST,LMESSG,LERR,LLEVEL,LKNTRL)
+C RESET TO ORIGINAL VALUES
+ LMESSG = NMESSG
+ LERR = NERR
+ LLEVEL = LEVEL
+ LKNTRL = MAX0(-2,MIN0(2,LKNTRL))
+ MKNTRL = IABS(LKNTRL)
+C DECIDE WHETHER TO PRINT MESSAGE
+ IF ((LLEVEL.LT.2).AND.(LKNTRL.EQ.0)) GO TO 100
+ IF (((LLEVEL.EQ.(-1)).AND.(KOUNT.GT.MIN0(1,MAXMES)))
+ 1.OR.((LLEVEL.EQ.0) .AND.(KOUNT.GT.MAXMES))
+ 2.OR.((LLEVEL.EQ.1) .AND.(KOUNT.GT.MAXMES).AND.(MKNTRL.EQ.1))
+ 3.OR.((LLEVEL.EQ.2) .AND.(KOUNT.GT.MAX0(1,MAXMES)))) GO TO 100
+ IF (LKNTRL.LE.0) GO TO 20
+ CALL XERPRT(' ',1)
+C INTRODUCTION
+ IF (LLEVEL.EQ.(-1)) CALL XERPRT
+ 1('WARNING MESSAGE...THIS MESSAGE WILL ONLY BE PRINTED ONCE.',57)
+ IF (LLEVEL.EQ.0) CALL XERPRT('WARNING IN...',13)
+ IF (LLEVEL.EQ.1) CALL XERPRT
+ 1 ('RECOVERABLE ERROR IN...',23)
+ IF (LLEVEL.EQ.2) CALL XERPRT('FATAL ERROR IN...',17)
+ 20 CONTINUE
+C MESSAGE
+ CALL XERPRT(MESSG,LMESSG)
+ CALL XGETUA(LUN,NUNIT)
+ ISIZEI = LOG10(FLOAT(I1MACH(9))) + 1.0
+ ISIZEF = LOG10(FLOAT(I1MACH(10))**I1MACH(11)) + 1.0
+ DO 50 KUNIT=1,NUNIT
+ IUNIT = LUN(KUNIT)
+ IF (IUNIT.EQ.0) IUNIT = I1MACH(4)
+ DO 22 I=1,MIN(NI,2)
+ WRITE (FORM,21) I,ISIZEI
+ 21 FORMAT ('(11X,21HIN ABOVE MESSAGE, I',I1,'=,I',I2,') ')
+ IF (I.EQ.1) WRITE (IUNIT,FORM) I1
+ IF (I.EQ.2) WRITE (IUNIT,FORM) I2
+ 22 CONTINUE
+ DO 24 I=1,MIN(NR,2)
+ WRITE (FORM,23) I,ISIZEF+10,ISIZEF
+ 23 FORMAT ('(11X,21HIN ABOVE MESSAGE, R',I1,'=,E',
+ 1 I2,'.',I2,')')
+ IF (I.EQ.1) WRITE (IUNIT,FORM) R1
+ IF (I.EQ.2) WRITE (IUNIT,FORM) R2
+ 24 CONTINUE
+ IF (LKNTRL.LE.0) GO TO 40
+C ERROR NUMBER
+ WRITE (IUNIT,30) LERR
+ 30 FORMAT (15H ERROR NUMBER =,I10)
+ 40 CONTINUE
+ 50 CONTINUE
+C TRACE-BACK
+ IF (LKNTRL.GT.0) CALL FDUMP
+ 100 CONTINUE
+ IFATAL = 0
+ IF ((LLEVEL.EQ.2).OR.((LLEVEL.EQ.1).AND.(MKNTRL.EQ.2)))
+ 1IFATAL = 1
+C QUIT HERE IF MESSAGE IS NOT FATAL
+ IF (IFATAL.LE.0) RETURN
+ IF ((LKNTRL.LE.0).OR.(KOUNT.GT.MAX0(1,MAXMES))) GO TO 120
+C PRINT REASON FOR ABORT
+ IF (LLEVEL.EQ.1) CALL XERPRT
+ 1 ('JOB ABORT DUE TO UNRECOVERED ERROR.',35)
+ IF (LLEVEL.EQ.2) CALL XERPRT
+ 1 ('JOB ABORT DUE TO FATAL ERROR.',29)
+C PRINT ERROR SUMMARY
+ CALL XERSAV(' ',-1,0,0,KDUMMY)
+ 120 CONTINUE
+C ABORT
+ IF ((LLEVEL.EQ.2).AND.(KOUNT.GT.MAX0(1,MAXMES))) LMESSG = 0
+ CALL XERABT(MESSG,LMESSG)
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERSAV.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERSAV.f
new file mode 100644
index 000000000..89a88ade9
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XERSAV.f
@@ -0,0 +1,104 @@
+ SUBROUTINE XERSAV(MESSG,NMESSG,NERR,LEVEL,ICOUNT)
+C***BEGIN PROLOGUE XERSAV
+C***DATE WRITTEN 800319 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. Z
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Records that an error occurred.
+C***DESCRIPTION
+C Abstract
+C Record that this error occurred.
+C
+C Description of Parameters
+C --Input--
+C MESSG, NMESSG, NERR, LEVEL are as in XERROR,
+C except that when NMESSG=0 the tables will be
+C dumped and cleared, and when NMESSG is less than zero the
+C tables will be dumped and not cleared.
+C --Output--
+C ICOUNT will be the number of times this message has
+C been seen, or zero if the table has overflowed and
+C does not contain this message specifically.
+C When NMESSG=0, ICOUNT will not be altered.
+C
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C Latest revision --- 19 Mar 1980
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED I1MACH,S88FMT,XGETUA
+C***END PROLOGUE XERSAV
+ INTEGER LUN(5)
+ CHARACTER*(*) MESSG
+ CHARACTER*20 MESTAB(10),MES
+ DIMENSION NERTAB(10),LEVTAB(10),KOUNT(10)
+ SAVE MESTAB,NERTAB,LEVTAB,KOUNT,KOUNTX
+C NEXT TWO DATA STATEMENTS ARE NECESSARY TO PROVIDE A BLANK
+C ERROR TABLE INITIALLY
+ DATA KOUNT(1),KOUNT(2),KOUNT(3),KOUNT(4),KOUNT(5),
+ 1 KOUNT(6),KOUNT(7),KOUNT(8),KOUNT(9),KOUNT(10)
+ 2 /0,0,0,0,0,0,0,0,0,0/
+ DATA KOUNTX/0/
+C***FIRST EXECUTABLE STATEMENT XERSAV
+ IF (NMESSG.GT.0) GO TO 80
+C DUMP THE TABLE
+ IF (KOUNT(1).EQ.0) RETURN
+C PRINT TO EACH UNIT
+ CALL XGETUA(LUN,NUNIT)
+ DO 60 KUNIT=1,NUNIT
+ IUNIT = LUN(KUNIT)
+ IF (IUNIT.EQ.0) IUNIT = I1MACH(4)
+C PRINT TABLE HEADER
+ WRITE (IUNIT,10)
+ 10 FORMAT (32H0 ERROR MESSAGE SUMMARY/
+ 1 51H MESSAGE START NERR LEVEL COUNT)
+C PRINT BODY OF TABLE
+ DO 20 I=1,10
+ IF (KOUNT(I).EQ.0) GO TO 30
+ WRITE (IUNIT,15) MESTAB(I),NERTAB(I),LEVTAB(I),KOUNT(I)
+ 15 FORMAT (1X,A20,3I10)
+ 20 CONTINUE
+ 30 CONTINUE
+C PRINT NUMBER OF OTHER ERRORS
+ IF (KOUNTX.NE.0) WRITE (IUNIT,40) KOUNTX
+ 40 FORMAT (41H0OTHER ERRORS NOT INDIVIDUALLY TABULATED=,I10)
+ WRITE (IUNIT,50)
+ 50 FORMAT (1X)
+ 60 CONTINUE
+ IF (NMESSG.LT.0) RETURN
+C CLEAR THE ERROR TABLES
+ DO 70 I=1,10
+ 70 KOUNT(I) = 0
+ KOUNTX = 0
+ RETURN
+ 80 CONTINUE
+C PROCESS A MESSAGE...
+C SEARCH FOR THIS MESSG, OR ELSE AN EMPTY SLOT FOR THIS MESSG,
+C OR ELSE DETERMINE THAT THE ERROR TABLE IS FULL.
+ MES = MESSG
+ DO 90 I=1,10
+ II = I
+ IF (KOUNT(I).EQ.0) GO TO 110
+ IF (MES.NE.MESTAB(I)) GO TO 90
+ IF (NERR.NE.NERTAB(I)) GO TO 90
+ IF (LEVEL.NE.LEVTAB(I)) GO TO 90
+ GO TO 100
+ 90 CONTINUE
+C THREE POSSIBLE CASES...
+C TABLE IS FULL
+ KOUNTX = KOUNTX+1
+ ICOUNT = 1
+ RETURN
+C MESSAGE FOUND IN TABLE
+ 100 KOUNT(II) = KOUNT(II) + 1
+ ICOUNT = KOUNT(II)
+ RETURN
+C EMPTY SLOT FOUND FOR NEW MESSAGE
+ 110 MESTAB(II) = MES
+ NERTAB(II) = NERR
+ LEVTAB(II) = LEVEL
+ KOUNT(II) = 1
+ ICOUNT = 1
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/XGETUA.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XGETUA.f
new file mode 100644
index 000000000..2f0e5f6f7
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/XGETUA.f
@@ -0,0 +1,46 @@
+ SUBROUTINE XGETUA(IUNITA,N)
+C***BEGIN PROLOGUE XGETUA
+C***DATE WRITTEN 790801 (YYMMDD)
+C***REVISION DATE 820801 (YYMMDD)
+C***CATEGORY NO. R3C
+C***KEYWORDS ERROR,XERROR PACKAGE
+C***AUTHOR JONES, R. E., (SNLA)
+C***PURPOSE Returns unit number(s) to which error messages are being
+C sent.
+C***DESCRIPTION
+C Abstract
+C XGETUA may be called to determine the unit number or numbers
+C to which error messages are being sent.
+C These unit numbers may have been set by a call to XSETUN,
+C or a call to XSETUA, or may be a default value.
+C
+C Description of Parameters
+C --Output--
+C IUNIT - an array of one to five unit numbers, depending
+C on the value of N. A value of zero refers to the
+C default unit, as defined by the I1MACH machine
+C constant routine. Only IUNIT(1),...,IUNIT(N) are
+C defined by XGETUA. The values of IUNIT(N+1),...,
+C IUNIT(5) are not defined (for N .LT. 5) or altered
+C in any way by XGETUA.
+C N - the number of units to which copies of the
+C error messages are being sent. N will be in the
+C range from 1 to 5.
+C
+C Latest revision --- 19 MAR 1980
+C Written by Ron Jones, with SLATEC Common Math Library Subcommittee
+C***REFERENCES JONES R.E., KAHANER D.K., "XERROR, THE SLATEC ERROR-"
+C HANDLING PACKAGE", SAND82-0800, SANDIA LABORATORIES,"
+C 1982.
+C***ROUTINES CALLED J4SAVE
+C***END PROLOGUE XGETUA
+ DIMENSION IUNITA(5)
+C***FIRST EXECUTABLE STATEMENT XGETUA
+ N = J4SAVE(5,0,.FALSE.)
+ DO 30 I=1,N
+ INDEX = I+4
+ IF (I.EQ.1) INDEX = 3
+ IUNITA(I) = J4SAVE(INDEX,0,.FALSE.)
+ 30 CONTINUE
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/amatrix.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/amatrix.f
new file mode 100644
index 000000000..0e84ed95e
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/amatrix.f
@@ -0,0 +1,21 @@
+ subroutine amatrix
+ parameter(nmx=24)
+ common /matrix/ a(nmx,nmx),capd2
+ COMMON /POSIT/ XOLD,YOLD,XCORN,YCORN
+ common /vect/rovect(nmx),xvect(nmx),yvect(nmx)
+c
+ PI180 = 4.*ATAN(1.0)/180.
+ yo=yold*pi180
+c qliu fact=cos(yo)
+ fact=1.0
+c capd2=(3.15)*(3.15)
+ capd2=(2.25)*(2.25)
+ do 10 ip=1,nmx
+ do 10 jp=ip,nmx
+ dpij=(fact*(xvect(ip)-xvect(jp)))**2 +(yvect(ip)-yvect(jp))**2
+ a(ip,jp)= exp(-dpij/capd2)
+ a(jp,ip)= a(ip,jp)
+10 continue
+100 format(5f8.4)
+ return
+ end
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/create_rel_domain.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/create_rel_domain.f
new file mode 100644
index 000000000..27b512c31
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/create_rel_domain.f
@@ -0,0 +1,504 @@
+!??????????????????????????????????????????????????????????
+ SUBROUTINE CREAT_41X41(ITIM,KST,KMX,MTV6,KS850,U850,V850,
+ & SDAT,P2)
+! SUBPROGRAM
+! PRGRMMR
+!
+! ABSTRACT
+!
+! DECLARE VARIABLES
+!
+ INTEGER I,J,K,NX,NY,NZ
+!
+! PARAMETER (NX=215,NY=431,NZ=42)
+ PARAMETER (NST=10,IRX=41,JRX=41,MAXNGRID=10000)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,GI=1./G,D608=0.608)
+!
+! variable for outer nest
+
+ REAL(4), ALLOCATABLE :: T3(:,:,:),Q3(:,:,:)
+ REAL(4), ALLOCATABLE :: U3(:,:,:),V3(:,:,:),W3(:,:,:)
+ REAL(4), ALLOCATABLE :: Z3(:,:,:),P3(:,:,:)
+ REAL(4), ALLOCATABLE :: SLP3(:,:),HP3(:,:,:),RH3(:,:)
+
+ REAL(4), ALLOCATABLE :: ZM3(:,:,:),PM3(:,:,:)
+ REAL(4), ALLOCATABLE :: PMV3(:,:,:),TV3(:,:,:)
+
+ REAL(4), ALLOCATABLE :: HLON3(:,:),HLAT3(:,:)
+ REAL(4), ALLOCATABLE :: VLON3(:,:),VLAT3(:,:)
+
+! REAL(4) DLMD3,DPHD3,CLON3,CLAT3,PT3,PDTOP3
+ REAL(4) LON1,LAT1,LON2,LAT2,CLON3,CLAT3
+
+ real(4),allocatable :: UT850(:,:),VT850(:,:)
+ real(4),allocatable :: wrk1(:,:,:),wrk2(:,:,:)
+
+ integer(4) IGD(IRX,JRX,MAXNGRID),JGD(IRX,JRX,MAXNGRID)
+ integer(4) NSUM(IRX,JRX),NGRID,KST
+ real WGD(IRX,JRX,MAXNGRID),WSUM(IRX,JRX)
+
+ REAL(4) BLON(IRX), BLAT(JRX)
+
+ REAL(4) U850(IRX,JRX),V850(IRX,JRX)
+
+ REAL(4) P2(KMX),SDAT(IRX,JRX,MTV6)
+
+! Variables on P surface
+
+ real(4) SLON_N,SLAT_N,CLON_N,CLAT_N
+
+ COMMON /NHC/ KSTM,IC_N(NST),JC_N(NST)
+ COMMON /NHC1/ SLON_N(NST),SLAT_N(NST),CLON_N(NST),CLAT_N(NST)
+ CHARACTER ST_NAME(NST)*3,STMNAME(NST)*3,TCVT(NST)*95
+ COMMON /STNAME/ST_NAME,STMNAME
+ COMMON /TCVIT/TCVT
+ COMMON /RSFC/STRPSF(NST),STVMAX(NST)
+!
+ COEF3=287.05*GI*GAMMA
+ COEF2=1./COEF3
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi
+ pi180=pi/180.
+! read data
+
+! READ(5,*)ITIM,IBGS
+
+! newly added
+! compute SDATA from outter nest domain
+
+ IUNIT=46
+
+ READ(IUNIT)KX,KY,KZ
+ KZ1=KZ+1
+ print*,'KX,KY,KZ=',KX,KY,KZ
+
+ max_kz_kmx=kz
+ if(kmx .gt. kz) then
+ max_kz_kmx=kmx
+ end if
+
+ ALLOCATE ( HLON3(KX,KY),HLAT3(KX,KY) )
+ ALLOCATE ( VLON3(KX,KY),VLAT3(KX,KY) )
+
+ ALLOCATE ( T3(KX,KY,KZ),Q3(KX,KY,KZ) )
+ ALLOCATE ( U3(KX,KY,KZ),V3(KX,KY,KZ),W3(KX,KY,KZ) )
+ ALLOCATE ( Z3(KX,KY,KZ1),P3(KX,KY,KZ1) )
+
+ ALLOCATE ( SLP3(KX,KY),ZM3(KX,KY,KZ) )
+ ALLOCATE ( HP3(KX,KY,max_kz_kmx),RH3(KX,KY) )
+ ALLOCATE ( PM3(KX,KY,KZ),PMV3(KX,KY,KZ) )
+ ALLOCATE ( TV3(KX,KY,KZ) )
+
+ ALLOCATE ( wrk1(KX,KY,KMX), wrk2(KX,KY,KMX) )
+ ALLOCATE ( UT850(KX,KY),VT850(KX,KY) )
+
+ READ(IUNIT) LON1,LAT1,LON2,LAT2,CLON3,CLAT3
+ READ(IUNIT) PM3
+ READ(IUNIT) T3
+ READ(IUNIT) Q3
+ READ(IUNIT) U3
+ READ(IUNIT) V3
+ READ(IUNIT) W3
+ READ(IUNIT) Z3
+ READ(IUNIT) HLON3,HLAT3,VLON3,VLAT3
+ READ(IUNIT) P3
+ READ(IUNIT)
+ READ(IUNIT)
+ READ(IUNIT)
+ CLOSE(IUNIT)
+ print*,'finish reading data'
+!
+!$omp parallel do
+!$omp& private(i,j,k)
+ DO K=1,KZ
+ DO J=1,KY
+ DO I=1,KX
+ TV3(I,J,K)=T3(I,J,K)*(1.+D608*Q3(I,J,K))
+ ZM3(I,J,K)=(Z3(I,J,K)+Z3(I,J,K+1))*0.5+
+ & 0.5*TV3(I,J,K)/GAMMA*(2.-(P3(I,J,K)/PM3(I,J,K))**COEF3-
+ & (P3(I,J,K+1)/PM3(I,J,K))**COEF3)
+! ZM3(I,J,K)=(Z3(I,J,K)+Z3(I,J,K+1))*0.5
+! PM3(I,J,K)=EXP((ALOG(1.*P3(I,J,K))+ALOG(1.*P3(I,J,K+1)))*0.5)
+ END DO
+ END DO
+ END DO
+
+!C COMPUTE SEA LEVEL PRESSURE.
+!C
+!$omp parallel do
+!$omp& private(i,j,ZSF1,PSF1,A)
+ DO J=1,KY
+ DO I=1,KX
+ ZSF1 = ZM3(I,J,1)
+ PSF1 = PM3(I,J,1)
+ A = (GAMMA * ZSF1) / TV3(I,J,1)
+ SLP3(I,J) = PSF1*(1+A)**COEF2
+ ENDDO
+ ENDDO
+
+ PMV3=PM3
+!!$omp parallel do
+!!$omp& private(i,j,k)
+! DO J=2,KY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO K=1,KZ
+! DO I=1,KX-1
+! PMV3(I,J,K)=0.25*(PM3(I,J,K)+PM3(I+1,J,K)+
+! & PM3(I,J-1,K)+PM3(I,J+1,K))
+! END DO
+! END DO
+! ELSE
+! DO K=1,KZ
+! DO I=2,KX
+! PMV3(I,J,K)=0.25*(PM3(I-1,J,K)+PM3(I,J,K)+
+! & PM3(I,J-1,K)+PM3(I,J+1,K))
+! END DO
+! END DO
+! END IF
+! END DO
+
+! Height at P3 grids
+
+!$omp parallel do
+!$omp& private(i,j,k,n)
+ DO J=1,KY
+ DO I=1,KX
+ CYC_510: DO K=1,KMX
+ IF(P2(K).GE.PM3(I,J,1))THEN
+ HP3(I,J,K)=ZM3(I,J,1)+
+ & TV3(I,J,1)/GAMMA*(1.-(P2(K)/PM3(I,J,1))**COEF3)
+ ELSE IF(P2(K).LE.PM3(I,J,KZ))THEN
+ HP3(I,J,K)=ZM3(I,J,KZ)+
+ & TV3(I,J,KZ)/GAMMA*(1.-(P2(K)/PM3(I,J,KZ))**COEF3)
+ ELSE
+ DO N=1,KZ-1
+ IF(P2(K).LE.PM3(I,J,N).and.P2(K).GT.PM3(I,J,N+1))THEN
+ HP3(I,J,K)=ZM3(I,J,N)+
+ & TV3(I,J,N)/GAMMA*(1.-(P2(K)/PM3(I,J,N))**COEF3)
+ CYCLE CYC_510
+ END IF
+ END DO
+ END IF
+ END DO CYC_510
+ END DO
+ END DO
+
+
+ do i=1,IRX
+ BLON(i)=SLON_N(kst)+i-1.
+ end do
+ do j=1,JRX
+ BLAT(j)=SLAT_N(kst)+j-1.
+ end do
+
+
+ DO J=1,KY
+ DO I=1,KX
+ UT850(I,J)=U3(I,J,KS850)
+ VT850(I,J)=V3(I,J,KS850)
+ END DO
+ END DO
+
+
+ print*,'compute weight'
+
+ IGD=0
+ JGD=0
+ WGD=0
+! RDST=0.75
+ !RDST=10.*(LON2-LON1)/FLOAT(KX-1)
+ RDST=5.*(LON2-LON1)/FLOAT(KX-1)
+ print*,'parent RDST=',RDST
+ !IF(RDST.LT.0.25)RDST=0.25
+ IF(RDST.LT.0.10)RDST=0.10
+ RDST1=RDST*RDST
+
+!$omp parallel do
+!$omp& private(i,j,k,N,NGRID,COST2,DIST)
+ DO J=1,JRX
+ DO I=1,IRX
+ NGRID=0
+ NSUM(I,J)=0.
+ WSUM(I,J)=0.
+ DO N=1,KY
+ DO K=1,KX
+ COST2=(COS((VLAT3(K,N)+BLAT(J))*0.5*pi180))**2
+ DIST=COST2*(VLON3(K,N)-BLON(I))**2+
+ & (VLAT3(K,N)-BLAT(J))**2
+ IF(DIST.LE.RDST1)THEN
+ NGRID=NGRID+1
+ IGD(I,J,NGRID)=K
+ JGD(I,J,NGRID)=N
+ WGD(I,J,NGRID)=EXP(-DIST/RDST1)
+ WSUM(I,J)=WSUM(I,J)+WGD(I,J,NGRID)
+ NSUM(I,J)=NGRID
+ END IF
+ END DO
+ END DO
+! print*,'I,J=',I,J,NSUM(I,J),WSUM(I,J),BLON(I),BLAT(J)
+ END DO
+ END DO
+
+ if(ngrid .ge. maxngrid) then
+ print*,'NGRID has passed MAXNGRID in create_rel_domain.f.'
+ print*,'NGRID = ',NGRID
+ print*,'MAXNGRID = ',MAXNGRID
+ stop
+ end if
+
+!$omp parallel do
+!$omp& private(i,j,N,SDAT1,I1,J1)
+ DO J=1,JRX
+ DO I=1,IRX
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+UT850(I1,J1)*WGD(I,J,N)
+ END DO
+!
+! Chanh puts a check here for the case that the outer domain
+! needs to be used, which caused NSUM = 0, and WSUM = 0
+!
+ IF (WSUM(I,J).gt.0) THEN
+ U850(I,J)=SDAT1/WSUM(I,J)
+ ELSE
+ U850(I,J)=0
+ ENDIF
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+VT850(I1,J1)*WGD(I,J,N)
+ END DO
+!
+! Chanh puts a check here for the case that the outer domain
+! needs to be used, which caused NSUM = 0, and WSUM = 0
+!
+ IF (WSUM(I,J).gt.0) THEN
+ V850(I,J)=SDAT1/WSUM(I,J)
+ ELSE
+ V850(I,J)=0
+ ENDIF
+ ENDDO
+ ENDDO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,W1,W)
+ DO J=1,KY
+ DO I=1,KX
+ CYC_44: DO K=1,KMX
+ IF(P2(K).GE.PMV3(I,J,1))THEN ! Below PMV1(I,J,1)
+! wrk1(I,J,K)=U3(I,J,1)*(1.-(P2(K)-PMV3(I,J,1))*1.4E-5)
+! wrk2(I,J,K)=V3(I,J,1)*(1.-(P2(K)-PMV3(I,J,1))*1.4E-5)
+ wrk1(I,J,K)=U3(I,J,1)
+ wrk2(I,J,K)=V3(I,J,1)
+ ELSE IF(P2(K).LE.PMV3(I,J,KZ))THEN
+ wrk1(I,J,K)=U3(I,J,KZ)
+ wrk2(I,J,K)=V3(I,J,KZ)
+ ELSE
+ DO N=1,KZ-1
+ IF(P2(K).LE.PMV3(I,J,N).and.P2(K).GT.PMV3(I,J,N+1))THEN
+ W1=ALOG(1.*PMV3(I,J,N+1))-ALOG(1.*PMV3(I,J,N))
+ W=(ALOG(1.*P2(K))-ALOG(1.*PMV3(I,J,N)))/W1
+ wrk1(I,J,K)=U3(I,J,N)+(U3(I,J,N+1)-U3(I,J,N))*W
+ wrk2(I,J,K)=V3(I,J,N)+(V3(I,J,N+1)-V3(I,J,N))*W
+ CYCLE CYC_44
+ END IF
+ END DO
+ END IF
+ END DO CYC_44
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,K2,K3,K5,K6,SDAT1,I1,J1)
+ DO K=1,KMX
+ K2=4*(K-1)+3+KMX+2
+ K3=4*(K-1)+4+KMX+2
+ K5=4*(K-1)+1+KMX+2 ! div (here U,V, otherwise move to next loop)
+ K6=4*(K-1)+2+KMX+2 ! vor
+ DO J=1,JRX
+ DO I=1,IRX
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+wrk1(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K2)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+wrk2(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K3)=SDAT1/WSUM(I,J)
+ SDAT(I,J,K5)=SDAT(I,J,K2)
+ SDAT(I,J,K6)=SDAT(I,J,K3)
+ ENDDO
+ ENDDO
+
+! WRITE(83)((SDAT(I,J,K2),I=1,41),J=1,41)
+
+ ENDDO
+
+! DO K=1,KMX
+! K3=4*(K-1)+4+KMX+2
+! WRITE(83)((SDAT(I,J,K3),I=1,41),J=1,41)
+! END DO
+
+!*** FOR T PS points
+
+
+ IGD=0
+ JGD=0
+ WGD=0
+ !RDST=0.75
+ !RDST=10.*(LON2-LON1)/FLOAT(KX-1)
+ RDST=5.*(LON2-LON1)/FLOAT(KX-1)
+ print*,'parent RDST=',RDST
+ !IF(RDST.LT.0.25)RDST=0.25
+ IF(RDST.LT.0.10)RDST=0.10
+ RDST1=RDST*RDST
+
+!$omp parallel do
+!$omp& private(i,j,k,N,NGRID,COST2,DIST)
+ DO J=1,JRX
+ DO I=1,IRX
+ NGRID=0
+ WSUM(I,J)=0.
+ DO N=1,KY
+ DO K=1,KX
+ COST2=(COS((HLAT3(K,N)+BLAT(J))*0.5*pi180))**2
+ DIST=COST2*(HLON3(K,N)-BLON(I))**2+
+ & (HLAT3(K,N)-BLAT(J))**2
+ IF(DIST.LE.RDST1)THEN
+ NGRID=NGRID+1
+ IGD(I,J,NGRID)=K
+ JGD(I,J,NGRID)=N
+ WGD(I,J,NGRID)=EXP(-DIST/RDST1)
+ WSUM(I,J)=WSUM(I,J)+WGD(I,J,NGRID)
+ NSUM(I,J)=NGRID
+ END IF
+ END DO
+ END DO
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,N,SDAT1,I1,J1)
+ DO J=1,JRX
+ DO I=1,IRX
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+Z3(I1,J1,1)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,1)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+SLP3(I1,J1)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,2)=SDAT1/WSUM(I,J)
+ END DO
+ END DO
+
+! WRITE(83)((SDAT(I,J,1),I=1,41),J=1,41)
+! WRITE(83)((SDAT(I,J,2),I=1,41),J=1,41)
+
+
+ K=1
+!$omp parallel do
+!$omp& private(i,j,DTEMP,ES,QS3)
+ DO J=1,KY
+ DO I=1,KX
+ DTEMP=T3(I,J,K)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ QS3=0.622*ES/(PM3(I,J,K)-0.378*ES)
+ RH3(I,J)=MIN(MAX(Q3(I,J,K)/QS3,0.),1.0)
+ END DO
+ END DO
+
+! Iterpolation to constant P
+
+!$omp parallel do
+!$omp& private(i,j,k,N,DTEMP,ES,QSK,W1,W)
+ DO J=1,KY
+ DO I=1,KX
+ DO K=1,KMX
+ IF(P2(K).GE.PM3(I,J,1))THEN ! Below PM1(I,J,1)
+ wrk1(I,J,K)=T3(I,J,1)-GAMMA*(HP3(I,J,K)-ZM3(I,J,1))
+ DTEMP=wrk1(I,J,K)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ QSK=0.622*ES/(P2(K)-0.378*ES)
+ wrk2(I,J,K)=RH3(I,J)*QSK ! constant RH below KZ=1
+ ELSE IF(P2(K).LE.PM3(I,J,KZ))THEN
+ wrk1(I,J,K)=T3(I,J,KZ)-GAMMA*(HP3(I,J,K)-ZM3(I,J,KZ))
+ wrk2(I,J,K)=Q3(I,J,KZ) ! very small
+ ELSE
+ DO N=1,KZ-1
+ IF(P2(K).LE.PM3(I,J,N).and.P2(K).GT.PM3(I,J,N+1))THEN
+ W1=ALOG(1.*PM3(I,J,N+1))-ALOG(1.*PM3(I,J,N))
+ W=(ALOG(1.*P2(K))-ALOG(1.*PM3(I,J,N)))/W1
+ wrk1(I,J,K)=T3(I,J,N)+(T3(I,J,N+1)-T3(I,J,N))*W
+ wrk2(I,J,K)=Q3(I,J,N)+(Q3(I,J,N+1)-Q3(I,J,N))*W
+ GO TO 42
+ END IF
+ END DO
+ 42 CONTINUE
+ END IF
+ END DO
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,K,K1,K4,N,SDAT1,I1,J1)
+ DO K=1,KMX
+ K1=K+2
+! K2=4*(K-1)+3+KMX+2
+! K3=4*(K-1)+4+KMX+2
+ K4=K+5*KMX+2
+! K5=4*(K-1)+1+KMX+2 ! div
+! K6=4*(K-1)+2+KMX+2 ! vor
+ DO J=1,JRX
+ DO I=1,IRX
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+wrk1(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K1)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+wrk2(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K4)=SDAT1/WSUM(I,J)
+ ENDDO
+ ENDDO
+
+! WRITE(83)((SDAT(I,J,K1),I=1,41),J=1,41)
+
+ ENDDO
+
+! DO K=1,KMX
+! K4=K+5*KMX+2
+! WRITE(83)((SDAT(I,J,K4),I=1,41),J=1,41)
+! END DO
+
+ DEALLOCATE (HLON3,HLAT3,VLON3,VLAT3)
+ DEALLOCATE (T3,Q3,U3,V3,Z3,P3,SLP3)
+ DEALLOCATE (ZM3,PM3,PMV3,TV3,HP3,RH3)
+ DEALLOCATE (wrk1,wrk2,UT850,VT850)
+
+
+! finish computing SDATA
+
+ end
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/fft99.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/fft99.f
new file mode 100644
index 000000000..3fcdedc7e
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/fft99.f
@@ -0,0 +1,1126 @@
+C
+ SUBROUTINE FFT99(A,WORK,TRIGS,IFAX,INC,JUMP,N,LOT,ISIGN)
+C
+C PURPOSE PERFORMS MULTIPLE FAST FOURIER TRANSFORMS. THIS PACKAGE
+C WILL PERFORM A NUMBER OF SIMULTANEOUS REAL/HALF-COMPLEX
+C PERIODIC FOURIER TRANSFORMS OR CORRESPONDING INVERSE
+C TRANSFORMS, I.E. GIVEN A SET OF REAL DATA VECTORS, THE
+C PACKAGE RETURNS A SET OF 'HALF-COMPLEX' FOURIER
+C COEFFICIENT VECTORS, OR VICE VERSA. THE LENGTH OF THE
+C TRANSFORMS MUST BE AN EVEN NUMBER GREATER THAN 4 THAT HAS
+C NO OTHER FACTORS EXCEPT POSSIBLY POWERS OF 2, 3, AND 5.
+C THIS IS AN ALL FORTRAN VERSION OF THE CRAYLIB PACKAGE
+C THAT IS MOSTLY WRITTEN IN CAL.
+C
+C THE PACKAGE FFT99F CONTAINS SEVERAL USER-LEVEL ROUTINES:
+C
+C SUBROUTINE FFTFAX
+C AN INITIALIZATION ROUTINE THAT MUST BE CALLED ONCE
+C BEFORE A SEQUENCE OF CALLS TO THE FFT ROUTINES
+C (PROVIDED THAT N IS NOT CHANGED).
+C
+C SUBROUTINES FFT99 AND FFT991
+C TWO FFT ROUTINES THAT RETURN SLIGHTLY DIFFERENT
+C ARRANGEMENTS OF THE DATA IN GRIDPOINT SPACE.
+C
+C
+C ACCESS THIS FORTRAN VERSION MAY BE ACCESSED WITH
+C
+C *FORTRAN,P=XLIB,SN=FFT99F
+C
+C TO ACCESS THE CRAY OBJECT CODE, CALLING THE USER ENTRY
+C POINTS FROM A CRAY PROGRAM IS SUFFICIENT. THE SOURCE
+C FORTRAN AND CAL CODE FOR THE CRAYLIB VERSION MAY BE
+C ACCESSED USING
+C
+C FETCH P=CRAYLIB,SN=FFT99
+C FETCH P=CRAYLIB,SN=CAL99
+C
+C USAGE LET N BE OF THE FORM 2**P * 3**Q * 5**R, WHERE P .GE. 1,
+C Q .GE. 0, AND R .GE. 0. THEN A TYPICAL SEQUENCE OF
+C CALLS TO TRANSFORM A GIVEN SET OF REAL VECTORS OF LENGTH
+C N TO A SET OF 'HALF-COMPLEX' FOURIER COEFFICIENT VECTORS
+C OF LENGTH N IS
+C
+C DIMENSION IFAX(13),TRIGS(3*N/2+1),A(M*(N+2)),
+C + WORK(M*(N+1))
+C
+C CALL FFTFAX (N, IFAX, TRIGS)
+C CALL FFT99 (A,WORK,TRIGS,IFAX,INC,JUMP,N,M,ISIGN)
+C
+C SEE THE INDIVIDUAL WRITE-UPS FOR FFTFAX, FFT99, AND
+C FFT991 BELOW, FOR A DETAILED DESCRIPTION OF THE
+C ARGUMENTS.
+C
+C HISTORY THE PACKAGE WAS WRITTEN BY CLIVE TEMPERTON AT ECMWF IN
+C NOVEMBER, 1978. IT WAS MODIFIED, DOCUMENTED, AND TESTED
+C FOR NCAR BY RUSS REW IN SEPTEMBER, 1980.
+C
+C-----------------------------------------------------------------------
+C
+C SUBROUTINE FFTFAX (N,IFAX,TRIGS)
+C
+C PURPOSE A SET-UP ROUTINE FOR FFT99 AND FFT991. IT NEED ONLY BE
+C CALLED ONCE BEFORE A SEQUENCE OF CALLS TO THE FFT
+C ROUTINES (PROVIDED THAT N IS NOT CHANGED).
+C
+C ARGUMENT IFAX(13),TRIGS(3*N/2+1)
+C DIMENSIONS
+C
+C ARGUMENTS
+C
+C ON INPUT N
+C AN EVEN NUMBER GREATER THAN 4 THAT HAS NO PRIME FACTOR
+C GREATER THAN 5. N IS THE LENGTH OF THE TRANSFORMS (SEE
+C THE DOCUMENTATION FOR FFT99 AND FFT991 FOR THE
+C DEFINITIONS OF THE TRANSFORMS).
+C
+C IFAX
+C AN INTEGER ARRAY. THE NUMBER OF ELEMENTS ACTUALLY USED
+C WILL DEPEND ON THE FACTORIZATION OF N. DIMENSIONING
+C IFAX FOR 13 SUFFICES FOR ALL N LESS THAN A MILLION.
+C
+C TRIGS
+C A FLOATING POINT ARRAY OF DIMENSION 3*N/2 IF N/2 IS
+C EVEN, OR 3*N/2+1 IF N/2 IS ODD.
+C
+C ON OUTPUT IFAX
+C CONTAINS THE FACTORIZATION OF N/2. IFAX(1) IS THE
+C NUMBER OF FACTORS, AND THE FACTORS THEMSELVES ARE STORED
+C IN IFAX(2),IFAX(3),... IF FFTFAX IS CALLED WITH N ODD,
+C OR IF N HAS ANY PRIME FACTORS GREATER THAN 5, IFAX(1)
+C IS SET TO -99.
+C
+C TRIGS
+C AN ARRAY OF TRIGNOMENTRIC FUNCTION VALUES SUBSEQUENTLY
+C USED BY THE FFT ROUTINES.
+C
+C-----------------------------------------------------------------------
+C
+C SUBROUTINE FFT991 (A,WORK,TRIGS,IFAX,INC,JUMP,N,M,ISIGN)
+C AND
+C SUBROUTINE FFT99 (A,WORK,TRIGS,IFAX,INC,JUMP,N,M,ISIGN)
+C
+C PURPOSE PERFORM A NUMBER OF SIMULTANEOUS REAL/HALF-COMPLEX
+C PERIODIC FOURIER TRANSFORMS OR CORRESPONDING INVERSE
+C TRANSFORMS, USING ORDINARY SPATIAL ORDER OF GRIDPOINT
+C VALUES (FFT991) OR EXPLICIT CYCLIC CONTINUITY IN THE
+C GRIDPOINT VALUES (FFT99). GIVEN A SET
+C OF REAL DATA VECTORS, THE PACKAGE RETURNS A SET OF
+C 'HALF-COMPLEX' FOURIER COEFFICIENT VECTORS, OR VICE
+C VERSA. THE LENGTH OF THE TRANSFORMS MUST BE AN EVEN
+C NUMBER THAT HAS NO OTHER FACTORS EXCEPT POSSIBLY POWERS
+C OF 2, 3, AND 5. THESE VERSION OF FFT991 AND FFT99 ARE
+C OPTIMIZED FOR USE ON THE CRAY-1.
+C
+C ARGUMENT A(M*(N+2)), WORK(M*(N+1)), TRIGS(3*N/2+1), IFAX(13)
+C DIMENSIONS
+C
+C ARGUMENTS
+C
+C ON INPUT A
+C AN ARRAY OF LENGTH M*(N+2) CONTAINING THE INPUT DATA
+C OR COEFFICIENT VECTORS. THIS ARRAY IS OVERWRITTEN BY
+C THE RESULTS.
+C
+C WORK
+C A WORK ARRAY OF DIMENSION M*(N+1)
+C
+C TRIGS
+C AN ARRAY SET UP BY FFTFAX, WHICH MUST BE CALLED FIRST.
+C
+C IFAX
+C AN ARRAY SET UP BY FFTFAX, WHICH MUST BE CALLED FIRST.
+C
+C INC
+C THE INCREMENT (IN WORDS) BETWEEN SUCCESSIVE ELEMENTS OF
+C EACH DATA OR COEFFICIENT VECTOR (E.G. INC=1 FOR
+C CONSECUTIVELY STORED DATA).
+C
+C JUMP
+C THE INCREMENT (IN WORDS) BETWEEN THE FIRST ELEMENTS OF
+C SUCCESSIVE DATA OR COEFFICIENT VECTORS. ON THE CRAY-1,
+C TRY TO ARRANGE DATA SO THAT JUMP IS NOT A MULTIPLE OF 8
+C (TO AVOID MEMORY BANK CONFLICTS). FOR CLARIFICATION OF
+C INC AND JUMP, SEE THE EXAMPLES BELOW.
+C
+C N
+C THE LENGTH OF EACH TRANSFORM (SEE DEFINITION OF
+C TRANSFORMS, BELOW).
+C
+C M
+C THE NUMBER OF TRANSFORMS TO BE DONE SIMULTANEOUSLY.
+C
+C ISIGN
+C = +1 FOR A TRANSFORM FROM FOURIER COEFFICIENTS TO
+C GRIDPOINT VALUES.
+C = -1 FOR A TRANSFORM FROM GRIDPOINT VALUES TO FOURIER
+C COEFFICIENTS.
+C
+C ON OUTPUT A
+C IF ISIGN = +1, AND M COEFFICIENT VECTORS ARE SUPPLIED
+C EACH CONTAINING THE SEQUENCE:
+C
+C A(0),B(0),A(1),B(1),...,A(N/2),B(N/2) (N+2 VALUES)
+C
+C THEN THE RESULT CONSISTS OF M DATA VECTORS EACH
+C CONTAINING THE CORRESPONDING N+2 GRIDPOINT VALUES:
+C
+C FOR FFT991, X(0), X(1), X(2),...,X(N-1),0,0.
+C FOR FFT99, X(N-1),X(0),X(1),X(2),...,X(N-1),X(0).
+C (EXPLICIT CYCLIC CONTINUITY)
+C
+C WHEN ISIGN = +1, THE TRANSFORM IS DEFINED BY:
+C X(J)=SUM(K=0,...,N-1)(C(K)*EXP(2*I*J*K*PI/N))
+C WHERE C(K)=A(K)+I*B(K) AND C(N-K)=A(K)-I*B(K)
+C AND I=SQRT (-1)
+C
+C IF ISIGN = -1, AND M DATA VECTORS ARE SUPPLIED EACH
+C CONTAINING A SEQUENCE OF GRIDPOINT VALUES X(J) AS
+C DEFINED ABOVE, THEN THE RESULT CONSISTS OF M VECTORS
+C EACH CONTAINING THE CORRESPONDING FOURIER COFFICIENTS
+C A(K), B(K), 0 .LE. K .LE N/2.
+C
+C WHEN ISIGN = -1, THE INVERSE TRANSFORM IS DEFINED BY:
+C C(K)=(1/N)*SUM(J=0,...,N-1)(X(J)*EXP(-2*I*J*K*PI/N))
+C WHERE C(K)=A(K)+I*B(K) AND I=SQRT(-1)
+C
+C A CALL WITH ISIGN=+1 FOLLOWED BY A CALL WITH ISIGN=-1
+C (OR VICE VERSA) RETURNS THE ORIGINAL DATA.
+C
+C NOTE: THE FACT THAT THE GRIDPOINT VALUES X(J) ARE REAL
+C IMPLIES THAT B(0)=B(N/2)=0. FOR A CALL WITH ISIGN=+1,
+C IT IS NOT ACTUALLY NECESSARY TO SUPPLY THESE ZEROS.
+C
+C EXAMPLES GIVEN 19 DATA VECTORS EACH OF LENGTH 64 (+2 FOR EXPLICIT
+C CYCLIC CONTINUITY), COMPUTE THE CORRESPONDING VECTORS OF
+C FOURIER COEFFICIENTS. THE DATA MAY, FOR EXAMPLE, BE
+C ARRANGED LIKE THIS:
+C
+C FIRST DATA A(1)= . . . A(66)= A(70)
+C VECTOR X(63) X(0) X(1) X(2) ... X(63) X(0) (4 EMPTY LOCATIONS)
+C
+C SECOND DATA A(71)= . . . A(140)
+C VECTOR X(63) X(0) X(1) X(2) ... X(63) X(0) (4 EMPTY LOCATIONS)
+C
+C AND SO ON. HERE INC=1, JUMP=70, N=64, M=19, ISIGN=-1,
+C AND FFT99 SHOULD BE USED (BECAUSE OF THE EXPLICIT CYCLIC
+C CONTINUITY).
+C
+C ALTERNATIVELY THE DATA MAY BE ARRANGED LIKE THIS:
+C
+C FIRST SECOND LAST
+C DATA DATA DATA
+C VECTOR VECTOR VECTOR
+C
+C A(1)= A(2)= A(19)=
+C
+C X(63) X(63) . . . X(63)
+C A(20)= X(0) X(0) . . . X(0)
+C A(39)= X(1) X(1) . . . X(1)
+C . . .
+C . . .
+C . . .
+C
+C IN WHICH CASE WE HAVE INC=19, JUMP=1, AND THE REMAINING
+C PARAMETERS ARE THE SAME AS BEFORE. IN EITHER CASE, EACH
+C COEFFICIENT VECTOR OVERWRITES THE CORRESPONDING INPUT
+C DATA VECTOR.
+C
+C-----------------------------------------------------------------------
+ DIMENSION A(N),WORK(N),TRIGS(N),IFAX(1)
+C
+C SUBROUTINE "FFT99" - MULTIPLE FAST REAL PERIODIC TRANSFORM
+C CORRESPONDING TO OLD SCALAR ROUTINE FFT9
+C PROCEDURE USED TO CONVERT TO HALF-LENGTH COMPLEX TRANSFORM
+C IS GIVEN BY COOLEY, LEWIS AND WELCH (J. SOUND VIB., VOL. 12
+C (1970), 315-337)
+C
+C A IS THE ARRAY CONTAINING INPUT AND OUTPUT DATA
+C WORK IS AN AREA OF SIZE (N+1)*LOT
+C TRIGS IS A PREVIOUSLY PREPARED LIST OF TRIG FUNCTION VALUES
+C IFAX IS A PREVIOUSLY PREPARED LIST OF FACTORS OF N/2
+C INC IS THE INCREMENT WITHIN EACH DATA 'VECTOR'
+C (E.G. INC=1 FOR CONSECUTIVELY STORED DATA)
+C JUMP IS THE INCREMENT BETWEEN THE START OF EACH DATA VECTOR
+C N IS THE LENGTH OF THE DATA VECTORS
+C LOT IS THE NUMBER OF DATA VECTORS
+C ISIGN = +1 FOR TRANSFORM FROM SPECTRAL TO GRIDPOINT
+C = -1 FOR TRANSFORM FROM GRIDPOINT TO SPECTRAL
+C
+C ORDERING OF COEFFICIENTS:
+C A(0),B(0),A(1),B(1),A(2),B(2),...,A(N/2),B(N/2)
+C WHERE B(0)=B(N/2)=0; (N+2) LOCATIONS REQUIRED
+C
+C ORDERING OF DATA:
+C X(N-1),X(0),X(1),X(2),...,X(N),X(0)
+C I.E. EXPLICIT CYCLIC CONTINUITY; (N+2) LOCATIONS REQUIRED
+C
+C VECTORIZATION IS ACHIEVED ON CRAY BY DOING THE TRANSFORMS IN
+C PARALLEL
+C
+C *** N.B. N IS ASSUMED TO BE AN EVEN NUMBER
+C
+C DEFINITION OF TRANSFORMS:
+C -------------------------
+C
+C ISIGN=+1: X(J)=SUM(K=0,...,N-1)(C(K)*EXP(2*I*J*K*PI/N))
+C WHERE C(K)=A(K)+I*B(K) AND C(N-K)=A(K)-I*B(K)
+C
+C ISIGN=-1: A(K)=(1/N)*SUM(J=0,...,N-1)(X(J)*COS(2*J*K*PI/N))
+C B(K)=-(1/N)*SUM(J=0,...,N-1)(X(J)*SIN(2*J*K*PI/N))
+C
+C
+C THE FOLLOWING CALL IS FOR MONITORING LIBRARY USE AT NCAR
+C CALL Q8QST4 ( 4HXLIB, 6HFFT99F, 5HFFT99, 10HVERSION 01)
+ NFAX=IFAX(1)
+ NX=N+1
+ NH=N/2
+ INK=INC+INC
+ IF (ISIGN.EQ.+1) GO TO 30
+C
+C IF NECESSARY, TRANSFER DATA TO WORK AREA
+ IGO=50
+ IF (MOD(NFAX,2).EQ.1) GOTO 40
+ IBASE=INC+1
+ JBASE=1
+ DO 20 L=1,LOT
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 10 M=1,N
+ WORK(J)=A(I)
+ I=I+INC
+ J=J+1
+ 10 CONTINUE
+ IBASE=IBASE+JUMP
+ JBASE=JBASE+NX
+ 20 CONTINUE
+C
+ IGO=60
+ GO TO 40
+C
+C PREPROCESSING (ISIGN=+1)
+C ------------------------
+C
+ 30 CONTINUE
+ CALL FFT99A(A,WORK,TRIGS,INC,JUMP,N,LOT)
+ IGO=60
+C
+C COMPLEX TRANSFORM
+C -----------------
+C
+ 40 CONTINUE
+ IA=INC+1
+ LA=1
+ DO 80 K=1,NFAX
+ IF (IGO.EQ.60) GO TO 60
+ 50 CONTINUE
+ CALL VPASSM(A(IA),A(IA+INC),WORK(1),WORK(2),TRIGS,
+ * INK,2,JUMP,NX,LOT,NH,IFAX(K+1),LA)
+ IGO=60
+ GO TO 70
+ 60 CONTINUE
+ CALL VPASSM(WORK(1),WORK(2),A(IA),A(IA+INC),TRIGS,
+ * 2,INK,NX,JUMP,LOT,NH,IFAX(K+1),LA)
+ IGO=50
+ 70 CONTINUE
+ LA=LA*IFAX(K+1)
+ 80 CONTINUE
+C
+ IF (ISIGN.EQ.-1) GO TO 130
+C
+C IF NECESSARY, TRANSFER DATA FROM WORK AREA
+ IF (MOD(NFAX,2).EQ.1) GO TO 110
+ IBASE=1
+ JBASE=IA
+ DO 100 L=1,LOT
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 90 M=1,N
+ A(J)=WORK(I)
+ I=I+1
+ J=J+INC
+ 90 CONTINUE
+ IBASE=IBASE+NX
+ JBASE=JBASE+JUMP
+ 100 CONTINUE
+C
+C FILL IN CYCLIC BOUNDARY POINTS
+ 110 CONTINUE
+ IA=1
+ IB=N*INC+1
+CDIR$ IVDEP
+ DO 120 L=1,LOT
+ A(IA)=A(IB)
+ A(IB+INC)=A(IA+INC)
+ IA=IA+JUMP
+ IB=IB+JUMP
+ 120 CONTINUE
+ GO TO 140
+C
+C POSTPROCESSING (ISIGN=-1):
+C --------------------------
+C
+ 130 CONTINUE
+ CALL FFT99B(WORK,A,TRIGS,INC,JUMP,N,LOT)
+C
+ 140 CONTINUE
+ RETURN
+ END
+ SUBROUTINE FFT99A(A,WORK,TRIGS,INC,JUMP,N,LOT)
+ DIMENSION A(N),WORK(N),TRIGS(N)
+C
+C SUBROUTINE FFT99A - PREPROCESSING STEP FOR FFT99, ISIGN=+1
+C (SPECTRAL TO GRIDPOINT TRANSFORM)
+C
+ NH=N/2
+ NX=N+1
+ INK=INC+INC
+C
+C A(0) AND A(N/2)
+ IA=1
+ IB=N*INC+1
+ JA=1
+ JB=2
+CDIR$ IVDEP
+ DO 10 L=1,LOT
+ WORK(JA)=A(IA)+A(IB)
+ WORK(JB)=A(IA)-A(IB)
+ IA=IA+JUMP
+ IB=IB+JUMP
+ JA=JA+NX
+ JB=JB+NX
+ 10 CONTINUE
+C
+C REMAINING WAVENUMBERS
+ IABASE=2*INC+1
+ IBBASE=(N-2)*INC+1
+ JABASE=3
+ JBBASE=N-1
+C
+ DO 30 K=3,NH,2
+ IA=IABASE
+ IB=IBBASE
+ JA=JABASE
+ JB=JBBASE
+ C=TRIGS(N+K)
+ S=TRIGS(N+K+1)
+CDIR$ IVDEP
+ DO 20 L=1,LOT
+ WORK(JA)=(A(IA)+A(IB))-
+ * (S*(A(IA)-A(IB))+C*(A(IA+INC)+A(IB+INC)))
+ WORK(JB)=(A(IA)+A(IB))+
+ * (S*(A(IA)-A(IB))+C*(A(IA+INC)+A(IB+INC)))
+ WORK(JA+1)=(C*(A(IA)-A(IB))-S*(A(IA+INC)+A(IB+INC)))+
+ * (A(IA+INC)-A(IB+INC))
+ WORK(JB+1)=(C*(A(IA)-A(IB))-S*(A(IA+INC)+A(IB+INC)))-
+ * (A(IA+INC)-A(IB+INC))
+ IA=IA+JUMP
+ IB=IB+JUMP
+ JA=JA+NX
+ JB=JB+NX
+ 20 CONTINUE
+ IABASE=IABASE+INK
+ IBBASE=IBBASE-INK
+ JABASE=JABASE+2
+ JBBASE=JBBASE-2
+ 30 CONTINUE
+C
+ IF (IABASE.NE.IBBASE) GO TO 50
+C WAVENUMBER N/4 (IF IT EXISTS)
+ IA=IABASE
+ JA=JABASE
+CDIR$ IVDEP
+ DO 40 L=1,LOT
+ WORK(JA)=2.0*A(IA)
+ WORK(JA+1)=-2.0*A(IA+INC)
+ IA=IA+JUMP
+ JA=JA+NX
+ 40 CONTINUE
+C
+ 50 CONTINUE
+ RETURN
+ END
+ SUBROUTINE FFT99B(WORK,A,TRIGS,INC,JUMP,N,LOT)
+ DIMENSION WORK(N),A(N),TRIGS(N)
+C
+C SUBROUTINE FFT99B - POSTPROCESSING STEP FOR FFT99, ISIGN=-1
+C (GRIDPOINT TO SPECTRAL TRANSFORM)
+C
+ NH=N/2
+ NX=N+1
+ INK=INC+INC
+C
+C A(0) AND A(N/2)
+ SCALE=1.0/FLOAT(N)
+ IA=1
+ IB=2
+ JA=1
+ JB=N*INC+1
+CDIR$ IVDEP
+ DO 10 L=1,LOT
+ A(JA)=SCALE*(WORK(IA)+WORK(IB))
+ A(JB)=SCALE*(WORK(IA)-WORK(IB))
+ A(JA+INC)=0.0
+ A(JB+INC)=0.0
+ IA=IA+NX
+ IB=IB+NX
+ JA=JA+JUMP
+ JB=JB+JUMP
+ 10 CONTINUE
+C
+C REMAINING WAVENUMBERS
+ SCALE=0.5*SCALE
+ IABASE=3
+ IBBASE=N-1
+ JABASE=2*INC+1
+ JBBASE=(N-2)*INC+1
+C
+ DO 30 K=3,NH,2
+ IA=IABASE
+ IB=IBBASE
+ JA=JABASE
+ JB=JBBASE
+ C=TRIGS(N+K)
+ S=TRIGS(N+K+1)
+CDIR$ IVDEP
+ DO 20 L=1,LOT
+ A(JA)=SCALE*((WORK(IA)+WORK(IB))
+ * +(C*(WORK(IA+1)+WORK(IB+1))+S*(WORK(IA)-WORK(IB))))
+ A(JB)=SCALE*((WORK(IA)+WORK(IB))
+ * -(C*(WORK(IA+1)+WORK(IB+1))+S*(WORK(IA)-WORK(IB))))
+ A(JA+INC)=SCALE*((C*(WORK(IA)-WORK(IB))-S*(WORK(IA+1)+WORK(IB+1)))
+ * +(WORK(IB+1)-WORK(IA+1)))
+ A(JB+INC)=SCALE*((C*(WORK(IA)-WORK(IB))-S*(WORK(IA+1)+WORK(IB+1)))
+ * -(WORK(IB+1)-WORK(IA+1)))
+ IA=IA+NX
+ IB=IB+NX
+ JA=JA+JUMP
+ JB=JB+JUMP
+ 20 CONTINUE
+ IABASE=IABASE+2
+ IBBASE=IBBASE-2
+ JABASE=JABASE+INK
+ JBBASE=JBBASE-INK
+ 30 CONTINUE
+C
+ IF (IABASE.NE.IBBASE) GO TO 50
+C WAVENUMBER N/4 (IF IT EXISTS)
+ IA=IABASE
+ JA=JABASE
+ SCALE=2.0*SCALE
+CDIR$ IVDEP
+ DO 40 L=1,LOT
+ A(JA)=SCALE*WORK(IA)
+ A(JA+INC)=-SCALE*WORK(IA+1)
+ IA=IA+NX
+ JA=JA+JUMP
+ 40 CONTINUE
+C
+ 50 CONTINUE
+ RETURN
+ END
+ SUBROUTINE FFT991(A,WORK,TRIGS,IFAX,INC,JUMP,N,LOT,ISIGN)
+ DIMENSION A(N),WORK(N),TRIGS(N),IFAX(1)
+C
+C SUBROUTINE "FFT991" - MULTIPLE REAL/HALF-COMPLEX PERIODIC
+C FAST FOURIER TRANSFORM
+C
+C SAME AS FFT99 EXCEPT THAT ORDERING OF DATA CORRESPONDS TO
+C THAT IN MRFFT2
+C
+C PROCEDURE USED TO CONVERT TO HALF-LENGTH COMPLEX TRANSFORM
+C IS GIVEN BY COOLEY, LEWIS AND WELCH (J. SOUND VIB., VOL. 12
+C (1970), 315-337)
+C
+C A IS THE ARRAY CONTAINING INPUT AND OUTPUT DATA
+C WORK IS AN AREA OF SIZE (N+1)*LOT
+C TRIGS IS A PREVIOUSLY PREPARED LIST OF TRIG FUNCTION VALUES
+C IFAX IS A PREVIOUSLY PREPARED LIST OF FACTORS OF N/2
+C INC IS THE INCREMENT WITHIN EACH DATA 'VECTOR'
+C (E.G. INC=1 FOR CONSECUTIVELY STORED DATA)
+C JUMP IS THE INCREMENT BETWEEN THE START OF EACH DATA VECTOR
+C N IS THE LENGTH OF THE DATA VECTORS
+C LOT IS THE NUMBER OF DATA VECTORS
+C ISIGN = +1 FOR TRANSFORM FROM SPECTRAL TO GRIDPOINT
+C = -1 FOR TRANSFORM FROM GRIDPOINT TO SPECTRAL
+C
+C ORDERING OF COEFFICIENTS:
+C A(0),B(0),A(1),B(1),A(2),B(2),...,A(N/2),B(N/2)
+C WHERE B(0)=B(N/2)=0; (N+2) LOCATIONS REQUIRED
+C
+C ORDERING OF DATA:
+C X(0),X(1),X(2),...,X(N-1)
+C
+C VECTORIZATION IS ACHIEVED ON CRAY BY DOING THE TRANSFORMS IN
+C PARALLEL
+C
+C *** N.B. N IS ASSUMED TO BE AN EVEN NUMBER
+C
+C DEFINITION OF TRANSFORMS:
+C -------------------------
+C
+C ISIGN=+1: X(J)=SUM(K=0,...,N-1)(C(K)*EXP(2*I*J*K*PI/N))
+C WHERE C(K)=A(K)+I*B(K) AND C(N-K)=A(K)-I*B(K)
+C
+C ISIGN=-1: A(K)=(1/N)*SUM(J=0,...,N-1)(X(J)*COS(2*J*K*PI/N))
+C B(K)=-(1/N)*SUM(J=0,...,N-1)(X(J)*SIN(2*J*K*PI/N))
+C
+C THE FOLLOWING CALL IS FOR MONITORING LIBRARY USE AT NCAR
+C CALL Q8QST4 ( 4HXLIB, 6HFFT99F, 6HFFT991, 10HVERSION 01)
+ NFAX=IFAX(1)
+ NX=N+1
+ NH=N/2
+ INK=INC+INC
+ IF (ISIGN.EQ.+1) GO TO 30
+C
+C IF NECESSARY, TRANSFER DATA TO WORK AREA
+ IGO=50
+ IF (MOD(NFAX,2).EQ.1) GOTO 40
+ IBASE=1
+ JBASE=1
+ DO 20 L=1,LOT
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 10 M=1,N
+ WORK(J)=A(I)
+ I=I+INC
+ J=J+1
+ 10 CONTINUE
+ IBASE=IBASE+JUMP
+ JBASE=JBASE+NX
+ 20 CONTINUE
+C
+ IGO=60
+ GO TO 40
+C
+C PREPROCESSING (ISIGN=+1)
+C ------------------------
+C
+ 30 CONTINUE
+ CALL FFT99A(A,WORK,TRIGS,INC,JUMP,N,LOT)
+ IGO=60
+C
+C COMPLEX TRANSFORM
+C -----------------
+C
+ 40 CONTINUE
+ IA=1
+ LA=1
+ DO 80 K=1,NFAX
+ IF (IGO.EQ.60) GO TO 60
+ 50 CONTINUE
+ CALL VPASSM(A(IA),A(IA+INC),WORK(1),WORK(2),TRIGS,
+ * INK,2,JUMP,NX,LOT,NH,IFAX(K+1),LA)
+ IGO=60
+ GO TO 70
+ 60 CONTINUE
+ CALL VPASSM(WORK(1),WORK(2),A(IA),A(IA+INC),TRIGS,
+ * 2,INK,NX,JUMP,LOT,NH,IFAX(K+1),LA)
+ IGO=50
+ 70 CONTINUE
+ LA=LA*IFAX(K+1)
+ 80 CONTINUE
+C
+ IF (ISIGN.EQ.-1) GO TO 130
+C
+C IF NECESSARY, TRANSFER DATA FROM WORK AREA
+ IF (MOD(NFAX,2).EQ.1) GO TO 110
+ IBASE=1
+ JBASE=1
+ DO 100 L=1,LOT
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 90 M=1,N
+ A(J)=WORK(I)
+ I=I+1
+ J=J+INC
+ 90 CONTINUE
+ IBASE=IBASE+NX
+ JBASE=JBASE+JUMP
+ 100 CONTINUE
+C
+C FILL IN ZEROS AT END
+ 110 CONTINUE
+ IB=N*INC+1
+CDIR$ IVDEP
+ DO 120 L=1,LOT
+ A(IB)=0.0
+ A(IB+INC)=0.0
+ IB=IB+JUMP
+ 120 CONTINUE
+ GO TO 140
+C
+C POSTPROCESSING (ISIGN=-1):
+C --------------------------
+C
+ 130 CONTINUE
+ CALL FFT99B(WORK,A,TRIGS,INC,JUMP,N,LOT)
+C
+ 140 CONTINUE
+ RETURN
+ END
+ SUBROUTINE FFTFAX(N,IFAX,TRIGS)
+ DIMENSION IFAX(13),TRIGS(1)
+C
+C MODE 3 IS USED FOR REAL/HALF-COMPLEX TRANSFORMS. IT IS POSSIBLE
+C TO DO COMPLEX/COMPLEX TRANSFORMS WITH OTHER VALUES OF MODE, BUT
+C DOCUMENTATION OF THE DETAILS WERE NOT AVAILABLE WHEN THIS ROUTINE
+C WAS WRITTEN.
+C
+ DATA MODE /3/
+ CALL FAX (IFAX, N, MODE)
+ I = IFAX(1)
+ IF (IFAX(I+1) .GT. 5 .OR. N .LE. 4) IFAX(1) = -99
+ IF (IFAX(1) .LE. 0 ) WRITE(6,1) N
+ IF (IFAX(1) .LE. 0 ) STOP 999
+ CALL FFTRIG (TRIGS, N, MODE)
+ 1 FORMAT(//5X, ' FFTFAX -- INVALID N =', I5,/)
+ RETURN
+ END
+ SUBROUTINE FAX(IFAX,N,MODE)
+ DIMENSION IFAX(10)
+ NN=N
+ IF (IABS(MODE).EQ.1) GO TO 10
+ IF (IABS(MODE).EQ.8) GO TO 10
+ NN=N/2
+ IF ((NN+NN).EQ.N) GO TO 10
+ IFAX(1)=-99
+ RETURN
+ 10 K=1
+C TEST FOR FACTORS OF 4
+ 20 IF (MOD(NN,4).NE.0) GO TO 30
+ K=K+1
+ IFAX(K)=4
+ NN=NN/4
+ IF (NN.EQ.1) GO TO 80
+ GO TO 20
+C TEST FOR EXTRA FACTOR OF 2
+ 30 IF (MOD(NN,2).NE.0) GO TO 40
+ K=K+1
+ IFAX(K)=2
+ NN=NN/2
+ IF (NN.EQ.1) GO TO 80
+C TEST FOR FACTORS OF 3
+ 40 IF (MOD(NN,3).NE.0) GO TO 50
+ K=K+1
+ IFAX(K)=3
+ NN=NN/3
+ IF (NN.EQ.1) GO TO 80
+ GO TO 40
+C NOW FIND REMAINING FACTORS
+ 50 L=5
+ INC=2
+C INC ALTERNATELY TAKES ON VALUES 2 AND 4
+ 60 IF (MOD(NN,L).NE.0) GO TO 70
+ K=K+1
+ IFAX(K)=L
+ NN=NN/L
+ IF (NN.EQ.1) GO TO 80
+ GO TO 60
+ 70 L=L+INC
+ INC=6-INC
+ GO TO 60
+ 80 IFAX(1)=K-1
+C IFAX(1) CONTAINS NUMBER OF FACTORS
+ NFAX=IFAX(1)
+C SORT FACTORS INTO ASCENDING ORDER
+ IF (NFAX.EQ.1) GO TO 110
+ DO 100 II=2,NFAX
+ ISTOP=NFAX+2-II
+ DO 90 I=2,ISTOP
+ IF (IFAX(I+1).GE.IFAX(I)) GO TO 90
+ ITEM=IFAX(I)
+ IFAX(I)=IFAX(I+1)
+ IFAX(I+1)=ITEM
+ 90 CONTINUE
+ 100 CONTINUE
+ 110 CONTINUE
+ RETURN
+ END
+ SUBROUTINE FFTRIG(TRIGS,N,MODE)
+ DIMENSION TRIGS(1)
+ PI=2.0*ASIN(1.0)
+ IMODE=IABS(MODE)
+ NN=N
+ IF (IMODE.GT.1.AND.IMODE.LT.6) NN=N/2
+ DEL=(PI+PI)/FLOAT(NN)
+ L=NN+NN
+ DO 10 I=1,L,2
+ ANGLE=0.5*FLOAT(I-1)*DEL
+ TRIGS(I)=COS(ANGLE)
+ TRIGS(I+1)=SIN(ANGLE)
+ 10 CONTINUE
+ IF (IMODE.EQ.1) RETURN
+ IF (IMODE.EQ.8) RETURN
+ DEL=0.5*DEL
+ NH=(NN+1)/2
+ L=NH+NH
+ LA=NN+NN
+ DO 20 I=1,L,2
+ ANGLE=0.5*FLOAT(I-1)*DEL
+ TRIGS(LA+I)=COS(ANGLE)
+ TRIGS(LA+I+1)=SIN(ANGLE)
+ 20 CONTINUE
+ IF (IMODE.LE.3) RETURN
+ DEL=0.5*DEL
+ LA=LA+NN
+ IF (MODE.EQ.5) GO TO 40
+ DO 30 I=2,NN
+ ANGLE=FLOAT(I-1)*DEL
+ TRIGS(LA+I)=2.0*SIN(ANGLE)
+ 30 CONTINUE
+ RETURN
+ 40 CONTINUE
+ DEL=0.5*DEL
+ DO 50 I=2,N
+ ANGLE=FLOAT(I-1)*DEL
+ TRIGS(LA+I)=SIN(ANGLE)
+ 50 CONTINUE
+ RETURN
+ END
+ SUBROUTINE VPASSM(A,B,C,D,TRIGS,INC1,INC2,INC3,INC4,LOT,N,IFAC,LA)
+ DIMENSION A(N),B(N),C(N),D(N),TRIGS(N)
+C
+C SUBROUTINE "VPASSM" - MULTIPLE VERSION OF "VPASSA"
+C PERFORMS ONE PASS THROUGH DATA
+C AS PART OF MULTIPLE COMPLEX FFT ROUTINE
+C A IS FIRST REAL INPUT VECTOR
+C B IS FIRST IMAGINARY INPUT VECTOR
+C C IS FIRST REAL OUTPUT VECTOR
+C D IS FIRST IMAGINARY OUTPUT VECTOR
+C TRIGS IS PRECALCULATED TABLE OF SINES " COSINES
+C INC1 IS ADDRESSING INCREMENT FOR A AND B
+C INC2 IS ADDRESSING INCREMENT FOR C AND D
+C INC3 IS ADDRESSING INCREMENT BETWEEN A"S & B"S
+C INC4 IS ADDRESSING INCREMENT BETWEEN C"S & D"S
+C LOT IS THE NUMBER OF VECTORS
+C N IS LENGTH OF VECTORS
+C IFAC IS CURRENT FACTOR OF N
+C LA IS PRODUCT OF PREVIOUS FACTORS
+C
+ DATA SIN36/0.587785252292473/,COS36/0.809016994374947/,
+ * SIN72/0.951056516295154/,COS72/0.309016994374947/,
+ * SIN60/0.866025403784437/
+C
+ M=N/IFAC
+ IINK=M*INC1
+ JINK=LA*INC2
+ JUMP=(IFAC-1)*JINK
+ IBASE=0
+ JBASE=0
+ IGO=IFAC-1
+ IF (IGO.GT.4) RETURN
+ GO TO (10,50,90,130),IGO
+C
+C CODING FOR FACTOR 2
+C
+ 10 IA=1
+ JA=1
+ IB=IA+IINK
+ JB=JA+JINK
+ DO 20 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 15 IJK=1,LOT
+ C(JA+J)=A(IA+I)+A(IB+I)
+ D(JA+J)=B(IA+I)+B(IB+I)
+ C(JB+J)=A(IA+I)-A(IB+I)
+ D(JB+J)=B(IA+I)-B(IB+I)
+ I=I+INC3
+ J=J+INC4
+ 15 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 20 CONTINUE
+ IF (LA.EQ.M) RETURN
+ LA1=LA+1
+ JBASE=JBASE+JUMP
+ DO 40 K=LA1,M,LA
+ KB=K+K-2
+ C1=TRIGS(KB+1)
+ S1=TRIGS(KB+2)
+ DO 30 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 25 IJK=1,LOT
+ C(JA+J)=A(IA+I)+A(IB+I)
+ D(JA+J)=B(IA+I)+B(IB+I)
+ C(JB+J)=C1*(A(IA+I)-A(IB+I))-S1*(B(IA+I)-B(IB+I))
+ D(JB+J)=S1*(A(IA+I)-A(IB+I))+C1*(B(IA+I)-B(IB+I))
+ I=I+INC3
+ J=J+INC4
+ 25 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 30 CONTINUE
+ JBASE=JBASE+JUMP
+ 40 CONTINUE
+ RETURN
+C
+C CODING FOR FACTOR 3
+C
+ 50 IA=1
+ JA=1
+ IB=IA+IINK
+ JB=JA+JINK
+ IC=IB+IINK
+ JC=JB+JINK
+ DO 60 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 55 IJK=1,LOT
+ C(JA+J)=A(IA+I)+(A(IB+I)+A(IC+I))
+ D(JA+J)=B(IA+I)+(B(IB+I)+B(IC+I))
+ C(JB+J)=(A(IA+I)-0.5*(A(IB+I)+A(IC+I)))-(SIN60*(B(IB+I)-B(IC+I)))
+ C(JC+J)=(A(IA+I)-0.5*(A(IB+I)+A(IC+I)))+(SIN60*(B(IB+I)-B(IC+I)))
+ D(JB+J)=(B(IA+I)-0.5*(B(IB+I)+B(IC+I)))+(SIN60*(A(IB+I)-A(IC+I)))
+ D(JC+J)=(B(IA+I)-0.5*(B(IB+I)+B(IC+I)))-(SIN60*(A(IB+I)-A(IC+I)))
+ I=I+INC3
+ J=J+INC4
+ 55 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 60 CONTINUE
+ IF (LA.EQ.M) RETURN
+ LA1=LA+1
+ JBASE=JBASE+JUMP
+ DO 80 K=LA1,M,LA
+ KB=K+K-2
+ KC=KB+KB
+ C1=TRIGS(KB+1)
+ S1=TRIGS(KB+2)
+ C2=TRIGS(KC+1)
+ S2=TRIGS(KC+2)
+ DO 70 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 65 IJK=1,LOT
+ C(JA+J)=A(IA+I)+(A(IB+I)+A(IC+I))
+ D(JA+J)=B(IA+I)+(B(IB+I)+B(IC+I))
+ C(JB+J)=
+ * C1*((A(IA+I)-0.5*(A(IB+I)+A(IC+I)))-(SIN60*(B(IB+I)-B(IC+I))))
+ * -S1*((B(IA+I)-0.5*(B(IB+I)+B(IC+I)))+(SIN60*(A(IB+I)-A(IC+I))))
+ D(JB+J)=
+ * S1*((A(IA+I)-0.5*(A(IB+I)+A(IC+I)))-(SIN60*(B(IB+I)-B(IC+I))))
+ * +C1*((B(IA+I)-0.5*(B(IB+I)+B(IC+I)))+(SIN60*(A(IB+I)-A(IC+I))))
+ C(JC+J)=
+ * C2*((A(IA+I)-0.5*(A(IB+I)+A(IC+I)))+(SIN60*(B(IB+I)-B(IC+I))))
+ * -S2*((B(IA+I)-0.5*(B(IB+I)+B(IC+I)))-(SIN60*(A(IB+I)-A(IC+I))))
+ D(JC+J)=
+ * S2*((A(IA+I)-0.5*(A(IB+I)+A(IC+I)))+(SIN60*(B(IB+I)-B(IC+I))))
+ * +C2*((B(IA+I)-0.5*(B(IB+I)+B(IC+I)))-(SIN60*(A(IB+I)-A(IC+I))))
+ I=I+INC3
+ J=J+INC4
+ 65 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 70 CONTINUE
+ JBASE=JBASE+JUMP
+ 80 CONTINUE
+ RETURN
+C
+C CODING FOR FACTOR 4
+C
+ 90 IA=1
+ JA=1
+ IB=IA+IINK
+ JB=JA+JINK
+ IC=IB+IINK
+ JC=JB+JINK
+ ID=IC+IINK
+ JD=JC+JINK
+ DO 100 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 95 IJK=1,LOT
+ C(JA+J)=(A(IA+I)+A(IC+I))+(A(IB+I)+A(ID+I))
+ C(JC+J)=(A(IA+I)+A(IC+I))-(A(IB+I)+A(ID+I))
+ D(JA+J)=(B(IA+I)+B(IC+I))+(B(IB+I)+B(ID+I))
+ D(JC+J)=(B(IA+I)+B(IC+I))-(B(IB+I)+B(ID+I))
+ C(JB+J)=(A(IA+I)-A(IC+I))-(B(IB+I)-B(ID+I))
+ C(JD+J)=(A(IA+I)-A(IC+I))+(B(IB+I)-B(ID+I))
+ D(JB+J)=(B(IA+I)-B(IC+I))+(A(IB+I)-A(ID+I))
+ D(JD+J)=(B(IA+I)-B(IC+I))-(A(IB+I)-A(ID+I))
+ I=I+INC3
+ J=J+INC4
+ 95 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 100 CONTINUE
+ IF (LA.EQ.M) RETURN
+ LA1=LA+1
+ JBASE=JBASE+JUMP
+ DO 120 K=LA1,M,LA
+ KB=K+K-2
+ KC=KB+KB
+ KD=KC+KB
+ C1=TRIGS(KB+1)
+ S1=TRIGS(KB+2)
+ C2=TRIGS(KC+1)
+ S2=TRIGS(KC+2)
+ C3=TRIGS(KD+1)
+ S3=TRIGS(KD+2)
+ DO 110 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 105 IJK=1,LOT
+ C(JA+J)=(A(IA+I)+A(IC+I))+(A(IB+I)+A(ID+I))
+ D(JA+J)=(B(IA+I)+B(IC+I))+(B(IB+I)+B(ID+I))
+ C(JC+J)=
+ * C2*((A(IA+I)+A(IC+I))-(A(IB+I)+A(ID+I)))
+ * -S2*((B(IA+I)+B(IC+I))-(B(IB+I)+B(ID+I)))
+ D(JC+J)=
+ * S2*((A(IA+I)+A(IC+I))-(A(IB+I)+A(ID+I)))
+ * +C2*((B(IA+I)+B(IC+I))-(B(IB+I)+B(ID+I)))
+ C(JB+J)=
+ * C1*((A(IA+I)-A(IC+I))-(B(IB+I)-B(ID+I)))
+ * -S1*((B(IA+I)-B(IC+I))+(A(IB+I)-A(ID+I)))
+ D(JB+J)=
+ * S1*((A(IA+I)-A(IC+I))-(B(IB+I)-B(ID+I)))
+ * +C1*((B(IA+I)-B(IC+I))+(A(IB+I)-A(ID+I)))
+ C(JD+J)=
+ * C3*((A(IA+I)-A(IC+I))+(B(IB+I)-B(ID+I)))
+ * -S3*((B(IA+I)-B(IC+I))-(A(IB+I)-A(ID+I)))
+ D(JD+J)=
+ * S3*((A(IA+I)-A(IC+I))+(B(IB+I)-B(ID+I)))
+ * +C3*((B(IA+I)-B(IC+I))-(A(IB+I)-A(ID+I)))
+ I=I+INC3
+ J=J+INC4
+ 105 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 110 CONTINUE
+ JBASE=JBASE+JUMP
+ 120 CONTINUE
+ RETURN
+C
+C CODING FOR FACTOR 5
+C
+ 130 IA=1
+ JA=1
+ IB=IA+IINK
+ JB=JA+JINK
+ IC=IB+IINK
+ JC=JB+JINK
+ ID=IC+IINK
+ JD=JC+JINK
+ IE=ID+IINK
+ JE=JD+JINK
+ DO 140 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 135 IJK=1,LOT
+ C(JA+J)=A(IA+I)+(A(IB+I)+A(IE+I))+(A(IC+I)+A(ID+I))
+ D(JA+J)=B(IA+I)+(B(IB+I)+B(IE+I))+(B(IC+I)+B(ID+I))
+ C(JB+J)=(A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * -(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I)))
+ C(JE+J)=(A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * +(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I)))
+ D(JB+J)=(B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * +(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I)))
+ D(JE+J)=(B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * -(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I)))
+ C(JC+J)=(A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * -(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I)))
+ C(JD+J)=(A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * +(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I)))
+ D(JC+J)=(B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * +(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I)))
+ D(JD+J)=(B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * -(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I)))
+ I=I+INC3
+ J=J+INC4
+ 135 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 140 CONTINUE
+ IF (LA.EQ.M) RETURN
+ LA1=LA+1
+ JBASE=JBASE+JUMP
+ DO 160 K=LA1,M,LA
+ KB=K+K-2
+ KC=KB+KB
+ KD=KC+KB
+ KE=KD+KB
+ C1=TRIGS(KB+1)
+ S1=TRIGS(KB+2)
+ C2=TRIGS(KC+1)
+ S2=TRIGS(KC+2)
+ C3=TRIGS(KD+1)
+ S3=TRIGS(KD+2)
+ C4=TRIGS(KE+1)
+ S4=TRIGS(KE+2)
+ DO 150 L=1,LA
+ I=IBASE
+ J=JBASE
+CDIR$ IVDEP
+ DO 145 IJK=1,LOT
+ C(JA+J)=A(IA+I)+(A(IB+I)+A(IE+I))+(A(IC+I)+A(ID+I))
+ D(JA+J)=B(IA+I)+(B(IB+I)+B(IE+I))+(B(IC+I)+B(ID+I))
+ C(JB+J)=
+ * C1*((A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * -(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I))))
+ * -S1*((B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * +(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I))))
+ D(JB+J)=
+ * S1*((A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * -(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I))))
+ * +C1*((B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * +(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I))))
+ C(JE+J)=
+ * C4*((A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * +(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I))))
+ * -S4*((B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * -(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I))))
+ D(JE+J)=
+ * S4*((A(IA+I)+COS72*(A(IB+I)+A(IE+I))-COS36*(A(IC+I)+A(ID+I)))
+ * +(SIN72*(B(IB+I)-B(IE+I))+SIN36*(B(IC+I)-B(ID+I))))
+ * +C4*((B(IA+I)+COS72*(B(IB+I)+B(IE+I))-COS36*(B(IC+I)+B(ID+I)))
+ * -(SIN72*(A(IB+I)-A(IE+I))+SIN36*(A(IC+I)-A(ID+I))))
+ C(JC+J)=
+ * C2*((A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * -(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I))))
+ * -S2*((B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * +(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I))))
+ D(JC+J)=
+ * S2*((A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * -(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I))))
+ * +C2*((B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * +(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I))))
+ C(JD+J)=
+ * C3*((A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * +(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I))))
+ * -S3*((B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * -(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I))))
+ D(JD+J)=
+ * S3*((A(IA+I)-COS36*(A(IB+I)+A(IE+I))+COS72*(A(IC+I)+A(ID+I)))
+ * +(SIN36*(B(IB+I)-B(IE+I))-SIN72*(B(IC+I)-B(ID+I))))
+ * +C3*((B(IA+I)-COS36*(B(IB+I)+B(IE+I))+COS72*(B(IC+I)+B(ID+I)))
+ * -(SIN36*(A(IB+I)-A(IE+I))-SIN72*(A(IC+I)-A(ID+I))))
+ I=I+INC3
+ J=J+INC4
+ 145 CONTINUE
+ IBASE=IBASE+INC1
+ JBASE=JBASE+INC2
+ 150 CONTINUE
+ JBASE=JBASE+JUMP
+ 160 CONTINUE
+ RETURN
+ END
+C ALTERNATE NAME
+ SUBROUTINE RFFTMLT(A,WORK,TRIGS,IFAX,INC,JUMP,N,LOT,ISIGN)
+ DIMENSION A(N),WORK(N),TRIGS(N),IFAX(1)
+ CALL FFT991(A,WORK,TRIGS,IFAX,INC,JUMP,N,LOT,ISIGN)
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/landcmsk.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/landcmsk.f
new file mode 100644
index 000000000..19298a4df
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/landcmsk.f
@@ -0,0 +1,39 @@
+ subroutine landcmsk(IK,JK,GLON,GLAT,ZDATG,IFLAG,lsflag,kst)
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c
+cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
+c parameter (IK=384,JK=190,ijdim=IK*JK,NSG=2000,NST=10)
+ parameter (NSG=50000,NST=10)
+ DIMENSION ZDATG(IK,JK),GLON(IK,JK),GLAT(IK,JK)
+ DIMENSION ING(NSG),JNG(NSG)
+ CHARACTER ST_NAME(NST)*3
+ COMMON /TR/ING,JNG,IB
+ COMMON /NHC2/MDX,MDY
+ COMMON /NHC3/AMDX,AMDY
+ COMMON /STNAME/ST_NAME
+ COMMON /CHEN/KUNIT,ITIM
+c
+ lsflag = 1
+
+ DO I = 1,IB
+ IW = ING(I)
+ JW = JNG(I)
+ IF(ZDATG(IW,JW).gt.500.)then
+ iflag = 1
+cnew MDX=0
+cnew MDY=0
+cnew AMDX=0.
+cnew AMDY=0.
+ print*,' Filter domain topography height > 500 m'
+ 1 ,', storm name = ', ST_NAME(KST),
+ 2 ', forecast time = ',ITIM,'h',
+ 3 ', only wind field is relocated'
+ go to 50
+ END IF
+ END DO
+
+ 50 continue
+
+
+ end
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/modules.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/modules.f
new file mode 100644
index 000000000..92b6d910e
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/modules.f
@@ -0,0 +1,6 @@
+ module setparms
+ integer :: real_single, real_double
+ integer :: int_single, int_double
+ parameter (real_single = 4, real_double = real_single * 2)
+ parameter (int_single = 4, int_double = int_single * 2)
+ end module setparms
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/rodist.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/rodist.f
new file mode 100644
index 000000000..5706b186d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/rodist.f
@@ -0,0 +1,25 @@
+ subroutine rodist
+ parameter(nmx=24)
+ common /vect/rovect(nmx),xvect(nmx),yvect(nmx)
+ COMMON /POSIT/ XOLD,YOLD,XCORN,YCORN
+c
+c print*,'rovect',rovect
+ pi=4.0*atan(1.0)
+ PI180 = 4.*ATAN(1.0)/180.
+ yo=yold*pi180
+c qliu fact=cos(yo)
+ fact=1.0
+ xc=xold-xcorn
+ yc=yold-ycorn
+c
+ do 10 ip=1,nmx
+c
+ theta=float(ip-1)/float(nmx)*2.*pi
+ r=rovect(ip)
+c
+ xvect(ip)=r*cos(theta)/fact +xc
+ yvect(ip)=r*sin(theta) +yc
+10 continue
+c
+ return
+ end
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/sig_p_convt.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/sig_p_convt.f
new file mode 100644
index 000000000..69b5619f6
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/sig_p_convt.f
@@ -0,0 +1,599 @@
+
+ SUBROUTINE SIG2P(KMAX,MTV2,MTV3,HDAT,PDAT,PSFCM,H,HP,KST)
+c
+c subprogram:
+c prgmmr: Qingfu Liu org: date: 2000-04-25
+c
+c abstract:
+c Convert data from SIG surface to P surface.
+c
+c usage: call
+c Input: HDAT - DATA at SIG surface
+c KST: not used
+C Ouput: PDAT - DATA at P surface
+
+ PARAMETER (IX=41, JX=41)
+
+ REAL HDAT(IX,JX,MTV2),PDAT(IX,JX,MTV3)
+ REAL ZS(IX,JX),PS(IX,JX),APS(IX,JX)
+ REAL H(IX,JX,KMAX),HP(IX,JX,2*KMAX+1)
+
+c REAL(4) FHOUR,X(160),SI(KMAX+1),SL(KMAX)
+ REAL*4 FHOUR,DUMMY(245)
+ COMMON /COEF3/FHOUR,DUMMY
+
+ REAL, ALLOCATABLE :: TV(:,:,:),DIV(:,:,:),VORT(:,:,:),
+ & U(:,:,:),V(:,:,:),SH(:,:,:)
+ REAL, ALLOCATABLE :: PSIG(:,:,:),RH(:,:,:),
+ & APG(:,:,:),T(:,:,:)
+ REAL, ALLOCATABLE :: P(:),AP(:)
+ REAL, ALLOCATABLE :: DIVP(:,:,:),VORTP(:,:,:),UP(:,:,:),
+ & VP(:,:,:),RHP(:,:,:),SHP(:,:,:),TP(:,:,:)
+
+ REAL, ALLOCATABLE :: SI(:),SL(:)
+
+ KMAX1=KMAX+1
+ NMAX=2*KMAX+1
+
+ ALLOCATE ( SI(KMAX1),SL(KMAX) )
+
+ DO K=1,KMAX1
+ SI(K)=DUMMY(K)
+ END DO
+ DO K=1,KMAX
+ SL(K)=DUMMY(KMAX1+K)
+ END DO
+
+ ALLOCATE ( TV(IX,JX,KMAX), DIV(IX,JX,KMAX),
+ & VORT(IX,JX,KMAX),U(IX,JX,KMAX),
+ & V(IX,JX,KMAX),SH(IX,JX,KMAX) )
+
+ ALLOCATE ( PSIG(IX,JX,KMAX),RH(IX,JX,KMAX),
+ & APG(IX,JX,KMAX),T(IX,JX,KMAX) )
+
+ ALLOCATE ( P(NMAX),AP(NMAX) )
+ ALLOCATE ( DIVP(IX,JX,NMAX),VORTP(IX,JX,NMAX),
+ & UP(IX,JX,NMAX), VP(IX,JX,NMAX),
+ & RHP(IX,JX,NMAX),SHP(IX,JX,NMAX),
+ & TP(IX,JX,NMAX) )
+
+ COEF1=461.5/287.05-1.
+ COEF2=287.05/9.8
+
+c Surface Height and Surface Press
+ DO J=1,JX
+ DO I=1,IX
+ ZS(I,J)=HDAT(I,J,1)
+ PS(I,J)=EXP(HDAT(I,J,2))*1000.
+ APS(I,J)=ALOG(PS(I,J))
+ END DO
+ END DO
+
+c DIV, VORT, U, V, T and Specific Humidity at Sigma Level
+ DO K=1,KMAX
+ DO J=1,JX
+ DO I=1,IX
+ DIV(I,J,K)=HDAT(I,J,KMAX+4+4*(K-1))
+ VORT(I,J,K)=HDAT(I,J,KMAX+5+4*(K-1))
+ U(I,J,K)=HDAT(I,J,KMAX+6+4*(K-1))
+ V(I,J,K)=HDAT(I,J,KMAX+7+4*(K-1))
+ SH(I,J,K)=HDAT(I,J,KMAX*5+3+K)
+ TV(I,J,K)=HDAT(I,J,3+K)
+ T(I,J,K)=TV(I,J,K)/(1.+COEF1*SH(I,J,K))
+ END DO
+ END DO
+ END DO
+
+c Press at Sigma-Level
+ DO K=1,KMAX
+ DO J=1,JX
+ DO I=1,IX
+ PSIG(I,J,K)=SL(K)*PS(I,J)
+ APG(I,J,K)=ALOG(PSIG(I,J,K))
+ END DO
+ END DO
+ END DO
+
+ DO J=1,JX
+ DO I=1,IX
+ TVD=TV(I,J,1)
+ H(I,J,1)=ZS(I,J)-
+ & COEF2*TVD*(APG(I,J,1)-APS(I,J))
+ DO K=2,KMAX
+ TVU=TV(I,J,K)
+ H(I,J,K)=H(I,J,K-1)-
+ & COEF2*0.5*(TVD+TVU)*(APG(I,J,K)-APG(I,J,K-1))
+ TVD=TVU
+ END DO
+ END DO
+ END DO
+
+c Const. P-Level
+ DO K=1,KMAX
+ P(2*K-1)=SI(K)*PSFCM
+ P(2*K)=SL(K)*PSFCM
+ END DO
+ P(NMAX)=SL(KMAX)*0.5*PSFCM
+ DO N=1,NMAX
+ AP(N)=ALOG(P(N))
+ END DO
+
+ GAMA=6.5E-3
+ COEF3=COEF2*GAMA
+ DO J=1,JX
+ DO I=1,IX
+ HP(I,J,1)=H(I,J,1)+
+ & T(I,J,1)/GAMA*(1.-(P(1)/PSIG(I,J,1))**COEF3)
+ HP(I,J,NMAX)=H(I,J,KMAX)+
+ & T(I,J,KMAX)/GAMA*(1.-(P(NMAX)/PSIG(I,J,KMAX))**COEF3)
+ DO N=2,NMAX-1
+ K=(N-1)/2+1
+ HP(I,J,N)=H(I,J,K)+
+ & T(I,J,K)/GAMA*(1.-(P(N)/PSIG(I,J,K))**COEF3)
+ END DO
+ END DO
+ END DO
+
+ DO N=1,NMAX
+ K=(N-1)/2+1
+c PRINT*,'Press=',N,P(N)/100.
+! PRINT*,'Press1=',N,K,P(N),HP(20,20,N),H(20,20,K)
+ END DO
+
+c RH at K=1 (Sigma=0.995)
+! DO K=1,KMAX
+ K=1
+ DO J=1,JX
+ DO I=1,IX
+ DTEMP=T(I,J,K)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ SHS=0.622*ES/(PSIG(I,J,K)-0.378*ES)
+ RH(I,J,K)=MIN(MAX(SH(I,J,K)/SHS,0.),1.0)
+ END DO
+ END DO
+! END DO
+
+! Interpolate to Const. Press Level.
+ DO J=1,JX
+ DO I=1,IX
+ DO N=1,NMAX
+ IF(P(N).GE.PSIG(I,J,1))THEN
+! below SIGMA K=1
+ DIVP(I,J,N)=DIV(I,J,1)
+ VORTP(I,J,N)=VORT(I,J,1)
+ UP(I,J,N)=U(I,J,1)
+ VP(I,J,N)=V(I,J,1)
+ RHP(I,J,N)=RH(I,J,1) ! RH at SIGMA K=1
+ TDRY=T(I,J,1)-GAMA*(HP(I,J,N)-H(I,J,1))
+ DTEMP=TDRY-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ SHS=0.622*ES/(P(N)-0.378*ES)
+ SHP(I,J,N)=RHP(I,J,N)*SHS
+ TP(I,J,N)=TDRY*(1.+COEF1*SHP(I,J,N))
+! within domain
+ ELSE IF((P(N).LT.PSIG(I,J,1)).AND.
+ & (P(N).GT.PSIG(I,J,KMAX)))THEN
+ DO L=1,KMAX
+ IF((P(N).LT.PSIG(I,J,L)).AND.
+ & (P(N).GE.PSIG(I,J,L+1)))THEN
+ W=(AP(N)-APG(I,J,L))/(APG(I,J,L+1)-APG(I,J,L))
+c W1=(P(N)-PSIG(I,J,L))/(PSIG(I,J,L+1)-PSIG(I,J,L))
+ DIVP(I,J,N)=DIV(I,J,L)+
+ & W*(DIV(I,J,L+1)-DIV(I,J,L))
+ VORTP(I,J,N)=VORT(I,J,L)+
+ & W*(VORT(I,J,L+1)-VORT(I,J,L))
+ UP(I,J,N)=U(I,J,L)+W*(U(I,J,L+1)-U(I,J,L))
+ VP(I,J,N)=V(I,J,L)+W*(V(I,J,L+1)-V(I,J,L))
+ TP(I,J,N)=TV(I,J,L)+W*(TV(I,J,L+1)-TV(I,J,L))
+ SHP(I,J,N)=SH(I,J,L)+W*(SH(I,J,L+1)-SH(I,J,L))
+ GO TO 123
+ END IF
+ END DO
+ 123 CONTINUE
+! above top
+ ELSE IF(P(N).LE.PSIG(I,J,KMAX))THEN
+ DIVP(I,J,N)=DIV(I,J,KMAX)
+ VORTP(I,J,N)=VORT(I,J,KMAX)
+ UP(I,J,N)=U(I,J,KMAX)
+ VP(I,J,N)=V(I,J,KMAX)
+ TDRY=T(I,J,KMAX)-GAMA*(HP(I,J,N)-H(I,J,KMAX))
+ SHP(I,J,N)=SH(I,J,KMAX)
+ TP(I,J,N)=TDRY*(1.+COEF1*SHP(I,J,N))
+ ELSE
+ PRINT*,'SOMETHING IS WRONG'
+ END IF
+
+ END DO
+ END DO
+ END DO
+
+ DO J=1,JX
+ DO I=1,IX
+ PDAT(I,J,1)=HDAT(I,J,1)
+ PDAT(I,J,2)=HDAT(I,J,2)
+ PDAT(I,J,3)=HDAT(I,J,3)
+ DO N=1,NMAX
+ PDAT(I,J,NMAX+4+4*(N-1))=DIVP(I,J,N)
+ PDAT(I,J,NMAX+5+4*(N-1))=VORTP(I,J,N)
+ PDAT(I,J,NMAX+6+4*(N-1))=UP(I,J,N)
+ PDAT(I,J,NMAX+7+4*(N-1))=VP(I,J,N)
+ PDAT(I,J,NMAX*5+3+N)=SHP(I,J,N)
+ PDAT(I,J,3+N)=TP(I,J,N)
+ END DO
+ END DO
+ END DO
+
+ DEALLOCATE ( SI,SL )
+
+ DEALLOCATE ( T, TV, DIV, VORT, U, V, SH )
+
+ DEALLOCATE ( PSIG, RH, APG )
+
+ DEALLOCATE ( P, AP )
+ DEALLOCATE ( DIVP, VORTP, UP, VP, RHP, SHP, TP )
+
+
+ END
+
+
+ SUBROUTINE P2SIG(KMAX,MTV2,MTV3,HDPB,PDPB,PDAT,HDAT,
+ & PSFCM,H,HP,KST)
+
+c P to SIG conversion
+c
+c Input: HDPB (perturbation part), PDPB (perturbation part)
+c Input: PDAT (total field), PDPB+PDAT = ENV part
+C Ouput: HDPB (the value at the top most level kmax is not changed)
+c KST: not used
+
+ PARAMETER (IX=41, JX=41)
+
+ REAL HDPB(IX,JX,MTV2),HDAT(IX,JX,MTV2)
+ REAL PDPB(IX,JX,MTV3),PDAT(IX,JX,MTV3)
+ REAL ZS(IX,JX),PS(IX,JX),APS(IX,JX)
+ REAL H(IX,JX,KMAX),HP(IX,JX,2*KMAX+1)
+
+c REAL(4) FHOUR,X(160),SI(KMAX+1),SL(KMAX)
+ REAL*4 FHOUR,DUMMY(245)
+ COMMON /COEF3/FHOUR,DUMMY
+
+ REAL, ALLOCATABLE :: TV(:,:,:),DIV(:,:,:),VORT(:,:,:),
+ & U(:,:,:),V(:,:,:),SH(:,:,:)
+ REAL, ALLOCATABLE :: PSIG(:,:,:),RH(:,:,:),
+ & APG(:,:,:)
+ REAL, ALLOCATABLE :: P(:),AP(:)
+ REAL, ALLOCATABLE :: DIVP(:,:,:),VORTP(:,:,:),UP(:,:,:),
+ & VP(:,:,:),RHP(:,:,:)
+ REAL, ALLOCATABLE :: TVP(:,:,:),TVP_E(:,:,:)
+ REAL, ALLOCATABLE :: TP_E(:,:,:)
+ REAL, ALLOCATABLE :: SHP(:,:,:),SHP_E(:,:,:)
+ REAL, ALLOCATABLE :: HT_T(:,:,:),HSH_T(:,:,:)
+
+ REAL, ALLOCATABLE :: SI(:),SL(:)
+
+ KMAX1=KMAX+1
+ NMAX=2*KMAX+1
+
+ ALLOCATE ( SI(KMAX1),SL(KMAX) )
+
+ DO K=1,KMAX1
+ SI(K)=DUMMY(K)
+ END DO
+ DO K=1,KMAX
+ SL(K)=DUMMY(KMAX1+K)
+ END DO
+
+ ALLOCATE ( TV(IX,JX,KMAX), DIV(IX,JX,KMAX),
+ & VORT(IX,JX,KMAX),U(IX,JX,KMAX),
+ & V(IX,JX,KMAX),SH(IX,JX,KMAX) )
+
+ ALLOCATE ( PSIG(IX,JX,KMAX),RH(IX,JX,KMAX),
+ & APG(IX,JX,KMAX) )
+
+ ALLOCATE ( HT_T(IX,JX,KMAX),HSH_T(IX,JX,KMAX) )
+
+ ALLOCATE ( TVP(IX,JX,NMAX),TVP_E(IX,JX,NMAX),
+ & SHP(IX,JX,NMAX),SHP_E(IX,JX,NMAX),
+ & TP_E(IX,JX,NMAX) )
+
+ ALLOCATE ( P(NMAX),AP(NMAX) )
+ ALLOCATE ( DIVP(IX,JX,NMAX),VORTP(IX,JX,NMAX),
+ & UP(IX,JX,NMAX), VP(IX,JX,NMAX),
+ & RHP(IX,JX,NMAX) )
+
+ COEF1=461.5/287.05-1.
+ COEF2=287.05/9.8
+
+c Surface Height and Surface Press
+ DO J=1,JX
+ DO I=1,IX
+ ZS(I,J)=PDPB(I,J,1) ! Full field
+ PS(I,J)=EXP(PDPB(I,J,2))*1000. ! FULL field
+ APS(I,J)=ALOG(PS(I,J))
+ END DO
+ END DO
+
+c DIV, VORT, U, V, T and Specific Humidity at P-Level
+ DO J=1,JX
+ DO I=1,IX
+ DO N=1,NMAX
+ DIVP(I,J,N)=PDPB(I,J,NMAX+4+4*(N-1))
+ VORTP(I,J,N)=PDPB(I,J,NMAX+5+4*(N-1))
+ UP(I,J,N)=PDPB(I,J,NMAX+6+4*(N-1))
+ VP(I,J,N)=PDPB(I,J,NMAX+7+4*(N-1))
+ SHP(I,J,N)=PDPB(I,J,NMAX*5+3+N)
+ SHP_E(I,J,N)=SHP(I,J,N)+PDAT(I,J,NMAX*5+3+N)
+ TVP(I,J,N)=PDPB(I,J,3+N)
+ TVP_E(I,J,N)=TVP(I,J,N)+PDAT(I,J,3+N)
+ TP_E(I,J,N)=TVP_E(I,J,N)/(1.+COEF1*SHP_E(I,J,N))
+ END DO
+ END DO
+ END DO
+
+ DO J=1,JX
+ DO I=1,IX
+ DO K=1,KMAX-1
+ HSH_T(I,J,K)=HDAT(I,J,KMAX*5+3+K) ! Specific Hum.
+ HT_T(I,J,K)=HDAT(I,J,3+K)
+ END DO
+ END DO
+ END DO
+
+c Const. P-Level
+ DO K=1,KMAX
+ P(2*K-1)=SI(K)*PSFCM
+ P(2*K)=SL(K)*PSFCM
+ END DO
+ P(NMAX)=SL(KMAX)*0.5*PSFCM
+ DO N=1,NMAX
+ AP(N)=ALOG(P(N))
+ END DO
+
+ GAMA=6.5E-3
+ COEF3=COEF2*GAMA
+! DO J=1,JX
+! DO I=1,IX
+! TVD=TVP_E(I,J,1)
+! HP(I,J,1)=ZS(I,J)-
+! & TP_E(I,J,1)/GAMA*(1.-(PS(I,J)/P(1))**COEF3)
+! DO N=2,NMAX
+! TVU=TVP_E(I,J,N)
+! HP(I,J,N)=HP(I,J,N-1)-
+! & COEF2*0.5*(TVD+TVU)*(AP(N)-AP(N-1))
+! TVD=TVU
+! END DO
+! END DO
+! END DO
+
+c Press at Sigma-Level
+ DO K=1,KMAX
+ DO J=1,JX
+ DO I=1,IX
+ PSIG(I,J,K)=SL(K)*PS(I,J)
+ APG(I,J,K)=ALOG(PSIG(I,J,K))
+ END DO
+ END DO
+ END DO
+
+
+! DO K=1,KMAX
+! N=2*K
+! DO J=1,JX
+! DO I=1,IX
+! H(I,J,K)=HP(I,J,N)+
+! & TP_E(I,J,N)/GAMA*(1.-(PSIG(I,J,K)/P(N))**COEF3)
+! END DO
+! END DO
+! END DO
+
+ DO N=1,NMAX
+ K=(N-1)/2+1
+c PRINT*,'Press=',N,P(N)/100.
+c PRINT*,'Press2=',N,K,P(N),HP(20,20,N),H(20,20,K)
+ END DO
+
+c RH at Press level
+! DO N=1,NMAX
+ N=1
+ DO J=1,JX
+ DO I=1,IX
+ DTEMP=TP_E(I,J,N)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ SHS=0.622*ES/(P(N)-0.378*ES)
+ RHP(I,J,N)=MIN(MAX(SHP_E(I,J,N)/SHS,0.),1.0)
+ END DO
+ END DO
+! END DO
+
+! Interpolate to Sigma Level.
+ DO J=1,JX
+ DO I=1,IX
+ DO K=1,KMAX
+ IF(PSIG(I,J,K).GE.P(1))THEN
+! below Press K=1
+ DIV(I,J,K)=DIVP(I,J,1)
+ VORT(I,J,K)=VORTP(I,J,1)
+ U(I,J,K)=UP(I,J,1)
+ V(I,J,K)=VP(I,J,1)
+ RH(I,J,K)=RHP(I,J,1) ! RH at SIGMA K=1
+ TDRY=TP_E(I,J,1)-GAMA*(H(I,J,K)-HP(I,J,1))
+ DTEMP=TDRY-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ SHS=0.622*ES/(PSIG(I,J,K)-0.378*ES)
+ SH_E=RH(I,J,K)*SHS
+ SH(I,J,K)=SH_E-HSH_T(I,J,K) ! Pert. Part
+ TV(I,J,K)=TDRY*(1.+COEF1*SH_E)-HT_T(I,J,K)
+! PRINT*,'LLL2=',SHP(I,J,1),SHP_E(I,J,K)
+! PRINT*,' ',SH(I,J,K),SH_E
+! within domain
+ ELSE IF((PSIG(I,J,K).LT.P(1)).AND.
+ & (PSIG(I,J,K).GT.P(NMAX)))THEN
+ DO L=1,NMAX-1
+ IF((PSIG(I,J,K).LT.P(L)).AND.
+ & (PSIG(I,J,K).GE.P(L+1)))THEN
+ W=(APG(I,J,K)-AP(L))/(AP(L+1)-AP(L))
+c W1=(PSIG(I,J,K)-P(L))/(P(L+1)-P(L))
+ DIV(I,J,K)=DIVP(I,J,L)+
+ & W*(DIVP(I,J,L+1)-DIVP(I,J,L))
+ VORT(I,J,K)=VORTP(I,J,L)+
+ & W*(VORTP(I,J,L+1)-VORTP(I,J,L))
+ U(I,J,K)=UP(I,J,L)+W*(UP(I,J,L+1)-UP(I,J,L))
+ V(I,J,K)=VP(I,J,L)+W*(VP(I,J,L+1)-VP(I,J,L))
+ TV(I,J,K)=TVP(I,J,L)+W*(TVP(I,J,L+1)-TVP(I,J,L))
+ SH(I,J,K)=SHP(I,J,L)+W*(SHP(I,J,L+1)-SHP(I,J,L))
+ GO TO 123
+ END IF
+ END DO
+ 123 CONTINUE
+! above top
+ ELSE IF(PSIG(I,J,K).LE.P(NMAX))THEN
+ DIV(I,J,K)=DIVP(I,J,NMAX)
+ VORT(I,J,K)=VORTP(I,J,NMAX)
+ U(I,J,K)=UP(I,J,NMAX)
+ V(I,J,K)=VP(I,J,NMAX)
+ TDRY=TP_E(I,J,NMAX)-GAMA*(H(I,J,K)-HP(I,J,NMAX))
+ SH(I,J,K)=SHP(I,J,NMAX)
+ SH_E=SH(I,J,K)+HSH_T(I,J,K)
+ TV(I,J,K)=TDRY*(1.+COEF1*SH_E)-HT_T(I,J,K)
+ ELSE
+ PRINT*,'SOMETHING IS WRONG'
+ END IF
+
+ END DO
+ END DO
+ END DO
+
+ DO J=1,JX
+ DO I=1,IX
+ HDPB(I,J,1)=PDPB(I,J,1)
+ HDPB(I,J,2)=PDPB(I,J,2)
+ HDPB(I,J,3)=PDPB(I,J,3)
+ DO K=1,KMAX-1
+ HDPB(I,J,KMAX+4+4*(K-1))=DIV(I,J,K)
+ HDPB(I,J,KMAX+5+4*(K-1))=VORT(I,J,K)
+ HDPB(I,J,KMAX+6+4*(K-1))=U(I,J,K)
+ HDPB(I,J,KMAX+7+4*(K-1))=V(I,J,K)
+ HDPB(I,J,KMAX*5+3+K)=SH(I,J,K)
+ HDPB(I,J,3+K)=TV(I,J,K)
+ END DO
+ END DO
+ END DO
+
+ DEALLOCATE ( SI,SL )
+
+ DEALLOCATE ( TV, DIV, VORT, U, V, SH )
+
+ DEALLOCATE ( PSIG, RH, APG )
+
+ DEALLOCATE ( P, AP )
+ DEALLOCATE ( DIVP, VORTP, UP, VP, RHP, SHP )
+
+ DEALLOCATE ( TVP, TVP_E, TP_E, SHP_E, HT_T, HSH_T)
+
+ END
+
+C
+ SUBROUTINE FIND_NEWCT1(UD,VD)
+ PARAMETER (IR=15,IT=24,IX=41,JX=41)
+ PARAMETER (ID=41,JD=41,DTX=0.2,DTY=0.2) ! Search x-Domain (ID-1)*DTX
+ DIMENSION TNMX(ID,JD),UD(IX,JX),VD(IX,JX)
+ DIMENSION WTM(IR),R0(IT)
+ COMMON /POSIT/CLON_NEW,CLAT_NEW,SLON,SLAT,CLON,CLAT,RAD
+
+ COMMON /vect/R0,XVECT(IT),YVECT(IT)
+c COMMON /CT/SLON,SLAT,CLON,CLAT,RAD
+c COMMON /GA/CLON_NEW,CLAT_NEW,R0
+C
+ PI=ASIN(1.)*2.
+ RAD=PI/180.
+C
+ XLAT = CLAT-(JD-1)*DTY/2.
+ XLON = CLON-(ID-1)*DTX/2.
+c print *,'STARTING LAT, LON AT FIND NEW CENTER ',XLAT,XLON
+C
+ DO I=1,ID
+ DO J=1,JD
+ TNMX(I,J) = 0.
+ BLON = XLON + (I-1)*DTX
+ BLAT = XLAT + (J-1)*DTY
+C
+C.. CALCULATE TANGENTIAL WIND EVERY 1 deg INTERVAL
+C.. 10*10 deg AROUND 1ST 1ST GUESS VORTEX CENTER
+C
+ DO 10 JL=1,IR
+ WTS= 0.
+ DO 20 IL=1,IT
+ DR = JL
+ DD = (IL-1)*15*RAD
+ DLON = DR*COS(DD)
+ DLAT = DR*SIN(DD)
+ TLON = BLON + DLON
+ TLAT = BLAT + DLAT
+C.. INTERPOLATION U, V AT TLON,TLAT AND CLACULATE TANGENTIAL WIND
+ IDX = floor(TLON) - SLON + 1
+ IDY = floor(TLAT) - SLAT + 1
+ DXX = TLON - floor(TLON)
+ DYY = TLAT - floor(TLAT)
+C
+ X1 = UD(IDX ,IDY+1)*DYY + UD(IDX ,IDY)*(1-DYY)
+ X2 = UD(IDX+1,IDY+1)*DYY + UD(IDX+1,IDY)*(1-DYY)
+ Y1 = UD(IDX+1,IDY )*DXX + UD(IDX,IDY )*(1-DXX)
+ Y2 = UD(IDX+1,IDY+1)*DXX + UD(IDX,IDY+1)*(1-DXX)
+ UT = (X1*(1-DXX)+X2*DXX + Y1*(1-DYY)+Y2*DYY)/2.
+ IF(IL.EQ.0.OR.IL.EQ.13) UT = Y1
+ IF(IL.EQ.7.OR.IL.EQ.19) UT = X1
+C
+ X1 = VD(IDX ,IDY+1)*DYY + VD(IDX ,IDY)*(1-DYY)
+ X2 = VD(IDX+1,IDY+1)*DYY + VD(IDX+1,IDY)*(1-DYY)
+ Y1 = VD(IDX+1,IDY )*DXX + VD(IDX,IDY )*(1-DXX)
+ Y2 = VD(IDX+1,IDY+1)*DXX + VD(IDX,IDY+1)*(1-DXX)
+ VT = (X1*(1-DXX)+X2*DXX + Y1*(1-DYY)+Y2*DYY)/2.
+ IF(IL.EQ.0.OR.IL.EQ.13) VT = Y1
+ IF(IL.EQ.7.OR.IL.EQ.19) VT = X1
+C.. TANGENTIAL WIND
+ WT = -SIN(DD)*UT + COS(DD)*VT
+ WTS = WTS+WT
+20 CONTINUE
+ WTM(JL) = WTS/24.
+10 CONTINUE
+C
+C Southern Hemisphere
+ IF(CLAT_NEW.LT.0)THEN
+ DO JL=1,IR
+ WTM(JL)=-WTM(JL)
+ END DO
+ END IF
+C EnD SH
+
+ TX = -10000000.
+ DO KL = 1,IR
+ IF(WTM(KL).GE.TX) THEN
+ TX = WTM(KL)
+ ENDIF
+ ENDDO
+C
+ TNMX(I,J) = TX
+ ENDDO
+ ENDDO
+C.. FIND NEW CENTER
+ TTX = -1000000.
+ DO I=1,ID
+ DO J=1,JD
+ IF(TNMX(I,J).GE.TTX) THEN
+ TTX = TNMX(I,J)
+ NIC = I
+ NJC = J
+ ENDIF
+ ENDDO
+ ENDDO
+C
+ CLAT_NEW = XLAT + (NJC-1)*DTY
+ CLON_NEW = XLON + (NIC-1)*DTX
+C
+ print *,'NEW CENTER, I, J IS ',NIC,NJC
+ print *,'NEW CENTER, LAT,LON IS ',CLAT_NEW,CLON_NEW
+ print *,'MAX TAN. WIND AT NEW CENTER IS ',TTX
+C
+ RETURN
+ END
+
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/split.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/split.f
new file mode 100644
index 000000000..68b16787d
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/split.f
@@ -0,0 +1,3302 @@
+!??????????????????????????????????????????????????????????
+!
+! ABSTRACT: Split the vortex into environment flow and vortex perturbation
+!
+! ORIGINAL AUTHOR: QINGFU LIU, NCEP/EMC, 2007
+! REVISED AUTHOR: Qingfu Liu, 2013
+! : Changed the filter domain size
+!
+! DECLARE VARIABLES
+!
+ INTEGER I,J,K,NX,NY,NZ,IBGS,IVOBS
+ INTEGER KK
+! REAL(4) DX_R,DY_R,PT,PDTOP,GAMMA
+ REAL(4) LON1,LAT1,LON2,LAT2,GAMMA
+ REAL(4) crfactor
+!
+! PARAMETER (NX=215,NY=431,NZ=42)
+ PARAMETER (NST=10)
+ PARAMETER (GAMMA=6.5E-3,G=9.8,GI=1./G,D608=0.608)
+!
+! Variables on hybrid coordinate
+
+ REAL(4), ALLOCATABLE :: T1(:,:,:),Q1(:,:,:)
+ REAL(4), ALLOCATABLE :: U1(:,:,:),V1(:,:,:),DZDT(:,:,:)
+ REAL(4), ALLOCATABLE :: Z1(:,:,:),P1(:,:,:)
+ REAL(4), ALLOCATABLE :: GLON(:,:),GLAT(:,:)
+ REAL(4), ALLOCATABLE :: PD(:,:),ETA1(:),ETA2(:)
+ REAL(4), ALLOCATABLE :: HGTSFC3(:,:)
+
+ REAL(4), ALLOCATABLE :: US850(:,:),VS850(:,:)
+
+ REAL(4), ALLOCATABLE :: HLON(:,:),HLAT(:,:)
+ REAL(4), ALLOCATABLE :: VLON(:,:),VLAT(:,:)
+
+ REAL(4), ALLOCATABLE :: USC(:,:),VSC(:,:) ! wind at z=0
+ REAL(4), ALLOCATABLE :: TMV1(:,:)
+
+
+ REAL(4),ALLOCATABLE :: ZM1(:,:,:),PM1(:,:,:),HV(:,:,:)
+ REAL(4),ALLOCATABLE :: ZMV1(:,:,:),PMV1(:,:,:)
+ REAL(4),ALLOCATABLE :: TV1(:,:,:)
+!
+! Variables on P surface
+
+ REAL(4),ALLOCATABLE :: T2(:,:,:),Q2(:,:,:)
+ REAL(4),ALLOCATABLE :: U2(:,:,:),V2(:,:,:)
+ REAL(4),ALLOCATABLE :: P2(:),SLP(:,:),Z2(:,:)
+ REAL(4),ALLOCATABLE :: SIG(:)
+ REAL(4),ALLOCATABLE :: RH(:,:)
+ REAL(4),ALLOCATABLE :: HP(:,:,:)
+
+ REAL(4),ALLOCATABLE :: UVTQ(:,:,:,:)
+ REAL(4),ALLOCATABLE :: work_1(:),work_2(:)
+
+ real(4) SLON_N,SLAT_N,CLON_N,CLAT_N
+
+ REAL(4) CENTRAL_LON,CENTRAL_LAT,WBD,SBD
+
+ COMMON /NHC/ KSTM,IC_N(NST),JC_N(NST)
+ COMMON /NHC1/ SLON_N(NST),SLAT_N(NST),CLON_N(NST),CLAT_N(NST)
+ CHARACTER ST_NAME(NST)*3,STMNAME(NST)*3,TCVT(NST)*95
+ COMMON /STNAME/ST_NAME,STMNAME
+ COMMON /TCVIT/TCVT
+ COMMON /RSFC/STRPSF(NST),STVMAX(NST),STRPSF_06(NST)
+ integer, external :: omp_get_max_threads
+
+ integer :: ICLAT,ICLON,CLAT_VIT,CLON_VIT
+ character :: SN,EW
+
+333 format('Have ',I0,' OpenMP threads.')
+ print 333,omp_get_max_threads()
+!
+ COEF3=287.05*GI*GAMMA
+ COEF2=1./COEF3
+
+ pi=4.*atan(1.)
+ pi_deg=180./pi
+! read data
+
+ READ(5,*)ITIM,IBGS,IVOBS,iflag_cold,crfactor
+
+ IUNIT=26
+ KUNIT=56
+
+! read in storm center
+ read(11,11)ICLAT,SN,ICLON,EW
+ 11 format(33x,I3,A1,I5,A1)
+ close(11)
+
+ CLAT_VIT=ICLAT*0.1
+ CLON_VIT=ICLON*0.1
+
+ IF(SN.eq.'S')CLAT_VIT=-CLAT_VIT
+ IF(EW.eq.'W')CLON_VIT=-CLON_VIT
+
+ I360=180
+ if(abs(CLON_VIT).gt.90.)then
+ I360=360
+ end if
+
+ READ(IUNIT) NX,NY,NZ
+
+ print*,'NX,NY,NZ,I360=',NX,NY,NZ,I360
+ IF ( NZ <= 60 ) THEN
+ KMX=2*NZ+1
+ ELSE
+! Warning: currently hard wired to 121 due to memory limit
+ KMX=121
+ ENDIF
+ KMAX=KMX
+ NX1=NX+1
+ NY1=NY+1
+ NZ1=NZ+1
+
+
+ ALLOCATE ( T1(NX,NY,NZ),Q1(NX,NY,NZ) )
+ ALLOCATE ( U1(NX,NY,NZ),V1(NX,NY,NZ),DZDT(NX,NY,NZ) )
+ ALLOCATE ( Z1(NX,NY,NZ1),P1(NX,NY,NZ1) )
+ ALLOCATE ( GLON(NX,NY),GLAT(NX,NY) )
+ ALLOCATE ( PD(NX,NY),ETA1(NZ1),ETA2(NZ1) )
+
+ ALLOCATE ( HLON(NX,NY),HLAT(NX,NY) )
+ ALLOCATE ( VLON(NX,NY),VLAT(NX,NY) )
+
+ ALLOCATE ( US850(NX,NY),VS850(NX,NY) )
+
+ ALLOCATE ( USC(NX,NY),VSC(NX,NY) ) ! wind at z=0
+ ALLOCATE ( TMV1(NX,NY) )
+
+ ALLOCATE ( ZM1(NX,NY,NZ),PM1(NX,NY,NZ),TV1(NX,NY,NZ) )
+ ALLOCATE ( ZMV1(NX,NY,NZ),PMV1(NX,NY,NZ) )
+
+ READ(IUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ READ(IUNIT) PM1
+ READ(IUNIT) T1
+ READ(IUNIT) Q1
+ READ(IUNIT) U1
+ READ(IUNIT) V1
+ READ(IUNIT) DZDT ! new
+ READ(IUNIT) Z1
+ READ(IUNIT) HLON,HLAT,VLON,VLAT
+ READ(IUNIT) P1
+ READ(IUNIT) PD ! surface pressure
+ READ(IUNIT) ETA1
+ READ(IUNIT) ETA2
+ READ(IUNIT) !land
+ READ(IUNIT) !sfrc
+ READ(IUNIT) !C101
+
+ CLOSE(IUNIT)
+
+!
+ DO J=1,NY
+ DO I=1,NX
+ GLON(I,J)=HLON(I,J) ! LON & LAT at T,Q P Z (H) points
+ GLAT(I,J)=HLAT(I,J)
+ END DO
+ END DO
+
+ print*,'CENTRAL_LON,CENTRAL_LAT=',CENTRAL_LON,CENTRAL_LAT
+
+ write(*,*)'K,T1,Q1,U1,V1,Z1,P1='
+ do k=1,nz
+ write(*,32)K,T1(9,9,K),
+ & Q1(9,9,K),U1(9,9,K),V1(9,9,K),Z1(9,9,K),P1(9,9,K)
+ end do
+ write(*,*)
+
+ ICT1=1+(NX-1)/2
+ JCT1=1+(NY-1)/2
+
+ SDT=1.E20
+ DO K=1,NZ
+ SDIF=abs(P1(ICT1,JCT1,K)/P1(ICT1,JCT1,1)-0.85)
+ IF(SDIF.LT.SDT)THEN
+ KS850=K
+ SDT=SDIF
+ END IF
+ END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ US850(I,J)=U1(I,J,KS850)
+ VS850(I,J)=V1(I,J,KS850)
+ END DO
+ END DO
+
+ 32 format(I3,6F12.2)
+
+!
+ write(*,*)'PT,PDTOP=',PT,PDTOP
+ do k=1,nz1
+ write(*,*)'K,ETA1,ETA2=',K,ETA1(k),ETA2(k)
+ end do
+ print*,'CLON,CLAT=',GLON(1+(NX-1)/2,1+(NY-1)/2),
+ & GLAT(1+(NX-1)/2,1+(NY-1)/2)
+! write(77,33)HLON
+! write(77,*)
+! write(77,33)HLAT
+! write(77,*)
+! write(77,34)PD
+! 33 format(15F8.1)
+! 34 format(10F12.1)
+
+! DO K=1,NZ+1
+! WRITE(61)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ+1
+! WRITE(61)((P1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((T1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((U1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,NZ
+! WRITE(61)((V1(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+
+ ALLOCATE ( T2(NX,NY,KMX),Q2(NX,NY,KMX) )
+ ALLOCATE ( U2(NX,NY,KMX),V2(NX,NY,KMX) )
+ ALLOCATE ( P2(KMX),SLP(NX,NY),Z2(NX,NY),SIG(KMX) )
+ ALLOCATE ( HP(NX,NY,KMX),RH(NX,NY) )
+ ALLOCATE ( HV(NX,NY,KMX) )
+
+ ALLOCATE ( UVTQ(NX,NY,KMX,4) )
+
+! Surface at K=1, top at K=NZ
+
+!$omp parallel do
+!$omp& private(i,j,k)
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+ TV1(I,J,K)=T1(I,J,K)*(1.+D608*Q1(I,J,K))
+ END DO
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,k)
+ DO K=1,NZ
+ DO J=1,NY
+ DO I=1,NX
+ ZM1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5+
+ & 0.5*TV1(I,J,K)/GAMMA*(2.-(P1(I,J,K)/PM1(I,J,K))**COEF3-
+ & (P1(I,J,K+1)/PM1(I,J,K))**COEF3)
+! ZM1(I,J,K)=(Z1(I,J,K)+Z1(I,J,K+1))*0.5
+! PM1(I,J,K)=EXP((ALOG(1.*P1(I,J,K))+ALOG(1.*P1(I,J,K+1)))*0.5)
+ END DO
+ END DO
+ END DO
+
+ ZMV1=ZM1
+ PMV1=PM1
+!!$omp parallel do
+!1$omp& private(i,j,k)
+! DO J=2,NY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO K=1,NZ
+! DO I=1,NX-1
+! ZMV1(I,J,K)=0.25*(ZM1(I,J,K)+ZM1(I+1,J,K)+
+! & ZM1(I,J-1,K)+ZM1(I,J+1,K))
+! PMV1(I,J,K)=0.25*(PM1(I,J,K)+PM1(I+1,J,K)+
+! & PM1(I,J-1,K)+PM1(I,J+1,K))
+! END DO
+! END DO
+! ELSE
+! DO K=1,NZ
+! DO I=2,NX
+! ZMV1(I,J,K)=0.25*(ZM1(I-1,J,K)+ZM1(I,J,K)+
+! & ZM1(I,J-1,K)+ZM1(I,J+1,K))
+! PMV1(I,J,K)=0.25*(PM1(I-1,J,K)+PM1(I,J,K)+
+! & PM1(I,J-1,K)+PM1(I,J+1,K))
+! END DO
+! END DO
+! END IF
+! END DO
+
+ DO J=1,NY
+ DO I=1,NX
+ TMV1(I,J)=TV1(I,J,1)
+ END DO
+ END DO
+! K=1
+!!$omp parallel do
+!!$omp& private(i,j)
+! DO J=2,NY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO I=1,NX-1
+! TMV1(I,J)=0.25*(TV1(I,J,K)+TV1(I+1,J,K)+
+! & TV1(I,J-1,K)+TV1(I,J+1,K))
+! END DO
+! ELSE
+! DO I=2,NX
+! TMV1(I,J)=0.25*(TV1(I-1,J,K)+TV1(I,J,K)+
+! & TV1(I,J-1,K)+TV1(I,J+1,K))
+! END DO
+! END IF
+! END DO
+
+
+! MAX Surface P
+ PSFX=0.
+ DO J=1,NY
+ DO I=1,NX
+ IF(PSFX.LT.P1(I,J,1))THEN
+ PSFX=P1(I,J,1)
+ IPX=I
+ JPX=J
+ END IF
+ END DO
+ END DO
+
+ PRINT*,'IPX,JPX,PSFX=',IPX,JPX,PSFX
+
+! constant P
+! Double resolution for low levels
+ KK=0
+ DO K=1,KMX-NZ-1
+ KK=2*K-1
+ P2(KK)=P1(IPX,JPX,K)
+ SIG(KK)=P1(IPX,JPX,K)/PSFX
+ END DO
+ DO K=1,KMX-NZ-1
+ KK=2*K
+ P2(KK)=PM1(IPX,JPX,K)
+ SIG(KK)=PM1(IPX,JPX,K)/PSFX
+ END DO
+ DO K=KMX-NZ,NZ+1
+ KK=KK+1
+ P2(KK)=P1(IPX,JPX,K)
+ SIG(KK)=P1(IPX,JPX,K)/PSFX
+ END DO
+
+! Height at P2 grids
+!$omp parallel do
+!$omp& private(i,j,k,n)
+ DO J=1,NY
+ DO I=1,NX
+ CYC_10: DO K=1,KMX
+ IF(P2(K).GE.PM1(I,J,1))THEN
+ HP(I,J,K)=ZM1(I,J,1)+
+ & TV1(I,J,1)/GAMMA*(1.-(P2(K)/PM1(I,J,1))**COEF3)
+ ELSE IF(P2(K).LE.PM1(I,J,NZ))THEN
+ HP(I,J,K)=ZM1(I,J,NZ)+
+ & TV1(I,J,NZ)/GAMMA*(1.-(P2(K)/PM1(I,J,NZ))**COEF3)
+ ELSE
+ DO N=1,NZ-1
+ IF(P2(K).LE.PM1(I,J,N).and.P2(K).GT.PM1(I,J,N+1))THEN
+ HP(I,J,K)=ZM1(I,J,N)+
+ & TV1(I,J,N)/GAMMA*(1.-(P2(K)/PM1(I,J,N))**COEF3)
+ CYCLE CYC_10
+ END IF
+ END DO
+ END IF
+ END DO CYC_10
+ END DO
+ END DO
+
+
+ HV=HP
+!!$omp parallel do
+!!$omp& private(i,j,k)
+! DO J=2,NY-1
+! IF(MOD(J,2).NE.0.)THEN
+! DO K=1,KMX
+! DO I=1,NX-1
+! HV(I,J,K)=0.25*(HP(I,J,K)+HP(I+1,J,K)+
+! & HP(I,J-1,K)+HP(I,J+1,K))
+! END DO
+! END DO
+! ELSE
+! DO K=1,KMX
+! DO I=2,NX
+! HV(I,J,K)=0.25*(HP(I-1,J,K)+HP(I,J,K)+
+! & HP(I,J-1,K)+HP(I,J+1,K))
+! END DO
+! END DO
+! END IF
+! END DO
+
+ K=1
+!$omp parallel do
+!$omp& private(i,j,DTEMP,ES,QS1)
+ DO J=1,NY
+ DO I=1,NX
+ DTEMP=T1(I,J,K)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ QS1=0.622*ES/(PM1(I,J,K)-0.378*ES)
+ RH(I,J)=MIN(MAX(Q1(I,J,K)/QS1,0.),1.0)
+! IF(I*J.LT.20)print*,'ES,PM1=',I,J,ES,PM1(I,J,K),QS1,RH(I,J)
+ END DO
+ END DO
+
+! Iterpolation to constant P
+!$omp parallel do
+!$omp& private(i,j,k,N,DTEMP,ES,QSK,W1,W)
+ DO J=1,NY
+ DO I=1,NX
+ CYC_12: DO K=1,KMX
+ IF(P2(K).GE.PM1(I,J,1))THEN ! Below PM1(I,J,1)
+ T2(I,J,K)=T1(I,J,1)-GAMMA*(HP(I,J,K)-ZM1(I,J,1))
+ DTEMP=T2(I,J,K)-273.15
+ ES=611.2*EXP(17.67*DTEMP/(DTEMP+243.5))
+ QSK=0.622*ES/(P2(K)-0.378*ES)
+ Q2(I,J,K)=RH(I,J)*QSK ! constant RH below Nz=1
+ ELSE IF(P2(K).LE.PM1(I,J,NZ))THEN
+ T2(I,J,K)=T1(I,J,NZ)-GAMMA*(HP(I,J,K)-ZM1(I,J,NZ))
+ Q2(I,J,K)=Q1(I,J,NZ) ! very small
+ ELSE
+ DO N=1,NZ-1
+ IF(P2(K).LE.PM1(I,J,N).and.P2(K).GT.PM1(I,J,N+1))THEN
+ W1=ALOG(1.*PM1(I,J,N+1))-ALOG(1.*PM1(I,J,N))
+ W=(ALOG(1.*P2(K))-ALOG(1.*PM1(I,J,N)))/W1
+ T2(I,J,K)=T1(I,J,N)+(T1(I,J,N+1)-T1(I,J,N))*W
+ Q2(I,J,K)=Q1(I,J,N)+(Q1(I,J,N+1)-Q1(I,J,N))*W
+ CYCLE CYC_12
+ END IF
+ END DO
+ END IF
+ END DO CYC_12
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,W1,W)
+ DO J=1,NY
+ DO I=1,NX
+ CYC_14: DO K=1,KMX
+ IF(P2(K).GE.PMV1(I,J,1))THEN ! Below PMV1(I,J,1)
+! U2(I,J,K)=U1(I,J,1)*(1.-(P2(K)-PMV1(I,J,1))*1.4E-5)
+! V2(I,J,K)=V1(I,J,1)*(1.-(P2(K)-PMV1(I,J,1))*1.4E-5)
+ U2(I,J,K)=U1(I,J,1)
+ V2(I,J,K)=V1(I,J,1)
+ ELSE IF(P2(K).LE.PMV1(I,J,NZ))THEN
+ U2(I,J,K)=U1(I,J,NZ)
+ V2(I,J,K)=V1(I,J,NZ)
+ ELSE
+ DO N=1,NZ-1
+ IF(P2(K).LE.PMV1(I,J,N).and.P2(K).GT.PMV1(I,J,N+1))THEN
+ W1=ALOG(1.*PMV1(I,J,N+1))-ALOG(1.*PMV1(I,J,N))
+ W=(ALOG(1.*P2(K))-ALOG(1.*PMV1(I,J,N)))/W1
+ U2(I,J,K)=U1(I,J,N)+(U1(I,J,N+1)-U1(I,J,N))*W
+ V2(I,J,K)=V1(I,J,N)+(V1(I,J,N+1)-V1(I,J,N))*W
+ CYCLE CYC_14
+ END IF
+ END DO
+ END IF
+ END DO CYC_14
+ END DO
+ END DO
+
+ write(*,*)'IPX,JPX,PSFX=',IPX,JPX,PSFX
+ do k=1,kmx
+ write(*,*)'K,P2,SIG=',K,P2(K),SIG(K)
+ end do
+ write(*,*)
+ write(*,*)'K,T2,Q2,U2,V2,Z2,P2='
+ do k=1,kmx
+ write(*,32)K,T2(9,9,K),
+ & Q2(9,9,K),U2(9,9,K),V2(9,9,K),HP(9,9,K),P2(K)
+ end do
+
+! DO K=1,KMX
+! WRITE(81)((U2(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(81)((V2(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+
+! save for later use
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ UVTQ(I,J,K,1)=U2(I,J,K)
+ UVTQ(I,J,K,2)=V2(I,J,K)
+ UVTQ(I,J,K,3)=T2(I,J,K)
+ UVTQ(I,J,K,4)=Q2(I,J,K)
+ END DO
+ END DO
+ END DO
+
+!C MSLP: LOOP OVER HORIZONTAL GRID.
+!C
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = Z1(I,J,1)
+ PSFC = P1(I,J,1)
+ TSFC = TV1(I,J,1)+GAMMA*(ZM1(I,J,1)-Z1(I,J,1))
+!C
+!C COMPUTE SEA LEVEL PRESSURE.
+ A = (GAMMA * ZSFC) / TSFC
+ SLP(I,J) = PSFC*(1+A)**COEF2
+ Z2(I,J)=Z1(I,J,1)
+ ENDDO
+ ENDDO
+
+
+ print*,'call before HURR_MESS'
+
+ CALL HURR_MESS(ITIM,IBGS,NX,NY,GLON,GLAT,I360)
+
+ print*,'call after HURR_MESS'
+
+
+ NCHT=71
+ WRITE(NCHT)KSTM
+
+ WRITE(NCHT)HLAT,HLON
+ WRITE(NCHT)VLAT,VLON
+
+ WRITE(NCHT)P2
+ WRITE(NCHT)HP
+
+!C Relocate Hurricane
+
+! DO KST=1,KSTM
+ DO KST=1,1
+
+ print*,'KST=',KST
+
+ CALL wrf_move(ITIM,KST,GLON,GLAT,US850,VS850,
+ & KS850,P2,
+ & Z2,T2,Q2,U2,V2,SLP,SIG,HLAT,HLON,VLAT,VLON,
+ & KMX,1,NX,1,NY,IBGS,IVOBS,iflag_cold,I360,crfactor)
+
+ END DO
+
+ print*,'test7'
+
+ DO J=1,NY
+ DO I=1,NX
+ ZSFC = Z1(I,J,1)
+ TSFC = T2(I,J,1)*(1.+D608*Q2(I,J,1))
+ A = (GAMMA * ZSFC) / TSFC
+ P1(I,J,1) = SLP(I,J)*(1-A)**COEF2
+ PD(I,J)=P1(I,J,1)
+ ENDDO
+ ENDDO
+
+
+ allocate (work_1(nz),work_2(nz+1))
+ DO J=1,NY
+ DO I=1,NX
+ call get_eta_level(nz,PD(I,J),work_1,work_2,eta1,eta2,1.0)
+ do k=1,nz
+ n=nz-k+1
+ PM1(I,J,K)=work_1(n)
+ end do
+ do k=1,nz+1
+ n=nz-k+2
+ P1(I,J,K)=work_2(n)
+ end do
+ ENDDO
+ ENDDO
+ deallocate (work_1,work_2)
+
+ do j = 1,ny
+ do i = 1,nx
+! Z1(I,J,1)=ZS1(I,J)
+ DO L=2,nz+1
+ Z1(I,J,L)=Z1(I,J,L-1)+T1(I,J,L-1)*
+ & (Q1(I,J,L-1)*0.608+1.0)*287.04*
+ & (ALOG(1.*P1(I,J,L-1))-ALOG(1.*P1(I,J,L)))/G
+ ENDDO
+ ENDDO
+ END DO
+
+ print*,'test8'
+
+! PD(I,J)=P1(I,J,1)-PDTOP-PT=PSFC(I,J)-PDTOP-PT
+! DO K=1,NZ+1
+! DO J=1,NY
+! DO I=1,NX
+! P1(I,J,K)=PT+PDTOP*ETA1(K)+PD(I,J)*ETA2(K) ! PD(I,J) changed
+! ENDDO
+! ENDDO
+! ENDDO
+
+! print*,'test9'
+
+! DO K=1,NZ
+! DO J=1,NY
+! DO I=1,NX
+! PM1(I,J,K)=EXP((ALOG(1.*P1(I,J,K))+ALOG(1.*P1(I,J,K+1)))*0.5)
+! END DO
+! END DO
+! END DO
+
+! CONVERT OTHER VARIABLES TO Hybrid Coordinate from Constant P
+
+ DO J=1,NY
+ DO I=1,NX
+ DO K=1,KMX
+ UVTQ(I,J,K,1)=U2(I,J,K)-UVTQ(I,J,K,1)
+ UVTQ(I,J,K,2)=V2(I,J,K)-UVTQ(I,J,K,2)
+ UVTQ(I,J,K,3)=T2(I,J,K)-UVTQ(I,J,K,3)
+ UVTQ(I,J,K,4)=Q2(I,J,K)-UVTQ(I,J,K,4)
+ END DO
+ END DO
+ END DO
+
+! DO K=1,KMX
+! WRITE(82)((U2(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+! DO K=1,KMX
+! WRITE(82)((V2(I,J,K),I=1,NX),J=1,NY,2)
+! END DO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,W1,W)
+ DO J=1,NY
+ DO I=1,NX
+ DO N=1,NZ
+ IF(PM1(I,J,N).GE.P2(1))THEN ! Below PM1(I,J,1)
+ T1(I,J,N)=T1(I,J,N)+UVTQ(I,J,1,3)
+ Q1(I,J,N)=Q1(I,J,N)+UVTQ(I,J,1,4)
+ ELSE IF(PM1(I,J,N).LE.P2(KMX))THEN
+ T1(I,J,N)=T1(I,J,N)+UVTQ(I,J,KMX,3)
+ Q1(I,J,N)=Q1(I,J,N)+UVTQ(I,J,KMX,4)
+ ELSE
+ DO K=1,KMX-1
+ IF(PM1(I,J,N).LE.P2(K).and.PM1(I,J,N).GT.P2(K+1))THEN
+ W1=ALOG(1.*P2(K+1))-ALOG(1.*P2(K))
+ W=(ALOG(1.*PM1(I,J,N))-ALOG(1.*P2(K)))/W1
+ T1(I,J,N)=T1(I,J,N)+UVTQ(I,J,K,3)+
+ & (UVTQ(I,J,K+1,3)-UVTQ(I,J,K,3))*W
+ Q1(I,J,N)=Q1(I,J,N)+UVTQ(I,J,K,4)+
+ & (UVTQ(I,J,K+1,4)-UVTQ(I,J,K,4))*W
+ GO TO 22
+ END IF
+ END DO
+ END IF
+ 22 CONTINUE
+ END DO
+ END DO
+ END DO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,W1,W)
+ DO J=1,NY
+ DO I=1,NX
+ DO N=1,NZ
+ IF(PMV1(I,J,N).GE.P2(1))THEN ! Below PMV1(I,J,1)
+ U1(I,J,N)=U1(I,J,N)+UVTQ(I,J,1,1)
+ V1(I,J,N)=V1(I,J,N)+UVTQ(I,J,1,2)
+ ELSE IF(PMV1(I,J,N).LE.P2(KMX))THEN
+ U1(I,J,N)=U1(I,J,N)+UVTQ(I,J,KMX,1)
+ V1(I,J,N)=V1(I,J,N)+UVTQ(I,J,KMX,2)
+ ELSE
+ DO K=1,KMX-1
+ IF(PMV1(I,J,N).LE.P2(K).and.PMV1(I,J,N).GT.P2(K+1))THEN
+ W1=ALOG(1.*P2(K+1))-ALOG(1.*P2(K))
+ W=(ALOG(1.*PMV1(I,J,N))-ALOG(1.*P2(K)))/W1
+ U1(I,J,N)=U1(I,J,N)+UVTQ(I,J,K,1)+
+ & (UVTQ(I,J,K+1,1)-UVTQ(I,J,K,1))*W
+ V1(I,J,N)=V1(I,J,N)+UVTQ(I,J,K,2)+
+ & (UVTQ(I,J,K+1,2)-UVTQ(I,J,K,2))*W
+ GO TO 24
+ END IF
+ END DO
+ END IF
+ 24 CONTINUE
+ END DO
+ END DO
+ END DO
+
+ DO K=1,NZ+1
+ WRITE(61)((Z1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ+1
+ WRITE(61)((P1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(61)((T1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(61)((Q1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(61)((U1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+ DO K=1,NZ
+ WRITE(61)((V1(I,J,K),I=1,NX),J=1,NY,2)
+ END DO
+
+! Compute USC and VSC at Z=0
+
+ DO J=1,NY
+ DO I=1,NX
+ IF(ZMV1(I,J,1).LT.0.)THEN ! Below SEA LEVEL
+ USC(I,J)=U1(I,J,1)
+ VSC(I,J)=V1(I,J,1)
+ ELSE
+! DP1=PMV1(I,J,1)*((1.+GAMMA*ZMV1(I,J,1)/TMV1(I,J))**COEF2-1.)
+ DP1=0.
+ USC(I,J)=U1(I,J,1)*(1.-DP1*1.4E-5)
+ VSC(I,J)=V1(I,J,1)*(1.-DP1*1.4E-5)
+ END IF
+ END DO
+ END DO
+
+ rewind KUNIT
+
+ WRITE(KUNIT) NX,NY,NZ,I360
+ WRITE(KUNIT) LON1,LAT1,LON2,LAT2,CENTRAL_LON,CENTRAL_LAT
+ WRITE(KUNIT) PM1
+ WRITE(KUNIT) T1
+ WRITE(KUNIT) Q1
+ WRITE(KUNIT) U1
+ WRITE(KUNIT) V1
+ WRITE(KUNIT) DZDT
+ WRITE(KUNIT) Z1
+ WRITE(KUNIT) HLON,HLAT,VLON,VLAT
+ WRITE(KUNIT) P1
+ WRITE(KUNIT) PD
+ WRITE(KUNIT) ETA1
+ WRITE(KUNIT) ETA2
+ WRITE(KUNIT) USC
+ WRITE(KUNIT) VSC
+
+
+ DEALLOCATE ( ZM1,PM1,TV1 )
+
+ DEALLOCATE ( ZMV1,PMV1,HV )
+
+ DEALLOCATE ( T2,Q2 )
+ DEALLOCATE ( U2,V2 )
+ DEALLOCATE ( P2,SLP,Z2,SIG )
+ DEALLOCATE ( HP,RH )
+
+ DEALLOCATE ( UVTQ )
+
+ print*,'test11'
+
+!C END OF ROUTINE.
+!C
+! RETURN
+ END
+
+
+ SUBROUTINE HURR_MESS(ITIM,IBGS,IMAX,JMAX,GLON,GLAT,
+ & I360)
+
+! all common blocks are output
+
+ PARAMETER (IRX=41,JRX=41,NST=10)
+ PARAMETER (MAXVIT=15)
+
+ REAL(4) GLAT(IMAX,JMAX),GLON(IMAX,JMAX)
+ real(4) SLON_N,SLAT_N,CLON_N,CLAT_N
+
+ COMMON /NHC/ KSTM,IC_N(NST),JC_N(NST)
+ COMMON /NHC1/ SLON_N(NST),SLAT_N(NST),CLON_N(NST),CLAT_N(NST)
+ DIMENSION STMDIR(NST),STMSPD(NST)
+ CHARACTER ST_NAME(NST)*3,STMNAME(NST)*3,TCVT(NST)*95
+ COMMON /STNAME/ST_NAME,STMNAME
+ COMMON /TCVIT/TCVT
+ COMMON /RSFC/STRPSF(NST),STVMAX(NST),STRPSF_06(NST)
+
+
+ CHARACTER BUFIN(95)*1,BUFY2K(95)*1,STMNAM(NST)*12,STMNMZ*9
+ CHARACTER FMTVIT(MAXVIT)*6,BUFINZ*100,LATNS*1,LONEW*1
+
+ DIMENSION IVTVAR(MAXVIT),VITVAR(MAXVIT),VITFAC(MAXVIT),
+ & ISTVAR(MAXVIT),IENVAR(MAXVIT)
+ DIMENSION ISTMCX1(7,NST),ISTMCY1(7,NST),STMCX(NST),STMCY(NST)
+ DATA ISTVAR/20,29,34,39,45,49,53,58,63,68,71,75,80,85,90/
+ DATA IENVAR/27,32,36,42,47,51,56,61,66,69,73,78,83,88,93/
+ DATA VITFAC/2*1.0,2*0.1,1.0,0.1,9*1.0/
+ DATA FMTVIT/'(I8.8)','(I4.4)','(I3.3)','(I4.4)',2*'(I3.3)',
+ & 3*'(I4.4)','(I2.2)','(I3.3)',4*'(I4.4)'/
+
+ EQUIVALENCE (BUFIN(37),LATNS),(BUFIN(43),LONEW),
+ & (BUFIN(10),STMNMZ),(BUFIN(1),BUFINZ)
+ EQUIVALENCE (IVTVAR(1),IDATEZ),(IVTVAR(2),IUTCZ)
+!
+ EQUIVALENCE (VITVAR( 3),STMLTZ),(VITVAR( 4),STMLNZ),
+ & (VITVAR( 5),STMDRZ),(VITVAR( 6),STMSPZ),
+ 1 (VITVAR( 9),RMPSFZ),(VITVAR(10),STMVMX)
+!
+ DO I=1,10
+ SLON_N(I)=0.
+ SLAT_N(I)=0.
+ CLON_N(I)=0.
+ CLAT_N(I)=0.
+ IC_N(I)=0
+ JC_N(I)=0
+! STMNAME(I)='NUL'
+ ST_NAME(I)='NUL'
+ STRPSF(I)=3.0
+ STVMAX(I)=0.
+ STRPSF_06(I)=3.0
+ END DO
+
+ INDX1=ITIM-2
+
+ K1STM=0
+ DO I=1,10
+ STMCX(I)=0.
+ STMCY(I)=0.
+ STMNAME(I)='NUL'
+ READ(30,442,end=436)
+ & (ISTMCY1(J,I),ISTMCX1(J,I),J=1,7),STMNAME(I)
+ do j=1,7
+ ISTMCX1(J,I)=-ISTMCX1(J,I)
+ end do
+ if(I360.eq.180)then
+ do j=1,7
+ IF(ISTMCX1(J,I).LT.-1800)
+ & ISTMCX1(J,I)=3600+ISTMCX1(J,I)
+ end do
+ end if
+ DYM1=0.
+ DXM1=0.
+ DYP1=0.
+ DXP1=0.
+ IF(ISTMCY1(1,I)*ISTMCY1(4,I).NE.0)THEN
+ DYM1=(ISTMCY1(4,I)-ISTMCY1(1,I))/3.
+ DXM1=(ISTMCX1(4,I)-ISTMCX1(1,I))/3.
+ END IF
+ IF(ISTMCY1(4,I)*ISTMCY1(7,I).NE.0)THEN
+ DYP1=(ISTMCY1(7,I)-ISTMCY1(4,I))/3.
+ DXP1=(ISTMCX1(7,I)-ISTMCX1(4,I))/3.
+ END IF
+ IF( ISTMCY1(2,I) == 999) ISTMCY1(2,I)=ISTMCY1(4,I)-DYM1*2.
+ IF( ISTMCY1(3,I) == 999) ISTMCY1(3,I)=ISTMCY1(4,I)-DYM1*1.
+ IF( ISTMCX1(2,I) == 999) ISTMCX1(2,I)=ISTMCX1(4,I)-DXM1*2.
+ IF( ISTMCX1(3,I) == 999) ISTMCX1(3,I)=ISTMCX1(4,I)-DXM1*1.
+ IF( ISTMCY1(5,I) == 999) ISTMCY1(5,I)=ISTMCY1(4,I)+DYP1*1.
+ IF( ISTMCY1(6,I) == 999) ISTMCY1(6,I)=ISTMCY1(4,I)+DYP1*2.
+ IF( ISTMCX1(5,I) == 999) ISTMCX1(5,I)=ISTMCX1(4,I)+DXP1*1
+ IF( ISTMCX1(6,I) == 999) ISTMCX1(6,I)=ISTMCX1(4,I)+DXP1*2
+!
+! STMCX(I)=360.-ISTMCX1(INDX1,I)*0.1
+ STMCX(I)=ISTMCX1(INDX1,I)*0.1
+ STMCY(I)=ISTMCY1(INDX1,I)*0.1
+ K1STM=K1STM+1
+ PRINT*,' CT STORM Model CENTER at ',ITIM,'h = ',
+ & STMNAME(I),STMCX(I),STMCY(I)
+ END DO
+ 442 FORMAT(14x,14i5,25x,A3)
+ 436 CONTINUE
+
+ REWIND 30
+
+ 90 REWIND 11
+ KREC=0
+ KSTORM=0
+ NERROR=0
+
+! Get the hurricane center from the hurricane message made by NHC
+
+! READ A RECORD INTO BUFFER
+
+ 100 CONTINUE
+ READ(11,101,ERR=990,END=200) (BUFIN(NCH),NCH=1,95)
+ 101 FORMAT(95A1)
+
+ if(BUFIN(35).eq.'N' .or. BUFIN(35).eq.'S') then
+
+ print *, ' '
+ print *, '==> Read in RECORD from tcvitals file -- contains a',
+ & ' 2-digit year "'
+ print *, ' '
+
+ BUFY2K(1:19) = BUFIN(1:19)
+ IF(BUFIN(20)//BUFIN(21).GT.'20') THEN
+ BUFY2K(20) = '1'
+ BUFY2K(21) = '9'
+ ELSE
+ BUFY2K(20) = '2'
+ BUFY2K(21) = '0'
+ ENDIF
+ BUFY2K(22:95) = BUFIN(20:93)
+ BUFIN = BUFY2K
+
+ print *, ' '
+ print *, '==> 2-digit year converted to 4-digit year "'
+ print *, ' '
+
+ else if(BUFIN(37).eq.'N' .or. BUFIN(37).eq.'S') then
+
+ print *, ' '
+ print *, '==> Read in RECORD from tcvitals file -- contains a',
+ & ' 4-digit year "'
+ print *, ' '
+
+ else
+
+ print *, ' '
+ print *, '***** Cannot determine if this record contains ',
+ & 'a 2-digit year or a 4-digit year - skip it and try reading ',
+ & 'the next record'
+ print *, ' '
+ go to 100
+
+ end if
+
+ KREC=KREC+1
+
+ DO I=1,3
+ ST_NAME(KREC)(I:I)=BUFIN(I+5)
+ END DO
+ DO I=1,95
+ TCVT(KREC)(I:I)=BUFIN(I)
+ END DO
+
+! DECODE DATE AND TIME
+
+ DO 110 IV=1,2
+ CALL DECVAR(ISTVAR(IV),IENVAR(IV),IVTVAR(IV),IERDEC,
+ & FMTVIT(IV),BUFINZ)
+
+ 110 CONTINUE
+
+ DO 140 IV=3,MAXVIT
+ CALL DECVAR(ISTVAR(IV),IENVAR(IV),IVTVAR(IV),IERDEC,
+ & FMTVIT(IV),BUFINZ)
+ VITVAR(IV)=REAL(IVTVAR(IV))*VITFAC(IV)
+ 140 CONTINUE
+
+! *****************************************************
+! *****************************************************
+! **** IMPORTANT NOTES: ****
+! **** ****
+! **** ALL STORM LONGITUDES CONVERTED TO ****
+! **** 0-360 DEGREES, POSITIVE EASTWARD !!! ****
+! **** ****
+! **** ALL STORM SPEEDS ARE IN M/SEC ****
+! **** ****
+! **** ALL DISTANCE DATA ARE IN KM ****
+! **** ****
+! **** ALL PRESSURE DATA ARE IN HPA (MB) ****
+! *****************************************************
+! *****************************************************
+
+! SIGN OF LATITUDE AND CONVERT LONGITUDE
+
+ IF(LATNS .EQ. 'S') THEN
+ STMLTZ=-STMLTZ
+ ELSE IF(LATNS .NE. 'N') THEN
+ WRITE(6,153) STMLTZ,STMLNZ,LATNS
+ 153 FORMAT('******ERROR DECODING LATNS, ERROR RECOVERY NEEDED.',
+ & ' STMLTZ,STMLNZ,LATNS=',2F12.2,2X,A1)
+ GO TO 100
+ ENDIF
+
+ IF(LONEW .EQ. 'W') THEN
+ STMLNZ=-STMLNZ
+ ELSE IF(LONEW .EQ. 'E') THEN
+ if(I360.eq.360)then
+ STMLNZ=-360+STMLNZ
+ end if
+ ELSE IF(LONEW .NE. 'E') THEN
+ WRITE(6,157) STMLTZ,STMLNZ,LATNS
+ 157 FORMAT('******ERROR DECODING LONEW, ERROR RECOVERY NEEDED.',
+ & ' STMLTZ,STMLNZ,LATNS=',2F12.2,2X,A1)
+ ENDIF
+
+ PRINT*,'STMLTZ,STMLNZ,LATNS=',STMLTZ,STMLNZ,LATNS
+ PRINT*,'IDATEZ,IUTCZ=',IDATEZ,IUTCZ
+
+ print*,'STMNAME(1),STMNMZ(KREC)=',STMNAME(1),ST_NAME(KREC)
+
+ DO I=1,10
+ IF(STMNAME(I).EQ.ST_NAME(KREC))THEN
+ STMCX21=STMCX(I)
+ STMCY21=STMCY(I)
+ STMLTZ=STMCY(I)
+ STMLNZ=STMCX(I)
+ go to 785
+ END IF
+ END DO
+
+ 785 continue
+
+ PRINT*,'STMCX21,STMCY21=',STMCX21,STMCY21
+
+ IF(KSTORM .LT. 10) THEN
+
+ KSTORM=KSTORM+1
+ CLAT_N(KSTORM)=STMLTZ
+ CLON_N(KSTORM)=STMLNZ
+ STMDIR(KSTORM)=STMDRZ
+ STMSPD(KSTORM)=STMSPZ
+ STMNAM(KSTORM)=STMNMZ
+ STRPSF(KSTORM)=RMPSFZ
+ STVMAX(KSTORM)=STMVMX
+ GO TO 100
+
+ ELSE
+
+ 300 WRITE(6,301) KSTORM
+ 301 FORMAT(/'******KSTORM EXCEEDS AVAILABLE SPACE, KSTORM=',
+ & I5,/,' Results may have serious problem')
+ GO TO 200
+
+ ENDIF
+
+ 200 IF(KSTORM .GT. 0) THEN
+ WRITE(6,201)KSTORM,KREC
+ 201 FORMAT(/'...FOUND STORM IN VITALS FILE.',/,4X,I5,
+ & ' TOTAL NUMBER OF RECORDS READ=',I7)
+ ELSE
+ WRITE(6,202)
+ 202 FORMAT(/'NO STORM FOUND IN VITALS FILE.')
+! CALL W3TAGE('RELOCATE_MV_NVORTEX_T254L64')
+! CALL ERREXIT(56)
+ STOP
+ END IF
+
+! Correct to the storm center position
+
+ PI=ATAN(1.0)*4.E+00
+ PI180 = PI/180.
+ DT=(float(ITIM)-6.)*3600. ! Second
+ ONEDEG=360./(2.*PI*6.37E6) ! Degree/Meter
+ FACT=DT*ONEDEG
+
+ KSTM=KSTORM
+
+ DO I=1,KSTM
+
+ WRITE(*,430)STMNAM(I),CLAT_N(I),CLON_N(I),STMDIR(I),STMSPD(I)
+ 430 FORMAT(/' STORM NAME: ',A12,/, ' READIN STORM CENTER=',2F12.4,
+ & /,' STORM DIR and SPEED: ',2F12.4)
+
+ PRINT*,'RAD OUTMOST CLOSED ISOBAR= ',STRPSF(I),' km'
+ STRPSF(I)=STRPSF(I)*1000.*ONEDEG
+ PRINT*,'RAD OUTMOST CLOSED ISOBAR= ',STRPSF(I),' degree'
+ PRINT*,'MAX STORM WIND SPEED = ',STVMAX(I),' m/s'
+
+ END DO
+
+! IF(IBGS.EQ.0)THEN
+! DO I=1,KSTM
+! READ(21,21) Ipsfc,Ipcls,Irmax
+! STRPSF_06(I)=Irmax*1000.*ONEDEG
+! END DO
+! 21 format(52x,I4,1x,I4,1x,I4)
+! END IF
+
+ DO I=1,KSTM
+ DO K=1,K1STM
+ IF(STMNAME(K).EQ.ST_NAME(I))THEN
+ IFWRT=0
+ DO J=1,7
+ IF(ISTMCY1(J,K).EQ.0.and.ISTMCX1(J,K).EQ.0)THEN
+ IFWRT=1
+ END IF
+ END DO
+ IF(IFWRT.EQ.0)THEN
+ XDIST6H=CLON_N(I)-ISTMCX1(4,K)*0.1
+ YDIST6H=CLAT_N(I)-ISTMCY1(4,K)*0.1
+ CLON_N(I)=STMCX(K)+XDIST6H
+ CLAT_N(I)=STMCY(K)+YDIST6H
+ ELSE
+ USTM=STMSPD(I)*SIN(PI180*STMDIR(I))
+ VSTM=STMSPD(I)*COS(PI180*STMDIR(I))
+ CLON_N(I)=CLON_N(I)+USTM*FACT/COS(PI180*CLAT_N(I))
+ CLAT_N(I)=CLAT_N(I)+VSTM*FACT
+ END IF
+ PRINT*, ' CT STORM OBS. CENTER at ',ITIM,'h = ',
+ & STMNAME(K),CLON_N(I),CLAT_N(I)
+ END IF
+ END DO
+ END DO
+
+
+ DO 900 I=1,KSTM
+
+ CLON=CLON_N(I)
+ CLAT=CLAT_N(I)
+
+ AMN = 500.
+ DO ILA = 1,JMAX
+ DO ILO = 1,IMAX
+ DMN = GLAT(ILO,ILA) - CLAT
+ OMN = GLON(ILO,ILA) - CLON
+ DISTC=DMN*DMN+OMN*OMN
+ IF(ILA*ILO.LT.20)PRINT*,'GLON,GLAT=',
+ & GLON(ILO,ILA),GLAT(ILO,ILA),DISTC
+ IF (DISTC.LE.AMN) THEN
+ AMN = DISTC
+ JC = ILA
+ IC = ILO
+ ENDIF
+ END DO
+ END DO
+
+ IC_N(I)=IC
+ JC_N(I)=JC
+
+ PRINT *,'CLON,CLAT=',CLON,CLAT
+ PRINT *,'IC,JC= ',IC,JC,GLON(IC,JC),GLAT(IC,JC)
+
+ SLON_N(I) = floor(GLON(IC,JC)+0.5 - IRX/2)
+ SLAT_N(I) = floor(GLAT(IC,JC)+0.5 - JRX/2)
+ PRINT *,' '
+ PRINT *,'=========================================='
+ PRINT *,'SLON,SLAT=',SLON_N(I),SLAT_N(I)
+
+
+ 900 CONTINUE
+
+ RETURN
+
+ 990 WRITE(6,991) BUFIN
+ 991 FORMAT('******ERROR READING STORM RECORD. BUFIN IS:',/,
+ & ' ******',A95,'******')
+ GO TO 100
+ RETURN
+
+ END
+
+ SUBROUTINE DECVAR(ISTART,IEND,IVALUE,IERDEC,FMT,BUFF)
+
+ PARAMETER (NCHLIN=130)
+
+ CHARACTER FMT*(*),BUFF*(*),OUTLIN*1
+
+ DIMENSION OUTLIN(NCHLIN)
+
+!c && 2 comments
+!CC WRITE(6,1) FMT,BUFF
+!CC 1 FORMAT(/'...FMT=',A10,/,' ...BUFF=',A100)
+
+ READ(BUFF(ISTART:IEND),FMT,ERR=10) IVALUE
+ IERDEC=0
+ RETURN
+
+ 10 CONTINUE
+
+ OUTLIN=' '
+
+ IERDEC=10
+ OUTLIN(ISTART:IEND)='*'
+
+ WRITE(6,31) (OUTLIN(ICH1),ICH1=1,NCHLIN)
+ WRITE(6,32) BUFF
+ 31 FORMAT(/'******ERROR DECODING, BUFF=',/,130A1)
+ 32 FORMAT(A130)
+
+ RETURN
+ END
+
+ subroutine wrf_move(ITIM,KST,grid_lon,grid_lat,
+ & US850,VS850,KS850,P2,zwindow,
+ & twindow,qwindow,uwindow,vwindow,pwindow,SIG,
+ & HLAT,HLON,VLAT,VLON,lmeta,iswin,iewin,
+ & jswin,jewin,IBGS,IVOBS,iflag_cold,I360,crfactor)
+!
+! ITIM: Time level
+! CLON_N,CLAT_N: observed storm center
+! CLON_TIM,CLAT_TIM: storm center in the model
+! lower-left corner of the 41x41 degree domain
+! grid_lon,grid_lat,SIG: grid coordinate
+! twindow,qwindow,uwindow,vwindow,pwindow: input data
+! iswin,iewin,jswin,jewin,lmeta: coordinate index range
+
+! insert storm relocation code here
+
+ implicit none
+
+ integer(4) IRX,JRX,MTV4,MTV6,NST,IBGS,IVOBS
+ integer iflag_cold,I360
+ integer IST,IED,JST,JED,KS850,gd_dim3
+ parameter (IRX=41,JRX=41,NST=10,gd_dim3=450)
+
+ integer(4) iswin,iewin,jswin,jewin,lmeta
+ real(4) twindow(iswin:iewin,jswin:jewin,lmeta)
+ real(4) qwindow(iswin:iewin,jswin:jewin,lmeta)
+ real(4) uwindow(iswin:iewin,jswin:jewin,lmeta)
+ real(4) vwindow(iswin:iewin,jswin:jewin,lmeta)
+ real(4) pwindow(iswin:iewin,jswin:jewin)
+ real(4) zwindow(iswin:iewin,jswin:jewin)
+
+ real(4) grid_lon(iswin:iewin,jswin:jewin)
+ real(4) grid_lat(iswin:iewin,jswin:jewin)
+ real(4) sig(lmeta)
+
+ real(4) HLAT(iswin:iewin,jswin:jewin)
+ real(4) HLON(iswin:iewin,jswin:jewin)
+ real(4) VLAT(iswin:iewin,jswin:jewin)
+ real(4) VLON(iswin:iewin,jswin:jewin)
+
+ real(4) US850(iswin:iewin,jswin:jewin)
+ real(4) VS850(iswin:iewin,jswin:jewin)
+
+ integer(4) IGD(IRX,JRX,gd_dim3),JGD(IRX,JRX,gd_dim3)
+ integer(4) NSUM(IRX,JRX),NGRID
+ real WGD(IRX,JRX,gd_dim3),WSUM(IRX,JRX)
+
+ real(4) U850(IRX,JRX),V850(IRX,JRX)
+ real(4) P2(lmeta)
+
+ integer(4) i,j,k,i1,j1,inx,jnx,kmx,ITIM
+ integer(4) inx1,jnx1,irx1,jrx1
+ integer(4) k1,k2,k3,k4,k5,k6
+ integer(4) m,n,m1,n1,n_check
+ real(8) coef1,coef2,coef3
+ real(8) rdst,rdst1,sdat1,dist,cost2
+ real(4) XB1,XB2,YB1,YB2,AB1,AB2,BB1,BB2
+ real(4) crfactor
+
+ real(4),allocatable::vort(:,:,:),divg(:,:,:)
+! real(8),allocatable::coslat(:,:),dx(:,:),dy(:,:)
+! real(4),allocatable::aft(:,:),bft(:,:),cft(:,:)
+! real(4),allocatable::dft(:,:),eft(:,:),fnt(:,:)
+! real(4),allocatable::SF1(:,:,:),SF2(:,:,:)
+ real(4),allocatable::HDATN(:,:,:),SDAT(:,:,:)
+ real(4),allocatable::BLON(:),BLAT(:),XLON(:,:),XLAT(:,:)
+ real(4),allocatable::XLON1(:,:),XLAT1(:,:)
+
+ real(8) pi,pi180,delt1,COSLAT2
+! real(4) rjac,c_latg,c_long
+
+! real(8) test3,uv_diff,uv_tt
+
+ integer(4) KST
+
+ real(4) SLON_N,SLAT_N,CLON_N,CLAT_N
+
+ CHARACTER ST_NAME(NST)*3,STMNAME(NST)*3,TCVT(NST)*95
+
+ COMMON /NHC1/ SLON_N(NST),SLAT_N(NST),CLON_N(NST),CLAT_N(NST)
+ COMMON /STNAME/ST_NAME,STMNAME
+ COMMON /TCVIT/TCVT
+
+ inx=iewin-iswin+1
+ jnx=jewin-jswin+1
+ kmx=lmeta
+ MTV4=4*kmx+2
+ MTV6=6*kmx+2
+
+ allocate (vort(inx,jnx,kmx),divg(inx,jnx,kmx))
+! allocate (coslat(inx,jnx),dx(inx,jnx),dy(inx,jnx))
+! allocate (aft(inx,jnx),bft(inx,jnx),cft(inx,jnx))
+! allocate (dft(inx,jnx),eft(inx,jnx),fnt(inx,jnx))
+! allocate (SF1(inx,jnx,kmx),SF2(inx,jnx,kmx))
+ allocate (SDAT(IRX,JRX,MTV6))
+ allocate (BLON(IRX),BLAT(JRX))
+ allocate (XLON(inx,jnx),XLAT(inx,jnx))
+ allocate (XLON1(inx,jnx),XLAT1(inx,jnx))
+
+ pi=4.*atan(1.)
+ pi180=pi/180.
+! delt1=6.371E6*pi180
+! rjac=cos(pi/jnx)
+
+ do j=1,jnx
+ do i=1,inx
+ i1=iswin+i-1
+ j1=jswin+j-1
+! coslat(i,j)=cos(grid_lat(i1,j1)*pi180)
+! XLON1(i,j)=grid_lon(i1,j1)
+! XLAT1(i,j)=grid_lat(i1,j1)
+ XLON1(i,j)=HLON(i1,j1)
+ XLAT1(i,j)=HLAT(i1,j1)
+
+ XLON(i,j)=VLON(i1,j1) ! LON, LAT at U,V grids
+ XLAT(i,j)=VLAT(i1,j1)
+ end do
+ end do
+
+ do i=1,IRX
+ BLON(i)=SLON_N(kst)+i-1.
+ end do
+ do j=1,JRX
+ BLAT(j)=SLAT_N(kst)+j-1.
+ end do
+
+ XB1=XLON1(1,1)
+ XB2=XLON1(INX-1,1)
+ DO J=1,JNX,2
+ IF(XB1.LT.XLON1(1,J))XB1=XLON1(1,J)
+ IF(XB2.GT.XLON1(INX-1,J))XB2=XLON1(INX-1,J)
+ END DO
+!
+ YB1=XLAT1(1,2)
+ YB2=XLAT1(1,JNX-1)
+ DO I=1,INX
+ IF(YB1.LT.XLAT1(I,2))YB1=XLAT1(I,2)
+ IF(YB2.GT.XLAT1(I,JNX-1))YB2=XLAT1(I,JNX-1)
+ END DO
+
+ RDST=0.25
+
+ XB1=XB1+RDST
+ XB2=XB2-RDST
+ YB1=YB1+RDST
+ YB2=YB2-RDST
+
+ AB1=BLON(1)
+ AB2=BLON(IRX)
+ BB1=BLAT(1)
+ BB2=BLAT(JRX)
+
+ print*,'XB1,XB2,AB1,AB2=',XB1,XB2,AB1,AB2
+ print*,'YB1,YB2,BB1,BB2=',YB1,YB2,BB1,BB2
+
+ IF(AB1.LT.XB1.or.AB2.GT.XB2.or.BB1.LT.YB1.or.BB2.GT.YB2)THEN
+ CALL CREAT_41X41(ITIM,KST,KMX,MTV6,KS850,U850,V850,SDAT,P2)
+! RDST1=0.75
+ IST=8
+ IED=33
+ JST=8
+ JED=33
+ print*,'using outer nest data'
+ ELSE
+! RDST1=0.06
+ IST=1
+ IED=IRX
+ JST=1
+ JED=JRX
+ END IF
+ print*,'crfactor=',crfactor
+ RDST=0.05*crfactor
+ print*,'RDST=', RDST
+ RDST1=RDST*RDST
+
+ DO J=1,JNX
+ DO I=1,INX
+ i1=iswin+i-1
+ j1=jswin+j-1
+ DO K=1,KMX
+ vort(i,j,k)=uwindow(i1,j1,k)
+ divg(i,j,k)=vwindow(i1,j1,k)
+ END DO
+ END DO
+ END DO
+
+
+!23456789012345678901234567890123456789012345678901234567890123456789012
+
+ allocate (HDATN(inx,jnx,MTV4))
+
+ DO J=1,JNX
+ DO I=1,INX
+ i1=iswin+i-1
+ j1=jswin+j-1
+ HDATN(I,J,1)=zwindow(i1,j1)
+ HDATN(I,J,2)=pwindow(i1,j1)
+ END DO
+ END DO
+
+ DO K=1,KMX
+ K1=K+2
+ K2=2*(K-1)+1+KMX+2 ! div ==> u
+ K3=2*(K-1)+2+KMX+2 ! vor ==> v
+ K4=K+3*KMX+2
+ DO J=1,JNX
+ DO I=1,INX
+ i1=iswin+i-1
+ j1=jswin+j-1
+ HDATN(I,J,K1)=twindow(i1,j1,K)
+ HDATN(I,J,K2)=vort(i,j,K) ! div ==> u
+ HDATN(I,J,K3)=divg(i,j,K) ! vor ==> v
+ HDATN(I,J,K4)=qwindow(i1,j1,K)
+ END DO
+ END DO
+ END DO
+
+
+! do k=1,kmx
+! write(27)((twindow(I,J,k),i=iswin,iewin),j=jswin,jewin)
+! end do
+! do k=1,kmx
+! write(27)((vwindow(I,J,k),i=iswin,iewin),j=jswin,jewin)
+! end do
+
+! write(27)((vort(I,J,33),I=1,INX),J=1,JNX)
+! write(27)((divg(I,J,33),I=1,INX),J=1,JNX)
+
+
+! fill the center area with inner nest data
+! for 6 degree inner nest, using 10 degree data
+
+
+ print*,'compute weight'
+
+ IGD=0
+ JGD=0
+ WGD=0
+ NSUM=0
+ WSUM=0.
+
+ N_CHECK=0
+
+!$omp parallel do
+!$omp& private(i,j,k,N,NGRID,COST2,DIST)
+ DO J=JST,JED
+ DO I=IST,IED
+ NGRID=0
+ NSUM(I,J)=0.
+ WSUM(I,J)=0.
+ DO N=1,JNX
+ DO K=1,INX
+ COST2=(COS((XLAT(K,N)+BLAT(J))*0.5*pi180))**2
+ DIST=COST2*(XLON(K,N)-BLON(I))**2+
+ & (XLAT(K,N)-BLAT(J))**2
+ IF(DIST.LE.RDST1)THEN
+ NGRID=NGRID+1
+ IGD(I,J,NGRID)=K
+ JGD(I,J,NGRID)=N
+ WGD(I,J,NGRID)=EXP(-DIST/RDST1)
+ WSUM(I,J)=WSUM(I,J)+WGD(I,J,NGRID)
+ NSUM(I,J)=NGRID
+ END IF
+ END DO
+ END DO
+ END DO
+ END DO
+
+ if(NGRID.GT.gd_dim3)STOP 12
+
+ DO J=JST,JED
+ DO I=IST,IED
+ IF(NSUM(I,J).GT.5)THEN
+ N_CHECK=1
+ ELSE
+ print*,'QQQ I,J=',I,J,NSUM(I,J),WSUM(I,J),BLON(I),BLAT(J)
+! N_CHECK=0
+ END IF
+ END DO
+ END DO
+
+ IF(N_CHECK.EQ.0)THEN
+ print*,'increase RDST1'
+ stop
+ END IF
+
+ print*,'corners=',XLON(1,1),XLON(INX,JNX)
+ print*,'corners=',XLAT(1,1),XLAT(INX,JNX)
+
+!$omp parallel do
+!$omp& private(i,j,N,i1,j1,SDAT1)
+ DO J=JST,JED
+ DO I=IST,IED
+ IF(NSUM(I,J).GT.5)THEN
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+US850(I1,J1)*WGD(I,J,N)
+ END DO
+ U850(I,J)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+VS850(I1,J1)*WGD(I,J,N)
+ END DO
+ V850(I,J)=SDAT1/WSUM(I,J)
+ END IF
+ ENDDO
+ ENDDO
+
+!$omp parallel do
+!$omp& private(i,j,k,N,K2,K3,K5,K6,SDAT1,I1,J1)
+ DO K=1,KMX
+ K2=4*(K-1)+3+KMX+2
+ K3=4*(K-1)+4+KMX+2
+ K5=4*(K-1)+1+KMX+2 ! div (here U,V, otherwise move to next loop)
+ K6=4*(K-1)+2+KMX+2 ! vor
+ DO J=JST,JED
+ DO I=IST,IED
+ IF(NSUM(I,J).GT.5)THEN
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+uwindow(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K2)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+vwindow(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K3)=SDAT1/WSUM(I,J)
+ SDAT(I,J,K5)=SDAT(I,J,K2)
+ SDAT(I,J,K6)=SDAT(I,J,K3)
+ END IF
+ ENDDO
+ ENDDO
+ ENDDO
+
+!*** FOR T PS points
+
+
+ IGD=0
+ JGD=0
+ WGD=0
+!$omp parallel do
+!$omp& private(i,j,k,N,NGRID,COST2,DIST)
+ DO J=JST,JED
+ DO I=IST,IED
+ NGRID=0
+ WSUM(I,J)=0.
+ DO N=1,JNX
+ DO K=1,INX
+ COST2=(COS((XLAT1(K,N)+BLAT(J))*0.5*pi180))**2
+ DIST=COST2*(XLON1(K,N)-BLON(I))**2+
+ & (XLAT1(K,N)-BLAT(J))**2
+ IF(DIST.LE.RDST1)THEN
+ NGRID=NGRID+1
+ IGD(I,J,NGRID)=K
+ JGD(I,J,NGRID)=N
+ WGD(I,J,NGRID)=EXP(-DIST/RDST1)
+ WSUM(I,J)=WSUM(I,J)+WGD(I,J,NGRID)
+ NSUM(I,J)=NGRID
+ END IF
+ END DO
+ END DO
+ END DO
+ END DO
+
+
+!$omp parallel do
+!$omp& private(i,j,N,SDAT1,I1,J1)
+ DO J=JST,JED
+ DO I=IST,IED
+ IF(NSUM(I,J).GT.5)THEN
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+zwindow(I1,J1)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,1)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+pwindow(I1,J1)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,2)=SDAT1/WSUM(I,J)
+ END IF
+ END DO
+ END DO
+
+! WRITE(83)((SDAT(I,J,1),I=1,41),J=1,41)
+! WRITE(83)((SDAT(I,J,2),I=1,41),J=1,41)
+
+!$omp parallel do
+!$omp& private(i,j,K,K1,K4,N,SDAT1,I1,J1)
+ DO K=1,KMX
+ K1=K+2
+! K2=4*(K-1)+3+KMX+2
+! K3=4*(K-1)+4+KMX+2
+ K4=K+5*KMX+2
+! K5=4*(K-1)+1+KMX+2 ! div
+! K6=4*(K-1)+2+KMX+2 ! vor
+ DO J=JST,JED
+ DO I=IST,IED
+ IF(NSUM(I,J).GT.5)THEN
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+twindow(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K1)=SDAT1/WSUM(I,J)
+ SDAT1=0.
+ DO N=1,NSUM(I,J)
+ I1=IGD(I,J,N)
+ J1=JGD(I,J,N)
+ SDAT1=SDAT1+qwindow(I1,J1,K)*WGD(I,J,N)
+ END DO
+ SDAT(I,J,K4)=SDAT1/WSUM(I,J)
+ END IF
+ ENDDO
+ ENDDO
+
+! WRITE(83)((SDAT(I,J,K1),I=1,41),J=1,41)
+
+ ENDDO
+
+! DO K=1,KMX
+! K4=K+5*KMX+2
+! WRITE(83)((SDAT(I,J,K4),I=1,41),J=1,41)
+! END DO
+
+! write(33)((pwindow(I,J),I=1,INX),J=1,JNX,2)
+! DO K=1,KMX
+! write(33)((twindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(33)((vort(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(33)((divg(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(33)((qwindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+
+
+
+ CALL HURR_MOVE(ITIM,KST,INX,JNX,KMX,MTV6,MTV4,SDAT,HDATN,
+ & U850,V850,XLON1,XLAT1,XLON,XLAT,SIG,IBGS,IVOBS,
+ & iflag_cold,I360)
+
+
+!23456789012345678901234567890123456789012345678901234567890123456789012
+
+
+ DO J=1,JNX
+ DO I=1,INX
+ i1=iswin+i-1
+ j1=jswin+j-1
+ zwindow(i1,j1)=HDATN(I,J,1)
+ pwindow(i1,j1)=HDATN(I,J,2)
+ END DO
+ END DO
+
+ DO K=1,KMX
+ K1=K+2
+ K2=2*(K-1)+1+KMX+2 ! div ==> u
+ K3=2*(K-1)+2+KMX+2 ! vor ==> v
+ K4=K+3*KMX+2
+ DO J=1,JNX
+ DO I=1,INX
+ i1=iswin+i-1
+ j1=jswin+j-1
+ twindow(i1,j1,K)=HDATN(I,J,K1)
+ vort(i,j,K)=HDATN(I,J,K2) ! div ==> u
+ divg(i,j,K)=HDATN(I,J,K3) ! vor ==> v
+ qwindow(i1,j1,K)=HDATN(I,J,K4)
+ END DO
+ END DO
+ END DO
+
+! write(29)((pwindow(I,J),I=1,INX),J=1,JNX,2)
+! DO K=1,KMX
+! write(29)((twindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(29)((vort(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(29)((divg(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! write(29)((qwindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+
+
+! aft=1.
+! bft=1.
+! do j=1,jnx
+! do i=1,inx
+! COSLAT2=COSLAT(i,j)*COSLAT(i,j)
+! cft(i,j)=COSLAT2
+! dft(i,j)=COSLAT2
+! eft(i,j)=-2.*(1.+COSLAT2)
+! end do
+! end do
+
+! print*,'compute SF1'
+
+! SF1=uwindow
+! DO k=1,kmx
+! fnt=0.
+! test3=0.
+! do j=3,jnx-2
+! do i=3,inx-2
+! fnt(i,j)=0.5*((divg(i+1,j,k)-divg(i-1,j,k))-
+! & (vort(i,j+1,k)-vort(i,j-1,k))*COSLAT(i,j))*
+! & dy(i,j)*COSLAT(i,j)
+! test3=test3+abs(fnt(i,j))
+! enddo
+! enddo
+!! write(6,*)test3
+! call sor(aft,bft,cft,dft,eft,fnt,SF1(1,1,k),jnx,rjac)
+! enddo
+
+! SF2=vwindow
+! do k=1,kmx
+! fnt=0.
+! do j=3,jnx-2
+! do i=3,inx-2
+! fnt(i,j)=0.5*((vort(i+1,j,k)-vort(i-1,j,k))+
+! & (divg(i,j+1,k)-divg(i,j-1,k))*COSLAT(i,j))*
+! & dy(i,j)*COSLAT(i,j)
+! enddo
+! enddo
+! call sor(aft,bft,cft,dft,eft,fnt,SF2(1,1,k),jnx,rjac)
+! enddo
+
+! uv_diff=0.
+! uv_tt=0.
+! DO k=1,kmx
+! do j=2,jnx-1
+! do i=2,inx-1
+! i1=iswin+i-1
+! j1=jswin+j-1
+! uv_diff=uv_diff+sqrt((SF1(i,j,k)-uwindow(i1,j1,k))**2+
+! & (SF2(i,j,k)-vwindow(i1,j1,k))**2)
+! uv_tt=uv_tt+sqrt(uwindow(i1,j1,k)**2+vwindow(i1,j1,k)**2)
+! enddo
+! enddo
+! enddo
+
+! print*,'uv_diff=',uv_diff,uv_diff/uv_tt
+
+ do j=1,jnx
+ do i=1,inx
+ i1=iswin+i-1
+ j1=jswin+j-1
+ do k=1,kmx
+ uwindow(i1,j1,k)=vort(i,j,k)
+ vwindow(i1,j1,k)=divg(i,j,k)
+ end do
+ end do
+ end do
+
+! uwindow=SF1
+! vwindow=SF2
+
+! DO K=1,KMX
+! WRITE(84)((uwindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+! DO K=1,KMX
+! WRITE(84)((vwindow(I,J,K),I=1,INX),J=1,JNX,2)
+! END DO
+
+
+ deallocate (vort,divg)
+! deallocate (coslat,dx,dy)
+! deallocate (aft,bft,cft)
+! deallocate (dft,eft,fnt)
+! deallocate (SF1,SF2)
+ deallocate (HDATN,SDAT)
+ deallocate (BLON,BLAT)
+ deallocate (XLON,XLAT)
+
+ return
+ end
+
+
+ SUBROUTINE sor(a,b,c,d,e,f,u,jmax,rjac)
+ INTEGER jmax,MAXITS
+ real(4) a(jmax,jmax),b(jmax,jmax),
+ & c(jmax,jmax),d(jmax,jmax),e(jmax,jmax),
+ & f(jmax,jmax),u(jmax,jmax)
+ PARAMETER (MAXITS=1000,EPS=1.e-3)
+
+!! Successive overrelaxation solution of equation (19.5.25)
+!! with Chebyshev acceleration. a, b, c, d, e, andfare input
+!! as the coe cients of the equation, each dimensioned to
+!! the grid size JMAX JMAX. u is input as the initial guess
+!! to the solution, usually zero, and returns with the
+!! nal value. rjac is input as the spectral radius of the
+!! Jacobi iteration, or an estimate of it.
+!! rjac=1.-2*pi/jmax
+
+ INTEGER ipass,j,jsw,l,lsw,n
+!! DOUBLE PRECISION anorm,anormf,omega,resid
+!! Double precision is a good idea for JMAX bigger than about 25.
+ anormf=0.d0
+!! Compute initial norm of residual and terminate iteration
+!! when norm has been reduced by a factor EPS.
+ do j=4,jmax-3
+ do l=4,jmax-3
+ anormf=anormf+abs(f(j,l)) !! Assumes initial u is zero.
+ enddo
+ enddo
+ print*,'test anormf=',anormf
+ omega=1.d0
+ do n=1,MAXITS
+ anorm=0.d0
+ jsw=1
+ do ipass=1,2 !! Odd-even ordering.
+ lsw=jsw
+! do j=2,jmax-1
+! do l=lsw+1,jmax-1,2
+ do j=4,jmax-3
+ do l=lsw+3,jmax-3,2
+ resid=a(j,l)*u(j+1,l)+b(j,l)*u(j-1,l)+
+ & c(j,l)*u(j,l+1)+d(j,l)*u(j,l-1)+
+ & e(j,l)*u(j,l)-f(j,l)
+ anorm=anorm+abs(resid)
+ u(j,l)=u(j,l)-omega*resid/e(j,l)
+ enddo
+ lsw=3-lsw
+ enddo
+ jsw=3-jsw
+ if(n.eq.1.and.ipass.eq.1) then
+ omega=1.d0/(1.d0-.5d0*rjac**2)
+ else
+ omega=1.d0/(1.d0-.25d0*rjac**2*omega)
+ endif
+ enddo
+! print*,'n,anorm,anormf=',n,anorm,anormf
+ if(anorm.lt.EPS*anormf)return
+ enddo
+ print*,'n,anorm,anormf=',n,anorm,anormf
+ print*,'MAXITS exceeded in sor'
+ END
+
+
+
+ SUBROUTINE hurr_move(ITIM,KST,IMAX,JMAX,KMAX,MTV6,MTV4,SDAT,
+ & HDATN,U850,V850,XLON1,XLAT1,XLON,XLAT,SL,IBGS,IVOBS,
+ & iflag_cold,I360)
+! KST is the storm number
+
+ ! From WRF-NMM in R2 HWRF (WRF-NMM 3.2):
+ real, parameter :: deg2rad = 3.1415926/180.
+
+ PARAMETER (IX=41,JX=41,NF=11,IT=24,IR=120,IJ=IX*JX)
+ PARAMETER (NSG=720000,NST=10)
+ PARAMETER (NSG5=NSG/5)
+
+ REAL(4) SDAT(IX,JX,MTV6),HDATN(IMAX,JMAX,MTV4),SL(KMAX)
+
+ REAL(4) U850(IX,JX),V850(IX,JX)
+
+ DIMENSION U(IX,JX),V(IX,JX),US(IX,JX),VS(IX,JX)
+ DIMENSION UD(IX,JX),VD(IX,JX),DKY(IX,JX),DKM(IX,JX)
+ DIMENSION DKY1(IMAX,JMAX),DKM1(IMAX,JMAX)
+! DIMENSION DKM1(IMAX,JMAX),SKIP(IX,JX)
+ DIMENSION XTU(IX,NF),XTV(IX,NF),YTU(IX,JX),YTV(IX,JX)
+ DIMENSION RS(IT),R0(IT),RF(IT)
+ DIMENSION M(NF),FK(NF),TW(IT,IR)
+ DIMENSION ALAT(JX),ALON(IX)
+ DIMENSION ING(NSG),JNG(NSG),RRIJ(NSG)
+ DIMENSION ING3(NSG),JNG3(NSG)
+ DIMENSION ING5(NSG5),JNG5(NSG5)
+ DIMENSION ING6(NSG5),JNG6(NSG5)
+ DIMENSION ISTMCX1(7,NST),ISTMCY1(7,NST),STMCX(NST),STMCY(NST)
+ REAL(4) testu(IMAX,JMAX),testv(IMAX,JMAX)
+
+ REAL(8),allocatable:: DATG(:,:),DATG2(:,:),DDAT(:,:)
+ REAL(8),allocatable:: ENV1(:,:,:)
+
+ REAL(4),ALLOCATABLE :: SAVE1(:,:),SAVE2(:,:)
+
+ real(4) XLON1(IMAX,JMAX),XLAT1(IMAX,JMAX)
+ real(4) XLON(IMAX,JMAX),XLAT(IMAX,JMAX)
+ real(4) GLON(IMAX,JMAX),GLAT(IMAX,JMAX)
+ real(4) SLON_N,SLAT_N,CLON_N,CLAT_N
+
+ real(4) zmax
+
+ real mindist,tmplat,tmplon,dist
+
+! COMMON /egrid/GLON(IMAX,JMAX),GLAT(IMAX,JMAX) !input
+
+ COMMON /NHC/ KSTM,IC_N(NST),JC_N(NST)
+ COMMON /NHC1/SLON_N(NST),SLAT_N(NST),CLON_N(NST),CLAT_N(NST) !input
+ COMMON /POSIT/CLON_NEW,CLAT_NEW,SLON,SLAT,CLON,CLAT,RAD
+ COMMON /vect/R0,XVECT(IT),YVECT(IT)
+
+ CHARACTER ST_NAME(NST)*3,STMNAME(NST)*3,TCVT(NST)*95
+ COMMON /STNAME/ST_NAME,STMNAME ! need storm name
+ COMMON /TCVIT/TCVT ! need TC vitals
+ COMMON /RSFC/STRPSF(NST),STVMAX(NST),STRPSF_06(NST)
+
+ COMMON /TR/ING,JNG,IB
+ COMMON /NHC2/MDX,MDY
+ COMMON /NHC3/AMDX,AMDY
+
+ DATA M/2,3,4,2,5,6,7,2,8,9,2/
+
+ allocate (DATG(IMAX,JMAX),DATG2(IMAX,JMAX),DDAT(IMAX,JMAX))
+ allocate (ENV1(IMAX,JMAX,MTV4))
+
+ ALLOCATE ( SAVE1(IMAX,JMAX), SAVE2(IMAX,JMAX) )
+
+ SAVE1=0.
+
+ PI=ASIN(1.)*2
+ RAD=PI/180.
+ pi180=PI/180.
+
+ ING=0
+ JNG=0
+
+! IF(STVMAX(KST).LT.21.)THEN
+! NF1=7
+! ELSE IF(STVMAX(KST).LT.26.)THEN
+! NF1=8
+! ELSE IF(STVMAX(KST).LT.31.)THEN
+! NF1=9
+! ELSE
+! NF1=NF
+! END IF
+
+! IF(STVMAX(KST).LT.26.)THEN
+! NF1=9
+! ELSE
+! NF1=NF
+! END IF
+
+ NF1=NF
+
+ print*,'IBGS=',IBGS,IVOBS
+
+ CLON_NHC = CLON_N(KST)
+ CLAT_NHC = CLAT_N(KST)
+
+ zmax1=0.
+ DO J=1,JMAX
+ DO I=1,IMAX
+ A = XLON1(I,J) - CLON_NHC
+ B = XLAT1(I,J) - CLAT_NHC
+ R = SQRT(A**2. + B**2.)
+ IF(R.LT.12.) THEN
+ if(zmax1.lt.HDATN(i,j,1))zmax1=HDATN(i,j,1)
+ ENDIF
+ END DO
+ END DO
+
+ PRINT*,'zmax1=',zmax1
+
+! if(zmax1.gt.500.)NF1=9
+
+!new IF(IBGS.eq.1)THEN
+!new NF1=7
+!new END IF
+
+ DO I=1,NF
+ IF(I.GE.NF1)M(I)=2 ! remove 1 degree wave in the last step
+ FK(I)=0.5/(1-COS(2.*PI/M(I)))
+ ENDDO
+
+
+! LON, LAT at U,V grids
+
+ GLON=XLON
+ GLAT=XLAT
+
+ SLON=SLON_N(KST)
+ SLAT=SLAT_N(KST)
+
+ DO I=1,IX
+ ALON(I)=SLON+(I-1) ! specify 41x41 lon and lat
+! PRINT*,'ALON(I)=',I,ALON(I),XLON1(1,1),XLON1(IMAX,JMAX)
+ END DO
+ DO J=1,JX
+ ALAT(J)=SLAT+(J-1)
+! PRINT*,'ALAT(J)=',I,ALAT(J),XLAT1(1,1),XLAT1(IMAX,JMAX)
+ END DO
+
+! CLON=ALON(21)
+! CLAT=ALAT(21)
+ CLON = CLON_N(KST)
+ CLAT = CLAT_N(KST)
+
+ INDX1=ITIM-2
+
+ K1STM=0
+ DO I=1,NST
+ STMCX(I)=0.
+ STMCY(I)=0.
+ STMNAME(I)='NUL'
+ READ(30,442,end=436)
+ & (ISTMCY1(J,I),ISTMCX1(J,I),J=1,7),STMNAME(I)
+!
+ STMCX(I)=-1*ISTMCX1(INDX1,I)*0.1
+ IF(I360.eq.180)THEN
+ IF(STMCX(I).lt.-180.)STMCX(I)=STMCX(I)+360.
+ END IF
+ STMCY(I)=ISTMCY1(INDX1,I)*0.1
+ K1STM=K1STM+1
+ PRINT*,'QLIU test=',STMNAME(I),STMCX(I),STMCY(I)
+ END DO
+ 442 FORMAT(14x,14i5,25x,A3)
+ 436 CONTINUE
+
+!.. READ U, V at ~850 mb
+
+ K8501=1
+ DIST2=ABS(SL(1)-0.85)
+ DO K=1,KMAX
+ DIST1=ABS(SL(K)-0.85)
+ IF(DIST1.LT.DIST2)THEN
+ K8501=K
+ DIST2=DIST1
+ END IF
+ END DO
+
+ K850=2+KMAX+4*(K8501-1)+1
+
+ IF(K8501.LT.1.OR.K8501.GT.KMAX)THEN
+ PRINT*,'K8501 is out of bound'
+ STOP
+ END IF
+
+ PRINT*,'QLIUQLIU test',K850,K8501
+ print*,SDAT(30,30,K850)
+ print*,SDAT(30,30,K850+1)
+ print*,SDAT(30,30,K850+2)
+ print*,SDAT(30,30,K850+3)
+
+ DO J=1,JX
+ DO I=1,IX
+! U(I,J)=SDAT(I,J,K850+2)
+! V(I,J)=SDAT(I,J,K850+3)
+ U(I,J)=U850(I,J)
+ V(I,J)=V850(I,J)
+ END DO
+ END DO
+
+
+! fact=cos(CLAT*rad)
+ fact=1.0
+ do j=1,jx
+ do i=1,ix
+! East-West wind in new coordinate (phi,theta)
+! this conversion only affects Hurrican Center determination and R0
+ U(I,J)=U(I,J)/fact
+ end do
+ end do
+!.. DO ZONAL FILTER
+
+ DO 100 J=1,JX
+ DO N=1,NF1
+ XTU(1,N) = U(1,J)
+ XTU(IX,N) = U(IX,J)
+ XTV(1,N) = V(1,J)
+ XTV(IX,N) = V(IX,J)
+ ENDDO
+
+ DO I=2,IX-1
+ XTU(I,1) = U(I,J)+FK(1)*(U(I-1,J)+U(I+1,J)-2.*U(I,J))
+ XTV(I,1) = V(I,J)+FK(1)*(V(I-1,J)+V(I+1,J)-2.*V(I,J))
+ ENDDO
+
+ DO N=2,NF1
+ DO I=2,IX-1
+ XTU(I,N)=XTU(I,N-1)+FK(N)*(XTU(I-1,N-1)+XTU(I+1,N-1)-2.
+ & *XTU(I,N-1))
+ XTV(I,N)=XTV(I,N-1)+FK(N)*(XTV(I-1,N-1)+XTV(I+1,N-1)-2.
+ & *XTV(I,N-1))
+ ENDDO
+ ENDDO
+
+ DO I=1,IX
+ US(I,J) = XTU(I,NF1)
+ VS(I,J) = XTV(I,NF1)
+ ENDDO
+
+100 CONTINUE
+
+!.. DO MERIDIONAL FILTER
+
+ DO 200 I=1,IX
+
+ DO N=1,NF1
+ YTU(1,N) = US(I,1)
+ YTU(JX,N) = US(I,JX)
+ YTV(1,N) = VS(I,1)
+ YTV(JX,N) = VS(I,JX)
+ ENDDO
+
+ DO J = 2 , JX-1
+ YTU(J,1) = US(I,J) + FK(1)*(US(I,J-1) + US(I,J+1)
+ & -2.*US(I,J))
+ YTV(J,1) = VS(I,J) + FK(1)*(VS(I,J-1) + VS(I,J+1)
+ & -2.*VS(I,J))
+ ENDDO
+
+ DO N = 2 , NF1
+ DO J = 2 , JX-1
+ YTU(J,N) = YTU(J,N-1) + FK(N)*(YTU(J-1,N-1) +
+ & YTU(J+1,N-1) - 2.*YTU(J,N-1))
+ YTV(J,N) = YTV(J,N-1) + FK(N)*(YTV(J-1,N-1) +
+ & YTV(J+1,N-1) - 2.*YTV(J,N-1))
+ ENDDO
+ ENDDO
+
+ DO J = 1 , JX
+ US(I,J) = YTU(J,NF1)
+ VS(I,J) = YTV(J,NF1)
+ ENDDO
+ 200 CONTINUE
+
+!.. GET THE DISTURBANCE FIELD
+
+ DO I=1,IX
+ DO J=1,JX
+ UD(I,J) = U(I,J) - US(I,J)
+ VD(I,J) = V(I,J) - VS(I,J)
+ ENDDO
+ ENDDO
+
+!.. FIND NEW VORTEX CENTER
+
+ ICHEK=0
+ CLON_TIM=0.
+ CLAT_TIM=0.
+ DO I=1,K1STM
+ IF(STMNAME(I).EQ.ST_NAME(KST))THEN
+ CLON_TIM=STMCX(I)
+ CLAT_TIM=STMCY(I)
+ ICHEK=1
+ DO J=1,7 ! newly added
+ IF(ISTMCY1(J,I).EQ.0.and.ISTMCX1(J,I).EQ.0)THEN
+ ICHEK=0
+ END IF
+ END DO
+ GO TO 446
+ END IF
+ END DO
+ 446 CONTINUE
+ print*,'ICHEK,CLON_TIM=',ICHEK,CLON_TIM
+ IF((ICHEK.EQ.1).AND.(ABS(CLON_TIM).LT.359.5))THEN
+ CLON_NEW=CLON_TIM
+ CLAT_NEW=CLAT_TIM
+ ELSE
+ CLON_NEW=CLON_NHC
+ CLAT_NEW=CLAT_NHC
+ ENDIF
+
+ PRINT*,'GFDL CENTER= ',ITIM,'h ',CLON_NEW,CLAT_NEW
+
+!.. CALCULATE TANGENTIAL WIND AROUND CIRCLE
+! 24 DIRECTION, RADIALLY 0.1DEG INTERVAL
+
+ CALL TWIND(UD,VD,TW)
+
+!.. CALCULATE STARTING POINT AT EACH DIRECTION
+
+ CALL STRT_PT(RS,TW,RFAVG)
+
+!.. DETERMINE FILTER DOMAIN D0 (=1.25*Rf)
+
+
+ CALL FILTER(RS,TW,RF,RFAVG,KST,IBGS,IVOBS,iflag_cold)
+
+ AMDX=CLON_NHC-CLON_NEW
+ AMDY=CLAT_NHC-CLAT_NEW
+
+ IF(ITIM.EQ.6)THEN
+ WRITE(52,65)TCVT(KST)(1:32),
+ & CLON_NHC,CLAT_NHC,CLON_NEW,
+ & CLAT_NEW,CLON_TIM,CLAT_TIM,AMDX,AMDY,
+ & SQRT(AMDX*AMDX+AMDY*AMDY)
+ DO I=1,K1STM
+ IF(STMNAME(I).EQ.ST_NAME(KST))THEN
+ IFWRT=0
+ DO J=1,7
+ IF(ISTMCY1(J,I).EQ.0.and.ISTMCX1(J,I).EQ.0)THEN
+ IFWRT=1
+ END IF
+ END DO
+ IF(IFWRT.EQ.1)THEN
+ WRITE(52,76)TCVT(KST)(1:32)
+ ELSE
+ WRITE(52,77)TCVT(KST)(1:32)
+ END IF
+ 76 FORMAT(/' STORM: ',A32,10x,' is bogused')
+ 77 FORMAT(/' STORM: ',A32,10x)
+ WRITE(52,79)
+ & (ISTMCY1(J,I),ISTMCX1(J,I),J=1,7),STMNAME(I)
+ 79 FORMAT(/' TRACKER OUTPUT: ',14i4,5x,A3)
+ END IF
+ END DO
+ END IF
+ 65 FORMAT(/' STORM NAME: ',A32,
+ & /' OBSERVED CENTER POSITION: ',2F10.2
+ & ,/' MODEL CENTER POSITION : ',2F10.2
+ & ,/' MODEL CENTER POSITION (TIM): ',2F10.2
+ & ,/' RELOCATION DISTANCE (DEGREE): ',3F10.2)
+
+! test by qliu
+! MDX=MDX+50
+! AMDX=AMDX+50*DLN
+
+ KNHC=-99999
+ MNHC=-99999
+
+ DO I=1,IMAX-1
+ DO J=1,JMAX-1
+ IF((CLAT_NHC.GE.GLAT(I,J).and.
+ & CLAT_NHC.LT.GLAT(I,J+1)).and.
+ & (CLON_NHC.GE.GLON(I,J).and.
+ & CLON_NHC.LT.GLON(I+1,J)))THEN
+ KNHC=I
+ MNHC=J
+ END IF
+ END DO
+ END DO
+
+ if( knhc==-99999 .or. mnhc==-99999 ) then
+ ! Should not get here, but it happens once in a blue moon.
+ ! The above search for the center point failed.
+ ! We'll try again by finding the nearest gridpoint.
+ ! This is much slower since it requires calculating great
+ ! circle distances.
+
+ ! What we should do is replace this and the above loop with
+ ! code that uses the rot-lat-lon projection information.
+ ! That isn't available here so we have to use these
+ ! dirty tricks instead.
+
+ write(6,*) 'COULD NOT FIND GRIDPOINT OF CENTER IN DOMAIN.'
+ write(6,*) 'REVERTING TO NEAREST GRIDPOINT METHOD.'
+ write(0,*) 'COULD NOT FIND GRIDPOINT OF CENTER IN DOMAIN.'
+ write(0,*) 'REVERTING TO NEAREST GRIDPOINT METHOD.'
+
+ mindist=9e15
+ clon_nhc_rad=clon_nhc*deg2rad
+ clat_nhc_rad=clat_nhc*deg2rad
+ DO I=1,IMAX-1
+ DO J=1,JMAX-1
+ tmplat=(glat(i,j)+glat(i,j+1))/2*deg2rad
+ tmplon=(glon(i,j)+glon(i+1,j))/2*deg2rad
+ dist=calc_dist(tmplat,tmplon,
+ & clat_nhc_rad,clon_nhc_rad)
+ if(dist100000) then
+ write(6,*) 'NEAREST GRIDPOINT IS AT LEAST',
+ & '100 KM FROM NHC POINT. GIVING UP.'
+ write(0,*) 'NEAREST GRIDPOINT IS AT LEAST',
+ & '100 KM FROM NHC POINT. GIVING UP.'
+ stop 47
+ endif
+
+ endif
+
+ if( knhc-7<=1 .or. knhc+7>=imax .or.
+ & mnhc-7<=1 .or. mnhc+7>=jmax) then
+ write(6,*) 'NHC GRIDPOINT WITHIN 8 POINTS OF EDGE. ABORT!!'
+ write(0,*) 'NHC GRIDPOINT WITHIN 8 POINTS OF EDGE. ABORT!!'
+ write(6,*) 'knhc,mnhc,imax,jmax: ',knhc,mnhc,imax,jmax
+ write(0,*) 'knhc,mnhc,imax,jmax: ',knhc,mnhc,imax,jmax
+ stop 49
+ endif
+
+ IC1=KNHC+1
+ JC1=MNHC+1
+ MDX=IFIX((CLON_NHC-CLON_NEW)/(GLON(IC1,MNHC)-GLON(KNHC,MNHC)))
+ MDY=IFIX((CLAT_NHC-CLAT_NEW)/(GLAT(KNHC,JC1)-GLAT(KNHC,MNHC)))
+
+!234567890123456789012345678901234567890123456789012345678901234567890
+
+ PRINT*,'GLON(1,1),GLAT(1,1)=',GLON(1,1),GLAT(1,1)
+
+ PRINT*,'MDX,MDY,KNHC,MNHC=',MDX,MDY,KNHC,MNHC
+ PRINT*,'AMDX,AMDY=',AMDX,AMDY
+ PRINT*,'CLON_NHC,CLAT_NHC=',CLON_NHC,CLAT_NHC
+ PRINT*,'CLON_NEW,CLAT_NEW=',CLON_NEW,CLAT_NEW
+ RDIST2=AMDX*AMDX+AMDY*AMDY
+
+ IB=0
+ RRIJ=0.
+
+ IB5=0
+ ING5=0
+ JNG5=0
+
+ IB6=0
+ ING6=0
+ JNG6=0
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+
+ A = GLON(I,J) - CLON_NEW
+ B = GLAT(I,J) - CLAT_NEW
+ R = SQRT(A**2. + B**2.)
+ IF(R.EQ.0.) GO TO 444
+ TH = ACOS(A/R) / RAD
+ IF(B.LT.0.) TH = 360-TH
+
+ IF(TH.LE.7.5 .OR. TH.GT.352.5 ) IC = 1
+ DO M2=2,24
+ IF((TH.GT.(15.*(M2-1)-7.5)).and.
+ & (TH.LE.(15.*M2-7.5)))IC=M2
+ END DO
+
+! print*,'R,R0(IC),ic=',R,R0(IC),ic
+
+ IF(R.LT.R0(IC)) THEN
+ IB = IB+1
+ ING(IB) = I
+ JNG(IB) = J
+
+! RRIJ(IB)=1.
+! IF(R.GT.0.75*R0(IC))THEN
+! RRIJ(IB)=(4.*(R0(IC)-R)/R0(IC))**2
+! END IF
+
+ ENDIF
+
+! IF(R.LT.(R0(IC)))THEN
+! IB5=IB5+1
+! ING5(IB5)=I
+! JNG5(IB5)=J
+! RRIJ(IB5)=1.
+! IF(R.GT.(R0(IC)-0.5))THEN
+! WT2=min(1.0,(R0(IC)-R)/0.5)
+! RRIJ(IB5)=WT2*WT2*(3.-2.*WT2)
+! END IF
+! END IF
+
+ IF((R.LT.R0(IC)).and.R.GT.(R0(IC)-0.8))THEN
+ IB5=IB5+1
+ ING5(IB5)=I
+ JNG5(IB5)=J
+ WT2=min(1.0,(R0(IC)-R)/0.8)
+ RRIJ(IB5)=WT2*WT2*(3.-2.*WT2)
+ END IF
+
+ IF((R.LT.R0(IC)).and.R.GT.(R0(IC)-0.2))THEN
+ IB6=IB6+1
+ ING6(IB6)=I
+ JNG6(IB6)=J
+ END IF
+
+ GO TO 22
+
+444 IB = IB+1
+ ING(IB) = I
+ JNG(IB) = J
+
+! RRIJ(IB)=1.
+
+22 CONTINUE
+
+ ENDDO
+ ENDDO
+
+
+ IBH=0
+ zmax=0.
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+
+ A = XLON1(I,J) - CLON_NEW
+ B = XLAT1(I,J) - CLAT_NEW
+ R = SQRT(A**2. + B**2.)
+ IF(R.EQ.0.) GO TO 866
+ TH = ACOS(A/R) / RAD
+ IF(B.LT.0.) TH = 360-TH
+
+ IF(TH.LE.7.5 .OR. TH.GT.352.5 ) IC = 1
+ DO M2=2,24
+ IF((TH.GT.(15.*(M2-1)-7.5)).and.
+ & (TH.LE.(15.*M2-7.5)))IC=M2
+ END DO
+
+! print*,'R,R0(IC),ic=',R,R0(IC),ic
+
+ IF(R.LT.R0(IC)) THEN
+ IBH = IBH+1
+ ING3(IBH) = I
+ JNG3(IBH) = J
+ if(zmax.lt.HDATN(i,j,1))zmax=HDATN(i,j,1)
+ ENDIF
+
+ GO TO 877
+
+866 IBH = IBH+1
+ ING3(IBH) = I
+ JNG3(IBH) = J
+877 CONTINUE
+
+ ENDDO
+ ENDDO
+
+ print*,'IB,IBH=',IB,IBH,NSG
+ IF(IB.GT.NSG.or.IBH.GT.NSG)THEN
+ print*,'need to increase NSG'
+ stop
+ END IF
+
+! temp relocation turned on
+ IFLAG = 0
+
+! Check if the syndata need to be called
+
+ IF(ITIM.EQ.3)THEN
+ DO I=1,K1STM
+ IF(STMNAME(I).EQ.ST_NAME(KST))THEN
+ IFWRT=0
+ DO J=1,7
+ IF(ISTMCY1(J,I).EQ.0.and.ISTMCX1(J,I).EQ.0)THEN
+ IFWRT=1
+ END IF
+ END DO
+ IF(IFWRT.EQ.1)THEN
+ WRITE(55,101) TCVT(KST)
+ END IF
+ 101 FORMAT(A95)
+ END IF
+ END DO
+ END IF
+
+
+! print *,'GAUSSIAN GRID # WITHIN R0 ',IB
+! DO I = 1,IB
+! print *,'GAUSSIAN GRID WITHIN R0, LAT,LON ',
+! 1 GLAT(ING(I),JNG(I)),GLON(ING(I),JNG(I))
+! print *,'GAUSSIAN GRID WITHIN R0 ',ING(I),JNG(I)
+! ENDDO
+
+!.. SETTING VALUE for xvect, yvect, a(,), capd2
+
+ call rodist
+
+ call amatrix
+
+ KMP=KMAX
+ KDIV1=2+KMP
+ KQ1=KDIV1+4*KMP
+
+ NRED1 = 0
+
+ ISE=1
+
+ DO 777 IV = 1,MTV6
+
+ IREM = -22
+
+ IF(IV.GT.KDIV1.AND.IV.LE.KQ1)IREM=MOD(IV-KDIV1,4)
+ IF((IV.GE.2.AND.IV.LE.KDIV1).OR.(IV.GT.KQ1).OR.
+ & (IREM.EQ.1.OR.IREM.EQ.2)) THEN
+! print *,'ORIGINAL VARIABLE # IS ',IV
+
+! added by Qingfu Liu
+! obtain the disturbance field
+
+ ISE=ISE+1
+
+ DO J=1,JX
+ DO I=1,IX
+ U(I,J)=SDAT(I,J,IV)
+ END DO
+ END DO
+
+! First smooth in east-west direction
+
+ DO 107 J=1,JX
+ DO N=1,NF1
+ XTU(1,N) = U(1,J)
+ XTU(IX,N) = U(IX,J)
+ ENDDO
+
+ DO I=2,IX-1
+ XTU(I,1) = U(I,J)+FK(1)*(U(I-1,J)+U(I+1,J)-2.*U(I,J))
+ ENDDO
+
+ DO N=2,NF1
+ DO I=2,IX-1
+ XTU(I,N)=XTU(I,N-1)+FK(N)*(XTU(I-1,N-1)+XTU(I+1,N-1)
+ & -2.*XTU(I,N-1))
+ ENDDO
+ ENDDO
+
+ DO I=1,IX
+ US(I,J) = XTU(I,NF1)
+ ENDDO
+
+ 107 CONTINUE
+
+!.. DO MERIDIONAL FILTER
+
+ DO 207 I=1,IX
+
+ DO N=1,NF1
+ YTU(1,N) = US(I,1)
+ YTU(JX,N) = US(I,JX)
+ ENDDO
+
+ DO J = 2 , JX-1
+ YTU(J,1) = US(I,J) + FK(1)*(US(I,J-1) + US(I,J+1)
+ & -2.*US(I,J))
+ ENDDO
+
+ DO N = 2 , NF1
+ DO J = 2 , JX-1
+ YTU(J,N) = YTU(J,N-1) + FK(N)*(YTU(J-1,N-1) +
+ & YTU(J+1,N-1) - 2.*YTU(J,N-1))
+ ENDDO
+ ENDDO
+
+ DO J = 1 , JX
+ US(I,J) = YTU(J,NF1)
+ ENDDO
+ 207 CONTINUE
+
+
+C.. GET THE DISTURBANCE FIELD
+C
+ DO I=1,IX
+ DO J=1,JX
+ DKY(I,J) = U(I,J) - US(I,J)
+ ENDDO
+ ENDDO
+
+! print*,'before call SEPAR',ISE
+
+ DKM=DKY
+ CALL SEPAR(DKY,DKM)
+
+! print*,'after call SEPAR'
+
+
+! print*,'qliu test1'
+
+ DO J=1,JX
+ DO I=1,IX
+! SKIP(I,J)=DKM(I,J)
+c SKIP(I,J)=U(I,J)
+ DKY(I,J) = DKM(I,J) + US(I,J)
+c DKY(I,J) = U(I,J)
+ ENDDO
+ ENDDO
+
+! Interpolate DKY to high resolution model grids
+
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ DKY1(I,J)=HDATN(I,J,ISE)
+ SAVE1(I,J)=DKY1(I,J)
+ ENDDO
+ ENDDO
+
+! write(33)((SAVE1(I,J),I=1,IMAX),J=1,JMAX,2)
+
+
+ IF(ISE.GT.(KMAX+2).and.ISE.LE.(3*KMAX+2))THEN ! wind field
+
+! print*,'qliu test2'
+
+! DO N=1,JMAX
+! DO K=1,IMAX
+ DO M3=1,IB
+ N=JNG(M3)
+ K=ING(M3)
+ DO J=1,JX-1
+ IF(GLAT(K,N).GE.ALAT(J).and.GLAT(K,N).LT.ALAT(J+1))THEN
+ DO I=1,IX-1
+ IF(GLON(K,N).GE.ALON(I).and.GLON(K,N).LT.ALON(I+1))THEN
+ COEF1=(GLON(K,N)-ALON(I))/(ALON(I+1)-ALON(I))
+ COEF2=(GLAT(K,N)-ALAT(J))/(ALAT(J+1)-ALAT(J))
+ COEF3=(1.-COEF1)*(1.-COEF2)
+ DKY1(K,N)=COEF3*DKY(I,J)+
+ & COEF1*(1.-COEF2)*DKY(I+1,J)+
+ & COEF1*COEF2*DKY(I+1,J+1)+
+ & (1.-COEF1)*COEF2*DKY(I,J+1)
+ GO TO 193
+ END IF
+ END DO
+ END IF
+ END DO
+ 193 CONTINUE
+ END DO
+! END DO
+! END DO
+
+ DKM1=DKY1
+
+ DO I = 1,IB6
+ IW = ING6(I)
+ JW = JNG6(I)
+ IF(MOD(JW,2) .NE. 0)THEN
+ DKM1(IW,JW)=0.2*(DKY1(IW,JW)+DKY1(IW,JW-1)+DKY1(IW,JW+1)
+ 1 +DKY1(IW+1,JW-1)+DKY1(IW+1,JW+1))
+ ELSE
+ DKM1(IW,JW)=0.2*(DKY1(IW-1,JW-1)+DKY1(IW-1,JW+1)
+ 1 +DKY1(IW,JW-1)+DKY1(IW,JW+1)+DKY1(IW,JW))
+ END IF
+ END DO
+
+ DKY1=DKM1
+
+ DO I = 1,IB5
+ IW = ING5(I)
+ JW = JNG5(I)
+ DKY1(IW,JW)=DKM1(IW,JW)*RRIJ(I)+HDATN(IW,JW,ISE)*(1.-RRIJ(I))
+ END DO
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE1(I,J)=DKY1(I,J)
+ ENDDO
+ ENDDO
+
+! write(34)((SAVE1(I,J),I=1,IMAX),J=1,JMAX,2)
+
+! print*,'qliu test3'
+
+!.. GET THE DISTURBANCE FIELD (High Resolution)
+
+! DO I=1,IMAX
+! DO J=1,JMAX
+! DKM1(I,J) = HDATN(I,J,ISE)-DKY1(I,J)
+! ENDDO
+! ENDDO
+
+ ELSE
+
+! print*,'qliu test4'
+! DO N=1,JMAX
+! DO K=1,IMAX
+ DO M3=1,IBH
+ N=JNG3(M3)
+ K=ING3(M3)
+ DO J=1,JX-1
+ IF(XLAT1(K,N).GE.ALAT(J).and.XLAT1(K,N).LT.ALAT(J+1))THEN
+ DO I=1,IX-1
+ IF(XLON1(K,N).GE.ALON(I).and.XLON1(K,N).LT.ALON(I+1))THEN
+ COEF1=(XLON1(K,N)-ALON(I))/(ALON(I+1)-ALON(I))
+ COEF2=(XLAT1(K,N)-ALAT(J))/(ALAT(J+1)-ALAT(J))
+ COEF3=(1.-COEF1)*(1.-COEF2)
+ DKY1(K,N)=COEF3*DKY(I,J)+
+ & COEF1*(1.-COEF2)*DKY(I+1,J)+
+ & COEF1*COEF2*DKY(I+1,J+1)+
+ & (1.-COEF1)*COEF2*DKY(I,J+1)
+
+ GO TO 293
+ END IF
+ END DO
+ END IF
+ END DO
+ 293 CONTINUE
+ END DO
+! END DO
+! END DO
+
+ DKM1=DKY1
+
+ DO I = 1,IB6
+ IW = ING6(I)
+ JW = JNG6(I)
+ IF(MOD(JW,2) .NE. 0)THEN
+ DKM1(IW,JW)=0.2*(DKY1(IW,JW)+DKY1(IW,JW-1)+DKY1(IW,JW+1)
+ 1 +DKY1(IW+1,JW-1)+DKY1(IW+1,JW+1))
+ ELSE
+ DKM1(IW,JW)=0.2*(DKY1(IW-1,JW-1)+DKY1(IW-1,JW+1)
+ 1 +DKY1(IW,JW-1)+DKY1(IW,JW+1)+DKY1(IW,JW))
+ END IF
+ END DO
+
+ DKY1=DKM1
+
+ DO I = 1,IB5
+ IW = ING5(I)
+ JW = JNG5(I)
+ DKY1(IW,JW)=DKM1(IW,JW)*RRIJ(I)+HDATN(IW,JW,ISE)*(1.-RRIJ(I))
+ END DO
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE1(I,J)=DKY1(I,J)
+ ENDDO
+ ENDDO
+
+! print*,'qliu test5'
+
+! write(35)((SAVE1(I,J),I=1,IMAX),J=1,JMAX,2)
+
+!.. GET THE DISTURBANCE FIELD (High Resolution)
+
+! DO I=1,IMAX
+! DO J=1,JMAX
+! DKM1(I,J) = HDATN(I,J,ISE)-DKY1(I,J)
+! ENDDO
+! ENDDO
+
+ END IF
+
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ ENV1(I,J,ISE) = DKY1(I,J)
+ ENDDO
+ ENDDO
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE1(I,J)=ENV1(I,J,ISE)
+ ENDDO
+ ENDDO
+
+! write(29)((SAVE1(I,J),I=1,IMAX),J=1,JMAX,2)
+
+ ENDIF
+
+ 777 CONTINUE
+
+! print*,'qliu test3'
+
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+ NCHT=71
+ WRITE(NCHT)ST_NAME(KST)
+
+ WRITE(NCHT)CLON_NEW,CLAT_NEW,CLON_NHC,CLAT_NHC
+ WRITE(NCHT)zmax
+
+ IWMAX=0.
+ IWMIN=1000.
+ JWMAX=0.
+ JWMIN=1000.
+ DO I = 1,IB
+ IW = ING(I)
+ JW = JNG(I)
+ IF(IWMAX.LT.IW)IWMAX=IW
+ IF(IWMIN.GT.IW)IWMIN=IW
+ IF(JWMAX.LT.JW)JWMAX=JW
+ IF(JWMIN.GT.JW)JWMIN=JW
+ END DO
+ IWMAX1=IWMAX+4
+ IWMIN1=IWMIN-4
+ JWMAX1=JWMAX+4
+ JWMIN1=JWMIN-4
+
+
+ IGU=IMAX
+ JGU=JMAX
+
+ KDIV2=2+KMAX
+ KQ2=KDIV2+4*KMAX
+
+ ISE = 1
+ DO 781 IV = 1,MTV6
+
+ IREM = -22
+
+ IF(IV.GT.KDIV2.AND.IV.LE.KQ2)IREM=MOD(IV-KDIV2,4)
+ IF((IV.GE.2.AND.IV.LE.KDIV2).OR.(IV.GT.KQ2).OR.
+ & (IREM.EQ.1.OR.IREM.EQ.2)) THEN
+ ISE = ISE+1
+
+ print*,'ISE,IV=',ISE,IV
+
+ DDAT=0.
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ DATG(I,J)=ENV1(I,J,ISE)
+ DATG2(I,J)=HDATN(I,J,ISE)
+ ENDDO
+ ENDDO
+
+ DDAT=0.
+ SAVE1=0.
+! RDIST2=AMDX*AMDX+AMDY*AMDY
+! IF(RDIST2.GT.0.02)THEN
+ IF(ISE.GE.2)THEN
+ DO J=1,JMAX
+ DO I=1,IMAX
+ DDAT(I,J)=DATG2(I,J)-DATG(I,J)
+ ENDDO
+ ENDDO
+ END IF
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE1(I,J)=DDAT(I,J)
+ ENDDO
+ ENDDO
+! DO I = 1,IB
+! IW = ING(I)
+! JW = JNG(I)
+! SAVE1(IW,JW)=DDAT(IW,JW)
+! END DO
+
+! END IF
+
+ IF(ISE.EQ.2) THEN
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG(I,J)
+ ENDDO
+ ENDDO
+ END IF
+
+ IF(ISE.GE.3.and.ISE.LE.(KMAX+2))then
+
+ IF(IFLAG.EQ.1)THEN
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG2(I,J)
+ ENDDO
+ ENDDO
+ SAVE1=0.
+ ELSE
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG(I,J)
+ ENDDO
+ ENDDO
+ END IF
+
+ END IF
+
+ IF(ISE.GT.(KMAX+2).and.ISE.LE.(3*KMAX+2))THEN
+
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG(I,J)
+ ENDDO
+ ENDDO
+
+ ENDIF
+
+ IF(ISE.GT.(3*KMAX+2))THEN
+ IF(IFLAG.EQ.1)THEN
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG2(I,J)
+ ENDDO
+ ENDDO
+ SAVE1=0.
+ ELSE
+ DO J=1,JMAX
+ DO I=1,IMAX
+ HDATN(I,J,ISE)=DATG(I,J)
+ SAVE1(I,J)=SAVE1(I,J)*1.E3
+ ENDDO
+ ENDDO
+ END IF
+ ENDIF
+
+
+ IF(ISE.EQ.2)THEN
+ WRITE(NCHT)IWMIN1,IWMAX1,JWMIN1,JWMAX1
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE2(I,J)=DATG(I,J)
+ END DO
+ END DO
+ WRITE(NCHT)((SAVE2(I,J),I=1,IMAX),J=1,JMAX) ! PSL
+ END IF
+! IF(ISE.EQ.3)THEN
+ IF(ISE.GE.3.and.ISE.LE.(KMAX+2))THEN
+ IF(IFLAG.EQ.1)THEN
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE2(I,J)=DATG2(I,J)
+ END DO
+ END DO
+ ELSE
+ DO J=1,JMAX
+ DO I=1,IMAX
+ SAVE2(I,J)=DATG(I,J)
+ END DO
+ END DO
+ END IF
+ WRITE(NCHT)((SAVE2(I,J),I=1,IMAX),J=1,JMAX) ! T1
+ END IF
+ WRITE(NCHT)((SAVE1(I,J),I=IWMIN1,IWMAX1),J=JWMIN1,JWMAX1)
+
+! PRINT*,'TEST ISE=',ISE
+
+ WRITE(25)((SAVE1(I,J),I=1,IMAX),J=1,JMAX,2)
+
+ ENDIF
+
+ 781 CONTINUE
+
+ 788 CONTINUE
+
+
+ DEALLOCATE ( SAVE1, SAVE2 )
+ deallocate (DATG,DATG2,DDAT)
+ deallocate (ENV1)
+
+ end
+
+ SUBROUTINE TWIND(UD,VD,TW)
+ PARAMETER (IX=41,JX=41,NF=11,IT=24,IR=120)
+ DIMENSION UD(IX,JX),VD(IX,JX),TW(IT,IR),R0(IT)
+ COMMON /POSIT/CLON_NEW,CLAT_NEW,SLON,SLAT,CLON,CLAT,RAD
+ COMMON /vect/R0,XVECT(IT),YVECT(IT)
+ print*,'CLON_NEW,CLAT_NEW,RAD=',CLON_NEW,CLAT_NEW,RAD
+ DO J=1,IR
+ DO I=1,IT
+!.. DETERMINE LAT, LON AREOUND CIRCLE
+ DR = 0.1*J
+ DD = (I-1)*15.*RAD
+ DLON = DR*COS(DD)
+ DLAT = DR*SIN(DD)
+ TLON = CLON_NEW + DLON
+ TLAT = CLAT_NEW + DLAT
+!.. INTERPOLATION U, V AT TLON,TLAT AND CLACULATE TANGENTIAL WIND
+ IDX = floor(TLON) - SLON + 1
+ IDY = floor(TLAT) - SLAT + 1
+ TW(I,J)=0.
+ IF(IDX.GE.1.and.IDX.LT.IX.and.IDY.GE.1.and.IDY.LT.JX)THEN
+ DXX = TLON - floor(TLON)
+ DYY = TLAT - floor(TLAT)
+ X1 = UD(IDX ,IDY+1)*DYY + UD(IDX ,IDY)*(1-DYY)
+ X2 = UD(IDX+1,IDY+1)*DYY + UD(IDX+1,IDY)*(1-DYY)
+ Y1 = UD(IDX+1,IDY )*DXX + UD(IDX,IDY )*(1-DXX)
+ Y2 = UD(IDX+1,IDY+1)*DXX + UD(IDX,IDY+1)*(1-DXX)
+ UT = (X1*(1-DXX)+X2*DXX + Y1*(1-DYY)+Y2*DYY)/2.
+ IF(I.EQ.0.OR.I.EQ.13) UT = Y1
+ IF(I.EQ.7.OR.I.EQ.19) UT = X1
+ X1 = VD(IDX ,IDY+1)*DYY + VD(IDX ,IDY)*(1-DYY)
+ X2 = VD(IDX+1,IDY+1)*DYY + VD(IDX+1,IDY)*(1-DYY)
+ Y1 = VD(IDX+1,IDY )*DXX + VD(IDX,IDY )*(1-DXX)
+ Y2 = VD(IDX+1,IDY+1)*DXX + VD(IDX,IDY+1)*(1-DXX)
+ VT = (X1*(1-DXX)+X2*DXX + Y1*(1-DYY)+Y2*DYY)/2.
+ IF(I.EQ.0.OR.I.EQ.13) VT = Y1
+ IF(I.EQ.7.OR.I.EQ.19) VT = X1
+!.. TANGENTIAL WIND
+ TW(I,J) = -SIN(DD)*UT + COS(DD)*VT
+ END IF
+ if(j.eq.1)then
+ print*,'TW(I,J),UT,VT=',I,J,TW(I,J),UT,VT,DD
+ & ,IDX,IDY,DLON,TLON,CLON_NEW,SLON
+ end if
+
+! for SH
+ ENDDO
+ ENDDO
+
+ IF(CLAT_NEW.LT.0)THEN
+ DO J=1,IR
+ DO I=1,IT
+ TW(I,J)=-TW(I,J)
+ ENDDO
+ ENDDO
+ END IF
+! SH
+
+ RETURN
+ END
+
+ SUBROUTINE STRT_PT(RMX,TW,RFAVG)
+
+ PARAMETER (IX=41,JX=41,NF=11,IT=24,IR=120)
+ DIMENSION TW(IT,IR),TWM(IR),TMXX(IT),RMX(IT)
+ REAL JMX
+
+ DO I=1,IR
+ TWM(I) = 0.
+ ENDDO
+
+!.. CALCULATE MEAN TANGENTIAL WIND
+
+ DO 10 J=1,IR
+ TM=0.
+ DO 20 I=1,IT
+ TM = TM + TW(I,J)
+20 CONTINUE
+ TWM(J) = TM/24.
+ print *,'MEAN TANGENTIAL WIND ',J,TWM(J)
+10 CONTINUE
+
+!.. FIND MAXIMUM TANGENTIAL WIND RADIUS
+
+ TMX=-100000000000.
+ DO J=1,IR
+ IF(TWM(J).GE.TMX) THEN
+ TMX=TWM(J)
+ JMX = J*0.1
+ ENDIF
+ ENDDO
+
+ print *,'MAXIMUM TANGENTIAL WIND RADIUS ',JMX
+ JJ=IFIX(JMX*10.)
+ print *,'MAXIMUM TANGENTIAL WIND SPEED ',TWM(JJ)
+
+ JXX = 15 * JMX
+! print *,'JXX, 15*JMX is ',JXX
+
+ ICK = 1
+ CNT = 0.000004
+!c print *,'CNT ',CNT
+
+ DO 30 K=JXX,120
+ IF(TWM(K).GE.6..OR.TWM(K).LT.3.) GO TO 30
+ DXX = 10000.
+ DV = TWM(K) - TWM(K+1)
+ DVDR = DV/DXX
+ IF(DVDR.LT.CNT) ICK = ICK+1
+ IF(ICK.EQ.3) THEN
+ RF=K*0.1
+ GO TO 40
+ ENDIF
+30 CONTINUE
+
+40 CONTINUE
+ IF(ICK.NE.3) THEN
+ DO IK=JXX,120
+ IF(TWM(IK).LE.3) THEN
+ RF = IK*0.1
+ ICK=3
+ GO TO 50
+ ENDIF
+ ENDDO
+ ENDIF
+
+50 CONTINUE
+ IF(ICK.NE.3) RF = 12.
+
+ RFAVG = RF
+
+!.. CALCULATE Ra, Rb.. REF. KURIHARA ET AL. 1995
+
+ RA = IFIX((0.5 * JMX)*10.)/10.
+ RB = IFIX((0.75 * JMX + 0.25 * RF)*10.)/10.
+ IRA = IFIX(RA*10.+0.5)
+ IRB = IFIX(RB*10.+0.5)
+
+!c print *,'Ra, Rb, Rf ', RA,RB,RF
+
+!.. DETERMINE STARTING POINT FOR EVERY 24 DIRECTION
+
+ DO I=1,IT
+ TMXX(I) = -100000000.
+ DO J=1,IR
+ IF(TW(I,J).GE.TMXX(I)) THEN
+ TMXX(I) = TW(I,J)
+ RMX(I) = J*0.1*1.1
+ ENDIF
+ ENDDO
+ ENDDO
+
+!c DO I=1,IT
+!c print *,'I, MX TANGENTIAL WIND RADIUS ',I,RMX(I),TMXX(I)
+!c ENDDO
+
+ DO I=1,IT
+ IF (RMX(I).GT.RB.OR.RMX(I).LT.RA) THEN
+ TMX = -10000000.
+ DO KK=IRA,IRB
+ IF(TW(I,KK).GE.TMX) RM = KK * 0.1 * 1.1
+ ENDDO
+ MR = IFIX(RM*10. + 0.5)
+ ICL=0
+ DO LL = MR,IRB
+ IF(TW(I,LL).LT.0.) ICL=ICL+1
+ ENDDO
+ IF(ICL.EQ.0) RMX(I) = RM*1.1
+ ENDIF
+ ENDDO
+
+!c DO I=1,IT
+!c print *,'I, RST ',I,RMX(I)
+!c ENDDO
+
+ RETURN
+ END
+
+ SUBROUTINE FILTER(RS,TW,RF,RFAVG,KST,IBGS,IVOBS,iflag_cold)
+ PARAMETER (IX=41,JX=41,IT=24,IR=120,NST=10)
+
+ DIMENSION RS(IT),TW(IT,IR),RF(IT),R0(IT),IST(IT)
+ DIMENSION R01(IT)
+ COMMON /vect/R0,XVECT(IT),YVECT(IT)
+ COMMON /RSFC/STRPSF(NST),STVMAX(NST),STRPSF_06(NST)
+
+! REAL(4) RMN,RMN_HWRF
+
+ ICK = 1
+ CNT = 0.000004
+! print *,'CNT ',CNT
+
+ DO I=1,IT
+ IST(I) = IFIX(RS(I)*10)
+!c print *,'STARTING POINT ',I,IST(I)
+ ENDDO
+
+ DO 100 I=1,IT
+ IS = IST(I)
+
+!CWH DO 30 K=IS,IR
+ DO 30 K=IS,IR-1
+ IF(TW(I,K).GE.6..OR.TW(I,K).LT.3.) GO TO 30
+ DXX = 10000.
+ DV = TW(I,K) - TW(I,K+1)
+ DVDR = DV/DXX
+ IF(DVDR.LT.CNT) THEN
+ ICK = ICK+1
+ ENDIF
+ IF(ICK.EQ.3) THEN
+ RF(I)=K*0.1 + 0.0000001
+!c print *,'1st Catagory ',I
+ GO TO 100
+ ENDIF
+30 CONTINUE
+
+40 CONTINUE
+ DO IK=IS,IR
+ IF(TW(I,IK).LE.3) THEN
+ RF(I) = IK*0.1 + 0.00000001
+!c print *,'2nd Catagory ',I
+ GO TO 100
+ ENDIF
+ ENDDO
+
+50 CONTINUE
+!c print *,'3rd Catagory ',I
+ RF(I) = 10.
+100 CONTINUE
+
+!c RMAX=0.
+ DO I=1,IT
+ print *,'Rf AT EACH DIRECTION ',I,RF(I)
+! RF(I) =max(RF(I),3.)
+ RF(I) = max(RF(I),2.2)
+!2014 RF(I) = min(RF(I),1.1*STRPSF(KST))
+! RF(I) = min(RF(I),STRPSF(KST))
+ RF(I) = min(RF(I),1.1*STRPSF(KST))
+ END DO
+
+ RMN=0.
+ DO I=1,IT
+ RMN=RMN+RF(I)
+ END DO
+ RMN=RMN/FLOAT(IT)
+ DO I=1,IT
+ IF(RF(I).GT.2.5*RMN)RF(I)=2.5*RMN
+ IF(RF(I).LT.0.4*RMN)RF(I)=0.4*RMN
+ END DO
+
+ DO I=2,IT-1
+ R01(I)=(RF(I)+RF(I-1)+RF(I+1))/3.
+ END DO
+ R01(1)=(RF(1)+RF(IT)+RF(2))/3.
+ R01(IT)=(RF(IT)+RF(IT-1)+RF(1))/3.
+
+ RF=R01
+
+
+ IF(IBGS.eq.0)THEN
+ DO I=1,IT
+! R0(I) = 1.25 * RF(I)
+!2014 R0(I) = 1.1 * RF(I)
+ R0(I) = 1.1* RF(I)
+! R0(I)=max(R0(I),3.3)
+! R0(I)=min(R0(I),1.4*STRPSF_06(KST))
+ R0(I)=min(R0(I),1.5*STRPSF(KST))
+ R0(I)=max(R0(I),2.5)+0.4
+ IF(R0(I).GT.11.)R0(I)=11.
+ print *,'R0,Rf AT EACH DIRECTION ',I,R0(I),RF(I)
+ ENDDO
+ ELSE IF(IBGS.eq.2)THEN
+ DO I=1,IT
+! R0(I) = 1.25 * RF(I)
+!2014 R0(I) = 1.1 * RF(I)
+ R0(I) = 1.1* RF(I)
+! R0(I)=min(R0(I),2.5*STRPSF(KST))
+! R0(I)=max(R0(I),3.3)
+ R0(I)=min(R0(I),1.5*STRPSF(KST))
+ R0(I)=max(R0(I),2.5)+0.4
+ IF(R0(I).GT.11.)R0(I)=11.
+ print *,'R0,Rf AT EACH DIRECTION ',I,R0(I),RF(I)
+ ENDDO
+ ELSE
+ DO I=1,IT
+! R0(I) = 1.25 * RF(I)
+!2014 R0(I) = 1.1 * RF(I)
+ R0(I) = 1.1* RF(I)
+ R0(I)=min(R0(I),1.5*STRPSF(KST))
+ R0(I)=max(R0(I),2.5)+0.4
+ IF(R0(I).GT.11.)R0(I)=11.
+ print *,'R0,Rf AT EACH DIRECTION ',I,R0(I),RF(I)
+ ENDDO
+ END IF
+
+! DO I=2,IT-1
+! R01(I)=(R0(I-1)+R0(I)+R0(I+1))/3.
+! END DO
+! R01(1)=(R0(IT)+R0(1)+R0(2))/3.
+! R01(IT)=(R0(IT-1)+R0(IT)+R0(1))/3.
+! R0=R01
+
+
+! IF(IBGS.NE.1)THEN
+! RMIN=1.E20
+! DO I=1,IT
+! IF(RMIN.GT.R0(I))RMIN=R0(I)
+! END DO
+! RMIN=min(RMIN,1.75*STRPSF(KST))
+! R0=RMIN
+! END IF
+
+! for bogus storm only
+! RF=5. !
+! R0=6.25 ! R0=4.5 (15m/s), 5.0(20m/s), 6.25 (35 m/s)
+! for bogus storm only
+
+ print *,'STRPSF(KST)=',STRPSF(KST)
+!C test for circular domain
+
+ RMN=0.
+ DO I=1,IT
+ RMN=RMN+R0(I)
+ END DO
+ RMN=RMN/FLOAT(IT)
+
+ print*,'RMN before adjustment=',RMN
+
+ RMN_HWRF=RMN
+
+ IF(IBGS.eq.1.and.iflag_cold.eq.0)THEN
+ REWIND(65)
+ READ(65)RMN_HWRF
+ END IF
+ IF(iflag_cold.ne.0)THEN
+ RMN_HWRF=STRPSF(KST)
+ END IF
+
+ RMN_FACT=RMN_HWRF/RMN
+ DO I=1,IT
+ RF(I)=RF(I)*RMN_FACT
+ R0(I)=R0(I)*RMN_FACT
+ END DO
+
+ RMN=RMN_HWRF
+
+ PRINT*,'MEAN RADIUS=',RMN
+ WRITE(85)RMN
+! WRITE(85)RF
+
+ DO I=1,IT
+ print *,'R0,Rf AT EACH DIRECTION ',I,R0(I),RF(I)
+ ENDDO
+
+ RETURN
+ END
+
+!! subroutine 'get_eta_level' returns the interface and
+!! layer-mean pressures for reference.
+ subroutine get_eta_level(npz, p_s, pf, ph, ak, bk, pscale)
+ integer, intent(in) :: npz
+ real(4), intent(in) :: p_s !< unit: pascal
+ real(4), intent(in) :: ak(npz+1)
+ real(4), intent(in) :: bk(npz+1)
+ real(4), intent(in), optional :: pscale
+ real(4), intent(out) :: pf(npz)
+ real(4), intent(out) :: ph(npz+1)
+
+ real, parameter :: RDGAS = 287.05 !< Gas constant for dry air [J/kg/deg]
+ real, parameter :: CP_AIR = 1004.6 !< Specific heat capacity of dry air at constant pressure [J/kg/deg]
+ real, parameter :: KAPPA = RDGAS/CP_AIR !< RDGAS / CP_AIR [dimensionless]
+ integer k
+
+ ph(1) = ak(1)
+ do k=2,npz+1
+ ph(k) = ak(k) + bk(k)*p_s
+ enddo
+
+! if ( present(pscale) ) then
+! do k=1,npz+1
+! ph(k) = pscale*ph(k)
+! enddo
+! endif
+
+ if( ak(1) > 1.E-8 ) then
+ pf(1) = (ph(2) - ph(1)) / log(ph(2)/ph(1))
+ else
+ pf(1) = (ph(2) - ph(1)) * kappa/(kappa+1.)
+ endif
+
+ do k=2,npz
+ pf(k) = (ph(k+1) - ph(k)) / log(ph(k+1)/ph(k))
+ enddo
+
+ end subroutine get_eta_level
+
+ real function calc_dist(lat1,lon1,lat2,lon2)
+ ! Distance using Haversine method for accuracy. Should be good to
+ ! about 100m for 32-bit floating point.
+
+! Earth radius from WRF-NMM module_model_constants.F as of HWRF R2
+! (WRF-NMM 3.2):
+ real, parameter :: Rearth = 6370e3
+
+ real, intent(in) :: lat1,lat2,lon1,lon2
+ real :: res,a,b,c
+
+ a=sin((lat2-lat1)/2.0)
+ b=cos(lat2)*cos(lat1)
+ c=sin((lon2-lon1)/2.0)
+ res=sqrt(a*a+b*c*c)
+
+ if(res>1) res=1
+ if(res<-1) res=-1
+ calc_dist= Rearth*2*asin(res);
+ end function calc_dist
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotm.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotm.f
new file mode 100644
index 000000000..50bac19fa
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotm.f
@@ -0,0 +1,106 @@
+ SUBROUTINE SROTM (N,SX,INCX,SY,INCY,SPARAM)
+C
+C APPLY THE MODIFIED GIVENS TRANSFORMATION, H, TO THE 2 BY N MATRIX
+C
+C (SX**T) , WHERE **T INDICATES TRANSPOSE. THE ELEMENTS OF SX ARE IN
+C (DX**T)
+C
+C SX(LX+I*INCX), I = 0 TO N-1, WHERE LX = 1 IF INCX .GE. 0, ELSE
+C LX = (-INCX)*N, AND SIMILARLY FOR SY USING USING LY AND INCY.
+C WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS..
+C
+C SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0
+C
+C (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0)
+C H=( ) ( ) ( ) ( )
+C (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0).
+C SEE SROTMG FOR A DESCRIPTION OF DATA STORAGE IN SPARAM.
+C
+ DIMENSION SX(1),SY(1),SPARAM(5)
+ DATA ZERO,TWO/0.E0,2.E0/
+C
+ SFLAG=SPARAM(1)
+ IF(N .LE. 0 .OR.(SFLAG+TWO.EQ.ZERO)) GO TO 140
+ IF(.NOT.(INCX.EQ.INCY.AND. INCX .GT.0)) GO TO 70
+C
+ NSTEPS=N*INCX
+ IF(SFLAG) 50,10,30
+ 10 CONTINUE
+ SH12=SPARAM(4)
+ SH21=SPARAM(3)
+ DO 20 I=1,NSTEPS,INCX
+ W=SX(I)
+ Z=SY(I)
+ SX(I)=W+Z*SH12
+ SY(I)=W*SH21+Z
+ 20 CONTINUE
+ GO TO 140
+ 30 CONTINUE
+ SH11=SPARAM(2)
+ SH22=SPARAM(5)
+ DO 40 I=1,NSTEPS,INCX
+ W=SX(I)
+ Z=SY(I)
+ SX(I)=W*SH11+Z
+ SY(I)=-W+SH22*Z
+ 40 CONTINUE
+ GO TO 140
+ 50 CONTINUE
+ SH11=SPARAM(2)
+ SH12=SPARAM(4)
+ SH21=SPARAM(3)
+ SH22=SPARAM(5)
+ DO 60 I=1,NSTEPS,INCX
+ W=SX(I)
+ Z=SY(I)
+ SX(I)=W*SH11+Z*SH12
+ SY(I)=W*SH21+Z*SH22
+ 60 CONTINUE
+ GO TO 140
+ 70 CONTINUE
+ KX=1
+ KY=1
+ IF(INCX .LT. 0) KX=1+(1-N)*INCX
+ IF(INCY .LT. 0) KY=1+(1-N)*INCY
+C
+ IF(SFLAG)120,80,100
+ 80 CONTINUE
+ SH12=SPARAM(4)
+ SH21=SPARAM(3)
+ DO 90 I=1,N
+ W=SX(KX)
+ Z=SY(KY)
+ SX(KX)=W+Z*SH12
+ SY(KY)=W*SH21+Z
+ KX=KX+INCX
+ KY=KY+INCY
+ 90 CONTINUE
+ GO TO 140
+ 100 CONTINUE
+ SH11=SPARAM(2)
+ SH22=SPARAM(5)
+ DO 110 I=1,N
+ W=SX(KX)
+ Z=SY(KY)
+ SX(KX)=W*SH11+Z
+ SY(KY)=-W+SH22*Z
+ KX=KX+INCX
+ KY=KY+INCY
+ 110 CONTINUE
+ GO TO 140
+ 120 CONTINUE
+ SH11=SPARAM(2)
+ SH12=SPARAM(4)
+ SH21=SPARAM(3)
+ SH22=SPARAM(5)
+ DO 130 I=1,N
+ W=SX(KX)
+ Z=SY(KY)
+ SX(KX)=W*SH11+Z*SH12
+ SY(KY)=W*SH21+Z*SH22
+ KX=KX+INCX
+ KY=KY+INCY
+ 130 CONTINUE
+ 140 CONTINUE
+ RETURN
+ END
diff --git a/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotmg.f b/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotmg.f
new file mode 100644
index 000000000..24243a13c
--- /dev/null
+++ b/sorc/hafs_tools.fd/sorc/hafs_vi/split/srotmg.f
@@ -0,0 +1,166 @@
+ SUBROUTINE SROTMG (SD1,SD2,SX1,SY1,SPARAM)
+C
+C CONSTRUCT THE MODIFIED GIVENS TRANSFORMATION MATRIX H WHICH ZEROS
+C THE SECOND COMPONENT OF THE 2-VECTOR (SQRT(SD1)*SX1,SQRT(SD2)*
+C SY2)**T.
+C WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS..
+C
+C SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0
+C
+C (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0)
+C H=( ) ( ) ( ) ( )
+C (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0).
+C LOCATIONS 2-4 OF SPARAM CONTAIN SH11,SH21,SH12, AND SH22
+C RESPECTIVELY. (VALUES OF 1.E0, -1.E0, OR 0.E0 IMPLIED BY THE
+C VALUE OF SPARAM(1) ARE NOT STORED IN SPARAM.)
+C
+C THE VALUES OF GAMSQ AND RGAMSQ SET IN THE DATA STATEMENT MAY BE
+C INEXACT. THIS IS OK AS THEY ARE ONLY USED FOR TESTING THE SIZE
+C OF SD1 AND SD2. ALL ACTUAL SCALING OF DATA IS DONE USING GAM.
+C
+ DIMENSION SPARAM(5)
+C
+ DATA ZERO,ONE,TWO /0.E0,1.E0,2.E0/
+ DATA GAM,GAMSQ,RGAMSQ/4096.E0,1.67772E7,5.96046E-8/
+ IF(.NOT. SD1 .LT. ZERO) GO TO 10
+C GO ZERO-H-D-AND-SX1..
+ GO TO 60
+ 10 CONTINUE
+C CASE-SD1-NONNEGATIVE
+ SP2=SD2*SY1
+ IF(.NOT. SP2 .EQ. ZERO) GO TO 20
+ SFLAG=-TWO
+ GO TO 260
+C REGULAR-CASE..
+ 20 CONTINUE
+ SP1=SD1*SX1
+ SQ2=SP2*SY1
+ SQ1=SP1*SX1
+C
+ IF(.NOT. ABS(SQ1) .GT. ABS(SQ2)) GO TO 40
+ SH21=-SY1/SX1
+ SH12=SP2/SP1
+C
+ SU=ONE-SH12*SH21
+C
+ IF(.NOT. SU .LE. ZERO) GO TO 30
+C GO ZERO-H-D-AND-SX1..
+ GO TO 60
+ 30 CONTINUE
+ SFLAG=ZERO
+ SD1=SD1/SU
+ SD2=SD2/SU
+ SX1=SX1*SU
+C GO SCALE-CHECK..
+ GO TO 100
+ 40 CONTINUE
+ IF(.NOT. SQ2 .LT. ZERO) GO TO 50
+C GO ZERO-H-D-AND-SX1..
+ GO TO 60
+ 50 CONTINUE
+ SFLAG=ONE
+ SH11=SP1/SP2
+ SH22=SX1/SY1
+ SU=ONE+SH11*SH22
+ STEMP=SD2/SU
+ SD2=SD1/SU
+ SD1=STEMP
+ SX1=SY1*SU
+C GO SCALE-CHECK
+ GO TO 100
+C PROCEDURE..ZERO-H-D-AND-SX1..
+ 60 CONTINUE
+ SFLAG=-ONE
+ SH11=ZERO
+ SH12=ZERO
+ SH21=ZERO
+ SH22=ZERO
+C
+ SD1=ZERO
+ SD2=ZERO
+ SX1=ZERO
+C RETURN..
+ GO TO 220
+C PROCEDURE..FIX-H..
+ 70 CONTINUE
+ IF(.NOT. SFLAG .GE. ZERO) GO TO 90
+C
+ IF(.NOT. SFLAG .EQ. ZERO) GO TO 80
+ SH11=ONE
+ SH22=ONE
+ SFLAG=-ONE
+ GO TO 90
+ 80 CONTINUE
+ SH21=-ONE
+ SH12=ONE
+ SFLAG=-ONE
+ 90 CONTINUE
+ GO TO IGO,(120,150,180,210)
+C PROCEDURE..SCALE-CHECK
+ 100 CONTINUE
+ 110 CONTINUE
+ IF(.NOT. SD1 .LE. RGAMSQ) GO TO 130
+ IF(SD1 .EQ. ZERO) GO TO 160
+ ASSIGN 120 TO IGO
+C FIX-H..
+ GO TO 70
+ 120 CONTINUE
+ SD1=SD1*GAM**2
+ SX1=SX1/GAM
+ SH11=SH11/GAM
+ SH12=SH12/GAM
+ GO TO 110
+ 130 CONTINUE
+ 140 CONTINUE
+ IF(.NOT. SD1 .GE. GAMSQ) GO TO 160
+ ASSIGN 150 TO IGO
+C FIX-H..
+ GO TO 70
+ 150 CONTINUE
+ SD1=SD1/GAM**2
+ SX1=SX1*GAM
+ SH11=SH11*GAM
+ SH12=SH12*GAM
+ GO TO 140
+ 160 CONTINUE
+ 170 CONTINUE
+ IF(.NOT. ABS(SD2) .LE. RGAMSQ) GO TO 190
+ IF(SD2 .EQ. ZERO) GO TO 220
+ ASSIGN 180 TO IGO
+C FIX-H..
+ GO TO 70
+ 180 CONTINUE
+ SD2=SD2*GAM**2
+ SH21=SH21/GAM
+ SH22=SH22/GAM
+ GO TO 170
+ 190 CONTINUE
+ 200 CONTINUE
+ IF(.NOT. ABS(SD2) .GE. GAMSQ) GO TO 220
+ ASSIGN 210 TO IGO
+C FIX-H..
+ GO TO 70
+ 210 CONTINUE
+ SD2=SD2/GAM**2
+ SH21=SH21*GAM
+ SH22=SH22*GAM
+ GO TO 200
+ 220 CONTINUE
+ IF(SFLAG)250,230,240
+ 230 CONTINUE
+ SPARAM(3)=SH21
+ SPARAM(4)=SH12
+ GO TO 260
+ 240 CONTINUE
+ SPARAM(2)=SH11
+ SPARAM(5)=SH22
+ GO TO 260
+ 250 CONTINUE
+ SPARAM(2)=SH11
+ SPARAM(3)=SH21
+ SPARAM(4)=SH12
+ SPARAM(5)=SH22
+ 260 CONTINUE
+ SPARAM(1)=SFLAG
+ RETURN
+ END
diff --git a/sorc/hafs_utils.fd b/sorc/hafs_utils.fd
index f2b376645..fa3b403da 160000
--- a/sorc/hafs_utils.fd
+++ b/sorc/hafs_utils.fd
@@ -1 +1 @@
-Subproject commit f2b376645f2f250624dba7bab2f73f36985c3240
+Subproject commit fa3b403dae9c55aca867382d6dd5b1fec6752a7c
diff --git a/sorc/install_all.sh b/sorc/install_all.sh
index a0fb4e768..903b54ef4 100755
--- a/sorc/install_all.sh
+++ b/sorc/install_all.sh
@@ -29,6 +29,7 @@ $Build_utils && {
${CP} hafs_utils.fd/exec/make_hgrid ../exec/hafs_make_hgrid.x
${CP} hafs_utils.fd/exec/make_solo_mosaic ../exec/hafs_make_solo_mosaic.x
${CP} hafs_utils.fd/exec/fregrid ../exec/hafs_fregrid.x
+ ${CP} hafs_utils.fd/exec/mppnccombine ../exec/hafs_mppnccombine.x
${CP} hafs_utils.fd/exec/filter_topo ../exec/hafs_filter_topo.x
${CP} hafs_utils.fd/exec/shave ../exec/hafs_shave.x
}
@@ -60,6 +61,14 @@ $Build_tools && {
${CP} hafs_tools.fd/exec/hafs_change_prepbufr_qm_typ.x ../exec/hafs_change_prepbufr_qm_typ.x
${CP} hafs_tools.fd/exec/hafs_change_prepbufr_qm_in_circle.x ../exec/hafs_change_prepbufr_qm_in_circle.x
${CP} hafs_tools.fd/exec/hafs_change_prepbufr_rm_typ_in_circle.x ../exec/hafs_change_prepbufr_rm_typ_in_circle.x
+ ${CP} hafs_tools.fd/exec/hafs_datool.x ../exec/hafs_datool.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_create_trak_guess.x ../exec/hafs_vi_create_trak_guess.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_create_trak_init.x ../exec/hafs_vi_create_trak_init.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_split.x ../exec/hafs_vi_split.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_anl_pert.x ../exec/hafs_vi_anl_pert.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_anl_combine.x ../exec/hafs_vi_anl_combine.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_anl_enhance.x ../exec/hafs_vi_anl_enhance.x
+ ${CP} hafs_tools.fd/exec/hafs_vi_anl_bogus.x ../exec/hafs_vi_anl_bogus.x
}
#------------------------------------
diff --git a/sorc/link_fix.sh b/sorc/link_fix.sh
index 08cee526c..ae0fe5ba4 100755
--- a/sorc/link_fix.sh
+++ b/sorc/link_fix.sh
@@ -24,7 +24,7 @@ else
exit 1
fi
-for subdir in fix_am fix_orog fix_fv3_gmted2010 fix_sfc_climo fix_hycom fix_ww3 hafs-crtm-2.3.0 fix_cdeps;
+for subdir in fix_am fix_orog fix_fv3_gmted2010 fix_sfc_climo fix_vi fix_hycom fix_ww3 hafs-crtm-2.3.0 fix_cdeps;
do
ln -sf ${FIXROOT}/${subdir} ./
done
diff --git a/ush/hafs/launcher.py b/ush/hafs/launcher.py
index 583e8fe9b..919e87520 100644
--- a/ush/hafs/launcher.py
+++ b/ush/hafs/launcher.py
@@ -1082,7 +1082,6 @@ def keep_condition(vit):
vitbase=self.choose_vitbase(storm_num)
vitbasedir=os.path.dirname(vitbase)
- print("vitbasedir",vitbasedir)
produtil.fileop.makedirs(vitbasedir,logger=logger)
logger.info('Reformat vitals...')
@@ -1119,6 +1118,18 @@ def keep_condition(vit):
with open(filename,'wt') as tmpvit:
print(self.oldsyndat.as_tcvitals(), file=tmpvit)
+ tm03syndat=syndat-3 # vitals at tm03
+ filename=os.path.join(self.getdir('WORKhafs'),'tm03vit')
+ logger.info(filename+': write tm03 vitals here')
+ with open(filename,'wt') as tmpvit:
+ print(tm03syndat.as_tcvitals(), file=tmpvit)
+
+ tp03syndat=syndat+3 # vitals at tp03
+ filename=os.path.join(self.getdir('WORKhafs'),'tp03vit')
+ logger.info(filename+': write tp03 vitals here')
+ with open(filename,'wt') as tmpvit:
+ print(tp03syndat.as_tcvitals(), file=tmpvit)
+
def sanity_check_archive(self,logger=None):
"""!Runs a sanity check on the archiving settings.
@param logger a logging.Logger for log messages"""
@@ -1412,103 +1423,6 @@ def make_holdvars(self,part1='{PARMhafs}/hafs_holdvars.txt',part2=None):
out=list()
logger=self.log()
- # Generate the output grid for the write grid component of the forecast job
- output_grid=self.getstr('forecast','output_grid','rotated_latlon')
- logger.info('output_grid is: %s'%(output_grid))
- output_grid_cen_lon=self.getfloat('forecast','output_grid_cen_lon',-62.0)
- output_grid_cen_lat=self.getfloat('forecast','output_grid_cen_lat',22.0)
- output_grid_lon_span=self.getfloat('forecast','output_grid_lon_span',70.0)
- output_grid_lat_span=self.getfloat('forecast','output_grid_lat_span',60.0)
- output_grid_dlon=self.getfloat('forecast','output_grid_dlon',0.025)
- output_grid_dlat=self.getfloat('forecast','output_grid_dlat',0.025)
- if output_grid=='rotated_latlon':
- output_grid_lon1=self.getfloat('forecast','output_grid_lon1',0.0-output_grid_lon_span/2.0)
- output_grid_lat1=self.getfloat('forecast','output_grid_lat1',0.0-output_grid_lat_span/2.0)
- output_grid_lon2=self.getfloat('forecast','output_grid_lon2',0.0+output_grid_lon_span/2.0)
- output_grid_lat2=self.getfloat('forecast','output_grid_lat2',0.0+output_grid_lat_span/2.0)
- elif output_grid=='regional_latlon':
- output_grid_lon1=self.getfloat('forecast','output_grid_lon1',output_grid_cen_lon-output_grid_lon_span/2.0)
- output_grid_lat1=self.getfloat('forecast','output_grid_lat1',output_grid_cen_lat-output_grid_lat_span/2.0)
- output_grid_lon2=self.getfloat('forecast','output_grid_lon2',output_grid_cen_lon+output_grid_lon_span/2.0)
- output_grid_lat2=self.getfloat('forecast','output_grid_lat2',output_grid_cen_lat+output_grid_lat_span/2.0)
- else:
- logger.error('Exiting, output_grid: %s not supported.'%(output_grid))
- sys.exit(2)
- self.set('holdvars','output_grid_lon1','%.6f'%(output_grid_lon1))
- self.set('holdvars','output_grid_lat1','%.6f'%(output_grid_lat1))
- self.set('holdvars','output_grid_lon2','%.6f'%(output_grid_lon2))
- self.set('holdvars','output_grid_lat2','%.6f'%(output_grid_lat2))
-
- # Generate synop_gridspecs if needed
- synop_gridspecs=self.getstr('atm_post','synop_gridspecs','auto')
- # if synop_gridspecs=auto, then synop_gridspecs will be automatically generated based on the output grid
- if synop_gridspecs=='auto':
- if output_grid=='rotated_latlon':
- latlon_lon0=output_grid_cen_lon+output_grid_lon1-9.
- latlon_lat0=output_grid_cen_lat+output_grid_lat1
- latlon_dlon=output_grid_dlon
- latlon_dlat=output_grid_dlat
- latlon_nlon=(output_grid_lon2-output_grid_lon1+18.)/output_grid_dlon
- latlon_nlat=(output_grid_lat2-output_grid_lat1)/output_grid_dlat
- elif output_grid=='regional_latlon':
- latlon_lon0=output_grid_lon1
- latlon_lat0=output_grid_lat1
- latlon_dlon=output_grid_dlon
- latlon_dlat=output_grid_dlat
- latlon_nlon=(output_grid_lon2-output_grid_lon1)/output_grid_dlon
- latlon_nlat=(output_grid_lat2-output_grid_lat1)/output_grid_dlat
- logger.info('since synop_gridspecs is %s' %(synop_gridspecs))
- synop_gridspecs='"latlon %f:%d:%f %f:%d:%f"'%(
- latlon_lon0,latlon_nlon,latlon_dlon,
- latlon_lat0,latlon_nlat,latlon_dlat)
- logger.info('automatically generated synop_gridspecs: %s' %(synop_gridspecs))
- self.set('holdvars','synop_gridspecs',synop_gridspecs)
-
- # Set trker_gridspecs if needed
- trker_gridspecs=self.getstr('atm_post','trker_gridspecs','auto')
- if trker_gridspecs=='auto':
- logger.info('since trker_gridspecs is %s' %(trker_gridspecs))
- trker_gridspecs=synop_gridspecs
- logger.info('automatically generated trker_gridspecs: %s' %(trker_gridspecs))
- self.set('holdvars','trker_gridspecs',trker_gridspecs)
-
- # Generate synop_gridspecs_ens if needed
- grid_ratio_ens=self.getfloat('config','GRID_RATIO_ENS',1.)
- synop_gridspecs_ens=self.getstr('atm_post_ens','synop_gridspecs_ens','auto')
- output_grid_dlon_ens=self.getfloat('forecast_ens','output_grid_dlon_ens',0.025)
- output_grid_dlat_ens=self.getfloat('forecast_ens','output_grid_dlat_ens',0.025)
-
- # if synop_gridspecs_ens=auto, then synop_gridspecs_ens will be automatically generated based on the output grid
- if synop_gridspecs_ens=='auto':
- if output_grid=='rotated_latlon':
- latlon_lon0=output_grid_cen_lon+output_grid_lon1-9.
- latlon_lat0=output_grid_cen_lat+output_grid_lat1
- latlon_dlon=output_grid_dlon_ens
- latlon_dlat=output_grid_dlat_ens
- latlon_nlon=(output_grid_lon2-output_grid_lon1+18.)/output_grid_dlon_ens
- latlon_nlat=(output_grid_lat2-output_grid_lat1)/output_grid_dlat_ens
- elif output_grid=='regional_latlon':
- latlon_lon0=output_grid_lon1
- latlon_lat0=output_grid_lat1
- latlon_dlon=output_grid_dlon_ens
- latlon_dlat=output_grid_dlat_ens
- latlon_nlon=(output_grid_lon2-output_grid_lon1)/output_grid_dlon_ens
- latlon_nlat=(output_grid_lat2-output_grid_lat1)/output_grid_dlat_ens
- logger.info('since synop_gridspecs_ens is %s' %(synop_gridspecs_ens))
- synop_gridspecs_ens='"latlon %f:%d:%f %f:%d:%f"'%(
- latlon_lon0,latlon_nlon,latlon_dlon,
- latlon_lat0,latlon_nlat,latlon_dlat)
- logger.info('automatically generated synop_gridspecs_ens: %s' %(synop_gridspecs_ens))
- self.set('holdvars','synop_gridspecs_ens',synop_gridspecs_ens)
-
- # Set trker_gridspecs_ens if needed
- trker_gridspecs_ens=self.getstr('atm_post_ens','trker_gridspecs_ens','auto')
- if trker_gridspecs_ens=='auto':
- logger.info('since trker_gridspecs_ens is %s' %(trker_gridspecs_ens))
- trker_gridspecs_ens=synop_gridspecs_ens
- logger.info('automatically generated trker_gridspecs_ens: %s' %(trker_gridspecs_ens))
- self.set('holdvars','trker_gridspecs_ens',trker_gridspecs_ens)
-
run_ocean=self.getbool('config','run_ocean')
# Set ocean_start_dtg if needed
@@ -1530,6 +1444,15 @@ def make_holdvars(self,part1='{PARMhafs}/hafs_holdvars.txt',part2=None):
gsi_flag=self.getbool('config','run_gsi')
self.set('holdvars','cap_run_gsi',('YES' if gsi_flag else 'NO'))
+ gsi_flag=self.getbool('config','gsi_d01')
+ self.set('holdvars','cap_gsi_d01',('YES' if gsi_flag else 'NO'))
+
+ gsi_flag=self.getbool('config','gsi_d02')
+ self.set('holdvars','cap_gsi_d02',('YES' if gsi_flag else 'NO'))
+
+ gsi_flag=self.getbool('config','gsi_d03')
+ self.set('holdvars','cap_gsi_d03',('YES' if gsi_flag else 'NO'))
+
fgat_flag=self.getbool('config','run_fgat')
self.set('holdvars','cap_run_fgat',('YES' if fgat_flag else 'NO'))
@@ -1542,9 +1465,38 @@ def make_holdvars(self,part1='{PARMhafs}/hafs_holdvars.txt',part2=None):
enkf_flag=self.getbool('config','run_enkf')
self.set('holdvars','cap_run_enkf',('YES' if enkf_flag else 'NO'))
- reloc_flag=self.getbool('config','run_vortexinit')
- self.set('holdvars','cap_run_vortexinit',
- ('YES' if reloc_flag else 'NO'))
+ atm_init_flag=self.getbool('config','run_atm_init')
+ self.set('holdvars','cap_run_atm_init',('YES' if atm_init_flag else 'NO'))
+
+ atm_init_fgat_flag=self.getbool('config','run_atm_init_fgat')
+ self.set('holdvars','cap_run_atm_init_fgat',('YES' if atm_init_fgat_flag else 'NO'))
+
+ atm_init_ens_flag=self.getbool('config','run_atm_init_ens')
+ self.set('holdvars','cap_run_atm_init_ens',('YES' if atm_init_ens_flag else 'NO'))
+
+ atm_vi_flag=self.getbool('config','run_atm_vi')
+ self.set('holdvars','cap_run_atm_vi',('YES' if atm_vi_flag else 'NO'))
+
+ atm_vi_fgat_flag=self.getbool('config','run_atm_vi_fgat')
+ self.set('holdvars','cap_run_atm_vi_fgat',('YES' if atm_vi_fgat_flag else 'NO'))
+
+ atm_vi_ens_flag=self.getbool('config','run_atm_vi_ens')
+ self.set('holdvars','cap_run_atm_vi_ens',('YES' if atm_vi_ens_flag else 'NO'))
+
+ atm_merge_flag=self.getbool('config','run_atm_merge')
+ self.set('holdvars','cap_run_atm_merge',('YES' if atm_merge_flag else 'NO'))
+
+ atm_merge_fgat_flag=self.getbool('config','run_atm_merge_fgat')
+ self.set('holdvars','cap_run_atm_merge_fgat',('YES' if atm_merge_fgat_flag else 'NO'))
+
+ atm_merge_ens_flag=self.getbool('config','run_atm_merge_ens')
+ self.set('holdvars','cap_run_atm_merge_ens',('YES' if atm_merge_ens_flag else 'NO'))
+
+ analysis_merge_flag=self.getbool('config','run_analysis_merge')
+ self.set('holdvars','cap_run_analysis_merge',('YES' if analysis_merge_flag else 'NO'))
+
+ analysis_merge_ens_flag=self.getbool('config','run_analysis_merge_ens')
+ self.set('holdvars','cap_run_analysis_merge_ens',('YES' if analysis_merge_ens_flag else 'NO'))
gplot_flag=self.getbool('config','run_hrdgraphics')
self.set('holdvars','cap_run_hrdgraphics',
diff --git a/ush/hafs_make_grid.sh b/ush/hafs_make_grid.sh
index 6df2e88da..c4e9f3028 100755
--- a/ush/hafs_make_grid.sh
+++ b/ush/hafs_make_grid.sh
@@ -1,16 +1,24 @@
#!/bin/sh
+#
+# Updates:
+# May 15, 2020 Bill Ramstrom, HRD/AOML, Added multiple nest capability
+#
set -eux
nargv=$#
-if [ $nargv -ne 3 -a $nargv -ne 6 -a $nargv -ne 12 ]; then
- echo "number of arguments must be 3 (regular cubic sphere grid), 6 (stretched grid) or 12 (nested grid)"
- echo "Usage for regular cubic sphere grid: "
+if [ $nargv -ne 3 -a $nargv -ne 5 -a $nargv -ne 6 -a $nargv -ne 12 -a $nargv -ne 14 ]; then
+ echo "number of arguments must be 3, 5 (regular cubic sphere grid), 6 (stretched grid), or 12, 14 ( nested grid)"
+ echo "Usage for regular cubic sphere grid: (uses default target_lat, target_lon, retained for backwards compatibility ) "
echo " $0 resolution out_dir script_dir"
+ echo "Usage for regular cubic sphere grid: "
+ echo " $0 resolution out_dir target_lon target_lat script_dir"
echo "Usage for Stretched grid: "
echo " $0 resolution out_dir stetch_fac target_lon target_lat script_dir"
- echo "Usage for Nested grid: "
- echo " $0 resolution out_dir stetch_fac target_lon target_lat refine_ratio istart_nest jstart_nest iend_nest jend_nest halo script_dir"
+ echo "Usage for Nested grid: (single nest with parent tile 6, retained for backwards compatibility)"
+ echo " $0 resolution out_dir stetch_fac target_lon target_lat refine_ratio_list istart_nest_list jstart_nest_list iend_nest_list jend_nest_list halo script_dir"
+ echo "Usage for Nested grid: (single or multiple nests)"
+ echo " $0 resolution out_dir stetch_fac target_lon target_lat num_nests parent_tile_list refine_ratio_list istart_nest_list jstart_nest_list iend_nest_list jend_nest_list halo script_dir"
exit 1
fi
@@ -22,16 +30,27 @@ if [ ! -s $outdir ]; then mkdir -p $outdir ;fi
nx=`expr $res \* 2 `
cd $outdir
-if [ $nargv -eq 3 ]; then
+if [ $nargv -eq 3 -o $nargv -eq 5 ]; then
export ntiles=6
- export script_dir=$3
- #export executable=$exec_dir/make_hgrid
+
+ if [ $nargv -eq 3 ]; then
+ export script_dir=$3
+ export target_opts=""
+ else
+ export target_lon=$3
+ export target_lat=$4
+ export script_dir=$5
+ export target_opts="--do_schmidt --stretch_factor 1.0 --target_lon ${target_lon} --target_lat ${target_lat}"
+ fi
+
export executable=${MAKEHGRIDEXEC:-$exec_dir/hafs_make_hgrid.x}
if [ ! -s $executable ]; then
echo "executable does not exist"
exit 1
fi
- $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid
+ echo "Making uniform grids: $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid ${target_opts}"
+
+ $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid ${target_opts}
elif [ $nargv -eq 6 ]; then
export stretch_fac=$3
@@ -45,32 +64,55 @@ elif [ $nargv -eq 6 ]; then
echo "executable does not exist"
exit 1
fi
+
+ echo "Making stretched grids: $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid --do_schmidt --stretch_factor ${stretch_fac} --target_lon ${target_lon} --target_lat ${target_lat} "
+
$APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid --do_schmidt --stretch_factor ${stretch_fac} --target_lon ${target_lon} --target_lat ${target_lat}
-elif [ $nargv -eq 12 ]; then
+elif [ $nargv -eq 12 -o $nargv -eq 14 ]; then
export stretch_fac=$3
export target_lon=$4
export target_lat=$5
- export refine_ratio=$6
- export istart_nest=$7
- export jstart_nest=$8
- export iend_nest=$9
- export jend_nest=${10}
- export halo=${11}
- export script_dir=${12}
+
+ if [ $nargv -eq 12 ]; then
+ export nest_grids=1
+ export parent_tile=6
+ export refine_ratio=$6
+ export istart_nest=$7
+ export jstart_nest=${8}
+ export iend_nest=${9}
+ export jend_nest=${10}
+ export halo=${11}
+ export script_dir=${12}
+ else
+ export nest_grids=$6
+ export parent_tile=$7
+ export refine_ratio=$8
+ export istart_nest=$9
+ export jstart_nest=${10}
+ export iend_nest=${11}
+ export jend_nest=${12}
+ export halo=${13}
+ export script_dir=${14}
+ fi
if [ $gtype = regional ]; then
- export ntiles=1
+ export ntiles=$(( 0+$nest_grids ))
else
- export ntiles=7
+ export ntiles=$(( 6+$nest_grids ))
fi
- #export executable=$exec_dir/make_hgrid
export executable=${MAKEHGRIDEXEC:-$exec_dir/hafs_make_hgrid.x}
if [ ! -s $executable ]; then
echo "executable does not exist"
exit 1
fi
- $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid --do_schmidt --stretch_factor ${stretch_fac} --target_lon ${target_lon} --target_lat ${target_lat} \
- --nest_grid --parent_tile 6 --refine_ratio $refine_ratio --istart_nest $istart_nest --jstart_nest $jstart_nest --iend_nest $iend_nest --jend_nest $jend_nest --halo $halo --great_circle_algorithm
+
+ echo "Making nested grids: $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid --do_schmidt --stretch_factor ${stretch_fac} \
+ --target_lon ${target_lon} --target_lat ${target_lat} --nest_grids $nest_grids --parent_tile $parent_tile --refine_ratio $refine_ratio \
+ --istart_nest $istart_nest --jstart_nest $jstart_nest --iend_nest $iend_nest --jend_nest $jend_nest --halo $halo --great_circle_algorithm"
+
+ $APRUN $executable --grid_type gnomonic_ed --nlon $nx --grid_name C${res}_grid --do_schmidt --stretch_factor ${stretch_fac} \
+ --target_lon ${target_lon} --target_lat ${target_lat} --nest_grids $nest_grids --parent_tile $parent_tile --refine_ratio $refine_ratio \
+ --istart_nest $istart_nest --jstart_nest $jstart_nest --iend_nest $iend_nest --jend_nest $jend_nest --halo $halo --great_circle_algorithm
fi
@@ -79,6 +121,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
+
#---------------------------------------------------------------------------------------
#export executable=$exec_dir/make_solo_mosaic
export executable=${MAKEMOSAICEXEC:-$exec_dir/hafs_make_solo_mosaic.x}
@@ -87,22 +130,61 @@ if [ ! -s $executable ]; then
exit 1
fi
-if [ $ntiles -eq 6 ]; then
+if [ $gtype = uniform -o $gtype = stretch ] && [ $ntiles -eq 6 ]; then
$APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc
-elif [ $ntiles -eq 7 ]; then
- $APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc,C${res}_grid.tile7.nc
+elif [ $gtype = nest -a $ntiles -ge 7 ]; then
+
+ file_list="C${res}_grid.tile7.nc"
+ for itile in $(seq 8 $ntiles)
+ do
+ file_list="${file_list},C${res}_grid.tile${itile}.nc"
+ done
+
+ # mosaic file for global and nests
+ $APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc,${file_list}
+ # mosaic file for coarse grids only
$APRUN $executable --num_tiles 6 --dir $outdir --mosaic C${res}_coarse_mosaic --tile_file C${res}_grid.tile1.nc,C${res}_grid.tile2.nc,C${res}_grid.tile3.nc,C${res}_grid.tile4.nc,C${res}_grid.tile5.nc,C${res}_grid.tile6.nc
- $APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_nested_mosaic --tile_file C${res}_grid.tile7.nc
-#
-#special case for the regional grid. For now we have only 1 tile and it is tile 7
-#
-elif [ $ntiles -eq 1 ];then
- $APRUN $executable --num_tiles $ntiles --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile7.nc
+ # mosaic file for nested grids only
+ for itile in $(seq 7 $ntiles)
+ do
+ file_list="C${res}_grid.tile${itile}.nc"
+ inest=$(($itile - 5))
+ $APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_nested0${inest}_mosaic --tile_file ${file_list}
+ done
+
+# regional grid without nests
+elif [ $gtype = regional -a $nest_grids -eq 1 ]; then
+
+ $APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_mosaic --tile_file C${res}_grid.tile7.nc
+
+# regional grid with nests
+elif [ $gtype = regional -a $nest_grids -gt 1 ]; then
+
+ ntiles=$(( 6+$nest_grids ))
+ file_list="C${res}_grid.tile7.nc"
+ for itile in $(seq 8 $ntiles)
+ do
+ file_list="${file_list},C${res}_grid.tile${itile}.nc"
+ done
+
+ # create mosaic for regional and nests
+ $APRUN $executable --num_tiles $nest_grids --dir $outdir --mosaic C${res}_all_mosaic --tile_file ${file_list}
+
+ # mosaic file for coarse grids only
+ $APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_coarse_mosaic --tile_file C${res}_grid.tile7.nc
+
+ # mosaic file for nested grids only
+ for itile in $(seq 8 $ntiles)
+ do
+ file_list="C${res}_grid.tile${itile}.nc"
+ inest=$(($itile - 6))
+ $APRUN $executable --num_tiles 1 --dir $outdir --mosaic C${res}_nested0${inest}_mosaic --tile_file ${file_list}
+ done
+
fi
exit
-
diff --git a/ush/hafs_make_orog.sh b/ush/hafs_make_orog.sh
index 6d3f7c3b3..1b1016cd6 100755
--- a/ush/hafs_make_orog.sh
+++ b/ush/hafs_make_orog.sh
@@ -90,7 +90,7 @@ cp ${indir}/landcover30.fixed .
# uncomment next line to use the old gtopo30 data.
# cp ${indir}/gtopo30_gg.fine.nh fort.235
# use gmted2020 data.
-cp ${indir}/gmted2010.30sec.int fort.235
+cp -f ${indir}/gmted2010.30sec.int fort.235
if [ $inorogexist -eq 1 ]; then
cp $inputorog .
fi
diff --git a/ush/tcutil/storminfo.py b/ush/tcutil/storminfo.py
index 14c799159..9d111af04 100644
--- a/ush/tcutil/storminfo.py
+++ b/ush/tcutil/storminfo.py
@@ -547,9 +547,9 @@ def __add__(self,amount):
#logging.debug('vmag=%s dt=%s dx=%s dy=%s dlat=%s dlon=%s'%(
# repr(vmag),repr(dt),repr(dx),repr(dy),repr(dlat),repr(dlon)))
return copy
+
def tcutil_domain_center(self,logger=None):
- """!Decide domain center based on the storm location, basin,
- and, if available, the 72hr forecast location. Returns a tuple
+ """!Decide domain center based on the storm location. Returns a tuple
containing a pair of floats (cenlo, cenla) which are the
domain center longitude and latitude, respectively. Results
are cached internally so future calls will not have to
@@ -562,64 +562,88 @@ def tcutil_domain_center(self,logger=None):
storm_lon=self.lon
assert(storm_lon is not None)
storm_lat=self.lat
- if self.havefcstloc:
- assert(self.flon is not None)
- avglon=self.flon
- else:
- avglon=storm_lon-20.0
- assert(avglon is not None)
-
- # Decide center latitude.
+ cenlo=storm_lon
cenla=storm_lat
- if storm_lat<0: cenla=-cenla
- ilat=math.floor(cenla)
- if ilat < 15: cenla=15.0
- if ilat > 25: cenla=25.0
- if ilat >= 35: cenla=30.0
- if ilat >= 40: cenla=35.0
- if ilat >= 44: cenla=40.0
- if ilat >= 50: cenla=45.0
- if ilat >= 55: cenla=50.0
- if storm_lat<0: cenla=-cenla
-
- # Decide the center longitude.
- if logger is not None:
- logger.info('Averaging storm_lon=%f and avglon=%f'%(storm_lon,avglon))
- diff=storm_lon-avglon
- if(diff> 360.): storm_lon -= 360.0
- if(diff<-360.): avglon -= 360.0
- result=int((10.0*storm_lon + 10.0*avglon)/2.0)/10.0
- if(result > 180.0): result-=360.0
- if(result < -180.0): result+=360.0
- cenlo=result
if logger is not None:
logger.info('Decided cenlo=%f cenla=%f'%(cenlo,cenla))
logger.info('Storm is at lon=%f lat=%f'%(storm_lon,storm_lat))
- # Lastly, some sanity checks to avoid outer domain centers too
- # far from storm centers:
- moved=False
- if(int(cenlo)>int(storm_lon)+5):
- cenlo=storm_lon+5.0
- if logger is not None:
- logger.info(
- 'Center is too far east of storm. Moving it to %f'
- %(cenlo,))
- moved=True
- if(int(cenlo) 25: cenla=25.0
+# if ilat >= 35: cenla=30.0
+# if ilat >= 40: cenla=35.0
+# if ilat >= 44: cenla=40.0
+# if ilat >= 50: cenla=45.0
+# if ilat >= 55: cenla=50.0
+# if storm_lat<0: cenla=-cenla
+
+# # Decide the center longitude.
+# if logger is not None:
+# logger.info('Averaging storm_lon=%f and avglon=%f'%(storm_lon,avglon))
+# diff=storm_lon-avglon
+# if(diff> 360.): storm_lon -= 360.0
+# if(diff<-360.): avglon -= 360.0
+# result=int((10.0*storm_lon + 10.0*avglon)/2.0)/10.0
+# if(result > 180.0): result-=360.0
+# if(result < -180.0): result+=360.0
+# cenlo=result
+# if logger is not None:
+# logger.info('Decided cenlo=%f cenla=%f'%(cenlo,cenla))
+# logger.info('Storm is at lon=%f lat=%f'%(storm_lon,storm_lat))
+# # Lastly, some sanity checks to avoid outer domain centers too
+# # far from storm centers:
+# moved=False
+# if(int(cenlo)>int(storm_lon)+5):
+# cenlo=storm_lon+5.0
+# if logger is not None:
+# logger.info(
+# 'Center is too far east of storm. Moving it to %f'
+# %(cenlo,))
+# moved=True
+# if(int(cenlo)