1 | #!/bin/bash |
---|
2 | export ROOT=$PWD |
---|
3 | export PATH=$ROOT/tools/FCM_V1.2/bin:${PATH} |
---|
4 | |
---|
5 | compil_mode_defined="FALSE" |
---|
6 | compil_mode="prod" |
---|
7 | |
---|
8 | job=1 |
---|
9 | full_defined="FALSE" |
---|
10 | arch_defined="FALSE" |
---|
11 | arch_path="arch" |
---|
12 | arch_default_path="arch" |
---|
13 | arch_path_defined="FALSE" |
---|
14 | CPP_KEY="CPP_NONE" |
---|
15 | |
---|
16 | while (($# > 0)) |
---|
17 | do |
---|
18 | case $1 in |
---|
19 | "-h") cat <<fin |
---|
20 | Usage : |
---|
21 | makegcm [options] -m arch exec |
---|
22 | [-h] : help |
---|
23 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
24 | -arch nom_arch : nom de l\'architecture cible |
---|
25 | fin |
---|
26 | exit;; |
---|
27 | |
---|
28 | "-prod") |
---|
29 | compil_mode="prod" ; shift ;; |
---|
30 | |
---|
31 | "-dev") |
---|
32 | compil_mode="dev" ; shift ;; |
---|
33 | |
---|
34 | "-debug") |
---|
35 | compil_mode="debug" ; shift ;; |
---|
36 | |
---|
37 | "-arch") |
---|
38 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
39 | |
---|
40 | "-arch_path") |
---|
41 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
42 | |
---|
43 | "-job") |
---|
44 | job=$2 ; shift ; shift;; |
---|
45 | |
---|
46 | "-full") |
---|
47 | full_defined="TRUE" ; shift ;; |
---|
48 | |
---|
49 | *) |
---|
50 | code="$1" ; shift ;; |
---|
51 | esac |
---|
52 | done |
---|
53 | |
---|
54 | rm -f .void_file |
---|
55 | echo > .void_file |
---|
56 | rm -rf .void_dir |
---|
57 | mkdir .void_dir |
---|
58 | |
---|
59 | if [[ "$arch_defined" == "TRUE" ]] |
---|
60 | then |
---|
61 | rm -f arch.path |
---|
62 | rm -f arch.fcm |
---|
63 | rm -f arch.env |
---|
64 | |
---|
65 | if test -f $arch_path/arch-${arch}.path |
---|
66 | then |
---|
67 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
68 | elif test -f $arch_default_path/arch-${arch}.path |
---|
69 | then |
---|
70 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
71 | else |
---|
72 | echo No arch.path is found. Exit now. |
---|
73 | exit 1 |
---|
74 | fi |
---|
75 | |
---|
76 | if test -f $arch_path/arch-${arch}.fcm |
---|
77 | then |
---|
78 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
79 | elif test -f $arch_default_path/arch-${arch}.fcm |
---|
80 | then |
---|
81 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
82 | fi |
---|
83 | |
---|
84 | if test -f $arch_path/arch-${arch}.env |
---|
85 | then |
---|
86 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
87 | elif test -f $arch_default_path/arch-${arch}.env |
---|
88 | then |
---|
89 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
90 | else |
---|
91 | ln -s .void_file arch.env |
---|
92 | fi |
---|
93 | source arch.env |
---|
94 | source arch.path |
---|
95 | else |
---|
96 | echo "Veuillez definir une architecture cible" |
---|
97 | exit 1 |
---|
98 | fi |
---|
99 | LD_FLAGS="%BASE_LD" |
---|
100 | |
---|
101 | if [[ "$compil_mode" == "prod" ]] |
---|
102 | then |
---|
103 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
104 | elif [[ "$compil_mode" == "dev" ]] |
---|
105 | then |
---|
106 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
107 | elif [[ "$compil_mode" == "debug" ]] |
---|
108 | then |
---|
109 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
110 | fi |
---|
111 | |
---|
112 | |
---|
113 | IOIPSL_LIB="$NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
---|
114 | |
---|
115 | rm -f config.fcm |
---|
116 | |
---|
117 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
---|
118 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
---|
119 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
120 | echo "%LIB $IOIPSL_LIB">> config.fcm |
---|
121 | |
---|
122 | if [[ "$full_defined" == "TRUE" ]] |
---|
123 | then |
---|
124 | ./build.sh --job $job --full |
---|
125 | else |
---|
126 | ./build.sh --job $job |
---|
127 | fi |
---|
128 | err=$? |
---|
129 | |
---|
130 | # Check error message from fcm build |
---|
131 | if [ $err != 0 ] ; then |
---|
132 | # Error found |
---|
133 | echo makeioipsl_fcm: Error in compiling IOIPSL : $err |
---|
134 | exit 1 |
---|
135 | fi |
---|
136 | |
---|
137 | # Link folders created during compilation to the base directory |
---|
138 | rm -f bin lib inc |
---|
139 | #ln -s build/bin bin |
---|
140 | ln -s build/lib lib |
---|
141 | ln -s build/inc inc |
---|
142 | |
---|