source: codes/icosagcm/trunk/make_icosa @ 347

Last change on this file since 347 was 347, checked in by dubos, 9 years ago

Synced with aquaplanet branch HEAT@45 - tested with DCMIP4

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/bin/bash
2export PATH=$PWD/tools/FCM/bin:$PATH
3
4echo ./make_icosa $* > rebuild
5chmod a+x rebuild
6
7compil_mode_defined="FALSE"
8compil_mode="prod"
9
10job=1
11full_defined="FALSE"
12with_xios_defined="FALSE"
13arch_defined="FALSE"
14parallel_defined="FALSE"
15arch_path="arch"
16parallel="none"
17physics="none"
18external_ioipsl="FALSE"
19external_physics="FALSE"
20
21CPP_KEY="CPP_NONE" 
22ICOSA_LIB=""
23
24while (($# > 0))
25  do
26  case $1 in
27      "-h") cat <<fin
28Usage :
29makegcm [options] -m arch exec
30[-h]                       : help
31[-prod / -dev / -debug]    : compilation en mode production (default) / developpement / debug .
32 -arch nom_arch            : nom de l\'architecture cible
33fin
34          exit;;
35
36      "-prod")
37          compil_mode="prod" ; shift ;;
38
39      "-dev")
40          compil_mode="dev" ; shift ;;
41
42      "-debug")
43          compil_mode="debug" ; shift ;;
44
45      "-arch")
46          arch=$2 ; arch_defined="TRUE"; shift ; shift ;;
47 
48      "-arch_path")
49          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
50
51      "-parallel")
52          parallel=$2 ; parallel_defined="TRUE"; shift ; shift ;;
53
54      "-physics")
55          physics=$2 ; physics_defined="TRUE"; shift ; shift ;;
56
57      "-job")
58          job=$2 ; shift ; shift;;
59
60      "-full")
61          full_defined="TRUE" ; shift ;;
62
63      "-with_xios")
64          with_xios_defined="TRUE" ; shift ;;
65
66      "-external_ioipsl")
67          external_ioipsl="TRUE" ; shift ;;
68
69      "-external_physics")
70          external_physics="TRUE" ; shift ;;
71
72      *)
73          code="$1" ; shift ;;
74  esac
75done
76
77rm -f .void_file
78echo > .void_file
79rm -rf .void_dir
80mkdir .void_dir
81
82if [[ "$arch_defined" == "TRUE" ]]
83then
84  rm -f arch.path
85  rm -f arch.fcm
86  rm -f arch.env
87  ln -s $arch_path/arch-${arch}.path ./arch.path
88  ln -s $arch_path/arch-${arch}.fcm  ./arch.fcm
89  if test -f $arch_path/arch-${arch}.env
90    then
91      ln -s $arch_path/arch-${arch}.env arch.env
92    else
93      ln -s .void_file arch.env
94    fi
95  source arch.env
96  source arch.path
97else
98  echo "Veuillez definir une architecture cible"
99  exit 1
100fi
101
102LD_FLAGS="%BASE_LD"
103
104if [[ "$compil_mode" == "prod" ]]
105then
106  COMPIL_FFLAGS="%PROD_FFLAGS"
107elif [[ "$compil_mode" == "dev" ]]
108then
109  COMPIL_FFLAGS="%DEV_FFLAGS"
110elif [[ "$compil_mode" == "debug" ]]
111then
112  COMPIL_FFLAGS="%DEBUG_FFLAGS"
113fi
114
115if [[ "$parallel" == "mpi" ]]
116then
117  CPP_KEY="$CPP_KEY CPP_USING_MPI"
118elif [[ "$parallel" == "omp" ]]
119then
120  CPP_KEY="$CPP_KEY CPP_USING_OMP"
121  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
122  LD_FLAGS="$LD_FLAGS %OMP_LD"
123elif [[ "$parallel" == "mpi_omp" ]]
124then
125  CPP_KEY="$CPP_KEY CPP_USING_MPI CPP_USING_OMP"
126  COMPIL_FFLAGS="$COMPIL_FFLAGS %OMP_FFLAGS"
127  LD_FLAGS="$LD_FLAGS %OMP_LD"
128elif [[ "$parallel" == "none" ]]
129then
130  parallel="none"
131else
132  echo "-parallel value $parallel is invalid, only permited <none>, <mpi>, <omp> or <mpi_omp>"
133  exit 1
134fi
135
136if [[ "$physics" == "lmdz_generic" ]]
137then
138  CPP_KEY="$CPP_KEY CPP_PHYSICS_LMDZ_GENERIC"
139  COMPIL_FFLAGS="$COMPIL_FFLAGS $PHYSICS_INCDIR"
140  ICOSA_LIB="$ICOSA_LIB $PHYSICS_LIBDIR $PHYSICS_LIB"
141fi
142
143if [[ "$with_xios_defined" == "TRUE" ]]
144then
145  CPP_KEY="$CPP_KEY CPP_USING_XIOS"
146  COMPIL_FFLAGS="$COMPIL_FFLAGS $XIOS_INCDIR"
147  ICOSA_LIB="$ICOSA_LIB $XIOS_LIBDIR $XIOS_LIB"
148fi 
149
150if [[ "$external_ioipsl" == "TRUE" ]]
151then
152  ioipsl_path=".void_dir"
153  use_ioipsl="use::ioipsl"
154  COMPIL_FFLAGS="$COMPIL_FFLAGS $IOIPSL_INCDIR"
155  ICOSA_LIB="$ICOSA_LIB $IOIPSL_LIBDIR $IOIPSL_LIB"
156else
157  ioipsl_path="tools/ioipsl"
158  use_ioipsl=""
159fi 
160
161if [[ "$external_physics" == "TRUE" ]]
162then
163  CPP_KEY="$CPP_KEY CPP_USING_EXTERNAL_PHYSICS"
164fi
165
166ICOSA_LIB="$ICOSA_LIB $NETCDF_LIBDIR $NETCDF_LIB $HDF5_LIBDIR $HDF5_LIB"
167
168
169rm -f config.fcm
170
171echo "%COMPIL_FFLAGS $COMPIL_FFLAGS $NETCDF_INCDIR" >> config.fcm
172echo "%LD_FLAGS $LD_FLAGS" >> config.fcm
173echo "%CPP_KEY $CPP_KEY" >> config.fcm
174echo "%LIB $ICOSA_LIB">> config.fcm
175echo "%IOIPSL_PATH $ioipsl_path">> config.fcm
176echo "%USE_IOIPSL $use_ioipsl">> config.fcm
177
178if [[ "$full_defined" == "TRUE" ]]
179then
180  ./build --job $job --full
181else
182  ./build --job $job
183fi
Note: See TracBrowser for help on using the repository browser.