source: codes/icosagcm/devel/make_icosa @ 535

Last change on this file since 535 was 535, checked in by dubos, 7 years ago

devel : allow inclusion of macro-generated kernels

  • Property svn:executable set to *
File size: 5.4 KB
Line 
1#!/bin/bash
2export PATH=$PWD/tools/FCM/bin:$PATH
3
4echo ./make_icosa $* > rebuild
5chmod a+x rebuild
6
7compil_mode_defined="FALSE"
8compil_mode="prod"
9
10job=1
11full_defined="FALSE"
12with_xios_defined="FALSE"
13arch_defined="FALSE"
14parallel_defined="FALSE"
15dysl_defined="FALSE"
16arch_default_path="arch"
17arch_path="arch"
18parallel="none"
19physics="none"
20external_ioipsl="FALSE"
21external_physics="FALSE"
22no_io_defined="FALSE"
23
24CPP_KEY="CPP_NONE" 
25ICOSA_LIB=""
26
27while (($# > 0))
28  do
29  case $1 in
30      "-h") cat <<fin
31Usage :
32makegcm [options] -m arch exec
33[-h]                       : help
34[-prod / -dev / -debug]    : compilation en mode production (default) / developpement / debug .
35 -arch nom_arch            : target architecture, use paths and compilation options from arch files arch/arch-NAME.*
36 -arch_path PATH           : use arch files PATH/arch-ARCH.*
37 -parallel mpi|mpi_omp     : pure MPI or hybrid MPI/OpenMP parallelism
38 -dysl                     : use macro-generated code for dynamics kernels (default : hand-written code)
39 -job N                    : parallel compilation as with make -j N
40 -full                     : full compilation
41 -with_xios                : use XIOS for I/O (default is NetCDF-CF on native grid)
42 -no_io                    : disable I/O altogether
43 -external_ioipsl PATH     : use IOIPSL from PATH rather than tools/ioipsl
44 -physics lmdz_generic     : use LMDZ generic physics (planets)
45 -external_physics         : allows external physics
46fin
47          exit;;
48
49      "-prod")
50          compil_mode="prod" ; shift ;;
51
52      "-dev")
53          compil_mode="dev" ; shift ;;
54
55      "-debug")
56          compil_mode="debug" ; shift ;;
57
58      "-arch")
59          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
60 
61      "-arch_path")
62          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
63
64      "-parallel")
65          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
66
67      "-dysl")
68          dysl_defined="TRUE"; shift ;;
69
70      "-physics")
71          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
72
73      "-job")
74          job=$2 ; shift ; shift;;
75
76      "-full")
77          full_defined="TRUE" ; shift ;;
78
79      "-with_xios")
80          with_xios_defined="TRUE" ; shift ;;
81 
82      "-no_io")
83          no_io_defined="TRUE" ; shift ;;
84 
85      "-external_ioipsl")
86          external_ioipsl="TRUE" ; shift ;;
87
88      "-external_physics")
89          external_physics="TRUE" ; shift ;;
90
91      *)
92          code="$1" ; shift ;;
93  esac
94done
95
96rm -f .void_file
97echo > .void_file
98rm -rf .void_dir
99mkdir .void_dir
100
101if [[ "$arch_defined" == "TRUE" ]]
102then
103  rm -f arch.path
104  rm -f arch.fcm
105  rm -f arch.env
106
107  if test -f $arch_path/arch-${arch}.path
108  then
109    ln -s $arch_path/arch-${arch}.path arch.path
110  elif test -f $arch_default_path/arch-${arch}.path
111  then
112    ln -s $arch_default_path/arch-${arch}.path arch.path
113  fi
114       
115  if test -f $arch_path/arch-${arch}.fcm
116  then
117    ln -s $arch_path/arch-${arch}.fcm arch.fcm
118  elif test -f $arch_default_path/arch-${arch}.fcm
119  then
120    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
121  fi
122
123  if test -f $arch_path/arch-${arch}.env
124  then
125    ln -s $arch_path/arch-${arch}.env arch.env
126  elif test -f $arch_default_path/arch-${arch}.env
127  then
128    ln -s $arch_default_path/arch-${arch}.env arch.env
129  else
130    ln -s .void_file arch.env
131  fi
132  source arch.env
133  source arch.path
134else
135  echo "Veuillez definir une architecture cible"
136  exit 1
137fi
138
139LD_FLAGS="%BASE_LD"
140
141if [[ "$compil_mode" == "prod" ]]
142then
143  COMPIL_FFLAGS="%PROD_FFLAGS"
144elif [[ "$compil_mode" == "dev" ]]
145then
146  COMPIL_FFLAGS="%DEV_FFLAGS"
147elif [[ "$compil_mode" == "debug" ]]
148then
149  COMPIL_FFLAGS="%DEBUG_FFLAGS"
150fi
151
152if [[ "$parallel" == "mpi" ]]
153then
154  CPP_KEY="$CPP_KEY CPP_USING_MPI"
155elif [[ "$parallel" == "omp" ]]
156then
157  CPP_KEY="$CPP_KEY CPP_USING_OMP"
158  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
159  LD_FLAGS="$LD_FLAGS %OMP_LD"
160elif [[ "$parallel" == "mpi_omp" ]]
161then
162  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
163  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
164  LD_FLAGS="$LD_FLAGS %OMP_LD"
165elif [[ "$parallel" == "none" ]]
166then
167  parallel="none"
168else
169  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
170  exit 1
171fi
172
173if [[ "$physics" == "lmdz_generic" ]]
174then
175  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
176  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
177  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
178fi
179
180if [[ "$no_io_defined" == "TRUE" ]]
181then
182  CPP_KEY="$CPP_KEY CPP_NO_IO"
183  with_xios_defined="FALSE"
184fi 
185
186if [[ "$dysl_defined" == "TRUE" ]]
187then
188  CPP_KEY="$CPP_KEY CPP_DYSL"
189fi 
190
191if [[ "$with_xios_defined" == "TRUE" ]]
192then
193  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
194  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
195  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
196fi 
197
198if [[ "$external_ioipsl" == "TRUE" ]]
199then
200  ioipsl_path=".void_dir"
201  use_ioipsl="use::ioipsl"
202  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
203  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
204else
205  ioipsl_path="tools/ioipsl"
206  use_ioipsl=""
207fi 
208
209if [[ "$external_physics" == "TRUE" ]]
210then
211  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
212fi
213
214if [[ "$no_io_defined" == "FALSE" ]]
215then
216  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
217  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
218fi
219
220rm -f config.fcm
221
222echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
223echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
224echo "%CPP_KEY $CPP_KEY" >> config.fcm
225echo "%LIB $ICOSA_LIB">> config.fcm
226echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
227echo "%USE_IOIPSL $use_ioipsl">> config.fcm
228
229if [[ "$full_defined" == "TRUE" ]]
230then
231  ./build --job $job --full
232else
233  ./build --job $job
234fi
Note: See TracBrowser for help on using the repository browser.