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