source: LMDZ6/branches/Ocean_skin/makelmdz @ 3601

Last change on this file since 3601 was 3359, checked in by idelkadi, 6 years ago

Implementation de la version COSPv2 dans LMDZ.

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