source: codes/icosagcm/devel/make_icosa @ 743

Last change on this file since 743 was 743, checked in by dubos, 6 years ago

devel : fixed bug recently introduced in make_icosa

  • Property svn:executable set to *
File size: 5.1 KB
Line 
1#!/bin/bash
2
3# resolve symlinks and '..' in $PWD to avoid useless re-compilation
4cd -P $PWD
5
6echo ./make_icosa $* > rebuild
7chmod a+x rebuild
8
9compil_mode_defined="FALSE"
10compil_mode="prod"
11
12job=1
13full_defined="FALSE"
14with_xios_defined="FALSE"
15arch_defined="FALSE"
16parallel_defined="FALSE"
17arch_default_path="arch"
18arch_path="arch"
19parallel="none"
20physics="none"
21external_ioipsl="FALSE"
22external_physics="FALSE"
23no_io_defined="FALSE"
24
25CPP_KEY="CPP_NONE" 
26ICOSA_LIB=""
27
28while (($# > 0))
29  do
30  case $1 in
31      "-h") cat <<fin
32Usage :
33makegcm [options] -m arch exec
34[-h]                       : help
35[-prod / -dev / -debug]    : compilation en mode production (default) / developpement / debug .
36 -arch nom_arch            : target architecture, use paths and compilation options from arch files arch/arch-NAME.*
37 -arch_path PATH           : use arch files PATH/arch-ARCH.*
38 -parallel mpi|mpi_omp     : pure MPI or hybrid MPI/OpenMP parallelism
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      "-physics")
68          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
69
70      "-job")
71          job=$2 ; shift ; shift;;
72
73      "-full")
74          full_defined="TRUE" ; shift ;;
75
76      "-with_xios")
77          with_xios_defined="TRUE" ; shift ;;
78 
79      "-no_io")
80          no_io_defined="TRUE" ; shift ;;
81 
82      "-external_ioipsl")
83          external_ioipsl="TRUE" ; shift ;;
84
85      "-external_physics")
86          external_physics="TRUE" ; shift ;;
87
88      *)
89          code="$1" ; shift ;;
90  esac
91done
92
93rm -f .void_file
94echo > .void_file
95rm -rf .void_dir
96mkdir .void_dir
97
98function link_if_exists()
99{
100  suffix=$1
101  rm -f arch.$suffix
102  if test -f $arch_path/arch-${arch}.${suffix}
103  then
104    ln -s $arch_path/arch-${arch}.${suffix} arch.${suffix}
105  elif test -f $arch_default_path/arch-${arch}.${suffix}
106  then
107    ln -s $arch_default_path/arch-${arch}.${suffix} arch.${suffix}
108  else
109    ln -sf .void_file arch.$suffix
110  fi   
111}
112
113if [[ "$arch_defined" == "TRUE" ]]
114then
115  for suffix in env path fcm opt ; do link_if_exists $suffix ; done
116
117  source arch.env
118  source arch.path
119
120else
121  echo "Veuillez definir une architecture cible"
122  exit 1
123fi
124
125LD_FLAGS="%BASE_LD"
126COMPIL_FFLAGS=""
127
128if [[ "$parallel" == "mpi" ]]
129then
130  CPP_KEY="$CPP_KEY CPP_USING_MPI"
131elif [[ "$parallel" == "omp" ]]
132then
133  CPP_KEY="$CPP_KEY CPP_USING_OMP"
134  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
135  LD_FLAGS="$LD_FLAGS %OMP_LD"
136elif [[ "$parallel" == "mpi_omp" ]]
137then
138  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
139  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
140  LD_FLAGS="$LD_FLAGS %OMP_LD"
141elif [[ "$parallel" == "none" ]]
142then
143  parallel="none"
144else
145  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
146  exit 1
147fi
148
149if [[ "$physics" == "lmdz_generic" ]]
150then
151  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
152  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
153  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
154fi
155
156if [[ "$no_io_defined" == "TRUE" ]]
157then
158  CPP_KEY="$CPP_KEY CPP_NO_IO"
159  with_xios_defined="FALSE"
160fi 
161
162if [[ "$with_xios_defined" == "TRUE" ]]
163then
164  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
165  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
166  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
167fi 
168
169if [[ "$external_ioipsl" == "TRUE" ]]
170then
171  ioipsl_path=".void_dir"
172  use_ioipsl="use::ioipsl"
173  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
174  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
175else
176  ioipsl_path="tools/ioipsl"
177  use_ioipsl=""
178fi 
179
180if [[ "$external_physics" == "TRUE" ]]
181then
182  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
183fi
184
185if [[ "$no_io_defined" == "FALSE" ]]
186then
187  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
188  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
189fi
190
191if [[ "$compil_mode" == "prod" ]]
192then
193  HOPT_FFLAGS="%FAST_FFLAGS $COMPIL_FFLAGS"
194  COMPIL_FFLAGS="%PROD_FFLAGS $COMPIL_FFLAGS"
195elif [[ "$compil_mode" == "dev" ]]
196then
197  COMPIL_FFLAGS="%DEV_FFLAGS $COMPIL_FFLAGS"
198  HOPT_FFLAGS=$COMPIL_FFLAGS
199elif [[ "$compil_mode" == "debug" ]]
200then
201  COMPIL_FFLAGS="%DEBUG_FFLAGS $COMPIL_FFLAGS"
202  HOPT_FFLAGS=$COMPIL_FFLAGS
203fi
204
205rm -f config.fcm
206
207echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
208echo "%HOPT_FFLAGS $HOPT_FFLAGS" >> config.fcm
209echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
210echo "%CPP_KEY $CPP_KEY" >> config.fcm
211echo "%LIB $ICOSA_LIB">> config.fcm
212echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
213echo "%USE_IOIPSL $use_ioipsl">> config.fcm
214
215if [[ "$full_defined" == "TRUE" ]]
216then
217  ./build --job $job --full
218else
219  ./build --job $job
220fi
Note: See TracBrowser for help on using the repository browser.