[Dart-dev] [4455] DART/trunk/models/NCOMMAS/shell_scripts/advance_model.csh: Lots of updates to bring this closer to what is really needed
nancy at ucar.edu
nancy at ucar.edu
Tue Aug 3 15:44:47 MDT 2010
Revision: 4455
Author: nancy
Date: 2010-08-03 15:44:47 -0600 (Tue, 03 Aug 2010)
Log Message:
-----------
Lots of updates to bring this closer to what is really needed
to advance ncommas.
Modified Paths:
--------------
DART/trunk/models/NCOMMAS/shell_scripts/advance_model.csh
-------------- next part --------------
Modified: DART/trunk/models/NCOMMAS/shell_scripts/advance_model.csh
===================================================================
--- DART/trunk/models/NCOMMAS/shell_scripts/advance_model.csh 2010-08-03 21:37:16 UTC (rev 4454)
+++ DART/trunk/models/NCOMMAS/shell_scripts/advance_model.csh 2010-08-03 21:44:47 UTC (rev 4455)
@@ -26,28 +26,34 @@
#-------------------------------------------------------------------------
# Block 1: populate a run-time directory with the bits needed to
-# run the ocean model.
+# run the NCOMMAS model.
#-------------------------------------------------------------------------
# Get unique name for temporary working directory for this process's stuff
set temp_dir = 'advance_temp'${process}
echo "temp_dir is $temp_dir"
-# Create a clean temporary directory and go there
-\rm -rf $temp_dir
-mkdir -p $temp_dir
+# FIXME: have the startup script echo the name of the experiment into a
+# known, fixed filename. for now, assume it is going to be called 'experiment.txt'.
+set exp=`cat experiment.txt`
+
+# get the name of the experiment out of the attributes namelist
+
+# If directory doesn't exist, create it. If it already exists,
+# assume what's in it is good.
+if ( ! -d $temp_dir) mkdir -p $temp_dir
cd $temp_dir
# Get the 'changing' namelist files from CENTRALDIR
# Only the namelists in CENTRALDIR have the updated information about
# the state of the model partway through an assimilation experiment.
-foreach FILE ( ../ncommas_in.part1 \
- ../ncommas_in.part2 \
+# NCOMMAS namelist, anything else
+foreach FILE ( ../${exp}.3d.run \
../input.nml )
cp -pv $FILE . || exit 1
end
-# Try to ensure that the input.nml has the required value for
+# Ensure that the input.nml has the required value for
# dart_to_ncommas_nml:advance_time_present for this context.
echo '1' >! ex_commands
@@ -59,15 +65,14 @@
( ex input.nml < ex_commands ) >& /dev/null
\rm -f ex_commands
-# copy the files used by
-foreach FILE ( ../horiz_grid.gx3v5.* \
- ../topography.gx3v5.* \
- ../vert_grid.gx3v5 \
- ../*_contents )
- ln -sfv $FILE . || exit 1
-end
+# Link the files that are common to all model advances;
+# you cannot put any files that need to be updated in this list.
+# (Put them above in the copy list).
+# ?empty for now
+#foreach FILE ( ../*_contents )
+# if ( ! -e $FILE) ln -sfv $FILE . || exit 1
+#end
-echo 'listing now that the table has been set ...'
ls -l
# Loop through each state
@@ -91,50 +96,51 @@
# The EXPECTED input DART 'initial conditions' file name is 'dart.ic'
# The dart_to_ncommas_nml:advance_time_present = .TRUE. must be set
+ # why is this a link and not a move?
ln -sfv ../$input_file dart.ic || exit 2
- # CENTRALDIR will always contain a pointer file containing the name
- # of the most recent NCOMMAS restart file for this ensemble member.
- # Locally, the NCOMMAS restart file name is always ncommas.r.nc
+ # CENTRALDIR should contain the restart files for all the ensemble members.
- if ( -e ../rpointer.ocn.${ensemble_member}.restart ) then
- # dereference the pointer file
- set RESTARTFILE = `head -1 ../rpointer.ocn.${ensemble_member}.restart`
- cp -pv ../${RESTARTFILE} ncommas.r.nc || exit 2
-
+ # if this is a problem with a symbolic link, make it a hard link or
+ # change it to a move and then move it back when done.
+ set RESTARTFILE = `printf %s%03d%s ${exp}.r. $ensemble_member .nc`
+ if ( -e ../$RESTARTFILE) then
+ ln -sfv ../${RESTARTFILE} ncommas_restart.nc || exit 2
else
- echo "ERROR: Pointer file for ensemble member $ensemble_member is missing."
- echo "Looking for "`pwd`" ../rpointer.ocn.${ensemble_member}.restart"
- echo "Exiting ... (pointer file not found in CENTRALDIR)"
+ echo "ERROR: Restart file for ensemble member $ensemble_member is missing."
+ echo "Cannot find ../$RESTARTFILE"
+ echo "Exiting."
exit 2
endif
- # create a ncommas_in to satisfy dart_ncommas_mod:initialize_module()
+ # Use the contents of the dart state vector to update the local history file.
- cat ncommas_in.part1 ncommas_in.part2 >! ncommas_in
-
../dart_to_ncommas || exit 2
- # Convey the new NCOMMAS 'advance_to' time to NCOMMAS via the namelist
- cat ncommas_in.DART ncommas_in.part2 >! ncommas_in
+ # now give it the right filename which includes the ensemble member number
+ mv ncommas_restart.nc ${RESTARTFILE}
- # NCOMMAS needs a pointer file containing the restart filename
- echo "ncommas.r.nc" >! rpointer.ocn.restart
- echo "RESTART_FMT=nc" >> rpointer.ocn.restart
+ # assume the converter has put two times on one line, the current time
+ # and the advance-to time. These are in seconds from time0. The name of
+ # the file is just 'times'.
+ set start_stop = `cat times`
+
#----------------------------------------------------------------------
- # Block 3: Run the ocean model
- # The CCSM version has a pointer file that contains the name of the
- # last restart. The LANL version has no such mechanism, but the
- # filename can be predicted from the ncommas_in namelist information.
+ # Block 3: Run the NCOMMAS model
#----------------------------------------------------------------------
- # the value of MPI is inherited
+ # the value of MPI could be inherited - null for now
+ set MPI = ''
- rm -f ocn.log.*
+ if ( "$MPI" == '' ) then
+ ${MPI} ../commas ${exp}.3d.run $ensemble_member $start_stop || exit 3
+ else
+ # ${MPI} ../commas_mpi ${exp}.3d.run $ensemble_member $start_stop || exit 3
+ endif
- ${MPI} ../ncommas || exit 3
-
- grep "Successful completion of ncommas run" ocn.log.*
+ # get the return status somehow - either from $status, or grepping
+ # for a success message in a log file.
+ grep "Successful completion of ncommas run" log.*
set ncommasstatus = $status
if ( $ncommasstatus != 0 ) then
echo "ERROR - NCOMMAS ensemble member $ensemble_member did not complete successfully"
@@ -143,25 +149,16 @@
endif
#----------------------------------------------------------------------
- # Block 4: Convert the ocean model output to form needed by DART
+ # Block 4: Convert the model output to form needed by DART
#----------------------------------------------------------------------
ls -lrt
- # NCOMMAS makes a new restart file and updates the pointer file
- # Rename the NCOMMAS pointer file contents to contain the ensemble member info
+ # NCOMMAS updates the restart file. extract the state vector data
+ # and put it into the name requested by dart.
- set RESTARTFILE = `head -1 rpointer.ocn.restart`
- set NEWFILE = `echo $RESTARTFILE | sed -e "s/ncommas/ncommas.$ensemble_member/"`
- echo "NCOMMAS member $ensemble_member made restart file $NEWFILE"
-
- mv -v $RESTARTFILE $NEWFILE
+ ln -s $RESTARTFILE restart.nc
- echo $NEWFILE >! rpointer.ocn.restart
- echo "RESTART_FMT=nc" >> rpointer.ocn.restart
-
- ln -svf ${NEWFILE} ncommas.r.nc || exit 4
-
# ncommas_to_dart reads the restart file after the model advance and writes
# out an updated DART 'initial conditions' file. This initial conditions
# file contains a header with the valid time of the ensuing model state.
@@ -169,12 +166,16 @@
../ncommas_to_dart || exit 4
+
# The (new,updated) DART restart file name is called 'dart.ud'
# Move the updated files back to 'centraldir'
mv -v dart.ud ../$output_file || exit 4
- mv -v rpointer.ocn.restart ../rpointer.ocn.${ensemble_member}.restart || exit 4
- mv -v ${NEWFILE} ../${NEWFILE} || exit 4
+ rm restart.nc
+ # the restart name was a link, so the central version should
+ # have been updated. if not, move it up there.
+ #mv -v ${RESTARTFILE} ../${RESTARTFILE} || exit 4
+
# bookkeeping
@ state_copy++
More information about the Dart-dev
mailing list