diff --git a/scripts/exglobal_forecast.sh b/scripts/exglobal_forecast.sh index 564c0c798a..9efed80ef4 100755 --- a/scripts/exglobal_forecast.sh +++ b/scripts/exglobal_forecast.sh @@ -1,1422 +1,238 @@ -#!/bin/ksh -################################################################################ -# UNIX Script Documentation Block -# Script name: exglobal_forecast.sh -# Script description: Runs a global FV3GFS model forecast -# -# Author: Fanglin Yang Org: NCEP/EMC Date: 2016-11-15 -# Abstract: This script runs a single GFS forecast with FV3 dynamical core. -# This script is created based on a C-shell script that GFDL wrote -# for the NGGPS Phase-II Dycore Comparison Project. -# -# Script history log: -# 2016-11-15 Fanglin Yang First Version. -# 2017-02-09 Rahul Mahajan Added warm start and restructured the code. -# 2017-03-10 Fanglin Yang Updated for running forecast on Cray. -# 2017-03-24 Fanglin Yang Updated to use NEMS FV3GFS with IPD4 -# 2017-05-24 Rahul Mahajan Updated for cycling with NEMS FV3GFS -# 2017-09-13 Fanglin Yang Updated for using GFDL MP and Write Component -# 2019-03-05 Rahul Mahajan Implemented IAU -# 2019-03-21 Fanglin Yang Add restart capability for running gfs fcst from a break point. -# 2019-12-12 Henrique Alves Added wave model blocks for coupled run -# 2020-01-31 Henrique Alves Added IAU capability for wave component -# 2020-06-02 Fanglin Yang restore restart capability when IAU is turned on. -# -# $Id$ -# -# Attributes: -# Language: Portable Operating System Interface (POSIX) Shell -# Machine: WCOSS-CRAY, Theia +#!/bin/bash ################################################################################ +## UNIX Script Documentation Block +## Script name: exglobal_fcst_nemsfv3gfs.sh +## Script description: Runs a global FV3GFS model forecast +## +## Author: Fanglin Yang Organization: NCEP/EMC Date: 2016-11-15 +## Abstract: This script runs a single GFS forecast with FV3 dynamical core. +## This script is created based on a C-shell script that GFDL wrote +## for the NGGPS Phase-II Dycore Comparison Project. +## +## Script history log: +## 2016-11-15 Fanglin Yang First Version. +## 2017-02-09 Rahul Mahajan Added warm start and restructured the code. +## 2017-03-10 Fanglin Yang Updated for running forecast on Cray. +## 2017-03-24 Fanglin Yang Updated to use NEMS FV3GFS with IPD4 +## 2017-05-24 Rahul Mahajan Updated for cycling with NEMS FV3GFS +## 2017-09-13 Fanglin Yang Updated for using GFDL MP and Write Component +## 2019-04-02 +## +## Attributes: +## Language: Portable Operating System Interface (POSIX) Shell +## Machines: All supported platforms +## +## Usage (Arguments) +## No command line argument +## +## Data input (location, name) +## Warm start files: +## 1. restart file except sfc_data, $gmemdir/RESTART/$PDY.$cyc.*.nc +## 2. sfcanl_data, $memdir/RESTART/$PDY.$cyc.*.nc +## 3. coupler_res, $gmemdir/RESTART/$PDY.$cyc.coupler.res +## 4. increment file, $memdir/${CDUMP}.t${cyc}z.atminc.nc +## OR $DATA/INPUT/fv3_increment.nc +## Cold start files: +## 1. initial condition, $memdir/INPUT/*.nc +## Restart files: +## +## Fix files: +## 1. computing grid, $FIXfv3/$CASE/${CASE}_grid.tile${n}.nc +## 2. orography data, $FIXfv3/$CASE/${CASE}_oro_data.tile${n}.nc +## 3. mosaic data, $FIXfv3/$CASE/${CASE}_mosaic.nc +## 4. Global O3 data, $FIX_AM/${O3FORC} +## 5. Global H2O data, $FIX_AM/${H2OFORC} +## 6. Global solar constant data, $FIX_AM/global_solarconstant_noaa_an.txt +## 7. Global surface emissivity, $FIX_AM/global_sfc_emissivity_idx.txt +## 8. Global CO2 historical data, $FIX_AM/global_co2historicaldata_glob.txt +## 8. Global CO2 monthly data, $FIX_AM/co2monthlycyc.txt +## 10. Additional global CO2 data, $FIX_AM/fix_co2_proj/global_co2historicaldata +## 11. Climatological aerosol global distribution +## $FIX_AM/global_climaeropac_global.txt +## 12. Monthly volcanic forcing $FIX_AM/global_volcanic_aerosols_YYYY-YYYY.txt +## +## Data output (location, name) +## If quilting=true and output grid is gaussian grid: +## 1. atmf data, $memdir/${CDUMP}.t${cyc}z.atmf${FH3}.$OUTPUT_FILE +## 2. sfcf data, $memdir/${CDUMP}.t${cyc}z.sfcf${FH3}.$OUTPUT_FILE +## 3. logf data, $memdir/${CDUMP}.t${cyc}z.logf${FH3}.$OUTPUT_FILE +## If quilting=false and output grid is not gaussian grid: +## 1. NGGPS2D, $memdir/nggps2d.tile${n}.nc +## 2. NGGPS3D, $memdir/nggps3d.tile${n}.nc +## 3. grid spec, $memdir/grid_spec.tile${n}.nc +## 4. atmospheric static tiles, $memdir/atmos_static.tile${n}.nc +## 5. atmospheric 4x daily tiles, $memdir/atmos_4xdaily.tile${n}.nc +## +## Status output +## 0: Normal +## others: Error +## +## Namelist input, in RUNDIR, +## 1. diag_table +## 2. nems.configure +## 3. model_configure +## 4. input.nml +####################### +# Main body starts here +####################### -# Set environment. VERBOSE=${VERBOSE:-"YES"} if [ $VERBOSE = "YES" ] ; then - echo $(date) EXECUTING $0 $* >&2 - set -x -fi - -machine=${machine:-"WCOSS_C"} -machine=$(echo $machine | tr '[a-z]' '[A-Z]') - -# Cycling and forecast hour specific parameters -CDUMPwave="${CDUMP}wave" -CASE=${CASE:-C768} -CDATE=${CDATE:-2017032500} -CDUMP=${CDUMP:-gdas} -FHMIN=${FHMIN:-0} -FHMAX=${FHMAX:-9} -FHOUT=${FHOUT:-3} -FHZER=${FHZER:-6} -FHCYC=${FHCYC:-24} -FHMAX_HF=${FHMAX_HF:-0} -FHOUT_HF=${FHOUT_HF:-1} -NSOUT=${NSOUT:-"-1"} -FDIAG=$FHOUT -if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 ]; then FDIAG=$FHOUT_HF; fi -WRITE_DOPOST=${WRITE_DOPOST:-".false."} -restart_interval=${restart_interval:-0} -rst_invt1=`echo $restart_interval |cut -d " " -f 1` - -PDY=$(echo $CDATE | cut -c1-8) -cyc=$(echo $CDATE | cut -c9-10) - -# Directories. -pwd=$(pwd) -NWPROD=${NWPROD:-${NWROOT:-$pwd}} -HOMEgfs=${HOMEgfs:-$NWPROD} -FIX_DIR=${FIX_DIR:-$HOMEgfs/fix} -FIX_AM=${FIX_AM:-$FIX_DIR/fix_am} -export FIX_AER=${FIX_AER:-$FIX_DIR/fix_aer} -export FIX_LUT=${FIX_LUT:-$FIX_DIR/fix_lut} -FIXfv3=${FIXfv3:-$FIX_DIR/fix_fv3_gmted2010} -DATA=${DATA:-$pwd/fv3tmp$$} # temporary running directory -ROTDIR=${ROTDIR:-$pwd} # rotating archive directory -ICSDIR=${ICSDIR:-$pwd} # cold start initial conditions -DMPDIR=${DMPDIR:-$pwd} # global dumps for seaice, snow and sst analysis - -# Model resolution specific parameters -DELTIM=${DELTIM:-225} -layout_x=${layout_x:-8} -layout_y=${layout_y:-16} -LEVS=${LEVS:-65} - -# Utilities -NCP=${NCP:-"/bin/cp -p"} -NLN=${NLN:-"/bin/ln -sf"} -NMV=${NMV:-"/bin/mv"} -SEND=${SEND:-"YES"} #move final result to rotating directory -ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} -KEEPDATA=${KEEPDATA:-"NO"} - -# Other options -MEMBER=${MEMBER:-"-1"} # -1: control, 0: ensemble mean, >0: ensemble member $MEMBER -ENS_NUM=${ENS_NUM:-1} # Single executable runs multiple members (e.g. GEFS) -PREFIX_ATMINC=${PREFIX_ATMINC:-""} # allow ensemble to use recentered increment - -# IAU options -DOIAU=${DOIAU:-"NO"} -IAUFHRS=${IAUFHRS:-0} -IAU_DELTHRS=${IAU_DELTHRS:-0} -IAU_OFFSET=${IAU_OFFSET:-0} - -# Model specific stuff -FCSTEXECDIR=${FCSTEXECDIR:-$HOMEgfs/sorc/fv3gfs.fd/NEMS/exe} -FCSTEXEC=${FCSTEXEC:-fv3_gfs.x} -PARM_FV3DIAG=${PARM_FV3DIAG:-$HOMEgfs/parm/parm_fv3diag} -PARM_POST=${PARM_POST:-$HOMEgfs/parm/post} - -# Wave coupling parameter defaults to false -cplwav=${cplwav:-.false.} - -# Model config options -APRUN_FV3=${APRUN_FV3:-${APRUN_FCST:-${APRUN:-""}}} -NTHREADS_FV3=${NTHREADS_FV3:-${NTHREADS_FCST:-${nth_fv3:-1}}} -cores_per_node=${cores_per_node:-${npe_node_max:-24}} -ntiles=${ntiles:-6} -NTASKS_FV3=${NTASKS_FV3:-$npe_fv3} - -TYPE=${TYPE:-"nh"} # choices: nh, hydro -MONO=${MONO:-"non-mono"} # choices: mono, non-mono -RUN_CCPP=${RUN_CCPP:-"NO"} - -QUILTING=${QUILTING:-".true."} -OUTPUT_GRID=${OUTPUT_GRID:-"gaussian_grid"} -OUTPUT_FILE=${OUTPUT_FILE:-"nemsio"} -WRITE_NEMSIOFLIP=${WRITE_NEMSIOFLIP:-".true."} -WRITE_FSYNCFLAG=${WRITE_FSYNCFLAG:-".true."} -affix="nemsio" -[[ "$OUTPUT_FILE" = "netcdf" ]] && affix="nc" - -rCDUMP=${rCDUMP:-$CDUMP} - -#------------------------------------------------------------------ -# setup the runtime environment -if [ $machine = "WCOSS_C" ] ; then - HUGEPAGES=${HUGEPAGES:-hugepages4M} - . $MODULESHOME/init/sh 2>/dev/null - module load iobuf craype-$HUGEPAGES 2>/dev/null - export MPICH_GNI_COLL_OPT_OFF=${MPICH_GNI_COLL_OPT_OFF:-MPI_Alltoallv} - export MKL_CBWR=AVX2 - export WRTIOBUF=${WRTIOBUF:-"4M"} - export NC_BLKSZ=${NC_BLKSZ:-"4M"} - export IOBUF_PARAMS="*nemsio:verbose:size=${WRTIOBUF},*:verbose:size=${NC_BLKSZ}" -fi - -#------------------------------------------------------- -if [ ! -d $ROTDIR ]; then mkdir -p $ROTDIR; fi -mkdata=NO -if [ ! -d $DATA ]; then - mkdata=YES - mkdir -p $DATA -fi -cd $DATA || exit 8 -mkdir -p $DATA/INPUT - -if [ $cplwav = ".true." ]; then - if [ $CDUMP = "gdas" ]; then - RSTDIR_WAVE=$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart - else - RSTDIR_WAVE=${RSTDIR_WAVE:-$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart} - fi - if [ ! -d $RSTDIR_WAVE ]; then mkdir -p $RSTDIR_WAVE ; fi - $NLN $RSTDIR_WAVE restart_wave -fi - -if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 ]; then - RSTDIR_ATM=${RSTDIR:-$ROTDIR}/${CDUMP}.${PDY}/${cyc}/atmos/RERUN_RESTART - if [ ! -d $RSTDIR_ATM ]; then mkdir -p $RSTDIR_ATM ; fi - $NLN $RSTDIR_ATM RESTART -else - mkdir -p $DATA/RESTART -fi - -#------------------------------------------------------- -# determine if restart IC exists to continue from a previous forecast -RERUN="NO" -filecount=$(find $RSTDIR_ATM -type f | wc -l) -if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 -a $FHMAX -gt $rst_invt1 -a $filecount -gt 10 ]; then - reverse=$(echo "${restart_interval[@]} " | tac -s ' ') - for xfh in $reverse ; do - yfh=$((xfh-(IAU_OFFSET/2))) - SDATE=$($NDATE +$yfh $CDATE) - PDYS=$(echo $SDATE | cut -c1-8) - cycs=$(echo $SDATE | cut -c9-10) - flag1=$RSTDIR_ATM/${PDYS}.${cycs}0000.coupler.res - flag2=$RSTDIR_ATM/coupler.res - if [ -s $flag1 ]; then - CDATE_RST=$SDATE - [[ $RERUN = "YES" ]] && break - mv $flag1 ${flag1}.old - if [ -s $flag2 ]; then mv $flag2 ${flag2}.old ;fi - RERUN="YES" - [[ $xfh = $rst_invt1 ]] && RERUN="NO" - fi - done -fi - -#------------------------------------------------------- -# member directory -if [ $MEMBER -lt 0 ]; then - prefix=$CDUMP - rprefix=$rCDUMP - memchar="" -else - prefix=enkf$CDUMP - rprefix=enkf$rCDUMP - memchar=mem$(printf %03i $MEMBER) -fi -memdir=$ROTDIR/${prefix}.$PDY/$cyc/atmos/$memchar -if [ ! -d $memdir ]; then mkdir -p $memdir; fi - -GDATE=$($NDATE -$assim_freq $CDATE) -gPDY=$(echo $GDATE | cut -c1-8) -gcyc=$(echo $GDATE | cut -c9-10) -gmemdir=$ROTDIR/${rprefix}.$gPDY/$gcyc/atmos/$memchar -sCDATE=$($NDATE -3 $CDATE) - -if [[ "$DOIAU" = "YES" ]]; then - sCDATE=$($NDATE -3 $CDATE) - sPDY=$(echo $sCDATE | cut -c1-8) - scyc=$(echo $sCDATE | cut -c9-10) - tPDY=$gPDY - tcyc=$gcyc -else - sCDATE=$CDATE - sPDY=$PDY - scyc=$cyc - tPDY=$sPDY - tcyc=$cyc -fi - -#------------------------------------------------------- -# initial conditions -warm_start=${warm_start:-".false."} -read_increment=${read_increment:-".false."} -res_latlon_dynamics="''" - -# Determine if this is a warm start or cold start -if [ -f $gmemdir/RESTART/${sPDY}.${scyc}0000.coupler.res ]; then - export warm_start=".true." -fi - -# turn IAU off for cold start -DOIAU_coldstart=${DOIAU_coldstart:-"NO"} -if [ $DOIAU = "YES" -a $warm_start = ".false." ] || [ $DOIAU_coldstart = "YES" -a $warm_start = ".true." ]; then - export DOIAU="NO" - echo "turning off IAU" - DOIAU_coldstart="YES" - IAU_OFFSET=0 - sCDATE=$CDATE - sPDY=$PDY - scyc=$cyc - tPDY=$sPDY - tcyc=$cyc -fi - -#------------------------------------------------------- -if [ $warm_start = ".true." -o $RERUN = "YES" ]; then -#------------------------------------------------------- -#............................. - if [ $RERUN = "NO" ]; then -#............................. - - # Link all (except sfc_data) restart files from $gmemdir - for file in $(ls $gmemdir/RESTART/${sPDY}.${scyc}0000.*.nc); do - file2=$(echo $(basename $file)) - file2=$(echo $file2 | cut -d. -f3-) # remove the date from file - fsuf=$(echo $file2 | cut -d. -f1) - if [ $fsuf != "sfc_data" ]; then - $NLN $file $DATA/INPUT/$file2 - fi - done - - # Link sfcanl_data restart files from $memdir - for file in $(ls $memdir/RESTART/${sPDY}.${scyc}0000.*.nc); do - file2=$(echo $(basename $file)) - file2=$(echo $file2 | cut -d. -f3-) # remove the date from file - fsufanl=$(echo $file2 | cut -d. -f1) - if [ $fsufanl = "sfcanl_data" ]; then - file2=$(echo $file2 | sed -e "s/sfcanl_data/sfc_data/g") - $NLN $file $DATA/INPUT/$file2 - fi - done - - # Need a coupler.res when doing IAU - if [ $DOIAU = "YES" ]; then - rm -f $DATA/INPUT/coupler.res - cat >> $DATA/INPUT/coupler.res << EOF - 2 (Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4) - ${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 Model start time: year, month, day, hour, minute, second - ${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 Current model time: year, month, day, hour, minute, second -EOF - fi - - # Link increments - if [ $DOIAU = "YES" ]; then - for i in $(echo $IAUFHRS | sed "s/,/ /g" | rev); do - incfhr=$(printf %03i $i) - if [ $incfhr = "006" ]; then - increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atminc.nc - else - increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atmi${incfhr}.nc - fi - if [ ! -f $increment_file ]; then - echo "ERROR: DOIAU = $DOIAU, but missing increment file for fhr $incfhr at $increment_file" - echo "Abort!" - exit 1 - fi - $NLN $increment_file $DATA/INPUT/fv_increment$i.nc - IAU_INC_FILES="'fv_increment$i.nc',$IAU_INC_FILES" - done - read_increment=".false." - res_latlon_dynamics="" - else - increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_INC}atminc.nc - if [ -f $increment_file ]; then - $NLN $increment_file $DATA/INPUT/fv_increment.nc - read_increment=".true." - res_latlon_dynamics="fv_increment.nc" - fi - fi - -#............................. - else ##RERUN - - export warm_start=".true." - PDYT=$(echo $CDATE_RST | cut -c1-8) - cyct=$(echo $CDATE_RST | cut -c9-10) - for file in $(ls $RSTDIR_ATM/${PDYT}.${cyct}0000.*); do - file2=$(echo $(basename $file)) - file2=$(echo $file2 | cut -d. -f3-) - $NLN $file $DATA/INPUT/$file2 - done - - hour_rst=`$NHOUR $CDATE_RST $CDATE` - IAU_FHROT=$((IAU_OFFSET+hour_rst)) - if [ $DOIAU = "YES" ]; then - IAUFHRS=-1 - IAU_DELTHRS=0 - IAU_INC_FILES="''" - fi - - rst_list_rerun="" - xfh=$restart_interval_gfs - while [ $xfh -le $FHMAX_GFS ]; do - rst_list_rerun="$rst_list_rerun $xfh" - xfh=$((xfh+restart_interval_gfs)) - done - restart_interval="$rst_list_rerun" - - fi -#............................. + echo $(date) EXECUTING $0 $* >&2 + set -x +fi + +SCRIPTDIR=$(dirname $(readlink -f "$0") )/../ush +echo "MAIN: environment loaded for $machine platform,Current Script locates in $SCRIPTDIR." + +# include all subroutines. Executions later. +source $SCRIPTDIR/cplvalidate.sh # validation of cpl* +source $SCRIPTDIR/forecast_predet.sh # include functions for variable definition +source $SCRIPTDIR/forecast_det.sh # include functions for run type determination +source $SCRIPTDIR/forecast_postdet.sh # include functions for variables after run type determination +source $SCRIPTDIR/nems_configure.sh # include functions for nems_configure processing +source $SCRIPTDIR/parsing_model_configure_FV3.sh +source $SCRIPTDIR/parsing_model_configure_DATM.sh + +# Compset string. For nems.configure.* template selection. Default ATM only +confignamevarfornems=${confignamevarfornems:-'atm'} + +# Coupling control switches, for coupling purpose, off by default +cpl=${cpl:-.false.} +cplflx=${cplflx:-.false.} # default off,import from outside source +cplwav=${cplwav:-.false.} # ? how to control 1-way/2-way? +cplchem=${cplchem:-.false.} # Chemistry model +cplgocart=${cplgocart:-.false.} # Chemistry model +cplice=${cplice:-.false.} # ICE model + +OCNTIM=${OCNTIM:-3600} +DELTIM=${DELTIM:-450} +ICETIM=${DELTIM} + +CPL_SLOW=${CPL_SLOW:-$OCNTIM} +CPL_FAST=${CPL_FAST:-$ICETIM} + +echo "MAIN: $confignamevarfornems selected" +echo "MAIN: Forecast script started for $confignamevarfornems on $machine" + +echo "MAIN: Validating $confignamevarfornems with cpl switches" +cplvalidate +echo "MAIN: $confignamevarfornems validated, continue" +# Validate the consistency between $confignamevarfornems and $CPL switches + +echo "MAIN: Loading variables before determination of run type" + +common_predet + +echo $RUN +case $RUN in + 'data') DATM_predet;; + 'gfs') FV3_GFS_predet;; + 'gdas') FV3_GFS_predet;; + 'gefs') FV3_GEFS_predet;; +esac +[[ $cplflx = .true. ]] && MOM6_predet +#[[ $cplwav = .true. ]] && WW3_predet #no WW3_predet at this time +[[ $cplice = .true. ]] && CICE_predet +[[ $cplchem = .true. ]] && GSD_predet + +case $RUN in + 'gfs') FV3_GFS_det;; + 'gdas') FV3_GFS_det;; + 'gefs') FV3_GEFS_det;; +esac #no run type determination for data atmosphere +[[ $cplflx = .true. ]] && MOM6_det +[[ $cplwav = .true. ]] && WW3_det +[[ $cplice = .true. ]] && CICE_det +[[ $cplchem = .true. ]] && GSD_det + +echo "MAIN: RUN Type Determined" + +echo "MAIN: Post-determination set up of run type" +echo $RUN +case $RUN in + 'data') DATM_postdet;; + 'gfs') FV3_GFS_postdet;; + 'gdas') FV3_GFS_postdet;; + 'gefs') FV3_GEFS_postdet;; +esac #no post determination set up for data atmosphere +[[ $cplflx = .true. ]] && MOM6_postdet +[[ $cplwav = .true. ]] && WW3_postdet +[[ $cplice = .true. ]] && CICE_postdet +[[ $cplchem = .true. ]] && GSD_postdet +echo "MAIN: Post-determination set up of run type finished" + +echo "MAIN: Writing name lists and model configuration" +case $RUN in + 'data') DATM_nml;; + 'gfs') FV3_GFS_nml;; + 'gdas') FV3_GFS_nml;; + 'gefs') FV3_GEFS_nml;; +esac #no namelist for data atmosphere +[[ $cplflx = .true. ]] && MOM6_nml +[[ $cplwav = .true. ]] && WW3_nml +[[ $cplice = .true. ]] && CICE_nml +[[ $cplchem = .true. ]] && GSD_nml +[[ $cplgocart = .true. ]] && GOCART_rc + +case $RUN in + 'data') DATM_model_configure;; + 'gfs') FV3_model_configure;; + 'gdas') FV3_model_configure;; + 'gefs') FV3_model_configure;; +esac +echo "MAIN: Name lists and model configuration written" + +echo "MAIN: Writing NEMS Configure file" +writing_nems_configure +echo "MAIN: NEMS configured" -else ## cold start - - for file in $(ls $memdir/INPUT/*.nc); do - file2=$(echo $(basename $file)) - fsuf=$(echo $file2 | cut -c1-3) - if [ $fsuf = "gfs" -o $fsuf = "sfc" ]; then - $NLN $file $DATA/INPUT/$file2 - fi - done - -#------------------------------------------------------- -fi -#------------------------------------------------------- - -nfiles=$(ls -1 $DATA/INPUT/* | wc -l) -if [ $nfiles -le 0 ]; then - echo "Initial conditions must exist in $DATA/INPUT, ABORT!" - msg="Initial conditions must exist in $DATA/INPUT, ABORT!" - postmsg "$jlogfile" "$msg" - exit 1 -fi - -# If doing IAU, change forecast hours -if [[ "$DOIAU" = "YES" ]]; then - FHMAX=$((FHMAX+6)) - if [ $FHMAX_HF -gt 0 ]; then - FHMAX_HF=$((FHMAX_HF+6)) - fi -fi - -#-------------------------------------------------------------------------- -# Grid and orography data -for n in $(seq 1 $ntiles); do - $NLN $FIXfv3/$CASE/${CASE}_grid.tile${n}.nc $DATA/INPUT/${CASE}_grid.tile${n}.nc - $NLN $FIXfv3/$CASE/${CASE}_oro_data.tile${n}.nc $DATA/INPUT/oro_data.tile${n}.nc -done -$NLN $FIXfv3/$CASE/${CASE}_mosaic.nc $DATA/INPUT/grid_spec.nc - -# GFS standard input data -IAER=${IAER:-111} -ICO2=${ICO2:-2} - -if [ ${new_o3forc:-YES} = YES ]; then - O3FORC=ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77 -else - O3FORC=global_o3prdlos.f77 -fi -H2OFORC=${H2OFORC:-"global_h2o_pltc.f77"} -$NLN $FIX_AM/${O3FORC} $DATA/global_o3prdlos.f77 -$NLN $FIX_AM/${H2OFORC} $DATA/global_h2oprdlos.f77 -$NLN $FIX_AM/global_solarconstant_noaa_an.txt $DATA/solarconstant_noaa_an.txt -$NLN $FIX_AM/global_sfc_emissivity_idx.txt $DATA/sfc_emissivity_idx.txt - -## merra2 aerosol climo -for n in 01 02 03 04 05 06 07 08 09 10 11 12; do -$NLN $FIX_AER/merra2.aerclim.2003-2014.m${n}.nc $DATA/aeroclim.m${n}.nc -done -$NLN $FIX_LUT/optics_BC.v1_3.dat $DATA/optics_BC.dat -$NLN $FIX_LUT/optics_OC.v1_3.dat $DATA/optics_OC.dat -$NLN $FIX_LUT/optics_DU.v15_3.dat $DATA/optics_DU.dat -$NLN $FIX_LUT/optics_SS.v3_3.dat $DATA/optics_SS.dat -$NLN $FIX_LUT/optics_SU.v1_3.dat $DATA/optics_SU.dat - -$NLN $FIX_AM/global_co2historicaldata_glob.txt $DATA/co2historicaldata_glob.txt -$NLN $FIX_AM/co2monthlycyc.txt $DATA/co2monthlycyc.txt -if [ $ICO2 -gt 0 ]; then - for file in $(ls $FIX_AM/fix_co2_proj/global_co2historicaldata*) ; do - $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") - done -fi - -$NLN $FIX_AM/global_climaeropac_global.txt $DATA/aerosol.dat -if [ $IAER -gt 0 ] ; then - for file in $(ls $FIX_AM/global_volcanic_aerosols*) ; do - $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") - done -fi - -#-------------wavewave---------------------- -if [ $cplwav = ".true." ]; then - - for file in $(ls $COMINwave/rundata/rmp_src_to_dst_conserv_*) ; do - $NLN $file $DATA/ - done - $NLN $COMINwave/rundata/ww3_multi.${CDUMPwave}${WAV_MEMBER}.${cycle}.inp $DATA/ww3_multi.inp - - array=($WAVECUR_FID $WAVEICE_FID $WAVEWND_FID $waveuoutpGRD $waveGRD $waveesmfGRD $wavesbsGRD $wavepostGRD $waveinterpGRD) - grdALL=`printf "%s\n" "${array[@]}" | sort -u | tr '\n' ' '` - - for wavGRD in ${grdALL}; do - $NLN $COMINwave/rundata/${CDUMPwave}.mod_def.$wavGRD $DATA/mod_def.$wavGRD - done - - export WAVHCYC=${WAVHCYC:-6} - export WRDATE=`$NDATE -${WAVHCYC} $CDATE` - export WRPDY=`echo $WRDATE | cut -c1-8` - export WRcyc=`echo $WRDATE | cut -c9-10` - export WRDIR=${ROTDIR}/${CDUMPRSTwave}.${WRPDY}/${WRcyc}/wave/restart - export datwave=$COMOUTwave/rundata - export wavprfx=${CDUMPwave}${WAV_MEMBER} - - for wavGRD in $waveGRD ; do - if [ $RERUN = "NO" ]; then - if [ ! -f ${WRDIR}/${sPDY}.${scyc}0000.restart.${wavGRD} ]; then - echo "WARNING: NON-FATAL ERROR wave IC is missing, will start from rest" - fi - $NLN ${WRDIR}/${sPDY}.${scyc}0000.restart.${wavGRD} $DATA/restart.${wavGRD} - else - if [ ! -f ${RSTDIR_WAVE}/${PDYT}.${cyct}0000.restart.${wavGRD} ]; then - echo "WARNING: NON-FATAL ERROR wave IC is missing, will start from rest" - fi - $NLN ${RSTDIR_WAVE}/${PDYT}.${cyct}0000.restart.${wavGRD} $DATA/restart.${wavGRD} - fi - eval $NLN $datwave/${wavprfx}.log.${wavGRD}.${PDY}${cyc} log.${wavGRD} - done - - if [ "$WW3ICEINP" = "YES" ]; then - wavicefile=$COMINwave/rundata/${CDUMPwave}.${WAVEICE_FID}.${cycle}.ice - if [ ! -f $wavicefile ]; then - echo "ERROR: WW3ICEINP = ${WW3ICEINP}, but missing ice file" - echo "Abort!" - exit 1 - fi - $NLN ${wavicefile} $DATA/ice.${WAVEICE_FID} - fi - - if [ "$WW3CURINP" = "YES" ]; then - wavcurfile=$COMINwave/rundata/${CDUMPwave}.${WAVECUR_FID}.${cycle}.cur - if [ ! -f $wavcurfile ]; then - echo "ERROR: WW3CURINP = ${WW3CURINP}, but missing current file" - echo "Abort!" - exit 1 - fi - $NLN $wavcurfile $DATA/current.${WAVECUR_FID} - fi - - # Link output files - cd $DATA - eval $NLN $datwave/${wavprfx}.log.mww3.${PDY}${cyc} log.mww3 - - # Loop for gridded output (uses FHINC) - fhr=$FHMIN_WAV - while [ $fhr -le $FHMAX_WAV ]; do - YMDH=`$NDATE $fhr $CDATE` - YMD=$(echo $YMDH | cut -c1-8) - HMS="$(echo $YMDH | cut -c9-10)0000" - for wavGRD in ${waveGRD} ; do - eval $NLN $datwave/${wavprfx}.out_grd.${wavGRD}.${YMD}.${HMS} ${YMD}.${HMS}.out_grd.${wavGRD} - done - FHINC=$FHOUT_WAV - if [ $FHMAX_HF_WAV -gt 0 -a $FHOUT_HF_WAV -gt 0 -a $fhr -lt $FHMAX_HF_WAV ]; then - FHINC=$FHOUT_HF_WAV - fi - fhr=$((fhr+FHINC)) - done - - # Loop for point output (uses DTPNT) - fhr=$FHMIN_WAV - while [ $fhr -le $FHMAX_WAV ]; do - YMDH=`$NDATE $fhr $CDATE` - YMD=$(echo $YMDH | cut -c1-8) - HMS="$(echo $YMDH | cut -c9-10)0000" - eval $NLN $datwave/${wavprfx}.out_pnt.${waveuoutpGRD}.${YMD}.${HMS} ${YMD}.${HMS}.out_pnt.${waveuoutpGRD} - FHINC=$FHINCP_WAV - fhr=$((fhr+FHINC)) - done - -fi #cplwav=true -#-------------wavewave---------------------- - -# inline post fix files -if [ $WRITE_DOPOST = ".true." ]; then - $NLN $PARM_POST/post_tag_gfs${LEVS} $DATA/itag - $NLN $PARM_POST/postxconfig-NT-GFS-TWO.txt $DATA/postxconfig-NT.txt - $NLN $PARM_POST/postxconfig-NT-GFS-F00-TWO.txt $DATA/postxconfig-NT_FH00.txt - $NLN $PARM_POST/params_grib2_tbl_new $DATA/params_grib2_tbl_new -fi #------------------------------------------------------------------ +# run the executable -# changeable parameters -# dycore definitions -res=$(echo $CASE |cut -c2-5) -resp=$((res+1)) -npx=$resp -npy=$resp -npz=$((LEVS-1)) -io_layout=${io_layout:-"1,1"} -#ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) - -# spectral truncation and regular grid resolution based on FV3 resolution -JCAP_CASE=$((2*res-2)) -LONB_CASE=$((4*res)) -LATB_CASE=$((2*res)) - -JCAP=${JCAP:-$JCAP_CASE} -LONB=${LONB:-$LONB_CASE} -LATB=${LATB:-$LATB_CASE} - -LONB_IMO=${LONB_IMO:-$LONB_CASE} -LATB_JMO=${LATB_JMO:-$LATB_CASE} - -# Fix files -FNGLAC=${FNGLAC:-"$FIX_AM/global_glacier.2x2.grb"} -FNMXIC=${FNMXIC:-"$FIX_AM/global_maxice.2x2.grb"} -FNTSFC=${FNTSFC:-"$FIX_AM/RTGSST.1982.2012.monthly.clim.grb"} -FNSNOC=${FNSNOC:-"$FIX_AM/global_snoclim.1.875.grb"} -FNZORC=${FNZORC:-"igbp"} -FNALBC2=${FNALBC2:-"$FIX_AM/global_albedo4.1x1.grb"} -FNAISC=${FNAISC:-"$FIX_AM/CFSR.SEAICE.1982.2012.monthly.clim.grb"} -FNTG3C=${FNTG3C:-"$FIX_AM/global_tg3clim.2.6x1.5.grb"} -FNVEGC=${FNVEGC:-"$FIX_AM/global_vegfrac.0.144.decpercent.grb"} -FNMSKH=${FNMSKH:-"$FIX_AM/global_slmask.t1534.3072.1536.grb"} -FNVMNC=${FNVMNC:-"$FIX_AM/global_shdmin.0.144x0.144.grb"} -FNVMXC=${FNVMXC:-"$FIX_AM/global_shdmax.0.144x0.144.grb"} -FNSLPC=${FNSLPC:-"$FIX_AM/global_slope.1x1.grb"} -FNALBC=${FNALBC:-"$FIX_AM/global_snowfree_albedo.bosu.t${JCAP}.${LONB}.${LATB}.rg.grb"} -FNVETC=${FNVETC:-"$FIX_AM/global_vegtype.igbp.t${JCAP}.${LONB}.${LATB}.rg.grb"} -FNSOTC=${FNSOTC:-"$FIX_AM/global_soiltype.statsgo.t${JCAP}.${LONB}.${LATB}.rg.grb"} -FNABSC=${FNABSC:-"$FIX_AM/global_mxsnoalb.uariz.t${JCAP}.${LONB}.${LATB}.rg.grb"} -FNSMCC=${FNSMCC:-"$FIX_AM/global_soilmgldas.statsgo.t${JCAP}.${LONB}.${LATB}.grb"} - -# If the appropriate resolution fix file is not present, use the highest resolution available (T1534) -[[ ! -f $FNALBC ]] && FNALBC="$FIX_AM/global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb" -[[ ! -f $FNVETC ]] && FNVETC="$FIX_AM/global_vegtype.igbp.t1534.3072.1536.rg.grb" -[[ ! -f $FNSOTC ]] && FNSOTC="$FIX_AM/global_soiltype.statsgo.t1534.3072.1536.rg.grb" -[[ ! -f $FNABSC ]] && FNABSC="$FIX_AM/global_mxsnoalb.uariz.t1534.3072.1536.rg.grb" -[[ ! -f $FNSMCC ]] && FNSMCC="$FIX_AM/global_soilmgldas.statsgo.t1534.3072.1536.grb" - -# NSST Options -# nstf_name contains the NSST related parameters -# nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled -# nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, -# nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON -# nstf_name(4) : ZSEA1 (in mm) : 0 -# nstf_name(5) : ZSEA2 (in mm) : 0 -# nst_anl : .true. or .false., NSST analysis over lake -NST_MODEL=${NST_MODEL:-0} -NST_SPINUP=${NST_SPINUP:-0} -NST_RESV=${NST_RESV-0} -ZSEA1=${ZSEA1:-0} -ZSEA2=${ZSEA2:-0} -nstf_name=${nstf_name:-"$NST_MODEL,$NST_SPINUP,$NST_RESV,$ZSEA1,$ZSEA2"} -nst_anl=${nst_anl:-".false."} - - -# blocking factor used for threading and general physics performance -#nyblocks=`expr \( $npy - 1 \) \/ $layout_y ` -#nxblocks=`expr \( $npx - 1 \) \/ $layout_x \/ 32` -#if [ $nxblocks -le 0 ]; then nxblocks=1 ; fi -blocksize=${blocksize:-32} - -# the pre-conditioning of the solution -# =0 implies no pre-conditioning -# >0 means new adiabatic pre-conditioning -# <0 means older adiabatic pre-conditioning -na_init=${na_init:-1} -[[ $warm_start = ".true." ]] && na_init=0 - -# variables for controlling initialization of NCEP/NGGPS ICs -filtered_terrain=${filtered_terrain:-".true."} -gfs_dwinds=${gfs_dwinds:-".true."} - -# various debug options -no_dycore=${no_dycore:-".false."} -dycore_only=${adiabatic:-".false."} -chksum_debug=${chksum_debug:-".false."} -print_freq=${print_freq:-6} - -if [ ${TYPE} = "nh" ]; then # non-hydrostatic options - - hydrostatic=".false." - phys_hydrostatic=".false." # enable heating in hydrostatic balance in non-hydrostatic simulation - use_hydro_pressure=".false." # use hydrostatic pressure for physics - if [ $warm_start = ".true." ]; then - make_nh=".false." # restarts contain non-hydrostatic state - else - make_nh=".true." # re-initialize non-hydrostatic state - fi - -else # hydrostatic options - - hydrostatic=".true." - phys_hydrostatic=".false." # ignored when hydrostatic = T - use_hydro_pressure=".false." # ignored when hydrostatic = T - make_nh=".false." # running in hydrostatic mode - -fi - -# Conserve total energy as heat globally -consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics - -# time step parameters in FV3 -k_split=${k_split:-2} -n_split=${n_split:-6} - -if [ $(echo $MONO | cut -c-4) = "mono" ]; then # monotonic options - - d_con=${d_con_mono:-"0."} - do_vort_damp=".false." - if [ ${TYPE} = "nh" ]; then # non-hydrostatic - hord_mt=${hord_mt_nh_mono:-"10"} - hord_xx=${hord_xx_nh_mono:-"10"} - else # hydrostatic - hord_mt=${hord_mt_hydro_mono:-"10"} - hord_xx=${hord_xx_hydro_mono:-"10"} - fi - -else # non-monotonic options - - d_con=${d_con_nonmono:-"1."} - do_vort_damp=".true." - if [ ${TYPE} = "nh" ]; then # non-hydrostatic - hord_mt=${hord_mt_nh_nonmono:-"5"} - hord_xx=${hord_xx_nh_nonmono:-"5"} - else # hydrostatic - hord_mt=${hord_mt_hydro_nonmono:-"10"} - hord_xx=${hord_xx_hydro_nonmono:-"10"} - fi - -fi - -if [ $(echo $MONO | cut -c-4) != "mono" -a $TYPE = "nh" ]; then - vtdm4=${vtdm4_nh_nonmono:-"0.06"} -else - vtdm4=${vtdm4:-"0.05"} -fi - -if [ $warm_start = ".true." ]; then # warm start from restart file - - nggps_ic=".false." - ncep_ic=".false." - external_ic=".false." - mountain=".true." - if [ $read_increment = ".true." ]; then # add increment on the fly to the restarts - res_latlon_dynamics="fv_increment.nc" - else - res_latlon_dynamics='""' - fi - -else # CHGRES'd GFS analyses - - nggps_ic=${nggps_ic:-".true."} - ncep_ic=${ncep_ic:-".false."} - external_ic=".true." - mountain=".false." - read_increment=".false." - res_latlon_dynamics='""' - +if [ $esmf_profile ]; then + export ESMF_RUNTIME_PROFILE=ON + export ESMF_RUNTIME_PROFILE_OUTPUT=SUMMARY fi -# Stochastic Physics Options -if [ ${SET_STP_SEED:-"YES"} = "YES" ]; then - ISEED_SKEB=$((CDATE*1000 + MEMBER*10 + 1)) - ISEED_SHUM=$((CDATE*1000 + MEMBER*10 + 2)) - ISEED_SPPT=$((CDATE*1000 + MEMBER*10 + 3)) +if [ $machine != 'sandbox' ]; then + $NCP $FCSTEXECDIR/$FCSTEXEC $DATA/. + export OMP_NUM_THREADS=$NTHREADS_FV3 + $APRUN_FV3 $DATA/$FCSTEXEC 1>&1 2>&2 + export ERR=$? + export err=$ERR + $ERRSCRIPT || exit $err else - ISEED=${ISEED:-0} -fi -DO_SKEB=${DO_SKEB:-"NO"} -DO_SPPT=${DO_SPPT:-"NO"} -DO_SHUM=${DO_SHUM:-"NO"} - -if [ $DO_SKEB = "YES" ]; then - do_skeb=".true." -fi -if [ $DO_SHUM = "YES" ]; then - do_shum=".true." -fi -if [ $DO_SPPT = "YES" ]; then - do_sppt=".true." -fi - -# copy over the tables -DIAG_TABLE=${DIAG_TABLE:-$PARM_FV3DIAG/diag_table} -DATA_TABLE=${DATA_TABLE:-$PARM_FV3DIAG/data_table} -FIELD_TABLE=${FIELD_TABLE:-$PARM_FV3DIAG/field_table} - -# build the diag_table with the experiment name and date stamp -if [ $DOIAU = "YES" ]; then -cat > diag_table << EOF -FV3 Forecast -${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 -EOF -cat $DIAG_TABLE >> diag_table + echo "MAIN: mpirun launch here" +fi + +if [ $machine != 'sandbox' ]; then + case $RUN in + 'data') data_out_Data_ATM;; + 'gfs') data_out_GFS;; + 'gdas') data_out_GFS;; + 'gefs') data_out_GEFS;; + esac + [[ $cplflx = .true. ]] && MOM6_out + [[ $cplwav = .true. ]] && WW3_out + [[ $cplice = .true. ]] && CICE_out + [[ $cplchem = .true. ]] && GSD_out + [[ $esmf_profile = .true. ]] && CPL_out else -cat > diag_table << EOF -FV3 Forecast -${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 -EOF -cat $DIAG_TABLE >> diag_table -fi - -$NCP $DATA_TABLE data_table -$NCP $FIELD_TABLE field_table - -# copy CCN_ACTIVATE.BIN for Thompson microphysics -if [ $RUN_CCPP = "YES" ]; then -if [ "$CCPP_SUITE" = 'FV3_GSD_v0' -o "$CCPP_SUITE" = 'FV3_GSD_noah' ]; then - $NLN $FIX_AM/CCN_ACTIVATE.BIN CCN_ACTIVATE.BIN - $NLN $FIX_AM/freezeH2O.dat freezeH2O.dat - $NLN $FIX_AM/qr_acr_qg.dat qr_acr_qg.dat - $NLN $FIX_AM/qr_acr_qs.dat qr_acr_qs.dat -fi + echo "MAIN: Running on sandbox mode, no output linking" fi +echo "MAIN: Output copied to COMROT" #------------------------------------------------------------------ -rm -f nems.configure - -if [ $cplwav = ".true." ]; then -#### ww3 version of nems.configure - -# Switch on cpl flag - cpl=.true. - -NTASKS_FV3m1=$((NTASKS_FV3-1)) -atm_petlist_bounds=" 0 $((NTASKS_FV3-1))" -wav_petlist_bounds=" $((NTASKS_FV3)) $((NTASKS_FV3m1+npe_wav))" -### atm_petlist_bounds=" 0 1511" -### atm_petlist_bounds=$atm_petlist_bounds -### wav_petlist_bounds="1512 1691" -### wav_petlist_bounds=$wav_petlist_bounds - coupling_interval_sec=${coupling_interval_sec:-1800} - rm -f nems.configure -cat > nems.configure < WAV :SrcTermProcessing=0:TermOrder=SrcSeq - WAV - @ -:: -EOF -else -#### fv3 standalone version of nems.configure -cat > nems.configure < model_configure < input.nml <> input.nml << EOF - iovr = ${iovr:-"3"} - ltaerosol = ${ltaerosol:-".false."} - lradar = ${lradar:-".false."} - ttendlim = ${ttendlim:-"0.005"} - oz_phys = ${oz_phys:-".false."} - oz_phys_2015 = ${oz_phys_2015:-".true."} - lsoil_lsm = ${lsoil_lsm:-"4"} - do_mynnedmf = ${do_mynnedmf:-".false."} - do_mynnsfclay = ${do_mynnsfclay:-".false."} - icloud_bl = ${icloud_bl:-"1"} - bl_mynn_edmf = ${bl_mynn_edmf:-"1"} - bl_mynn_tkeadvect = ${bl_mynn_tkeadvect:-".true."} - bl_mynn_edmf_mom = ${bl_mynn_edmf_mom:-"1"} - min_lakeice = ${min_lakeice:-"0.15"} - min_seaice = ${min_seaice:-"0.15"} -EOF -else - cat >> input.nml << EOF - iovr_lw = ${iovr_lw:-"3"} - iovr_sw = ${iovr_sw:-"3"} -EOF -fi - -# Add namelist for IAU -if [ $DOIAU = "YES" ]; then - cat >> input.nml << EOF - iaufhrs = ${IAUFHRS} - iau_delthrs = ${IAU_DELTHRS} - iau_inc_files= ${IAU_INC_FILES} - iau_drymassfixer = .false. -EOF -fi - -cat >> input.nml <> input.nml - -cat >> input.nml <> input.nml -if [ $MEMBER -gt 0 ]; then - - cat >> input.nml << EOF -&nam_stochy -EOF - - if [ $DO_SKEB = "YES" ]; then - cat >> input.nml << EOF - skeb = $SKEB - iseed_skeb = ${ISEED_SKEB:-$ISEED} - skeb_tau = ${SKEB_TAU:-"-999."} - skeb_lscale = ${SKEB_LSCALE:-"-999."} - skebnorm = ${SKEBNORM:-"1"} - skeb_npass = ${SKEB_nPASS:-"30"} - skeb_vdof = ${SKEB_VDOF:-"5"} -EOF - fi - - if [ $DO_SHUM = "YES" ]; then - cat >> input.nml << EOF - shum = $SHUM - iseed_shum = ${ISEED_SHUM:-$ISEED} - shum_tau = ${SHUM_TAU:-"-999."} - shum_lscale = ${SHUM_LSCALE:-"-999."} -EOF - fi - - if [ $DO_SPPT = "YES" ]; then - cat >> input.nml << EOF - sppt = $SPPT - iseed_sppt = ${ISEED_SPPT:-$ISEED} - sppt_tau = ${SPPT_TAU:-"-999."} - sppt_lscale = ${SPPT_LSCALE:-"-999."} - sppt_logit = ${SPPT_LOGIT:-".true."} - sppt_sfclimit = ${SPPT_SFCLIMIT:-".true."} - use_zmtnblck = ${use_zmtnblck:-".true."} -EOF - fi - - cat >> input.nml << EOF - $nam_stochy_nml -/ -EOF - - - cat >> input.nml << EOF -&nam_sfcperts - $nam_sfcperts_nml -/ -EOF - -else - - cat >> input.nml << EOF -&nam_stochy -/ -&nam_sfcperts -/ -EOF - +if [ $VERBOSE = "YES" ] ; then + echo $(date) EXITING $0 with return code $err >&2 fi - -#------------------------------------------------------------------ -# make symbolic links to write forecast files directly in memdir -cd $DATA -if [ $QUILTING = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]; then - fhr=$FHMIN - while [ $fhr -le $FHMAX ]; do - FH3=$(printf %03i $fhr) - FH2=$(printf %02i $fhr) - atmi=atmf${FH3}.$affix - sfci=sfcf${FH3}.$affix - logi=logf${FH3} - pgbi=GFSPRS.GrbF${FH2} - flxi=GFSFLX.GrbF${FH2} - atmo=$memdir/${CDUMP}.t${cyc}z.atmf${FH3}.$affix - sfco=$memdir/${CDUMP}.t${cyc}z.sfcf${FH3}.$affix - logo=$memdir/${CDUMP}.t${cyc}z.logf${FH3}.txt - pgbo=$memdir/${CDUMP}.t${cyc}z.master.grb2f${FH3} - flxo=$memdir/${CDUMP}.t${cyc}z.sfluxgrbf${FH3}.grib2 - eval $NLN $atmo $atmi - eval $NLN $sfco $sfci - eval $NLN $logo $logi - if [ $WRITE_DOPOST = ".true." ]; then - eval $NLN $pgbo $pgbi - eval $NLN $flxo $flxi - fi - FHINC=$FHOUT - if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 -a $fhr -lt $FHMAX_HF ]; then - FHINC=$FHOUT_HF - fi - fhr=$((fhr+FHINC)) - done +if [ $err != 0 ]; then + echo "MAIN: $confignamevarfornems Forecast failed" + exit $err else - for n in $(seq 1 $ntiles); do - eval $NLN nggps2d.tile${n}.nc $memdir/nggps2d.tile${n}.nc - eval $NLN nggps3d.tile${n}.nc $memdir/nggps3d.tile${n}.nc - eval $NLN grid_spec.tile${n}.nc $memdir/grid_spec.tile${n}.nc - eval $NLN atmos_static.tile${n}.nc $memdir/atmos_static.tile${n}.nc - eval $NLN atmos_4xdaily.tile${n}.nc $memdir/atmos_4xdaily.tile${n}.nc - done -fi - -# Copy namelist file -$NCP input.nml $memdir - -#------------------------------------------------------------------ -# run the executable - -$NCP $FCSTEXECDIR/$FCSTEXEC $DATA/. -export OMP_NUM_THREADS=$NTHREADS_FV3 -$APRUN_FV3 $DATA/$FCSTEXEC 1>&1 2>&2 -export ERR=$? -export err=$ERR -$ERRSCRIPT || exit $err - -#------------------------------------------------------------------ -if [ $SEND = "YES" ]; then - - # Copy gdas and enkf member restart files - if [ $CDUMP = "gdas" -a $rst_invt1 -gt 0 ]; then - cd $DATA/RESTART - mkdir -p $memdir/RESTART - for rst_int in $restart_interval ; do - if [ $rst_int -ge 0 ]; then - RDATE=$($NDATE +$rst_int $CDATE) - rPDY=$(echo $RDATE | cut -c1-8) - rcyc=$(echo $RDATE | cut -c9-10) - for file in $(ls ${rPDY}.${rcyc}0000.*) ; do - $NCP $file $memdir/RESTART/$file - done - fi - done - if [ $DOIAU = "YES" ] || [ $DOIAU_coldstart = "YES" ]; then - # if IAU is on, save restart at start of IAU window - rst_iau=$(( ${IAU_OFFSET} - (${IAU_DELTHRS}/2) )) - if [ $rst_iau -lt 0 ];then - rst_iau=$(( (${IAU_DELTHRS}) - ${IAU_OFFSET} )) - fi - RDATE=$($NDATE +$rst_iau $CDATE) - rPDY=$(echo $RDATE | cut -c1-8) - rcyc=$(echo $RDATE | cut -c9-10) - for file in $(ls ${rPDY}.${rcyc}0000.*) ; do - $NCP $file $memdir/RESTART/$file - done - fi - fi -fi - -#------------------------------------------------------------------ -# Clean up before leaving -if [ $mkdata = "YES" ]; then rm -rf $DATA; fi - -#------------------------------------------------------------------ -set +x -if [ $VERBOSE = "YES" ] ; then - echo $(date) EXITING $0 with return code $err >&2 + echo "MAIN: $confignamevarfornems Forecast completed at normal status" + if [ $KEEPDATA != "YES" ]; then rm -rf $DATA; fi + exit 0 fi -exit 0 diff --git a/scripts/exglobal_forecast.sh_bk b/scripts/exglobal_forecast.sh_bk new file mode 100755 index 0000000000..564c0c798a --- /dev/null +++ b/scripts/exglobal_forecast.sh_bk @@ -0,0 +1,1422 @@ +#!/bin/ksh +################################################################################ +# UNIX Script Documentation Block +# Script name: exglobal_forecast.sh +# Script description: Runs a global FV3GFS model forecast +# +# Author: Fanglin Yang Org: NCEP/EMC Date: 2016-11-15 +# Abstract: This script runs a single GFS forecast with FV3 dynamical core. +# This script is created based on a C-shell script that GFDL wrote +# for the NGGPS Phase-II Dycore Comparison Project. +# +# Script history log: +# 2016-11-15 Fanglin Yang First Version. +# 2017-02-09 Rahul Mahajan Added warm start and restructured the code. +# 2017-03-10 Fanglin Yang Updated for running forecast on Cray. +# 2017-03-24 Fanglin Yang Updated to use NEMS FV3GFS with IPD4 +# 2017-05-24 Rahul Mahajan Updated for cycling with NEMS FV3GFS +# 2017-09-13 Fanglin Yang Updated for using GFDL MP and Write Component +# 2019-03-05 Rahul Mahajan Implemented IAU +# 2019-03-21 Fanglin Yang Add restart capability for running gfs fcst from a break point. +# 2019-12-12 Henrique Alves Added wave model blocks for coupled run +# 2020-01-31 Henrique Alves Added IAU capability for wave component +# 2020-06-02 Fanglin Yang restore restart capability when IAU is turned on. +# +# $Id$ +# +# Attributes: +# Language: Portable Operating System Interface (POSIX) Shell +# Machine: WCOSS-CRAY, Theia +################################################################################ + +# Set environment. +VERBOSE=${VERBOSE:-"YES"} +if [ $VERBOSE = "YES" ] ; then + echo $(date) EXECUTING $0 $* >&2 + set -x +fi + +machine=${machine:-"WCOSS_C"} +machine=$(echo $machine | tr '[a-z]' '[A-Z]') + +# Cycling and forecast hour specific parameters +CDUMPwave="${CDUMP}wave" +CASE=${CASE:-C768} +CDATE=${CDATE:-2017032500} +CDUMP=${CDUMP:-gdas} +FHMIN=${FHMIN:-0} +FHMAX=${FHMAX:-9} +FHOUT=${FHOUT:-3} +FHZER=${FHZER:-6} +FHCYC=${FHCYC:-24} +FHMAX_HF=${FHMAX_HF:-0} +FHOUT_HF=${FHOUT_HF:-1} +NSOUT=${NSOUT:-"-1"} +FDIAG=$FHOUT +if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 ]; then FDIAG=$FHOUT_HF; fi +WRITE_DOPOST=${WRITE_DOPOST:-".false."} +restart_interval=${restart_interval:-0} +rst_invt1=`echo $restart_interval |cut -d " " -f 1` + +PDY=$(echo $CDATE | cut -c1-8) +cyc=$(echo $CDATE | cut -c9-10) + +# Directories. +pwd=$(pwd) +NWPROD=${NWPROD:-${NWROOT:-$pwd}} +HOMEgfs=${HOMEgfs:-$NWPROD} +FIX_DIR=${FIX_DIR:-$HOMEgfs/fix} +FIX_AM=${FIX_AM:-$FIX_DIR/fix_am} +export FIX_AER=${FIX_AER:-$FIX_DIR/fix_aer} +export FIX_LUT=${FIX_LUT:-$FIX_DIR/fix_lut} +FIXfv3=${FIXfv3:-$FIX_DIR/fix_fv3_gmted2010} +DATA=${DATA:-$pwd/fv3tmp$$} # temporary running directory +ROTDIR=${ROTDIR:-$pwd} # rotating archive directory +ICSDIR=${ICSDIR:-$pwd} # cold start initial conditions +DMPDIR=${DMPDIR:-$pwd} # global dumps for seaice, snow and sst analysis + +# Model resolution specific parameters +DELTIM=${DELTIM:-225} +layout_x=${layout_x:-8} +layout_y=${layout_y:-16} +LEVS=${LEVS:-65} + +# Utilities +NCP=${NCP:-"/bin/cp -p"} +NLN=${NLN:-"/bin/ln -sf"} +NMV=${NMV:-"/bin/mv"} +SEND=${SEND:-"YES"} #move final result to rotating directory +ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} +KEEPDATA=${KEEPDATA:-"NO"} + +# Other options +MEMBER=${MEMBER:-"-1"} # -1: control, 0: ensemble mean, >0: ensemble member $MEMBER +ENS_NUM=${ENS_NUM:-1} # Single executable runs multiple members (e.g. GEFS) +PREFIX_ATMINC=${PREFIX_ATMINC:-""} # allow ensemble to use recentered increment + +# IAU options +DOIAU=${DOIAU:-"NO"} +IAUFHRS=${IAUFHRS:-0} +IAU_DELTHRS=${IAU_DELTHRS:-0} +IAU_OFFSET=${IAU_OFFSET:-0} + +# Model specific stuff +FCSTEXECDIR=${FCSTEXECDIR:-$HOMEgfs/sorc/fv3gfs.fd/NEMS/exe} +FCSTEXEC=${FCSTEXEC:-fv3_gfs.x} +PARM_FV3DIAG=${PARM_FV3DIAG:-$HOMEgfs/parm/parm_fv3diag} +PARM_POST=${PARM_POST:-$HOMEgfs/parm/post} + +# Wave coupling parameter defaults to false +cplwav=${cplwav:-.false.} + +# Model config options +APRUN_FV3=${APRUN_FV3:-${APRUN_FCST:-${APRUN:-""}}} +NTHREADS_FV3=${NTHREADS_FV3:-${NTHREADS_FCST:-${nth_fv3:-1}}} +cores_per_node=${cores_per_node:-${npe_node_max:-24}} +ntiles=${ntiles:-6} +NTASKS_FV3=${NTASKS_FV3:-$npe_fv3} + +TYPE=${TYPE:-"nh"} # choices: nh, hydro +MONO=${MONO:-"non-mono"} # choices: mono, non-mono +RUN_CCPP=${RUN_CCPP:-"NO"} + +QUILTING=${QUILTING:-".true."} +OUTPUT_GRID=${OUTPUT_GRID:-"gaussian_grid"} +OUTPUT_FILE=${OUTPUT_FILE:-"nemsio"} +WRITE_NEMSIOFLIP=${WRITE_NEMSIOFLIP:-".true."} +WRITE_FSYNCFLAG=${WRITE_FSYNCFLAG:-".true."} +affix="nemsio" +[[ "$OUTPUT_FILE" = "netcdf" ]] && affix="nc" + +rCDUMP=${rCDUMP:-$CDUMP} + +#------------------------------------------------------------------ +# setup the runtime environment +if [ $machine = "WCOSS_C" ] ; then + HUGEPAGES=${HUGEPAGES:-hugepages4M} + . $MODULESHOME/init/sh 2>/dev/null + module load iobuf craype-$HUGEPAGES 2>/dev/null + export MPICH_GNI_COLL_OPT_OFF=${MPICH_GNI_COLL_OPT_OFF:-MPI_Alltoallv} + export MKL_CBWR=AVX2 + export WRTIOBUF=${WRTIOBUF:-"4M"} + export NC_BLKSZ=${NC_BLKSZ:-"4M"} + export IOBUF_PARAMS="*nemsio:verbose:size=${WRTIOBUF},*:verbose:size=${NC_BLKSZ}" +fi + +#------------------------------------------------------- +if [ ! -d $ROTDIR ]; then mkdir -p $ROTDIR; fi +mkdata=NO +if [ ! -d $DATA ]; then + mkdata=YES + mkdir -p $DATA +fi +cd $DATA || exit 8 +mkdir -p $DATA/INPUT + +if [ $cplwav = ".true." ]; then + if [ $CDUMP = "gdas" ]; then + RSTDIR_WAVE=$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart + else + RSTDIR_WAVE=${RSTDIR_WAVE:-$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart} + fi + if [ ! -d $RSTDIR_WAVE ]; then mkdir -p $RSTDIR_WAVE ; fi + $NLN $RSTDIR_WAVE restart_wave +fi + +if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 ]; then + RSTDIR_ATM=${RSTDIR:-$ROTDIR}/${CDUMP}.${PDY}/${cyc}/atmos/RERUN_RESTART + if [ ! -d $RSTDIR_ATM ]; then mkdir -p $RSTDIR_ATM ; fi + $NLN $RSTDIR_ATM RESTART +else + mkdir -p $DATA/RESTART +fi + +#------------------------------------------------------- +# determine if restart IC exists to continue from a previous forecast +RERUN="NO" +filecount=$(find $RSTDIR_ATM -type f | wc -l) +if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 -a $FHMAX -gt $rst_invt1 -a $filecount -gt 10 ]; then + reverse=$(echo "${restart_interval[@]} " | tac -s ' ') + for xfh in $reverse ; do + yfh=$((xfh-(IAU_OFFSET/2))) + SDATE=$($NDATE +$yfh $CDATE) + PDYS=$(echo $SDATE | cut -c1-8) + cycs=$(echo $SDATE | cut -c9-10) + flag1=$RSTDIR_ATM/${PDYS}.${cycs}0000.coupler.res + flag2=$RSTDIR_ATM/coupler.res + if [ -s $flag1 ]; then + CDATE_RST=$SDATE + [[ $RERUN = "YES" ]] && break + mv $flag1 ${flag1}.old + if [ -s $flag2 ]; then mv $flag2 ${flag2}.old ;fi + RERUN="YES" + [[ $xfh = $rst_invt1 ]] && RERUN="NO" + fi + done +fi + +#------------------------------------------------------- +# member directory +if [ $MEMBER -lt 0 ]; then + prefix=$CDUMP + rprefix=$rCDUMP + memchar="" +else + prefix=enkf$CDUMP + rprefix=enkf$rCDUMP + memchar=mem$(printf %03i $MEMBER) +fi +memdir=$ROTDIR/${prefix}.$PDY/$cyc/atmos/$memchar +if [ ! -d $memdir ]; then mkdir -p $memdir; fi + +GDATE=$($NDATE -$assim_freq $CDATE) +gPDY=$(echo $GDATE | cut -c1-8) +gcyc=$(echo $GDATE | cut -c9-10) +gmemdir=$ROTDIR/${rprefix}.$gPDY/$gcyc/atmos/$memchar +sCDATE=$($NDATE -3 $CDATE) + +if [[ "$DOIAU" = "YES" ]]; then + sCDATE=$($NDATE -3 $CDATE) + sPDY=$(echo $sCDATE | cut -c1-8) + scyc=$(echo $sCDATE | cut -c9-10) + tPDY=$gPDY + tcyc=$gcyc +else + sCDATE=$CDATE + sPDY=$PDY + scyc=$cyc + tPDY=$sPDY + tcyc=$cyc +fi + +#------------------------------------------------------- +# initial conditions +warm_start=${warm_start:-".false."} +read_increment=${read_increment:-".false."} +res_latlon_dynamics="''" + +# Determine if this is a warm start or cold start +if [ -f $gmemdir/RESTART/${sPDY}.${scyc}0000.coupler.res ]; then + export warm_start=".true." +fi + +# turn IAU off for cold start +DOIAU_coldstart=${DOIAU_coldstart:-"NO"} +if [ $DOIAU = "YES" -a $warm_start = ".false." ] || [ $DOIAU_coldstart = "YES" -a $warm_start = ".true." ]; then + export DOIAU="NO" + echo "turning off IAU" + DOIAU_coldstart="YES" + IAU_OFFSET=0 + sCDATE=$CDATE + sPDY=$PDY + scyc=$cyc + tPDY=$sPDY + tcyc=$cyc +fi + +#------------------------------------------------------- +if [ $warm_start = ".true." -o $RERUN = "YES" ]; then +#------------------------------------------------------- +#............................. + if [ $RERUN = "NO" ]; then +#............................. + + # Link all (except sfc_data) restart files from $gmemdir + for file in $(ls $gmemdir/RESTART/${sPDY}.${scyc}0000.*.nc); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) # remove the date from file + fsuf=$(echo $file2 | cut -d. -f1) + if [ $fsuf != "sfc_data" ]; then + $NLN $file $DATA/INPUT/$file2 + fi + done + + # Link sfcanl_data restart files from $memdir + for file in $(ls $memdir/RESTART/${sPDY}.${scyc}0000.*.nc); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) # remove the date from file + fsufanl=$(echo $file2 | cut -d. -f1) + if [ $fsufanl = "sfcanl_data" ]; then + file2=$(echo $file2 | sed -e "s/sfcanl_data/sfc_data/g") + $NLN $file $DATA/INPUT/$file2 + fi + done + + # Need a coupler.res when doing IAU + if [ $DOIAU = "YES" ]; then + rm -f $DATA/INPUT/coupler.res + cat >> $DATA/INPUT/coupler.res << EOF + 2 (Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4) + ${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 Model start time: year, month, day, hour, minute, second + ${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 Current model time: year, month, day, hour, minute, second +EOF + fi + + # Link increments + if [ $DOIAU = "YES" ]; then + for i in $(echo $IAUFHRS | sed "s/,/ /g" | rev); do + incfhr=$(printf %03i $i) + if [ $incfhr = "006" ]; then + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atminc.nc + else + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atmi${incfhr}.nc + fi + if [ ! -f $increment_file ]; then + echo "ERROR: DOIAU = $DOIAU, but missing increment file for fhr $incfhr at $increment_file" + echo "Abort!" + exit 1 + fi + $NLN $increment_file $DATA/INPUT/fv_increment$i.nc + IAU_INC_FILES="'fv_increment$i.nc',$IAU_INC_FILES" + done + read_increment=".false." + res_latlon_dynamics="" + else + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_INC}atminc.nc + if [ -f $increment_file ]; then + $NLN $increment_file $DATA/INPUT/fv_increment.nc + read_increment=".true." + res_latlon_dynamics="fv_increment.nc" + fi + fi + +#............................. + else ##RERUN + + export warm_start=".true." + PDYT=$(echo $CDATE_RST | cut -c1-8) + cyct=$(echo $CDATE_RST | cut -c9-10) + for file in $(ls $RSTDIR_ATM/${PDYT}.${cyct}0000.*); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) + $NLN $file $DATA/INPUT/$file2 + done + + hour_rst=`$NHOUR $CDATE_RST $CDATE` + IAU_FHROT=$((IAU_OFFSET+hour_rst)) + if [ $DOIAU = "YES" ]; then + IAUFHRS=-1 + IAU_DELTHRS=0 + IAU_INC_FILES="''" + fi + + rst_list_rerun="" + xfh=$restart_interval_gfs + while [ $xfh -le $FHMAX_GFS ]; do + rst_list_rerun="$rst_list_rerun $xfh" + xfh=$((xfh+restart_interval_gfs)) + done + restart_interval="$rst_list_rerun" + + fi +#............................. + +else ## cold start + + for file in $(ls $memdir/INPUT/*.nc); do + file2=$(echo $(basename $file)) + fsuf=$(echo $file2 | cut -c1-3) + if [ $fsuf = "gfs" -o $fsuf = "sfc" ]; then + $NLN $file $DATA/INPUT/$file2 + fi + done + +#------------------------------------------------------- +fi +#------------------------------------------------------- + +nfiles=$(ls -1 $DATA/INPUT/* | wc -l) +if [ $nfiles -le 0 ]; then + echo "Initial conditions must exist in $DATA/INPUT, ABORT!" + msg="Initial conditions must exist in $DATA/INPUT, ABORT!" + postmsg "$jlogfile" "$msg" + exit 1 +fi + +# If doing IAU, change forecast hours +if [[ "$DOIAU" = "YES" ]]; then + FHMAX=$((FHMAX+6)) + if [ $FHMAX_HF -gt 0 ]; then + FHMAX_HF=$((FHMAX_HF+6)) + fi +fi + +#-------------------------------------------------------------------------- +# Grid and orography data +for n in $(seq 1 $ntiles); do + $NLN $FIXfv3/$CASE/${CASE}_grid.tile${n}.nc $DATA/INPUT/${CASE}_grid.tile${n}.nc + $NLN $FIXfv3/$CASE/${CASE}_oro_data.tile${n}.nc $DATA/INPUT/oro_data.tile${n}.nc +done +$NLN $FIXfv3/$CASE/${CASE}_mosaic.nc $DATA/INPUT/grid_spec.nc + +# GFS standard input data +IAER=${IAER:-111} +ICO2=${ICO2:-2} + +if [ ${new_o3forc:-YES} = YES ]; then + O3FORC=ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77 +else + O3FORC=global_o3prdlos.f77 +fi +H2OFORC=${H2OFORC:-"global_h2o_pltc.f77"} +$NLN $FIX_AM/${O3FORC} $DATA/global_o3prdlos.f77 +$NLN $FIX_AM/${H2OFORC} $DATA/global_h2oprdlos.f77 +$NLN $FIX_AM/global_solarconstant_noaa_an.txt $DATA/solarconstant_noaa_an.txt +$NLN $FIX_AM/global_sfc_emissivity_idx.txt $DATA/sfc_emissivity_idx.txt + +## merra2 aerosol climo +for n in 01 02 03 04 05 06 07 08 09 10 11 12; do +$NLN $FIX_AER/merra2.aerclim.2003-2014.m${n}.nc $DATA/aeroclim.m${n}.nc +done +$NLN $FIX_LUT/optics_BC.v1_3.dat $DATA/optics_BC.dat +$NLN $FIX_LUT/optics_OC.v1_3.dat $DATA/optics_OC.dat +$NLN $FIX_LUT/optics_DU.v15_3.dat $DATA/optics_DU.dat +$NLN $FIX_LUT/optics_SS.v3_3.dat $DATA/optics_SS.dat +$NLN $FIX_LUT/optics_SU.v1_3.dat $DATA/optics_SU.dat + +$NLN $FIX_AM/global_co2historicaldata_glob.txt $DATA/co2historicaldata_glob.txt +$NLN $FIX_AM/co2monthlycyc.txt $DATA/co2monthlycyc.txt +if [ $ICO2 -gt 0 ]; then + for file in $(ls $FIX_AM/fix_co2_proj/global_co2historicaldata*) ; do + $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") + done +fi + +$NLN $FIX_AM/global_climaeropac_global.txt $DATA/aerosol.dat +if [ $IAER -gt 0 ] ; then + for file in $(ls $FIX_AM/global_volcanic_aerosols*) ; do + $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") + done +fi + +#-------------wavewave---------------------- +if [ $cplwav = ".true." ]; then + + for file in $(ls $COMINwave/rundata/rmp_src_to_dst_conserv_*) ; do + $NLN $file $DATA/ + done + $NLN $COMINwave/rundata/ww3_multi.${CDUMPwave}${WAV_MEMBER}.${cycle}.inp $DATA/ww3_multi.inp + + array=($WAVECUR_FID $WAVEICE_FID $WAVEWND_FID $waveuoutpGRD $waveGRD $waveesmfGRD $wavesbsGRD $wavepostGRD $waveinterpGRD) + grdALL=`printf "%s\n" "${array[@]}" | sort -u | tr '\n' ' '` + + for wavGRD in ${grdALL}; do + $NLN $COMINwave/rundata/${CDUMPwave}.mod_def.$wavGRD $DATA/mod_def.$wavGRD + done + + export WAVHCYC=${WAVHCYC:-6} + export WRDATE=`$NDATE -${WAVHCYC} $CDATE` + export WRPDY=`echo $WRDATE | cut -c1-8` + export WRcyc=`echo $WRDATE | cut -c9-10` + export WRDIR=${ROTDIR}/${CDUMPRSTwave}.${WRPDY}/${WRcyc}/wave/restart + export datwave=$COMOUTwave/rundata + export wavprfx=${CDUMPwave}${WAV_MEMBER} + + for wavGRD in $waveGRD ; do + if [ $RERUN = "NO" ]; then + if [ ! -f ${WRDIR}/${sPDY}.${scyc}0000.restart.${wavGRD} ]; then + echo "WARNING: NON-FATAL ERROR wave IC is missing, will start from rest" + fi + $NLN ${WRDIR}/${sPDY}.${scyc}0000.restart.${wavGRD} $DATA/restart.${wavGRD} + else + if [ ! -f ${RSTDIR_WAVE}/${PDYT}.${cyct}0000.restart.${wavGRD} ]; then + echo "WARNING: NON-FATAL ERROR wave IC is missing, will start from rest" + fi + $NLN ${RSTDIR_WAVE}/${PDYT}.${cyct}0000.restart.${wavGRD} $DATA/restart.${wavGRD} + fi + eval $NLN $datwave/${wavprfx}.log.${wavGRD}.${PDY}${cyc} log.${wavGRD} + done + + if [ "$WW3ICEINP" = "YES" ]; then + wavicefile=$COMINwave/rundata/${CDUMPwave}.${WAVEICE_FID}.${cycle}.ice + if [ ! -f $wavicefile ]; then + echo "ERROR: WW3ICEINP = ${WW3ICEINP}, but missing ice file" + echo "Abort!" + exit 1 + fi + $NLN ${wavicefile} $DATA/ice.${WAVEICE_FID} + fi + + if [ "$WW3CURINP" = "YES" ]; then + wavcurfile=$COMINwave/rundata/${CDUMPwave}.${WAVECUR_FID}.${cycle}.cur + if [ ! -f $wavcurfile ]; then + echo "ERROR: WW3CURINP = ${WW3CURINP}, but missing current file" + echo "Abort!" + exit 1 + fi + $NLN $wavcurfile $DATA/current.${WAVECUR_FID} + fi + + # Link output files + cd $DATA + eval $NLN $datwave/${wavprfx}.log.mww3.${PDY}${cyc} log.mww3 + + # Loop for gridded output (uses FHINC) + fhr=$FHMIN_WAV + while [ $fhr -le $FHMAX_WAV ]; do + YMDH=`$NDATE $fhr $CDATE` + YMD=$(echo $YMDH | cut -c1-8) + HMS="$(echo $YMDH | cut -c9-10)0000" + for wavGRD in ${waveGRD} ; do + eval $NLN $datwave/${wavprfx}.out_grd.${wavGRD}.${YMD}.${HMS} ${YMD}.${HMS}.out_grd.${wavGRD} + done + FHINC=$FHOUT_WAV + if [ $FHMAX_HF_WAV -gt 0 -a $FHOUT_HF_WAV -gt 0 -a $fhr -lt $FHMAX_HF_WAV ]; then + FHINC=$FHOUT_HF_WAV + fi + fhr=$((fhr+FHINC)) + done + + # Loop for point output (uses DTPNT) + fhr=$FHMIN_WAV + while [ $fhr -le $FHMAX_WAV ]; do + YMDH=`$NDATE $fhr $CDATE` + YMD=$(echo $YMDH | cut -c1-8) + HMS="$(echo $YMDH | cut -c9-10)0000" + eval $NLN $datwave/${wavprfx}.out_pnt.${waveuoutpGRD}.${YMD}.${HMS} ${YMD}.${HMS}.out_pnt.${waveuoutpGRD} + FHINC=$FHINCP_WAV + fhr=$((fhr+FHINC)) + done + +fi #cplwav=true +#-------------wavewave---------------------- + +# inline post fix files +if [ $WRITE_DOPOST = ".true." ]; then + $NLN $PARM_POST/post_tag_gfs${LEVS} $DATA/itag + $NLN $PARM_POST/postxconfig-NT-GFS-TWO.txt $DATA/postxconfig-NT.txt + $NLN $PARM_POST/postxconfig-NT-GFS-F00-TWO.txt $DATA/postxconfig-NT_FH00.txt + $NLN $PARM_POST/params_grib2_tbl_new $DATA/params_grib2_tbl_new +fi +#------------------------------------------------------------------ + +# changeable parameters +# dycore definitions +res=$(echo $CASE |cut -c2-5) +resp=$((res+1)) +npx=$resp +npy=$resp +npz=$((LEVS-1)) +io_layout=${io_layout:-"1,1"} +#ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) + +# spectral truncation and regular grid resolution based on FV3 resolution +JCAP_CASE=$((2*res-2)) +LONB_CASE=$((4*res)) +LATB_CASE=$((2*res)) + +JCAP=${JCAP:-$JCAP_CASE} +LONB=${LONB:-$LONB_CASE} +LATB=${LATB:-$LATB_CASE} + +LONB_IMO=${LONB_IMO:-$LONB_CASE} +LATB_JMO=${LATB_JMO:-$LATB_CASE} + +# Fix files +FNGLAC=${FNGLAC:-"$FIX_AM/global_glacier.2x2.grb"} +FNMXIC=${FNMXIC:-"$FIX_AM/global_maxice.2x2.grb"} +FNTSFC=${FNTSFC:-"$FIX_AM/RTGSST.1982.2012.monthly.clim.grb"} +FNSNOC=${FNSNOC:-"$FIX_AM/global_snoclim.1.875.grb"} +FNZORC=${FNZORC:-"igbp"} +FNALBC2=${FNALBC2:-"$FIX_AM/global_albedo4.1x1.grb"} +FNAISC=${FNAISC:-"$FIX_AM/CFSR.SEAICE.1982.2012.monthly.clim.grb"} +FNTG3C=${FNTG3C:-"$FIX_AM/global_tg3clim.2.6x1.5.grb"} +FNVEGC=${FNVEGC:-"$FIX_AM/global_vegfrac.0.144.decpercent.grb"} +FNMSKH=${FNMSKH:-"$FIX_AM/global_slmask.t1534.3072.1536.grb"} +FNVMNC=${FNVMNC:-"$FIX_AM/global_shdmin.0.144x0.144.grb"} +FNVMXC=${FNVMXC:-"$FIX_AM/global_shdmax.0.144x0.144.grb"} +FNSLPC=${FNSLPC:-"$FIX_AM/global_slope.1x1.grb"} +FNALBC=${FNALBC:-"$FIX_AM/global_snowfree_albedo.bosu.t${JCAP}.${LONB}.${LATB}.rg.grb"} +FNVETC=${FNVETC:-"$FIX_AM/global_vegtype.igbp.t${JCAP}.${LONB}.${LATB}.rg.grb"} +FNSOTC=${FNSOTC:-"$FIX_AM/global_soiltype.statsgo.t${JCAP}.${LONB}.${LATB}.rg.grb"} +FNABSC=${FNABSC:-"$FIX_AM/global_mxsnoalb.uariz.t${JCAP}.${LONB}.${LATB}.rg.grb"} +FNSMCC=${FNSMCC:-"$FIX_AM/global_soilmgldas.statsgo.t${JCAP}.${LONB}.${LATB}.grb"} + +# If the appropriate resolution fix file is not present, use the highest resolution available (T1534) +[[ ! -f $FNALBC ]] && FNALBC="$FIX_AM/global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb" +[[ ! -f $FNVETC ]] && FNVETC="$FIX_AM/global_vegtype.igbp.t1534.3072.1536.rg.grb" +[[ ! -f $FNSOTC ]] && FNSOTC="$FIX_AM/global_soiltype.statsgo.t1534.3072.1536.rg.grb" +[[ ! -f $FNABSC ]] && FNABSC="$FIX_AM/global_mxsnoalb.uariz.t1534.3072.1536.rg.grb" +[[ ! -f $FNSMCC ]] && FNSMCC="$FIX_AM/global_soilmgldas.statsgo.t1534.3072.1536.grb" + +# NSST Options +# nstf_name contains the NSST related parameters +# nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled +# nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, +# nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON +# nstf_name(4) : ZSEA1 (in mm) : 0 +# nstf_name(5) : ZSEA2 (in mm) : 0 +# nst_anl : .true. or .false., NSST analysis over lake +NST_MODEL=${NST_MODEL:-0} +NST_SPINUP=${NST_SPINUP:-0} +NST_RESV=${NST_RESV-0} +ZSEA1=${ZSEA1:-0} +ZSEA2=${ZSEA2:-0} +nstf_name=${nstf_name:-"$NST_MODEL,$NST_SPINUP,$NST_RESV,$ZSEA1,$ZSEA2"} +nst_anl=${nst_anl:-".false."} + + +# blocking factor used for threading and general physics performance +#nyblocks=`expr \( $npy - 1 \) \/ $layout_y ` +#nxblocks=`expr \( $npx - 1 \) \/ $layout_x \/ 32` +#if [ $nxblocks -le 0 ]; then nxblocks=1 ; fi +blocksize=${blocksize:-32} + +# the pre-conditioning of the solution +# =0 implies no pre-conditioning +# >0 means new adiabatic pre-conditioning +# <0 means older adiabatic pre-conditioning +na_init=${na_init:-1} +[[ $warm_start = ".true." ]] && na_init=0 + +# variables for controlling initialization of NCEP/NGGPS ICs +filtered_terrain=${filtered_terrain:-".true."} +gfs_dwinds=${gfs_dwinds:-".true."} + +# various debug options +no_dycore=${no_dycore:-".false."} +dycore_only=${adiabatic:-".false."} +chksum_debug=${chksum_debug:-".false."} +print_freq=${print_freq:-6} + +if [ ${TYPE} = "nh" ]; then # non-hydrostatic options + + hydrostatic=".false." + phys_hydrostatic=".false." # enable heating in hydrostatic balance in non-hydrostatic simulation + use_hydro_pressure=".false." # use hydrostatic pressure for physics + if [ $warm_start = ".true." ]; then + make_nh=".false." # restarts contain non-hydrostatic state + else + make_nh=".true." # re-initialize non-hydrostatic state + fi + +else # hydrostatic options + + hydrostatic=".true." + phys_hydrostatic=".false." # ignored when hydrostatic = T + use_hydro_pressure=".false." # ignored when hydrostatic = T + make_nh=".false." # running in hydrostatic mode + +fi + +# Conserve total energy as heat globally +consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics + +# time step parameters in FV3 +k_split=${k_split:-2} +n_split=${n_split:-6} + +if [ $(echo $MONO | cut -c-4) = "mono" ]; then # monotonic options + + d_con=${d_con_mono:-"0."} + do_vort_damp=".false." + if [ ${TYPE} = "nh" ]; then # non-hydrostatic + hord_mt=${hord_mt_nh_mono:-"10"} + hord_xx=${hord_xx_nh_mono:-"10"} + else # hydrostatic + hord_mt=${hord_mt_hydro_mono:-"10"} + hord_xx=${hord_xx_hydro_mono:-"10"} + fi + +else # non-monotonic options + + d_con=${d_con_nonmono:-"1."} + do_vort_damp=".true." + if [ ${TYPE} = "nh" ]; then # non-hydrostatic + hord_mt=${hord_mt_nh_nonmono:-"5"} + hord_xx=${hord_xx_nh_nonmono:-"5"} + else # hydrostatic + hord_mt=${hord_mt_hydro_nonmono:-"10"} + hord_xx=${hord_xx_hydro_nonmono:-"10"} + fi + +fi + +if [ $(echo $MONO | cut -c-4) != "mono" -a $TYPE = "nh" ]; then + vtdm4=${vtdm4_nh_nonmono:-"0.06"} +else + vtdm4=${vtdm4:-"0.05"} +fi + +if [ $warm_start = ".true." ]; then # warm start from restart file + + nggps_ic=".false." + ncep_ic=".false." + external_ic=".false." + mountain=".true." + if [ $read_increment = ".true." ]; then # add increment on the fly to the restarts + res_latlon_dynamics="fv_increment.nc" + else + res_latlon_dynamics='""' + fi + +else # CHGRES'd GFS analyses + + nggps_ic=${nggps_ic:-".true."} + ncep_ic=${ncep_ic:-".false."} + external_ic=".true." + mountain=".false." + read_increment=".false." + res_latlon_dynamics='""' + +fi + +# Stochastic Physics Options +if [ ${SET_STP_SEED:-"YES"} = "YES" ]; then + ISEED_SKEB=$((CDATE*1000 + MEMBER*10 + 1)) + ISEED_SHUM=$((CDATE*1000 + MEMBER*10 + 2)) + ISEED_SPPT=$((CDATE*1000 + MEMBER*10 + 3)) +else + ISEED=${ISEED:-0} +fi +DO_SKEB=${DO_SKEB:-"NO"} +DO_SPPT=${DO_SPPT:-"NO"} +DO_SHUM=${DO_SHUM:-"NO"} + +if [ $DO_SKEB = "YES" ]; then + do_skeb=".true." +fi +if [ $DO_SHUM = "YES" ]; then + do_shum=".true." +fi +if [ $DO_SPPT = "YES" ]; then + do_sppt=".true." +fi + +# copy over the tables +DIAG_TABLE=${DIAG_TABLE:-$PARM_FV3DIAG/diag_table} +DATA_TABLE=${DATA_TABLE:-$PARM_FV3DIAG/data_table} +FIELD_TABLE=${FIELD_TABLE:-$PARM_FV3DIAG/field_table} + +# build the diag_table with the experiment name and date stamp +if [ $DOIAU = "YES" ]; then +cat > diag_table << EOF +FV3 Forecast +${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +else +cat > diag_table << EOF +FV3 Forecast +${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +fi + +$NCP $DATA_TABLE data_table +$NCP $FIELD_TABLE field_table + +# copy CCN_ACTIVATE.BIN for Thompson microphysics +if [ $RUN_CCPP = "YES" ]; then +if [ "$CCPP_SUITE" = 'FV3_GSD_v0' -o "$CCPP_SUITE" = 'FV3_GSD_noah' ]; then + $NLN $FIX_AM/CCN_ACTIVATE.BIN CCN_ACTIVATE.BIN + $NLN $FIX_AM/freezeH2O.dat freezeH2O.dat + $NLN $FIX_AM/qr_acr_qg.dat qr_acr_qg.dat + $NLN $FIX_AM/qr_acr_qs.dat qr_acr_qs.dat +fi +fi + +#------------------------------------------------------------------ +rm -f nems.configure + +if [ $cplwav = ".true." ]; then +#### ww3 version of nems.configure + +# Switch on cpl flag + cpl=.true. + +NTASKS_FV3m1=$((NTASKS_FV3-1)) +atm_petlist_bounds=" 0 $((NTASKS_FV3-1))" +wav_petlist_bounds=" $((NTASKS_FV3)) $((NTASKS_FV3m1+npe_wav))" +### atm_petlist_bounds=" 0 1511" +### atm_petlist_bounds=$atm_petlist_bounds +### wav_petlist_bounds="1512 1691" +### wav_petlist_bounds=$wav_petlist_bounds + coupling_interval_sec=${coupling_interval_sec:-1800} + rm -f nems.configure +cat > nems.configure < WAV :SrcTermProcessing=0:TermOrder=SrcSeq + WAV + @ +:: +EOF +else +#### fv3 standalone version of nems.configure +cat > nems.configure < model_configure < input.nml <> input.nml << EOF + iovr = ${iovr:-"3"} + ltaerosol = ${ltaerosol:-".false."} + lradar = ${lradar:-".false."} + ttendlim = ${ttendlim:-"0.005"} + oz_phys = ${oz_phys:-".false."} + oz_phys_2015 = ${oz_phys_2015:-".true."} + lsoil_lsm = ${lsoil_lsm:-"4"} + do_mynnedmf = ${do_mynnedmf:-".false."} + do_mynnsfclay = ${do_mynnsfclay:-".false."} + icloud_bl = ${icloud_bl:-"1"} + bl_mynn_edmf = ${bl_mynn_edmf:-"1"} + bl_mynn_tkeadvect = ${bl_mynn_tkeadvect:-".true."} + bl_mynn_edmf_mom = ${bl_mynn_edmf_mom:-"1"} + min_lakeice = ${min_lakeice:-"0.15"} + min_seaice = ${min_seaice:-"0.15"} +EOF +else + cat >> input.nml << EOF + iovr_lw = ${iovr_lw:-"3"} + iovr_sw = ${iovr_sw:-"3"} +EOF +fi + +# Add namelist for IAU +if [ $DOIAU = "YES" ]; then + cat >> input.nml << EOF + iaufhrs = ${IAUFHRS} + iau_delthrs = ${IAU_DELTHRS} + iau_inc_files= ${IAU_INC_FILES} + iau_drymassfixer = .false. +EOF +fi + +cat >> input.nml <> input.nml + +cat >> input.nml <> input.nml +if [ $MEMBER -gt 0 ]; then + + cat >> input.nml << EOF +&nam_stochy +EOF + + if [ $DO_SKEB = "YES" ]; then + cat >> input.nml << EOF + skeb = $SKEB + iseed_skeb = ${ISEED_SKEB:-$ISEED} + skeb_tau = ${SKEB_TAU:-"-999."} + skeb_lscale = ${SKEB_LSCALE:-"-999."} + skebnorm = ${SKEBNORM:-"1"} + skeb_npass = ${SKEB_nPASS:-"30"} + skeb_vdof = ${SKEB_VDOF:-"5"} +EOF + fi + + if [ $DO_SHUM = "YES" ]; then + cat >> input.nml << EOF + shum = $SHUM + iseed_shum = ${ISEED_SHUM:-$ISEED} + shum_tau = ${SHUM_TAU:-"-999."} + shum_lscale = ${SHUM_LSCALE:-"-999."} +EOF + fi + + if [ $DO_SPPT = "YES" ]; then + cat >> input.nml << EOF + sppt = $SPPT + iseed_sppt = ${ISEED_SPPT:-$ISEED} + sppt_tau = ${SPPT_TAU:-"-999."} + sppt_lscale = ${SPPT_LSCALE:-"-999."} + sppt_logit = ${SPPT_LOGIT:-".true."} + sppt_sfclimit = ${SPPT_SFCLIMIT:-".true."} + use_zmtnblck = ${use_zmtnblck:-".true."} +EOF + fi + + cat >> input.nml << EOF + $nam_stochy_nml +/ +EOF + + + cat >> input.nml << EOF +&nam_sfcperts + $nam_sfcperts_nml +/ +EOF + +else + + cat >> input.nml << EOF +&nam_stochy +/ +&nam_sfcperts +/ +EOF + +fi + + +#------------------------------------------------------------------ +# make symbolic links to write forecast files directly in memdir +cd $DATA +if [ $QUILTING = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]; then + fhr=$FHMIN + while [ $fhr -le $FHMAX ]; do + FH3=$(printf %03i $fhr) + FH2=$(printf %02i $fhr) + atmi=atmf${FH3}.$affix + sfci=sfcf${FH3}.$affix + logi=logf${FH3} + pgbi=GFSPRS.GrbF${FH2} + flxi=GFSFLX.GrbF${FH2} + atmo=$memdir/${CDUMP}.t${cyc}z.atmf${FH3}.$affix + sfco=$memdir/${CDUMP}.t${cyc}z.sfcf${FH3}.$affix + logo=$memdir/${CDUMP}.t${cyc}z.logf${FH3}.txt + pgbo=$memdir/${CDUMP}.t${cyc}z.master.grb2f${FH3} + flxo=$memdir/${CDUMP}.t${cyc}z.sfluxgrbf${FH3}.grib2 + eval $NLN $atmo $atmi + eval $NLN $sfco $sfci + eval $NLN $logo $logi + if [ $WRITE_DOPOST = ".true." ]; then + eval $NLN $pgbo $pgbi + eval $NLN $flxo $flxi + fi + FHINC=$FHOUT + if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 -a $fhr -lt $FHMAX_HF ]; then + FHINC=$FHOUT_HF + fi + fhr=$((fhr+FHINC)) + done +else + for n in $(seq 1 $ntiles); do + eval $NLN nggps2d.tile${n}.nc $memdir/nggps2d.tile${n}.nc + eval $NLN nggps3d.tile${n}.nc $memdir/nggps3d.tile${n}.nc + eval $NLN grid_spec.tile${n}.nc $memdir/grid_spec.tile${n}.nc + eval $NLN atmos_static.tile${n}.nc $memdir/atmos_static.tile${n}.nc + eval $NLN atmos_4xdaily.tile${n}.nc $memdir/atmos_4xdaily.tile${n}.nc + done +fi + +# Copy namelist file +$NCP input.nml $memdir + +#------------------------------------------------------------------ +# run the executable + +$NCP $FCSTEXECDIR/$FCSTEXEC $DATA/. +export OMP_NUM_THREADS=$NTHREADS_FV3 +$APRUN_FV3 $DATA/$FCSTEXEC 1>&1 2>&2 +export ERR=$? +export err=$ERR +$ERRSCRIPT || exit $err + +#------------------------------------------------------------------ +if [ $SEND = "YES" ]; then + + # Copy gdas and enkf member restart files + if [ $CDUMP = "gdas" -a $rst_invt1 -gt 0 ]; then + cd $DATA/RESTART + mkdir -p $memdir/RESTART + for rst_int in $restart_interval ; do + if [ $rst_int -ge 0 ]; then + RDATE=$($NDATE +$rst_int $CDATE) + rPDY=$(echo $RDATE | cut -c1-8) + rcyc=$(echo $RDATE | cut -c9-10) + for file in $(ls ${rPDY}.${rcyc}0000.*) ; do + $NCP $file $memdir/RESTART/$file + done + fi + done + if [ $DOIAU = "YES" ] || [ $DOIAU_coldstart = "YES" ]; then + # if IAU is on, save restart at start of IAU window + rst_iau=$(( ${IAU_OFFSET} - (${IAU_DELTHRS}/2) )) + if [ $rst_iau -lt 0 ];then + rst_iau=$(( (${IAU_DELTHRS}) - ${IAU_OFFSET} )) + fi + RDATE=$($NDATE +$rst_iau $CDATE) + rPDY=$(echo $RDATE | cut -c1-8) + rcyc=$(echo $RDATE | cut -c9-10) + for file in $(ls ${rPDY}.${rcyc}0000.*) ; do + $NCP $file $memdir/RESTART/$file + done + fi + fi +fi + +#------------------------------------------------------------------ +# Clean up before leaving +if [ $mkdata = "YES" ]; then rm -rf $DATA; fi + +#------------------------------------------------------------------ +set +x +if [ $VERBOSE = "YES" ] ; then + echo $(date) EXITING $0 with return code $err >&2 +fi +exit 0 diff --git a/ush/forecast_det.sh b/ush/forecast_det.sh new file mode 100755 index 0000000000..4b152019d2 --- /dev/null +++ b/ush/forecast_det.sh @@ -0,0 +1,82 @@ +#! /bin/sh + +##### +## "forecast_def.sh" +## This script sets value of all variables +## +## This is the child script of ex-global forecast, +## This script is a definition of functions. +##### + + +# For all non-evironment variables +# Cycling and forecast hour specific parameters + +FV3_GFS_det(){ + #------------------------------------------------------- + # warm start? + warm_start=${warm_start:-".false."} + read_increment=${read_increment:-".false."} + res_latlon_dynamics="''" + + # Determine if this is a warm start or cold start + if [ -f $gmemdir/RESTART/${sPDY}.${scyc}0000.coupler.res ]; then + export warm_start=".true." + fi + + # turn IAU off for cold start + DOIAU_coldstart=${DOIAU_coldstart:-"NO"} + if [ $DOIAU = "YES" -a $warm_start = ".false." ] || [ $DOIAU_coldstart = "YES" -a $warm_start = ".true." ]; then + export DOIAU="NO" + echo "turning off IAU since warm_start = $warm_start" + DOIAU_coldstart="YES" + IAU_OFFSET=0 + sCDATE=$CDATE + sPDY=$PDY + scyc=$cyc + tPDY=$sPDY + tcyc=$cyc + fi + + #------------------------------------------------------- + # determine if restart IC exists to continue from a previous forecast + RERUN="NO" + filecount=$(find $RSTDIR_ATM -type f | wc -l) + if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 -a $FHMAX -gt $rst_invt1 -a $filecount -gt 10 ]; then + reverse=$(echo "${restart_interval[@]} " | tac -s ' ') + for xfh in $reverse ; do + yfh=$((xfh-(IAU_OFFSET/2))) + SDATE=$($NDATE +$yfh $CDATE) + PDYS=$(echo $SDATE | cut -c1-8) + cycs=$(echo $SDATE | cut -c9-10) + flag1=$RSTDIR_ATM/${PDYS}.${cycs}0000.coupler.res + flag2=$RSTDIR_ATM/coupler.res + if [ -s $flag1 ]; then + CDATE_RST=$SDATE + [[ $RERUN = "YES" ]] && break + mv $flag1 ${flag1}.old + if [ -s $flag2 ]; then mv $flag2 ${flag2}.old ;fi + RERUN="YES" + [[ $xfh = $rst_invt1 ]] && RERUN="NO" + fi + done + fi + + #------------------------------------------------------- +} + +FV3_GEFS_det(){ + echo "SUB ${FUNCNAME[0]}: Defining variables for FV3GEFS" +} + +WW3_det(){ + echo "SUB ${FUNCNAME[0]}: Run type determination for WW3" +} + +CICE_det(){ + echo "SUB ${FUNCNAME[0]}: Run type determination for CICE" +} + +MOM6_det(){ + echo "SUB ${FUNCNAME[0]}: Run type determination for MOM6" +} diff --git a/ush/forecast_postdet.sh b/ush/forecast_postdet.sh new file mode 100755 index 0000000000..7bdde50324 --- /dev/null +++ b/ush/forecast_postdet.sh @@ -0,0 +1,880 @@ +#!/bin/sh + +##### +## This script defines functions for data I/O and namelist. +## different applications could share the same function +## or have their own. +## +## This is a child script of modular +## forecast script. This script is function definition. +## need to call these functions in the parent script +## for execution. +##### + +FV3_GEFS_postdet(){ + echo SUB ${FUNCNAME[0]}: Linking input data for FV3 $RUN + # soft link commands insert here +} + +DATM_postdet(){ + ###################################################################### + # Link DATM inputs (ie forcing files) # + ###################################################################### + + #TODO: This should be some loop through CDATE-> CDATE+ FORECAST length + #and get input from either CFSR or GEFS or Whatever... + #Currently assumes you only need the month of DATM input for IC date + #DATMINPUTDIR should be machine specific + + # DATM forcing file name convention is ${DATM_FILENAME_BASE}.$YYYYMMDDHH.nc + echo "Link DATM forcing files" + DATMINPUTDIR="/scratch2/NCEPDEV/marineda/DATM_INPUT/CFSR/${SYEAR}${SMONTH}" + $NLN -sf ${DATMINPUTDIR}/${DATM_FILENAME_BASE}*.nc $DATA/DATM_INPUT/ +} + +FV3_GFS_postdet(){ + echo "SUB ${FUNCNAME[0]}: $RERUN and $warm_start determined for $RUN" + + echo $warm_start + echo $RERUN + + if [ ${TYPE} = "nh" ]; then # non-hydrostatic options + hydrostatic=".false." + phys_hydrostatic=".false." # enable heating in hydrostatic balance in non-hydrostatic simulation + use_hydro_pressure=".false." # use hydrostatic pressure for physics + if [ $warm_start = ".true." ]; then + make_nh=".false." # restarts contain non-hydrostatic state + else + make_nh=".true." # re-initialize non-hydrostatic state + fi + else # hydrostatic options + hydrostatic=".true." + phys_hydrostatic=".false." # ignored when hydrostatic = T + use_hydro_pressure=".false." # ignored when hydrostatic = T + make_nh=".false." # running in hydrostatic mode + fi + + #------------------------------------------------------- + if [ $warm_start = ".true." -o $RERUN = "YES" ]; then + #------------------------------------------------------- + #............................. + if [ $RERUN = "NO" ]; then + #............................. + + # Link all (except sfc_data) restart files from $gmemdir + for file in $(ls $gmemdir/RESTART/${sPDY}.${scyc}0000.*.nc); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) # remove the date from file + fsuf=$(echo $file2 | cut -d. -f1) + if [ $fsuf != "sfc_data" ]; then + $NLN $file $DATA/INPUT/$file2 + fi + done + + # Link sfcanl_data restart files from $memdir + for file in $(ls $memdir/RESTART/${sPDY}.${scyc}0000.*.nc); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) # remove the date from file + fsufanl=$(echo $file2 | cut -d. -f1) + if [ $fsufanl = "sfcanl_data" ]; then + file2=$(echo $file2 | sed -e "s/sfcanl_data/sfc_data/g") + $NLN $file $DATA/INPUT/$file2 + fi + done + + # Need a coupler.res when doing IAU + # if [ $DOIAU = "YES" ]; then + # rm -f $DATA/INPUT/coupler.res + # cat >> $DATA/INPUT/coupler.res << EOF + # 2 (Calendar: no_calendar=0, thirty_day_months=1, julian=2, gregorian=3, noleap=4) + # ${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 Model start time: year, month, day, hour, minute, second + # ${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 Current model time: year, month, day, hour, minute, second + #EOF + # fi + + # Link increments + if [ $DOIAU = "YES" ]; then + for i in $(echo $IAUFHRS | sed "s/,/ /g" | rev); do + incfhr=$(printf %03i $i) + if [ $incfhr = "006" ]; then + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atminc.nc + else + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_ATMINC}atmi${incfhr}.nc + fi + if [ ! -f $increment_file ]; then + echo "ERROR: DOIAU = $DOIAU, but missing increment file for fhr $incfhr at $increment_file" + echo "Abort!" + exit 1 + fi + $NLN $increment_file $DATA/INPUT/fv_increment$i.nc + IAU_INC_FILES="'fv_increment$i.nc',$IAU_INC_FILES" + done + read_increment=".false." + res_latlon_dynamics="" + else + increment_file=$memdir/${CDUMP}.t${cyc}z.${PREFIX_INC}atminc.nc + if [ -f $increment_file ]; then + $NLN $increment_file $DATA/INPUT/fv3_increment.nc + read_increment=".true." + res_latlon_dynamics="fv3_increment.nc" + fi + fi + + #............................. + else ##RERUN + + export warm_start=".true." + PDYT=$(echo $CDATE_RST | cut -c1-8) + cyct=$(echo $CDATE_RST | cut -c9-10) + for file in $(ls $RSTDIR_ATM/${PDYT}.${cyct}0000.*); do + file2=$(echo $(basename $file)) + file2=$(echo $file2 | cut -d. -f3-) + $NLN $file $DATA/INPUT/$file2 + done + + hour_rst=`$NHOUR $CDATE_RST $CDATE` + IAU_FHROT=$((IAU_OFFSET+hour_rst)) + if [ $DOIAU = "YES" ]; then + IAUFHRS=-1 + IAU_DELTHRS=0 + IAU_INC_FILES="''" + fi + + fi + #............................. + + else ## cold start + + for file in $(ls $memdir/INPUT/*.nc); do + file2=$(echo $(basename $file)) + fsuf=$(echo $file2 | cut -c1-3) + if [ $fsuf = "gfs" -o $fsuf = "sfc" ]; then + $NLN $file $DATA/INPUT/$file2 + fi + done + + fi + + if [ $machine = 'sandbox' ]; then + echo SUB ${FUNCNAME[0]}: Checking initial condition, overriden in sandbox mode! + else + nfiles=$(ls -1 $DATA/INPUT/* | wc -l) + if [ $nfiles -le 0 ]; then + echo SUB ${FUNCNAME[0]}: Initial conditions must exist in $DATA/INPUT, ABORT! + msg=”"SUB ${FUNCNAME[0]}: Initial conditions must exist in $DATA/INPUT, ABORT!" + postmsg "$jlogfile" "$msg" + exit 1 + fi + fi + + # If doing IAU, change forecast hours + if [[ "$DOIAU" = "YES" ]]; then + FHMAX=$((FHMAX+6)) + if [ $FHMAX_HF -gt 0 ]; then + FHMAX_HF=$((FHMAX_HF+6)) + fi + fi + + #-------------------------------------------------------------------------- + # Grid and orography data + if [ -z ${GRDFIX} ] ; then + FIXgrd=$FIXfv3/$CASE + else + FIXgrd=${GRDFIX} + fi + for n in $(seq 1 $ntiles); do + $NLN ${FIXgrd}/${CASE}_grid.tile${n}.nc $DATA/INPUT/${CASE}_grid.tile${n}.nc + done + + if [ -f ${FIXgrd}/${CASE}_mosaic.nc ] ; then + src_grid_spec=${FIXgrd}/${CASE}_mosaic.nc + else + src_grid_spec=${FIXgrd}/grid_spec.nc + fi + + if [ $cplflx = ".false." ] ; then + $NLN ${src_grid_spec} $DATA/INPUT/grid_spec.nc + else + $NLN ${src_grid_spec} $DATA/INPUT/${CASE}_mosaic.nc + fi + + if [ -z ${OROFIX} ]; then + if [ $FRAC_GRID ]; then + FIXoro=${FIXoro:-$FIX_DIR/fix_fv3_fracoro}/${CASE}.mx${OCNRES}_frac/${CASE}.mx${OCNRES}_ + else + FIXoro=$FIXfv3/$CASE/${CASE}_oro_data. + fi + else + FIXoro=${OROFIX}/oro_data. + fi + for n in $(seq 1 $ntiles); do + $NLN ${FIXoro}tile${n}.nc $DATA/INPUT/oro_data.tile${n}.nc + done + + # GFS standard input data + + IALB=${IALB:-1} + IEMS=${IEMS:-1} + ISOL=${ISOL:-2} + IAER=${IAER:-111} + ICO2=${ICO2:-2} + + if [ ${new_o3forc:-YES} = YES ]; then + O3FORC=ozprdlos_2015_new_sbuvO3_tclm15_nuchem.f77 + else + O3FORC=global_o3prdlos.f77 + fi + H2OFORC=${H2OFORC:-"global_h2o_pltc.f77"} + #### + # copy CCN_ACTIVATE.BIN for Thompson microphysics + if [ $imp_physics -eq 8 ]; then + $NCP $FV3INP/CCN_ACTIVATE.BIN CCN_ACTIVATE.BIN + #### + $NCP $FIX_AM/freezeH2O.dat . + $NCP $FIX_AM/qr_acr_qg.dat . + $NCP $FIX_AM/qr_acr_qs.dat . + sleep 60 + fi + $NLN $FIX_AM/${O3FORC} $DATA/global_o3prdlos.f77 + $NLN $FIX_AM/${H2OFORC} $DATA/global_h2oprdlos.f77 + $NLN $FIX_AM/global_solarconstant_noaa_an.txt $DATA/solarconstant_noaa_an.txt + $NLN $FIX_AM/global_sfc_emissivity_idx.txt $DATA/sfc_emissivity_idx.txt + + $NLN $FIX_AM/global_co2historicaldata_glob.txt $DATA/co2historicaldata_glob.txt + $NLN $FIX_AM/co2monthlycyc.txt $DATA/co2monthlycyc.txt + if [ $ICO2 -gt 0 ]; then + for file in $(ls $FIX_AM/fix_co2_proj/global_co2historicaldata*) ; do + $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") + done + fi + + $NLN $FIX_AM/global_climaeropac_global.txt $DATA/aerosol.dat + if [ $IAER -gt 0 ] ; then + for file in $(ls $FIX_AM/global_volcanic_aerosols*) ; do + $NLN $file $DATA/$(echo $(basename $file) | sed -e "s/global_//g") + done + fi + + # inline post fix files + if [ $WRITE_DOPOST = ".true." ]; then + $NLN $PARM_POST/post_tag_gfs${LEVS} $DATA/itag + $NLN $PARM_POST/postxconfig-NT-GFS-TWO.txt $DATA/postxconfig-NT.txt + $NLN $PARM_POST/postxconfig-NT-GFS-F00-TWO.txt $DATA/postxconfig-NT_FH00.txt + $NLN $PARM_POST/params_grib2_tbl_new $DATA/params_grib2_tbl_new + fi + + #------------------------------------------------------------------ + # changeable parameters + # dycore definitions + res=$(echo $CASE |cut -c2-5) + resp=$((res+1)) + npx=$resp + npy=$resp + npz=$((LEVS-1)) + io_layout="1,1" + #ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) + + # spectral truncation and regular grid resolution based on FV3 resolution + JCAP_CASE=$((2*res-2)) + LONB_CASE=$((4*res)) + LATB_CASE=$((2*res)) + if [ $LATB_CASE -eq 192 ]; then + LATB_CASE=190 # berror file is at this resolution + fi + + JCAP=${JCAP:-$JCAP_CASE} + LONB=${LONB:-$LONB_CASE} + LATB=${LATB:-$LATB_CASE} + + LONB_IMO=${LONB_IMO:-$LONB_CASE} + LATB_JMO=${LATB_JMO:-$LATB_CASE} + + # Fix files + FNGLAC=${FNGLAC:-"$FIX_AM/global_glacier.2x2.grb"} + FNMXIC=${FNMXIC:-"$FIX_AM/global_maxice.2x2.grb"} + FNTSFC=${FNTSFC:-"$FIX_AM/RTGSST.1982.2012.monthly.clim.grb"} + FNSNOC=${FNSNOC:-"$FIX_AM/global_snoclim.1.875.grb"} + FNZORC=${FNZORC:-"igbp"} + FNALBC2=${FNALBC2:-"$FIX_AM/global_albedo4.1x1.grb"} + FNAISC=${FNAISC:-"$FIX_AM/CFSR.SEAICE.1982.2012.monthly.clim.grb"} + FNTG3C=${FNTG3C:-"$FIX_AM/global_tg3clim.2.6x1.5.grb"} + FNVEGC=${FNVEGC:-"$FIX_AM/global_vegfrac.0.144.decpercent.grb"} + #if [ $cpl = ".true." ]; then + # export FNMSKH=${FNMSKH:-"$FIX_AM/seaice_newland.grb"} + #else + export FNMSKH=${FNMSKH:-"$FIX_AM/global_slmask.t1534.3072.1536.grb"} + #fi + FNVMNC=${FNVMNC:-"$FIX_AM/global_shdmin.0.144x0.144.grb"} + FNVMXC=${FNVMXC:-"$FIX_AM/global_shdmax.0.144x0.144.grb"} + FNSLPC=${FNSLPC:-"$FIX_AM/global_slope.1x1.grb"} + FNALBC=${FNALBC:-"$FIX_AM/global_snowfree_albedo.bosu.t${JCAP}.${LONB}.${LATB}.rg.grb"} + FNVETC=${FNVETC:-"$FIX_AM/global_vegtype.igbp.t${JCAP}.${LONB}.${LATB}.rg.grb"} + FNSOTC=${FNSOTC:-"$FIX_AM/global_soiltype.statsgo.t${JCAP}.${LONB}.${LATB}.rg.grb"} + FNABSC=${FNABSC:-"$FIX_AM/global_mxsnoalb.uariz.t${JCAP}.${LONB}.${LATB}.rg.grb"} + FNSMCC=${FNSMCC:-"$FIX_AM/global_soilmgldas.statsgo.t${JCAP}.${LONB}.${LATB}.grb"} + + # If the appropriate resolution fix file is not present, use the highest resolution available (T1534) + [[ ! -f $FNALBC ]] && FNALBC="$FIX_AM/global_snowfree_albedo.bosu.t1534.3072.1536.rg.grb" + [[ ! -f $FNVETC ]] && FNVETC="$FIX_AM/global_vegtype.igbp.t1534.3072.1536.rg.grb" + [[ ! -f $FNSOTC ]] && FNSOTC="$FIX_AM/global_soiltype.statsgo.t1534.3072.1536.rg.grb" + [[ ! -f $FNABSC ]] && FNABSC="$FIX_AM/global_mxsnoalb.uariz.t1534.3072.1536.rg.grb" + [[ ! -f $FNSMCC ]] && FNSMCC="$FIX_AM/global_soilmgldas.statsgo.t1534.3072.1536.grb" + + # NSST Options + # nstf_name contains the NSST related parameters + # nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled + # nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, + # nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON + # nstf_name(4) : ZSEA1 (in mm) : 0 + # nstf_name(5) : ZSEA2 (in mm) : 0 + # nst_anl : .true. or .false., NSST analysis over lake + NST_MODEL=${NST_MODEL:-0} + NST_SPINUP=${NST_SPINUP:-0} + NST_RESV=${NST_RESV-0} + ZSEA1=${ZSEA1:-0} + ZSEA2=${ZSEA2:-0} + nstf_name=${nstf_name:-"$NST_MODEL,$NST_SPINUP,$NST_RESV,$ZSEA1,$ZSEA2"} + nst_anl=${nst_anl:-".false."} + + # blocking factor used for threading and general physics performance + #nyblocks=`expr \( $npy - 1 \) \/ $layout_y ` + #nxblocks=`expr \( $npx - 1 \) \/ $layout_x \/ 32` + #if [ $nxblocks -le 0 ]; then nxblocks=1 ; fi + blocksize=${blocksize:-32} + + # the pre-conditioning of the solution + # =0 implies no pre-conditioning + # >0 means new adiabatic pre-conditioning + # <0 means older adiabatic pre-conditioning + na_init=${na_init:-1} + [[ $warm_start = ".true." ]] && na_init=0 + + # variables for controlling initialization of NCEP/NGGPS ICs + filtered_terrain=${filtered_terrain:-".true."} + gfs_dwinds=${gfs_dwinds:-".true."} + + # various debug options + no_dycore=${no_dycore:-".false."} + dycore_only=${adiabatic:-".false."} + chksum_debug=${chksum_debug:-".false."} + print_freq=${print_freq:-6} + + # Conserve total energy as heat globally + consv_te=${consv_te:-1.} # range 0.-1., 1. will restore energy to orig. val. before physics + + # time step parameters in FV3 + k_split=${k_split:-2} + n_split=${n_split:-6} + + if [ $(echo $MONO | cut -c-4) = "mono" ]; then # monotonic options + + d_con=${d_con_mono:-"0."} + do_vort_damp=".false." + if [ ${TYPE} = "nh" ]; then # non-hydrostatic + hord_mt=${hord_mt_nh_mono:-"10"} + hord_xx=${hord_xx_nh_mono:-"10"} + else # hydrostatic + hord_mt=${hord_mt_hydro_mono:-"10"} + hord_xx=${hord_xx_hydro_mono:-"10"} + fi + + else # non-monotonic options + + d_con=${d_con_nonmono:-"1."} + do_vort_damp=".true." + if [ ${TYPE} = "nh" ]; then # non-hydrostatic + hord_mt=${hord_mt_nh_nonmono:-"5"} + hord_xx=${hord_xx_nh_nonmono:-"5"} + else # hydrostatic + hord_mt=${hord_mt_hydro_nonmono:-"10"} + hord_xx=${hord_xx_hydro_nonmono:-"10"} + fi + + fi + + if [ $(echo $MONO | cut -c-4) != "mono" -a $TYPE = "nh" ]; then + vtdm4=${vtdm4_nh_nonmono:-"0.06"} + else + vtdm4=${vtdm4:-"0.05"} + fi + + if [ $warm_start = ".true." ]; then # warm start from restart file + + nggps_ic=".false." + ncep_ic=".false." + external_ic=".false." + mountain=".true." + if [ $read_increment = ".true." ]; then # add increment on the fly to the restarts + res_latlon_dynamics="fv3_increment.nc" + else + res_latlon_dynamics='""' + fi + + else # CHGRES'd GFS analyses + + nggps_ic=${nggps_ic:-".true."} + ncep_ic=${ncep_ic:-".false."} + external_ic=".true." + mountain=".false." + read_increment=".false." + res_latlon_dynamics='""' + + fi + + # Stochastic Physics Options + if [ ${SET_STP_SEED:-"YES"} = "YES" ]; then + ISEED_SKEB=$((CDATE*1000 + MEMBER*10 + 1)) + ISEED_SHUM=$((CDATE*1000 + MEMBER*10 + 2)) + ISEED_SPPT=$((CDATE*1000 + MEMBER*10 + 3)) + else + ISEED=${ISEED:-0} + fi + DO_SKEB=${DO_SKEB:-".false."} + DO_SPPT=${DO_SPPT:-".false."} + DO_SHUM=${DO_SHUM:-".false."} + JCAP_STP=${JCAP_STP:-$JCAP_CASE} + LONB_STP=${LONB_STP:-$LONB_CASE} + LATB_STP=${LATB_STP:-$LATB_CASE} + + #------------------------------------------------------------------ + # make symbolic links to write forecast files directly in memdir + cd $DATA + if [ "$CCPP_SUITE" = 'FV3_GSD_v0' -o "$CCPP_SUITE" = 'FV3_GSD_noah' ]; then + $NLN $FIX_AM/CCN_ACTIVATE.BIN CCN_ACTIVATE.BIN + $NLN $FIX_AM/freezeH2O.dat freezeH2O.dat + $NLN $FIX_AM/qr_acr_qg.dat qr_acr_qg.dat + $NLN $FIX_AM/qr_acr_qs.dat qr_acr_qs.dat + fi + + affix="nc" + if [ "$OUTPUT_FILE" = "nemsio" ]; then + affix="nemsio" + fi + + if [ $QUILTING = ".true." -a $OUTPUT_GRID = "gaussian_grid" ]; then + fhr=$FHMIN + while [ $fhr -le $FHMAX ]; do + FH3=$(printf %03i $fhr) + FH2=$(printf %02i $fhr) + atmi=atmf${FH3}.$affix + sfci=sfcf${FH3}.$affix + logi=logf${FH3} + pgbi=GFSPRS.GrbF${FH2} + flxi=GFSFLX.GrbF${FH2} + atmo=$memdir/${CDUMP}.t${cyc}z.atmf${FH3}.$affix + sfco=$memdir/${CDUMP}.t${cyc}z.sfcf${FH3}.$affix + logo=$memdir/${CDUMP}.t${cyc}z.logf${FH3}.txt + pgbo=$memdir/${CDUMP}.t${cyc}z.master.grb2f${FH3} + flxo=$memdir/${CDUMP}.t${cyc}z.sfluxgrbf${FH3}.grib2 + eval $NLN $atmo $atmi + eval $NLN $sfco $sfci + eval $NLN $logo $logi + if [ $WRITE_DOPOST = ".true." ]; then + eval $NLN $pgbo $pgbi + eval $NLN $flxo $flxi + fi + FHINC=$FHOUT + if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 -a $fhr -lt $FHMAX_HF ]; then + FHINC=$FHOUT_HF + fi + fhr=$((fhr+FHINC)) + done + else + for n in $(seq 1 $ntiles); do + eval $NLN nggps2d.tile${n}.nc $memdir/nggps2d.tile${n}.nc + eval $NLN nggps3d.tile${n}.nc $memdir/nggps3d.tile${n}.nc + eval $NLN grid_spec.tile${n}.nc $memdir/grid_spec.tile${n}.nc + eval $NLN atmos_static.tile${n}.nc $memdir/atmos_static.tile${n}.nc + eval $NLN atmos_4xdaily.tile${n}.nc $memdir/atmos_4xdaily.tile${n}.nc + done + fi +} + +FV3_GFS_nml(){ + # namelist output for a certain component + echo SUB ${FUNCNAME[0]}: Creating name lists and model configure file for FV3 + if [ $machine = 'sandbox' ]; then + cd $SCRIPTDIR + echo "MAIN: !!!Sandbox mode, writing to current directory!!!" + fi + # Call child scripts in current script directory + if [ $cplgocart = .true. ]; then + source $SCRIPTDIR/parsing_namelists_FV3_GOCART.sh + else + source $SCRIPTDIR/parsing_namelists_FV3.sh + fi + FV3_namelists + echo SUB ${FUNCNAME[0]}: FV3 name lists and model configure file created +} + +DATM_nml(){ + source $SCRIPTDIR/parsing_namelists_DATM.sh + DATM_namelists + echo SUB ${FUNCNAME[0]}: DATM name lists and model configure file created +} + +data_out_GFS() { + # data in take for FV3GFS + # Arguments: None + # + #------------------------------------------------------------------ + # make symbolic links to write forecast files directly in memdir + echo "SUB ${FUNCNAME[0]}: copying output data for FV3" + #------------------------------------------------------------------ + + if [ $SEND = "YES" ]; then + # Copy model restart files + if [ $CDUMP = "gdas" -a $restart_interval -gt 0 ]; then + cd $DATA/RESTART + mkdir -p $memdir/RESTART + # Only save restarts at single time in RESTART directory + # Either at restart_interval or at end of the forecast + # if [ $restart_interval -eq 0 -o $restart_interval -eq $FHMAX ]; then + + # Add time-stamp to restart files at FHMAX + # RDATE=$($NDATE +$FHMAX $CDATE) + # rPDY=$(echo $RDATE | cut -c1-8) + # rcyc=$(echo $RDATE | cut -c9-10) + # for file in $(ls * | grep -v 0000); do + # $NMV $file ${rPDY}.${rcyc}0000.$file + # done + # else + # time-stamp exists at restart_interval time, just copy + RDATE=$($NDATE +$restart_interval $CDATE) + rPDY=$(echo $RDATE | cut -c1-8) + rcyc=$(echo $RDATE | cut -c9-10) + for file in ${rPDY}.${rcyc}0000.* ; do + $NCP $file $memdir/RESTART/$file + done + fi + fi + + $NCP $DATA/input.nml $ROTDIR/${CDUMP}.${PDY}/${cyc}/atmos/ + + echo "SUB ${FUNCNAME[0]}: Output data for FV3 copied" +} + +WW3_postdet() { + echo "SUB ${FUNCNAME[0]}: Linking input data for WW3" + COMPONENTwave=${COMPONENTwave:-${RUN}wave} + + #Link mod_def files for wave grids + array=($WAVECUR_FID $WAVEICE_FID $WAVEWND_FID $waveuoutpGRD $waveGRD $waveesmfGRD $wavesbsGRD $wavepostGRD $waveinterpGRD) + echo "Wave Grids: $WAVECUR_FID $WAVEICE_FID $WAVEWND_FID $waveuoutpGRD $waveGRD $waveesmfGRD $wavesbsGRD $wavepostGRD $waveinterpGRD" + grdALL=`printf "%s\n" "${array[@]}" | sort -u | tr '\n' ' '` + for wavGRD in ${grdALL}; do + $NCP $ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/rundata/${COMPONENTwave}.mod_def.$wavGRD $DATA/mod_def.$wavGRD + done + + #Copy initial condition files: + for wavGRD in $waveGRD ; do + # Link wave IC for current cycle + # $NLN ${WRDIR}/${sPDY}.${scyc}0000.restart.${wavGRD} $DATA/restart.${wavGRD} + # Link IC for S2S benchmarks: + $NCP -pf $ICSDIR/$CDATE/wav/${PDY}.${cyc}0000.restart.$wavGRD $DATA/restart.$wavGRD + # Link log files for computational grids: + eval $NLN $ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/rundata/${COMPONENTwave}${WAV_MEMBER}.log.${wavGRD}.${PDY}${cyc} $DATA/log.${wavGRD} + done + + #link more log files: + eval $NLN $ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/rundata/${COMPONENTwave}${WAV_MEMBER}.log.mww3.${PDY}${cyc} $DATA/log.mww3 + + datwave=$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/rundata + wavprfx=${COMPONENTwave}${WAV_MEMBER} + # Loop for gridded output (uses FHINC) + fhr=$FHMIN_WAV + while [ $fhr -le $FHMAX_WAV ]; do + YMDH=`$NDATE $fhr $CDATE` + YMD=$(echo $YMDH | cut -c1-8) + HMS="$(echo $YMDH | cut -c9-10)0000" + for wavGRD in ${waveGRD} ; do + eval $NLN $datwave/${wavprfx}.out_grd.${wavGRD}.${YMD}.${HMS} $DATA/${YMD}.${HMS}.out_grd.${wavGRD} + done + FHINC=$FHOUT_WAV + if [ $FHMAX_HF_WAV -gt 0 -a $FHOUT_HF_WAV -gt 0 -a $fhr -lt $FHMAX_HF_WAV ]; then + FHINC=$FHOUT_HF_WAV + fi + fhr=$((fhr+FHINC)) + done + # Loop for point output (uses DTPNT) + fhr=$FHMIN_WAV + while [ $fhr -le $FHMAX_WAV ]; do + YMDH=`$NDATE $fhr $CDATE` + YMD=$(echo $YMDH | cut -c1-8) + HMS="$(echo $YMDH | cut -c9-10)0000" + eval $NLN $datwave/${wavprfx}.out_pnt.${waveuoutpGRD}.${YMD}.${HMS} $DATA/${YMD}.${HMS}.out_pnt.${waveuoutpGRD} + FHINC=$FHINCP_WAV + fhr=$((fhr+FHINC)) + done + +} + +WW3_nml() { + echo "SUB ${FUNCNAME[0]}: Copying input files for WW3" + WAV_MOD_TAG=${CDUMP}wave${waveMEMB} + $NCP $ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/rundata/ww3_multi.${WAV_MOD_TAG}.${cycle}.inp $DATA/ww3_multi.inp +} + +WW3_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for WW3" +} + + +CPL_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for general cpl fields" + if [ $esmf_profile = ".true." ]; then + $NCP $DATA/ESMF_Profile.summary $ROTDIR/$CDUMP.$PDY/$cyc/ + fi +} + +MOM6_postdet() { + echo "SUB ${FUNCNAME[0]}: MOM6 after run type determination" + + OCNRES=${OCNRES:-"025"} + + # Copy MOM6 ICs + $NCP -pf $ICSDIR/$CDATE/ocn/MOM*nc $DATA/INPUT/ + + # Copy MOM6 fixed files + $NCP -pf $FIXmom/$OCNRES/* $DATA/INPUT/ + + # Copy coupled grid_spec + $NCP -pf $FIX_DIR/fix_cpl/a${CASE}o${OCNRES}/grid_spec.nc $DATA/INPUT/ + + # Copy mediator restart files to RUNDIR + if [ $inistep = 'restart' ]; then + $NCP $ROTDIR/$CDUMP.$PDY/$cyc/ufs.cpld*.nc $DATA/ + $NCP $ROTDIR/$CDUMP.$PDY/$cyc/rpointer.cpl $DATA/ + fi + + echo "SUB ${FUNCNAME[0]}: MOM6 input data linked/copied" +} + +MOM6_nml() { + echo "SUB ${FUNCNAME[0]}: Creating name list for MOM6" + source $SCRIPTDIR/parsing_namelists_MOM6.sh + MOM6_namelists +} + +MOM6_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for MOM6" + + export ENSMEM=${ENSMEM:-01} + + export IDATE=$CDATE + + if [ $RUN_ENVIR = "nco" ]; then + export COMIN=${COMIN:-$ROTDIR/$RUN.$PDY/$cyc} + export COMOUT=${COMOUT:-$ROTDIR/$RUN.$PDY/$cyc} + else + export COMIN="$ROTDIR/$CDUMP.$PDY/$cyc" + export COMOUT="$ROTDIR/$CDUMP.$PDY/$cyc" + fi + [[ ! -d $COMOUT ]] && mkdir -m 775 -p $COMOUT + + if [ $inistep = 'cold' ]; then + cp $DATA/ufs.cpld.cold.cpl.r.*.nc $COMOUT/ + cp $DATA/rpointer.cpl $COMOUT/ + status=$? + exit $status + else + if [ $FHRGRP -eq 0 ]; then + fhrlst="anl" + else + fhrlst=$(echo $FHRLST | sed -e 's/_/ /g; s/\[/ /g; s/\]/ /g; s/f/ /g; s/,/ /g') + fi + + # copy ocn files + for fhr in $fhrlst; do + export fhr=$fhr + if [[ 10#$fhr -ge 6 ]]; then + hh_inc_m=$((10#$FHOUT/2)) + hh_inc_o=$((10#$FHOUT )) + + # ------------------------------------------------------ + # adjust the dates on the mom filenames and save + # ------------------------------------------------------ + VDATE=$($NDATE $fhr $IDATE) + YYYY=`echo $VDATE | cut -c1-4` + MM=`echo $VDATE | cut -c5-6` + DD=`echo $VDATE | cut -c7-8` + HH=`echo $VDATE | cut -c9-10` + SS=$((10#$HH*3600)) + + m_date=$($NDATE -$hh_inc_m $VDATE) + p_date=$VDATE + + year=`echo $m_date | cut -c1-4` + month=`echo $m_date | cut -c5-6` + day=`echo $m_date | cut -c7-8` + hh=`echo $m_date | cut -c9-10` + + export ocnfile=ocn_${year}_${month}_${day}_${hh}.nc + + echo "$NCP -p $ocnfile $COMOUT/ocn$p_date.$ENSMEM.$IDATE.nc" + $NCP -p $ocnfile $COMOUT/ocn$p_date.$ENSMEM.$IDATE.nc + status=$? + [[ $status -ne 0 ]] && exit $status + + fi + + done + $NCP -p $DATA/ocn_daily*nc $COMOUT/ + $NCP -p $DATA/wavocn*nc $COMOUT/ #temporary for p4 + $NCP -p $DATA/INPUT/MOM_input $COMOUT/ + fi +} + +CICE_postdet() { + echo "SUB ${FUNCNAME[0]}: CICE after run type determination" + + year=$(echo $CDATE|cut -c 1-4) + stepsperhr=$((3600/$ICETIM)) + nhours=$($NHOUR $CDATE ${year}010100) + istep0=$((nhours*stepsperhr)) + steps=$((nhours*stepsperhr)) + npt=$((FHMAX*$stepsperhr)) # Need this in order for dump_last to work + + histfreq_n=${histfreq_n:-6} + if [ $inistep = 'cold' ]; then + dumpfreq_n=${dumpfreq_n:-3600} # restart write interval in seconds, default 1 hour + dumpfreq="s" + else + dumpfreq_n=${dumpfreq_n:-3024000} # restart write interval in seconds, default 35 days + dumpfreq=${dumpfreq:-"s"} # "s" or "d" or "m" for restarts at intervals of "seconds", "days" or "months" + fi + cice_hist_avg=${cice_hist_avg:-".true."} + + FRAZIL_FWSALT=${FRAZIL_FWSALT:-".true."} + tr_pond_lvl=${tr_pond_lvl:-".true."} # Use level melt ponds tr_pond_lvl=true + + # restart_pond_lvl (if tr_pond_lvl=true): + # -- if true, initialize the level ponds from restart (if runtype=continue) + # -- if false, re-initialize level ponds to zero (if runtype=initial or continue) + + #TODO: Determine the proper way to determine if it's a 'hot start' or not + #note this is not mediator cold start or not + #if [ hotstart ]; then + # #continuing run "hot start" + # RUNTYPE='continue' + # USE_RESTART_TIME='.true.' + #fi + RUNTYPE='initial' + USE_RESTART_TIME='.false.' + restart_pond_lvl=${restart_pond_lvl:-".false."} + + ICERES=${ICERES:-"025"} + if [ $ICERES = '025' ]; then + ICERESdec="0.25" + fi + if [ $ICERES = '050' ]; then + ICERESdec="0.50" + fi + if [ $ICERES = '100' ]; then + ICERESdec="1.00" + fi + + ice_grid_file=${ice_grid_file:-"grid_cice_NEMS_mx${ICERES}.nc"} + ice_kmt_file=${ice_kmt_file:-"kmtu_cice_NEMS_mx${ICERES}.nc"} + + iceic="cice_model.res_$CDATE.nc" + + # Copy CICE IC + $NCP -p $ICSDIR/$CDATE/ice/cice_model_${ICERESdec}.res_$CDATE.nc $DATA/$iceic + + echo "Link CICE fixed files" + $NLN -sf $FIXcice/$ICERES/${ice_grid_file} $DATA/ + $NLN -sf $FIXcice/$ICERES/${ice_kmt_file} $DATA/ + $NLN -sf $FIXcice/$ICERES/$MESHICE $DATA/ +} + +CICE_nml() { + echo "SUB ${FUNCNAME[0]}: Creating name list for CICE" + source $SCRIPTDIR/parsing_namelists_CICE.sh + CICE_namelists +} + +CICE_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for CICE" + if [ $inistep = 'cold' ]; then + echo "mediator cold start, no copying of data for CICE" + else + export ENSMEM=${ENSMEM:-01} + export IDATE=$CDATE + $NCP -p $DATA/ice_in $COMOUT/ + if [ $FHRGRP -eq 0 ]; then + fhrlst="anl" + else + fhrlst=$(echo $FHRLST | sed -e 's/_/ /g; s/\[/ /g; s/\]/ /g; s/f/ /g; s/,/ /g') + fi + + for fhr in $fhrlst; do + export fhr=$fhr + # -------------------------------------- + # cp cice data to COMOUT directory + # -------------------------------------- + YYYY0=`echo $IDATE | cut -c1-4` + MM0=`echo $IDATE | cut -c5-6` + DD0=`echo $IDATE | cut -c7-8` + HH0=`echo $IDATE | cut -c9-10` + SS0=$((10#$HH0*3600)) + + VDATE=$($NDATE $fhr $IDATE) + YYYY=`echo $VDATE | cut -c1-4` + MM=`echo $VDATE | cut -c5-6` + DD=`echo $VDATE | cut -c7-8` + HH=`echo $VDATE | cut -c9-10` + SS=$((10#$HH*3600)) + + if [[ 10#$fhr -eq 0 ]]; then + $NCP -p $DATA/history/iceh_ic.${YYYY0}-${MM0}-${DD0}-`printf "%5.5d" ${SS0}`.nc $COMOUT/iceic$VDATE.$ENSMEM.$IDATE.nc + status=$? + [[ $status -ne 0 ]] && exit $status + echo "fhr is 0, only copying ice initial conditions... exiting" + else + $NCP -p $DATA/history/iceh_`printf "%0.2d" $FHOUT`h.${YYYY}-${MM}-${DD}-`printf "%5.5d" ${SS}`.nc $COMOUT/ice$VDATE.$ENSMEM.$IDATE.nc + status=$? + [[ $status -ne 0 ]] && exit $status + fi + + done + fi +} + +GOCART_rc() { + echo "SUB ${FUNCNAME[0]}: Linking input data and copying config files for GOCART" + # set input directory containing GOCART input data and configuration files + # this variable is platform-dependent and should be set via a YAML file + + # link directory containing GOCART input dataset, if provided + if [ ! -z "${CHM_INPDIR}" ]; then + $NLN -sf ${CHM_INPDIR} $DATA + status=$? + [[ $status -ne 0 ]] && exit $status + fi + + # copying GOCART configuration files + if [ ! -z "${CHM_CFGDIR}" ]; then + $NCP ${CHM_CFGDIR}/*.rc $DATA + status=$? + [[ $status -ne 0 ]] && exit $status + fi +} + +GSD_in() { + echo "SUB ${FUNCNAME[0]}: Linking input data for GSD" + # soft link commands insert here +} + +GSD_nml() { + echo "SUB ${FUNCNAME[0]}: Creating name list for GSD" + sh parsing_namelists_GSD.sh +} + +GSD_out() { + echo "SUB ${FUNCNAME[0]}: Copying output data for GSD" + # soft link commands insert here +} + + + diff --git a/ush/forecast_predet.sh b/ush/forecast_predet.sh new file mode 100755 index 0000000000..4cd5763b36 --- /dev/null +++ b/ush/forecast_predet.sh @@ -0,0 +1,294 @@ +#! /bin/sh + +##### +## "forecast_def.sh" +## This script sets value of all variables +## +## This is the child script of ex-global forecast, +## This script is a definition of functions. +##### + + +# For all non-evironment variables +# Cycling and forecast hour specific parameters +common_predet(){ + echo "SUB ${FUNCNAME[0]}: Defining variables for shared through models" + pwd=$(pwd) + machine=${machine:-"WCOSS_C"} + machine=$(echo $machine | tr '[a-z]' '[A-Z]') + CASE=${CASE:-C768} + CDATE=${CDATE:-2017032500} + DATA=${DATA:-$pwd/fv3tmp$$} # temporary running directory + ROTDIR=${ROTDIR:-$pwd} # rotating archive directory + ICSDIR=${ICSDIR:-$pwd} # cold start initial conditions +} + +DATM_predet(){ + SYEAR=$(echo $CDATE | cut -c1-4) + SMONTH=$(echo $CDATE | cut -c5-6) + SDAY=$(echo $CDATE | cut -c7-8) + SHOUR=$(echo $CDATE | cut -c9-10) + # directory set up + if [ ! -d $DATA ]; then mkdir -p $DATA; fi + if [ ! -d $DATA/DATM_INPUT ]; then mkdir -p $DATA/DATM_INPUT; fi + FHMAX=${FHMAX:-9} + # Go to Run Directory (DATA) + cd $DATA +} + +FV3_GFS_predet(){ + echo "SUB ${FUNCNAME[0]}: Defining variables for FV3GFS" + CDUMP=${CDUMP:-gdas} + CDUMPwave="${CDUMP}wave" + FHMIN=${FHMIN:-0} + FHMAX=${FHMAX:-9} + FHOUT=${FHOUT:-3} + FHZER=${FHZER:-6} + FHCYC=${FHCYC:-24} + FHMAX_HF=${FHMAX_HF:-0} + FHOUT_HF=${FHOUT_HF:-1} + NSOUT=${NSOUT:-"-1"} + FDIAG=$FHOUT + if [ $FHMAX_HF -gt 0 -a $FHOUT_HF -gt 0 ]; then FDIAG=$FHOUT_HF; fi + + WRITE_DOPOST=${WRITE_DOPOST:-".false."} + restart_interval=${restart_interval:-0} + rst_invt1=`echo $restart_interval |cut -d " " -f 1` + + PDY=$(echo $CDATE | cut -c1-8) + cyc=$(echo $CDATE | cut -c9-10) + + # Directories. + pwd=$(pwd) + NWPROD=${NWPROD:-${NWROOT:-$pwd}} + HOMEgfs=${HOMEgfs:-$NWPROD} + FIX_DIR=${FIX_DIR:-$HOMEgfs/fix} + FIX_AM=${FIX_AM:-$FIX_DIR/fix_am} + FIXfv3=${FIXfv3:-$FIX_DIR/fix_fv3_gmted2010} + DATA=${DATA:-$pwd/fv3tmp$$} # temporary running directory + ROTDIR=${ROTDIR:-$pwd} # rotating archive directory + ICSDIR=${ICSDIR:-$pwd} # cold start initial conditions + DMPDIR=${DMPDIR:-$pwd} # global dumps for seaice, snow and sst analysis + + # Model resolution specific parameters + DELTIM=${DELTIM:-225} + layout_x=${layout_x:-8} + layout_y=${layout_y:-16} + LEVS=${LEVS:-65} + + # Utilities + NCP=${NCP:-"/bin/cp -p"} + NLN=${NLN:-"/bin/ln -sf"} + NMV=${NMV:-"/bin/mv"} + SEND=${SEND:-"YES"} #move final result to rotating directory + ERRSCRIPT=${ERRSCRIPT:-'eval [[ $err = 0 ]]'} + KEEPDATA=${KEEPDATA:-"NO"} + NEMSIOCHGDATE=${NEMSIOCHGDATE:-"${HOMEgfs}/exec/nemsio_chgdate"} + IAU_CHGDATE=${IAU_CHGDATE:-"YES"} + + # Other options + MEMBER=${MEMBER:-"-1"} # -1: control, 0: ensemble mean, >0: ensemble member $MEMBER + ENS_NUM=${ENS_NUM:-1} # Single executable runs multiple members (e.g. GEFS) + PREFIX_ATMINC=${PREFIX_ATMINC:-""} # allow ensemble to use recentered increment + + # IAU options + DOIAU=${DOIAU:-"NO"} + IAUFHRS=${IAUFHRS:-0} + IAU_DELTHRS=${IAU_DELTHRS:-0} + IAU_OFFSET=${IAU_OFFSET:-0} + + # Model specific stuff + FCSTEXECDIR=${FCSTEXECDIR:-$HOMEgfs/sorc/fv3gfs.fd/NEMS/exe} + FCSTEXEC=${FCSTEXEC:-fv3_gfs.x} + PARM_FV3DIAG=${PARM_FV3DIAG:-$HOMEgfs/parm/parm_fv3diag} + PARM_POST=${PARM_POST:-$HOMEgfs/parm/post} + + # Model config options + APRUN_FV3=${APRUN_FV3:-${APRUN_FCST:-${APRUN:-""}}} + #the following NTHREAD_FV3 line is commented out because NTHREAD_FCST is not defined + #and because NTHREADS_FV3 gets overwritten by what is in the env/${macine}.env + #file and the value of npe_node_fcst is not correctly defined when using more than + #one thread and sets NTHREADS_FV3=1 even when the number of threads is appropraitely >1 + #NTHREADS_FV3=${NTHREADS_FV3:-${NTHREADS_FCST:-${nth_fv3:-1}}} + NTHREADS_FV3=${nth_fv3:-1} + cores_per_node=${cores_per_node:-${npe_node_fcst:-24}} + ntiles=${ntiles:-6} + if [ $MEMBER -lt 0 ]; then + NTASKS_TOT=${NTASKS_TOT:-$npe_fcst_gfs} + else + NTASKS_TOT=${NTASKS_TOT:-$npe_efcs} + fi + + TYPE=${TYPE:-"nh"} # choices: nh, hydro + MONO=${MONO:-"non-mono"} # choices: mono, non-mono + + QUILTING=${QUILTING:-".true."} + OUTPUT_GRID=${OUTPUT_GRID:-"gaussian_grid"} + OUTPUT_FILE=${OUTPUT_FILE:-"nemsio"} + WRITE_NEMSIOFLIP=${WRITE_NEMSIOFLIP:-".true."} + WRITE_FSYNCFLAG=${WRITE_FSYNCFLAG:-".true."} + + rCDUMP=${rCDUMP:-$CDUMP} + + #------------------------------------------------------------------ + # setup the runtime environment + if [ $machine = "WCOSS_C" ] ; then + HUGEPAGES=${HUGEPAGES:-hugepages4M} + . $MODULESHOME/init/sh 2>/dev/null + module load iobuf craype-$HUGEPAGES 2>/dev/null + export MPICH_GNI_COLL_OPT_OFF=${MPICH_GNI_COLL_OPT_OFF:-MPI_Alltoallv} + export MKL_CBWR=AVX2 + export WRTIOBUF=${WRTIOBUF:-"4M"} + export NC_BLKSZ=${NC_BLKSZ:-"4M"} + export IOBUF_PARAMS="*nemsio:verbose:size=${WRTIOBUF},*:verbose:size=${NC_BLKSZ}" + fi + #------------------------------------------------------- + + #------------------------------------------------------------------ + # changeable parameters + # dycore definitions + res=$(echo $CASE |cut -c2-5) + resp=$((res+1)) + npx=$resp + npy=$resp + npz=$((LEVS-1)) + io_layout="1,1" + #ncols=$(( (${npx}-1)*(${npy}-1)*3/2 )) + + # spectral truncation and regular grid resolution based on FV3 resolution + JCAP_CASE=$((2*res-2)) + LONB_CASE=$((4*res)) + LATB_CASE=$((2*res)) + if [ $LATB_CASE -eq 192 ]; then + LATB_CASE=190 # berror file is at this resolution + fi + + JCAP=${JCAP:-$JCAP_CASE} + LONB=${LONB:-$LONB_CASE} + LATB=${LATB:-$LATB_CASE} + + LONB_IMO=${LONB_IMO:-$LONB_CASE} + LATB_JMO=${LATB_JMO:-$LATB_CASE} + + # NSST Options + # nstf_name contains the NSST related parameters + # nstf_name(1) : NST_MODEL (NSST Model) : 0 = OFF, 1 = ON but uncoupled, 2 = ON and coupled + # nstf_name(2) : NST_SPINUP : 0 = OFF, 1 = ON, + # nstf_name(3) : NST_RESV (Reserved, NSST Analysis) : 0 = OFF, 1 = ON + # nstf_name(4) : ZSEA1 (in mm) : 0 + # nstf_name(5) : ZSEA2 (in mm) : 0 + # nst_anl : .true. or .false., NSST analysis over lake + NST_MODEL=${NST_MODEL:-0} + NST_SPINUP=${NST_SPINUP:-0} + NST_RESV=${NST_RESV-0} + ZSEA1=${ZSEA1:-0} + ZSEA2=${ZSEA2:-0} + nstf_name=${nstf_name:-"$NST_MODEL,$NST_SPINUP,$NST_RESV,$ZSEA1,$ZSEA2"} + nst_anl=${nst_anl:-".false."} + + + # blocking factor used for threading and general physics performance + #nyblocks=`expr \( $npy - 1 \) \/ $layout_y ` + #nxblocks=`expr \( $npx - 1 \) \/ $layout_x \/ 32` + #if [ $nxblocks -le 0 ]; then nxblocks=1 ; fi + blocksize=${blocksize:-32} + + # variables for controlling initialization of NCEP/NGGPS ICs + filtered_terrain=${filtered_terrain:-".true."} + gfs_dwinds=${gfs_dwinds:-".true."} + + # various debug options + no_dycore=${no_dycore:-".false."} + dycore_only=${adiabatic:-".false."} + chksum_debug=${chksum_debug:-".false."} + print_freq=${print_freq:-6} + + #------------------------------------------------------- + if [ ! -d $ROTDIR ]; then mkdir -p $ROTDIR; fi + mkdata=NO + if [ ! -d $DATA ]; then + mkdata=YES + mkdir -p $DATA ; + fi + cd $DATA || exit 8 + mkdir -p $DATA/INPUT + if [ $CDUMP = "gfs" -a $rst_invt1 -gt 0 ]; then + RSTDIR_ATM=${RSTDIR:-$ROTDIR}/${CDUMP}.${PDY}/${cyc}/atmos/RERUN_RESTART + if [ ! -d $RSTDIR_ATM ]; then mkdir -p $RSTDIR_ATM ; fi + $NLN $RSTDIR_ATM RESTART + else + mkdir -p $DATA/RESTART + fi + + #------------------------------------------------------- + # member directory + if [ $MEMBER -lt 0 ]; then + prefix=$CDUMP + rprefix=$rCDUMP + memchar="" + else + prefix=enkf$CDUMP + rprefix=enkf$rCDUMP + memchar=mem$(printf %03i $MEMBER) + fi + memdir=$ROTDIR/${prefix}.$PDY/$cyc/atmos/$memchar + if [ ! -d $memdir ]; then mkdir -p $memdir; fi + + GDATE=$($NDATE -$assim_freq $CDATE) + gPDY=$(echo $GDATE | cut -c1-8) + gcyc=$(echo $GDATE | cut -c9-10) + gmemdir=$ROTDIR/${rprefix}.$gPDY/$gcyc/atmos/$memchar + sCDATE=$($NDATE -3 $CDATE) + + if [[ "$DOIAU" = "YES" ]]; then + sCDATE=$($NDATE -3 $CDATE) + sPDY=$(echo $sCDATE | cut -c1-8) + scyc=$(echo $sCDATE | cut -c9-10) + tPDY=$gPDY + tcyc=$gcyc + else + sCDATE=$CDATE + sPDY=$PDY + scyc=$cyc + tPDY=$sPDY + tcyc=$cyc + fi + + echo "SUB ${FUNCNAME[0]}: pre-determination variables set" +} + +WW3_predet(){ + echo "SUB ${FUNCNAME[0]}: Defining variables for WW3" + if [ $CDUMP = "gdas" ]; then + RSTDIR_WAVE=$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart + else + RSTDIR_WAVE=${RSTDIR_WAVE:-$ROTDIR/${CDUMP}.${PDY}/${cyc}/wave/restart} + fi + if [ ! -d $RSTDIR_WAVE ]; then mkdir -p $RSTDIR_WAVE ; fi + $NLN $RSTDIR_WAVE restart_wave +} + +CICE_predet(){ + echo "SUB ${FUNCNAME[0]}: CICE before run type determination" + if [ ! -d $ROTDIR ]; then mkdir -p $ROTDIR; fi + if [ ! -d $DATA ]; then mkdir -p $DATA; fi + if [ ! -d $DATA/RESTART ]; then mkdir -p $DATA/RESTART; fi + if [ ! -d $DATA/INPUT ]; then mkdir -p $DATA/INPUT; fi + if [ ! -d $DATA/restart ]; then mkdir -p $DATA/restart; fi + if [ ! -d $DATA/history ]; then mkdir -p $DATA/history; fi + if [ ! -d $DATA/OUTPUT ]; then mkdir -p $DATA/OUTPUT; fi +} + +MOM6_predet(){ + echo "SUB ${FUNCNAME[0]}: MOM6 before run type determination" + if [ ! -d $ROTDIR ]; then mkdir -p $ROTDIR; fi + if [ ! -d $DATA ]; then mkdir -p $DATA; fi + if [ ! -d $DATA/RESTART ]; then mkdir -p $DATA/RESTART; fi + if [ ! -d $DATA/INPUT ]; then mkdir -p $DATA/INPUT; fi + if [ ! -d $DATA/restart ]; then mkdir -p $DATA/restart; fi + if [ ! -d $DATA/history ]; then mkdir -p $DATA/history; fi + if [ ! -d $DATA/OUTPUT ]; then mkdir -p $DATA/OUTPUT; fi + if [ ! -d $DATA/MOM6_OUTPUT ]; then mkdir -p $DATA/MOM6_OUTPUT; fi + if [ ! -d $DATA/MOM6_RESTART ]; then mkdir -p $DATA/MOM6_RESTART; fi + cd $DATA || exit 8 +} diff --git a/ush/parsing_model_configure_DATM.sh b/ush/parsing_model_configure_DATM.sh new file mode 100755 index 0000000000..c3fb5d1ac5 --- /dev/null +++ b/ush/parsing_model_configure_DATM.sh @@ -0,0 +1,40 @@ +#! /bin/sh + +##### +## "parsing_model_configure_DATM.sh" +## This script writes model configure file +## for DATM model +## +## This is the child script of ex-global forecast, +## writing model configure file for DATM +## This script is a direct execution. +##### + +DATM_model_configure(){ + +rm -f model_configure +cat > model_configure <> model_configure <> model_configure < ice_in < diag_table << EOF +FV3 Forecast +${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +else +cat > diag_table << EOF +FV3 Forecast +${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +fi + +$NCP $DATA_TABLE data_table +$NCP $FIELD_TABLE field_table + +cat > input.nml <> input.nml << EOF + oz_phys = .false. + oz_phys_2015 = .true. +EOF +elif [ $CCPP_SUITE = "FV3_GSD_v0" ]; then + cat >> input.nml << EOF + iovr = ${iovr:-"3"} + ltaerosol = ${ltaerosol:-".F."} ! In config.fcst + lradar = ${lradar:-".F."} ! In config.fcst + ttendlim = ${ttendlim:-0.005} ! In config.fcst + oz_phys = ${oz_phys:-".false."} + oz_phys_2015 = ${oz_phys_2015:-".true."} + lsoil_lsm = ${lsoil_lsm:-"4"} + do_mynnedmf = ${do_mynnedmf:-".false."} + do_mynnsfclay = ${do_mynnsfclay:-".false."} + icloud_bl = ${icloud_bl:-"1"} ! In config.fcst + bl_mynn_edmf = ${bl_mynn_edmf:-"1"} ! In config.fcst + bl_mynn_tkeadvect=${bl_mynn_tkeadvect:-".true."} ! In config.fcst + bl_mynn_edmf_mom=${bl_mynn_edmf_mom:-"1"} ! In config.fcst + min_lakeice = ${min_lakeice:-"0.15"} + min_seaice = ${min_seaice:-"0.15"} +EOF +elif [ $CCPP_SUITE = "FV3_GFS_v16_coupled" ]; then + cat >> input.nml << EOF + iovr = ${iovr:-"3"} + ltaerosol = ${ltaerosol:-".false."} + lradar = ${lradar:-".false."} + ttendlim = ${ttendlim:-"0.005"} + oz_phys = ${oz_phys:-".false."} + oz_phys_2015 = ${oz_phys_2015:-".true."} + lsoil_lsm = ${lsoil_lsm:-"4"} + do_mynnedmf = ${do_mynnedmf:-".false."} + do_mynnsfclay = ${do_mynnsfclay:-".false."} + icloud_bl = ${icloud_bl:-"1"} + bl_mynn_edmf = ${bl_mynn_edmf:-"1"} + bl_mynn_tkeadvect = ${bl_mynn_tkeadvect:-".true."} + bl_mynn_edmf_mom = ${bl_mynn_edmf_mom:-"1"} + min_lakeice = ${min_lakeice:-"0.15"} + min_seaice = ${min_seaice:-"0.15"} +EOF +else + cat >> input.nml << EOF + iovr_lw = ${iovr_lw:-"3"} + iovr_sw = ${iovr_sw:-"3"} +EOF +fi + +cat >> input.nml <> input.nml << EOF + cplflx = $cplflx + cplwav2atm = ${cplwav2atm} ! CROW configured +EOF +fi + +# Add namelist for IAU +if [ $DOIAU = "YES" ]; then + cat >> input.nml << EOF + iaufhrs = ${IAUFHRS} + iau_delthrs = ${IAU_DELTHRS} + iau_inc_files= ${IAU_INC_FILES} + iau_drymassfixer = .false. +EOF +fi + +cat >> input.nml <> input.nml + +cat >> input.nml <> input.nml +#if [ $MEMBER -gt 0 ]; then +if [ $DO_SPPT = .true. -o $DO_SHUM = .true. -o $DO_SKEB = .true. ]; then + + cat >> input.nml << EOF +&nam_stochy + new_lscale = .true. + ntrunc = $JCAP_STP + lon_s = $LONB_STP + lat_s = $LATB_STP +EOF + + if [ $DO_SKEB = ".true." ]; then + cat >> input.nml << EOF + skeb = $SKEB + iseed_skeb = ${ISEED_SKEB:-$ISEED} + skeb_tau = ${SKEB_TAU:-"-999."} + skeb_lscale = ${SKEB_LSCALE:-"-999."} + skebnorm = ${SKEBNORM:-"1"} + skeb_npass = ${SKEB_nPASS:-"30"} + skeb_vdof = ${SKEB_VDOF:-"5"} +EOF + fi + + if [ $DO_SHUM = ".true." ]; then + cat >> input.nml << EOF + shum = $SHUM + iseed_shum = ${ISEED_SHUM:-$ISEED} + shum_tau = ${SHUM_TAU:-"-999."} + shum_lscale = ${SHUM_LSCALE:-"-999."} +EOF + fi + + if [ $DO_SPPT = ".true." ]; then + cat >> input.nml << EOF + sppt = $SPPT + iseed_sppt = ${ISEED_SPPT:-$ISEED} + sppt_tau = ${SPPT_TAU:-"-999."} + sppt_lscale = ${SPPT_LSCALE:-"-999."} + sppt_logit = ${SPPT_LOGIT:-".true."} + sppt_sfclimit = ${SPPT_SFCLIMIT:-".true."} + use_zmtnblck = ${use_zmtnblck:-".true."} +EOF + fi + + cat >> input.nml << EOF + $nam_stochy_nml +/ +EOF + + + cat >> input.nml << EOF +&nam_sfcperts + $nam_sfcperts_nml +/ +EOF + +else + + cat >> input.nml << EOF +&nam_stochy +/ +&nam_sfcperts +/ +EOF + +fi + +echo "$(cat input.nml)" +} diff --git a/ush/parsing_namelists_FV3_GOCART.sh b/ush/parsing_namelists_FV3_GOCART.sh new file mode 100755 index 0000000000..0d2390515c --- /dev/null +++ b/ush/parsing_namelists_FV3_GOCART.sh @@ -0,0 +1,364 @@ +#! /bin/sh +##### +## "parsing_namelist_FV3.sh" +## This script writes namelist for FV3 model +## +## This is the child script of ex-global forecast, +## writing namelist for FV3 +## This script is a direct execution. +##### + +FV3_namelists(){ + +# copy over the tables +DIAG_TABLE=${DIAG_TABLE:-$PARM_FV3DIAG/diag_table_aer} +DATA_TABLE=${DATA_TABLE:-$PARM_FV3DIAG/data_table} +FIELD_TABLE=${FIELD_TABLE:-$PARM_FV3DIAG/field_table_aer} + +# build the diag_table with the experiment name and date stamp +if [ $DOIAU = "YES" ]; then +cat > diag_table << EOF +FV3 Forecast +${gPDY:0:4} ${gPDY:4:2} ${gPDY:6:2} ${gcyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +else +cat > diag_table << EOF +FV3 Forecast +${sPDY:0:4} ${sPDY:4:2} ${sPDY:6:2} ${scyc} 0 0 +EOF +cat $DIAG_TABLE >> diag_table +fi + +$NCP $DATA_TABLE data_table +$NCP $FIELD_TABLE field_table + +cat > input.nml <> input.nml <> input.nml + +cat >> input.nml <> input.nml << EOF +&nam_stochy +/ +&nam_sfcperts +/ +EOF + +echo "$(cat input.nml)" +} diff --git a/ush/parsing_namelists_MOM6.sh b/ush/parsing_namelists_MOM6.sh new file mode 100644 index 0000000000..2af5e1d457 --- /dev/null +++ b/ush/parsing_namelists_MOM6.sh @@ -0,0 +1,88 @@ + +MOM6_namelists(){ + +# MOM6 namelists generation + +OCNRES=${OCNRES:-"025"} +MOM_INPUT=MOM_input_template_$OCNRES + +#TODO: Make these variables configurable + +#Set to False for restart reproducibility +MOM6_REPRO_LA='True' +MOM6_THERMO_SPAN='False' + +if [ $cplwav = ".true." ] ; then + MOM6_USE_WAVES='True' +else + MOM6_USE_WAVES='False' +fi + +if [ $OCNRES = '025' ]; then + NX_GLB=1440 + NY_GLB=1080 + DT_DYNAM_MOM6='900' + DT_THERM_MOM6='1800' + CHLCLIM="seawifs-clim-1997-2010.${NX_GLB}x${NY_GLB}.v20180328.nc" + FRUNOFF="runoff.daitren.clim.${NX_GLB}x${NY_GLB}.v20180328.nc" + MOM6_RIVER_RUNOFF='True' + MOM6_RESTART_SETTING="r" +elif [ $OCNRES = '050' ]; then + NX_GLB=720 + NY_GLB=576 + DT_DYNAM_MOM6='1800' + DT_THERM_MOM6='3600' + CHLCLIM="seawifs-clim-1997-2010.${NX_GLB}x${NY_GLB}.v20180328.nc" + FRUNOFF="runoff.daitren.clim.${NX_GLB}x${NY_GLB}.v20180328.nc" + MOM6_RESTART_SETTING='n' + MOM6_RIVER_RUNOFF='True' +elif [ $OCNRES = '100' ]; then + NX_GLB=360 + NY_GLB=320 + DT_DYNAM_MOM6='1800' + DT_THERM_MOM6='3600' + FRUNOFF="" + CHLCLIM="seawifs_1998-2006_smoothed_2X.nc" + MOM6_RESTART_SETTING='n' + MOM6_RIVER_RUNOFF='False' +else + echo "FATAL ERROR: do not have MOM6 settings defined for desired OCNRES=$OCNRES" + exit 1 +fi + + + cat >> input.nml < $DATA/INPUT/MOM_input +rm $DATA/INPUT/MOM_input_template_$OCNRES + +#data table for runoff: +DATA_TABLE=${DATA_TABLE:-$PARM_FV3DIAG/data_table} +$NCP $DATA_TABLE $DATA/data_table_template +sed -e "s/FRUNOFF/$FRUNOFF/g" $DATA/data_table_template > $DATA/data_table +rm $DATA/data_table_template + +}