Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 34 additions & 62 deletions scripts/exglobal_fcst_nemsfv3gfs.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/ksh
#!/bin/bash
################################################################################
## UNIX Script Documentation Block
## Script name: exglobal_fcst_nemsfv3gfs.sh
Expand Down Expand Up @@ -72,7 +72,6 @@
## 2. nems.configure
## 3. model_configure
## 4. input.nml

#######################
# Main body starts here
#######################
Expand All @@ -83,29 +82,8 @@ if [ $VERBOSE = "YES" ] ; then
set -x
fi

## Run in sandbox if no $machine defined
## Locate mod_forecast script folder
if [ -z $machine ]; then
machine='sandbox'
echo "MAIN: !!!Running in sandbox mode!!!"
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*)
SCRIPTDIR=$(dirname $(readlink -f "$0") )/../ush
echo "MAIN: Linux environment. Current Script locates in $SCRIPTDIR."
;;
Darwin*)
SCRIPTDIR=$(pwd)/../ush
echo "MAIN: MacOS environment. Current Script locates in $SCRIPTDIR."
;;
CYGWIN*) echo CYGWIN ;;
MINGW*) echo MinGw ;;
*) echo "UNKNOWN:${unameOut}"
esac
else
SCRIPTDIR=$(dirname $(readlink -f "$0") )/../ush
echo "MAIN: environment loaded for $machine platform,Current Script locates in $SCRIPTDIR."
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*
Expand All @@ -114,6 +92,7 @@ source $SCRIPTDIR/forecast_det.sh # include functions for run type determinatio
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'}
Expand All @@ -125,15 +104,12 @@ cplwav=${cplwav:-.false.} # ? how to control 1-way/2-way?
cplchem=${cplchem:-.false.} # Chemistry model
cplice=${cplice:-.false.} # ICE model

OCNTIM=${OCNTIM:-1800}
OCNTIM=${OCNTIM:-3600}
DELTIM=${DELTIM:-450}
ICETIM=${DELTIM}

CPL_SLOW=${OCNTIM}
CPL_FAST=${ICETIM}
# Coupling control switches, for coupling purpose, off by default

[[ $machine = 'sandbox' ]] && RUN=gfs
CPL_SLOW=${CPL_SLOW:-$OCNTIM}
CPL_FAST=${CPL_FAST:-$ICETIM}

echo "MAIN: $confignamevarfornems selected"
echo "MAIN: Forecast script started for $confignamevarfornems on $machine"
Expand All @@ -149,7 +125,7 @@ common_predet

echo $RUN
case $RUN in
'data') Data_ATM_setup;;
'data') DATM_predet;;
'gfs') FV3_GFS_predet;;
'gdas') FV3_GFS_predet;;
'gefs') FV3_GEFS_predet;;
Expand All @@ -174,6 +150,7 @@ 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;;
Expand All @@ -186,6 +163,7 @@ 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;;
Expand All @@ -194,7 +172,13 @@ esac #no namelist for data atmosphere
[[ $cplwav = .true. ]] && WW3_nml
[[ $cplice = .true. ]] && CICE_nml
[[ $cplchem = .true. ]] && GSD_nml
Common_model_configure

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"
Expand All @@ -204,39 +188,26 @@ echo "MAIN: NEMS configured"
#------------------------------------------------------------------
# run the executable

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
echo "MAIN: mpirun launch here"
fi
$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 [ $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
else
echo "MAIN: Running on sandbox mode, no output linking"
fi
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
echo "MAIN: Output copied to COMROT"

#------------------------------------------------------------------
# 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
Expand All @@ -246,5 +217,6 @@ if [ $err != 0 ]; then
exit $err
else
echo "MAIN: $confignamevarfornems Forecast completed at normal status"
if [ $mkdata = "YES" ]; then rm -rf $DATA; fi
exit 0
fi
1 change: 1 addition & 0 deletions ush/cplvalidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ cplvalidate(){
echo "SUB cplvalidate: validating cpl** switches for $confignamevarfornems"
case $confignamevarfornems in
'atm') combination=.false..false..false..false..false.;;
'datm') combination=.true..true..false..false..false.;;
'med_atm_ocn_ice') combination=.true..true..true..false..false.;;
'blocked_atm_wav') combination=.true..false..false..true..false.;;
'leapfrog_atm_wav')combination=.true..false..false..true..false.;;
Expand Down
104 changes: 79 additions & 25 deletions ush/forecast_postdet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ FV3_GEFS_postdet(){
# soft link commands insert here
}

DATM_postdet(){
######################################################################
# 3.1 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

# 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}"
ln -sf ${DATMINPUTDIR}/${DATM_FILENAME_BASE}*.nc $DATA/DATM_INPUT/
}

