source: LMDZ5/trunk/makelmdz @ 2247

Last change on this file since 2247 was 2242, checked in by Ehouarn Millour, 10 years ago

Further reorganizing of the physics-dynamics interface.
Things related to dynamics grid and physics grid go in "dynlonlat_phylonlat".
Any physics phy* related stuff (e.g. iniphysiq, ce0l) goes in a phy* subdirectory of dynlonlat_phylonlat.
EM

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:executable set to *
File size: 21.4 KB
RevLine 
[1463]1#!/bin/bash
2#
[1695]3# $Id$
[1463]4#
5#
6########################################################################
7# for debug, uncomment line below
8#set -xv
9########################################################################
10# options par defaut pour la commande make
11########################################################################
12dim="96x72x19"
13physique=lmd
14code=gcm
15filtre=filtrez
16grille=reg
17couple=false
18veget=false
19chimie=false
20parallel=none
[1690]21paramem="par"
[1463]22compil_mod=prod
23io=ioipsl
24LIBPREFIX=""
25fcm_path=none
26cosp=false
[1865]27sisvat=false
[1990]28rrtm=false
[2112]29full=""
[1463]30
31# guess a default 'arch'
[1690]32arch="local" # start with assuming we're on a local machine with local arch file
[1463]33## try to recognise machine and infer arch from it
34machine=`hostname`
[1897]35if [[ "${machine:0:3}" == "ada" ]]
[1463]36then
[1897]37  arch="X64_ADA"
[1463]38fi
39if [[ "${machine:0:7}" == "platine" ]]
40then
41  arch="IA64_PLATINE"
42fi
43if [[ "${machine:0:6}" == "titane" ]]
44then
45  arch="X64_TITANE"
46fi
47if [[ "${machine:0:8}" == "mercure1" ]]
48then
49  arch="SX8_MERCURE"
50fi
51if [[ "${machine:0:8}" == "mercure2" ]]
52then
53  arch="SX9_MERCURE"
54fi
55
56LMDGCM=`pwd -P`
57LIBFGCM=$LMDGCM/libf
58LIBOGCM=$LMDGCM/libo
59if [[ ! -d $LIBOGCM ]]
60then
61  # create the directory
62  mkdir $LIBOGCM
63  if [[ ! $? ]]
64  then
65  echo "Failed to create directory $LIBOGCM"
66  exit
67  fi
68fi
69COSP_PATH=$LMDGCM/.void_dir
70
71
72
73localdir=`pwd -P`
74########################################################################
75#  Quelques initialisations de variables du shell.
76########################################################################
77
78CPP_KEY="" 
[2239]79INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. '
[1463]80LIB=""
81adjnt=""
82##COMPIL_FFLAGS="%PROD_FFLAGS"
83PARA_FFLAGS=""
84PARA_LD=""
85EXT_SRC=""
[2238]86#src_dirs: directories containing source files
[2239]87src_dirs="grid misc" 
[1463]88########################################################################
89# lecture des options
90########################################################################
91
92while (($# > 0))
93  do
94  case $1 in
95      "-h") cat <<fin
96Usage :
[1772]97makelmdz [options] -arch nom_arch exec
98[-h]                       : brief help
99[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
100[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
101[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug
102[-c false/MPI1/MPI2]       : coupling with ocean model : MPI1/MPI2/false (default: false)
103[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
104          false       : no vegetation model
105          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
106          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
107          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
108[-chimie INCA/false]       : with INCA chemistry model or without (default: false)
[2238]109[-cosp true/false]    : compile with/without cosp package (default: false)
110[-sisvat true/false]  : compile with/without sisvat package (default: false)
111[-rrtm true/false]    : compile with/without rrtm package (default: false)
[1772]112[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
113[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
[2097]114[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
[1772]115[-include INCLUDES]        : extra include path to add
116[-cpp CPP_KEY]             : additional preprocessing definitions
117[-adjnt]                   : adjoint model, not operational ...
118[-mem]                     : reduced memory dynamics (if in parallel mode)
119[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
[2112]120[-full]                    : Full (re)compilation (from scratch)
[1772]121[-link LINKS]              : additional links with other libraries
122[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
123[-ext_src path]            : path to an additional set of routines to compile with the model
124 -arch nom_arch            : target architecture
125 exec                      : executable to build
[1463]126fin
127          exit;;
128      "-d")
129          dim=$2 ; shift ; shift ;;
130     
131      "-p")
132          physique="$2" ;  shift ; shift ;;
133
134      "-g")
135          grille="$2" ; shift ; shift ;;
136
137      "-c")
138          couple="$2" ; shift ; shift ;;
139
140      "-prod")
141          compil_mod="prod" ; shift ;;
142
143      "-dev")
144          compil_mod="dev" ; shift ;;
145
146      "-debug")
147          compil_mod="debug" ; shift ;;
148
149      "-io")
150          io="$2" ; shift ; shift ;;
151
152      "-v")
153          veget="$2" ; shift ; shift ;;
154
155      "-chimie")
156          chimie="$2" ; shift ; shift ;;
157
158      "-parallel")
159          parallel="$2" ; shift ; shift ;;
160     
161      "-include")
162          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
163
164      "-cpp")
165          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
166
167      "-cosp")
168          cosp="$2" ; shift ; shift ;;
[1690]169     
[1865]170      "-sisvat")
171          sisvat="$2" ; shift ; shift ;;
172     
[1990]173      "-rrtm")
174          rrtm="$2" ; shift ; shift ;;
175     
[1690]176      "-mem")
177          paramem="mem" ; shift ;;
[1463]178
179      "-filtre")
180          filtre=$2 ; shift ; shift ;;
181
[2112]182      "-full")
183      full="full" ; shift ;;
184
[1463]185      "-link")
186          LIB="$LIB $2" ; shift ; shift ;;
187
188      "-fcm_path")
189          fcm_path=$2 ; shift ; shift ;;
190
191      "-ext_src")
[2238]192          EXT_SRC=$2 ; src_dirs="$src_dirs $EXT_SRC" ; shift ; shift ;;
[1463]193
194      "-arch")
195          arch=$2 ; shift ; shift ;;
196
197      *)
198          code="$1" ; shift ;;
199  esac
200done
201
202###############################################################
[2098]203# lecture des chemins propres \`a l'architecture de la machine #
[1463]204###############################################################
205rm -f .void_file
206echo > .void_file
207rm -rf .void_dir
208mkdir .void_dir
209rm -f arch.path
210if [[ -r arch/arch-${arch}.path ]]
211then
212  ln -s arch/arch-${arch}.path ./arch.path
213  source arch.path
214else
215  echo "Error: missing arch/arch-${arch}.path file !"
216  exit
217fi
218rm -f arch.fcm
219if [[ -r arch/arch-${arch}.fcm ]]
220then
221  ln -s arch/arch-${arch}.fcm arch.fcm
222else
223  echo "Error: missing arch/arch-${arch}.fcm file !"
224  exit
225fi
226########################################################################
227# Definition des clefs CPP, des chemins des includes et modules
228#  et des libraries
229########################################################################
230
231# basic compile flags from arch.fcm file
232archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm )
233COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} )
234
235# other compile flags, depending on compilation mode
236if [[ "$compil_mod" == "prod" ]]
237then
238## read COMPIL_FFLAGS from arch.fcm file
239  archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm )
240  archfileopt=$( echo ${archfileline##%PROD_FFLAGS} )
241  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
242elif [[ "$compil_mod" == "dev" ]]
243then
244## read %DEV_FFLAGS from arch.fcm file
245  archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm )
246  archfileopt=$( echo ${archfileline##%DEV_FFLAGS} )
247  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
248elif [[ "$compil_mod" == "debug" ]]
249then
250## read %DEBUG_FFLAGS from arch.fcm file
251  archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm )
252  archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} )
253  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
254fi
255
256# add CPP_KEY defined in arch.fcm file
257archfileline=$( grep -i '^%FPP_DEF' arch.fcm )
258archfileopt=$( echo ${archfileline##%FPP_DEF} )
259CPP_KEY="$CPP_KEY ${archfileopt}"
260
261# get compiler name from arch.fcm file
262archfileline=$( grep -i '^%COMPILER' arch.fcm )
263fcompiler=$( echo ${archfileline##%COMPILER} )
264
265# get linker name from arch.fcm file
266archfileline=$( grep -i '^%LINK' arch.fcm )
267linker=$( echo ${archfileline##%LINK} )
268
269# get ar command from arch.fcm file
270archfileline=$( grep -i '^%AR' arch.fcm )
271arcommand=$( echo ${archfileline##%AR} )
272
273# get make utility from arch.fcm file
274archfileline=$( grep -i '^%MAKE' arch.fcm )
275makecommand=$( echo ${archfileline##%MAKE} )
276
277# get basic libraries to link with arch.fcm file
278archfileline=$( grep -i '^%BASE_LD' arch.fcm )
279archfileopt=$( echo ${archfileline##%BASE_LD} )
280LIB="$LIB  ${archfileopt}"
281
[1873]282# add Include files defined in arch.fcm file for pre-processing
283archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
284for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
285
[1463]286if [[ "$physique" != "nophys" ]]
287then
[1690]288   #We'll use some physics
[2238]289   src_dirs="$src_dirs phy$physique"
[2239]290   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
291   lib_phy='-lphy'"$physique"
[1690]292   CPP_KEY="$CPP_KEY CPP_PHYS"
293   if [[ "${physique:0:3}" == "lmd" ]]
294   then
295   #For lmd physics, default planet type is Earth
[1463]296   CPP_KEY="$CPP_KEY CPP_EARTH"
[1690]297   fi
[1463]298fi
299
300if [[ "$chimie" == "INCA" ]]
301then
302   CPP_KEY="$CPP_KEY INCA"
303   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
304   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
305   libchimie=" -L${INCA_LIBDIR} -lchimie"
306fi
307
308if [[ "$couple" != "false" ]]
309then
310   CPP_KEY="$CPP_KEY CPP_COUPLE"
311   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
312   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
313fi
314
315if [[ "$parallel" == "none" ]]
316then
317  FLAG_PARA=''
318else
[1810]319  FLAG_PARA="$paramem"
[2202]320  if [[ $paramem == par ]]
321  then
322      echo "The version of the dynamics in dyn3dpar is no longer updated."
323      echo "You should use option \"-mem\"."
324      exit 1
[2238]325  fi
[1463]326fi
327
328if [[ "$parallel" == "mpi" ]]
329then
330   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
331  # MPI additional compilation options
332  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
333  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
334  # MPI additional links
335  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
336  PARA_LD=$( echo ${archfileline##%MPI_LD} )
337elif [[ "$parallel" == "omp" ]]
338then
339   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
340  # OMP additional compilation options
341  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
342  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
343  # OMP additional links
344  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
345  PARA_LD=$( echo ${archfileline##%OMP_LD} )
346elif [[ "$parallel" == "mpi_omp" ]]
347then
348   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
349  # MPI additional compilation options
350  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
351  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
352  # OMP additional compilation options
353  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
354  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
355  # MPI additional links
356  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
357  PARA_LD=$( echo ${archfileline##%MPI_LD} )
358  # OMP additional links
359  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
360  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
361fi
362
363if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
364   && "$compil_mod" == "debug" ]]
365then
366    echo "Usually, parallelization with OpenMP requires some optimization."
367    echo "We suggest switching to \"-dev\"."
368fi
369
[1810]370
371#==============================================================================
372if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
[1463]373then
[1810]374
[1463]375   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
[1772]376   CPP_KEY="$CPP_KEY CPP_VEGET"
[1810]377# temporary, for Orchidee versions 1.9.* (before openmp activation)
378   if [[ "$veget" == "orchidee1.9" ]] ; then
379      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
380   fi
381   if [[ "$veget" == "orchidee2.0" ]] ; then
[1838]382      orch_libs="sechiba parameters stomate parallel orglob orchidee"
[1810]383   else
[1811]384      orch_libs="sechiba parameters stomate parallel orglob"
[1810]385   fi
386   LIB="${LIB} -L${ORCH_LIBDIR}"
[1811]387   for lib in ${orch_libs} ; do
[1810]388      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
389         LIB="${LIB} -l${LIBPREFIX}$lib "
390      fi
391   done
392elif [[ "$veget" != "false" ]] ; then
[1772]393   echo "Option -v $veget does not exist"
394   echo "Use ./makelmdz -h for more information"
395   exit 
[1463]396fi
397
[1810]398#===============================================================================
[1463]399if [[ $io == ioipsl ]]
400then
401   CPP_KEY="$CPP_KEY CPP_IOIPSL"
402   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
403   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
[2097]404elif [[ $io == mix ]]
[1897]405then
406   # For now, xios implies also using ioipsl
407   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
408   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
409   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
[2097]410elif [[ $io == xios ]]
411then
412   # For now, xios implies also using ioipsl
413   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
414   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
415   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
[1463]416fi
417
418if [[ "$cosp" == "true" ]]
419then
420   CPP_KEY="$CPP_KEY CPP_COSP"
[2239]421   COSP_PATH="$LIBFGCM/phylmd/cosp"
[2238]422   src_dirs="$src_dirs cosp"
[1463]423#   LIB="${LIB} -l${LIBPREFIX}cosp"
424   opt_dep="$opt_dep cosp"
425   lcosp="-l${LIBPREFIX}cosp"
426   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
427fi
428
[1865]429if [[ "$sisvat" == "true" ]]
430then
431   CPP_KEY="$CPP_KEY CPP_SISVAT"
[2238]432   src_dirs="$src_dirs phy${physique}/sisvat"
[1865]433fi
434
[1990]435if [[ "$rrtm" == "true" ]]
436then
437   CPP_KEY="$CPP_KEY CPP_RRTM"
[2238]438   src_dirs="$src_dirs phy${physique}/rrtm"
[1990]439fi
[1865]440
[1990]441
[1551]442INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
443LIB="$LIB ${NETCDF_LIBDIR}"
[1463]444
445########################################################################
446# calcul du nombre de dimensions
447########################################################################
448
449
450dim_full=$dim
451dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
452set $dim
453dimc=$#
454echo calcul de la dimension
455echo dim $dim
456echo dimc $dimc
457
458########################################################################
459# Gestion des dimensions du modele.
460# on cree ou remplace le fichier des dimensions
461########################################################################
462
[1695]463cd $LIBFGCM/grid
464if [[ -f dimensions.h ]]
465then
466  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
467  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
468  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
469  echo  vous pouvez continuer en repondant oui.
470  echo "Voulez-vous vraiment continuer?"
[1755]471  echo ""
472  echo "WARNING: you are probably already compiling the model somewhere else."
473  echo "Wait until the first compilation is finished before launching this one."
474  echo "If you are sure that you are not compiling elsewhere, just answer "
475  echo "yes (or 'oui') to the question below to proceed."
476  echo "Do you wish to continue?"
[1695]477  read reponse
[1755]478  if [[ $reponse == "oui" || $reponse == "yes" ]]
[1695]479  then
[1696]480    \rm -f $LIBFGCM/grid/dimensions.h
[1695]481  else
482    exit
483  fi
484fi
485
[1463]486cd $LIBFGCM/grid/dimension
487./makdim $dim
[2202]488if (($? != 0))
489then
490    exit 1
491fi
492
[1463]493cat $LIBFGCM/grid/dimensions.h
494cd $LMDGCM
495
496########################################################################
497# Differentes dynamiques (3d, 2d, 1d)
498########################################################################
499
[1810]500if (( $dimc == 3 )) ; then
[2238]501   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
[2239]502   if [[ $physique != "nophys" ]] ; then
[2242]503     src_dirs="$src_dirs dynlonlat_phylonlat dynlonlat_phylonlat/phy${physique}"
504     libdyn_phy="-ldynlonlat_phylonlat"
505     LIBDYN_PHYS='$(LIBO)/libdynlonlat_phylonlat.a'
506     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat'
507     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlonlat_phylonlat_'"${physique}"
[2239]508   fi
[1810]509   cd $LIBFGCM/grid
510   \rm fxyprim.h
511   cp -p fxy_${grille}.h fxyprim.h
[1463]512   filtre="FILTRE=$filtre"
[2016]513   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
[1810]514elif (( $dimc == 2 )) ; then
[2239]515   src_dirs="$src_dirs dyn2d"
[1810]516   filtre="FILTRE= L_FILTRE= "
517   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
518elif (( $dimc == 1 )) ; then
[2239]519   #src_dirs="$src_dirs dyn3d dyn3d_common filtrez"
520   src_dirs="$src_dirs phy${physique}/dyn1d"
[2023]521   CPP_KEY="$CPP_KEY CPP_1D"
[2239]522   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
523   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
524   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
[1463]525else
[1810]526   echo Dimension dimc=$dimc pas prevu ; exit
[1463]527fi
528
529cd $LMDGCM
530
[2112]531########################################################################
532# library directory name:
533########################################################################
[1463]534
[2112]535nomlib=`echo ${arch}_${physique}_${dim_full}_${grille}_${compil_mod}_parall${parallel}_${CPP_KEY}_${FLAG_PARA} | sed -e 's/ //g' -e 's/-//g ' | sed -e 's/CPP_//g'`
536echo "Path to library: "$nomlib
537
[1463]538########################################################################
[2112]539#  Cleanup for a full recompilation, if requested
540########################################################################
541
542if [[ $full == "full" ]]
543then
544# remove makefile and librairies
545  echo "-full option: recompiling from scratch"
546  \rm -f makefile
547  \rm -rf "${LIBOGCM}/${nomlib}"
548fi
549
550########################################################################
[1463]551#  Avant de lancer le make, on recree le makefile si necessaire
552########################################################################
553########################################################################
554# c'est a dire dans 3 cas:
555# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
556#    derniere creation du makefile
557# 2. si le fichier contenant cette liste "liste_des_sources"
558#    n'existe pas.
559# 3. Si le makefile n'existe pas.
560########################################################################
561cd $LMDGCM
[1810]562
[2238]563find libf -name '*.[Fh]' -print | sort > tmp77
564#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
565find libf -name '*.F90' -print | sort > tmp90
[1463]566
[2238]567if [[ -r .makelmdz ]]
[1463]568then
[2238]569old_lmdz_configuration=$(cat .makelmdz )
570else
571old_lmdz_configuration=""
572fi
573lmdz_configuration="$src_dirs"
574if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
575then
576  configuration_change="true"
577else
578  configuration_change="false"
579fi
580
581if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]]
582then
[1463]583  echo "les fichiers suivants ont ete crees ou detruits"
584  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
585  diff liste_des_sources_f77 tmp77
586  diff liste_des_sources_f90 tmp90
587  \cp -f tmp77 liste_des_sources_f77
588  \cp -f tmp90 liste_des_sources_f90
[2238]589  echo "Recreating the makefile"
590  echo "src_dirs: $src_dirs"
591  ./create_make_gcm $src_dirs > tmp
[1463]592  \mv -f tmp makefile
[2238]593  echo "New makefile created"
[1463]594fi
595
[2238]596#Create a .makelmdz file containing main compilation option for later comparisons
597echo "$lmdz_configuration" > .makelmdz
598
[1463]599#################################################################
600# Preparation de l'execution de la comande make
601#################################################################
602
603source_code=${code}.F
[2239]604dirmain=dyn${dimc}d${FLAG_PARA}
[1463]605if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
606then
607  source_code=${code}.F90
[2016]608elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
[2239]609  dirmain=phy$physique
[2016]610  source_code=${code}.F90
[2242]611elif [[ -r $LMDGCM/libf/dynlonlat_phylonlat/phy$physique/${code}.F90 ]] ; then
612  dirmain="dynlonlat_phylonlat/phy${physique}"
[2239]613  source_code=${code}.F90
614elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then
615  dirmain=phy$physique/dyn1d
616  source_code=${code}.F90
[1463]617fi
618
619if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
620then
621  mkdir ${LIBOGCM}/${nomlib}
622  # check we indeed managed to create the directory
623  if [[ ! $? ]]
624  then
625    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
626    exit
627  fi
628fi
629
630# where module files are created
631mod_loc_dir=$localdir
632
633if [[ "$physique" != "nophys" ]]
634then
635  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
636fi
[1810]637INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
[1463]638
639# ranlib utility (check it exists or else default to ls)
640if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
641then
642  ranlib="ranlib"
643else
644  ranlib="ls"
645fi
646
647# add CPP keys to COMPIL_FLAGS
648# (but first add -D before all CPP_KEY items)
649cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
650# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
651if [[ "${fcompiler:0:3}" == "xlf" ]]
652then
653cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
654fi
655COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
656
657#################################################################
658# Execution du make
659#################################################################
660echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
661OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
662OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
663OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
664OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
665INCLUDE="$INCLUDE" \
666$filtre \
667LIBO=${LIBOGCM}/${nomlib} \
668"PHYS=$physique" \
[2239]669LIBPHY=${LIBPHY} \
670LIBDYN_PHYS=${LIBDYN_PHYS} \
[1463]671DIM=$dimc \
672FLAG_PARA=$FLAG_PARA \
[2239]673L_PHY="$lib_phy" \
674L_DYN_PHY="$libdyn_phy" \
[1463]675L_ADJNT=$adjnt \
676L_COSP="$lcosp" \
677L_CHIMIE="$libchimie" \
678LOCAL_DIR="$localdir"  \
679F77="$fcompiler" \
680F90="$fcompiler" \
681OPLINK="$LIB" \
682LINK="$linker" \
683GCM="$LMDGCM" \
684MOD_LOC_DIR=$mod_loc_dir \
685MOD_SUFFIX="mod" \
686AR=$arcommand \
[2239]687DIRMAIN=$dirmain \
[1463]688SOURCE=$source_code \
689PROG=$code
690
691$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
692OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
693OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
694OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
695OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
696INCLUDE="$INCLUDE" \
697$filtre \
698LIBO=${LIBOGCM}/${nomlib} \
699"PHYS=$physique" \
[2239]700LIBPHY=${LIBPHY} \
701LIBDYN_PHYS=${LIBDYN_PHYS} \
[1463]702DIM=$dimc \
703FLAG_PARA=$FLAG_PARA \
[2239]704L_PHY="$lib_phy" \
705L_DYN_PHY="$libdyn_phy" \
[1810]706L_ADJNT=$adjnt \
[1463]707L_COSP="$lcosp" \
708L_CHIMIE="$libchimie" \
709LOCAL_DIR="$localdir"  \
710F77="$fcompiler" \
711F90="$fcompiler" \
712OPLINK="$LIB" \
713LINK="$linker" \
714GCM="$LMDGCM" \
715MOD_LOC_DIR=$mod_loc_dir \
716MOD_SUFFIX="mod" \
717AR=$arcommand \
[2239]718DIRMAIN=$dirmain \
[1463]719SOURCE=$source_code \
720PROG=$code
721
[1810]722
[1696]723if [[ -r $LIBFGCM/grid/dimensions.h ]]
[1463]724then
725  # Cleanup: remove dimension.h file
[1696]726  \rm -f $LIBFGCM/grid/dimensions.h
[1463]727fi
Note: See TracBrowser for help on using the repository browser.