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

Fix multi-pe advection=none bug #664

Merged
merged 5 commits into from
Nov 26, 2021
Merged
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
73 changes: 63 additions & 10 deletions cice.setup
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/csh -f

#set pd0 = `date -u "+%s%N"`

set ICE_SANDBOX = `pwd`
set ICE_VERSION = unknown
if (-e cicecore/version.txt) then
Expand Down Expand Up @@ -824,8 +826,8 @@ EOF
# set default test output as failure
if (${docase} == 0) then
echo "#---" >! test_output
echo "FAIL ${testname_noid} build" >> test_output
echo "FAIL ${testname_noid} run" >> test_output
echo "PEND ${testname_noid} build" >> test_output
echo "PEND ${testname_noid} run" >> test_output
endif

# from basic script dir to case
Expand Down Expand Up @@ -934,9 +936,21 @@ EOF
if (-e ${fimods}) rm ${fimods}
if (-e ${fsmods}) rm ${fsmods}

# Use an existing ice_in file from the suite if it exists
# to reduce time spent in parse_namelist
set skip_parse_namelist = spval
if (${dosuite} == 1) then
set iceinfn = ../ice_in_save_${grid}${soptions}
Copy link
Member

Choose a reason for hiding this comment

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

I think I'd maybe prefer we put the saved namelists in a separate directory, so as to not clutter the suite's top level directory, but I don't have that strong of an opinion about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These sit in the test suite directory and are deleted at the end of the test suite. You're right that it may be cleaner to put them in a separate directory, but I think we're OK for now.

if (-e ${iceinfn}) then
echo "use ${iceinfn}"
cp ${iceinfn} ice_in
set skip_parse_namelist = true
endif
endif

# Set decomp info in namelist
cat >! ${fimods} << EOF1
# cice.setup settings

nprocs = ${task}
nx_global = ${ICE_DECOMP_NXGLOB}
ny_global = ${ICE_DECOMP_NYGLOB}
Expand Down Expand Up @@ -965,7 +979,6 @@ EOF1

cat >! ${fsmods} << EOF1
# cice.setup settings

setenv ICE_SANDBOX ${ICE_SANDBOX}
setenv ICE_SCRIPTS ${ICE_SCRIPTS}
setenv ICE_CASENAME ${casename}
Expand Down Expand Up @@ -1034,42 +1047,59 @@ EOF1

foreach name (${grid} $setsx)
set found = 0

if (-e ${ICE_SCRIPTS}/options/set_nml.${name}) then
cat >> ${fimods} << EOF2

# set_nml.${name}

EOF2
cat ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods}
cat >> ${fimods} << EOF2

if ("${skip_parse_namelist}" == "true") then
# need to make sure the decomp info from the set_nml is picked up. each case
# has a slightly different decomp that is independent of the ice_in_save file.
# compute that then overwrite by set_nml as needed.
grep -i "distribution_type" ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods}
grep -i "processor_shape" ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods}
cat >> ${fimods} << EOF2
# using saved ice_in
EOF2
else
cat ${ICE_SCRIPTS}/options/set_nml.${name} >> ${fimods}
cat >> ${fimods} << EOF2
EOF2
endif
echo "adding namelist mods set_nml.${name}"
echo "`date` ${0} adding namelist modes set_nml.${name}" >> ${casedir}/README.case
set found = 1
endif

if (-e ${ICE_SCRIPTS}/options/set_env.${name}) then

cat >> ${fsmods} << EOF2

# set_env.${name}

EOF2
cat ${ICE_SCRIPTS}/options/set_env.${name} >> ${fsmods}
cat >> ${fsmods} << EOF2

EOF2
echo "adding env mods set_env.${name}"
echo "`date` ${0} adding namelist modes set_env.${name}" >> ${casedir}/README.case
set found = 1
endif

if (${found} == 0) then
echo "${0}: ERROR, ${ICE_SCRIPTS}/options/set_[nml,env].${name} not found"
exit -1
endif
end

#set pd1 = `date -u "+%s%N"`
#@ pdd = ( $pd1 - $pd0 ) / 1000000
#echo "tcxp b4 parse $pdd"
${casescr}/parse_settings.sh cice.settings ${fsmods}
if ($status != 0) then
echo "${0}: ERROR, parse_settings.sh aborted"
exit -1
endif
${casescr}/parse_namelist.sh ice_in ${fimods}
if ($status != 0) then
echo "${0}: ERROR, parse_namelist.sh aborted"
Expand All @@ -1078,6 +1108,20 @@ EOF2
source ./cice.settings
source ./env.${machcomp} -nomodules || exit 2
${casescr}/parse_namelist_from_env.sh ice_in
if ($status != 0) then
echo "${0}: ERROR, parse_namelist_from_env.sh aborted"
exit -1
endif
#set pd1 = `date -u "+%s%N"`
#@ pdd = ( $pd1 - $pd0 ) / 1000000
#echo "tcxp after parse $pdd"

# Save ice_in in the suite to reduce time spent in parse_namelist
if (${dosuite} == 1) then
if !(-e ${iceinfn}) then
cp ice_in ${iceinfn}
endif
endif

#------------------------------------------------------------
# Generate run script
Expand Down Expand Up @@ -1162,6 +1206,10 @@ EOF
echo ""
endif

