source: trunk/ICOSA_LMDZ/make_icosa_lmdz @ 3539

Last change on this file since 3539 was 3484, checked in by afalco, 2 months ago

ICOSA_LMDZ: overall compilation stops when compilation of a module fails.
Errors from internal calls in compilation scripts are transferred to the scripts above.
AF

  • Property svn:executable set to *
File size: 5.7 KB
Line 
1#!/bin/bash
2export PATH=$PWD/tools/FCM/bin:$PATH
3
4export ROOT=$PWD
5#set -x
6echo $0 $* > rebuild_all
7chmod a+x rebuild_all
8
9compil_mode_defined="FALSE"
10compil_mode="prod"
11
12job=1
13full_defined="FALSE"
14with_xios_defined="TRUE"
15with_orchidee_defined="FALSE"
16arch_defined="FALSE"
17parallel_defined="FALSE"
18arch_path="../ARCH"
19arch_default_path="arch"
20parallel="none"
21physics="none"
22build_deps="TRUE"
23CPP_KEY="CPP_NONE"
24ICOSA_LIB=""
25
26while (($# > 0))
27  do
28  case $1 in
29      "-h") cat <<fin
30Usage :
31make_icosa_lmdz [options] -arch arch_name -p phys
32[-h]                       : help
33[-prod / -dev / -debug]    : compilation mode: production (default) / developpement / debug .
34[-full]                    : recompile all code from scratch
35[-nodeps]                  : do not build dependencies (XIOS and IOIPSL libraries)
36 -arch arch_name           : target architecture
37[-arch_path path]          : relative PATH to directory containing multi-model
38                             path and environment arch files
39 -p phys                   : physics package (e.g. std , venus , mars, ...)
40[-p_opt "options"]         : additional options for physics package
41[-parallel type]           : parallelism (none|mpi|omp|mpi_omp)
42[-with_xios]               : compile and link with XIOS (default)
43[-job num]                 : speed up compilation by using num simulateneous
44                             compilation steps (when possible)
45fin
46          exit;;
47
48      "-p")
49          phys=$2 ; shift ; shift ;;
50
51      "-p_opt")
52          phys_opt=$2 ; shift ; shift ;;
53
54      "-prod")
55          compil_mode="prod" ; shift ;;
56
57      "-dev")
58          compil_mode="dev" ; shift ;;
59
60      "-debug")
61          compil_mode="debug" ; shift ;;
62
63      "-arch")
64          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
65
66      "-arch_path")
67          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
68
69      "-parallel")
70          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
71
72      "-job")
73          job=$2 ; shift ; shift;;
74
75      "-full")
76          full_defined="TRUE" ; shift ;;
77
78      "-nodeps")
79          build_deps="FALSE" ; shift ;;
80
81      "-with_xios")
82          with_xios_defined="TRUE" ; shift ;;
83
84      "-with_orchidee")
85          with_orchidee_defined="TRUE" ; shift ;;
86
87      *)
88          code="$1" ; shift ;;
89  esac
90done
91
92rm -f .void_file
93echo > .void_file
94rm -rf .void_dir
95mkdir .void_dir
96
97if [[ "$arch_defined" == "TRUE" ]]
98then
99  rm -f arch.path
100  rm -f arch.fcm
101  rm -f arch.env
102
103  if test -f $arch_path/arch-${arch}.path
104  then
105    ln -s $arch_path/arch-${arch}.path arch.path
106  elif test -f $arch_default_path/arch-${arch}.path
107  then
108    ln -s $arch_default_path/arch-${arch}.path arch.path
109  fi
110
111  if test -f $arch_path/arch-${arch}.fcm
112  then
113    ln -s $arch_path/arch-${arch}.fcm arch.fcm
114  elif test -f $arch_default_path/arch-${arch}.fcm
115  then
116    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
117  fi
118
119  if test -f $arch_path/arch-${arch}.env
120  then
121    ln -s $arch_path/arch-${arch}.env arch.env
122  elif test -f $arch_default_path/arch-${arch}.env
123  then
124    ln -s $arch_default_path/arch-${arch}.env arch.env
125  else
126    ln -s .void_file arch.env
127  fi
128  source arch.env
129  source arch.path
130else
131  echo "Please define a target architecture"
132  exit 1
133fi
134
135LD_FLAGS="%BASE_LD"
136
137if [[ "$compil_mode" == "prod" ]]
138then
139  COMPIL_FFLAGS="%PROD_FFLAGS"
140elif [[ "$compil_mode" == "dev" ]]
141then
142  COMPIL_FFLAGS="%DEV_FFLAGS"
143elif [[ "$compil_mode" == "debug" ]]
144then
145  COMPIL_FFLAGS="%DEBUG_FFLAGS"
146fi
147
148if [[ "$parallel" == "mpi" ]]
149then
150  CPP_KEY="$CPP_KEY CPP_USING_MPI"
151elif [[ "$parallel" == "omp" ]]
152then
153  CPP_KEY="$CPP_KEY CPP_USING_OMP"
154  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
155  LD_FLAGS="$LD_FLAGS %OMP_LD"
156elif [[ "$parallel" == "mpi_omp" ]]
157then
158  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
159  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
160  LD_FLAGS="$LD_FLAGS %OMP_LD"
161elif [[ "$parallel" == "none" ]]
162then
163  parallel="none"
164else
165  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
166  exit 1
167fi
168
169if [[ "$with_orchidee_defined" == "TRUE" ]]
170then
171  ICOSA_LIB="$ICOSA_LIB $ORCHIDEE_LIBDIR $ORCHIDEE_LIB"
172fi
173
174if [[ "$with_xios_defined" == "TRUE" ]]
175then
176  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
177  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
178  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
179fi
180
181ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
182
183rm bin/*
184
185if [[ "$full_defined" == "TRUE" ]]
186then
187  full_flag="-full"
188  full_flag2="--full"
189else
190  full_flag=""
191  full_flag2=""
192fi
193
194rm -f config.fcm
195
196echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm
197echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
198echo "%CPP_KEY $CPP_KEY" >> config.fcm
199echo "%PHYS phy$phys" >> config.fcm
200echo "%LIB $ICOSA_LIB">> config.fcm
201
202function compile_module {
203  ## function to compile each module.
204  dir=$1 # module folder
205  shift
206  cmd=$@ # command line to compile
207  if [[ -d ../$dir ]] ; then
208    cd ../$dir
209    echo "-- Compiling $dir with:"
210    echo $cmd
211    $cmd
212    if [ $? != 0 ]; then # check if fcm command worked
213      echo "In ../$dir, the following command failed:"
214      echo "$cmd"
215      exit 1
216    fi
217
218    cd -
219  else
220    echo "Error: cannot find ../$dir directory"
221    exit 1
222  fi
223}
224
225if [[ "$build_deps" == "TRUE" ]]
226then
227  compile_module IOIPSL ./makeioipsl_fcm -parallel -arch $arch -arch_path $arch_path -j $job $full_flag
228  compile_module XIOS ./make_xios --arch $arch --arch_path $arch_path --job $job $full_flag2
229fi # of if [[ "$build_deps" == "TRUE" ]]
230
231compile_module LMDZ.COMMON ./makelmdz_fcm -p $phys $phys_opt -$compil_mode -parallel $parallel -libphy -io xios -arch $arch -arch_path $arch_path -j $job $full_flag
232
233compile_module ICOSAGCM ./make_icosa -$compil_mode -parallel $parallel -external_ioipsl -with_xios -arch $arch -arch_path $arch_path -job $job $full_flag
234
235# compile interface and link
236./build --job $job $full_flag2
Note: See TracBrowser for help on using the repository browser.