Skip to content
Snippets Groups Projects
Commit 8478d8dd authored by RIETTE Sébastien's avatar RIETTE Sébastien
Browse files

S. Riette 9 Nov 2022: tool updates

bf for guessing IAL version of arome_* commits
check if repository is checked before cloning
use 'git mv'/'git rm' instead of mv/rm
guess PATH in prep_code for filepp, mnh_expand and correct_indent
parent 4069f9d7
No related branches found
No related tags found
No related merge requests found
...@@ -205,9 +205,16 @@ elif echo $specialPack | grep -w $commit > /dev/null; then ...@@ -205,9 +205,16 @@ elif echo $specialPack | grep -w $commit > /dev/null; then
else else
packBranch="COMMIT$commit" packBranch="COMMIT$commit"
if [ "$cycle" == "" ]; then if [ "$cycle" == "" ]; then
content_ial_version=$(wget --no-check-certificate https://raw.githubusercontent.com/$PHYEXREPOuser/PHYEX/${commit}/src/arome/ial_version.json -O - 2>/dev/null || echo "") if [[ $commit == arome${separator}* ]]; then
apl_arome_file="ext/apl_arome.F90"
ial_version_file="ext/ial_version.json"
else
apl_arome_file="src/arome/ext/apl_arome.F90"
ial_version_file="src/arome/ial_version.json"
fi
content_ial_version=$(wget --no-check-certificate https://raw.githubusercontent.com/$PHYEXREPOuser/PHYEX/${commit}/$ial_version_file -O - 2>/dev/null || echo "")
if [ "$content_ial_version" == "" ]; then if [ "$content_ial_version" == "" ]; then
content_apl_arome=$(wget --no-check-certificate https://raw.githubusercontent.com/$PHYEXREPOuser/PHYEX/${commit}/src/arome/ext/apl_arome.F90 -O - 2>/dev/null) content_apl_arome=$(wget --no-check-certificate https://raw.githubusercontent.com/$PHYEXREPOuser/PHYEX/${commit}/$apl_arome_file -O - 2>/dev/null)
cycle=$(apl_arome_content2cycle) cycle=$(apl_arome_content2cycle)
else else
cycle=$(ial_version_content2cycle) cycle=$(ial_version_content2cycle)
......
...@@ -103,12 +103,18 @@ if [ -z "${checkout_point-}" ]; then ...@@ -103,12 +103,18 @@ if [ -z "${checkout_point-}" ]; then
fi fi
cd $directory cd $directory
from='dir' from='dir'
mv='mv -f'
rm='rm -f'
else else
[ $verbose -gt 0 ] && echo "Clone and checkout $checkout_point into $directory directory" [ $verbose -gt 0 ] && echo "Clone and checkout $checkout_point into $directory directory"
if [ -d $directory ]; then if [ -d $directory ]; then
echo "$directory already exists, suppress it before executing the script (or remove the -c option)" echo "$directory already exists, suppress it before executing the script (or remove the -c option)"
exit 3 exit 3
fi fi
if [ -z "${repository-}" ]; then
echo "A repository must be set (use -h option to get help)"
exit 1
fi
git clone $repository $directory git clone $repository $directory
cd $directory cd $directory
if [ -n "${branch-}" ]; then if [ -n "${branch-}" ]; then
...@@ -120,13 +126,16 @@ else ...@@ -120,13 +126,16 @@ else
fi fi
git checkout $branch $checkout_point git checkout $branch $checkout_point
from='git' from='git'
mv='git mv -f'
rm='git rm -q -f'
fi fi
###### RENAME .F90 into .f90 ###### RENAME .F90 into .f90
if [ $renameFf -eq 1 ]; then if [ $renameFf -eq 1 ]; then
#we use find/while/read in case the number of files is too big to be hold on a single shell line
find . -type f -name \*.F90 -print0 | \ find . -type f -name \*.F90 -print0 | \
while IFS= read -r -d '' file; do while IFS= read -r -d '' file; do
mv -- "$file" "${file%.F90}.f90" $mv "$file" "${file%.F90}.f90"
done done
fi fi
...@@ -151,8 +160,23 @@ if [ -n "${model-}" ]; then ...@@ -151,8 +160,23 @@ if [ -n "${model-}" ]; then
echo "$sub must not exist in the repository root, this is a limitation of the script" echo "$sub must not exist in the repository root, this is a limitation of the script"
exit 7 exit 7
fi fi
[ -e src/common/$sub ] && mv src/common/$sub . [ -e src/common/$sub ] && $mv src/common/$sub . #sub doesn't exist, we can move it directly
[ -e src/$model/$sub ] && cp -rlf src/$model/$sub . && rm -rf src/$model/$sub if [ -e src/$model/$sub ]; then
if [ -f src/$model/$sub ]; then
#$sub is a file, it can be overwritten
$mv "src/$model/$sub" $sub
else
#directory can exist, we must move files one by one
#we use find/while/read in case the number of files is too big to be hold on a single shell line
(cd src/$model/$sub; find . -type f -print0) | \
while IFS= read -r -d '' file; do
dname=$(dirname $file)
[ ! -d $sub/$dname ] && mkdir -p $sub/$dname
$mv "src/$model/$sub/$file" "$sub/$file"
done
rmdir --ignore-fail-on-non-empty -p "src/$model/$sub" #suppress tree if empty
fi
fi
done done
#Supression of unwanted files #Supression of unwanted files
...@@ -161,7 +185,7 @@ if [ -n "${model-}" ]; then ...@@ -161,7 +185,7 @@ if [ -n "${model-}" ]; then
#because these files are already existing elsewhere in the model source code #because these files are already existing elsewhere in the model source code
while read -r line; do while read -r line; do
filename=$(echo $line | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//') #trim filename=$(echo $line | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//') #trim
[ -f "$filename" ] && rm -f "$filename" [ -f "$filename" ] && $rm "$filename"
done < src/$model/filesToSuppress.txt done < src/$model/filesToSuppress.txt
fi fi
...@@ -173,9 +197,9 @@ if [ -n "${model-}" ]; then ...@@ -173,9 +197,9 @@ if [ -n "${model-}" ]; then
exit 8 exit 8
fi fi
for file in $files; do for file in $files; do
if [ $from == 'dir' -o $(git ls-files --error-unmatch $file 2>/dev/null | wc -l) -gt 0 ] ; then [ $verbose -gt 1 ] && echo "Suppression of $file"
[ $verbose -gt 1 ] && echo "Suppression of $file" if [ -e "$file" -a "$file" != '.git' -a "$file" != '.git/' ]; then
rm -rf $file $rm -r "$file"
fi fi
done done
fi fi
...@@ -183,13 +207,20 @@ fi ...@@ -183,13 +207,20 @@ fi
###### MNH_EXPAND ###### MNH_EXPAND
if [ -n "${mnh_expand_options-}" ]; then if [ -n "${mnh_expand_options-}" ]; then
[ $verbose -gt 0 ] && echo "Applying mnh_expand" [ $verbose -gt 0 ] && echo "Applying mnh_expand"
#Update PATH if needed
UPDATEDPATH=$PATH
which correct_indent.py > /dev/null || UPDATEDPATH=$PHYEXTOOLSDIR:$UPDATEDPATH
which mnh_expand > /dev/null || UPDATEDPATH=$PHYEXTOOLSDIR/mnh_expand/MNH_Expand_Array:$UPDATEDPATH
which filepp > /dev/null || UPDATEDPATH=$PHYEXTOOLSDIR/mnh_expand/filepp:$UPDATEDPATH
function apply_mnh_expand () { function apply_mnh_expand () {
if grep mnh_expand $1 > /dev/null 2>&1 ; then if grep mnh_expand $1 > /dev/null 2>&1 ; then
[ $verbose -gt 1 ] && echo "Applying mnh_expand on $1" [ $verbose -gt 1 ] && echo "Applying mnh_expand on $1"
$PHYEXTOOLSDIR/correct_indent.py $1 "detect" PATH=$UPDATEDPATH correct_indent.py $1 "detect"
mnh_expand -DMNH_EXPAND_NOCPP $mnh_expand_options $1_EXPAND > tempo_mnh_expand PATH=$UPDATEDPATH mnh_expand -DMNH_EXPAND_NOCPP $mnh_expand_options $1_EXPAND > tempo_mnh_expand
rm -f $1_EXPAND rm -f $1_EXPAND
$PHYEXTOOLSDIR/correct_indent.py tempo_mnh_expand "indent" PATH=$UPDATEDPATH correct_indent.py tempo_mnh_expand "indent"
mv tempo_mnh_expand_CORRECT_INDENT $1 mv tempo_mnh_expand_CORRECT_INDENT $1
rm -f tempo_mnh_expand rm -f tempo_mnh_expand
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment