-
Notifications
You must be signed in to change notification settings - Fork 0
/
move_to_prefix.sh
executable file
·131 lines (105 loc) · 4.08 KB
/
move_to_prefix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh
# ICON
#
# ---------------------------------------------------------------
# Copyright (C) 2004-2024, DWD, MPI-M, DKRZ, KIT, ETH, MeteoSwiss
# Contact information: icon-model.org
#
# See AUTHORS.TXT for a list of authors
# See LICENSES/ for license information
# SPDX-License-Identifier: BSD-3-Clause
# ---------------------------------------------------------------
fn_error()
{
echo "ERROR: $2" >&2 && exit $1
}
fn_warn()
{
echo "WARNING: $1" >&2
}
fn_rsync()
{
cmd="rsync -uavz $1 $2 $3"
echo "$cmd"
eval "$cmd" || fn_error 4 "failed to copy '$1' to '$2'"
}
fn_copy_file()
{
cmd="$mkdir_p \"$2\" && cp \"$1\" \"$2\""
echo "$cmd"
eval "$cmd" || fn_error 4 "failed to copy '$1' to '$2'"
}
# Default values:
builddir=`pwd`
force=no
prev=
for option; do
if test -n "$prev"; then
eval $prev=\$option
prev=
continue
fi
optarg=
case $option in
*=?*) optarg=`expr "X$option" : '[^=]*=\(.*\)'` ;;
esac
case $option in
--help | -h)
cat <<_EOF
Usage: $0 [OPTION]...
Generates and transfers files required for running ICON from source and build
directories to PREFIX directory. Paths to source and PREFIX directories are read
from file 'config.status' generated by the configure script of ICON.
A possible usage scenario is to build ICON on a fast local disk partition of a
login node and then transfer data required for running the model to a shared
partition available on compute nodes.
Defaults for the options are specified in brackets.
Options:
-h, --help display this help and exit
-f, --force disable checks preventing unexpected results
--builddir=DIR look for 'config.status' in DIR [`pwd`]
_EOF
exit 0 ;;
--builddir)
prev=builddir ;;
--builddir=*)
builddir=$optarg ;;
--force | -f)
force=yes ;;
*)
fn_error 1 "unrecognized option: '$option': try '$0 --help' for more information" ;;
esac
done
test -z $builddir && fn_error 1 "expected a non-empty value for --builddir"
test -f "$builddir/config.status" || fn_error 2 "cannot find config.status in $builddir: try '$0 --help' for more information"
test -f "$builddir/bin/icon" || fn_error 2 "cannot find 'bin/icon' in '$builddir': you need to build first: 'cd \"$builddir\" && make'"
eval "`echo "top_srcdir='@abs_top_srcdir@'; prefix='@prefix@'; mkdir_p='@MKDIR_P@'" | "$builddir/config.status" --file=-`"
test x"$force" = xno && test x"$prefix" = 'x/usr/local' && fn_error 3 \
"prefix equals to the default value '/usr/local': rerun the configure script
specifying an installation prefix other than '/usr/local' using '--prefix' or
rerun this script with an option '--force' to disable this check"
# We do not run 'make install' in $builddir because the user might have
# specified '--exec-prefix' or '--bindir' configure options, which is valid but
# potentially leads to the executables being installed in a directory other than
# $prefix/bin. Therefore, we simply copy '$builddir/bin/icon' to '$prefix/bin'.
fn_copy_file "$builddir/bin/icon" "$prefix/bin/"
test -f "$builddir/bin/jsb4_driver" && fn_copy_file "$builddir/bin/jsb4_driver" "$prefix/bin/"
if test -f "$builddir/run/set-up.info"; then
fn_copy_file "$builddir/run/set-up.info" "$prefix/run/"
else
fn_warn "cannot find 'run/set-up.info' in '$builddir': trying to generate it..."
cmd="\"$builddir/run/collect.set-up.info\" \"$prefix/run/set-up.info\""
echo "$cmd"
eval "$cmd" || fn_error 4 "failed to generate '$prefix/run/set-up.info'"
fi
fn_rsync "$top_srcdir/run" "$prefix/" "--exclude='*.in' --exclude='.*'"
fn_rsync "$top_srcdir/vertical_coord_tables" "$prefix/"
fn_rsync "$top_srcdir/externals" "$prefix/" "--exclude='.git' --exclude='*.f90' --exclude='*.F90' --exclude='*.c' --exclude='*.h' --exclude='*.Po' --exclude='tests' --exclude='*.mod' --exclude='*.o'"
fn_rsync "$top_srcdir/data" "$prefix/"
fn_rsync "$top_srcdir/make_runscripts" "$prefix/"
cat <<_EOF
********************************************************************************
All runtime files have been successfully transferred to '$prefix'
You can proceed with the following command:
cd "$prefix" && ./make_runscripts
_EOF