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
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
[738]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
[12]111if [[ "$arch_defined" == "TRUE" ]]
112then
113  rm -f arch.path
114  rm -f arch.fcm
[28]115  rm -f arch.env
[738]116 
117  for suffix in env path fcm opt ; do link_if_exists $suffix ; done
[497]118
[28]119  source arch.env
[12]120  source arch.path
[738]121
[12]122else
123  echo "Veuillez definir une architecture cible"
124  exit 1
125fi
126
[152]127LD_FLAGS="%BASE_LD"
[738]128COMPIL_FFLAGS=""
[152]129
[28]130if [[ "$parallel" == "mpi" ]]
131then
132  CPP_KEY="$CPP_KEY CPP_USING_MPI"
[152]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"
[189]141  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
[152]142  LD_FLAGS="$LD_FLAGS %OMP_LD"
[28]143elif [[ "$parallel" == "none" ]]
144then
145  parallel="none"
146else
[152]147  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
[28]148  exit 1
149fi
150
[327]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
[488]158if [[ "$no_io_defined" == "TRUE" ]]
159then
160  CPP_KEY="$CPP_KEY CPP_NO_IO"
161  with_xios_defined="FALSE"
162fi 
163
[171]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 
[28]170
[347]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
[488]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
[171]192
[738]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
[12]207rm -f config.fcm
208
[488]209echo "%COMPIL_FFLAGS $COMPIL_FFLAGS" >> config.fcm
[738]210echo "%HOPT_FFLAGS $HOPT_FFLAGS" >> config.fcm
[152]211echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
[28]212echo "%CPP_KEY $CPP_KEY" >> config.fcm
213echo "%LIB $ICOSA_LIB">> config.fcm
[347]214echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
215echo "%USE_IOIPSL $use_ioipsl">> config.fcm
[12]216
[89]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.