1 | #!/bin/bash |
---|
2 | set -x |
---|
3 | export PATH=$PWD/tools/FCM/bin:$PATH |
---|
4 | |
---|
5 | echo ./make_icosa $* > rebuild |
---|
6 | chmod a+x rebuild |
---|
7 | |
---|
8 | compil_mode_defined="FALSE" |
---|
9 | compil_mode="prod" |
---|
10 | |
---|
11 | job=1 |
---|
12 | full_defined="FALSE" |
---|
13 | with_xios_defined="FALSE" |
---|
14 | arch_defined="FALSE" |
---|
15 | parallel_defined="FALSE" |
---|
16 | arch_path="arch" |
---|
17 | parallel="none" |
---|
18 | physics="none" |
---|
19 | CPP_KEY="CPP_NONE" |
---|
20 | ICOSA_LIB="" |
---|
21 | |
---|
22 | while (($# > 0)) |
---|
23 | do |
---|
24 | case $1 in |
---|
25 | "-h") cat <<fin |
---|
26 | Usage : |
---|
27 | makegcm [options] -m arch exec |
---|
28 | [-h] : help |
---|
29 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
30 | -arch nom_arch : nom de l\'architecture cible |
---|
31 | fin |
---|
32 | exit;; |
---|
33 | |
---|
34 | "-prod") |
---|
35 | compil_mode="prod" ; shift ;; |
---|
36 | |
---|
37 | "-dev") |
---|
38 | compil_mode="dev" ; shift ;; |
---|
39 | |
---|
40 | "-debug") |
---|
41 | compil_mode="debug" ; shift ;; |
---|
42 | |
---|
43 | "-arch") |
---|
44 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
45 | |
---|
46 | "-arch_path") |
---|
47 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
---|
48 | |
---|
49 | "-parallel") |
---|
50 | parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;; |
---|
51 | |
---|
52 | "-job") |
---|
53 | job=$2 ; shift ; shift;; |
---|
54 | |
---|
55 | "-full") |
---|
56 | full_defined="TRUE" ; shift ;; |
---|
57 | |
---|
58 | "-with_xios") |
---|
59 | with_xios_defined="TRUE" ; shift ;; |
---|
60 | |
---|
61 | *) |
---|
62 | code="$1" ; shift ;; |
---|
63 | esac |
---|
64 | done |
---|
65 | |
---|
66 | rm -f .void_file |
---|
67 | echo > .void_file |
---|
68 | rm -rf .void_dir |
---|
69 | mkdir .void_dir |
---|
70 | |
---|
71 | if [[ "$arch_defined" == "TRUE" ]] |
---|
72 | then |
---|
73 | rm -f arch.path |
---|
74 | rm -f arch.fcm |
---|
75 | rm -f arch.env |
---|
76 | ln -s $arch_path/arch-${arch}.path ./arch.path |
---|
77 | ln -s $arch_path/arch-${arch}.fcm ./arch.fcm |
---|
78 | if test -f $arch_path/arch-${arch}.env |
---|
79 | then |
---|
80 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
81 | else |
---|
82 | ln -s .void_file arch.env |
---|
83 | fi |
---|
84 | source arch.env |
---|
85 | source arch.path |
---|
86 | else |
---|
87 | echo "Veuillez definir une architecture cible" |
---|
88 | exit 1 |
---|
89 | fi |
---|
90 | |
---|
91 | LD_FLAGS="%BASE_LD" |
---|
92 | |
---|
93 | if [[ "$compil_mode" == "prod" ]] |
---|
94 | then |
---|
95 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
96 | elif [[ "$compil_mode" == "dev" ]] |
---|
97 | then |
---|
98 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
99 | elif [[ "$compil_mode" == "debug" ]] |
---|
100 | then |
---|
101 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
102 | fi |
---|
103 | |
---|
104 | if [[ "$parallel" == "mpi" ]] |
---|
105 | then |
---|
106 | CPP_KEY="$CPP_KEY CPP_USING_MPI" |
---|
107 | elif [[ "$parallel" == "omp" ]] |
---|
108 | then |
---|
109 | CPP_KEY="$CPP_KEY CPP_USING_OMP" |
---|
110 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
111 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
112 | elif [[ "$parallel" == "mpi_omp" ]] |
---|
113 | then |
---|
114 | CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP" |
---|
115 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
---|
116 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
---|
117 | elif [[ "$parallel" == "none" ]] |
---|
118 | then |
---|
119 | parallel="none" |
---|
120 | else |
---|
121 | echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>" |
---|
122 | exit 1 |
---|
123 | fi |
---|
124 | |
---|
125 | |
---|
126 | if [[ "$with_xios_defined" == "TRUE" ]] |
---|
127 | then |
---|
128 | CPP_KEY="$CPP_KEY CPP_USING_XIOS" |
---|
129 | COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR" |
---|
130 | ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB" |
---|
131 | fi |
---|
132 | |
---|
133 | ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
---|
134 | |
---|
135 | |
---|
136 | cd ../LMDZ5 |
---|
137 | makelmdz_fcm toto -$compil_mode -mem -parallel $parallel -nodyn -arch $arch |
---|
138 | |
---|
139 | cd ../LMDZ5 |
---|
140 | make_icosa -$compil_mode -parallel $parallel -arch $arch |
---|
141 | |
---|
142 | |
---|
143 | cd ../ICOSA_LMDZ |
---|
144 | |
---|
145 | rm -f config.fcm |
---|
146 | |
---|
147 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
---|
148 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
---|
149 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
150 | echo "%LIB $ICOSA_LIB">> config.fcm |
---|
151 | |
---|
152 | if [[ "$full_defined" == "TRUE" ]] |
---|
153 | then |
---|
154 | ./build --job $job --full |
---|
155 | else |
---|
156 | ./build --job $job |
---|
157 | fi |
---|