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 | arch_defined="FALSE" |
---|
9 | parallel_defined="FALSE" |
---|
10 | arch="" |
---|
11 | parallel="none" |
---|
12 | CPP_KEY="CPP_NONE" |
---|
13 | |
---|
14 | while (($# > 0)) |
---|
15 | do |
---|
16 | case $1 in |
---|
17 | "-h") cat <<fin |
---|
18 | Usage : |
---|
19 | makegcm [options] -m arch exec |
---|
20 | [-h] : help |
---|
21 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
---|
22 | -arch nom_arch : nom de l\'architecture cible |
---|
23 | fin |
---|
24 | exit;; |
---|
25 | |
---|
26 | "-prod") |
---|
27 | compil_mode="prod" ; shift ;; |
---|
28 | |
---|
29 | "-dev") |
---|
30 | compil_mode="dev" ; shift ;; |
---|
31 | |
---|
32 | "-debug") |
---|
33 | compil_mode="debug" ; shift ;; |
---|
34 | |
---|
35 | "-arch") |
---|
36 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
---|
37 | |
---|
38 | "-parallel") |
---|
39 | parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;; |
---|
40 | |
---|
41 | *) |
---|
42 | code="$1" ; shift ;; |
---|
43 | esac |
---|
44 | done |
---|
45 | |
---|
46 | rm -f .void_file |
---|
47 | echo > .void_file |
---|
48 | rm -rf .void_dir |
---|
49 | mkdir .void_dir |
---|
50 | |
---|
51 | if [[ "$arch_defined" == "TRUE" ]] |
---|
52 | then |
---|
53 | rm -f arch.path |
---|
54 | rm -f arch.fcm |
---|
55 | rm -f arch.env |
---|
56 | ln -s arch/arch-${arch}.path ./arch.path |
---|
57 | ln -s arch/arch-${arch}.fcm ./arch.fcm |
---|
58 | if test -f arch/arch-${arch}.env |
---|
59 | then |
---|
60 | ln -s arch/arch-${arch}.env arch.env |
---|
61 | else |
---|
62 | ln -s .void_file arch.env |
---|
63 | fi |
---|
64 | source arch.env |
---|
65 | source arch.path |
---|
66 | else |
---|
67 | echo "Veuillez definir une architecture cible" |
---|
68 | exit 1 |
---|
69 | fi |
---|
70 | |
---|
71 | if [[ "$compil_mode" == "prod" ]] |
---|
72 | then |
---|
73 | COMPIL_FFLAGS="%PROD_FFLAGS" |
---|
74 | elif [[ "$compil_mode" == "dev" ]] |
---|
75 | then |
---|
76 | COMPIL_FFLAGS="%DEV_FFLAGS" |
---|
77 | elif [[ "$compil_mode" == "debug" ]] |
---|
78 | then |
---|
79 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
---|
80 | fi |
---|
81 | |
---|
82 | if [[ "$parallel" == "mpi" ]] |
---|
83 | then |
---|
84 | CPP_KEY="$CPP_KEY CPP_USING_MPI" |
---|
85 | elif [[ "$parallel" == "none" ]] |
---|
86 | then |
---|
87 | parallel="none" |
---|
88 | else |
---|
89 | echo "-parallel value $parallel is invalid, only permited <none> or <mpi>" |
---|
90 | exit 1 |
---|
91 | fi |
---|
92 | |
---|
93 | ICOSA_LIB="$NETCDF_LIBDIR $HDF5_LIBDIR $NETCDF_LIB $HDF5_LIB" |
---|
94 | |
---|
95 | rm -f config.fcm |
---|
96 | |
---|
97 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
---|
98 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
---|
99 | echo "%LIB $ICOSA_LIB">> config.fcm |
---|
100 | |
---|
101 | ./build |
---|