source: ICOSA_LMDZ/make_icosa_lmdz @ 5436

Last change on this file since 5436 was 4616, checked in by acozic, 18 months ago

standardized names for environment variables managed by files arch.path

File size: 5.8 KB
Line 
1#!/bin/bash
2#set -x
3
4# Use FCM from DYNAMICO
5export PATH=$PWD/../DYNAMICO/tools/FCM/bin:$PATH
6export ROOT=$PWD
7
8echo $0 $* > rebuild_all
9chmod a+x rebuild_all
10
11compil_mode_defined="FALSE"
12compil_mode="prod"
13
14job=1
15full_defined="FALSE"
16with_xios_defined="TRUE"
17with_orchidee_defined="FALSE"
18with_inca_defined="FALSE"
19with_oasis_defined="FALSE"
20arch_defined="FALSE"
21parallel_defined="FALSE"
22arch_path="../ARCH"
23arch_default_path="arch"
24parallel="none"
25phys="none"
26build_deps="TRUE"
27CPP_KEY="CPP_NONE" 
28ICOSA_LIB=""
29rrtm="false"
30
31while (($# > 0))
32  do
33  case $1 in
34      "-h") cat <<fin
35Usage :
36makegcm [options] -m arch -p phys  exec
37[-h]                       : help
38[-prod / -dev / -debug]    : compilation en mode production (default) / developpement / debug .
39[-nodeps]                  : do not build dependencies (XIOS, IOIPSL, LMDZ, DYNAMICO must be compiled already)
40 -arch nom_arch            : nom de l\'architecture cible
41 -p phys                   : physics package (e.g. std , venus , ...)
42[-p_opt "options"]         : additional options for physics package
43fin
44          exit;;
45
46      "-p")
47          phys=$2 ; shift ; shift ;;
48     
49      "-p_opt")
50          phys_opt=$2 ; shift ; shift ;;
51
52      "-rrtm")
53          rrtm=$2 ; shift ; shift ;;
54         
55      "-prod")
56          compil_mode="prod" ; shift ;;
57
58      "-dev")
59          compil_mode="dev" ; shift ;;
60
61      "-debug")
62          compil_mode="debug" ; shift ;;
63
64      "-arch")
65          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
66 
67      "-arch_path")
68          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
69
70      "-parallel")
71          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
72
73      "-job")
74          job=$2 ; shift ; shift;;
75
76      "-full")
77          full_defined="TRUE" ; shift ;;
78
79      "-nodeps")
80          build_deps="FALSE" ; shift ;;
81
82      "-with_xios")
83          with_xios_defined="TRUE" ; shift ;;
84
85      "-with_orchidee")
86          with_orchidee_defined="TRUE" ; shift ;;
87
88      "-with_inca")
89          with_inca_defined="TRUE" ; shift ;;
90
91      "-with_oasis")
92      with_oasis_defined="TRUE" ; shift ;;
93
94
95      *)
96          code="$1" ; shift ;;
97  esac
98done
99
100rm -f .void_file
101echo > .void_file
102rm -rf .void_dir
103mkdir .void_dir
104
105if [[ "$arch_defined" == "TRUE" ]]
106then
107  rm -f arch.path
108  rm -f arch.fcm
109  rm -f arch.env
110
111  if test -f $arch_path/arch-${arch}.path
112  then
113    ln -s $arch_path/arch-${arch}.path arch.path
114  elif test -f $arch_default_path/arch-${arch}.path
115  then
116    ln -s $arch_default_path/arch-${arch}.path arch.path
117  fi
118       
119  if test -f $arch_path/arch-${arch}.fcm
120  then
121    ln -s $arch_path/arch-${arch}.fcm arch.fcm
122  elif test -f $arch_default_path/arch-${arch}.fcm
123  then
124    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
125  fi
126
127  if test -f $arch_path/arch-${arch}.env
128  then
129    ln -s $arch_path/arch-${arch}.env arch.env
130  elif test -f $arch_default_path/arch-${arch}.env
131  then
132    ln -s $arch_default_path/arch-${arch}.env arch.env
133  else
134    ln -s .void_file arch.env
135  fi
136  source arch.env
137  source arch.path
138else
139  echo "Please define a target architecture"
140  exit 1
141fi
142
143LD_FLAGS="%BASE_LD"
144
145if [[ "$compil_mode" == "prod" ]]
146then
147  COMPIL_FFLAGS="%PROD_FFLAGS"
148elif [[ "$compil_mode" == "dev" ]]
149then
150  COMPIL_FFLAGS="%DEV_FFLAGS"
151elif [[ "$compil_mode" == "debug" ]]
152then
153  COMPIL_FFLAGS="%DEBUG_FFLAGS"
154fi
155
156if [[ "$parallel" == "mpi" ]]
157then
158  CPP_KEY="$CPP_KEY CPP_USING_MPI"
159elif [[ "$parallel" == "omp" ]]
160then
161  CPP_KEY="$CPP_KEY CPP_USING_OMP"
162  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
163  LD_FLAGS="$LD_FLAGS %OMP_LD"
164elif [[ "$parallel" == "mpi_omp" ]]
165then
166  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
167  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
168  LD_FLAGS="$LD_FLAGS %OMP_LD"
169elif [[ "$parallel" == "none" ]]
170then
171  parallel="none"
172else 
173  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
174  exit 1
175fi
176
177if [[ "$with_orchidee_defined" == "TRUE" ]]
178then
179  ICOSA_LIB="$ICOSA_LIB $ORCH_LIBDIR $ORCH_LIB"
180fi 
181
182if [[ "$with_inca_defined" == "TRUE" ]]
183then
184  CPP_KEY="$CPP_KEY INCA"
185  ICOSA_LIB="$ICOSA_LIB $INCA_LIBDIR $INCA_LIB"
186fi 
187
188if [[ "$with_oasis_defined" == "TRUE" ]]
189then
190  ICOSA_LIB="$ICOSA_LIB $OASIS_LIBDIR $OASIS_LIB"
191fi
192
193
194if [[ "$with_xios_defined" == "TRUE" ]]
195then
196  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
197  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
198  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
199fi 
200
201ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB $NETCDF_LIBDIR $NETCDF_LIB $NETCDF95_LIBDIR $NETCDF95_LIB $HDF5_LIBDIR $HDF5_LIB"
202
203rm bin/*
204
205if [[ "$full_defined" == "TRUE" ]]
206then
207  full_flag="-full"
208  full_flag2="--full"
209else 
210  full_flag=""
211  full_flag2=""
212fi
213
214rm -f config.fcm
215
216echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR $NETCDF95_INCDIR" >> config.fcm
217echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
218echo "%CPP_KEY $CPP_KEY" >> config.fcm
219echo "%PHYS phy$phys" >> config.fcm
220echo "%LIB $ICOSA_LIB">> config.fcm
221
222if [[ "$build_deps" == "TRUE" ]]
223then
224
225    cd ../IOIPSL
226    ./makeioipsl_fcm -$compil_mode -parallel -arch $arch -arch_path $arch_path -j $job $full_flag  || exit 1
227    cd -
228
229    cd ../XIOS
230    ./make_xios --$compil_mode --arch $arch --arch_path $arch_path --job $job $full_flag2 || exit 1
231    cd -
232
233    if [[ "$with_orchidee_defined" == "TRUE" ]]
234    then
235        cd ../ORCHIDEE
236        ./makeorchidee_fcm -$compil_mode -parallel $parallel -xios2 -arch $arch -arch_path $arch_path -j $job $full_flag  || exit 1
237        cd -
238    fi
239
240    cd ../LMDZ
241    lmdz_veget="false"
242    if [[ "$with_orchidee_defined" == "TRUE" ]]
243    then
244        lmdz_veget="orchidee2.0 -cpp ORCHIDEE_NOZ0H"
245    fi
246    ./makelmdz_fcm -p $phys $phys_opt -rrtm $rrtm -$compil_mode -mem -parallel $parallel -libphy -io xios -v $lmdz_veget -arch $arch -arch_path $arch_path -j $job $full_flag || exit 1
247    cd -
248
249    cd ../DYNAMICO
250    ./make_icosa -$compil_mode -parallel $parallel -external_ioipsl -with_xios -arch $arch -arch_path $arch_path -job $job $full_flag || exit 1
251    cd -
252fi
253
254./build --job $job $full_flag2
Note: See TracBrowser for help on using the repository browser.