source: LMDZ6/trunk/makelmdz @ 3901

Last change on this file since 3901 was 3901, checked in by evignon, 3 years ago

Commission LMDZ-sisvat, deuxieme phase:

  • suppression du repertoire sisvat
  • nettoyage de certains scripts de la physique et des makefile
  • 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.9 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
29inlandsis=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="IN_LMDZ" 
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[-inlandsis true/false]  : compile with/without inlandsis 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      "-inlandsis")
193          inlandsis="$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 [[ "$inlandsis" == "true" ]]
516then
517   CPP_KEY="$CPP_KEY CPP_INLANDSIS"
518   src_dirs="$src_dirs phy${physique}/inlandsis"
519fi
520
521
522if [[ "$rrtm" == "true" ]]
523then
524   CPP_KEY="$CPP_KEY CPP_RRTM"
525   src_dirs="$src_dirs phy${physique}/rrtm"
526fi
527
528if [[ "$dust" == "true" ]]
529then
530   CPP_KEY="$CPP_KEY CPP_Dust"
531   src_dirs="$src_dirs phy${physique}/Dust"
532fi
533
534if [[ "$strataer" == "true" ]]
535then
536   CPP_KEY="$CPP_KEY CPP_StratAer"
537   src_dirs="$src_dirs phy${physique}/StratAer"
538fi
539
540#add new ocean skin modelisation to source dir by default
541
542src_dirs="$src_dirs phy${physique}/Ocean_skin"
543
544
545INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
546LIB="$LIB ${NETCDF_LIBDIR}"
547
548########################################################################
549# calcul du nombre de dimensions
550########################################################################
551
552
553dim_full=$dim
554dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
555set $dim
556dimc=$#
557echo calcul de la dimension
558echo dim $dim
559echo dimc $dimc
560
561########################################################################
562# Gestion des dimensions du modele.
563# on cree ou remplace le fichier des dimensions
564########################################################################
565
566cd $LIBFGCM/grid
567if [[ -f dimensions.h ]]
568then
569  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
570  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
571  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
572  echo  vous pouvez continuer en repondant oui.
573  echo "Voulez-vous vraiment continuer?"
574  echo ""
575  echo "WARNING: you are probably already compiling the model somewhere else."
576  echo "Wait until the first compilation is finished before launching this one."
577  echo "If you are sure that you are not compiling elsewhere, just answer "
578  echo "yes (or 'oui') to the question below to proceed."
579  echo "Do you wish to continue?"
580  read reponse
581  if [[ $reponse == "oui" || $reponse == "yes" ]]
582  then
583    \rm -f $LIBFGCM/grid/dimensions.h
584  else
585    exit
586  fi
587fi
588
589cd $LIBFGCM/grid/dimension
590./makdim $dim
591if (($? != 0))
592then
593    exit 1
594fi
595
596cat $LIBFGCM/grid/dimensions.h
597cd $LMDGCM
598
599########################################################################
600# Differentes dynamiques (3d, 2d, 1d)
601########################################################################
602
603if (( $dimc == 3 )) ; then
604   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
605   if [[ $physique != "nophys" ]] ; then
606     src_dirs="$src_dirs dynphy_lonlat dynphy_lonlat/phy${phys_root}"
607     libdyn_phy="-ldynphy_lonlat"
608     LIBDYN_PHYS='$(LIBO)/libdynphy_lonlat.a'
609     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat'
610     INCLUDE="$INCLUDE "'-I$(LIBF)/dynphy_lonlat/'"phy${phys_root}"
611   fi
612   cd $LIBFGCM/grid
613   \rm fxyprim.h
614   cp -p fxy_${grille}.h fxyprim.h
615   filtre="FILTRE=$filtre"
616   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
617elif (( $dimc == 2 )) ; then
618   src_dirs="$src_dirs dyn2d"
619   filtre="FILTRE= L_FILTRE= "
620   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
621elif (( $dimc == 1 )) ; then
622   #src_dirs="$src_dirs dyn3d dyn3d_common filtrez"
623   src_dirs="$src_dirs phy${physique}/dyn1d"
624   CPP_KEY="$CPP_KEY CPP_1D"
625   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
626   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
627   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
628else
629   echo Dimension dimc=$dimc pas prevu ; exit
630fi
631
632cd $LMDGCM
633
634########################################################################
635# library directory name:
636########################################################################
637
638nomlib=`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'`
639echo "Path to library: "$nomlib
640
641########################################################################
642#  Cleanup for a full recompilation, if requested
643########################################################################
644
645if [[ $full == "full" ]]
646then
647# remove makefile and librairies
648  echo "-full option: recompiling from scratch"
649  \rm -f makefile
650  \rm -rf "${LIBOGCM}/${nomlib}"
651fi
652
653########################################################################
654#  Avant de lancer le make, on recree le makefile si necessaire
655########################################################################
656########################################################################
657# c'est a dire dans 3 cas:
658# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
659#    derniere creation du makefile
660# 2. si le fichier contenant cette liste "liste_des_sources"
661#    n'existe pas.
662# 3. Si le makefile n'existe pas.
663########################################################################
664cd $LMDGCM
665
666
667if [[ -r .makelmdz ]]
668then
669old_lmdz_configuration=$(cat .makelmdz )
670else
671old_lmdz_configuration=""
672fi
673lmdz_configuration="$src_dirs"
674if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
675then
676  configuration_change="true"
677else
678  configuration_change="false"
679fi
680
681mkdir -p make_dir
682suf_make=`echo $src_dirs | sed -e 's/\//_/g' -e 's/ /_/g'`
683echo suf_make $suf_make
684
685\rm tmp77 tmp90
686for dir in $src_dirs ; do
687find libf/$dir -name '*.[Fh]' -print | sort >> tmp77
688find libf/$dir -name '*.F90' -print | sort >> tmp90
689done
690
691liste77=make_dir/liste_des_sources_f77_$suf_make
692liste90=make_dir/liste_des_sources_f90_$suf_make
693makefile=make_dir/makefile_$suf_make
694
695if [[ $configuration_change == "true" || ! ( -r $makefile ) || ! ( -r $liste90 ) || ! ( -r $liste77 ) || ` diff tmp77 $liste77 | wc -w ` -ne 0 || ` diff tmp90 $liste90 | wc -w ` -ne 0 ]]
696then
697  echo "les fichiers suivants ont ete crees ou detruits"
698  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
699  diff $liste77 tmp77
700  diff $liste90 tmp90
701  \cp -f tmp77 $liste77
702  \cp -f tmp90 $liste90
703  echo "Recreating the makefile"
704  echo "src_dirs: $src_dirs"
705  ./create_make_gcm $src_dirs > tmp
706  \mv -f tmp $makefile
707  echo "New makefile created"
708fi
709
710ln -sf $makefile makefile
711
712#Create a .makelmdz file containing main compilation option for later comparisons
713echo "$lmdz_configuration" > .makelmdz
714
715#################################################################
716# Preparation de l'execution de la comande make
717#################################################################
718
719source_code=${code}.F
720dirmain=dyn${dimc}d${FLAG_PARA}
721if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
722then
723  source_code=${code}.F90
724elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
725  dirmain=phy$physique
726  source_code=${code}.F90
727elif [[ -r $LMDGCM/libf/dynphy_lonlat/phy$phys_root/${code}.F90 ]] ; then
728  dirmain="dynphy_lonlat/phy${phys_root}"
729  source_code=${code}.F90
730elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then
731  dirmain=phy$physique/dyn1d
732  source_code=${code}.F90
733fi
734
735if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
736then
737  mkdir ${LIBOGCM}/${nomlib}
738  # check we indeed managed to create the directory
739  if [[ ! $? ]]
740  then
741    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
742    exit
743  fi
744fi
745
746# where module files are created
747mod_loc_dir=$localdir
748
749if [[ "$physique" != "nophys" ]]
750then
751  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
752fi
753INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
754
755# ranlib utility (check it exists or else default to ls)
756if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
757then
758  ranlib="ranlib"
759else
760  ranlib="ls"
761fi
762
763# add CPP keys to COMPIL_FLAGS
764# (but first add -D before all CPP_KEY items)
765cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
766# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
767if [[ "${fcompiler:0:3}" == "xlf" ]]
768then
769cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
770fi
771COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
772
773#################################################################
774# Execution du make
775#################################################################
776echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
777OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
778OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
779OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
780OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
781INCLUDE="$INCLUDE" \
782$filtre \
783LIBO=${LIBOGCM}/${nomlib} \
784"PHYS=$physique" \
785LIBPHY=${LIBPHY} \
786LIBPHY_COMMON=${LIBPHY_COMMON} \
787LIBDYN_PHYS=${LIBDYN_PHYS} \
788DIM=$dimc \
789FLAG_PARA=$FLAG_PARA \
790L_PHY="$lib_phy" \
791L_DYN_PHY="$libdyn_phy" \
792L_ADJNT=$adjnt \
793L_COSP="$lcosp" \
794L_COSP2="$lcosp2" \
795L_COSPV2="$lcospv2" \
796L_CHIMIE="$libchimie" \
797LOCAL_DIR="$localdir"  \
798F77="$fcompiler" \
799F90="$fcompiler" \
800OPLINK="$LIB" \
801LINK="$linker" \
802GCM="$LMDGCM" \
803MOD_LOC_DIR=$mod_loc_dir \
804MOD_SUFFIX="mod" \
805AR=$arcommand \
806ARFLAGS="$arflags" \
807DIRMAIN=$dirmain \
808SOURCE=$source_code \
809PROG=$code
810
811$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
812OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
813OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
814OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
815OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
816INCLUDE="$INCLUDE" \
817$filtre \
818LIBO=${LIBOGCM}/${nomlib} \
819"PHYS=$physique" \
820LIBPHY=${LIBPHY} \
821LIBPHY_COMMON=${LIBPHY_COMMON} \
822LIBDYN_PHYS=${LIBDYN_PHYS} \
823DIM=$dimc \
824FLAG_PARA=$FLAG_PARA \
825L_PHY="$lib_phy" \
826L_DYN_PHY="$libdyn_phy" \
827L_ADJNT=$adjnt \
828L_COSP="$lcosp" \
829L_COSP2="$lcosp2" \
830L_COSPV2="$lcospv2" \
831L_CHIMIE="$libchimie" \
832LOCAL_DIR="$localdir"  \
833F77="$fcompiler" \
834F90="$fcompiler" \
835OPLINK="$LIB" \
836LINK="$linker" \
837GCM="$LMDGCM" \
838MOD_LOC_DIR=$mod_loc_dir \
839MOD_SUFFIX="mod" \
840AR=$arcommand \
841ARFLAGS="$arflags" \
842DIRMAIN=$dirmain \
843SOURCE=$source_code \
844PROG=$code
845
846
847if [[ -r $LIBFGCM/grid/dimensions.h ]]
848then
849  # Cleanup: remove dimension.h file
850  \rm -f $LIBFGCM/grid/dimensions.h
851fi
Note: See TracBrowser for help on using the repository browser.