source: trunk/LMDZ.COMMON/makelmdz @ 1610

Last change on this file since 1610 was 1540, checked in by emillour, 9 years ago

All GCMS: Further adaptations to keep up with changes in LMDZ5 concerning
physics/dynamics separation:

  • changed directory "dynlonlat_phylonlat" to "dynphy_lonlat" and adapted makelmdz and makelmdz_fcm scripts accordingly.
  • added option "-libphy" to makelmdz_fcm to just build a physics library, without any main program (not operational yet; further cleanup in the physics required).
  • moved "iniprint.h" from dyn3d_common to misc (NB: it is used in both physics and dynamics; this should be cleaned up further...)

EM

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