#set pd1 = `date -u "+%s%N"`
#@ pdd = ( $pd1 - $pd0 ) / 1000000
#echo "tcxp case done $pdd"

# This is the foreach end for the testsuite
end
# This is the foreach end for the envnames
Expand All @@ -1176,6 +1224,7 @@ if ( ${dosuite} == 1 ) then
cat >> ${tsdir}/suite.submit << EOF0

set nonomatch && rm -f ciceexe.* && unset nonomatch
set nonomatch && rm -f ice_in_save* && unset nonomatch
Comment on lines 1226 to +1227
Copy link
Member

Choose a reason for hiding this comment

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

why not simply

-set nonomatch && rm -f ciceexe.* && unset nonomatch
+set nonomatch && rm -f ciceexe.* ice_in_save* && unset nonomatch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can go either way. This happens once at the end of the test suite, so cost is not an issue. By splitting the lines up, it's easier to comment out one or the other for testing/debugging of the ciceexe or ice_in_save feature. Two lines seems a little cleaner, but it doesn't make much difference. I guess I prefer to leave two lines.


EOF0

Expand Down Expand Up @@ -1218,6 +1267,10 @@ endif

#---------------------------------------------

#set pd1 = `date -u "+%s%N"`
#@ pdd = ( $pd1 - $pd0 ) / 1000000
#echo "tcxp done $pdd"

echo " "
echo "${0} done"
echo " "
Expand Down
7 changes: 4 additions & 3 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,10 @@ subroutine input_data
abort_list = trim(abort_list)//":1"
endif

if (ktransport <= 0) then
advection = 'none'
endif

if (ktransport > 0 .and. advection /= 'remap' .and. advection /= 'upwind') then
if (my_task == master_task) write(nu_diag,*) subname//' ERROR: invalid advection=',trim(advection)
abort_list = trim(abort_list)//":3"
Expand Down Expand Up @@ -1467,9 +1471,6 @@ subroutine input_data
endif
write(nu_diag,1030) ' ssh_stress = ',trim(ssh_stress),trim(tmpstr2)

if (ktransport <= 0) then
advection = 'none'
endif
if (trim(advection) == 'remap') then
tmpstr2 = ' : linear remapping advection'
elseif (trim(advection) == 'upwind') then
Expand Down
1 change: 0 additions & 1 deletion configuration/scripts/options/set_env.box2001

This file was deleted.

18 changes: 8 additions & 10 deletions configuration/scripts/parse_namelist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ filename=$1
filemods=$2

#echo "$0 $1 $2"
echo "running parse_namelist.sh"
echo "running ${scriptname}"
foundstring="FoundSTRING"
vnamearray=()
valuearray=()
Expand Down Expand Up @@ -43,29 +43,27 @@ do
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
grep -q "^[[:space:]]*${vname}[[:space:]]*=" $filename
grepout=$?
if [ ${grepout} -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 "${scriptname} ERROR: parsing error for ${vname}"
exit -99
fi
rm ${filename}.check ${filename}.check.sedbak

fi

done < "$filemods"

if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
fi

exit 0
3 changes: 2 additions & 1 deletion configuration/scripts/parse_namelist_from_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ if [[ "$#" -ne 1 ]]; then
exit -1
fi

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

#echo "$0 $1"
echo "running parse_namelist_from_env.sh"
echo "running $scriptname"

sed -i.sedbak -e 's|ICE_SANDBOX|'"${ICE_SANDBOX}"'|g' $filename
sed -i.sedbak -e 's|ICE_MACHINE_INPUTDATA|'"${ICE_MACHINE_INPUTDATA}"'|g' $filename
Expand Down
34 changes: 21 additions & 13 deletions configuration/scripts/parse_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ filename=$1
filemods=$2

#echo "$0 $1 $2"
echo "running parse_settings.sh"
echo "running ${scriptname}"
foundstring="FoundSTRING"
vnamearray=()
valuearray=()
Expand All @@ -23,8 +23,11 @@ do
else
#vname=`echo $line | sed "s|\(^\s*set\S*\)\s\{1,100\}\(\S*\)\s\{1,100\}\(\S*\).*$|\2|g"`
#value=`echo $line | sed "s|\(^\s*set\S*\)\s\{1,100\}\(\S*\)\s\{1,100\}\(\S*\).*$|\3|g"`
vname=`echo $line | sed "s|\(^[[:space:]]*set[^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\).*$|\2|g"`
vname=`echo $line | sed "s|\(^[[:space:]]*set[^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\).*$|\2|g"`
value=`echo $line | sed "s|\(^[[:space:]]*set[^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\)[[:space:]][[:space:]]*\([^[:space:]]*\).*$|\3|g"`
if [[ "${value}" == "${line}" ]]; then
value=""
fi
# echo "$line $vname $value"

found=${foundstring}
Expand All @@ -43,22 +46,27 @@ do
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)
grep -q "^[[:space:]]*set.* ${vname}[[:space:]]*" $filename
grepout=$?
if [ ${grepout} -eq 0 ]; then
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
else
valuearray[$found]=${value}
fi

if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
echo "${scriptname} ERROR: parsing error for ${vname}"
exit -99
fi

fi

done < "$filemods"

if [[ -e "${filename}.sedbak" ]]; then
rm ${filename}.sedbak
fi

exit 0