[Dart-dev] [10618] DART/trunk/models/mpas_atm/shell_scripts: updated scripts contributed by soyoung ha, mmm, ncar.

nancy at ucar.edu nancy at ucar.edu
Mon Aug 15 09:42:38 MDT 2016


Revision: 10618
Author:   nancy
Date:     2016-08-15 09:42:38 -0600 (Mon, 15 Aug 2016)
Log Message:
-----------
updated scripts contributed by soyoung ha, mmm, ncar.
thank you!

Modified Paths:
--------------
    DART/trunk/models/mpas_atm/shell_scripts/advance_model.csh
    DART/trunk/models/mpas_atm/shell_scripts/run_filter_mpas.csh

-------------- next part --------------
Modified: DART/trunk/models/mpas_atm/shell_scripts/advance_model.csh
===================================================================
--- DART/trunk/models/mpas_atm/shell_scripts/advance_model.csh	2016-08-12 22:19:32 UTC (rev 10617)
+++ DART/trunk/models/mpas_atm/shell_scripts/advance_model.csh	2016-08-15 15:42:38 UTC (rev 10618)
@@ -23,10 +23,6 @@
 # 9.  Saves the mpas analysis file for each member if save_analysis = true
 #10.  Saves the mpas forecast file for each member if save_forecast = true
 #11.  Saves u on the edges if save_analysis = false and use_u_wind = false (for extended forecasts later)
-#12.  Saves diagnostic variables at pressure levels (both for analysis and forecast at the cycle)
-#     if save_diag_plev = true 
-#     For this, you need to create an mpas output (not restart) file at the target time
-#     since only mpas output files print out those diagnostic fields at pressure levels.
 #
 # Note: 1. MPAS is run in a restart mode during the cycles, which means
 #          both input and output will be restart files.
@@ -73,17 +69,17 @@
 set CENTRALDIR = `pwd`
 
 # Do you want to save the analysis file?
-set save_analysis = false
+set save_analysis = true
 
 # Do you want to save the forecast at the target time?
 set save_forecast = false
 
-# Do you want to save the diagnostic variables at pressure levels? (true or false)
-set save_diag_plev = true 
+# Do you want to save normal speed (u) in the forecast at the target time?
+set save_prior_uedge = true 
 
 #
 set  REMOVE = 'rm -rf'
-set    COPY = 'cp -p'
+set    COPY = 'cp -pf'
 set    MOVE = 'mv -f'
 set    LINK = 'ln -sf'
 unalias cd
@@ -105,9 +101,9 @@
       exit 1
    endif
 
-   if ( ! -x ${CENTRALDIR}/MPAS_RUN/nhyd_atmos_model.exe ) then
+   if ( ! -x ${CENTRALDIR}/MPAS_RUN/atmosphere_model ) then
      echo ABORT\: advance_model.csh could not find required executable dependency 
-     echo         ${CENTRALDIR}/MPAS_RUN/nhyd_atmos_model.exe
+     echo         ${CENTRALDIR}/MPAS_RUN/atmosphere_model    
      exit 1
    endif
 
@@ -116,8 +112,8 @@
      exit 1
    endif
 
-   if ( ! -r ${CENTRALDIR}/namelist.input ) then
-     echo ABORT\: advance_model.csh could not find required readable dependency ${CENTRALDIR}/namelist.input
+   if ( ! -r ${CENTRALDIR}/namelist.atmosphere ) then
+     echo ABORT\: advance_model.csh could not find required readable dependency ${CENTRALDIR}/namelist.atmosphere
      exit 1
    endif
 
@@ -139,37 +135,43 @@
    # Create a new temp directory for each member unless requested to keep and it exists already.
    set temp_dir = 'advance_temp'${ensemble_member}
 
-   if(! -d $temp_dir) mkdir -p $temp_dir  || exit 1
-   cd $temp_dir  || exit 1
+   if(! -d $temp_dir) mkdir -p $temp_dir                || exit 1
+   cd $temp_dir  
 
    # Get the program and necessary files for the model
