source: LMDZ6/branches/LMDZ_cdrag_LSCE/makelmdz @ 5304

Last change on this file since 5304 was 4669, checked in by Laurent Fairhead, 14 months ago

Merged with trunk revision 4586 corresponding to june 2023 testing

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