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