-   ${LINK} ${CENTRALDIR}/MPAS_RUN/nhyd_atmos_model.exe .         || exit 1
-   ${LINK} ${CENTRALDIR}/MPAS_RUN/*BL                  .         || exit 1
-   ${LINK} ${CENTRALDIR}/advance_time                  .         || exit 1
+   ${LINK} ${CENTRALDIR}/atmosphere_model     .         || exit 2
+   ${LINK} ${CENTRALDIR}/streams.atmosphere   .         || exit 3
+   ${LINK} ${CENTRALDIR}/stream_list.atmosphere.* .     || exit 4
+   ${LINK} ${CENTRALDIR}/*BL                  .         || exit 5
+   ${LINK} ${CENTRALDIR}/*DATA                .         || exit 6
+   ${LINK} ${CENTRALDIR}/advance_time         .         || exit 7
 
    # Get the namelists
-   ${COPY} ${CENTRALDIR}/input.nml      .                        || exit 1
-   ${COPY} ${CENTRALDIR}/namelist.input namelist.input.template  || exit 1
+   if( -e input.nml) ${REMOVE} input.nml
+   ${COPY} ${CENTRALDIR}/input.nml      .               || exit 8
+   ${COPY} ${CENTRALDIR}/namelist.atmosphere namelist.atmosphere.template  || exit 9
 
    # Get the grid info files - now for PIO
-   set is_grid_info = `grep config_block_decomp_file_prefix namelist.input.template | wc -l`
+   set is_grid_info = `grep config_block_decomp_file_prefix namelist.atmosphere.template | wc -l`
    if( $is_grid_info != 1 ) then
        echo Cannot find grid info. Stop.
        exit
    endif
-   set fs_grid = `grep config_block_decomp_file_prefix namelist.input.template | awk '{print $3}' | sed -e "s/'//g"`
-   ${LINK} ${CENTRALDIR}/MPAS_RUN/${fs_grid}* .
+   set fs_grid = `grep config_block_decomp_file_prefix namelist.atmosphere.template | awk '{print $3}' | sed -e "s/'//g"`
+   set  x_grid = `echo $fs_grid | cut -d . -f1`
+   set  n_grid = `echo $fs_grid | cut -d . -f2`
+   set  f_grid = $x_grid.$n_grid
+   ${LINK} ${CENTRALDIR}/${fs_grid}* .
 
-   # Surface update
-   set if_sfc_update = `grep config_sst_update namelist.input.template | awk '{print $3}'`
+   # Surface update - FIXME: No idea how to grab the surface file name (defined in streams.atmosphere)
+   set if_sfc_update = `grep config_sst_update namelist.atmosphere.template | awk '{print $3}'`
    if($if_sfc_update == .true.) then
-      set fsfc = `grep config_sfc_update_name namelist.input.template | awk '{print $3}' | sed "s/'//g"`
-      if(-e ${CENTRALDIR}/MPAS_RUN/$fsfc) then
-         echo ${LINK} ${CENTRALDIR}/MPAS_RUN/$fsfc .
-         ${LINK} ${CENTRALDIR}/MPAS_RUN/$fsfc .
+      set fsfc = `ls -1 ${CENTRALDIR}/*sfc_update*.nc | tail -1`
+      if(-e $fsfc) then
+         ${LINK} $fsfc .
          ls -lL $fsfc						|| exit
       else
-         echo $fsfc does not exist in ${CENTRALDIR}/MPAS_RUN/.  || exit
+         echo $fsfc does not exist.  || exit
       endif
    endif
 
@@ -177,69 +179,61 @@
    set f1 = `grep  dart_to_model_input_file input.nml | awk '{print $3}' | cut -d ',' -f1 | sed -e "s/'//g"`
    set f2 = `grep model_to_dart_output_file input.nml | awk '{print $3}' | cut -d ',' -f1 | sed -e "s/'//g"`
    set f3 = `grep   model_analysis_filename input.nml | awk '{print $3}' | cut -d ',' -f1 | sed -e "s/'//g"`
+   set f4 = `grep  grid_definition_filename input.nml | awk '{print $3}' | cut -d ',' -f1 | sed -e "s/'//g"`
 
+   if(! -e $f4) ${LINK} ${CENTRALDIR}/$f4 .
+
    #----------------------------------------------------------------------
    # Block 2: move/convert the DART state vector to the model netcdf file.
    #----------------------------------------------------------------------
-   set ff = `echo $f3 | cut -d . -f1`
+   set ff = `basename $f3 .nc`
    set fn = ${ff}.e${ensemble_member}.nc
 
    if(! -e ${f3}) then
-      #if(! -e ${CENTRALDIR}/$fn) then
-      #   echo ABORT\: ${CENTRALDIR}/$fn does not exist.
-      #   exit
-      #endif
-     echo ${COPY} ${CENTRALDIR}/$fn ${f3}      
-          ${COPY} ${CENTRALDIR}/$fn ${f3}           || exit 2
-     # echo ${COPY} ${CENTRALDIR}/$f3 ${f3}
-     #      ${COPY} ${CENTRALDIR}/$f3 ${f3}           || exit 2
+      if(! -e ${CENTRALDIR}/$fn) then
+         echo ABORT\: ${CENTRALDIR}/$fn does not exist.
+         exit
+      endif
+      echo ${COPY} ${CENTRALDIR}/$fn ${f3}      
+           ${COPY} ${CENTRALDIR}/$fn ${f3}           || exit 2
    endif
-
+   
    ${MOVE} ${CENTRALDIR}/$input_file $f1 || exit 2
-
+   
    # Overwrite a template file (or prior) with the analysis from filter.
    # That is, f3 is updated by f1 here.
    ${CENTRALDIR}/dart_to_model >&! out.dart_to_model
-
+    
    # The program dart_to_model has created an ascii file named mpas_time.
    # Time information is extracted from the file.
    set curr_utc = `head -1 mpas_time | tail -1`		|| exit
    set targ_utc = `head -2 mpas_time | tail -1`
    set intv_utc = `head -3 mpas_time | tail -1`
+   set targ_pio = `echo ${targ_utc} | sed -e 's/:/\./g'`
 
-   ${MOVE} out.dart_to_model out.dart_to_model.${curr_utc}
-
-   set if_DAcycling = `grep config_do_DAcycling namelist.input.template | wc -l`
-   if($if_DAcycling == 0) then
-      echo Please add config_do_DAcycling = .true. in &restart
-      echo in ${CENTRALDIR}/namelist.input.
-      exit -1
+   # Sanity check - if there is any Not-A-Number of Infinity values.
+   set drange = `grep "min/max" out.dart_to_model | awk '{print $4,$5}'`
+   set is_nan = `echo $drange | grep '[a-zA-Z]' | wc -l`
+   if($is_nan == 1) then
+      echo Error in dart_to_model: Something bad happened in the analysis. Stop.
+      exit
    endif
-        
-   set ftype = "restart"
-   set finit = "config_"${ftype}"_name"
-   set fhead = `basename $f3 .nc`
-   set f3new = ${fhead}.${curr_utc}.nc
-   set fname = "config_"${ftype}"_name"
-   set fintv = "config_"${ftype}"_interval"
-   set fjunk = `grep config_output_name namelist.input.template | awk '{print $3}' | sed -e "s/'//g"`
-   set fremove = `basename $fjunk .nc`
 
+   ${MOVE} out.dart_to_model out.dart_to_model.${curr_utc}.txt
+
    # Rename the restart file for PIO
+   set f3new = ${ff}.${curr_utc}.nc
    set f3pio = `echo ${f3new} | sed -e 's/:/\./g'`
 
-   # In a restart mode, the model looks for an IC filename not as specified in 
-   # config_restart_name, but as ${finit}.${date_in_pio_format}.nc.
-   # In other words, the actual initial file name should be in a new form 
-   # including the date info as in PIO format to run the model.
-   # This is neither straightforward nor consistent with the way we define the model input 
-   # file in DART (i.e., model_analysis_filename) to run model_to_dart after the model run. 
+   # In a restart mode, the initial file name should be provided in a new form 
+   # including the date info in PIO format. On the other hand, DART/input.nml
+   # does not use the date info in the model_analysis_filename.
    # So we just make a link between the two different filenames here.
    ${LINK} $f3 ${f3pio}
 
    #----------------------------------------------------------------------
    # Block 3: advance the model
-   #          Make sure the file name is consistent in the namelist.input.
+   #          Make sure the file name is consistent in the namelist.atmosphere.
    #          Mar-21-2013: To save the variables at pressure levels,
    #          we print out output files as well. 
    #----------------------------------------------------------------------
@@ -247,55 +241,43 @@
    /config_start_time/c\
    config_start_time = '$curr_utc'
    /config_stop_time/c\
-   config_stop_time ='$targ_utc'
+   config_stop_time = '$targ_utc'
    /config_run_duration/c\
    config_run_duration = '$intv_utc'
-   /config_output_interval/c\
-   config_output_interval    = '$intv_utc'
-   /$fintv/c\
-   $fintv = '$intv_utc'
-   /$finit/c\
-   $finit = '$f3'
-   /config_frames_per_outfile/c\
-   config_frames_per_outfile = 1
 EOF
-# The EOF on the line above MUST REMAIN in column 1.
+   sed -f script.sed namelist.atmosphere.template >! namelist.atmosphere
 
-   sed -f script.sed namelist.input.template >! namelist.input
-
-   cat >! restart.sed << EOF
-   /config_do_restart /c\
-   config_do_restart = .true.
-   /config_do_DAcycling /c\
-   config_do_DAcycling       = .true.
-EOF
-
-   ${MOVE} namelist.input namelist.input.temp
-   sed -f restart.sed namelist.input.temp >! namelist.input
-
    # clean out any old rsl files
    if ( -e log.0000.out ) ${REMOVE} log.*
 
    # mpi run on Yellowstone
-   mpirun.lsf ./nhyd_atmos_model.exe || exit 3
+   mpirun.lsf ./atmosphere_model        || exit 3
+   sleep 60
 
-   # mpi run on Mac OS
-   #mpiexec -n 4 ./nhyd_atmos_model.exe || exit 3
-
    # Check the status
-   ls -lrt > list.${curr_utc}
+   ls -lrt > list.${curr_utc}.txt
   
+   # Check if it is in a restart mode or not
+   set if_restart = `grep config_do_restart   namelist.atmosphere | awk '{print $3}'`
+   set if_cycling = `grep config_do_DAcycling namelist.atmosphere | awk '{print $3}'`
+   if($if_restart == .false. && $if_cycling == .false.) then
+      set fh = `basename $ff .init`
+      set ff = $fh.restart
+   endif
+
    # Model output at the target time
-   set fout = ${fhead}.`echo ${targ_utc} | sed -e 's/:/\./g'`.nc
+   set fout = ${ff}.`echo ${targ_utc} | sed -e 's/:/\./g'`.nc
    set date_utc = `ncdump -v xtime $fout | tail -2 | head -1 | cut -d";" -f1 | sed -e 's/"//g'`
    set targ_grg = `echo $date_utc 0 -g | advance_time`
    set targ_day = $targ_grg[1]
    set targ_sec = $targ_grg[2]
 
    # Check if the model was succefully completed.
-   if($date_utc != $targ_utc) then
-      echo $ensemble_member >>! ${CENTRALDIR}/blown_${targ_day}_${targ_sec}.out
-      echo "Model failure! Check file " ${CENTRALDIR}/blown_${targ_day}_${targ_sec}.out
+   set fatal_err = `grep -i abort log.0000.err | cat | wc -l`
+   if(($fatal_err != 0) || ($date_utc != $targ_utc)) then
+      mv log.0000.err log.failed.${targ_utc}.txt
+      echo $ensemble_member >>! ${CENTRALDIR}/blown_${targ_utc}.out
+      echo "Model failure! Check file " ${CENTRALDIR}/blown_${targ_utc}.out
       exit 1
    endif
 
@@ -305,45 +287,34 @@
    set f3utc = `echo ${curr_utc} 0 | advance_time`
    set if_u_used = `grep use_u_for_wind input.nml | awk '{print $3}' | cut -d ',' -f1`
    if ( $if_u_used == .false. ) then
-        ncks -v xtime,u $f3 analysis.uedge.${f3utc}.nc
-        ls -l analysis.uedge.${f3utc}.nc
+        set f_wind = analysis.uedge.${f3utc}.nc
+        echo ncks -O -v xtime,u $f3 ${f_wind}
+             ncks -O -v xtime,u $f3 ${f_wind}
    else
-        ncks -v xtime,uReconstructZonal,uReconstructMeridional $f3 analysis.uv.${f3utc}.nc
-        ls -l analysis.uv.${f3utc}.nc
+        set f_wind = analysis.uv.${f3utc}.nc
+        ncks -O -v xtime,uReconstructZonal,uReconstructMeridional $f3 ${f_wind}
    endif
-   if ( $save_analysis == true ) then
-        set f3out = mpas_anal.${f3utc}.nc
-        ${MOVE} $f3 ${f3out}
-   endif
+   ls -l ${f_wind}
 
-   if ( $save_diag_plev == true ) then
-        set f3out = ${fremove}.${curr_utc}.nc
-        set f3anl = `echo ${f3out} | sed -e 's/:/\./g'`
-        set vlist = `ncdump -h ${f3anl} | grep hPa | awk '{print $2}' | cut -d "(" -f1`
-        set vstr  = ""
-        foreach v ( $vlist )
-          set vstr = `echo $vstr,$v`
-        end
-        set vars = `echo $vstr | cut -c2-`
-        set var2d = "u10,v10,q2,t2m,th2m,skintemp"
-        set vars = `echo xtime,$vars,$var2d`
-        ncks -v $vars ${f3anl} -O anal_diag_plevs.${f3utc}.nc
- 
-        set f3utc = `echo ${targ_utc} 0 | advance_time`
-        set f3out = ${fremove}.${targ_utc}.nc
-        set f3run = `echo ${f3out} | sed -e 's/:/\./g'`
-        if(! -e ${f3run}) then
-           echo Trying to save diagnostic variables at pressure levels, 
-           echo but ${f3run} does not exist. Stop.
-           exit
-        endif
-        set var2d = "u10,v10,q2,t2m,th2m,skintemp,rainc,rainnc,hpbl,hfx,qfx,lh"
-        set vars = `echo xtime,$vars,$var2d`
-        ncks -v $vars ${f3run} -O fcst_diag_plevs.${f3utc}.nc
+   set f3out = mpas_anal.${f3utc}.nc
+   ${MOVE} $f3 ${f3out}
+
+   if( ! -e ${f_wind} ) then
+       if(! -e ${f3out} ) then
+	  echo Neither ${f_wind} or ${f3out} exists. We stop here.
+          echo You cannot run extended forecasts from the mean EnKF analysis at this cycle later. 
+          exit
+       else 
+          set date_anl = `ncdump -v xtime ${f3out} | tail -2 | head -1 | cut -d";" -f1 | sed -e 's/"//g'`
+          set    tanal = `echo $date_anl 0 | advance_time`
+          if($tanal != ${f3utc}) then
+             echo ${f3out} has wrong time. $tanal should be ${f3utc}. Stop.
+             exit
+          endif  
+       endif
    endif
+   if( -e ${f3pio}) ${REMOVE} ${f3pio}
 
-   ${REMOVE} ${f3pio} ${fremove}.*.nc
-
    #-------------------------------------------------------------------
    # Block 4: Convert your model output to a DART format ics file,
    #          then move it back to CENTRALDIR
@@ -351,17 +322,47 @@
    #          temp directory
    #-------------------------------------------------------------------
    # Overwrite the analysis file with the forecast at target time (for the next cycle).
+   set futc = `echo ${targ_utc} 0 | advance_time`
+   set fsav = mpas_fcst.${futc}.nc
+   if ( $save_prior_uedge == true ) then
+        if ( $if_u_used == .false. ) then
+        set f_wind = forecast.uedge.${futc}.nc
+        echo ncks -O -v xtime,u $fout ${f_wind}
+             ncks -O -v xtime,u $fout ${f_wind}
+        else
+        set f_wind = forecast.uv.${futc}.nc
+        ncks -O -v xtime,uReconstructZonal,uReconstructMeridional $fout ${f_wind}
+        endif
+   endif
    if ( $save_forecast == true ) then
-        set futc = `echo ${targ_utc} 0 | advance_time`
-        set fsav = mpas_fcst.${futc}.nc
         echo ${COPY} $fout $fsav
              ${COPY} $fout $fsav	|| exit 5
    endif
-   ${MOVE} $fout $f3   	 		|| exit 6
 
+   # Get ready to run with full state vectors in a restart mode from the second cycle.
+   if($if_restart == .false. && $if_cycling == .false.) then
+      ${COPY} ${CENTRALDIR}/input.nml.filter input.nml || exit
+      set f3 = `grep model_analysis_filename input.nml | awk '{print $3}' | cut -d ',' -f1 | sed -e "s/'//g"`
+   endif
+
+   echo ${MOVE} $fout $f3
+        ${MOVE} $fout $f3   	 		|| exit 6
+
    ${CENTRALDIR}/model_to_dart >&! out.model_to_dart.${date_utc}
-   ${MOVE} $f2 ${CENTRALDIR}/$output_file || exit 7
 
+   # Sanity check - if there is any Not-A-Number or Infinity values.
+   set vrange = `grep "min/max" out.model_to_dart.${date_utc} | awk '{print $4,$5}'`
+   set is_nan = `echo $vrange | grep '[a-zA-Z]' | wc -l`
+   if($is_nan == 1) then
+      echo Error in model_to_dart: Something bad happened in mpas forecast. Stop.
+      exit
+   endif
+
+   echo ${MOVE} $f2 ${CENTRALDIR}/$output_file 
+        ${MOVE} $f2 ${CENTRALDIR}/$output_file || exit 7
+
+   if ( $save_analysis == false ) ${REMOVE} ${f3out}
+
    # Change back to original directory.
    cd $CENTRALDIR
 

Modified: DART/trunk/models/mpas_atm/shell_scripts/run_filter_mpas.csh
===================================================================
--- DART/trunk/models/mpas_atm/shell_scripts/run_filter_mpas.csh	2016-08-12 22:19:32 UTC (rev 10617)
+++ DART/trunk/models/mpas_atm/shell_scripts/run_filter_mpas.csh	2016-08-15 15:42:38 UTC (rev 10618)
@@ -13,13 +13,13 @@
 #  THIS IS A TOP-LEVEL DRIVER SCRIPT TO RUN FILTER AND THE MPAS MODEL BOTH IN AN MPI VERSION.
 #
 #  This is a sample script for a retrospective case study, and was tested on
-#  NCAR IBM Supercomputer (bluefire) using a "bsub" command.
+#  NCAR IBM Supercomputer (yellowstone and yellowstone) using a "bsub" command.
 #  Any back-up option to the hpss storage is not supported here. 
 #  Instead, all the outputs will be locally stored. 
 #  Check your disk space before running this script.
 #
 #  Required file to run this script:
-#  1. namelist.input          (for mpas) - a namelist template for the mpas model run.
+#  1. namelist.atmosphere     (for mpas) - a namelist template for the mpas model run.
 #  2. advance_model.csh       (for mpas) - which decides how to update the model states.
 #  3. mpas_init.nc            (for mpas) - you can change the filename below (mpas_fname).
 #  4. input.nml               (for filter) - a namelist template for filter. 
@@ -27,29 +27,41 @@
 #  6. filter.template.lsf     (for an mpi filter run; with async >= 2)
 #  7. advance_model.template.lsf (for an mpi mpas run; using separate nodes)
 #
-#  Note: For your own complete filter design, you need to edit your input.nml
-#        for the parameters which are not set up in "Assimilation parameters" below.
-#        At least double-check your &filter_nml, &obs_kind_nml, &model_nml, &location_nml 
-#        and &mpas_vars_nml before running this script.
+#  Note1: For your own complete filter design, you need to edit your input.nml
+#         for the parameters which are not set up in "Assimilation parameters" below.
+#         At least double-check your &filter_nml, &obs_kind_nml, &model_nml, &location_nml 
+#         and &mpas_vars_nml before running this script.
+#  Note2: The mpas model configurations are not edited in this script.
+#         Thus, namelist.atmosphere is assumed to be all set up before being called here.
+#  Note3: advance_model.csh takes all the necessary files for the model run from MPAS_RUN/
+#         except for an initial condition (e.g., analysis from DART).
+#  Note4: All the logical parameters are case-sensitive. They should be either true or false.
+# 
+#  Note5: Before running this script, we assume that
+#         - both mpas and dart are successfully compiled.
+#         - Initial ensemble forecasts are ready in both mpas netcdf format and DART binary format in IENS_DIR/
+#         - All the observations are ready in OBS_DIR/ for all cycles.
 #
 #  Input files to run filter:
-#  1. FG_DIR/${restart_in} - first guess in dart format for the initial cycle (ex. filter_ics)
-#                            Can be generated by $DART_DIR/../shell_scripts/make_filter_ics.csh.
+#  1. FG_DIR/${restart_in} - first guess in dart binary format for the initial cycle (ex. filter_ics)                           
 #  2. OBS_DIR/YYYYMMDDHH/${obs_seq_in} - an obs sequence file for each analysis cycle.
 #
-#  Output from this script will be all stored in $RUN_DIR/${expname}/YYYYMMDDHH/.
+#  Output from this script will be all stored in $RUN_DIR/YYYYMMDDHH/ for each analysis cycle.
 #
-#  Written by So-Young Ha (MMM/NCAR) Sep-30-2011
-#
+#  Written by Soyoung Ha (MMM/NCAR) Sep-30-2011
+#  Updated by Soyoung Ha (MMM/NCAR) Apr-16-2013 for yellowstone
 ##############################################################################################
 # Experiment name and the cycle period
 #--------------------------------------------------------------------------
-set  expname = OSSE2			# experiment name
-set date_ini = 2008-08-01_12:00:00	# initial cycle for this experiment
-set date_beg = 2008-08-01_12:00:00	# start date to run this script
-set date_end = 2008-08-11_00:00:00	# end date to run this script
+set echo
+
+set  expname = OSSE			# experiment name
+set init_cyc = 2008080112               # initial cycle (YYYYMMDDHH)
+set date_ini = 2008-08-01_12:00:00	# initial cycle for this experiment in UTC format
+set date_beg = 2008-08-01_12:00:00	# start date to run this script in UTC format
+set date_end = 2008-08-31_00:00:00	# end date to run this script in UTC format
 set intv_day = 0			# cycling frequency - assimilation_period_days    in input.nml
-set intv_sec = 43200			# cycling frequency - assimilation_period_seconds in input.nml
+set intv_sec = 21600			# cycling frequency - assimilation_period_seconds in input.nml
 #--------------------------------------------------------------------------
 # Assimilation parameters (Logical parameters should be true or false (case-sensitive.))
 #--------------------------------------------------------------------------
@@ -61,27 +73,27 @@
 				# And you also need to edit inf_sd_initial, inf_damping,
 				# inf_lower_bound, and inf_sd_lower_bound in &filter_nml.
 set single_restart = false	# true if all copies read from and written to a single file in filter.
-set use_u_for_wind = true	# Use normal velocity ('u') on edges for wind assimilation
+set use_u_for_wind = false	# Use normal velocity ('u') on edges for wind assimilation
 set output_ens_obs = true	# Print out ensemble observations in the output obs sequence file.
 #--------------------------------------------------------------------------
 # Configuration for cycling
 #--------------------------------------------------------------------------
-set   mpas_restart = true 	# true if each mpas run starts with a restart (not output) file.
-set   sav_analysis = true	# true if you want to save the ensemble analysis locally (in ENS_DIR).
+set   sav_ens_anal = true	# true if you want to save the ensemble analysis locally (in ENS_DIR).
+set   sav_ens_fcst = false	# true if you want to save the ensemble forecast locally (in ENS_DIR).
 #--------------------------------------------------------------------------
 # Directories
 #--------------------------------------------------------------------------
 set DART_DIR = /mmm/mmmtmp/syha/MPAS/DART/models/mpas_atm/work	# where dart executables exist
-set MPAS_DIR = /mmm/mmmtmp/syha/MPAS/r1496             		# where all the aux files exist to run mpas
-set  OBS_DIR = OBS_SEQ						# where all obs sequence files exist
+set MPAS_DIR = /mmm/mmmtmp/syha/MPAS             		# where all the auxiliary files exist to run mpas
+set  OBS_DIR = /mmm/mmmtmp/syha/OBS_SEQ				# where all obs sequence files exist
 set  RUN_DIR = `pwd`						# top-level working directory
-set   FG_DIR = $RUN_DIR/$expname/2008080112                     # where filter_ics exists for initial cycle
-set  OUT_DIR = $RUN_DIR/$expname				# storage for output
-set  ENS_DIR = /ptmp/syha/MPAS/ENS   # where a background forecast exists for each member 
-                                     # ex. ENS_#/${mpas_fhead}.${date_beg}.nc for an initial cycle
-                                     #     advance_temp#/${mpas_fname}.nc for other cycles
+set   FG_DIR = $RUN_DIR/${init_cyc}                             # where filter_ics exists for initial cycle (2008-08-01_12 UTC)
+set  OUT_DIR = $RUN_DIR      				        # storage for output - a subdirectory for each cycle will be
+                                                                # automatically generated during cycles
+set  ENS_DIR = advance_temp                                     # each ensemble member directory (under $RUN_DIR)
+set IENS_DIR = /mmm/mmmtmp/syha/INITIAL_ENSEMBLE                # initial ensemble directory (for the initial cycle)
 #--------------------------------------------------------------------------
-# File naming convention
+# File naming convention - you may not need to change dart file names.
 #--------------------------------------------------------------------------
 set restart_in  = filter_ics
 set restart_out = filter_restart
@@ -89,15 +101,19 @@
 set    infl_out = prior_inflate_restart
 set obs_seq_in  = obs_seq.out
 set obs_seq_out = obs_seq.final
-set  mpas_fname = mpas_init	# both for the analysis and the grid files (without .nc)
-set  mpas_fhead = x1.10242.restart	# prefix of a template file (in ENS_DIR for the initial cycle)
+
+set    mpas_exe = atmosphere_model      # mpas model executable
+set    mpas_grd = x1.10242              # mpas grid info    
+set   mpas_fini = mpas_init	        # can be used for both the analysis and the grid info files (without .nc)
+set   mpas_frst = x1.10242.restart	# prefix of a template file (in ENS_DIR for the initial cycle)
 					# should be matched with either config_output_name or 
-                                        # config_restart_name in namelist.input (without .nc)
+					# config_restart_name in namelist.atmosphere (without .nc)
+
 #--------------------------------------------------------------------------
-# LSF setup on NCAR bluefire (only if $bsub_in_ibm = yes)
+# LSF setup on NCAR yellowstone (only if $bsub_in_ibm = yes)
 #--------------------------------------------------------------------------
-set  bsub_in_ibm = yes  	# run on bluefire? yes or no.
-set  PROJ_NUMBER = 64000103	# Account key to submit filter and mpas jobs in bluefire
+set  bsub_in_ibm = yes  	# run on yellowstone? yes or no.
+set  PROJ_NUMBER = NMMM000x	# Account key to submit filter and mpas jobs in yellowstone
 set  time_filter = 00:20	# wall clock time for mpi filter runs
 
 ####################################################################################
@@ -111,10 +127,21 @@
 unalias cd
 unalias ls
 
+echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'    
+echo Running $0 at $RUN_DIR
+echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'  
+echo We edit input.nml for DART thru this script,
+echo but the MPAS model configuration is assumed to be all setup thru
+echo namelist.atmosphere and stream files (except for the cycling part).    
+echo
+cat namelist.atmosphere
+echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++'  
+echo
+
 #------------------------------------------
 # Check if we have all the necessary files.
 #------------------------------------------
-foreach fn ( input.nml namelist.input )
+foreach fn ( input.nml namelist.atmosphere )
   if ( ! -r $fn ) then
       echo ABORT\: We cannot find required readable dependency $fn.
   endif 
@@ -127,37 +154,49 @@
 
 # Update advance_model.csh
 cat >! config_restart.sed << EOF
-/set is_restart/c\
-set is_restart = ${mpas_restart}
+/set save_forecast/c\
+set save_forecast = ${sav_ens_fcst}
 /set save_analysis/c\
-set save_analysis = ${sav_analysis}
+set save_analysis = ${sav_ens_anal}
 EOF
 if(-e advance_new.csh) ${REMOVE} advance_new.csh
 sed -f config_restart.sed advance_model.csh >! advance_new.csh
 ${MOVE} advance_new.csh advance_model.csh
 chmod +x advance_model.csh
 
-# For an initial cycle, we already linked the mpas template files 
-# thru make_filter_ics.csh. But if you start this script in the middle
-# of the cycling, you need to make sure that a correct background
-# forecast is linked in each ensemble member directory.
 
+#------------------------------------------
+# Initialize the first cycle
+    
 set ie = 1
 while ( $ie <= $nens )
 if($date_ini == $date_beg) then
-# ${LINK} ${ENS_DIR}_${ie}/${mpas_fhead}.${date_beg}.nc ${mpas_fname}.e${ie}.nc
+
+  # Get all the initial ensemble files ready.
+  if( $ie == 1 && ! -d ${FG_DIR}) mkdir -p ${FG_DIR}
+  set icnum = `echo $ie + 10000 | bc | cut -b2-5`
+  set mpas_fname = ${mpas_fini}
+  if(! -e ${FG_DIR}/${mpas_fname}.e${ie}.nc) ${LINK} ${IENS_DIR}/${mpas_fname}.e${ie}.nc ${FG_DIR}/	|| exit
+  if(! -e ${FG_DIR}/${restart_in}.${icnum})  ${LINK} ${IENS_DIR}/${restart_in}.${icnum} ${FG_DIR}/	|| exit
+  ${LINK} ${FG_DIR}/${mpas_fname}.e${ie}.nc .		|| exit
+  ${LINK} ${FG_DIR}/${restart_in}.${icnum} .      	|| exit
+  if(-d ${ENS_DIR}1) ${REMOVE} ${ENS_DIR}*
+
 else
+
+  echo "Skip initializing ensemble..."
   set mpas_temp = ${ENS_DIR}${ie}/${mpas_fname}.nc
   set time_ie = `ncdump -v xtime ${mpas_temp} | tail -2 | head -1 | awk '{print $1}' | cut -c2-`
   if($time_ie != $date_beg) then
-     echo ABORT\: $mpas_temp should have the time $date_beg, but has $time_ie. Stop.
+     echo $mpas_temp should have the time $date_beg, but has $time_ie. Stop.
+     exit -1
   endif
+
 endif
 @ ie++
 end
-#
 
-foreach fn ( filter advance_time convertdate restart_file_tool )
+foreach fn ( filter advance_time convertdate restart_file_tool dart_to_model model_to_dart )
   if ( ! -x $fn ) then
        echo ${LINK} $DART_DIR/$fn .
             ${LINK} $DART_DIR/$fn .
@@ -177,10 +216,18 @@
  end
 endif
 
+cd $MPAS_DIR    
+set mfiles = ( ${mpas_exe} ${mpas_grd}.graph.info* *BL *DATA stream* )
+cd -
+
 if ( ! -d MPAS_RUN ) ${LINK} $MPAS_DIR MPAS_RUN		# for advance_model.csh
 if ( ! -d logs ) mkdir logs				# to print out log files
 ${COPY} input.nml input.nml.template 			# for advance_time
 
+foreach f ( $mfiles )    
+    ${LINK} MPAS_RUN/$f .
+end
+      
 #------------------------------------------
 # Time info
 #------------------------------------------
@@ -209,11 +256,11 @@
       \rm -fR advance_temp*
    endif
 endif
-set ncyc = `expr $icyc \+ $n_cycles \- 1`
-   
+set ncyc = `expr $icyc \+ $n_cycles \- 1`   
 
+
 #--------------------------------------------------------
-# Cycling gets started
+# MAIN LOOP FOR CYCLING
 #--------------------------------------------------------
 set time_anl = `echo $date_beg 0 | advance_time`		#YYYYMMDDHH
 
@@ -229,6 +276,35 @@
   #------------------------------------------------------
   # 1. Namelist setup
   #------------------------------------------------------
+    
+  # MPAS namelist configuration
+  #--------------------------------------------------------
+  if($icyc == 1) then      # First cycle is run as cold start.
+     set mpas_fname = ${mpas_fini}
+     set cycling    = .false.
+     set do_restart = .false.
+     if(! -e ${mpas_fname}.nc) ${COPY} ${FG_DIR}/${mpas_fname}.e1.nc ${mpas_fname}.nc  || exit 1
+  else
+     set mpas_fname = ${mpas_frst}
+     set cycling    = .true.
+     set do_restart = .true.
+     set mpas_template = ${RUN_DIR}/advance_temp1/${mpas_fname}.nc
+    #set mpas_template = ${IENS_DIR}/ENS_1/${mpas_fname}.`echo $date_ini | sed -e 's/:/./g'`.nc
+     if(! -e ${mpas_fname}.nc) ln -sf $mpas_template ${mpas_fname}.nc		|| exit
+  endif
+
+  ${REMOVE} init.sed  
+  cat >! init.sed << EOF
+  /config_do_DAcycling /c\
+   config_do_DAcycling = $cycling
+  /config_do_restart /c\
+   config_do_restart = ${do_restart}
+EOF
+  mv namelist.atmosphere namelist.input.temp                    || exit
+  sed -f init.sed namelist.input.temp >! namelist.atmosphere    || exit
+            
+  # DART namelist configuration
+  #--------------------------------------------------------    
    cat >! script.sed << EOF
   /ens_size /c\
    ens_size                    = $nens,
@@ -304,30 +380,23 @@
 
   if( $use_u_for_wind == true ) then
       set is_use_u_there = `grep use_u_for_wind input.nml.template | wc -l`
-      set is_u_there = `grep KIND_EDGE_NORMAL_SPEED input.nml | wc -l`
+      set is_u_there = `grep KIND_EDGE_NORMAL_SPEED input.nml.template | wc -l`
+	
+      if($is_use_u_there == 0) then
+         echo No use_u_for_wind in your input.nml.template.
+         exit -1
+      endif
+      if($is_u_there == 0) then
+         echo No KIND_EDGE_NORMAL_SPEED in your input.nml.template.
+         exit -1
+      endif
 
-      if($is_use_u_there == 0) then		# Add this parameter in model_nml.
       cat >! script3.sed << EOF
-  /model_analysis_filename/i\
-   use_u_for_wind               = .true.,
-EOF
-      else
-      cat >! script3.sed << EOF
   /use_u_for_wind/c\
    use_u_for_wind               = .true.,
 EOF
-      endif
 
       cat script3.sed >> script.sed
-
-      if($is_u_there == 0) then
-      cat >! script3.sed << EOF
-  /theta/i\
-                          'u',                     'KIND_EDGE_NORMAL_SPEED',
-EOF
-      cat script3.sed >> script.sed
-      endif
-
   endif
 
   set nobs = 0
@@ -348,7 +417,7 @@
    if($icyc == 1) then
       set dir_rst = $FG_DIR
    else
-      set dir_rst = $RUN_DIR/${expname}/${time_anl}
+      set dir_rst = $RUN_DIR/${time_anl}
    endif
    set fn_rst = $dir_rst/${restart_in}
    if(! -e ${mpas_fname}.nc) ${LINK} $dir_rst/${mpas_fname}.nc .
@@ -375,15 +444,15 @@
    endif
 
    if( $adaptive_inf == true && $icyc > 1 ) then
-       if(! -e $RUN_DIR/${expname}/${time_pre}/${infl_out}) then
-          echo $RUN_DIR/${expname}/${time_pre}/${infl_out} does not exist. Stop.
+       if(! -e $RUN_DIR/${time_pre}/${infl_out}) then
+          echo $RUN_DIR/${time_pre}/${infl_out} does not exist. Stop.
           exit
        endif
-       ${LINK} $RUN_DIR/${expname}/${time_pre}/${infl_out} ${infl_in}
+       ${LINK} $RUN_DIR/${time_pre}/${infl_out} ${infl_in}
    endif
 
    #------------------------------------------------------
-   # 3. Obs sequence for this analysis cycle - one obs time at each analysis cycle
+   # 3. Obs sequence for this analysis cycle 
    #------------------------------------------------------
    #set fn_obs = $OBS_DIR/${time_anl}/obs_seq.out
    set fn_obs = $OBS_DIR/obs_seq.${time_anl}.out
@@ -391,13 +460,14 @@
       echo $fn_obs does not exist. Stop.
       exit
    endif
-   ${LINK} $fn_obs obs_seq.out
+   ${LINK} $fn_obs ${obs_seq_in}
 
    #------------------------------------------------------
    # 4. Run filter
    #------------------------------------------------------
+   set wdir = `pwd`
    set job_name = ${expname}.${icyc}
-   echo Running filter: $job_name
+   echo Running filter: $job_name at $wdir
 
   if($bsub_in_ibm == yes) then
 
@@ -475,7 +545,7 @@
    sed -e '/^   input_file_name/,/^   new_advance_secs/d' \
        -e '/&restart_file_tool_nml/r ./input.nml.ic.restart_file_tool' input.nml.filter.${icyc} >! input.nml
  
-   $RUN_DIR/restart_file_tool >! logs/restart_file_tool.ic_${icyc}.log
+   $DART_DIR/restart_file_tool >! logs/restart_file_tool.ic_${icyc}.log
 
    set n_ics = `ls -1 assim_model_state_ic.* | wc -l`
    if( $n_ics != $nens ) then
@@ -527,7 +597,7 @@
    #------------------------------------------------------
    set sav_dir = $OUT_DIR/${time_anl}
    if(! -d $sav_dir) mkdir -p $sav_dir
-   echo Saving output files...
+   echo Saving output files in ${sav_dir}...
    ls -lrt >! ${sav_dir}/list
    ${COPY} input.nml.filter.${icyc} ${sav_dir}/
    ${COPY} input.nml ${sav_dir}/input.nml.ic.restart_file_tool.${icyc}
@@ -595,7 +665,7 @@
    endif
 
    #------------------------------------------------------
-   # 10. Get ready to run filter for next cycle.
+   # 10. Get ready to run filter for the next cycle
    #------------------------------------------------------
    if(! -d $OUT_DIR/${time_nxt}) mkdir -p $OUT_DIR/${time_nxt}
 
@@ -622,7 +692,7 @@
    sed -e '/^   input_file_name/,/^   new_advance_secs/d' \
        -e '/&restart_file_tool_nml/r ./input.nml.ud.restart_file_tool' input.nml.filter.${icyc} >! input.nml
 
-   $RUN_DIR/restart_file_tool >! logs/restart_file_tool.ud_${icyc}.log
+   $DART_DIR/restart_file_tool >! logs/restart_file_tool.ud_${icyc}.log
    ${COPY} input.nml ${sav_dir}/input.nml.ud.restart_file_tool.${icyc}
    ${MOVE} ${restart_in} $OUT_DIR/${time_nxt}/
 
@@ -637,7 +707,6 @@
 
    endif
 
-
    echo Filter is ready to go for the next cycle now.
    set time_anl = $time_nxt
    @ icyc++


More information about the Dart-dev mailing list