source: branches/DEV_r1879_FCM/NEMOGCM/TOOLS/maketools @ 2136

Last change on this file since 2136 was 2136, checked in by rblod, 11 years ago

add compilation of tools like rebuild or nesting tools

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1#!/bin/bash
2#set -x
3set -o posix
4#set -u
5#set -e
6#+
7#
8# ===============
9# maketools
10# ===============
11#
12# --------------------------
13# Compile NEMO
14# --------------------------
15#
16# SYNOPSIS
17# ========
18#
19# ::
20#
21#  $ makenetools
22#
23#
24# DESCRIPTION
25# ===========
26#
27#
28# This script aims :
29#
30# - to choose a tool to compile
31# - to choose compiler options 
32# - to compile this tool
33#
34#  Variables used :
35#
36#  From user input
37#
38# - NEW_CONF    : configuration to be created
39# - CMP_NAM     : compiler name
40# - NBR_PRC     : number of processes used to compile 
41#
42#  Locally defined :
43#
44# - MAIN_DIR : self explaining
45# - MODELES_DIR :   "    "    "
46# - TOOLS_DIR   :   "    "    "
47# - NEMO_DIR    :   "    "    "
48#
49# EXAMPLES
50# ========
51#
52# ::
53#
54#  $ ./maketools -t ifort_osx - j3 -n NESTING
55#
56#
57# TODO
58# ====
59#
60# option debug
61#
62#
63# EVOLUTIONS
64# ==========
65#
66# $Id$
67#
68#
69# - rblod 2010-06-20T16:11:47Z
70#
71#   * creation
72#
73#-
74
75#- Local variables ---
76b_n=$(basename ${0})
77export MAIN_DIR=${PWD%/NEMOGCM*}/NEMOGCM
78export TOOLS_DIR=${MAIN_DIR}/TOOLS
79export COMPIL_DIR=${MAIN_DIR}/TOOLS/COMPILE
80export NEMO_DIR=${MAIN_DIR}/NEMO
81#-
82#- FCM and functions location ---
83export PATH=${MAIN_DIR}/EXTERNAL/fcm/bin:$PATH
84
85#-
86#- Choice of the options ---
87x_n="";
88x_m="";
89x_t="";
90x_j=1;
91while getopts :hld:n:r:m:j:t: V
92  do
93    case $V in
94      (h)  echo "Usage   : "${b_n} \
95                " [-h] [-l] [-n name] [-m arch] [-j No] [-t tmpdir]";
96           echo " -h  : help";
97           echo " -l        : list existing tools";
98           echo " -n name : tool name";
99           echo " -m arch : choose machine";
100           echo " -j No  : number of processes used to compile (0=nocompilation)";
101           echo " -t dir  : remporary directory for compilation"
102           echo "";
103           echo "Example to compile Agrif Nesting tools";
104           echo "maketools -n NESTING" ;
105           echo "";
106           echo "Defaults    : ";
107           echo "";
108           exit 0;;
109      (n)  x_n=${OPTARG};;
110      (m)  x_m=${OPTARG};;
111      (j)  x_j=${OPTARG};;
112      (t)  x_t=${OPTARG};;
113      (l)  echo "Available tools :"; ls ${TOOLS_DIR}|grep -v COMPILE | grep -v maketools; exit;;
114      (:)  echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;
115           exit 2;;
116      (\?) echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;
117           exit 2;;
118    esac
119  done
120shift $(($OPTIND-1));
121
122#-
123#- Go to NEMOGCM/TOOLS directory ---
124cd ${TOOLS_DIR}
125
126#-
127#- Initialisation from input ---
128export NEW_CONF=${x_n}
129NBR_PRC=${x_j}
130CMP_NAM=${x_m}
131NEMO_TDIR=${x_t:-$NEMO_TDIR}
132export NEMO_TDIR=${NEMO_TDIR:-$CONFIG_DIR}
133
134#- When used for the first time, choose a compiler ---
135. ${COMPIL_DIR}/Fcheck_archfile.sh arch_tools.fcm ${CMP_NAM} || exit
136
137. ${COMPIL_DIR}/Fmake_bld.sh ${TOOLS_DIR} ${NEW_CONF} ${NEMO_TDIR} || exit
138
139#-
140#_ END OF CONFIGURATION PHASE
141#_
142
143#-
144#- Compile ---
145
146if [ "${NBR_PRC}" -gt 0 ]; then
147cd ${NEMO_TDIR}/${NEW_CONF} || cd -
148
149fcm build --ignore-lock -v 1 -j ${NBR_PRC} ${COMPIL_DIR}/bld_tools.cfg || cd -
150for i in `ls ${NEMO_TDIR}/${NEW_CONF}/BLD/bin/*.exe`
151   do
152   ln -sf ${i}  ${TOOLS_DIR}/${NEW_CONF}/.
153   done
154fi
155
156#-
157#- Come back to original directory ---
158cd -
159
160#-
161#- Unset variables
162${COMPIL_DIR}/Fclean_var.sh
163
164
165exit 0;
Note: See TracBrowser for help on using the repository browser.