forked from wrf-model/GENBE_2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile
executable file
·97 lines (79 loc) · 2.6 KB
/
compile
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
#!/bin/csh -f
setenv START_OF_COMPILE "`date`"
cont1:
if ( ! -e configure.gen_be ) then
echo "This script assumes you have configured the code already."
echo "Run the configure script before continuing."
exit 1
endif
set arglist=""
foreach a ( $argv )
if ( "$a" == "-h" ) then
goto help
else
if ( "$a" != "-d" ) then
set arglist = ( $arglist $a )
endif
if ( "$a" == "-j" ) then
shift argv
setenv J "-j $argv[1]"
endif
endif
end
if ( "$arglist" == "" ) then
goto help
else
unsetenv A2DCASE
setenv A2DCASE `echo $arglist | grep 2d`
# these settings get passed down through the environment in the
# calls to Make
set overwrite=0
echo -n "Compiling GEN_BE "
if ( ! $?GEN_BE_SRC_ROOT_DIR ) setenv GEN_BE_SRC_ROOT_DIR `pwd`
# new dec 2009. check to see if make supports parallel -j option
make -j 2 >& /dev/null
if ( $status == 0 ) then # Parallel make ok
if ( ! $?J ) then # J not defined
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
else
# J is defined, check that it is a correctly formed variable
set first2chars = `echo $J | cut -c 1-2` # Are 1st two chars are -j?
set second_word = `echo $J | cut -d" " -f2` # Is second word a number?
if ( "$first2chars" == "-j" ) then
if ( ( "$second_word" >= "2" ) && \
( "$second_word" <= "20" ) ) then
echo setting parallel make $J
else if ( "$second_word" == "1" ) then
echo setting serial make $J
else
echo "badly formed -j option for parallel make: $J"
echo "or you set the number of processors above 20 "
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
endif
else
if ( "$J" == "" ) then # J blank is OK
echo setting serial make $J
else
echo "parallel option for make is -j, you entered: $first2chars"
echo setting parallel make -j 2 # Set default to 2
setenv J "-j 2"
endif
endif
endif
else
echo not setting parallel make
endif
make $arglist A2DCASE="$A2DCASE" GEN_BE_SRC_ROOT_DIR="$GEN_BE_SRC_ROOT_DIR"
endif
exit 0
help:
echo ' '
echo 'Usage:'
echo ' '
echo ' compile [-d] [-j n] gen_be compile gen_be in src dir '
echo ' '
echo ' compile -d compile without optimization and with debugging'
echo ' compile -j n parallel make using n tasks if supported (default 2)'
echo ' compile -h help message'