Wednesday, July 30, 2014

Standard setting to run GSI

#!/bin/sh --login
##########################################
# 1. qsub flags : starting with #$
##########################################
#$ -N run1
#$ -pe mpi2_mpd 192
#$ -o $HOME/run1.out
#$ -e $HOME/run1.err
# Specify to run the job in bash shell(optional for bash)
#$ -S /bin/bash  

set -x

##################################################
# 2. Set experiment name and analysis date
##################################################
ANAL_TIME=2013011400
EXP_NAME=run1
WORK_DIR=/scratch5/dxu/${EXP_NAME}_${ANAL_TIME}

##################################################
# 3. Data directories
##################################################
#1) test data dir
DATA_DIR=/data/dxu/gsi_sample_data/${ANAL_TIME}
#2) obs dir
OBS_DIR=${DATA_DIR}/obs
#3) guess dir
BK_DIR=${DATA_DIR}/ges
#4)ensemble dir
datens=${DATA_DIR}/ens

##################################################
# 4. GSI dir
##################################################
GSI_DIR=/data/dxu/gsi_tag_rel-5.0.0
GSI_EXE=$GSI_DIR/src/global_gsi
GSI_TYPE=gdas

##################################################
# 5. nwprod directory : utility 
##################################################
NWPROD_DIR=/usr/local/jcsda/nwprod_gdas_2014
NDATE=$NWPROD_DIR/util/exec/ndate

##################################################
# 6. coeff direcotry
##################################################
GSI_FIX_DIR=$GSI_DIR/fix
CRTM_FIX_DIR=$NWPROD_DIR/lib/sorc/crtm_v2.1.3/fix

##################################################
# Set the JCAP resolution which you want.
# All resolutions use LEVS=64
##################################################
export JCAP=62
export LEVS=64
 
##################################################
# 7. Create working directory
##################################################
rm -rf $WORK_DIR
mkdir -p $WORK_DIR
cd $WORK_DIR
rm -rf core*

##################################################
# 8. Create GSI f90 namelist
##################################################
cat << EOF > gsiparm.anl
 &SETUP
   miter=2, niter(1)=100, niter(2)=150, 
...
...
 /
EOF

##################################################
# 9. Define all the files
##################################################
#----------------------------------------------------
#1) GSI fix info files
#----------------------------------------------------
# a) config file
# b) Observation control file
# c) Bias correction used by radiance analysis
#----------------------------------------------------
# a) config file
ANAVINFO=$GSI_FIX_DIR/global_anavinfo.l64.txt
BERROR=$GSI_FIX_DIR/Big_Endian/global_berror.l${LEVS}y${NLAT}.f77
OBERROR=$GSI_FIX_DIR/prepobs_errtable.global
# b) Observation control file
CONVINFO=$GSI_FIX_DIR/global_convinfo.txt
SATINFO=$GSI_FIX_DIR/global_satinfo.txt
PCPINFO=$GSI_FIX_DIR/global_pcpinfo.txt
OZINFO=$GSI_FIX_DIR/global_ozinfo.txt
# c) Bias correction used by radiance analysis
SATBIAS=$OBS_DIR/biascr.gdas.$ANAL_TIME
SATANGL=$GSI_FIX_DIR/global_satangbias.txt

#----------------------------------------------------
#2) CRTM fix files (11 files)
#----------------------------------------------------
emiscoef_IRwater=$CRTM_FIX_DIR/Nalli.IRwater.EmisCoeff.bin
emiscoef_IRice=$CRTM_FIX_DIR/NPOESS.IRice.EmisCoeff.bin
emiscoef_IRland=$CRTM_FIX_DIR/NPOESS.IRland.EmisCoeff.bin
emiscoef_IRsnow=$CRTM_FIX_DIR/NPOESS.IRsnow.EmisCoeff.bin
emiscoef_VISice=$CRTM_FIX_DIR/NPOESS.VISice.EmisCoeff.bin
emiscoef_VISland=$CRTM_FIX_DIR/NPOESS.VISland.EmisCoeff.bin
emiscoef_VISsnow=$CRTM_FIX_DIR/NPOESS.VISsnow.EmisCoeff.bin
emiscoef_VISwater=$CRTM_FIX_DIR/NPOESS.VISwater.EmisCoeff.bin
emiscoef_MWwater=$CRTM_FIX_DIR/FASTEM5.MWwater.EmisCoeff.bin
aercoef=$CRTM_FIX_DIR/AerosolCoeff.bin
cldcoef=$CRTM_FIX_DIR/CloudCoeff.bin

#----------------------------------------------------
#3) Only need this file for single obs test
#----------------------------------------------------
BUFRTABLE=$GSI_FIX_DIR/prepobs_prep.bufrtable

#----------------------------------------------------
#4) Only need this file for sst retrieval
#----------------------------------------------------
BFTAB_SST=$GSI_FIX_DIR/bufrtab.012

##########################################
# 10. Copy file to working directory
##########################################
#----------------------------------------------------
#1) GSI fix info files
#----------------------------------------------------
#-----------------------------------------------
# a) config file
# b) Observation control file
# c) Bias correction used by radiance analysis
#-----------------------------------------------
# a) config file 
$CP $ANAVINFO ./anavinfo     # config file to set control and analysis vars
$CP $BERROR   ./berror_stats # background error covariance
$CP $OBERROR  ./errtable     # obs error table : bias correction to conv obs data
# b) Observation control file
$CP $CONVINFO ./convinfo     # conv obs data
$CP $SATINFO  ./satinfo      # sat obs data
$CP $PCPINFO  ./pcpinfo      # pcp rate obs data
$CP $OZINFO   ./ozinfo       # o3 obs data
# c) Bias correction used by radiance analysis
$CP $SATBIAS  ./satbias_in
$CP $SATANGL  ./satbias_angle
# d) Used for hybrid ensemble test
$CP $HYBENS_LOCINFO ./hybens_locinfo

