[1332] | 1 | #!/bin/bash |
---|
[1385] | 2 | |
---|
[1386] | 3 | #==============================================================================================================================\n |
---|
[2148] | 4 | # MODULE : makeorchidee_fcm |
---|
[1386] | 5 | # |
---|
[4470] | 6 | # CONTACT : orchidee-help _at_ listes.ipsl.fr |
---|
[1385] | 7 | # |
---|
[1386] | 8 | # LICENCE : IPSL (2006) |
---|
| 9 | # This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC |
---|
| 10 | # |
---|
[2148] | 11 | # SVN : |
---|
| 12 | # $HeadURL: svn://forge.ipsl.jussieu.fr/orchidee/trunk/ORCHIDEE/makeorchidee_fcm $ |
---|
| 13 | # $Date: $ |
---|
| 14 | # $Revision: $ |
---|
| 15 | # \n |
---|
[1385] | 16 | #################################################################################################### |
---|
| 17 | # |
---|
| 18 | # This script has several possible functions : |
---|
[1505] | 19 | # 1. Compiling ORCHIDEE |
---|
[1385] | 20 | # 2. Building of the documentation |
---|
| 21 | # |
---|
| 22 | #*************************************************************************************************** |
---|
| 23 | # |
---|
[2148] | 24 | # Command lines : |
---|
[1385] | 25 | # |
---|
[1885] | 26 | # 1) makeorchidee_fcm [ -parallel PARALLEL_TYPE ] |
---|
[1385] | 27 | # [ -driver ] |
---|
[2148] | 28 | # [ -arch XXX ] |
---|
[1385] | 29 | # [ -prod | -dev | -debug ] |
---|
| 30 | # |
---|
[2148] | 31 | # 2) makeorchidee_fcm [ -clean ] |
---|
| 32 | # |
---|
| 33 | # 3) makeorchidee_fcm [ -doc | -doc_para ] ## actually doc_para is commented |
---|
[1385] | 34 | # [ -rmdoc ] |
---|
| 35 | # [ -doc_tree ] |
---|
| 36 | # |
---|
| 37 | |
---|
[3447] | 38 | ######################################################################## |
---|
| 39 | # |
---|
| 40 | # 1) Set default values. Some of them can be specified using environnement variables. |
---|
| 41 | # |
---|
| 42 | |
---|
[1332] | 43 | is_driver_opt=FALSE |
---|
[4061] | 44 | is_other_opt=FALSE |
---|
[1773] | 45 | clean=FALSE |
---|
[2148] | 46 | compile_flags="%PROD_FFLAGS" |
---|
[3838] | 47 | xios=FALSE |
---|
[1505] | 48 | full="" |
---|
| 49 | ext_src="" |
---|
[1332] | 50 | export P_P="" |
---|
| 51 | export SECTIONS_PARA="" |
---|
| 52 | ORCHDIR=`/bin/pwd` |
---|
[1513] | 53 | fcm_path=$ORCHDIR/tools/FCM_V1.2/bin |
---|
[3447] | 54 | compile_doc=FALSE |
---|
[5526] | 55 | |
---|
| 56 | arch_default_path="arch" |
---|
| 57 | arch_path="arch" |
---|
| 58 | |
---|
[5523] | 59 | # Path to store files produced during compilation |
---|
[5574] | 60 | # Note: config_path was previously named .config |
---|
[5576] | 61 | rel_config_path=build |
---|
| 62 | config_path=$ORCHDIR/${rel_config_path} |
---|
[8] | 63 | |
---|
[5526] | 64 | |
---|
[3447] | 65 | # Following variables can be set as environement variables if wanted |
---|
| 66 | if [ -n "$FCM_ARCH" ]; then |
---|
| 67 | arch="$FCM_ARCH" |
---|
| 68 | else |
---|
| 69 | arch=NONE |
---|
| 70 | fi |
---|
| 71 | if [ -n "$FCM_PARA" ]; then |
---|
| 72 | parallel_mode="$FCM_PARA" |
---|
| 73 | else |
---|
| 74 | parallel_mode=seq |
---|
| 75 | fi |
---|
| 76 | if [ -n "$FCM_JOBS" ]; then |
---|
| 77 | job="$FCM_JOBS" |
---|
| 78 | else |
---|
| 79 | job=1 |
---|
| 80 | fi |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | ######################################################################### |
---|
| 84 | # 2. Read arguments |
---|
| 85 | # |
---|
[2148] | 86 | while (($# > 0)) ; do |
---|
[3447] | 87 | |
---|
[1332] | 88 | case $1 in |
---|
[3447] | 89 | "-h") |
---|
| 90 | print_help=TRUE ; shift ;; |
---|
[8] | 91 | |
---|
[3447] | 92 | "-parallel") |
---|
| 93 | parallel_mode=$2 ; shift ; shift ;; |
---|
| 94 | |
---|
| 95 | "-p") |
---|
| 96 | parallel_mode=$2 ; shift ; shift ;; |
---|
| 97 | |
---|
| 98 | "-driver") |
---|
| 99 | is_driver_opt=TRUE ; shift ;; |
---|
| 100 | |
---|
| 101 | "-otherexec") |
---|
| 102 | is_other_opt=TRUE |
---|
| 103 | is_driver_opt=TRUE ; shift ;; |
---|
| 104 | |
---|
| 105 | "-arch") |
---|
| 106 | arch="$2" ; shift ; shift ;; |
---|
| 107 | |
---|
[5526] | 108 | "-arch_path") |
---|
| 109 | arch_path=$2 ; shift ; shift ;; |
---|
| 110 | |
---|
[3447] | 111 | "-xios") |
---|
[3838] | 112 | xios=TRUE |
---|
[3447] | 113 | shift ;; |
---|
| 114 | |
---|
| 115 | "-xios2") |
---|
[3838] | 116 | xios=TRUE |
---|
[3447] | 117 | shift ;; |
---|
| 118 | |
---|
| 119 | "-noxios") |
---|
[3838] | 120 | xios=FALSE |
---|
[3447] | 121 | shift ;; |
---|
| 122 | |
---|
| 123 | "-prod") |
---|
| 124 | compile_flags="%PROD_FFLAGS" ; shift ;; |
---|
| 125 | |
---|
| 126 | "-dev") |
---|
| 127 | compile_flags="%DEV_FFLAGS" ; shift ;; |
---|
| 128 | |
---|
| 129 | "-debug") |
---|
| 130 | compile_flags="%DEBUG_FFLAGS" ; shift ;; |
---|
| 131 | |
---|
| 132 | "-j") |
---|
| 133 | job="$2" ; shift ; shift ;; |
---|
| 134 | |
---|
| 135 | "-full") |
---|
| 136 | full='-full' ; shift ;; |
---|
| 137 | |
---|
| 138 | "-clean") |
---|
| 139 | clean=TRUE ; shift ;; |
---|
| 140 | |
---|
| 141 | "-ext_src") |
---|
| 142 | ext_src=$2 ; shift ; shift ;; |
---|
| 143 | |
---|
| 144 | # "-doc_para") |
---|
| 145 | # setenv P_P -DCPP_PARA |
---|
| 146 | # setenv SECTIONS_PARA "-e s&ENABLED_SECTIONS\ *= &ENABLED_SECTIONS = CPP_PARA&g" |
---|
| 147 | # goto doc |
---|
| 148 | |
---|
| 149 | "-doc") |
---|
| 150 | compile_doc=TRUE ; shift ;; |
---|
| 151 | |
---|
| 152 | "-rmdoc") |
---|
| 153 | \rm -rf docs |
---|
| 154 | shift ;; |
---|
| 155 | |
---|
| 156 | "-doc_tree") |
---|
| 157 | cd .. |
---|
| 158 | find ORCHIDEE \( -not -path '*.svn*' \ |
---|
| 159 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
| 160 | -exec bash -c 'mkdir -p ORCHIDEE/DOC/$( dirname {} )/$( echo $( basename {} ) | sed -e "s/\..*//" )' \; |
---|
| 161 | cd ORCHIDEE |
---|
| 162 | shift ;; |
---|
| 163 | |
---|
| 164 | *) |
---|
| 165 | echo "unknown option "$1" , exiting..." |
---|
| 166 | exit |
---|
| 167 | esac |
---|
| 168 | done |
---|
| 169 | |
---|
| 170 | ######################################################################### |
---|
| 171 | # 3. Print help documentation and exit |
---|
| 172 | # |
---|
| 173 | if [[ "$print_help" == "TRUE" ]] ; then |
---|
| 174 | cat <<fin |
---|
| 175 | |
---|
[8] | 176 | ######################################################################## |
---|
[2148] | 177 | # Usage of the script makeorchidee_fcm |
---|
[2149] | 178 | # |
---|
| 179 | # makeorchidee_fcm compiles ORCHIDEE using the Fcm a software developed |
---|
| 180 | # by the Hadley Centre. Fcm is stored in tools directory. |
---|
| 181 | # Platform specific compile options are found in the arch directory. |
---|
[8] | 182 | ######################################################################## |
---|
| 183 | |
---|
[2148] | 184 | ./makeorchidee_fcm [Options] |
---|
[8] | 185 | |
---|
[2148] | 186 | Main options |
---|
| 187 | [ -h ] : show this help |
---|
[8] | 188 | |
---|
[2148] | 189 | [ -arch XXX ] : name of the archicture file containg platform dependent compile options. |
---|
| 190 | The files arch/arch-XXX.fcm and arch/arch-XXX.path must exist. |
---|
| 191 | |
---|
[5526] | 192 | [ -arch_path XXX ] : directory of the archicture file containg platform dependent compile options. |
---|
| 193 | Default is ./arch directory. If the files are not found in the folder, the default ./arch folder will be used. |
---|
| 194 | |
---|
[2148] | 195 | [ -parallel|-p PARALLEL_TYPE ] : choose parallelization mode for ORCHIDEE : |
---|
[8] | 196 | PARALLEL_TYPE = |
---|
[2148] | 197 | ( mpi | MPI ) : only MPI (Message Passing Interface) |
---|
| 198 | ( omp | OMP ) : only OpenMP |
---|
| 199 | ( mpi_omp | MPI_OMP ) : hybrid MPI/OpenMP mode |
---|
| 200 | ( none | NONE | seq ) : sequential mode (default) |
---|
[8] | 201 | |
---|
[3447] | 202 | [ -driver ] : compilation of ORCHIDEE offline standard driver |
---|
[5217] | 203 | [ -otherexec ] : compilation of other programs: teststomate, forcesoil, testrouting. |
---|
[3447] | 204 | Warning! All these programs are not fully validated or maintained. |
---|
[8] | 205 | |
---|
[2148] | 206 | Options related to cleaning |
---|
| 207 | | -clean ] : delete all files produceed during previous compilation |
---|
| 208 | | -full ] : activate full recompiling |
---|
[8] | 209 | |
---|
[2148] | 210 | Options for XIOS, only choose one of the following |
---|
[3838] | 211 | [ -xios | -xios2 ] : linking with XIOS 2.0 (it is not longer possible to use XIOS1) |
---|
[3096] | 212 | [ -noxios ] : compilation without XIOS (default) |
---|
[1788] | 213 | |
---|
[2148] | 214 | Options for optimization, choose only one of the following |
---|
| 215 | [ -prod ] : compilation for production (all optimization) |
---|
| 216 | [ -dev ] : compilation for development (low optimization and -g) |
---|
| 217 | [ -debug ] : compilation for debugging (no optmization and all debug options) |
---|
[1788] | 218 | |
---|
[2148] | 219 | Option to optimize the compilation time |
---|
| 220 | [ -j x ] : activate parallel compiling on x task, default 1 task |
---|
[8] | 221 | |
---|
[2148] | 222 | Option to add extra source to compile |
---|
| 223 | [ -ext_src path] : path to an additional directory with fortran routines to compile with the model |
---|
[8] | 224 | |
---|
[2148] | 225 | Options for compiling the documentation : |
---|
| 226 | [ -doc ] : generate documentation with Doxygen (exit after doc computation) |
---|
| 227 | [ -doc_para ] : generate documentation with Doxygen with parallelization calls |
---|
| 228 | [ -rmdoc ] : remove documentation directory (before generate new documentation with Doxygen ?) |
---|
| 229 | [ -doc_tree ] : generate tree of ORCHIDEE directories for each file |
---|
[8] | 230 | |
---|
[1505] | 231 | |
---|
[2149] | 232 | Example 1 : compile at curie(TGCC) for MPI parallel run mode |
---|
[2148] | 233 | ./makeorchidee_fcm -parallel mpi -arch X64_CURIE -driver |
---|
[1773] | 234 | |
---|
[2149] | 235 | Example 2 : compile at ada(IDRIS) for MPI-OpenMP parallel run mode |
---|
[2148] | 236 | ./makeorchidee_fcm -parallel mpi_omp -arch X64_ADA -driver |
---|
[1505] | 237 | |
---|
[2149] | 238 | Example 3 : compile at obelix(LSCE) |
---|
| 239 | ./makeorchidee_fcm -arch ifort_LSCE -driver |
---|
| 240 | |
---|
| 241 | Example 4 : compile using gfortran compiler for sequential run mode |
---|
[2148] | 242 | First make sure that the files arch/gfortran.fcm and arch/gfortran.path are suitable for |
---|
| 243 | your environement especially the path to netcdf library. |
---|
| 244 | ./makeorchidee_fcm -parallel seq -arch gfortran -driver |
---|
[1505] | 245 | |
---|
[2149] | 246 | Example 5 : clean files created during previous compilation |
---|
[2148] | 247 | ./makeorchidee_fcm -clean |
---|
[8] | 248 | |
---|
[1332] | 249 | fin |
---|
[2149] | 250 | |
---|
[3447] | 251 | exit |
---|
| 252 | fi |
---|
| 253 | # |
---|
| 254 | # |
---|
[1385] | 255 | ##################################################################################################### |
---|
[3447] | 256 | # 4. Building the documentation: |
---|
[1385] | 257 | # ------------------------------ |
---|
| 258 | # We assume to start in the ORCHIDEE directory |
---|
| 259 | # |
---|
| 260 | #**** Directory structure: |
---|
| 261 | # |
---|
| 262 | # .. : parent of the start dir. |
---|
| 263 | # -- ORCHIDEE : ($MODELPATH), start directory |
---|
| 264 | # - src_sechiba |
---|
| 265 | # - src_stomate |
---|
| 266 | # + DOC |
---|
| 267 | # + webdoc |
---|
| 268 | # -- IOIPSL |
---|
| 269 | # - src |
---|
| 270 | # ++ modeles_doc : ($SRCPATH), source files for the documentation, emptied at start, temporary |
---|
| 271 | # |
---|
| 272 | #**** gawk scripts called : |
---|
| 273 | # |
---|
| 274 | # codeinc.awk : encaspulates code parts in Doxygen documentation |
---|
| 275 | # codedox.awk : transforms almost all comments in Doxygen comments for documentation |
---|
| 276 | # codealgo.awk : emphasizes main algorithm description of each routine in their Doxygen documentation |
---|
| 277 | # |
---|
| 278 | #**** |
---|
[3447] | 279 | if [[ "$comple_doc" == "TRUE" ]] ; then |
---|
[947] | 280 | |
---|
[3447] | 281 | unalias cd |
---|
[1332] | 282 | |
---|
[3447] | 283 | export REV=`svn info | grep vision | sed -e 's&.*vision.*: \([0-9]*\)&\1&' | head -n 1` |
---|
| 284 | export TAG=`svn info | grep URL | sed -e 's&.*URL.*: svn://forge.ipsl.jussieu.fr/orchidee/\(.*\)&\1&' | head -n 1 | xargs dirname` |
---|
| 285 | cd .. |
---|
| 286 | |
---|
| 287 | \rm -rf modeles_doc |
---|
| 288 | export MODELPATH=${PWD} |
---|
| 289 | \mkdir modeles_doc |
---|
| 290 | export SRCPATH=${MODELPATH}/modeles_doc |
---|
| 291 | |
---|
| 292 | find IOIPSL/src \( -not -path '*.svn*' \ |
---|
| 293 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
| 294 | -exec bash -c 'mkdir -p '${SRCPATH}'/$( dirname {} ); cp -p {} '${SRCPATH}'/$( dirname {} )' \; |
---|
| 295 | |
---|
| 296 | find ORCHIDEE \( -not -path '*.svn*' \ |
---|
| 297 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
| 298 | -exec bash -c 'mkdir -p '${SRCPATH}'/$( dirname {} ); cp -p {} '${SRCPATH}'/$( dirname {} )' \; |
---|
| 299 | cd ${SRCPATH} |
---|
| 300 | # Use standard preprocessor to suppress all preproc directives |
---|
| 301 | \find . -name "*.f90" -exec cpp -P -C -traditional -x assembler-with-cpp ${P_P} '{}' '{}'_ \; |
---|
| 302 | \find . -name "*.f90" -print -exec mv -f '{}'_ '{}' \; |
---|
[8] | 303 | |
---|
[3447] | 304 | # use codeinc script to encaspulate code parts in Doxygen documentation |
---|
| 305 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codeinc.awk '{}' \; > /dev/null |
---|
| 306 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codeinc '{}' \; |
---|
| 307 | # use codedox script to transform almost all comments in Doxygen comments for documentation (use with care !) |
---|
| 308 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codedox.awk '{}' \; > /dev/null |
---|
| 309 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codedox '{}' \; |
---|
| 310 | |
---|
| 311 | # use codealgo script to emphasize main algorithm description of each routine in their Doxygen documentation |
---|
| 312 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codealgo.awk '{}' \; > /dev/null |
---|
| 313 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codealgo '{}' \; |
---|
| 314 | cd ../ORCHIDEE |
---|
| 315 | \rm -f ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE |
---|
| 316 | sed -e 's&MYPATH&'${MODELPATH}'&g' -e 's&SRCPATH&'${SRCPATH}'&g' \ |
---|
| 317 | -e 's&MYTAG&'${TAG}'&' -e 's&MYREV&'${REV}'&' ${SECTIONS_PARA} \ |
---|
| 318 | ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE.init > ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE |
---|
| 319 | \rm -f ${MODELPATH}/ORCHIDEE/DOC/header.tex |
---|
| 320 | sed -e "s&MYTAG&${TAG}&" -e "s&MYREV&${REV}&" \ |
---|
| 321 | ${MODELPATH}/ORCHIDEE/DOC/header.tex.init > ${MODELPATH}/ORCHIDEE/DOC/header.tex |
---|
| 322 | ln -s /home/orchidee01/maignan/ORCHIDEE/DOC/IMAGES ${MODELPATH}/ORCHIDEE/DOC/IMAGES |
---|
| 323 | gmake doc |
---|
| 324 | gmake bib |
---|
| 325 | gmake toc |
---|
| 326 | \rm -rf ${MODELPATH}/ORCHIDEE/webdoc |
---|
| 327 | \mv ${MODELPATH}/ORCHIDEE/docs/html ${MODELPATH}/ORCHIDEE/webdoc |
---|
| 328 | gmake index |
---|
| 329 | gmake toc |
---|
| 330 | \rm -rf ${SRCPATH} |
---|
| 331 | cp ${MODELPATH}/ORCHIDEE/docs/latex/refman.pdf ${MODELPATH}/ORCHIDEE/documentation.pdf |
---|
| 332 | exit |
---|
| 333 | fi |
---|
[947] | 334 | |
---|
[1385] | 335 | ##################################################################################################### |
---|
[3447] | 336 | # 5. Clean directory from files produced during previous compilation |
---|
[1773] | 337 | # -------------------------------------- |
---|
| 338 | if [[ "$clean" == "TRUE" ]] ; then |
---|
[5523] | 339 | # Remove the whole directory created during previous compilation |
---|
| 340 | rm -fr ${config_path} |
---|
| 341 | |
---|
| 342 | # Clean ORCHIDEE modules in modipsl/lib folder |
---|
[1773] | 343 | rm -f ../../lib/intersurf.mod |
---|
[5526] | 344 | rm -f ../../lib/sechiba.mod |
---|
[3225] | 345 | rm -f ../../lib/chemistry.mod |
---|
[1773] | 346 | rm -f ../../lib/liborglob.a |
---|
| 347 | rm -f ../../lib/libparallel.a |
---|
| 348 | rm -f ../../lib/libsechiba.a |
---|
| 349 | rm -f ../../lib/libstomate.a |
---|
| 350 | rm -f ../../lib/libparameters.a |
---|
| 351 | rm -f ../../lib/liborchidee_ol.a |
---|
| 352 | rm -f ../../lib/liborchidee.a |
---|
[1385] | 353 | |
---|
[5523] | 354 | echo Clean files created during previous compilation of ORCHIDEE done |
---|
| 355 | |
---|
[1773] | 356 | exit |
---|
| 357 | fi |
---|
| 358 | |
---|
[3447] | 359 | ######################################################################### |
---|
| 360 | # 6. Prepare compilation |
---|
| 361 | # |
---|
[1513] | 362 | # Add fcm in environement path |
---|
[1332] | 363 | export PATH=${fcm_path}:${PATH} |
---|
[8] | 364 | |
---|
[3447] | 365 | # Define architecture files |
---|
| 366 | if [[ "$arch" != "NONE" ]] ; then |
---|
[5526] | 367 | # First search for file in arch_path folder, if they are not there, search in arch_default_path |
---|
| 368 | if [[ -e $arch_path/arch-${arch}.path ]] ; then |
---|
| 369 | rm -f arch.path |
---|
| 370 | ln -s $arch_path/arch-${arch}.path arch.path |
---|
| 371 | elif [[ -e $arch_default_path/arch-${arch}.path ]] ; then |
---|
| 372 | rm -f arch.path |
---|
| 373 | ln -s $arch_default_path/arch-${arch}.path arch.path |
---|
| 374 | fi |
---|
| 375 | |
---|
| 376 | if [[ -e $arch_path/arch-${arch}.fcm ]] ; then |
---|
[8] | 377 | rm -f arch.fcm |
---|
[5526] | 378 | ln -s $arch_path/arch-${arch}.fcm arch.fcm |
---|
| 379 | elif [[ -e $arch_default_path/arch-${arch}.fcm ]] ; then |
---|
| 380 | rm -f arch.fcm |
---|
| 381 | ln -s $arch_default_path/arch-${arch}.fcm arch.fcm |
---|
[1332] | 382 | fi |
---|
[5526] | 383 | |
---|
| 384 | if [[ -e $arch_path/arch-${arch}.env ]] ; then |
---|
| 385 | rm -f arch.env |
---|
| 386 | ln -s $arch_path/arch-${arch}.env arch.env |
---|
| 387 | elif [[ -e $arch_default_path/arch-${arch}.env ]] ; then |
---|
| 388 | rm -f arch.env |
---|
| 389 | ln -s $arch_default_path/arch-${arch}.env arch.env |
---|
[8] | 390 | else |
---|
[5526] | 391 | ln -s .void_file arch.env |
---|
[1332] | 392 | fi |
---|
[5526] | 393 | source arch.env |
---|
| 394 | source arch.path |
---|
[8] | 395 | else |
---|
| 396 | echo "Warning : architecture not specified, taking default file <<arch.fcm>> and <<arch.path>>" |
---|
[2148] | 397 | if [[ ! -e arch.fcm ]] ; then |
---|
[5526] | 398 | echo "architecture file : << arch.fcm >> is missing, exit now...." |
---|
[8] | 399 | exit |
---|
[1332] | 400 | fi |
---|
[8] | 401 | |
---|
[5526] | 402 | if [[ -e arch.path ]] ; then |
---|
| 403 | source arch.path |
---|
| 404 | else |
---|
| 405 | echo "architecture file : << arch.path >> is missing, exit now...." |
---|
[8] | 406 | exit |
---|
[1332] | 407 | fi |
---|
[5526] | 408 | |
---|
| 409 | if [[ -e arch.env ]] ; then |
---|
| 410 | source arch.env |
---|
| 411 | fi |
---|
[1332] | 412 | fi |
---|
[5526] | 413 | |
---|
[8] | 414 | # set compiler flags |
---|
[1332] | 415 | FFLAGS="%BASE_FFLAGS" |
---|
| 416 | LD_FFLAGS="%BASE_LD" |
---|
| 417 | CPP_KEY="%FPP_DEF" |
---|
[8] | 418 | |
---|
| 419 | # set compiler flags for optimisation |
---|
[1332] | 420 | FFLAGS=${FFLAGS}" "$compile_flags |
---|
[1788] | 421 | LD_FFLAGS=${LD_FFLAGS}" "$compile_flags |
---|
[8] | 422 | |
---|
| 423 | # set compiler flags for parallelism |
---|
[1885] | 424 | echo "parallel_mode = "${parallel_mode} |
---|
| 425 | |
---|
[2148] | 426 | if [[ "$parallel_mode" == "mpi" ]] || [[ "$parallel_mode" == "MPI" ]] ; then |
---|
[1332] | 427 | FFLAGS="${FFLAGS} %MPI_FFLAGS" |
---|
| 428 | LD_FFLAGS="%MPI_LD ${LD_FFLAGS}" |
---|
| 429 | CPP_KEY="CPP_PARA ${CPP_KEY}" |
---|
[2148] | 430 | elif [[ "$parallel_mode" == "omp" ]] || [[ "$parallel_mode" == "OMP" ]] ; then |
---|
[1885] | 431 | FFLAGS="${FFLAGS} %OMP_FFLAGS" |
---|
| 432 | LD_FFLAGS="%OMP_LD ${LD_FFLAGS}" |
---|
| 433 | CPP_KEY="CPP_OMP CPP_PARA ${CPP_KEY}" |
---|
[2148] | 434 | elif [[ "$parallel_mode" == "mpi_omp" ]] || [[ "$parallel_mode" == "MPI_OMP" ]] ; then |
---|
[1885] | 435 | FFLAGS="${FFLAGS} %MPI_FFLAGS %OMP_FFLAGS" |
---|
| 436 | LD_FFLAGS="%MPI_LD %OMP_LD ${LD_FFLAGS}" |
---|
| 437 | CPP_KEY="CPP_OMP CPP_PARA ${CPP_KEY}" |
---|
[2148] | 438 | elif [[ "$parallel_mode" == "none" ]] || [[ "$parallel_mode" == "NONE" ]] || [[ "$parallel_mode" == "seq" ]] ; then |
---|
[1885] | 439 | echo "Compiling for sequential mode" |
---|
| 440 | else |
---|
| 441 | echo "This option for parallel_mode is not implemeted. Choose between mpi, omp, mpi_omp and none." |
---|
| 442 | exit |
---|
| 443 | fi |
---|
[1788] | 444 | |
---|
[3447] | 445 | # |
---|
| 446 | # Create some temporary variable to which we add as needed |
---|
| 447 | # |
---|
[5574] | 448 | INCDIR="$NETCDF_INCDIR $IOIPSL_INCDIR" |
---|
[5836] | 449 | LIBDIR="$NETCDF_LIBDIR $NETCDF_LIB $IOIPSL_LIBDIR $IOIPSL_LIB" |
---|
[1885] | 450 | |
---|
[3447] | 451 | # Do we need to link with XIOS |
---|
| 452 | # |
---|
[3838] | 453 | if [[ "$xios" == "TRUE" ]] ; then |
---|
[1788] | 454 | CPP_KEY="XIOS ${CPP_KEY}" |
---|
[5574] | 455 | INCDIR="${INCDIR} $XIOS_INCDIR" |
---|
[5836] | 456 | LIBDIR="${LIBDIR} $XIOS_LIBDIR $XIOS_LIB" |
---|
[1788] | 457 | fi |
---|
| 458 | |
---|
[4595] | 459 | # Determine if also need to compile the OASIS driver. This is only the case if the |
---|
| 460 | # path for the libraries is provided and exists |
---|
| 461 | if [ -n "$OASIS_LIBDIR" ] ; then |
---|
| 462 | is_oasisdriver_opt=TRUE |
---|
| 463 | # Check also if the provided path also exist. If not, delete the option. |
---|
| 464 | if [ ! -d ${OASIS_LIBDIR} ]; then |
---|
| 465 | is_oasisdriver_opt=FALSE |
---|
| 466 | fi |
---|
| 467 | else |
---|
| 468 | is_oasisdriver_opt=FALSE |
---|
| 469 | fi |
---|
| 470 | |
---|
[8] | 471 | # set target |
---|
[1332] | 472 | TARGET=liborchidee.a |
---|
[2148] | 473 | if [[ "$is_driver_opt" == "TRUE" ]] ; then |
---|
[5217] | 474 | TARGET="liborchidee_ol.a dim2_driver.exe orchideedriver.exe" |
---|
[1332] | 475 | fi |
---|
[3447] | 476 | if [[ "$is_other_opt" == "TRUE" ]] ; then |
---|
[5217] | 477 | TARGET="${TARGET} teststomate.exe forcesoil.exe testrouting.exe" |
---|
[3447] | 478 | fi |
---|
[8] | 479 | |
---|
[3447] | 480 | if [[ "$is_oasisdriver_opt" == "TRUE" ]] ; then |
---|
| 481 | CPP_KEY="OASIS ${CPP_KEY}" |
---|
| 482 | TARGET="${TARGET} driver2oasis.exe orchideeoasis.exe" |
---|
[5574] | 483 | INCDIR="${INCDIR} ${OASIS_INCDIR}/psmile.MPI1 ${OASIS_INCDIR}/scrip ${OASIS_INCDIR}/mct" |
---|
| 484 | LIBDIR="${LIBDIR} ${OASIS_LIBDIR} -lpsmile.MPI1 -lmct -lmpeu -lscrip" |
---|
[3447] | 485 | echo "OASIS : ${INCDIR}" |
---|
| 486 | fi |
---|
[8] | 487 | |
---|
[5523] | 488 | |
---|
[8] | 489 | # build config file |
---|
[1332] | 490 | config_fcm="config.fcm" |
---|
[8] | 491 | rm -f $config_fcm |
---|
[1117] | 492 | touch $config_fcm |
---|
[8] | 493 | |
---|
[5523] | 494 | echo "%CONFIG_PATH $config_path" >> $config_fcm |
---|
[1117] | 495 | echo "%ARCH $arch" >> $config_fcm |
---|
| 496 | echo "%FFLAGS $FFLAGS" >> $config_fcm |
---|
[8] | 497 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
| 498 | echo "%EXEC $TARGET" >> $config_fcm |
---|
| 499 | echo "%LD_FFLAGS $LD_FFLAGS" >> $config_fcm |
---|
[3447] | 500 | echo "%INCDIR ${INCDIR}" >> $config_fcm |
---|
| 501 | echo "%LIBDIR ${LIBDIR}" >> $config_fcm |
---|
[1505] | 502 | echo "%EXT_SRC $ext_src" >> $config_fcm |
---|
[8] | 503 | |
---|
| 504 | |
---|
[1773] | 505 | # Delete interface module from modipsl/lib directory |
---|
| 506 | rm -f ../../lib/intersurf.mod |
---|
[4103] | 507 | rm -f ../../lib/sechiba.mod |
---|
[1773] | 508 | |
---|
[2378] | 509 | # Check if compiling is locked |
---|
[5523] | 510 | if [ -f ${config_path}/fcm.bld.lock ] ; then |
---|
[2378] | 511 | echo "WARNING : build lock file exists" |
---|
| 512 | echo "This means that either someone else is compiling this directory right now " |
---|
| 513 | echo "or the previous compiling was interrupt abnormally." |
---|
| 514 | echo "" |
---|
| 515 | echo "Do you whant to remove this file and start compiling? [answer yes/no]" |
---|
| 516 | read answer |
---|
| 517 | if [ $answer = "yes" ] || [ $answer = "y" ] ; then |
---|
[5523] | 518 | rm -f ${config_path}/fcm.bld.lock |
---|
[2378] | 519 | else |
---|
| 520 | echo "Exit now!!!" |
---|
| 521 | exit 1 |
---|
| 522 | fi |
---|
| 523 | fi |
---|
| 524 | |
---|
[3447] | 525 | ######################################################################### |
---|
| 526 | # 7. Do the compiling |
---|
[1505] | 527 | fcm build -j $job $full |
---|
[3595] | 528 | err=$? |
---|
[5560] | 529 | |
---|
| 530 | # Check error message from fcm build |
---|
[3595] | 531 | if [ $err != 0 ] ; then |
---|
| 532 | # ERROR IN COMPILING |
---|
| 533 | echo ERROR IN COMPILING ORCHIDEE : $err |
---|
| 534 | exit 1 |
---|
| 535 | fi |
---|
[1505] | 536 | |
---|
[5576] | 537 | # Create link to bin, lib and inc folders directly in ORCHIDEE folder |
---|
| 538 | # Use rel_config_path to create link with the relative path |
---|
[5820] | 539 | rm -f bin ; rm -f lib; rm -f inc |
---|
[5576] | 540 | ln -s ${rel_config_path}/bin bin |
---|
| 541 | ln -s ${rel_config_path}/lib lib |
---|
| 542 | ln -s ${rel_config_path}/inc inc |
---|
| 543 | |
---|
[1773] | 544 | # Copy into modipsl/lib directory libraries and interface module needed by LMDZ |
---|
[5523] | 545 | cp ${config_path}/lib/lib*a ../../lib/. |
---|
[5524] | 546 | cp ${config_path}/inc/intersurf.mod ../../lib/. |
---|
| 547 | cp ${config_path}/inc/sechiba.mod ../../lib/. |
---|
[1773] | 548 | |
---|
[3447] | 549 | # Move created executables to modipsl/bin directory |
---|
[5574] | 550 | if [ -f ${config_path}/bin/dim2_driver.exe ] ; then cp -f ${config_path}/bin/dim2_driver.exe ../../bin/orchidee_ol ; fi |
---|
| 551 | if [ -f ${config_path}/bin/teststomate.exe ] ; then cp -f ${config_path}/bin/teststomate.exe ../../bin/teststomate ; fi |
---|
| 552 | if [ -f ${config_path}/bin/forcesoil.exe ] ; then cp -f ${config_path}/bin/forcesoil.exe ../../bin/forcesoil ; fi |
---|
| 553 | if [ -f ${config_path}/bin/orchideedriver.exe ] ; then cp -f ${config_path}/bin/orchideedriver.exe ../../bin/orchideedriver ; fi |
---|
| 554 | if [ -f ${config_path}/bin/testrouting.exe ] ; then cp -f ${config_path}/bin/testrouting.exe ../../bin/testrouting ; fi |
---|
| 555 | if [ -f ${config_path}/bin/driver2oasis.exe ] ; then cp -f ${config_path}/bin/driver2oasis.exe ../../bin/driver2oasis ; fi |
---|
| 556 | if [ -f ${config_path}/bin/orchideeoasis.exe ] ; then cp -f ${config_path}/bin/orchideeoasis.exe ../../bin/orchideeoasis ; fi |
---|
[1332] | 557 | |
---|
| 558 | |
---|