source: LMDZ5/branches/AI-cosp/makelmdz @ 3575

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

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