source: codes/icosagcm/devel/make_icosa @ 738

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

devel/IRENE : use AVX512 in dynamics and AVX elsewhere ; fixes mass convervation issue

  • 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  if test -f $arch_path/arch-${arch}.${suffix}
102  then
103    ln -s $arch_path/arch-${arch}.${suffix} arch.${suffix}
104  elif test -f $arch_default_path/arch-${arch}.${suffix}
105  then
106    ln -s $arch_default_path/arch-${arch}.${suffix} arch.${suffix}
107  fi
108       
109}
110
111if [[ "$arch_defined" == "TRUE" ]]
112then
113  rm -f arch.path
114  rm -f arch.fcm
115  rm -f arch.env
116 
117  for suffix in env path fcm opt ; do link_if_exists $suffix ; done
118
119  source arch.env
120  source arch.path
121
122else
123  echo "Veuillez definir une architecture cible"
124  exit 1
125fi
126
127LD_FLAGS="%BASE_LD"
128COMPIL_FFLAGS=""
129
130if [[ "$parallel" == "mpi" ]]
131then
132  CPP_KEY="$CPP_KEY CPP_USING_MPI"
133elif [[ "$parallel" == "omp" ]]
134then
135  CPP_KEY="$CPP_KEY CPP_USING_OMP"
136  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
137  LD_FLAGS="$LD_FLAGS %OMP_LD"
138elif [[ "$parallel" == "mpi_omp" ]]
139then
140  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
141  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
142  LD_FLAGS="$LD_FLAGS %OMP_LD"
143elif [[ "$parallel" == "none" ]]
144then
145  parallel="none"
146else
147  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
148  exit 1
149fi
150
151if [[ "$physics" == "lmdz_generic" ]]
152then
153  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
154  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
155  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
156fi
157
158if [[ "$no_io_defined" == "TRUE" ]]
159then
160  CPP_KEY="$CPP_KEY CPP_NO_IO"
161  with_xios_defined="FALSE"
162fi 
163
164if [[ "$with_xios_defined" == "TRUE" ]]
165then
166  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
167  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
168  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
169fi 
170
171if [[ "$external_ioipsl" == "TRUE" ]]
172then
173  ioipsl_path=".void_dir"
174  use_ioipsl="use::ioipsl"
175  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
176  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
177else
178  ioipsl_path="tools/ioipsl"
179  use_ioipsl=""
180fi 
181
182if [[ "$external_physics" == "TRUE" ]]
183then
184  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
185fi
186
187if [[ "$no_io_defined" == "FALSE" ]]
188then
189  ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
190  COMPIL_FFLAGS="$COMPIL_FFLAGS $NETCDF_INCDIR"
191fi
192
193if [[ "$compil_mode" == "prod" ]]
194then
195  HOPT_FFLAGS="%FAST_FFLAGS $COMPIL_FFLAGS"
196  COMPIL_FFLAGS="%PROD_FFLAGS $COMPIL_FFLAGS"
197elif [[ "$compil_mode" == "dev" ]]
198then
199  COMPIL_FFLAGS="%DEV_FFLAGS $COMPIL_FFLAGS"
200  HOPT_FFLAGS=$COMPIL_FFLAGS
201elif [[ "$compil_mode" == "debug" ]]
202then
203  COMPIL_FFLAGS="%DEBUG_FFLAGS $COMPIL_FFLAGS"
204  HOPT_FFLAGS=$COMPIL_FFLAGS
205fi
206
207rm -f config.fcm
208
209echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
210echo "%HOPT_FFLAGS $HOPT_FFLAGS" >> config.fcm
211echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
212echo "%CPP_KEY $CPP_KEY" >> config.fcm
213echo "%LIB $ICOSA_LIB">> config.fcm
214echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
215echo "%USE_IOIPSL $use_ioipsl">> config.fcm
216
217if [[ "$full_defined" == "TRUE" ]]
218then
219  ./build --job $job --full
220else
221  ./build --job $job
222fi
Note: See TracBrowser for help on using the repository browser.