source: LMDZ6/trunk/makelmdz @ 3635

Last change on this file since 3635 was 3574, checked in by fhourdin, 5 years ago

makelmdz ada->jean-zay

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