source: LMDZ6/trunk/makelmdz @ 3223

Last change on this file since 3223 was 3075, checked in by Ehouarn Millour, 7 years ago

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