source: LMDZ5/branches/testing/makelmdz @ 2776

Last change on this file since 2776 was 2720, checked in by Laurent Fairhead, 8 years ago

Merged trunk changes r2664:2719 into testing branch

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