source: trunk/LMDZ.COMMON/makelmdz @ 1391

Last change on this file since 1391 was 1391, checked in by emillour, 10 years ago

Common dynamical core:
Updates in the dynamics to keeup up with updates in LMDZ5
(up to LMDZ5 trunk rev 2200):

  • compilation:
  • create_make_gcm : added processing of .f & .f90 files (not just .F and .F90)
  • makelmdz: add "mix" option for -io (ouptut with both IOIPSL and XIOS)
  • makelmdz_fcm: add "mix" option for -io
  • filtrez:
  • acc.F and eigen.F : add "implicit none" and variable declarations
  • bibio:
  • handle_err_m.F90: replace "stop" with call to abort_gcm()
  • i1mach.F, j4save.F: add "implicit none" and variable declarations
  • xercnt.F, xermsg.F, xerprn.F, xersve.F, xgetua.F: add "implicit none" and variable declarations
  • dyn3d_common:
  • disvert.F90 : added comments on meaning of "pa" variable
  • grid_atob.F : better control on level of default ouputs
  • infotrac.F90: update Earth-specific stuff (nqo water tracers)
  • interpre.F: correction on the size of input array w
  • juldate.F, massbar.F, ppm3d.F, ran1.F: add "implicit none" and variable declarations
  • sortvarc.F: code cleanup
  • iniacademic.F90: cleanup and extra sanity check.
  • dyn3d:
  • abort_gcm.F: additions for XIOS
  • conf_gcm.F90: transformed to free form from conf_gcm.F
  • gcm.F: added test to check that iphysiq is a multiple of iperiod
  • getparam.F90, guidz_mod.F: update from LMDZ5
  • integrd.F: replace stop with call_abort()
  • dyn3dpar:
  • abort_gcm.F: minor cleanup
  • gcm.F: added test to check that iphysiq is a multiple of iperiod
  • getparam.F90, guide_p_mod.F90: update from LMDZ5
  • integrd_p.F: abort with call_abort when there is negative surface pressure
  • leapfrog_p.F: add INCA specific stuff to keep up with current LMDZ5
  • conf_gcm.F90: transformed to free form from conf_gcm.F

EM

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