FV3_GFS_postdet(){

echo "SUB ${FUNCNAME[0]}: $RERUN and $warm_start determined for $RUN"
Expand Down Expand Up @@ -180,6 +195,16 @@ EOF
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 /scratch1/NCEPDEV/stmp2/Lin.Gan/RUNDIRS/gsdsuite-NEW/2019100900/gfs/fcst.383441/freezeH2O.dat freezeH2O.dat
$NCP /scratch1/NCEPDEV/stmp2/Lin.Gan/RUNDIRS/gsdsuite-NEW/2019100900/gfs/fcst.383441/qr_acr_qg.dat qr_acr_qg.dat
$NCP /scratch1/NCEPDEV/stmp2/Lin.Gan/RUNDIRS/gsdsuite-NEW/2019100900/gfs/fcst.383441/qr_acr_qs.dat 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
Expand Down Expand Up @@ -362,9 +387,9 @@ EOF
else
ISEED=${ISEED:-0}
fi
DO_SKEB=${DO_SKEB:-"NO"}
DO_SPPT=${DO_SPPT:-"NO"}
DO_SHUM=${DO_SHUM:-"NO"}
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}
Expand Down Expand Up @@ -415,6 +440,12 @@ FV3_GFS_nml(){
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
Expand Down Expand Up @@ -581,37 +612,57 @@ MOM6_out()
CICE_postdet()
{
echo "SUB ${FUNCNAME[0]}: CICE after run type determination"

year=$(echo $CDATE|cut -c 1-4)
#BL2018
stepsperhr=$((3600/$DT_CICE))
#BL2018
nhours=$(${NHOUR} ${CDATE} ${SYEAR}010100)
istep0=$((nhours*stepsperhr))
npt=$((FHMAX*$stepsperhr)) # Need this in order for dump_last to work

histfreq_n=${histfreq_n:-6}
restart_interval=${restart_interval:-1296000} # restart write interval in seconds, default 15 days
dumpfreq_n=$restart_interval # restart write interval in seconds

#BL2018
#dumpfreq='d'
#dumpfreq='s'
if [ -d $ROTDIR/../NEXT_IC ]; then
#continuing run "hot start"
RUNTYPE='continue'
USE_RESTART_TIME='.true.'
restart_pond_lvl=${restart_pond_lvl:-".true."}
else
#using cold start IC
RUNTYPE='initial'
USE_RESTART_TIME='.false.'
restart_pond_lvl=${restart_pond_lvl:-".false."}
fi

dumpfreq_n=${dumpfreq_n:-"${restart_interval}"}
dumpfreq=${dumpfreq:-"s"} # "s" or "d" or "m" for restarts at intervals of "seconds", "days" or "months"

iceres=${iceres:-"mx025"}
ice_grid_file=${ice_grid_file:-"grid_cice_NEMS_${iceres}.nc"}
ice_kmt_file=${ice_kmt_file:-"kmtu_cice_NEMS_${iceres}.nc"}

#TODO iceic name... this might need to be update?
iceic="cice5_model.res_$CDATE.nc"

# Copy CICE5 IC - pre-generated from CFSv2
cp -p $ICSDIR/$CDATE/cice5_model_0.25.res_$CDATE.nc $DATA/cice5_model.res_$CDATE.nc
cp -p $ICSDIR/$CDATE/cice5_model_0.25.res_$CDATE.nc $DATA/$iceic
#cp -p $ICSDIR/$CDATE/cpc/cice5_model_0.25.res_$CDATE.nc ./cice5_model.res_$CDATE.nc

# Copy CICE5 fixed files, and namelists
cp -p $FIXcice/kmtu_cice_NEMS_mx025.nc $DATA/
cp -p $FIXcice/grid_cice_NEMS_mx025.nc $DATA/
echo "Link CICE fixed files"
ln -sf $FIXcice/${ice_grid_file} $DATA/
ln -sf $FIXcice/${ice_kmt_file} $DATA/

# Copy grid_spec and mosaic files
cp -pf $FIXgrid/$CASE/${CASE}_mosaic* $DATA/INPUT/
cp -pf $FIXgrid/$CASE/grid_spec.nc $DATA/INPUT/
cp -pf $FIXgrid/$CASE/ocean_mask.nc $DATA/INPUT/
cp -pf $FIXgrid/$CASE/land_mask* $DATA/INPUT/

iceic=cice5_model.res_$CDATE.nc
year=$(echo $CDATE|cut -c 1-4)
#BL2018
stepsperhr=$((3600/$ICETIM))
#BL2018
nhours=$($NHOUR $CDATE ${year}010100)
steps=$((nhours*stepsperhr))
npt=$((FHMAX*$stepsperhr)) # Need this in order for dump_last to work

histfreq_n=${histfreq_n:-6}
restart_interval=${restart_interval:-1296000} # restart write interval in seconds, default 15 days
dumpfreq_n=$restart_interval # restart write interval in seconds

#BL2018
#dumpfreq='d'
#dumpfreq='s'

}

CICE_nml()
Expand Down Expand Up @@ -683,3 +734,6 @@ GSD_out()
echo "SUB ${FUNCNAME[0]}: Copying output data for GSD"
# soft link commands insert here
}



20 changes: 19 additions & 1 deletion ush/forecast_predet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ common_predet(){
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}
Expand Down Expand Up @@ -83,7 +97,11 @@ FV3_GFS_predet(){
NTHREADS_FV3=${NTHREADS_FV3:-${NTHREADS_FCST:-${nth_fv3:-1}}}
cores_per_node=${cores_per_node:-${npe_node_max:-24}}
ntiles=${ntiles:-6}
NTASKS_TOT=${NTASKS_TOT:-$npe_fcst}
if [ $MEMBER -lt 0 ]; then
NTASKS_TOT=${NTASKS_TOT:-$npe_fcst}
else
NTASKS_TOT=${NTASKS_TOT:-$npe_efcs}
fi

TYPE=${TYPE:-"nh"} # choices: nh, hydro
MONO=${MONO:-"non-mono"} # choices: mono, non-mono
Expand Down
Loading