source: codes/icosagcm/devel/make_icosa @ 730

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

devel : improve make_icosa to avoid unnecessary re-compilation

  • Property svn:executable set to *
File size: 5.2 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
[12]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 ;;
[332]60 
61      "-arch_path")
62          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
[12]63
[28]64      "-parallel")
65          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
66
[327]67      "-physics")
68          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
69
[89]70      "-job")
[103]71          job=$2 ; shift ; shift;;
[89]72
73      "-full")
[103]74          full_defined="TRUE" ; shift ;;
[89]75
[171]76      "-with_xios")
77          with_xios_defined="TRUE" ; shift ;;
[488]78 
[535]79      "-no_io")
[488]80          no_io_defined="TRUE" ; shift ;;
81 
[347]82      "-external_ioipsl")
83          external_ioipsl="TRUE" ; shift ;;
84
85      "-external_physics")
86          external_physics="TRUE" ; shift ;;
87
[12]88      *)
89          code="$1" ; shift ;;
90  esac
91done
92
[28]93rm -f .void_file
94echo > .void_file
95rm -rf .void_dir
96mkdir .void_dir
97
[12]98if [[ "$arch_defined" == "TRUE" ]]
99then
100  rm -f arch.path
101  rm -f arch.fcm
[28]102  rm -f arch.env
[497]103
104  if test -f $arch_path/arch-${arch}.path
105  then
106    ln -s $arch_path/arch-${arch}.path arch.path
107  elif test -f $arch_default_path/arch-${arch}.path
108  then
109    ln -s $arch_default_path/arch-${arch}.path arch.path
110  fi
111       
112  if test -f $arch_path/arch-${arch}.fcm
113  then
114    ln -s $arch_path/arch-${arch}.fcm arch.fcm
115  elif test -f $arch_default_path/arch-${arch}.fcm
116  then
117    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
118  fi
119
[332]120  if test -f $arch_path/arch-${arch}.env
[497]121  then
122    ln -s $arch_path/arch-${arch}.env arch.env
123  elif test -f $arch_default_path/arch-${arch}.env
124  then
125    ln -s $arch_default_path/arch-${arch}.env arch.env
126  else
127    ln -s .void_file arch.env
128  fi
[28]129  source arch.env
[12]130  source arch.path
131else
132  echo "Veuillez definir une architecture cible"
133  exit 1
134fi
135
[152]136LD_FLAGS="%BASE_LD"
137
[12]138if [[ "$compil_mode" == "prod" ]]
139then
140  COMPIL_FFLAGS="%PROD_FFLAGS"
141elif [[ "$compil_mode" == "dev" ]]
142then
143  COMPIL_FFLAGS="%DEV_FFLAGS"
144elif [[ "$compil_mode" == "debug" ]]
145then
146  COMPIL_FFLAGS="%DEBUG_FFLAGS"
147fi
148
[28]149if [[ "$parallel" == "mpi" ]]
150then
151  CPP_KEY="$CPP_KEY CPP_USING_MPI"
[152]152elif [[ "$parallel" == "omp" ]]
153then
154  CPP_KEY="$CPP_KEY CPP_USING_OMP"
155  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
156  LD_FLAGS="$LD_FLAGS %OMP_LD"
157elif [[ "$parallel" == "mpi_omp" ]]
158then
159  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
[189]160  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
[152]161  LD_FLAGS="$LD_FLAGS %OMP_LD"
[28]162elif [[ "$parallel" == "none" ]]
163then
164  parallel="none"
165else
[152]166  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
[28]167  exit 1
168fi
169
[327]170if [[ "$physics" == "lmdz_generic" ]]
171then
172  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
173  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
174  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
175fi
176
[488]177if [[ "$no_io_defined" == "TRUE" ]]
178then
179  CPP_KEY="$CPP_KEY CPP_NO_IO"
180  with_xios_defined="FALSE"
181fi 
182
[171]183if [[ "$with_xios_defined" == "TRUE" ]]
184then
185  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
186  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
187  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
188fi 
[28]189
[347]190if [[ "$external_ioipsl" == "TRUE" ]]
191then
192  ioipsl_path=".void_dir"
193  use_ioipsl="use::ioipsl"
194  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
195  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
196else
197  ioipsl_path="tools/ioipsl"
198  use_ioipsl=""
199fi 
200
201if [[ "$external_physics" == "TRUE" ]]
202then
203  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
204fi
205
[488]206if [[ "$no_io_defined" == "FALSE" ]]
207then
208  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
209  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
210fi
[171]211
[12]212rm -f config.fcm
213
[488]214echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
[152]215echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
[28]216echo "%CPP_KEY $CPP_KEY" >> config.fcm
217echo "%LIB $ICOSA_LIB">> config.fcm
[347]218echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
219echo "%USE_IOIPSL $use_ioipsl">> config.fcm
[12]220
[89]221if [[ "$full_defined" == "TRUE" ]]
222then
223  ./build --job $job --full
224else
225  ./build --job $job
226fi
Note: See TracBrowser for help on using the repository browser.