source: codes/icosagcm/devel/make_icosa @ 841

Last change on this file since 841 was 841, checked in by dubos, 5 years ago

devel : update signature.f90 (=> rebuild) only if necessary

  • Property svn:executable set to *
File size: 5.9 KB
RevLine 
[12]1#!/bin/bash
2
[730]3# resolve symlinks and '..' in $PWD to avoid useless re-compilation
4cd -P $PWD
5
[279]6echo ./make_icosa $* > rebuild
7chmod a+x rebuild
8
[12]9compil_mode_defined="FALSE"
10compil_mode="prod"
11
[89]12job=1
13full_defined="FALSE"
[171]14with_xios_defined="FALSE"
[12]15arch_defined="FALSE"
[28]16parallel_defined="FALSE"
[497]17arch_default_path="arch"
[332]18arch_path="arch"
[28]19parallel="none"
[327]20physics="none"
[347]21external_ioipsl="FALSE"
22external_physics="FALSE"
[488]23no_io_defined="FALSE"
[347]24
[28]25CPP_KEY="CPP_NONE" 
[171]26ICOSA_LIB=""
[12]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 .
[535]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
[744]46 -mixed_prec               : compiles unstructured dynamics in single precision (float32)
[12]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 ;;
[332]61 
62      "-arch_path")
63          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
[12]64
[28]65      "-parallel")
66          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
67
[327]68      "-physics")
69          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
70
[89]71      "-job")
[103]72          job=$2 ; shift ; shift;;
[89]73
74      "-full")
[103]75          full_defined="TRUE" ; shift ;;
[89]76
[171]77      "-with_xios")
78          with_xios_defined="TRUE" ; shift ;;
[488]79 
[535]80      "-no_io")
[488]81          no_io_defined="TRUE" ; shift ;;
82 
[347]83      "-external_ioipsl")
84          external_ioipsl="TRUE" ; shift ;;
85
86      "-external_physics")
87          external_physics="TRUE" ; shift ;;
88
[744]89      "-mixed_prec")
90          mixed_prec="TRUE" ; shift ;;
[12]91      *)
92          code="$1" ; shift ;;
93  esac
94done
95
[28]96rm -f .void_file
97echo > .void_file
98rm -rf .void_dir
99mkdir .void_dir
100
[738]101function link_if_exists()
102{
103  suffix=$1
[743]104  rm -f arch.$suffix
[738]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}
[743]111  else
112    ln -sf .void_file arch.$suffix
113  fi   
[738]114}
115
[12]116if [[ "$arch_defined" == "TRUE" ]]
117then
[738]118  for suffix in env path fcm opt ; do link_if_exists $suffix ; done
[497]119
[28]120  source arch.env
[12]121  source arch.path
[738]122
[12]123else
124  echo "Veuillez definir une architecture cible"
125  exit 1
126fi
127
[152]128LD_FLAGS="%BASE_LD"
[738]129COMPIL_FFLAGS=""
[152]130
[28]131if [[ "$parallel" == "mpi" ]]
132then
133  CPP_KEY="$CPP_KEY CPP_USING_MPI"
[152]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"
[189]142  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
[152]143  LD_FLAGS="$LD_FLAGS %OMP_LD"
[28]144elif [[ "$parallel" == "none" ]]
145then
146  parallel="none"
147else
[152]148  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
[28]149  exit 1
150fi
151
[327]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
[488]159if [[ "$no_io_defined" == "TRUE" ]]
160then
161  CPP_KEY="$CPP_KEY CPP_NO_IO"
162  with_xios_defined="FALSE"
163fi 
164
[171]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 
[28]171
[347]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
[744]188if [[ "$mixed_prec" == "TRUE" ]]
189then
190  CPP_KEY="$CPP_KEY CPP_MIXED_PREC"
191fi
192
[488]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
[171]198
[738]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
[12]213rm -f config.fcm
214
[488]215echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
[828]216echo "%HOPT_FFLAGS %BASE_FFLAGS $HOPT_FFLAGS" >> config.fcm
[152]217echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
[28]218echo "%CPP_KEY $CPP_KEY" >> config.fcm
219echo "%LIB $ICOSA_LIB">> config.fcm
[347]220echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
221echo "%USE_IOIPSL $use_ioipsl">> config.fcm
[12]222
[835]223# generate signature
224function signature()
225{
226    cat <<EOF
227MODULE signature_mod
228IMPLICIT NONE
229CONTAINS
230SUBROUTINE print_signature
231EOF
232    (cd -P src ; svn info .. ; svn status -q) | (while read line ; do echo "   PRINT *, '$line' " ; done)
233    cat <<EOF
234END SUBROUTINE print_signature
235END MODULE signature_mod
236EOF
237}
238
[841]239signature > signature.f90
240diff -q signature.f90 src/base/signature.f90 || cp -f signature.f90 src/base/
241rm -f signature.f90
[835]242
[89]243if [[ "$full_defined" == "TRUE" ]]
244then
245  ./build --job $job --full
246else
247  ./build --job $job
248fi
[747]249
250# force recompilation of cython modules
[828]251touch Python/src/*.pyx
Note: See TracBrowser for help on using the repository browser.