1 | #!/bin/csh |
---|
2 | #set verbose echo |
---|
3 | set is_parallel_opt = FALSE |
---|
4 | set is_driver_opt = FALSE |
---|
5 | set is_arch_opt = FALSE |
---|
6 | set is_compile_opt = FALSE |
---|
7 | set default_compile_flags = "%PROD_FFLAGS" |
---|
8 | set fcm_path=none |
---|
9 | |
---|
10 | setenv P_P "" |
---|
11 | setenv SECTIONS_PARA "" |
---|
12 | |
---|
13 | top: |
---|
14 | if ($#argv > 0) then |
---|
15 | switch ($1) |
---|
16 | |
---|
17 | case -h |
---|
18 | |
---|
19 | ######################################################################## |
---|
20 | # Manuel en ligne |
---|
21 | ######################################################################## |
---|
22 | more <<eod |
---|
23 | |
---|
24 | |
---|
25 | makeorchidee_fcm [Options] |
---|
26 | |
---|
27 | [ -parallel|-p PARALLEL_TYPE ] : activate parallelization with 3 options : |
---|
28 | PARALLEL_TYPE = |
---|
29 | ( mpi | MPI ) : use Message Passing Interface standard |
---|
30 | ( omp | OMP ) : use OpenMP standard |
---|
31 | ( mpi_omp | MPI_OMP ) : use both MPI and OpenMP |
---|
32 | |
---|
33 | [ -driver ] : compilation of ORCHIDEE driver if equal TRUE |
---|
34 | |
---|
35 | [ -a|-arch ARCHitecture ] : if TRUE, change architecture for ARCHitecture |
---|
36 | |
---|
37 | [ -prod ] : compilation for production (all optimization) |
---|
38 | |
---|
39 | [ -dev ] : compilation for development (low optimization and -g) |
---|
40 | |
---|
41 | [ -d|-debug ] : compilation for debugging (no optmization and all debug options) |
---|
42 | |
---|
43 | [-fcm_path path] : path for fcm (default: the default fcm path in environment) |
---|
44 | |
---|
45 | [ -doc ] : generate documentation with Doxygen (exit after doc computation) |
---|
46 | |
---|
47 | [ -doc_para ] : generate documentation with Doxygen with parallelization calls |
---|
48 | |
---|
49 | [ -rmdoc ] : remove documentation directory (before generate new documentation with Doxygen ?) |
---|
50 | |
---|
51 | [ -doc_tree ] : generate tree of ORCHIDEE directories for each file |
---|
52 | |
---|
53 | eod |
---|
54 | exit |
---|
55 | |
---|
56 | ######################################################################## |
---|
57 | # Lecture des differentes options |
---|
58 | ######################################################################## |
---|
59 | |
---|
60 | case -parallel |
---|
61 | set is_parallel_opt = TRUE |
---|
62 | set parallel=$2 ; shift ; shift ; goto top |
---|
63 | |
---|
64 | case -p |
---|
65 | set is_parallel_opt = TRUE |
---|
66 | set parallel=$2 ; shift ; shift ; goto top |
---|
67 | |
---|
68 | case -driver |
---|
69 | set is_driver_opt = TRUE |
---|
70 | shift ; goto top |
---|
71 | |
---|
72 | case -a |
---|
73 | case -arch |
---|
74 | set is_arch_opt = TRUE |
---|
75 | set arch="$2" ; shift ; shift ; goto top |
---|
76 | |
---|
77 | case -prod |
---|
78 | set is_compile_opt = TRUE |
---|
79 | set compile_flags="%PROD_FFLAGS" |
---|
80 | shift ; goto top |
---|
81 | |
---|
82 | case -dev |
---|
83 | set is_compile_opt = TRUE |
---|
84 | set compile_flags="%DEV_FFLAGS" |
---|
85 | shift ; goto top |
---|
86 | |
---|
87 | case -d |
---|
88 | case -debug |
---|
89 | set is_compile_opt = TRUE |
---|
90 | set compile_flags="%DEBUG_FFLAGS" |
---|
91 | shift ; goto top |
---|
92 | |
---|
93 | case -fcm_path |
---|
94 | set fcm_path=$2 ; shift ; shift ; goto top |
---|
95 | |
---|
96 | case -doc_para |
---|
97 | setenv P_P -DCPP_PARA |
---|
98 | setenv SECTIONS_PARA "-e s&ENABLED_SECTIONS\ *= &ENABLED_SECTIONS = CPP_PARA&g" |
---|
99 | goto doc |
---|
100 | |
---|
101 | case -doc |
---|
102 | doc: |
---|
103 | unalias cd |
---|
104 | setenv REV `svn info | grep vision | sed -e 's&.*vision.*: \([0-9]*\)&\1&' | head -n 1` |
---|
105 | setenv TAG `svn info | grep URL | sed -e 's&.*URL.*: svn://forge.ipsl.jussieu.fr/orchidee/\(.*\)&\1&' | head -n 1 | xargs dirname` |
---|
106 | cd .. |
---|
107 | \rm -rf modeles_doc |
---|
108 | setenv MODELPATH ${PWD} |
---|
109 | \mkdir modeles_doc |
---|
110 | setenv SRCPATH ${MODELPATH}/modeles_doc |
---|
111 | |
---|
112 | find IOIPSL/src \( -not -path '*.svn*' \ |
---|
113 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
114 | -exec bash -c 'mkdir -p '${SRCPATH}'/$( dirname {} ); cp -p {} '${SRCPATH}'/$( dirname {} )' \; |
---|
115 | |
---|
116 | find ORCHIDEE \( -not -path '*.svn*' \ |
---|
117 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
118 | -exec bash -c 'mkdir -p '${SRCPATH}'/$( dirname {} ); cp -p {} '${SRCPATH}'/$( dirname {} )' \; |
---|
119 | cd ${SRCPATH} |
---|
120 | # Use standard preprocessor to suppress all preproc directives |
---|
121 | \find . -name "*.f90" -exec cpp -P -C -traditional -x assembler-with-cpp ${P_P} '{}' '{}'_ \; |
---|
122 | \find . -name "*.f90" -print -exec mv -f '{}'_ '{}' \; |
---|
123 | |
---|
124 | # use codeinc script to encaspulate code parts in Doxygen documentation |
---|
125 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codeinc.awk '{}' \; > /dev/null |
---|
126 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codeinc '{}' \; |
---|
127 | # use codedox script to transform almost all comments in Doxygen comments for documentation (use with care !) |
---|
128 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codedox.awk '{}' \; > /dev/null |
---|
129 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codedox '{}' \; |
---|
130 | |
---|
131 | # use codealgo script to emphasize main algorithm description of each routine in their Doxygen documentation |
---|
132 | \find . -name "*.f90" -exec gawk -f ${MODELPATH}/ORCHIDEE/DOC/TOOLS/codealgo.awk '{}' \; > /dev/null |
---|
133 | \find . -name "*.f90" -print -exec mv -f '{}'_preproc_codealgo '{}' \; |
---|
134 | cd ../ORCHIDEE |
---|
135 | \rm -f ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE |
---|
136 | sed -e 's&MYPATH&'${MODELPATH}'&g' -e 's&SRCPATH&'${SRCPATH}'&g' \ |
---|
137 | -e 's&MYTAG&'${TAG}'&' -e 's&MYREV&'${REV}'&' ${SECTIONS_PARA} \ |
---|
138 | ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE.init > ${MODELPATH}/ORCHIDEE/Doxyfile_ORCHIDEE |
---|
139 | \rm -f ${MODELPATH}/ORCHIDEE/DOC/header.tex |
---|
140 | sed -e "s&MYTAG&${TAG}&" -e "s&MYREV&${REV}&" \ |
---|
141 | ${MODELPATH}/ORCHIDEE/DOC/header.tex.init > ${MODELPATH}/ORCHIDEE/DOC/header.tex |
---|
142 | ln -s /home/orchidee01/maignan/ORCHIDEE/DOC/IMAGES ${MODELPATH}/ORCHIDEE/DOC/IMAGES |
---|
143 | gmake doc |
---|
144 | gmake bib |
---|
145 | gmake toc |
---|
146 | \rm -rf ${MODELPATH}/ORCHIDEE/webdoc |
---|
147 | \mv ${MODELPATH}/ORCHIDEE/docs/html ${MODELPATH}/ORCHIDEE/webdoc |
---|
148 | gmake index |
---|
149 | gmake toc |
---|
150 | \rm -rf ${SRCPATH} |
---|
151 | cp ${MODELPATH}/ORCHIDEE/docs/latex/refman.pdf ${MODELPATH}/ORCHIDEE/documentation.pdf |
---|
152 | exit |
---|
153 | |
---|
154 | case -rmdoc |
---|
155 | \rm -rf docs |
---|
156 | shift ; goto top |
---|
157 | |
---|
158 | case -doc_tree |
---|
159 | cd .. |
---|
160 | find ORCHIDEE \( -not -path '*.svn*' \ |
---|
161 | -a \( -name '*.f90' -o -name "*.F90" -o -name "*.h" \) \) \ |
---|
162 | -exec bash -c 'mkdir -p ORCHIDEE/DOC/$( dirname {} )/$( echo $( basename {} ) | sed -e "s/\..*//" )' \; |
---|
163 | cd ORCHIDEE |
---|
164 | shift ; goto top |
---|
165 | |
---|
166 | default |
---|
167 | echo "unknown option "$1" , exiting..." |
---|
168 | exit |
---|
169 | endsw |
---|
170 | endif |
---|
171 | |
---|
172 | ############################################################### |
---|
173 | # mettre le chemin du fcm dans le path |
---|
174 | ############################################################### |
---|
175 | if ( "$fcm_path" != 'none' ) then |
---|
176 | setenv PATH ${fcm_path}:${PATH} |
---|
177 | endif |
---|
178 | |
---|
179 | echo "Chemin du fcm utlise :" |
---|
180 | which fcm |
---|
181 | |
---|
182 | |
---|
183 | #define architecture files |
---|
184 | if ( $is_arch_opt == TRUE) then |
---|
185 | if ( -e arch/arch-${arch}.fcm ) then |
---|
186 | rm -f arch.fcm |
---|
187 | ln -s arch/arch-${arch}.fcm arch.fcm |
---|
188 | else |
---|
189 | echo "architecture file : << arch/arch-${arch}.fcm >> is missing, exiting...." |
---|
190 | exit |
---|
191 | endif |
---|
192 | |
---|
193 | if ( -e arch/arch-${arch}.path ) then |
---|
194 | rm -f arch.path |
---|
195 | ln -s arch/arch-${arch}.path arch.path |
---|
196 | else |
---|
197 | echo "architecture file : << arch/arch-${arch}.path >> is missing, exiting...." |
---|
198 | exit |
---|
199 | endif |
---|
200 | else |
---|
201 | echo "Warning : architecture not specified, taking default file <<arch.fcm>> and <<arch.path>>" |
---|
202 | if ( ! -e arch.fcm ) then |
---|
203 | echo "architecture file : << arch.fcm >> is missing, exiting...." |
---|
204 | exit |
---|
205 | endif |
---|
206 | |
---|
207 | if ( ! -e arch.fcm ) then |
---|
208 | echo "architecture file : << arch.path >> is missing, exiting...." |
---|
209 | exit |
---|
210 | endif |
---|
211 | endif |
---|
212 | |
---|
213 | # set compiler flags |
---|
214 | set FFLAGS="%BASE_FFLAGS" |
---|
215 | set LD_FFLAGS="%BASE_LD" |
---|
216 | set CPP_KEY="%FPP_DEF" |
---|
217 | |
---|
218 | # set compiler flags for optimisation |
---|
219 | if ( $is_compile_opt == FALSE ) then |
---|
220 | set compile_flags=$default_compile_flags |
---|
221 | endif |
---|
222 | set FFLAGS=${FFLAGS}" "$compile_flags |
---|
223 | |
---|
224 | # set compiler flags for parallelism |
---|
225 | if ( $is_parallel_opt == TRUE ) then |
---|
226 | echo $parallel |
---|
227 | switch ($parallel) |
---|
228 | case mpi |
---|
229 | case MPI |
---|
230 | set FFLAGS="${FFLAGS} %MPI_FFLAGS" |
---|
231 | set LD_FFLAGS="%MPI_LD ${LD_FFLAGS}" |
---|
232 | set CPP_KEY="CPP_PARA ${CPP_KEY}" |
---|
233 | breaksw |
---|
234 | case omp |
---|
235 | case OMP |
---|
236 | set FFLAGS="${FFLAGS} %OMP_FFLAGS" |
---|
237 | set LD_FFLAGS="%OMP_LD ${LD_FFLAGS}" |
---|
238 | set CPP_KEY="CPP_OMP CPP_PARA ${CPP_KEY}" |
---|
239 | breaksw |
---|
240 | case mpi_omp |
---|
241 | case MPI_OMP |
---|
242 | set FFLAGS="${FFLAGS} %MPI_FFLAGS %OMP_FFLAGS" |
---|
243 | set LD_FFLAGS="%MPI_LD %OMP_LD ${LD_FFLAGS}" |
---|
244 | set CPP_KEY="CPP_OMP CPP_PARA ${CPP_KEY}" |
---|
245 | breaksw |
---|
246 | |
---|
247 | default |
---|
248 | echo "unknown option for parallelism :$parallel , only <<mpi>>, <<MPI>> or <<omp>>, <<OMP>> or <<mpi_omp>> <<MPI_OMP>> allowed , exiting..." |
---|
249 | exit |
---|
250 | endsw |
---|
251 | endif |
---|
252 | |
---|
253 | # set target |
---|
254 | set TARGET = liborchidee.a |
---|
255 | if ( $is_driver_opt == TRUE) then |
---|
256 | set TARGET="liborchidee_ol.a dim2_driver.exe teststomate.exe forcesoil.exe" |
---|
257 | endif |
---|
258 | |
---|
259 | source ./arch.path |
---|
260 | |
---|
261 | # build config file |
---|
262 | set config_fcm="config.fcm" |
---|
263 | rm -f $config_fcm |
---|
264 | touch $config_fcm |
---|
265 | |
---|
266 | echo "%ARCH $arch" >> $config_fcm |
---|
267 | echo "%FFLAGS $FFLAGS" >> $config_fcm |
---|
268 | echo "%CPP_KEY $CPP_KEY" >> $config_fcm |
---|
269 | echo "%EXEC $TARGET" >> $config_fcm |
---|
270 | echo "%LD_FFLAGS $LD_FFLAGS" >> $config_fcm |
---|
271 | echo "%INCDIR -I$NETCDF_INCDIR -I$IOIPSL_INCDIR" >> $config_fcm |
---|
272 | echo "%LIBDIR -L$NETCDF_LIBDIR -L$IOIPSL_LIBDIR" >> $config_fcm |
---|
273 | |
---|
274 | |
---|
275 | fcm build |
---|