source: LMDZ5/trunk/makelmdz @ 2239

Last change on this file since 2239 was 2239, checked in by Ehouarn Millour, 9 years ago

Reorganizing physics/dynamics interface:

  • what is related to dynamics-physics interface is now in a seperate directory: dynlmdz_phy* for physics in phy*
  • 1d model and related dependencies (including a couple from "dynamics", set up as symbolic links) is now in subdirectory "dyn1d" of phy*.
  • "bibio" directory is now "misc" and should only contain autonomous utilities.
  • "cosp" is now a subdirectory of phylmd.

EM

  • 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: 21.3 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
286if [[ "$physique" != "nophys" ]]
287then
288   #We'll use some physics
289   src_dirs="$src_dirs phy$physique"
290   LIBPHY='$(LIBO)/libphy'"$physique"'.a'
291   lib_phy='-lphy'"$physique"
292   CPP_KEY="$CPP_KEY CPP_PHYS"
293   if [[ "${physique:0:3}" == "lmd" ]]
294   then
295   #For lmd physics, default planet type is Earth
296   CPP_KEY="$CPP_KEY CPP_EARTH"
297   fi
298fi
299
300if [[ "$chimie" == "INCA" ]]
301then
302   CPP_KEY="$CPP_KEY INCA"
303   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
304   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
305   libchimie=" -L${INCA_LIBDIR} -lchimie"
306fi
307
308if [[ "$couple" != "false" ]]
309then
310   CPP_KEY="$CPP_KEY CPP_COUPLE"
311   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
312   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
313fi
314
315if [[ "$parallel" == "none" ]]
316then
317  FLAG_PARA=''
318else
319  FLAG_PARA="$paramem"
320  if [[ $paramem == par ]]
321  then
322      echo "The version of the dynamics in dyn3dpar is no longer updated."
323      echo "You should use option \"-mem\"."
324      exit 1
325  fi
326fi
327
328if [[ "$parallel" == "mpi" ]]
329then
330   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
331  # MPI additional compilation options
332  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
333  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
334  # MPI additional links
335  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
336  PARA_LD=$( echo ${archfileline##%MPI_LD} )
337elif [[ "$parallel" == "omp" ]]
338then
339   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
340  # OMP additional compilation options
341  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
342  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
343  # OMP additional links
344  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
345  PARA_LD=$( echo ${archfileline##%OMP_LD} )
346elif [[ "$parallel" == "mpi_omp" ]]
347then
348   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
349  # MPI additional compilation options
350  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
351  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
352  # OMP additional compilation options
353  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
354  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
355  # MPI additional links
356  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
357  PARA_LD=$( echo ${archfileline##%MPI_LD} )
358  # OMP additional links
359  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
360  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
361fi
362
363if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
364   && "$compil_mod" == "debug" ]]
365then
366    echo "Usually, parallelization with OpenMP requires some optimization."
367    echo "We suggest switching to \"-dev\"."
368fi
369
370
371#==============================================================================
372if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
373then
374
375   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
376   CPP_KEY="$CPP_KEY CPP_VEGET"
377# temporary, for Orchidee versions 1.9.* (before openmp activation)
378   if [[ "$veget" == "orchidee1.9" ]] ; then
379      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
380   fi
381   if [[ "$veget" == "orchidee2.0" ]] ; then
382      orch_libs="sechiba parameters stomate parallel orglob orchidee"
383   else
384      orch_libs="sechiba parameters stomate parallel orglob"
385   fi
386   LIB="${LIB} -L${ORCH_LIBDIR}"
387   for lib in ${orch_libs} ; do
388      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
389         LIB="${LIB} -l${LIBPREFIX}$lib "
390      fi
391   done
392elif [[ "$veget" != "false" ]] ; then
393   echo "Option -v $veget does not exist"
394   echo "Use ./makelmdz -h for more information"
395   exit 
396fi
397
398#===============================================================================
399if [[ $io == ioipsl ]]
400then
401   CPP_KEY="$CPP_KEY CPP_IOIPSL"
402   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
403   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
404elif [[ $io == mix ]]
405then
406   # For now, xios implies also using ioipsl
407   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS"
408   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
409   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
410elif [[ $io == xios ]]
411then
412   # For now, xios implies also using ioipsl
413   CPP_KEY="$CPP_KEY CPP_IOIPSL CPP_XIOS CPP_IOIPSL_NO_OUTPUT"
414   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR} -I${XIOS_INCDIR}"
415   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl -L${XIOS_LIBDIR} -l${LIBPREFIX}stdc++ -l${LIBPREFIX}xios"
416fi
417
418if [[ "$cosp" == "true" ]]
419then
420   CPP_KEY="$CPP_KEY CPP_COSP"
421   COSP_PATH="$LIBFGCM/phylmd/cosp"
422   src_dirs="$src_dirs cosp"
423#   LIB="${LIB} -l${LIBPREFIX}cosp"
424   opt_dep="$opt_dep cosp"
425   lcosp="-l${LIBPREFIX}cosp"
426   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
427fi
428
429if [[ "$sisvat" == "true" ]]
430then
431   CPP_KEY="$CPP_KEY CPP_SISVAT"
432   src_dirs="$src_dirs phy${physique}/sisvat"
433fi
434
435if [[ "$rrtm" == "true" ]]
436then
437   CPP_KEY="$CPP_KEY CPP_RRTM"
438   src_dirs="$src_dirs phy${physique}/rrtm"
439fi
440
441
442INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
443LIB="$LIB ${NETCDF_LIBDIR}"
444
445########################################################################
446# calcul du nombre de dimensions
447########################################################################
448
449
450dim_full=$dim
451dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
452set $dim
453dimc=$#
454echo calcul de la dimension
455echo dim $dim
456echo dimc $dimc
457
458########################################################################
459# Gestion des dimensions du modele.
460# on cree ou remplace le fichier des dimensions
461########################################################################
462
463cd $LIBFGCM/grid
464if [[ -f dimensions.h ]]
465then
466  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
467  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
468  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
469  echo  vous pouvez continuer en repondant oui.
470  echo "Voulez-vous vraiment continuer?"
471  echo ""
472  echo "WARNING: you are probably already compiling the model somewhere else."
473  echo "Wait until the first compilation is finished before launching this one."
474  echo "If you are sure that you are not compiling elsewhere, just answer "
475  echo "yes (or 'oui') to the question below to proceed."
476  echo "Do you wish to continue?"
477  read reponse
478  if [[ $reponse == "oui" || $reponse == "yes" ]]
479  then
480    \rm -f $LIBFGCM/grid/dimensions.h
481  else
482    exit
483  fi
484fi
485
486cd $LIBFGCM/grid/dimension
487./makdim $dim
488if (($? != 0))
489then
490    exit 1
491fi
492
493cat $LIBFGCM/grid/dimensions.h
494cd $LMDGCM
495
496########################################################################
497# Differentes dynamiques (3d, 2d, 1d)
498########################################################################
499
500if (( $dimc == 3 )) ; then
501   src_dirs="$src_dirs $filtre dyn3d_common dyn3d${FLAG_PARA}"
502   if [[ $physique != "nophys" ]] ; then
503     src_dirs="$src_dirs dynlmdz_phy${physique}"
504     libdyn_phy="-ldynlmdz_phy${physique}"
505     LIBDYN_PHYS='$(LIBO)/libdynlmdz_phy'"${physique}"'.a'
506     INCLUDE="$INCLUDE "'-I$(LIBF)/dynlmdz_phy'"${physique}"
507   fi
508   cd $LIBFGCM/grid
509   \rm fxyprim.h
510   cp -p fxy_${grille}.h fxyprim.h
511   filtre="FILTRE=$filtre"
512   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
513elif (( $dimc == 2 )) ; then
514   src_dirs="$src_dirs dyn2d"
515   filtre="FILTRE= L_FILTRE= "
516   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
517elif (( $dimc == 1 )) ; then
518   #src_dirs="$src_dirs dyn3d dyn3d_common filtrez"
519   src_dirs="$src_dirs phy${physique}/dyn1d"
520   CPP_KEY="$CPP_KEY CPP_1D"
521   filtre="L_DYN= DYN= FILTRE= L_FILTRE= "
522   #INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
523   INCLUDE="$INCLUDE "' -I$(LIBF)/phy'"$physique"'/dyn1d'
524else
525   echo Dimension dimc=$dimc pas prevu ; exit
526fi
527
528cd $LMDGCM
529
530########################################################################
531# library directory name:
532########################################################################
533
534nomlib=`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'`
535echo "Path to library: "$nomlib
536
537########################################################################
538#  Cleanup for a full recompilation, if requested
539########################################################################
540
541if [[ $full == "full" ]]
542then
543# remove makefile and librairies
544  echo "-full option: recompiling from scratch"
545  \rm -f makefile
546  \rm -rf "${LIBOGCM}/${nomlib}"
547fi
548
549########################################################################
550#  Avant de lancer le make, on recree le makefile si necessaire
551########################################################################
552########################################################################
553# c'est a dire dans 3 cas:
554# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
555#    derniere creation du makefile
556# 2. si le fichier contenant cette liste "liste_des_sources"
557#    n'existe pas.
558# 3. Si le makefile n'existe pas.
559########################################################################
560cd $LMDGCM
561
562find libf -name '*.[Fh]' -print | sort > tmp77
563#find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
564find libf -name '*.F90' -print | sort > tmp90
565
566if [[ -r .makelmdz ]]
567then
568old_lmdz_configuration=$(cat .makelmdz )
569else
570old_lmdz_configuration=""
571fi
572lmdz_configuration="$src_dirs"
573if [[ "$lmdz_configuration" != "$old_lmdz_configuration" ]]
574then
575  configuration_change="true"
576else
577  configuration_change="false"
578fi
579
580if [[ $configuration_change == "true" || ! ( -r makefile ) || ! ( -r liste_des_sources_f90 ) || ! ( -r liste_des_sources_f77 ) || ` diff tmp77 liste_des_sources_f77 | wc -w ` -ne 0 || ` diff tmp90 liste_des_sources_f90 | wc -w ` -ne 0 ]]
581then
582  echo "les fichiers suivants ont ete crees ou detruits"
583  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
584  diff liste_des_sources_f77 tmp77
585  diff liste_des_sources_f90 tmp90
586  \cp -f tmp77 liste_des_sources_f77
587  \cp -f tmp90 liste_des_sources_f90
588  echo "Recreating the makefile"
589  echo "src_dirs: $src_dirs"
590  ./create_make_gcm $src_dirs > tmp
591  \mv -f tmp makefile
592  echo "New makefile created"
593fi
594
595#Create a .makelmdz file containing main compilation option for later comparisons
596echo "$lmdz_configuration" > .makelmdz
597
598#################################################################
599# Preparation de l'execution de la comande make
600#################################################################
601
602source_code=${code}.F
603dirmain=dyn${dimc}d${FLAG_PARA}
604if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
605then
606  source_code=${code}.F90
607elif [[ -r $LMDGCM/libf/phy$physique/${code}.F90 ]] ; then
608  dirmain=phy$physique
609  source_code=${code}.F90
610elif [[ -r $LMDGCM/libf/dynlmdz_phy$physique/${code}.F90 ]] ; then
611  dirmain=dynlmdz_phy${physique}
612  source_code=${code}.F90
613elif [[ -r $LMDGCM/libf/phy$physique/dyn1d/${code}.F90 ]] ; then
614  dirmain=phy$physique/dyn1d
615  source_code=${code}.F90
616fi
617
618if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
619then
620  mkdir ${LIBOGCM}/${nomlib}
621  # check we indeed managed to create the directory
622  if [[ ! $? ]]
623  then
624    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
625    exit
626  fi
627fi
628
629# where module files are created
630mod_loc_dir=$localdir
631
632if [[ "$physique" != "nophys" ]]
633then
634  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
635fi
636INCLUDE="$INCLUDE"' -I'${LIBOGCM}/${nomlib}
637
638# ranlib utility (check it exists or else default to ls)
639if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
640then
641  ranlib="ranlib"
642else
643  ranlib="ls"
644fi
645
646# add CPP keys to COMPIL_FLAGS
647# (but first add -D before all CPP_KEY items)
648cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
649# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
650if [[ "${fcompiler:0:3}" == "xlf" ]]
651then
652cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
653fi
654COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
655
656#################################################################
657# Execution du make
658#################################################################
659echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
660OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
661OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
662OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
663OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
664INCLUDE="$INCLUDE" \
665$filtre \
666LIBO=${LIBOGCM}/${nomlib} \
667"PHYS=$physique" \
668LIBPHY=${LIBPHY} \
669LIBDYN_PHYS=${LIBDYN_PHYS} \
670DIM=$dimc \
671FLAG_PARA=$FLAG_PARA \
672L_PHY="$lib_phy" \
673L_DYN_PHY="$libdyn_phy" \
674L_ADJNT=$adjnt \
675L_COSP="$lcosp" \
676L_CHIMIE="$libchimie" \
677LOCAL_DIR="$localdir"  \
678F77="$fcompiler" \
679F90="$fcompiler" \
680OPLINK="$LIB" \
681LINK="$linker" \
682GCM="$LMDGCM" \
683MOD_LOC_DIR=$mod_loc_dir \
684MOD_SUFFIX="mod" \
685AR=$arcommand \
686DIRMAIN=$dirmain \
687SOURCE=$source_code \
688PROG=$code
689
690$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
691OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
692OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
693OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
694OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
695INCLUDE="$INCLUDE" \
696$filtre \
697LIBO=${LIBOGCM}/${nomlib} \
698"PHYS=$physique" \
699LIBPHY=${LIBPHY} \
700LIBDYN_PHYS=${LIBDYN_PHYS} \
701DIM=$dimc \
702FLAG_PARA=$FLAG_PARA \
703L_PHY="$lib_phy" \
704L_DYN_PHY="$libdyn_phy" \
705L_ADJNT=$adjnt \
706L_COSP="$lcosp" \
707L_CHIMIE="$libchimie" \
708LOCAL_DIR="$localdir"  \
709F77="$fcompiler" \
710F90="$fcompiler" \
711OPLINK="$LIB" \
712LINK="$linker" \
713GCM="$LMDGCM" \
714MOD_LOC_DIR=$mod_loc_dir \
715MOD_SUFFIX="mod" \
716AR=$arcommand \
717DIRMAIN=$dirmain \
718SOURCE=$source_code \
719PROG=$code
720
721
722if [[ -r $LIBFGCM/grid/dimensions.h ]]
723then
724  # Cleanup: remove dimension.h file
725  \rm -f $LIBFGCM/grid/dimensions.h
726fi
Note: See TracBrowser for help on using the repository browser.