source: codes/icosagcm/devel/make_icosa

Last change on this file was 1009, checked in by dubos, 4 years ago

devel : signature.f90 is a generated file, do not track with svn

  • Property svn:executable set to *
File size: 5.9 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
46 -mixed_prec               : compiles unstructured dynamics in single precision (float32)
47fin
48          exit;;
49
50      "-prod")
51          compil_mode="prod" ; shift ;;
52
53      "-dev")
54          compil_mode="dev" ; shift ;;
55
56      "-debug")
57          compil_mode="debug" ; shift ;;
58
59      "-arch")
60          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
61 
62      "-arch_path")
63          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
64
65      "-parallel")
66          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
67
68      "-physics")
69          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
70
71      "-job")
72          job=$2 ; shift ; shift;;
73
74      "-full")
75          full_defined="TRUE" ; shift ;;
76
77      "-with_xios")
78          with_xios_defined="TRUE" ; shift ;;
79 
80      "-no_io")
81          no_io_defined="TRUE" ; shift ;;
82 
83      "-external_ioipsl")
84          external_ioipsl="TRUE" ; shift ;;
85
86      "-external_physics")
87          external_physics="TRUE" ; shift ;;
88
89      "-mixed_prec")
90          mixed_prec="TRUE" ; shift ;;
91      *)
92          code="$1" ; shift ;;
93  esac
94done
95
96rm -f .void_file
97echo > .void_file
98rm -rf .void_dir
99mkdir .void_dir
100
101function link_if_exists()
102{
103  suffix=$1
104  rm -f arch.$suffix
105  if test -f $arch_path/arch-${arch}.${suffix}
106  then
107    ln -s $arch_path/arch-${arch}.${suffix} arch.${suffix}
108  elif test -f $arch_default_path/arch-${arch}.${suffix}
109  then
110    ln -s $arch_default_path/arch-${arch}.${suffix} arch.${suffix}
111  else
112    ln -sf .void_file arch.$suffix
113  fi   
114}
115
116if [[ "$arch_defined" == "TRUE" ]]
117then
118  for suffix in env path fcm opt ; do link_if_exists $suffix ; done
119
120  source arch.env
121  source arch.path
122
123else
124  echo "Veuillez definir une architecture cible"
125  exit 1
126fi
127
128LD_FLAGS="%BASE_LD"
129COMPIL_FFLAGS=""
130
131if [[ "$parallel" == "mpi" ]]
132then
133  CPP_KEY="$CPP_KEY CPP_USING_MPI"
134elif [[ "$parallel" == "omp" ]]
135then
136  CPP_KEY="$CPP_KEY CPP_USING_OMP"
137  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
138  LD_FLAGS="$LD_FLAGS %OMP_LD"
139elif [[ "$parallel" == "mpi_omp" ]]
140then
141  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
142  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
143  LD_FLAGS="$LD_FLAGS %OMP_LD"
144elif [[ "$parallel" == "none" ]]
145then
146  parallel="none"
147else
148  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
149  exit 1
150fi
151
152if [[ "$physics" == "lmdz_generic" ]]
153then
154  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
155  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
156  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
157fi
158
159if [[ "$no_io_defined" == "TRUE" ]]
160then
161  CPP_KEY="$CPP_KEY CPP_NO_IO"
162  with_xios_defined="FALSE"
163fi 
164
165if [[ "$with_xios_defined" == "TRUE" ]]
166then
167  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
168  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
169  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
170fi 
171
172if [[ "$external_ioipsl" == "TRUE" ]]
173then
174  ioipsl_path=".void_dir"
175  use_ioipsl="use::ioipsl"
176  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
177  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
178else
179  ioipsl_path="tools/ioipsl"
180  use_ioipsl=""
181fi 
182
183if [[ "$external_physics" == "TRUE" ]]
184then
185  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
186fi
187
188if [[ "$mixed_prec" == "TRUE" ]]
189then
190  CPP_KEY="$CPP_KEY CPP_MIXED_PREC"
191fi
192
193if [[ "$no_io_defined" == "FALSE" ]]
194then
195  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
196  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
197fi
198
199if [[ "$compil_mode" == "prod" ]]
200then
201  HOPT_FFLAGS="%FAST_FFLAGS $COMPIL_FFLAGS"
202  COMPIL_FFLAGS="%PROD_FFLAGS $COMPIL_FFLAGS"
203elif [[ "$compil_mode" == "dev" ]]
204then
205  COMPIL_FFLAGS="%DEV_FFLAGS $COMPIL_FFLAGS"
206  HOPT_FFLAGS=$COMPIL_FFLAGS
207elif [[ "$compil_mode" == "debug" ]]
208then
209  COMPIL_FFLAGS="%DEBUG_FFLAGS $COMPIL_FFLAGS"
210  HOPT_FFLAGS=$COMPIL_FFLAGS
211fi
212
213rm -f config.fcm
214
215echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
216echo "%HOPT_FFLAGS %BASE_FFLAGS $HOPT_FFLAGS" >> config.fcm
217echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
218echo "%CPP_KEY $CPP_KEY" >> config.fcm
219echo "%LIB $ICOSA_LIB">> config.fcm
220echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
221echo "%USE_IOIPSL $use_ioipsl">> config.fcm
222
223# generate signature
224function signature()
225{
226    cat <<EOF
227! Signature file generated by make_icosa.
228! Please do NOT track with svn.
229MODULE signature_mod
230IMPLICIT NONE
231CONTAINS
232SUBROUTINE print_signature
233EOF
234    (cd -P src ; svn info .. ; svn status -q) | (while read line ; do echo "   PRINT *, '$line' " ; done)
235    cat <<EOF
236END SUBROUTINE print_signature
237END MODULE signature_mod
238EOF
239}
240
241signature > signature.f90
242diff -q signature.f90 src/base/signature.f90 || cp -f signature.f90 src/base/
243rm -f signature.f90
244
245if [[ "$full_defined" == "TRUE" ]]
246then
247  ./build --job $job --full
248else
249  ./build --job $job
250fi
251
252# force recompilation of cython modules
253touch Python/*/*.pyx
Note: See TracBrowser for help on using the repository browser.