#----------------------------------------------------
#2) Radiance coefficient used by CRTM
#----------------------------------------------------
#------------------------------
# a) EmisCoeff.bin
# b) AErosolCoeff.bin
# c) CloudCoeff.bin
# d) ${satsen}.SpcCoeff.bin
# e) ${satsen}.TauCoeff.bin
#------------------------------
# a) EmisCoeff.bin
$LN $emiscoef_IRwater ./Nalli.IRwater.EmisCoeff.bin
$LN $emiscoef_IRice ./NPOESS.IRice.EmisCoeff.bin
$LN $emiscoef_IRsnow ./NPOESS.IRsnow.EmisCoeff.bin
$LN $emiscoef_IRland ./NPOESS.IRland.EmisCoeff.bin
$LN $emiscoef_VISice ./NPOESS.VISice.EmisCoeff.bin
$LN $emiscoef_VISland ./NPOESS.VISland.EmisCoeff.bin
$LN $emiscoef_VISsnow ./NPOESS.VISsnow.EmisCoeff.bin
$LN $emiscoef_VISwater ./NPOESS.VISwater.EmisCoeff.bin
$LN $emiscoef_MWwater ./FASTEM5.MWwater.EmisCoeff.bin
# b) AErosolCoeff.bin
$LN $aercoef  ./AerosolCoeff.bin
# c) CloudCoeff.bin
$LN $cldcoef  ./CloudCoeff.bin

# d) ${satsen}.SpcCoeff.bin
# e) ${satsen}.TauCoeff.bin
# CRTM Spectral and Transmittance coefficients
# Print out the 1st column of file satinfo
for file in `awk '{if($1!~"!"){print $1}}' satinfo | sort | uniq` ;do
   ${LN:-cp} $CRTM_FIX_DIR/${file}.SpcCoeff.bin ./
   ${LN:-cp} $CRTM_FIX_DIR/${file}.TauCoeff.bin ./
done

#----------------------------------------------------
#3) Only need this file for single obs test
#----------------------------------------------------
$CP $BUFRTABLE ./prepobs_prep.bufrtable

#----------------------------------------------------
#4) Only need this file for sst retrieval
#----------------------------------------------------
$CP $BFTAB_SST ./bftab_sstphr

#----------------------------------------------------
#5) Obs data 
#  Destination filenames such as "prepbufr" needs to 
#  match ones in GSI f90 namelist
#----------------------------------------------------
$LN $OBS_DIR/prepqc.$GSI_TYPE.$ANAL_TIME   ./prepbufr
$LN $OBS_DIR/satwnd.$GSI_TYPE.$ANAL_TIME   ./satwndbufr
...
...
$LN $OBS_DIR/ssmis.$GSI_TYPE.$ANAL_TIME    ./ssmisbufr
$LN $OBS_DIR/tcvitl.$GSI_TYPE.$ANAL_TIME   ./tcvitl

#----------------------------------------------------
#6) Background file
#----------------------------------------------------
# Bring over background field (it's modified by GSI so we can't link to it)
$LN $BK_DIR/sfcf03.t${JCAP_B}.${gdate}  ./sfcf03
$LN $BK_DIR/sfcf06.t${JCAP_B}.${gdate}  ./sfcf06
$LN $BK_DIR/sfcf09.t${JCAP_B}.${gdate}  ./sfcf09

$LN $BK_DIR/sigf03.t${JCAP_B}.${gdate}  ./sigf03
$LN $BK_DIR/sigf06.t${JCAP_B}.${gdate}  ./sigf06
$LN $BK_DIR/sigf09.t${JCAP_B}.${gdate}  ./sigf09

#----------------------------------------------------
#7) Copy GSI executable
#----------------------------------------------------
$CP $GSI_EXE  ./gsi.x

##################################################
# 11. source .bashrc for basic environment,
# including module support
##################################################
source /etc/bashrc

##################################################
# 12. Load jovars module 
#   - this provides $TMPDIR_SHORT, $TMPDIR_LONG, and $SCRATCH
##################################################
module load jobvars

##################################################
# 13. Set up for MPI
##################################################
MPI_DIR=/opt/intel/impi/current/bin64
export MPD_CON_EXT="sge_$JOB_ID.$SGE_TASK_ID"``
export MPI_DISPLAY_SETTINGS=YES
export MPI_STATS=YES
export MPI_STATS_FILE=mpi_tmp.out
export MPI_BUFS_PER_PROC=1024
export MPI_BUFS_PER_HOST=1024
export MPI_GROUP_MAX=1024
export OMP_NUM_THREADS=1
export OMP_STACKSIZE=500M
export PROCS=${PBS_NP}
export nthreads=$OMP_NUM_THREADS

##################################################
# 14. Load modules 
##################################################
module load license_intel/BADGER
module load intel/13.1
module load hdf5/1.8.12
module load szip/2.1
module load impi/4.0.3.008
module load netcdf4/4.2

##################################################
# 15. Run GSI
##################################################
cd $WORK_DIR/
echo "GSI starts @ `date` "

eval "$MPI_DIR/mpiexec -machinefile $TMPDIR/machines -n $NSLOTS $WORK_DIR/gsi.x > stdout"

echo "GSI ends @ `date` "

rc=$?
exit

No comments:

Post a Comment