source: ICOSA_LMDZ/make_icosa_lmdz @ 5699

Last change on this file since 5699 was 5596, checked in by yann meurdesoif, 8 months ago

Make a wrapper for OASIS library
YM

File size: 5.9 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  COMPIL_FFLAGS="$COMPIL_FFLAGS $OASIS_INCDIR"
191  CPP_KEY="$CPP_KEY CPP_USING_OASIS"
192  ICOSA_LIB="$ICOSA_LIB $OASIS_LIBDIR $OASIS_LIB"
193fi
194
195
196if [[ "$with_xios_defined" == "TRUE" ]]
197then
198  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
199  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
200  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
201fi 
202
203ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB $NETCDF_LIBDIR $NETCDF_LIB $NETCDF95_LIBDIR $NETCDF95_LIB $HDF5_LIBDIR $HDF5_LIB"
204
205rm bin/*
206
207if [[ "$full_defined" == "TRUE" ]]
208then
209  full_flag="-full"
210  full_flag2="--full"
211else 
212  full_flag=""
213  full_flag2=""
214fi
215
216rm -f config.fcm
217
218echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR $NETCDF95_INCDIR" >> config.fcm
219echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
220echo "%CPP_KEY $CPP_KEY" >> config.fcm
221echo "%PHYS phy$phys" >> config.fcm
222echo "%LIB $ICOSA_LIB">> config.fcm
223
224if [[ "$build_deps" == "TRUE" ]]
225then
226
227    cd ../IOIPSL
228    ./makeioipsl_fcm -$compil_mode -parallel -arch $arch -arch_path $arch_path -j $job $full_flag  || exit 1
229    cd -
230
231    cd ../XIOS
232    ./make_xios --$compil_mode --arch $arch --arch_path $arch_path --job $job $full_flag2 || exit 1
233    cd -
234
235    if [[ "$with_orchidee_defined" == "TRUE" ]]
236    then
237        cd ../ORCHIDEE
238        ./makeorchidee_fcm -$compil_mode -parallel $parallel -xios2 -arch $arch -arch_path $arch_path -j $job $full_flag  || exit 1
239        cd -
240    fi
241
242    cd ../LMDZ
243    lmdz_veget="false"
244    if [[ "$with_orchidee_defined" == "TRUE" ]]
245    then
246        lmdz_veget="orchidee2.0 -cpp ORCHIDEE_NOZ0H"
247    fi
248    ./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
249    cd -
250
251    cd ../DYNAMICO
252    ./make_icosa -$compil_mode -parallel $parallel -external_ioipsl -with_xios -arch $arch -arch_path $arch_path -job $job $full_flag || exit 1
253    cd -
254fi
255
256./build --job $job $full_flag2
Note: See TracBrowser for help on using the repository browser.