source: trunk/LMDZ.COMMON/makelmdz @ 1701

Last change on this file since 1701 was 1695, checked in by emillour, 8 years ago

Common dynamics/framework:
Removed some obsolete arch files.
Reorganization of the way paths to external libraries are handles by makelmdz_fcm and makelmdz. This will ease interfacing with Dynamico which follows simillar rules with respect to a given external library ,e.g. for SOMELIBRARY, in the arch.path file:
SOMELIBRARY_LIBDIR="-L/path/to/the/library/libdir -L/possible/other/required/path"
SOMELIBRARY_LIB"-lsomelib -lsomeotherrequiredlib"
SOMELIBRARY_INCDIR"-I/path/to/the/library/incdir -I/possible/other/required/include/path"
EM

  • Property svn:executable set to *
File size: 27.0 KB
RevLine 
[66]1#!/bin/bash
2#
3# $Id $
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
[979]21paramem="par"
[66]22compil_mod=prod
23io=ioipsl
24LIBPREFIX=""
25fcm_path=none
26cosp=false
[1300]27sisvat=false
[1302]28rrtm=false
[1650]29dust=false
30strataer=false
[957]31bands=""
32scatterers=""
[1107]33full=''
[66]34
[1650]35arch_defined="FALSE"
36arch_path="arch"
37arch_default_path="arch"
38
[66]39# guess a default 'arch'
[979]40arch="local" # start with assuming we're on a local machine with local arch file
[1650]41arch_defined="TRUE" # and thus also set arch_defined to true
[66]42## try to recognise machine and infer arch from it
43machine=`hostname`
[1300]44if [[ "${machine:0:3}" == "ada" ]]
[66]45then
[1300]46  arch="X64_ADA"
[66]47fi
48if [[ "${machine:0:7}" == "platine" ]]
49then
50  arch="IA64_PLATINE"
51fi
52if [[ "${machine:0:6}" == "titane" ]]
53then
54  arch="X64_TITANE"
55fi
56if [[ "${machine:0:8}" == "mercure1" ]]
57then
58  arch="SX8_MERCURE"
59fi
60if [[ "${machine:0:8}" == "mercure2" ]]
61then
62  arch="SX9_MERCURE"
63fi
64
65LMDGCM=`pwd -P`
66LIBFGCM=$LMDGCM/libf
67LIBOGCM=$LMDGCM/libo
68if [[ ! -d $LIBOGCM ]]
69then
70  # create the directory
71  mkdir $LIBOGCM
72  if [[ ! $? ]]
73  then
74  echo "Failed to create directory $LIBOGCM"
75  exit
76  fi
77fi
78COSP_PATH=$LMDGCM/.void_dir
79
80
81
82localdir=`pwd -P`
83########################################################################
84#  Quelques initialisations de variables du shell.
85########################################################################
86
87CPP_KEY="" 
[1403]88INCLUDE='-I$(LIBF)/grid -I$(LIBF)/misc -I$(LIBF)/filtrez -I. '
[66]89LIB=""
90adjnt=""
91##COMPIL_FFLAGS="%PROD_FFLAGS"
92PARA_FFLAGS=""
93PARA_LD=""
94EXT_SRC=""
[1403]95#src_dirs: directories containing source files
96src_dirs="grid misc" 
[104]97ccompiler=""
98OPTIMC=""
99INCLUDEC=""
[66]100
101########################################################################
102# lecture des options
103########################################################################
104
105while (($# > 0))
106  do
107  case $1 in
108      "-h") cat <<fin
109manuel complet sur http://...
110Usage :
[957]111makeldmz [options] -arch arch exec
112[-h]                       : brief help
113[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
114[-s nscat]                 : (Generic) Number of radiatively active scatterers
115[-b IRxVIS]                : (Generic) Number of infrared (IR) and visible (VIS) bands for radiative transfer
116[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
117[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug .
118[-c false/MPI1/MPI2]       : (Earth) coupling with ocean model : MPI1/MPI2/false (default: false)
[1019]119[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
120          false       : no vegetation model
121          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
122          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
123          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
124
[957]125[-chimie INCA/false]       : (Earth) with INCA chemistry model or without (default: false)
126[-cosp cosp/false]         : (Earth) add the cosp model (default: false)
[1403]127[-sisvat true/false]  : (Earth) compile with/without sisvat package (default: false)
128[-rrtm true/false]    : (Earth) compile with/without rrtm package (default: false)
[1650]129[-dust true/false]    : (Earth) compile with/without the dust package from Boucher et al. (default: false)
130[-strataer true/false]    : (Earth) compile with/without the strat aer package from Boucher et al. (default: false)
[957]131[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
132[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
[1391]133[-io ioipsl/mix/xios]                   : Input/Output library (default: ioipsl)
[957]134[-include INCLUDES]        : extra include path to add
135[-cpp CPP_KEY]             : additional preprocessing definitions
136[-adjnt]                   : adjoint model, not operational ...
[979]137[-mem]                     : reduced memory dynamics (if in parallel mode)
[957]138[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
139[-link LINKS]              : additional links with other libraries
[1107]140[-full]                    : full (re-)compilation (from scratch)
[957]141[-ext_src path]            : path to an additional set of routines to compile with the model
[1650]142[-arch_path path]          : path to architecture files (default: $arch_default_path)
[957]143 -arch arch                : target architecture
144 exec                      : executable to build
[66]145fin
146          exit;;
147      "-d")
148          dim=$2 ; shift ; shift ;;
149     
150      "-p")
[979]151          physique="$2" ; shift ; shift ;;
[66]152
[957]153      "-s")
154          scatterers=$2 ; shift ; shift ;;
155
156      "-b")
157          bands=$2 ; shift ; shift ;;
158
[66]159      "-g")
160          grille="$2" ; shift ; shift ;;
161
162      "-c")
163          couple="$2" ; shift ; shift ;;
164
165      "-prod")
166          compil_mod="prod" ; shift ;;
167
168      "-dev")
169          compil_mod="dev" ; shift ;;
170
171      "-debug")
172          compil_mod="debug" ; shift ;;
173
174      "-io")
175          io="$2" ; shift ; shift ;;
176
177      "-v")
178          veget="$2" ; shift ; shift ;;
179
180      "-chimie")
181          chimie="$2" ; shift ; shift ;;
182
183      "-parallel")
184          parallel="$2" ; shift ; shift ;;
185     
186      "-include")
187          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
188
189      "-cpp")
190          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
191
192      "-cosp")
193          cosp="$2" ; shift ; shift ;;
[979]194     
[1300]195      "-sisvat")
196          sisvat="$2" ; shift ; shift ;;
197     
[1302]198      "-rrtm")
199          rrtm="$2" ; shift ; shift ;;
200     
[1650]201      "-dust")
202          dust="$2" ; shift ; shift ;;
203     
204      "-strataer")
205          strataer="$2" ; shift ; shift ;;
206     
[979]207      "-mem")
208          paramem="mem" ; shift ;;
[66]209
210      "-filtre")
211          filtre=$2 ; shift ; shift ;;
212
213      "-link")
214          LIB="$LIB $2" ; shift ; shift ;;
215
[1107]216      "-full")
217          full="full" ; shift ;;
[66]218
219      "-ext_src")
220          EXT_SRC=$2 ; shift ; shift ;;
221
222      "-arch")
[1650]223          arch=$2 ; arch_defined="TRUE" ; shift ; shift ;;
[66]224
[1650]225      "-arch_path")
226          arch_path=$2 ; arch_path_defined="TRUE"; shift ; shift ;;
227
[66]228      *)
229          code="$1" ; shift ;;
230  esac
231done
232
233###############################################################
[1391]234# lecture des chemins propres \`a l'architecture de la machine #
[66]235###############################################################
236rm -f .void_file
237echo > .void_file
238rm -rf .void_dir
239mkdir .void_dir
[1650]240
241if [[ "$arch_defined" == "TRUE" ]]
[66]242then
[1650]243  rm -f arch.path
244  rm -f arch.fcm
245  rm -f arch.env
246
247  if test -f $arch_path/arch-${arch}.path
248  then
249    ln -s $arch_path/arch-${arch}.path arch.path
250  elif test -f $arch_default_path/arch-${arch}.path
251  then
252    ln -s $arch_default_path/arch-${arch}.path arch.path
253  fi
254       
255  if test -f $arch_path/arch-${arch}.fcm
256  then
257    ln -s $arch_path/arch-${arch}.fcm arch.fcm
258  elif test -f $arch_default_path/arch-${arch}.fcm
259  then
260    ln -s $arch_default_path/arch-${arch}.fcm arch.fcm
261  fi
262
263  if test -f $arch_path/arch-${arch}.env
264  then
265    ln -s $arch_path/arch-${arch}.env arch.env
266  elif test -f $arch_default_path/arch-${arch}.env
267  then
268    ln -s $arch_default_path/arch-${arch}.env arch.env
269  else
270    ln -s .void_file arch.env
271  fi
272  # source architecture PATH and ENV files
273  source arch.env
[66]274  source arch.path
275else
[1650]276  echo "You must define a target architecture"
277  exit 1
[66]278fi
[1650]279
[66]280########################################################################
281# Definition des clefs CPP, des chemins des includes et modules
282#  et des libraries
283########################################################################
284
285# basic compile flags from arch.fcm file
286archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm )
287COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} )
288
289# other compile flags, depending on compilation mode
290if [[ "$compil_mod" == "prod" ]]
291then
292## read COMPIL_FFLAGS from arch.fcm file
293  archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm )
294  archfileopt=$( echo ${archfileline##%PROD_FFLAGS} )
295  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
296elif [[ "$compil_mod" == "dev" ]]
297then
298## read %DEV_FFLAGS from arch.fcm file
299  archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm )
300  archfileopt=$( echo ${archfileline##%DEV_FFLAGS} )
301  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
302elif [[ "$compil_mod" == "debug" ]]
303then
304## read %DEBUG_FFLAGS from arch.fcm file
305  archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm )
306  archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} )
307  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
308fi
309
310# add CPP_KEY defined in arch.fcm file
311archfileline=$( grep -i '^%FPP_DEF' arch.fcm )
312archfileopt=$( echo ${archfileline##%FPP_DEF} )
313CPP_KEY="$CPP_KEY ${archfileopt}"
314
315# get compiler name from arch.fcm file
316archfileline=$( grep -i '^%COMPILER' arch.fcm )
317fcompiler=$( echo ${archfileline##%COMPILER} )
318
319# get linker name from arch.fcm file
320archfileline=$( grep -i '^%LINK' arch.fcm )
321linker=$( echo ${archfileline##%LINK} )
322
323# get ar command from arch.fcm file
324archfileline=$( grep -i '^%AR' arch.fcm )
325arcommand=$( echo ${archfileline##%AR} )
326
327# get make utility from arch.fcm file
328archfileline=$( grep -i '^%MAKE' arch.fcm )
329makecommand=$( echo ${archfileline##%MAKE} )
330
331# get basic libraries to link with arch.fcm file
332archfileline=$( grep -i '^%BASE_LD' arch.fcm )
333archfileopt=$( echo ${archfileline##%BASE_LD} )
334LIB="$LIB  ${archfileopt}"
335
[1019]336#NB some -I... might be located in the %FPP_FLAGS section of the arch file
337archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
[1049]338for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
[1019]339
[1403]340phys_root=$physique
341if [[ "${physique:0:3}" == "lmd" ]] ; then phys_root=lmd ; fi
342if [[ "${physique:0:3}" == "mar" ]] ; then phys_root=mar ; fi
343if [[ "${physique:0:4}" == "mars" ]] ; then phys_root=mars ; fi
344if [[ "${physique:0:3}" == "std" ]] ; then phys_root=std ; fi
345if [[ "${physique:0:5}" == "venus" ]] ; then phys_root=venus ; fi
346if [[ "${physique:0:5}" == "titan" ]] ; then phys_root=titan ; fi
347if [[ "${physique:0:3}" == "dev" ]] ; then phys_root=dev ; fi
348
[66]349if [[ "$physique" != "nophys" ]]
350then
[1403]351   #We'll use some physics
[1521]352   src_dirs="$src_dirs phy_common phy$physique"
[1403]353   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
[1521]354   LIBPHY_COMMON='$(LIBO)/libphy_common.a'
355   lib_phy='-lphy'"$physique"' -lphy_common'
[101]356   CPP_KEY="$CPP_KEY CPP_PHYS"
[1403]357   if [[ "${phys_root}" == "lmd" ]]
358   then
359   #For lmd physics, default planet type is Earth
[66]360   CPP_KEY="$CPP_KEY CPP_EARTH"
[1403]361   fi
[66]362fi
363
[104]364######### CAS PARTICULIER CHIMIE TITAN
365if [[ "$physique" == "titan" ]]
366then
367   INCLUDE="$INCLUDE"' -I$(LIBF)/chim'"$physique"
368   LIB="$LIB -l${LIBPREFIX}chim$physique"
369   opt_dep="$opt_dep chim$physique"
[1403]370   src_dirs="$src_dirs chim$physique"
[104]371# get C compiler name and optim from arch.fcm file
372   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
373   ccompiler=$( echo ${archfileline##%C_COMPILER} )
374   archfileline=$( grep -i '^%C_OPTIM' arch.fcm )
375   coptim=$( echo ${archfileline##%C_OPTIM} )
[1076]376   OPTIMC="${coptim}"
[104]377   INCLUDEC='-I$(LIBF)/grid -I.'
378fi
379#########
380
[1661]381######### CAS PARTICULIER NUAGES VENUS
382if [[ "$physique" == "venus" ]]
383then
384   src_dirs="$src_dirs phy${physique}/cloudvenus"
385fi
386#########
387
[1107]388# for Mars (but could be used by others as well), there is also "aeronomars"
389if [[ -d ${LIBFGCM}/aerono${physique} ]]
390then
[1403]391   src_dirs="$src_dirs aerono$physique"
[1107]392   INCLUDE="$INCLUDE -I${LIBFGCM}/aerono${physique}"
393   LIB="$LIB -l${LIBPREFIX}aerono$physique"
394   opt_dep="$opt_dep aerono$physique"
395   laeronomars="-l${LIBPREFIX}aeronomars"
396fi
397
398
[66]399if [[ "$chimie" == "INCA" ]]
400then
401   CPP_KEY="$CPP_KEY INCA"
402   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
[1695]403   LIB="$LIB -L${INCA_LIBDIR} ${INCA_LIB}"
404   libchimie=" -L${INCA_LIBDIR} ${INCA_LIB}"
[66]405fi
406
407if [[ "$couple" != "false" ]]
408then
409   CPP_KEY="$CPP_KEY CPP_COUPLE"
410   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
[1695]411   LIB="$LIB -L${OASIS_LIBDIR} ${OASIS_LIB}"
[66]412fi
413
[1530]414if [[ "$parallel" != "none" && \
415     ( "$code" == "newstart" || "$code" == "start2archive" ) ]]
416then
417    echo "newstart or start2archive utilities should be run in serial!"
418    echo " Compile without -parallel [mpi|omp|mpi_omp] option!"
419    exit
420fi
421
[66]422if [[ "$parallel" == "none" ]]
423then
424  FLAG_PARA=''
425else
[1019]426  FLAG_PARA="$paramem"
[66]427fi
428
429if [[ "$parallel" == "mpi" ]]
430then
431   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
432  # MPI additional compilation options
433  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
434  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
435  # MPI additional links
436  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
437  PARA_LD=$( echo ${archfileline##%MPI_LD} )
438elif [[ "$parallel" == "omp" ]]
439then
440   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
441  # OMP additional compilation options
442  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
443  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
444  # OMP additional links
445  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
446  PARA_LD=$( echo ${archfileline##%OMP_LD} )
447elif [[ "$parallel" == "mpi_omp" ]]
448then
449   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
450  # MPI additional compilation options
451  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
452  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
453  # OMP additional compilation options
454  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
455  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
456  # MPI additional links
457  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
458  PARA_LD=$( echo ${archfileline##%MPI_LD} )
459  # OMP additional links
460  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
461  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
462fi
463
464if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
465   && "$compil_mod" == "debug" ]]
466then
467    echo "Usually, parallelization with OpenMP requires some optimization."
468    echo "We suggest switching to \"-dev\"."
469fi
470
[1019]471if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
[66]472then
[1019]473
[1695]474   INCLUDE="${INCLUDE} ${ORCHIDEE_INCDIR}"
[66]475   CPP_KEY="$CPP_KEY CPP_VEGET"
[1019]476# temporary, for Orchidee versions 1.9.* (before openmp activation)
477   if [[ "$veget" == "orchidee1.9" ]] ; then
478      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
479   fi
480   if [[ "$veget" == "orchidee2.0" ]] ; then
481      orch_libs="sechiba parameters stomate parallel orglob orchidee"
482   else
483      orch_libs="sechiba parameters stomate parallel orglob"
484   fi
[1695]485   LIB="${LIB} -L${ORCHIDEE_LIBDIR} ${ORCHIDEE_LIB}"
[1019]486elif [[ "$veget" != "false" ]] ; then
487   echo "Option -v $veget does not exist"
488   echo "Use ./makelmdz -h for more information"
489   exit 
[66]490fi
491
492if [[ $io == ioipsl ]]
493then
494   CPP_KEY="$CPP_KEY CPP_IOIPSL"
[1695]495   INCLUDE="$INCLUDE ${IOIPSL_INCDIR}"
496   LIB="$LIB -L${IOIPSL_LIBDIR} ${IOIPSL_LIB}"
[1391]497elif [[ $io == mix ]]
[1300]498then
499   # For now, xios implies also using ioipsl
500   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
[1695]501   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
502   LIB="$LIB -L${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
[1391]503elif [[ $io == xios ]]
504then
505   # For now, xios implies also using ioipsl
506   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
[1695]507   INCLUDE="$INCLUDE ${IOIPSL_INCDIR} ${XIOS_INCDIR}"
508   LIB="$LIB ${IOIPSL_LIBDIR} ${IOIPSL_LIB} ${XIOS_LIBDIR} ${XIOS_LIB}"
[66]509fi
510
511if [[ "$cosp" == "true" ]]
512then
513   CPP_KEY="$CPP_KEY CPP_COSP"
514   COSP_PATH="$LIBFGCM/cosp"
[1403]515   src_dirs="$src_dirs cosp"
[66]516#   LIB="${LIB} -l${LIBPREFIX}cosp"
517   opt_dep="$opt_dep cosp"
518   lcosp="-l${LIBPREFIX}cosp"
519   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
520fi
521
[1300]522if [[ "$sisvat" == "true" ]]
523then
524   CPP_KEY="$CPP_KEY CPP_SISVAT"
[1403]525   src_dirs="$src_dirs phy${physique}/sisvat"
[1300]526fi
[1019]527
[1302]528if [[ "$rrtm" == "true" ]]
529then
530   CPP_KEY="$CPP_KEY CPP_RRTM"
[1403]531   src_dirs="$src_dirs phy${physique}/rrtm"
[1302]532fi
[1300]533
[1650]534if [[ "$dust" == "true" ]]
535then
536   CPP_KEY="$CPP_KEY CPP_Dust"
537   src_dirs="$src_dirs phy${physique}/Dust"
538fi
[1302]539
[1650]540if [[ "$strataer" == "true" ]]
541then
542   CPP_KEY="$CPP_KEY CPP_StratAer"
543   src_dirs="$src_dirs phy${physique}/StratAer"
544fi
545
[1695]546# NETCDF library include/library paths
[270]547INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
[1695]548LIB="$LIB ${NETCDF_LIBDIR} ${NETCDF_LIB}"
[66]549
550########################################################################
551# calcul du nombre de dimensions
552########################################################################
553
554
555dim_full=$dim
556dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
557set $dim
558dimc=$#
559echo calcul de la dimension
560echo dim $dim
561echo dimc $dimc
562
563
564########################################################################
565# Gestion des dimensions du modele.
566# on cree ou remplace le fichier des dimensions
567########################################################################
568
[979]569cd $LIBFGCM/grid
570if [[ -f dimensions.h ]]
571then
572  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
573  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
574  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
575  echo  vous pouvez continuer en repondant oui.
576  echo "Voulez-vous vraiment continuer?"
577  echo ""
578  echo "WARNING: you are probably already compiling the model somewhere else."
579  echo "Wait until the first compilation is finished before launching this one."
580  echo "If you are sure that you are not compiling elsewhere, just answer "
581  echo "yes (or 'oui') to the question below to proceed."
582  echo "Do you wish to continue?"
583  read reponse
584  if [[ $reponse == "oui" || $reponse == "yes" ]]
585  then
586    \rm -f $LIBFGCM/grid/dimensions.h
587  else
588    exit
589  fi
590fi
591
592
[66]593cd $LIBFGCM/grid/dimension
594./makdim $dim
[1403]595if (($? != 0))
596then
597    exit 1
598fi
599
[66]600cat $LIBFGCM/grid/dimensions.h
601cd $LMDGCM
602
[957]603if [[ "$bands" != "" ]]
604then
605  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
606  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
607  cd $LIBFGCM/phy$physique/bands
608  ./makbands $bands
609  cat $LIBFGCM/phy$physique/bands.h
610  cd $LMDGCM
611fi
[66]612
[957]613if [[ "$scatterers" != "" ]]
614then
615  # Generic model, recreate scatterers.h
616  cd $LIBFGCM/phy$physique/scatterers
617  ./make_scatterers $scatterers
618  cat $LIBFGCM/phy$physique/scatterers.h
619  cd $LMDGCM
620fi
621
622
[66]623########################################################################
624# Differentes dynamiques (3d, 2d, 1d)
625########################################################################
626
[1403]627if (( $dimc == 3 )) ; then
628   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
629   if [[ $physique != "nophys" ]] ; then
[1540]630     src_dirs="$src_dirs dynphy_lonlat dynphy_lonlat/phy${phys_root}"
631     libdyn_phy="-ldynphy_lonlat"
632     LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
633     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat'
634     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat/'"${phys_root}"
[1403]635   fi
[66]636  cd $LIBFGCM/grid
637  \rm fxyprim.h
638  cp -p fxy_${grille}.h fxyprim.h
[1302]639  filtre="FILTRE=$filtre"
640  INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
[1403]641elif (( $dimc == 2 )) ; then
642   src_dirs="$src_dirs dyn2d"
[66]643   filtre="FILTRE= L_FILTRE= "
[1302]644   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
[1403]645elif (( $dimc == 1 )) ; then
[1530]646   ## Sanity check: 1D models should be used in serial
647   if [[ $parallel != "none" ]]
648   then
649     echo "Error: a 1D model should not be compiled with "
650     echo "       -parallel [mpi|omp|mpi_omp] option!"
651     exit
652   fi
[1302]653   echo pas de dynamique
[1403]654   src_dirs="$src_dirs phy${physique}/dyn1d"
[1302]655   CPP_KEY="$CPP_KEY CPP_1D"
[1403]656   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
657   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
658   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
[66]659else
[1302]660   echo Dimension dimc=$dimc pas prevu ; exit
[66]661fi
662
663cd $LMDGCM
664
[1391]665########################################################################
666# library directory name:
667########################################################################
668
669nomlib=`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'`
670echo "Path to library: "$nomlib
671
672########################################################################
673#  Cleanup for a full recompilation, if requested
674########################################################################
675
[1107]676if [[ $full == "full" ]]
677then
[1391]678# remove makefile and libraries
679  echo "-full option: recompiling from scratch"
[1107]680  \rm -f makefile
[1391]681  \rm -rf "${LIBOGCM}/${nomlib}"
[1107]682fi
[66]683
684########################################################################
685#  Avant de lancer le make, on recree le makefile si necessaire
686########################################################################
687########################################################################
688# c'est a dire dans 3 cas:
689# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
690#    derniere creation du makefile
691# 2. si le fichier contenant cette liste "liste_des_sources"
692#    n'existe pas.
693# 3. Si le makefile n'existe pas.
694########################################################################
695cd $LMDGCM
[1403]696
697
698if [[ -r .makelmdz ]]
699then
700old_lmdz_configuration=$(cat .makelmdz )
701else
702old_lmdz_configuration=""
703fi
704lmdz_configuration="$src_dirs"
705if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
706then
707  configuration_change="true"
708else
709  configuration_change="false"
710fi
711
712mkdir -p make_dir
713suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
714echo suf_make $suf_make
715
716\rm tmp77 tmp90
717for dir in $src_dirs ; do
718find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
719find libf/$dir -name '*.F90' -print | sort >> tmp90
[104]720######### CAS PARTICULIER CHIMIE TITAN
721if [[ "$physique" == "titan" ]]
722then 
[1048]723  find libf -name '*.[ch]' -print | sort > tmpC
[104]724fi
725#########
[1403]726done
[66]727
[1403]728liste77=make_dir/liste_des_sources_f77_$suf_make
729liste90=make_dir/liste_des_sources_f90_$suf_make
730if [[ "$physique" == "titan" ]] ; then
731listeC=make_dir/liste_des_sources_C_$suf_make
732fi
733makefile=make_dir/makefile_$suf_make
734
[1444]735if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]]
[66]736then
737  echo "les fichiers suivants ont ete crees ou detruits"
738  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
[1403]739  diff $liste77  tmp77
740  diff $liste90 tmp90
741  \cp -f tmp77 $liste77
742  \cp -f tmp90 $liste90
[104]743######### CAS PARTICULIER CHIMIE TITAN
744  if [[ "$physique" == "titan" ]]
745  then 
[1403]746  diff $listeC tmpC
747  \cp -f tmpC $listeC
[104]748  fi
749#########
[1403]750  echo "Recreating the makefile"
751  echo "src_dirs: $src_dirs"
752  ./create_make_gcm $src_dirs > tmp
753  \mv -f tmp $makefile
754  echo "New makefile created"
[104]755######### CAS PARTICULIER CHIMIE TITAN
756else if [[ "$physique" == "titan" ]]
757 then
[1403]758   if [[ ! ( -r $listeC ) || ` diff tmpC $listeC | wc -w ` -ne 0 ]]
[104]759   then
[1403]760     diff $listeC tmpC
761     \cp -f tmpC $listeC
[104]762     echo "on recree le makefile"
[1403]763     ./create_make_gcm $src_dirs > tmp
764     \mv -f tmp $makefile
[104]765     echo "Nouveau makefile cree"
766   fi
767 fi
768#########
[66]769fi
770
[1403]771ln -sf $makefile makefile
772
773#Create a .makelmdz file containing main compilation option for later comparisons
774echo "$lmdz_configuration" > .makelmdz
775
[66]776#################################################################
[104]777# Preparation de l'execution de la commande make
[66]778#################################################################
779
[849]780# find code suffix and directory where code is located
781if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
[66]782then
[849]783  source_code=${code}.F
[1403]784  dirmain=dyn${dimc}d${FLAG_PARA}
[849]785else
786  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
787  then
788    source_code=${code}.F90
[1403]789    dirmain=dyn${dimc}d${FLAG_PARA}
[849]790  else
791    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
792    then
793      source_code=${code}.F
[1403]794      dirmain=phy${physique}
[849]795    else
[887]796      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
[849]797      then
798        source_code=${code}.F90
[1403]799        dirmain=phy${physique}
[849]800      else
[1540]801        if [[ -r $LMDGCM/libf/dynphy_lonlat/phy$phys_root/${code}.F ]] 
[1403]802        then
803          source_code=${code}.F
[1540]804          dirmain="dynphy_lonlat/phy${phys_root}"
[1403]805        else
806          if [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F ]]
807          then
808            source_code=${code}.F
809            dirmain=phy$physique/dyn1d
810          else
811            echo "Error: cannot find ${code}.F[90]"
812            echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
813            exit
814          fi
815        fi
[849]816      fi
817    fi
818  fi
[66]819fi
820
821if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
822then
823  mkdir ${LIBOGCM}/${nomlib}
824  # check we indeed managed to create the directory
825  if [[ ! $? ]]
826  then
827    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
828    exit
829  fi
830fi
831
832# where module files are created
833mod_loc_dir=$localdir
834
835if [[ "$physique" != "nophys" ]]
836then
837  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
[1403]838#  phys="PHYS=$physique"
839#else
840#  # trick to avoid having a physics-related library in the makefile
841#  phys="L_PHY= LIBPHY="
[66]842fi
[1403]843INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
844#if (( $dimension == 1 ))
845#then
846# INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
847#else
848#INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
849#fi
[66]850
851# ranlib utility (check it exists or else default to ls)
852if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
853then
854  ranlib="ranlib"
855else
856  ranlib="ls"
857fi
858
859# add CPP keys to COMPIL_FLAGS
860# (but first add -D before all CPP_KEY items)
861cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
862# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
863if [[ "${fcompiler:0:3}" == "xlf" ]]
864then
865cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
866fi
867COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
868
869#################################################################
870# Execution du make
871#################################################################
872echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
873OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
874OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
875OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
876OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
[1076]877OPTIMC="$OPTIMC" \
[66]878INCLUDE="$INCLUDE" \
[104]879INCLUDEC="$includec" \
[66]880$filtre \
881LIBO=${LIBOGCM}/${nomlib} \
[1403]882"PHYS=$physique" \
883LIBPHY=${LIBPHY} \
[1521]884LIBPHY_COMMON=${LIBPHY_COMMON} \
[1403]885LIBDYN_PHYS=${LIBDYN_PHYS} \
[66]886DIM=$dimc \
887FLAG_PARA=$FLAG_PARA \
[1403]888L_PHY="$lib_phy" \
889L_DYN_PHY="$libdyn_phy" \
[66]890L_ADJNT=$adjnt \
891L_COSP="$lcosp" \
[1107]892L_AERONOMARS="$laeronomars" \
[66]893L_CHIMIE="$libchimie" \
894LOCAL_DIR="$localdir"  \
895F77="$fcompiler" \
896F90="$fcompiler" \
[104]897CCC="$ccompiler" \
[66]898OPLINK="$LIB" \
899LINK="$linker" \
900GCM="$LMDGCM" \
901MOD_LOC_DIR=$mod_loc_dir \
902MOD_SUFFIX="mod" \
903AR=$arcommand \
[1403]904DIRMAIN=$dirmain \
[66]905SOURCE=$source_code \
906PROG=$code
907
908$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
909OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
910OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
911OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
912OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
[1076]913OPTIMC="$OPTIMC" \
[66]914INCLUDE="$INCLUDE" \
[104]915INCLUDEC="$includec" \
[66]916$filtre \
917LIBO=${LIBOGCM}/${nomlib} \
[1403]918"PHYS=$physique" \
919LIBPHY=${LIBPHY} \
[1521]920LIBPHY_COMMON=${LIBPHY_COMMON} \
[1403]921LIBDYN_PHYS=${LIBDYN_PHYS} \
[66]922DIM=$dimc \
923FLAG_PARA=$FLAG_PARA \
[1403]924L_PHY="$lib_phy" \
925L_DYN_PHY="$libdyn_phy" \
[66]926L_ADJNT="$adjnt" \
927L_COSP="$lcosp" \
[1107]928L_AERONOMARS="$laeronomars" \
[66]929L_CHIMIE="$libchimie" \
930LOCAL_DIR="$localdir"  \
931F77="$fcompiler" \
932F90="$fcompiler" \
[104]933CCC="$ccompiler" \
[66]934OPLINK="$LIB" \
935LINK="$linker" \
936GCM="$LMDGCM" \
937MOD_LOC_DIR=$mod_loc_dir \
938MOD_SUFFIX="mod" \
939AR=$arcommand \
[1403]940DIRMAIN=$dirmain \
[66]941SOURCE=$source_code \
942PROG=$code
943
[979]944if [[ -r $LIBFGCM/grid/dimensions.h ]]
[66]945then
946  # Cleanup: remove dimension.h file
[979]947  \rm -f $LIBFGCM/grid/dimensions.h
[66]948fi
Note: See TracBrowser for help on using the repository browser.