| 1 | #!/bin/bash |
|---|
| 2 | export PATH=$PWD/tools/FCM/bin:$PATH |
|---|
| 3 | |
|---|
| 4 | export ROOT=$PWD |
|---|
| 5 | set -x |
|---|
| 6 | echo $0 $* > rebuild_all |
|---|
| 7 | chmod a+x rebuild_all |
|---|
| 8 | |
|---|
| 9 | compil_mode_defined="FALSE" |
|---|
| 10 | compil_mode="prod" |
|---|
| 11 | |
|---|
| 12 | job=1 |
|---|
| 13 | full_defined="FALSE" |
|---|
| 14 | with_xios_defined="TRUE" |
|---|
| 15 | with_orchidee_defined="FALSE" |
|---|
| 16 | arch_defined="FALSE" |
|---|
| 17 | parallel_defined="FALSE" |
|---|
| 18 | arch_path="../ARCH" |
|---|
| 19 | arch_default_path="arch" |
|---|
| 20 | parallel="none" |
|---|
| 21 | physics="none" |
|---|
| 22 | build_deps="TRUE" |
|---|
| 23 | CPP_KEY="CPP_NONE" |
|---|
| 24 | ICOSA_LIB="" |
|---|
| 25 | |
|---|
| 26 | while (($# > 0)) |
|---|
| 27 | do |
|---|
| 28 | case $1 in |
|---|
| 29 | "-h") cat <<fin |
|---|
| 30 | Usage : |
|---|
| 31 | makegcm [options] -m arch exec |
|---|
| 32 | [-h] : help |
|---|
| 33 | [-prod / -dev / -debug] : compilation en mode production (default) / developpement / debug . |
|---|
| 34 | [-nodeps] : do not build dependencies (XIOS, IOIPSL, LMDZ5, ICOSAGCM) |
|---|
| 35 | -arch nom_arch : nom de l\'architecture cible |
|---|
| 36 | fin |
|---|
| 37 | exit;; |
|---|
| 38 | |
|---|
| 39 | "-prod") |
|---|
| 40 | compil_mode="prod" ; shift ;; |
|---|
| 41 | |
|---|
| 42 | "-dev") |
|---|
| 43 | compil_mode="dev" ; shift ;; |
|---|
| 44 | |
|---|
| 45 | "-debug") |
|---|
| 46 | compil_mode="debug" ; shift ;; |
|---|
| 47 | |
|---|
| 48 | "-arch") |
|---|
| 49 | arch=$2 ; arch_defined="TRUE"; shift ; shift ;; |
|---|
| 50 | |
|---|
| 51 | "-arch_path") |
|---|
| 52 | arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;; |
|---|
| 53 | |
|---|
| 54 | "-parallel") |
|---|
| 55 | parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;; |
|---|
| 56 | |
|---|
| 57 | "-job") |
|---|
| 58 | job=$2 ; shift ; shift;; |
|---|
| 59 | |
|---|
| 60 | "-full") |
|---|
| 61 | full_defined="TRUE" ; shift ;; |
|---|
| 62 | |
|---|
| 63 | "-nodeps") |
|---|
| 64 | build_deps="FALSE" ; shift ;; |
|---|
| 65 | |
|---|
| 66 | "-with_xios") |
|---|
| 67 | with_xios_defined="TRUE" ; shift ;; |
|---|
| 68 | |
|---|
| 69 | "-with_orchidee") |
|---|
| 70 | with_orchidee_defined="TRUE" ; shift ;; |
|---|
| 71 | |
|---|
| 72 | *) |
|---|
| 73 | code="$1" ; shift ;; |
|---|
| 74 | esac |
|---|
| 75 | done |
|---|
| 76 | |
|---|
| 77 | rm -f .void_file |
|---|
| 78 | echo > .void_file |
|---|
| 79 | rm -rf .void_dir |
|---|
| 80 | mkdir .void_dir |
|---|
| 81 | |
|---|
| 82 | if [[ "$arch_defined" == "TRUE" ]] |
|---|
| 83 | then |
|---|
| 84 | rm -f arch.path |
|---|
| 85 | rm -f arch.fcm |
|---|
| 86 | rm -f arch.env |
|---|
| 87 | |
|---|
| 88 | if test -f $arch_path/arch-${arch}.path |
|---|
| 89 | then |
|---|
| 90 | ln -s $arch_path/arch-${arch}.path arch.path |
|---|
| 91 | elif test -f $arch_default_path/arch-${arch}.path |
|---|
| 92 | then |
|---|
| 93 | ln -s $arch_default_path/arch-${arch}.path arch.path |
|---|
| 94 | fi |
|---|
| 95 | |
|---|
| 96 | if test -f $arch_path/arch-${arch}.fcm |
|---|
| 97 | then |
|---|
| 98 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
|---|
| 99 | elif test -f $arch_default_path/arch-${arch}.fcm |
|---|
| 100 | then |
|---|
| 101 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
|---|
| 102 | fi |
|---|
| 103 | |
|---|
| 104 | if test -f $arch_path/arch-${arch}.env |
|---|
| 105 | then |
|---|
| 106 | ln -s $arch_path/arch-${arch}.env arch.env |
|---|
| 107 | elif test -f $arch_default_path/arch-${arch}.env |
|---|
| 108 | then |
|---|
| 109 | ln -s $arch_default_path/arch-${arch}.env arch.env |
|---|
| 110 | else |
|---|
| 111 | ln -s .void_file arch.env |
|---|
| 112 | fi |
|---|
| 113 | source arch.env |
|---|
| 114 | source arch.path |
|---|
| 115 | else |
|---|
| 116 | echo "Please define a target architecture" |
|---|
| 117 | exit 1 |
|---|
| 118 | fi |
|---|
| 119 | |
|---|
| 120 | LD_FLAGS="%BASE_LD" |
|---|
| 121 | |
|---|
| 122 | if [[ "$compil_mode" == "prod" ]] |
|---|
| 123 | then |
|---|
| 124 | COMPIL_FFLAGS="%PROD_FFLAGS" |
|---|
| 125 | elif [[ "$compil_mode" == "dev" ]] |
|---|
| 126 | then |
|---|
| 127 | COMPIL_FFLAGS="%DEV_FFLAGS" |
|---|
| 128 | elif [[ "$compil_mode" == "debug" ]] |
|---|
| 129 | then |
|---|
| 130 | COMPIL_FFLAGS="%DEBUG_FFLAGS" |
|---|
| 131 | fi |
|---|
| 132 | |
|---|
| 133 | if [[ "$parallel" == "mpi" ]] |
|---|
| 134 | then |
|---|
| 135 | CPP_KEY="$CPP_KEY CPP_USING_MPI" |
|---|
| 136 | elif [[ "$parallel" == "omp" ]] |
|---|
| 137 | then |
|---|
| 138 | CPP_KEY="$CPP_KEY CPP_USING_OMP" |
|---|
| 139 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
|---|
| 140 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
|---|
| 141 | elif [[ "$parallel" == "mpi_omp" ]] |
|---|
| 142 | then |
|---|
| 143 | CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP" |
|---|
| 144 | COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS" |
|---|
| 145 | LD_FLAGS="$LD_FLAGS %OMP_LD" |
|---|
| 146 | elif [[ "$parallel" == "none" ]] |
|---|
| 147 | then |
|---|
| 148 | parallel="none" |
|---|
| 149 | else |
|---|
| 150 | echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>" |
|---|
| 151 | exit 1 |
|---|
| 152 | fi |
|---|
| 153 | |
|---|
| 154 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
|---|
| 155 | then |
|---|
| 156 | ICOSA_LIB="$ICOSA_LIB $ORCHIDEE_LIBDIR $ORCHIDEE_LIB" |
|---|
| 157 | fi |
|---|
| 158 | |
|---|
| 159 | if [[ "$with_xios_defined" == "TRUE" ]] |
|---|
| 160 | then |
|---|
| 161 | CPP_KEY="$CPP_KEY CPP_USING_XIOS" |
|---|
| 162 | COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR" |
|---|
| 163 | ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB" |
|---|
| 164 | fi |
|---|
| 165 | |
|---|
| 166 | ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB" |
|---|
| 167 | |
|---|
| 168 | rm bin/* |
|---|
| 169 | |
|---|
| 170 | if [[ "$full_defined" == "TRUE" ]] |
|---|
| 171 | then |
|---|
| 172 | full_flag="-full" |
|---|
| 173 | full_flag2="--full" |
|---|
| 174 | else |
|---|
| 175 | full_flag="" |
|---|
| 176 | full_flag2="" |
|---|
| 177 | fi |
|---|
| 178 | |
|---|
| 179 | rm -f config.fcm |
|---|
| 180 | |
|---|
| 181 | echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm |
|---|
| 182 | echo "%LD_FLAGS $LD_FLAGS" >> config.fcm |
|---|
| 183 | echo "%CPP_KEY $CPP_KEY" >> config.fcm |
|---|
| 184 | echo "%LIB $ICOSA_LIB">> config.fcm |
|---|
| 185 | |
|---|
| 186 | if [[ "$build_deps" == "TRUE" ]] |
|---|
| 187 | then |
|---|
| 188 | |
|---|
| 189 | cd ../IOIPSL |
|---|
| 190 | ./makeioipsl_fcm -$compil_mode -parallel -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
|---|
| 191 | cd - |
|---|
| 192 | |
|---|
| 193 | cd ../XIOS |
|---|
| 194 | ./make_xios --$compil_mode --arch $arch --arch_path $arch_path --job $job $full_flag2 || exit 1 |
|---|
| 195 | cd - |
|---|
| 196 | |
|---|
| 197 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
|---|
| 198 | then |
|---|
| 199 | cd ../ORCHIDEE |
|---|
| 200 | ./makeorchidee_fcm -$compil_mode -parallel $parallel -xios2 -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
|---|
| 201 | cd - |
|---|
| 202 | fi |
|---|
| 203 | |
|---|
| 204 | cd ../LMDZ5 |
|---|
| 205 | lmdz_veget="false" |
|---|
| 206 | if [[ "$with_orchidee_defined" == "TRUE" ]] |
|---|
| 207 | then |
|---|
| 208 | lmdz_veget="orchidee2.0 -cpp ORCHIDEE_NOZ0H" |
|---|
| 209 | fi |
|---|
| 210 | # ./makelmdz_fcm gcm -$compil_mode -mem -parallel $parallel -nodyn -io xios -v $lmdz_veget -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
|---|
| 211 | ./makelmdz_fcm gcm -$compil_mode -mem -parallel $parallel -libphy -io xios -v $lmdz_veget -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1 |
|---|
| 212 | cd - |
|---|
| 213 | |
|---|
| 214 | cd ../ICOSAGCM |
|---|
| 215 | ./make_icosa -$compil_mode -parallel $parallel -external_ioipsl -with_xios -arch $arch -arch_path $arch_path -job $job $full_flag || exit 1 |
|---|
| 216 | cd - |
|---|
| 217 | fi |
|---|
| 218 | |
|---|
| 219 | ./build --job $job $full_flag2 |
|---|