123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- #!/bin/bash
- #set -x
- set -o posix
- #set -u
- #set -e
- #+
- #
- # ===============
- # maketools
- # ===============
- #
- # --------------------------
- # Compile NEMO
- # --------------------------
- #
- # SYNOPSIS
- # ========
- #
- # ::
- #
- # $ maketools
- #
- #
- # DESCRIPTION
- # ===========
- #
- #
- # This script aims :
- #
- # - to choose a tool to compile
- # - to choose compiler options
- # - to compile this tool
- #
- # Variables used :
- #
- # From user input
- #
- # - NEW_CONF : configuration to be created
- # - CMP_NAM : compiler name
- # - NBR_PRC : number of processes used to compile
- #
- # Locally defined :
- #
- # - MAIN_DIR : self explaining
- # - MODELES_DIR : " " "
- # - TOOLS_DIR : " " "
- # - NEMO_DIR : " " "
- #
- # EXAMPLES
- # ========
- #
- # ::
- #
- # $ ./maketools -t ifort_osx - j3 -n NESTING
- #
- #
- # TODO
- # ====
- #
- # option debug
- #
- #
- # EVOLUTIONS
- # ==========
- #
- # $Id: maketools 4363 2014-01-22 11:11:47Z rfurner $
- #
- #
- #
- # * creation
- #
- #-
- #- Local variables ---
- b_n=$(basename ${0})
- export MAIN_DIR=${PWD%/TOOLS*}
- export TOOLS_DIR=${MAIN_DIR}/TOOLS
- export COMPIL_DIR=${MAIN_DIR}/TOOLS/COMPILE
- export NEMO_DIR=${MAIN_DIR}/NEMO
- #-
- #- FCM and functions location ---
- export PATH=${MAIN_DIR}/EXTERNAL/fcm/bin:$PATH
- #-
- #- Choice of the options ---
- x_h="";
- x_n="";
- x_m="";
- x_t="";
- x_c="";
- x_j=1;
- while getopts :hm:n:r:j:t: V
- do
- case $V in
- (h) x_h=${OPTARG};
- echo "Usage : "${b_n} \
- " [-h] [-n name] [-m arch] [-j No] [-t tmpdir]";
- echo " -h : help";
- echo " -h institute : specific help for consortium members";
- echo " -n name : tool name, [-n help] to list existing tools";
- echo " -m arch : choose compiler, [-m help] to list exiting compilers";
- echo " -j No : number of processes used to compile (0=nocompilation)";
- echo " -t dir : remporary directory for compilation"
- echo "";
- echo "Example to compile Agrif Nesting tools";
- echo "maketools -n NESTING" ;
- echo "";
- printf "%s\n" "Available tools :" `ls ${TOOLS_DIR}|grep -v COMPILE | grep -v maketools`;
- echo "";
- . ${COMPIL_DIR}/Flist_archfile.sh ${x_h};
- echo "";
- echo "Default : previous tool and compiler";
- exit 0;;
- (n) x_n=${OPTARG};;
- (m) x_m=${OPTARG};;
- (j) x_j=${OPTARG};;
- (t) x_t=${OPTARG};;
- (:) echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
- exit 2;;
- (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
- exit 2;;
- esac
- done
- shift $(($OPTIND-1));
- #-
- #- Get the clean option
- [[ "${#@}" -ne 0 && "${@}" != clean ]] && echo "Invalid option "$@" " && exit
- [ "${#@}" -ne 0 ] && x_c="--$@"
- #-
- #- Go to NEMOGCM/TOOLS directory ---
- cd ${TOOLS_DIR}
- #-
- #- Initialisation from input ---
- export NEW_CONF=${x_n}
- NBR_PRC=${x_j}
- CMP_NAM=${x_m}
- NEMO_TDIR=${x_t:-$NEMO_TDIR}
- export NEMO_TDIR=${NEMO_TDIR:-$TOOLS_DIR}
- #- Check if the tool or the compiler exist or list it
- [ "${NEW_CONF}" == help ] && printf "%s\n" "Available tools :" `ls ${TOOLS_DIR}|grep -v COMPILE | grep -v maketools` && exit
- [ "${CMP_NAM}" == help ] && . ${COMPIL_DIR}/Flist_archfile.sh all && exit
- #- When used for the first time, choose a compiler ---
- . ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm cpp.fcm ${CMP_NAM} || exit
- #- Choose a default tool if needed ---
- #- REBUILD or last one used ---
- . ${COMPIL_DIR}/Fcheck_config.sh tools.txt ${NEW_CONF} || exit
- #- Save new configuration ---
- echo "${NEW_CONF} " > ${COMPIL_DIR}/tools.txt
- #- Make the building directory
- . ${COMPIL_DIR}/Fmake_bld.sh ${TOOLS_DIR} ${NEW_CONF} ${NEMO_TDIR} || exit
- #-
- #_ END OF CONFIGURATION PHASE
- #_
- #-
- #- Compile ---
- if [ "${NBR_PRC}" -gt 0 ]; then
- cd ${NEMO_TDIR}/${NEW_CONF} || cd -
- fcm build ${x_c} --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/bld_tools.cfg || cd -
- if [ -n "$(ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe)" ]; then
- for i in `ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe`
- do
- ln -sf ${i} ${TOOLS_DIR}/${NEW_CONF}/.
- done
- fi
- fi
- #-
- #- Come back to original directory ---
- cd -
- #-
- #- Unset variables
- ${COMPIL_DIR}/Fclean_var.sh
- exit 0;
|