source: LMDZ6/trunk/makelmdz

Last change on this file was 5288, checked in by abarral, 8 weeks ago

Remove grid argument from makegcm makelmdz makelmdz_fcm since it acts on a file that isn't included anywhere

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