[Dart-dev] [3704] DART/trunk/models:
Fully commented script to aid people who may use it
nancy at ucar.edu
nancy at ucar.edu
Wed Dec 10 16:48:29 MST 2008
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/dart-dev/attachments/20081210/8fb9cab7/attachment-0001.html
-------------- next part --------------
Modified: DART/trunk/models/bgrid_solo/shell_scripts/advance_model.csh
===================================================================
--- DART/trunk/models/bgrid_solo/shell_scripts/advance_model.csh 2008-12-10 22:51:16 UTC (rev 3703)
+++ DART/trunk/models/bgrid_solo/shell_scripts/advance_model.csh 2008-12-10 23:48:28 UTC (rev 3704)
@@ -13,68 +13,123 @@
# Standard script for use in assimilation applications
# where the model advance is executed as a separate process.
-# Can be used with most low-order models and the bgrid model which
+# Can be used as-is with most low-order models and the bgrid model which
# can be advanced using the integrate_model executable.
+#
+# Arguments are (created by 'filter' or 'perfect_model_obs' and include):
+# 1) the process number of caller,
+# 2) the number of ensemble members/state copies belonging to that process, and
+# 3) the name of the control_file for that process.
+#
+# If this script finishes and the 'control_file' still exists, it is
+# an ERROR CONDITION and means one or more of the ensemble members did
+# not advance properly. Despite our best attempts to trap on this
+# condition, some MPI installations simply hang, some properly terminate.
+#
+# This script loops over all the entries in the control_file to advance
+# any/all of the ensemble members. The number of trips through the
+# loop is the second argument to this script. The control_file contains
+# the information about which ensemble members are to be advanced by THIS TASK.
+# Sometimes it may be just one ensemble member, sometimes all of them.
+# Read DART/doc/html/filter_async_modes.html and the mpi_intro.html
+# for an overview.
+#
+# This script has 4 logical 'blocks':
+# 1) creates a clean, temporary directory in which to run a model instance
+# and copies the necessary files into the temporary directory
+# 2) copies/converts the DART state vector to something the model can ingest
+# 3) runs the model
+# 4) copies/converts the model output to input expected by DART
-# This script copies the necessary files into the temporary directory
-# and then executes the fortran program integrate_model.
-
-# Arguments are the process number of caller, the number of state copies
-# belonging to that process, and the name of the filter_control_file for
-# that process
-set process = $1
-set num_states = $2
+set process = $1
+set num_states = $2
set control_file = $3
-# Get unique name for temporary working directory for this process's stuff
+#----------------------------------------------------------------------
+# Block 1: copy necessary input files/executables/files common
+# to all model advances to a clean, temporary directory.
+# These will be used by ALL of the ensemble
+# members being advanced by this script.
+#----------------------------------------------------------------------
+
+# Create a unique temporary working directory for this process's stuff
+# The run-time directory for the entire experiment is called CENTRALDIR;
+# we need to provide a safe haven for each TASK ... in 'temp_dir'.
+
set temp_dir = 'advance_temp'${process}
# Create a clean temporary directory and go there
-\rm -rf $temp_dir
-mkdir -p $temp_dir
-cd $temp_dir
+\rm -rf $temp_dir || exit 1
+mkdir -p $temp_dir || exit 1
+cd $temp_dir || exit 1
# Get the program and input.nml
-cp ../integrate_model .
-cp ../input.nml .
+ln -s ../integrate_model . || exit 1
+cp ../input.nml . || exit 1
# Loop through each state
set state_copy = 1
set ensemble_member_line = 1
-set input_file_line = 2
-set output_file_line = 3
+set input_file_line = 2
+set output_file_line = 3
+
while($state_copy <= $num_states)
set ensemble_member = `head -$ensemble_member_line ../$control_file | tail -1`
set input_file = `head -$input_file_line ../$control_file | tail -1`
set output_file = `head -$output_file_line ../$control_file | tail -1`
- # Get the ics file for this state_copy
- mv ../$input_file temp_ic
+ #-------------------------------------------------------------------
+ # Block 2: copy/convert the DART state vector to something the
+ # model can ingest. In this case, just copy.
+ # In general, there is more to it.
+ #
+ # * copy/link ensemble-member-specific files
+ # * convey the advance-to-time to the model
+ # * convert the DART state vector to model format
+ #-------------------------------------------------------------------
- # Advance the model saving standard out
- # integrate_model is hardcoded to expect input in temp_ic and it creates
- # temp_ud as output.
- ./integrate_model >! integrate_model_out_temp
+ mv ../$input_file temp_ic || exit 2
- # Append the output from the advance to the file in the working directory
- #cat integrate_model_out_temp >> ../integrate_model_out_temp$process
+ #-------------------------------------------------------------------
+ # Block 3: advance the model
+ # In this case, we are saving the run-time messages to
+ # a LOCAL file, which makes debugging easier.
+ # integrate_model is hardcoded to expect input in temp_ic
+ # and it creates temp_ud as output.
+ # Your model will likely be different.
+ #-------------------------------------------------------------------
- # Move the updated state vector back up
- # (temp_ud was created by integrate_model.)
- mv temp_ud ../$output_file
+ ./integrate_model >! integrate_model_out_temp || exit 3
+ # (OPTIONAL) Append the run-time messages to the file in the CENTRALDIR
+ #cat integrate_model_out_temp >> ../integrate_model_out_temp${ensemble_member}
+
+ #-------------------------------------------------------------------
+ # Block 4: Move the updated state vector back to CENTRALDIR
+ # (temp_ud was created by integrate_model and is in the
+ # right format already.) In general, you must convert your
+ # model output to a DART ics file with the proper name.
+ #-------------------------------------------------------------------
+
+ mv temp_ud ../$output_file || exit 4
+
@ state_copy++
@ ensemble_member_line = $ensemble_member_line + 3
@ input_file_line = $input_file_line + 3
@ output_file_line = $output_file_line + 3
end
-# Change back to original directory and get rid of temporary directory
+# Change back to original directory and get rid of temporary directory.
+# If all goes well, there should be no need to keep this directory.
+# If you are debugging, you may want to keep this directory.
+
cd ..
\rm -rf $temp_dir
-# Remove the filter_control file to signal completeion
-# Is there a need for any sleeps to avoid trouble on completing moves here?
+# MANDATORY - Remove the control_file to signal completion. If it still
+# exists in CENTRALDIR after all the ensemble members have been advanced,
+# it means one or more of the advances failed and is an ERROR CONDITION.
+
\rm -rf $control_file
Modified: DART/trunk/models/lorenz_96/shell_scripts/advance_model.csh
===================================================================
--- DART/trunk/models/lorenz_96/shell_scripts/advance_model.csh 2008-12-10 22:51:16 UTC (rev 3703)
+++ DART/trunk/models/lorenz_96/shell_scripts/advance_model.csh 2008-12-10 23:48:28 UTC (rev 3704)
@@ -13,68 +13,123 @@
# Standard script for use in assimilation applications
# where the model advance is executed as a separate process.
-# Can be used with most low-order models and the bgrid model which
+# Can be used as-is with most low-order models and the bgrid model which
# can be advanced using the integrate_model executable.
+#
+# Arguments are (created by 'filter' or 'perfect_model_obs' and include):
+# 1) the process number of caller,
+# 2) the number of ensemble members/state copies belonging to that process, and
+# 3) the name of the control_file for that process.
+#
+# If this script finishes and the 'control_file' still exists, it is
+# an ERROR CONDITION and means one or more of the ensemble members did
+# not advance properly. Despite our best attempts to trap on this
+# condition, some MPI installations simply hang, some properly terminate.
+#
+# This script loops over all the entries in the control_file to advance
+# any/all of the ensemble members. The number of trips through the
+# loop is the second argument to this script. The control_file contains
+# the information about which ensemble members are to be advanced by THIS TASK.
+# Sometimes it may be just one ensemble member, sometimes all of them.
+# Read DART/doc/html/filter_async_modes.html and the mpi_intro.html
+# for an overview.
+#
+# This script has 4 logical 'blocks':
+# 1) creates a clean, temporary directory in which to run a model instance
+# and copies the necessary files into the temporary directory
+# 2) copies/converts the DART state vector to something the model can ingest
+# 3) runs the model
+# 4) copies/converts the model output to input expected by DART
-# This script copies the necessary files into the temporary directory
-# and then executes the fortran program integrate_model.
-
-# Arguments are the process number of caller, the number of state copies
-# belonging to that process, and the name of the filter_control_file for
-# that process
-set process = $1
-set num_states = $2
+set process = $1
+set num_states = $2
set control_file = $3
-# Get unique name for temporary working directory for this process's stuff
+#----------------------------------------------------------------------
+# Block 1: copy necessary input files/executables/files common
+# to all model advances to a clean, temporary directory.
+# These will be used by ALL of the ensemble
+# members being advanced by this script.
+#----------------------------------------------------------------------
+
+# Create a unique temporary working directory for this process's stuff
+# The run-time directory for the entire experiment is called CENTRALDIR;
+# we need to provide a safe haven for each TASK ... in 'temp_dir'.
+
set temp_dir = 'advance_temp'${process}
# Create a clean temporary directory and go there
-\rm -rf $temp_dir
-mkdir -p $temp_dir
-cd $temp_dir
+\rm -rf $temp_dir || exit 1
+mkdir -p $temp_dir || exit 1
+cd $temp_dir || exit 1
# Get the program and input.nml
-cp ../integrate_model .
-cp ../input.nml .
+ln -s ../integrate_model . || exit 1
+cp ../input.nml . || exit 1
# Loop through each state
set state_copy = 1
set ensemble_member_line = 1
-set input_file_line = 2
-set output_file_line = 3
+set input_file_line = 2
+set output_file_line = 3
+
while($state_copy <= $num_states)
set ensemble_member = `head -$ensemble_member_line ../$control_file | tail -1`
set input_file = `head -$input_file_line ../$control_file | tail -1`
set output_file = `head -$output_file_line ../$control_file | tail -1`
- # Get the ics file for this state_copy
- mv ../$input_file temp_ic
+ #-------------------------------------------------------------------
+ # Block 2: copy/convert the DART state vector to something the
+ # model can ingest. In this case, just copy.
+ # In general, there is more to it.
+ #
+ # * copy/link ensemble-member-specific files
+ # * convey the advance-to-time to the model
+ # * convert the DART state vector to model format
+ #-------------------------------------------------------------------
- # Advance the model saving standard out
- # integrate_model is hardcoded to expect input in temp_ic and it creates
- # temp_ud as output.
- ./integrate_model >! integrate_model_out_temp
+ mv ../$input_file temp_ic || exit 2
- # Append the output from the advance to the file in the working directory
- #cat integrate_model_out_temp >> ../integrate_model_out_temp$process
+ #-------------------------------------------------------------------
+ # Block 3: advance the model
+ # In this case, we are saving the run-time messages to
+ # a LOCAL file, which makes debugging easier.
+ # integrate_model is hardcoded to expect input in temp_ic
+ # and it creates temp_ud as output.
+ # Your model will likely be different.
+ #-------------------------------------------------------------------
- # Move the updated state vector back up
- # (temp_ud was created by integrate_model.)
- mv temp_ud ../$output_file
+ ./integrate_model >! integrate_model_out_temp || exit 3
+ # (OPTIONAL) Append the run-time messages to the file in the CENTRALDIR
+ #cat integrate_model_out_temp >> ../integrate_model_out_temp${ensemble_member}
+
+ #-------------------------------------------------------------------
+ # Block 4: Move the updated state vector back to CENTRALDIR
+ # (temp_ud was created by integrate_model and is in the
+ # right format already.) In general, you must convert your
+ # model output to a DART ics file with the proper name.
+ #-------------------------------------------------------------------
+
+ mv temp_ud ../$output_file || exit 4
+
@ state_copy++
@ ensemble_member_line = $ensemble_member_line + 3
@ input_file_line = $input_file_line + 3
@ output_file_line = $output_file_line + 3
end
-# Change back to original directory and get rid of temporary directory
+# Change back to original directory and get rid of temporary directory.
+# If all goes well, there should be no need to keep this directory.
+# If you are debugging, you may want to keep this directory.
+
cd ..
\rm -rf $temp_dir
-# Remove the filter_control file to signal completeion
-# Is there a need for any sleeps to avoid trouble on completing moves here?
+# MANDATORY - Remove the control_file to signal completion. If it still
+# exists in CENTRALDIR after all the ensemble members have been advanced,
+# it means one or more of the advances failed and is an ERROR CONDITION.
+
\rm -rf $control_file
Modified: DART/trunk/models/template/shell_scripts/advance_model.csh
===================================================================
--- DART/trunk/models/template/shell_scripts/advance_model.csh 2008-12-10 22:51:16 UTC (rev 3703)
+++ DART/trunk/models/template/shell_scripts/advance_model.csh 2008-12-10 23:48:28 UTC (rev 3704)
@@ -13,68 +13,123 @@
# Standard script for use in assimilation applications
# where the model advance is executed as a separate process.
-# Can be used with most low-order models and the bgrid model which
+# Can be used as-is with most low-order models and the bgrid model which
# can be advanced using the integrate_model executable.
+#
+# Arguments are (created by 'filter' or 'perfect_model_obs' and include):
+# 1) the process number of caller,
+# 2) the number of ensemble members/state copies belonging to that process, and
+# 3) the name of the control_file for that process.
+#
+# If this script finishes and the 'control_file' still exists, it is
+# an ERROR CONDITION and means one or more of the ensemble members did
+# not advance properly. Despite our best attempts to trap on this
+# condition, some MPI installations simply hang, some properly terminate.
+#
+# This script loops over all the entries in the control_file to advance
+# any/all of the ensemble members. The number of trips through the
+# loop is the second argument to this script. The control_file contains
+# the information about which ensemble members are to be advanced by THIS TASK.
+# Sometimes it may be just one ensemble member, sometimes all of them.
+# Read DART/doc/html/filter_async_modes.html and the mpi_intro.html
+# for an overview.
+#
+# This script has 4 logical 'blocks':
+# 1) creates a clean, temporary directory in which to run a model instance
+# and copies the necessary files into the temporary directory
+# 2) copies/converts the DART state vector to something the model can ingest
+# 3) runs the model
+# 4) copies/converts the model output to input expected by DART
-# This script copies the necessary files into the temporary directory
-# and then executes the fortran program integrate_model.
-
-# Arguments are the process number of caller, the number of state copies
-# belonging to that process, and the name of the filter_control_file for
-# that process
-set process = $1
-set num_states = $2
+set process = $1
+set num_states = $2
set control_file = $3
-# Get unique name for temporary working directory for this process's stuff
+#----------------------------------------------------------------------
+# Block 1: copy necessary input files/executables/files common
+# to all model advances to a clean, temporary directory.
+# These will be used by ALL of the ensemble
+# members being advanced by this script.
+#----------------------------------------------------------------------
+
+# Create a unique temporary working directory for this process's stuff
+# The run-time directory for the entire experiment is called CENTRALDIR;
+# we need to provide a safe haven for each TASK ... in 'temp_dir'.
+
set temp_dir = 'advance_temp'${process}
# Create a clean temporary directory and go there
-\rm -rf $temp_dir
-mkdir -p $temp_dir
-cd $temp_dir
+\rm -rf $temp_dir || exit 1
+mkdir -p $temp_dir || exit 1
+cd $temp_dir || exit 1
# Get the program and input.nml
-cp ../integrate_model .
-cp ../input.nml .
+ln -s ../integrate_model . || exit 1
+cp ../input.nml . || exit 1
# Loop through each state
set state_copy = 1
-set ensemble_member_line = template
-set input_file_line = 2
-set output_file_line = 3
+set ensemble_member_line = 1
+set input_file_line = 2
+set output_file_line = 3
+
while($state_copy <= $num_states)
set ensemble_member = `head -$ensemble_member_line ../$control_file | tail -1`
set input_file = `head -$input_file_line ../$control_file | tail -1`
set output_file = `head -$output_file_line ../$control_file | tail -1`
- # Get the ics file for this state_copy
- mv ../$input_file temp_ic
+ #-------------------------------------------------------------------
+ # Block 2: copy/convert the DART state vector to something the
+ # model can ingest. In this case, just copy.
+ # In general, there is more to it.
+ #
+ # * copy/link ensemble-member-specific files
+ # * convey the advance-to-time to the model
+ # * convert the DART state vector to model format
+ #-------------------------------------------------------------------
- # Advance the model saving standard out
- # integrate_model is hardcoded to expect input in temp_ic and it creates
- # temp_ud as output.
- ./integrate_model >! integrate_model_out_temp
+ mv ../$input_file temp_ic || exit 2
- # Append the output from the advance to the file in the working directory
- #cat integrate_model_out_temp >> ../integrate_model_out_temp$process
+ #-------------------------------------------------------------------
+ # Block 3: advance the model
+ # In this case, we are saving the run-time messages to
+ # a LOCAL file, which makes debugging easier.
+ # integrate_model is hardcoded to expect input in temp_ic
+ # and it creates temp_ud as output.
+ # Your model will likely be different.
+ #-------------------------------------------------------------------
- # Move the updated state vector back up
- # (temp_ud was created by integrate_model.)
- mv temp_ud ../$output_file
+ ./integrate_model >! integrate_model_out_temp || exit 3
+ # (OPTIONAL) Append the run-time messages to the file in the CENTRALDIR
+ #cat integrate_model_out_temp >> ../integrate_model_out_temp${ensemble_member}
+
+ #-------------------------------------------------------------------
+ # Block 4: Move the updated state vector back to CENTRALDIR
+ # (temp_ud was created by integrate_model and is in the
+ # right format already.) In general, you must convert your
+ # model output to a DART ics file with the proper name.
+ #-------------------------------------------------------------------
+
+ mv temp_ud ../$output_file || exit 4
+
@ state_copy++
@ ensemble_member_line = $ensemble_member_line + 3
@ input_file_line = $input_file_line + 3
@ output_file_line = $output_file_line + 3
end
-# Change back to original directory and get rid of temporary directory
+# Change back to original directory and get rid of temporary directory.
+# If all goes well, there should be no need to keep this directory.
+# If you are debugging, you may want to keep this directory.
+
cd ..
\rm -rf $temp_dir
-# Remove the filter_control file to signal completeion
-# Is there a need for any sleeps to avoid trouble on completing moves here?
+# MANDATORY - Remove the control_file to signal completion. If it still
+# exists in CENTRALDIR after all the ensemble members have been advanced,
+# it means one or more of the advances failed and is an ERROR CONDITION.
+
\rm -rf $control_file
More information about the Dart-dev
mailing list