source: LMDZ5/branches/testing/makelmdz @ 2394

Last change on this file since 2394 was 2298, checked in by Laurent Fairhead, 9 years ago

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