Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .cice_set, git clone --depth=1, atmbndy namelist output, script warning messages for --set conflicts #494

Merged
merged 6 commits into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
19 changes: 18 additions & 1 deletion cice.setup
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ set suitebuild = true
set suitereuse = true
set suiterun = false
set suitesubmit = true
set ignoreuserset = false

if ($#argv < 1) then
set helpheader = 1
Expand Down Expand Up @@ -98,6 +99,7 @@ DESCRIPTION
--acct : account number for the batch submission
--grid, -g : grid, grid (default = ${grid})
--set, -s : case option setting(s), comma separated (default = " ")
--ignore-user-set: ignore ~/.cice_set if it exists
--queue : queue for the batch submission

For testing
Expand All @@ -112,7 +114,7 @@ DESCRIPTION
--diff : generate comparison against another case
--report : automatically post results when tests are complete
--coverage : generate and report test coverage metrics when tests are complete,
requires GNU compiler (ie. normally ``--env gnu``)
requires GNU compiler (ie. normally --env gnu)
--setup-only : for suite, setup testcases, no build, no submission
--setup-build : for suite, setup and build testcases, no submission
--setup-build-run : for suite, setup, build, and run interactively
Expand Down Expand Up @@ -263,6 +265,10 @@ while (1)
set suitesubmit = true
shift argv

else if ("$option" == "--ignore-user-set") then
set ignoreuserset = true
shift argv

# arguments with settings
else
shift argv
Expand Down Expand Up @@ -412,6 +418,17 @@ set vers = ${ICE_VERSION}
set shhash = `echo ${hash} | cut -c 1-10`

if ( ${dosuite} == 0 ) then
# grab user defined default sets
if ("${ignoreuserset}" == "false" && -e ~/.cice_set) then
set setsu1 = `cat ~/.cice_set`
# get rid of spaces if they exist!
set setsuser = `echo ${setsu1} | sed 's/ //g'`
if ( ${sets} == "" ) then
set sets = "${setsuser}"
else
set sets = "${setsuser},${sets}"
endif
endif
set teststring = "${test} ${grid} ${pesx} ${sets}"
if ( $bfbcomp != ${spval} ) then
if ( ${sets} == "" ) then
Expand Down
4 changes: 2 additions & 2 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1290,12 +1290,12 @@ subroutine input_data
write(nu_diag,1012) ' calc_strair = ', calc_strair,' calculate wind stress and speed'
write(nu_diag,1012) ' rotate_wind = ', rotate_wind,' rotate wind/stress to computational grid'
write(nu_diag,1012) ' formdrag = ', formdrag,' use form drag parameterization'
if (trim(atmbndy) == 'constant') then
if (trim(atmbndy) == 'default') then
tmpstr2 = ': stability-based boundary layer'
write(nu_diag,1012) ' highfreq = ', highfreq,' high-frequency atmospheric coupling'
write(nu_diag,1022) ' natmiter = ', natmiter,' number of atmo boundary layer iterations'
write(nu_diag,1006) ' atmiter_conv = ', atmiter_conv,' convergence criterion for ustar'
elseif (trim(atmbndy) == 'default') then
elseif (trim(atmbndy) == 'constant') then
tmpstr2 = ': boundary layer uses bulk transfer coefficients'
endif
write(nu_diag,*) 'atmbndy = ', trim(atmbndy),trim(tmpstr2)
Expand Down
27 changes: 26 additions & 1 deletion configuration/scripts/parse_namelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ if [[ "$#" -ne 2 ]]; then
exit -1
fi

scriptname=`basename "$0"`
filename=$1
filemods=$2

#echo "$0 $1 $2"
echo "running parse_namelist.sh"
foundstring="FoundSTRING"
vnamearray=()
valuearray=()

while read -r line
do
Expand All @@ -24,17 +27,39 @@ do
value=`echo $line | sed "s|^[[:space:]]*\([^[:space:]]*\)[[:space:]]*=[[:space:]]*\([^[:space:]]*\).*$|\2|g"`
# echo "$line $vname $value"

found=${foundstring}
for i in "${!vnamearray[@]}"; do
if [[ "${found}" == "${foundstring}" ]]; then
vn=${vnamearray[$i]}
vv=${valuearray[$i]}
# echo "names/values $i ${vname} ${vn} ${value} ${vv}"
if [[ "$vname" == "$vn" ]]; then
found=$i
if [[ "$value" != "${vv}" ]]; then
# echo "names/values $i ${vname} ${vn} ${value} ${vv}"
echo "${scriptname} WARNING: re-overriding $vname from ${vv} to ${value}"
fi
fi
fi
done

#sed -i 's|\(^\s*'"$vname"'\s*\=\s*\)\(.*$\)|\1'"$value"'|g' $filename
cp ${filename} ${filename}.check
sed -i.sedbak -e 's|\(^[[:space:]]*'"$vname"'[[:space:]]*=[[:space:]]*\)\(.*$\)|\1'"$foundstring"'|g' ${filename}.check
grep -q ${foundstring} ${filename}.check
if [ $? -eq 0 ]; then
sed -i.sedbak -e 's|\(^[[:space:]]*'"$vname"'[[:space:]]*=[[:space:]]*\)\(.*$\)|\1'"$value"'|g' ${filename}
if [[ "${found}" == "${foundstring}" ]]; then
vnamearray+=($vname)
valuearray+=($value)
else
valuearray[$found]=${value}
fi
if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
fi
else
echo "$0 ERROR: parsing error for ${vname}"
echo "${scriptname} ERROR: parsing error for ${vname}"
exit -99
fi
rm ${filename}.check ${filename}.check.sedbak
Expand Down
28 changes: 28 additions & 0 deletions configuration/scripts/parse_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ if [[ "$#" -ne 2 ]]; then
exit -1
fi

scriptname=`basename "$0"`
filename=$1
filemods=$2

#echo "$0 $1 $2"
echo "running parse_settings.sh"
foundstring="FoundSTRING"
vnamearray=()
valuearray=()

while read -r line
do
Expand All @@ -23,8 +27,32 @@ do
value=`echo $line | sed "s|\(^[[:space:]]*set[^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\).*$|\3|g"`
# echo "$line $vname $value"

found=${foundstring}
for i in "${!vnamearray[@]}"; do
if [[ "${found}" == "${foundstring}" ]]; then
vn=${vnamearray[$i]}
vv=${valuearray[$i]}
# echo "names/values $i ${vname} ${vn} ${value} ${vv}"
if [[ "$vname" == "$vn" ]]; then
found=$i
if [[ "$value" != "${vv}" ]]; then
# echo "names/values $i ${vname} ${vn} ${value} ${vv}"
echo "${scriptname} WARNING: re-overriding $vname from ${vv} to ${value}"
fi
fi
fi
done

#sed -i 's|\(^\s*set.* '"$vname"' \)[^#]*\(#*.*$\)|\1 '"$value"' \2|g' $filename
sed -i.sedbak -e 's|\(^[[:space:]]*set.* '"$vname"' \)[^#]*\(#*.*$\)|\1 '"$value"' \2|g' $filename

if [[ "${found}" == "${foundstring}" ]]; then
vnamearray+=($vname)
valuearray+=($value)
else
valuearray[$found]=${value}
fi

if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
fi
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/tests/cice.lcov.csh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set lcovhtmldir = lcov_cice_${report_name}
genhtml -o ./${lcovhtmldir} --precision 2 -t "${report_name}" total.info

rm -r -f ${lcovrepo}
git clone https://github.com/apcraig/${lcovrepo}
git clone --depth=1 https://github.com/apcraig/${lcovrepo}
cp -p -r ${lcovhtmldir} ${lcovrepo}/

cd ${lcovrepo}
Expand Down
4 changes: 2 additions & 2 deletions configuration/scripts/tests/cice_test_codecov.csh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ cd ${testdir}
# Check out current cice master
echo " "
echo "*** checkout current cice master ***"
git clone https://github.com/cice-consortium/cice cice.master.${date} --recursive
git clone --depth=1 https://github.com/cice-consortium/cice cice.master.${date} --recursive
cd cice.master.${date}
set hash = `git rev-parse --short HEAD `
cd ../
Expand All @@ -40,7 +40,7 @@ cd ../
# This also copies in all dot file at the root that do not start with .g (ie. .git*)
echo " "
echo "*** checkout current test_cice_master ***"
git clone https://github.com/apcraig/test_cice_icepack test_cice_icepack.${date}
git clone --depth=1 https://github.com/apcraig/test_cice_icepack test_cice_icepack.${date}
cd test_cice_icepack.${date}
echo " "
echo "*** remove current files and copy in cice master files ***"
Expand Down
2 changes: 1 addition & 1 deletion configuration/scripts/tests/report_results.csh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set wikirepo = "https://github.com/CICE-Consortium/Test-Results.wiki.git"
set wikiname = Test-Results.wiki

rm -r -f ${wikiname}
git clone ${wikirepo} ${wikiname}
git clone --depth=1 ${wikirepo} ${wikiname}
if ($status != 0) then
echo " "
echo "${0}: ERROR git clone failed"
Expand Down
15 changes: 12 additions & 3 deletions doc/source/user_guide/ug_running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ specifies the compilation environment associated with the machine. This should
specifies the grid. This is a string and for the current CICE driver, gx1, gx3, and tx1 are supported. (default = gx3)

``--set``, ``-s`` SET1,SET2,SET3
specifies the optional settings for the case. The settings for ``--suite`` are defined in the suite file. Multiple settings can be specified by providing a comma deliminated set of values without spaces between settings. The available settings are in **configurations/scripts/options** and ``cice.setup --help`` will also list them. These settings files can change either the namelist values or overall case settings (such as the debug flag).
specifies the optional settings for the case. The settings for ``--suite`` are defined in the suite file. Multiple settings can be specified by providing a comma deliminated set of values without spaces between settings. The available settings are in **configurations/scripts/options** and ``cice.setup --help`` will also list them. These settings files can change either the namelist values or overall case settings (such as the debug flag). For cases and tests (not suites), settings defined in **~/.cice_set** (if it exists) will be included in the --set options. This behaviour can be overridden with the `--ignore-user-set`` command line option.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little suggestion to make reviewing documentation easier: one thing we could do is write only one sentence per line. Here there are multiple sentences on the same line so the diff is long, whereas if we'd stick to one sentence per line it would be easy to see that it's two sentences that are added at the end and the rest of the paragraph is not modified. (Whether to do a PR that changes that for the whole documentation is something we could discuss, but maybe just doing it as we go when we make documentation changes could be a good way forward). Also if everybody is on board we should mention it on the wiki page that talks about Documentation changes.

Also, I think the format of the ~/.cice_set file should be documented: are options separated by commas, just as on the command line (and with no trailing comma) ? Reading the code added in cice.setup this appears to be the case, but I think it should be mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @phil-blain, I have updated the documentation and added a sentence about the format of the .cice_set file. I also agree about the "long line" issue in the documentation and agree that we can move away from it as we go. I think we have to be a little careful as there may be cases where the line breaks change the formatting, for instance in the indented section highlighted above, but we can also explore that issue moving forward.


``--ignore-user-set``
ignores settings defined in **~/.cice.set** (if it exists) for cases and tests. **~/.cice_set** is always ignored for test suites.

For CICE, when setting up cases, the ``--case`` and ``--mach`` must be specified.
It's also recommended that ``--env`` be set explicitly as well.
Expand All @@ -228,7 +231,13 @@ settings (options), the set_env.setting and set_nml.setting will be used to
change the defaults. This is done as part of the ``cice.setup`` and the
modifications are resolved in the **cice.settings** and **ice_in** file placed in
the case directory. If multiple options are chosen that conflict, then the last
option chosen takes precedent. Not all options are compatible with each other.
option chosen takes precedence. Not all options are compatible with each other.

Settings defined in **~/.cice_set** (if it exists) will be included in the ``--set``
options. This behaviour can be overridden with the `--ignore-user-set`` command
line option. The format of the **~/.cice_set** file is a identical to the
``--set`` option, a single command delimited line of options. Settings on the
apcraig marked this conversation as resolved.
Show resolved Hide resolved
command line will take precedence over settings defined in **~/.cice_set**.

Some of the options are

Expand Down Expand Up @@ -453,7 +462,7 @@ the **env.[machine]** file. The easiest way to change a user's default is to
create a file in your home directory called **.cice\_proj** and add your
preferred account name to the first line.
There is also an option (``--acct``) in **cice.setup** to define the account number.
The order of precedent is **cice.setup** command line option,
The order of precedence is **cice.setup** command line option,
**.cice\_proj** setting, and then value in the **env.[machine]** file.

.. _queue:
Expand Down
6 changes: 4 additions & 2 deletions doc/source/user_guide/ug_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ For individual tests, the following command line options can be set

``--set`` SET1,SET2,SET3 (see :ref:`case_options`)

``--ignore-user-set`` (see :ref:`case_options`)

``--acct`` ACCOUNT (see :ref:`case_options`)

``--grid`` GRID (see :ref:`case_options`)
Expand Down Expand Up @@ -312,7 +314,7 @@ If a user adds ``--set`` to the suite, all tests in that suite will add that opt

./cice.setup --suite base_suite,decomp_suite --mach wolf --env gnu --testid myid -s debug

The option settings defined in the suite have precendent over the command line
The option settings defined in the suite have precendence over the command line
values if there are conflicts.

The predefined test suites are defined under **configuration/scripts/tests** and
Expand Down Expand Up @@ -459,7 +461,7 @@ Test Suite Examples
./results.csh

If there are conflicts between the ``--set`` options in the suite and on the command line,
the suite will take precedent.
the suite will take precedence.

5) **Multiple test suites from a single command line**

Expand Down