source: LMDZ6/trunk/makelmdz @ 6059

Last change on this file since 6059 was 6058, checked in by fhourdin, 4 weeks ago

Travail pour la replayisation de la convection

Reunion de tous les anciens common devenus modules, dans lmdz_cv_ini.
Déplacement de presque toutes les routines d'initialisation dans lmdz_cv_ini.
Encapsulage de certains sous-programmes dans des modules.
Suppression de programmes inutilisés (cv3_crit et cv3_incp)
Reste :

  • à sortir des routines d'initialisation "_pre" de cv_driver et

cva_driver

  • à passer le variables argunement en intent(in/out/inout).

La convergence numérique a été testée pour
iflag_con=3/30/4
en 3D parallèle.
La compilation de la version isotopique fonctionne.

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