source: trunk/LMDZ.COMMON/makelmdz @ 1019

Last change on this file since 1019 was 1019, checked in by emillour, 11 years ago

Common dynamics; keep up with updates (seq and ) in LMDZ5 (up tio rev 1845):

  • General stuff:
  • makelmdz_fcm: add options -j # (compile using # threads) and -full, and to keep up

with Earth model, possibility to compile with various versions of orchidee

  • bld.cfg: adaptations to enable compiling using multiple threads
  • build_gcm: adaptations to enable compiling using multiple threads
  • makelmdz: keep up with Earth model: possibility to compile with various versions of orchidee + cosmetic changes + library directory name change
  • bibio:
  • wxios.F90 : Added for possible future use of XIOS library
  • filtrez:
  • mkl_dft_type.f90 & mkl_dfti.f90 : MKL (for MKL FFT) interface definitions
  • filtreg_mod : limit use of FFT to parallel mode
  • mod_filtre_fft.F90 & mod_filtre_fft_lov.F90 : swich to use parallel_lmdz
  • dyn3d:
  • abort_gcm.F : add things for xios
  • advtrac.F90 : minor change in CFL outputs
  • ce0l.F90 : indicesol.h is now module indice_sol_mod
  • comvert.h : cosmetic change on comments
  • gcm.F : add xios and use module indice_sol_mod (for INCA)
  • inigeom.F : move two computations outside loop
  • dyn3dpar:
  • parallel.F90 => parallel_lmdz.F90 : and change all the "use parallel" into "use parallel_lmdz" in all files in dyn3dpar
  • comvert.h : cosmetic change on comments
  • gcm.F : add xios and use module indice_sol_mod (for INCA)
  • leapfrog_p.F : add xios + correction for times in Newtonian case
  • ce0l.F90 : indicesol.h is now module indice_sol_mod
  • inigeom.F : move two computations outside loop

EM

  • Property svn:executable set to *
File size: 21.6 KB
Line 
1#!/bin/bash
2#
3# $Id $
4#
5#
6########################################################################
7# for debug, uncomment line below
8#set -xv
9########################################################################
10# options par defaut pour la commande make
11########################################################################
12dim="96x72x19"
13physique=lmd
14code=gcm
15filtre=filtrez
16grille=reg
17couple=false
18veget=false
19chimie=false
20parallel=none
21paramem="par"
22compil_mod=prod
23io=ioipsl
24LIBPREFIX=""
25fcm_path=none
26cosp=false
27bands=""
28scatterers=""
29dyn=""
30
31# guess a default 'arch'
32arch="local" # start with assuming we're on a local machine with local arch file
33## try to recognise machine and infer arch from it
34machine=`hostname`
35if [[ "$machine" == "brodie" ]]
36then
37  arch="SX8_BRODIE"
38fi
39if [[ "${machine:0:6}" == "vargas" ]]
40then
41  arch="PW6_VARGAS"
42fi
43if [[ "${machine:0:6}" == "ada338" ]]
44then
45  arch="PW6_VARGAS"
46fi
47if [[ "${machine:0:6}" == "ciclad" ]]
48then
49  arch="AMD64_CICLAD"
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
81COSP_PATH=$LMDGCM/.void_dir
82
83
84
85localdir=`pwd -P`
86########################################################################
87#  Quelques initialisations de variables du shell.
88########################################################################
89
90CPP_KEY="" 
91INCLUDE='-I$(LIBF)/grid -I$(LIBF)/bibio -I$(LIBF)/filtrez -I. '
92LIB=""
93adjnt=""
94##COMPIL_FFLAGS="%PROD_FFLAGS"
95PARA_FFLAGS=""
96PARA_LD=""
97EXT_SRC=""
98ccompiler=""
99OPTIMC=""
100INCLUDEC=""
101
102########################################################################
103# lecture des options
104########################################################################
105
106while (($# > 0))
107  do
108  case $1 in
109      "-h") cat <<fin
110manuel complet sur http://...
111Usage :
112makeldmz [options] -arch arch exec
113[-h]                       : brief help
114[-d [[IMx]JMx]LM]          : IM, JM, LM are the dimensions in x, y, z (default: $dim)
115[-s nscat]                 : (Generic) Number of radiatively active scatterers
116[-b IRxVIS]                : (Generic) Number of infrared (IR) and visible (VIS) bands for radiative transfer
117[-p PHYS]                  : set of physical parametrizations (in libf/phyPHYS), (default: lmd)
118[-prod / -dev / -debug]    : compilation mode production (default) / developement / debug .
119[-c false/MPI1/MPI2]       : (Earth) coupling with ocean model : MPI1/MPI2/false (default: false)
120[-v false/orchidee2.0/orchidee1.9/true] : version of the vegetation model to include (default: false)
121          false       : no vegetation model
122          orchidee2.0 : compile using ORCHIDEE 2.0 (or more recent version)
123          orchidee1.9 : compile using ORCHIDEE up to the version including OpenMP in ORCHIDEE : tag 1.9-1.9.5(version AR5)-1.9.6
124          true        : (obsolete; for backward compatibility) use ORCHIDEE tag 1.9-1.9.6
125
126[-chimie INCA/false]       : (Earth) with INCA chemistry model or without (default: false)
127[-cosp cosp/false]         : (Earth) add the cosp model (default: false)
128[-parallel none/mpi/omp/mpi_omp] : parallelism (default: none) : mpi, openmp or mixted mpi_openmp
129[-g GRI]                   : grid configuration in dyn3d/GRI_xy.h  (default: reg, inclues a zoom)
130[-io IO]                   : Input/Output library (default: ioipsl)
131[-include INCLUDES]        : extra include path to add
132[-cpp CPP_KEY]             : additional preprocessing definitions
133[-adjnt]                   : adjoint model, not operational ...
134[-mem]                     : reduced memory dynamics (if in parallel mode)
135[-filtre NOMFILTRE]        : use filtre from libf/NOMFILTRE (default: filtrez)
136[-link LINKS]              : additional links with other libraries
137[-fcm_path path]           : path to the fcm tool (default: tools/fcm/bin)
138[-ext_src path]            : path to an additional set of routines to compile with the model
139 -arch arch                : target architecture
140 exec                      : executable to build
141fin
142          exit;;
143      "-d")
144          dim=$2 ; shift ; shift ;;
145     
146      "-p")
147          physique="$2" ; shift ; shift ;;
148
149      "-s")
150          scatterers=$2 ; shift ; shift ;;
151
152      "-b")
153          bands=$2 ; shift ; shift ;;
154
155      "-g")
156          grille="$2" ; shift ; shift ;;
157
158      "-c")
159          couple="$2" ; shift ; shift ;;
160
161      "-prod")
162          compil_mod="prod" ; shift ;;
163
164      "-dev")
165          compil_mod="dev" ; shift ;;
166
167      "-debug")
168          compil_mod="debug" ; shift ;;
169
170      "-io")
171          io="$2" ; shift ; shift ;;
172
173      "-v")
174          veget="$2" ; shift ; shift ;;
175
176      "-chimie")
177          chimie="$2" ; shift ; shift ;;
178
179      "-parallel")
180          parallel="$2" ; shift ; shift ;;
181     
182      "-include")
183          INCLUDE="$INCLUDE -I$2" ; shift ; shift ;;
184
185      "-cpp")
186          CPP_KEY="$CPP_KEY $2" ; shift ; shift ;;
187
188      "-adjnt")
189          echo "not operational ... work to be done here ";exit
190          opt_dep="$opt_dep adjnt" ; adjnt="-ladjnt -ldyn3d "
191          optim="$optim -Dadj" ; shift ;;
192
193      "-cosp")
194          cosp="$2" ; shift ; shift ;;
195     
196      "-mem")
197          paramem="mem" ; shift ;;
198
199      "-filtre")
200          filtre=$2 ; shift ; shift ;;
201
202      "-link")
203          LIB="$LIB $2" ; shift ; shift ;;
204
205      "-fcm_path")
206          fcm_path=$2 ; shift ; shift ;;
207
208      "-ext_src")
209          EXT_SRC=$2 ; shift ; shift ;;
210
211      "-arch")
212          arch=$2 ; shift ; shift ;;
213
214      *)
215          code="$1" ; shift ;;
216  esac
217done
218
219###############################################################
220# lecture des chemins propres à l'architecture de la machine #
221###############################################################
222rm -f .void_file
223echo > .void_file
224rm -rf .void_dir
225mkdir .void_dir
226rm -f arch.path
227if [[ -r arch/arch-${arch}.path ]]
228then
229  ln -s arch/arch-${arch}.path ./arch.path
230  source arch.path
231else
232  echo "Error: missing arch/arch-${arch}.path file !"
233  exit
234fi
235rm -f arch.fcm
236if [[ -r arch/arch-${arch}.fcm ]]
237then
238  ln -s arch/arch-${arch}.fcm arch.fcm
239else
240  echo "Error: missing arch/arch-${arch}.fcm file !"
241  exit
242fi
243########################################################################
244# Definition des clefs CPP, des chemins des includes et modules
245#  et des libraries
246########################################################################
247
248# basic compile flags from arch.fcm file
249archfileline=$( grep -i '^%BASE_FFLAGS' arch.fcm )
250COMPIL_FFLAGS=$( echo ${archfileline##%BASE_FFLAGS} )
251
252# other compile flags, depending on compilation mode
253if [[ "$compil_mod" == "prod" ]]
254then
255## read COMPIL_FFLAGS from arch.fcm file
256  archfileline=$( grep -i '^%PROD_FFLAGS' arch.fcm )
257  archfileopt=$( echo ${archfileline##%PROD_FFLAGS} )
258  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
259elif [[ "$compil_mod" == "dev" ]]
260then
261## read %DEV_FFLAGS from arch.fcm file
262  archfileline=$( grep -i '^%DEV_FFLAGS' arch.fcm )
263  archfileopt=$( echo ${archfileline##%DEV_FFLAGS} )
264  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
265elif [[ "$compil_mod" == "debug" ]]
266then
267## read %DEBUG_FFLAGS from arch.fcm file
268  archfileline=$( grep -i '^%DEBUG_FFLAGS' arch.fcm )
269  archfileopt=$( echo ${archfileline##%DEBUG_FFLAGS} )
270  COMPIL_FFLAGS="${COMPIL_FFLAGS} ${archfileopt}"
271fi
272
273# add CPP_KEY defined in arch.fcm file
274archfileline=$( grep -i '^%FPP_DEF' arch.fcm )
275archfileopt=$( echo ${archfileline##%FPP_DEF} )
276CPP_KEY="$CPP_KEY ${archfileopt}"
277
278# get compiler name from arch.fcm file
279archfileline=$( grep -i '^%COMPILER' arch.fcm )
280fcompiler=$( echo ${archfileline##%COMPILER} )
281
282# get linker name from arch.fcm file
283archfileline=$( grep -i '^%LINK' arch.fcm )
284linker=$( echo ${archfileline##%LINK} )
285
286# get ar command from arch.fcm file
287archfileline=$( grep -i '^%AR' arch.fcm )
288arcommand=$( echo ${archfileline##%AR} )
289
290# get make utility from arch.fcm file
291archfileline=$( grep -i '^%MAKE' arch.fcm )
292makecommand=$( echo ${archfileline##%MAKE} )
293
294# get basic libraries to link with arch.fcm file
295archfileline=$( grep -i '^%BASE_LD' arch.fcm )
296archfileopt=$( echo ${archfileline##%BASE_LD} )
297LIB="$LIB  ${archfileopt}"
298
299#NB some -I... might be located in the %FPP_FLAGS section of the arch file
300archfileline=$( grep -i '^%FPP_FLAGS' arch.fcm )
301archfileopt=$( echo "-I"${archfileline##*-I} ) ## to be improved...
302INCLUDE="$INCLUDE ${archfileopt}"
303
304if [[ "$physique" != "nophys" ]]
305then
306   CPP_KEY="$CPP_KEY CPP_PHYS"
307fi
308
309if [[ "$physique" == "lmd" ]]
310then
311   #Default planet type is Earth
312   CPP_KEY="$CPP_KEY CPP_EARTH"
313fi
314
315######### CAS PARTICULIER CHIMIE TITAN
316if [[ "$physique" == "titan" ]]
317then
318   INCLUDE="$INCLUDE"' -I$(LIBF)/chim'"$physique"
319   LIB="$LIB -l${LIBPREFIX}chim$physique"
320   opt_dep="$opt_dep chim$physique"
321# get C compiler name and optim from arch.fcm file
322   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
323   ccompiler=$( echo ${archfileline##%C_COMPILER} )
324   archfileline=$( grep -i '^%C_OPTIM' arch.fcm )
325   coptim=$( echo ${archfileline##%C_OPTIM} )
326   OPTIMC="$OPTIMC  ${coptim}"
327   INCLUDEC='-I$(LIBF)/grid -I.'
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"
426fi
427
428if [[ "$cosp" == "true" ]]
429then
430   CPP_KEY="$CPP_KEY CPP_COSP"
431   COSP_PATH="$LIBFGCM/cosp"
432#   LIB="${LIB} -l${LIBPREFIX}cosp"
433   opt_dep="$opt_dep cosp"
434   lcosp="-l${LIBPREFIX}cosp"
435   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
436fi
437
438
439INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
440LIB="$LIB ${NETCDF_LIBDIR}"
441
442########################################################################
443# calcul du nombre de dimensions
444########################################################################
445
446
447dim_full=$dim
448dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
449set $dim
450dimc=$#
451echo calcul de la dimension
452echo dim $dim
453echo dimc $dimc
454
455
456########################################################################
457# Gestion des dimensions du modele.
458# on cree ou remplace le fichier des dimensions
459########################################################################
460
461cd $LIBFGCM/grid
462if [[ -f dimensions.h ]]
463then
464  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
465  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
466  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
467  echo  vous pouvez continuer en repondant oui.
468  echo "Voulez-vous vraiment continuer?"
469  echo ""
470  echo "WARNING: you are probably already compiling the model somewhere else."
471  echo "Wait until the first compilation is finished before launching this one."
472  echo "If you are sure that you are not compiling elsewhere, just answer "
473  echo "yes (or 'oui') to the question below to proceed."
474  echo "Do you wish to continue?"
475  read reponse
476  if [[ $reponse == "oui" || $reponse == "yes" ]]
477  then
478    \rm -f $LIBFGCM/grid/dimensions.h
479  else
480    exit
481  fi
482fi
483
484
485cd $LIBFGCM/grid/dimension
486./makdim $dim
487cat $LIBFGCM/grid/dimensions.h
488cd $LMDGCM
489
490if [[ "$bands" != "" ]]
491then
492  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
493  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
494  cd $LIBFGCM/phy$physique/bands
495  ./makbands $bands
496  cat $LIBFGCM/phy$physique/bands.h
497  cd $LMDGCM
498fi
499
500if [[ "$scatterers" != "" ]]
501then
502  # Generic model, recreate scatterers.h
503  cd $LIBFGCM/phy$physique/scatterers
504  ./make_scatterers $scatterers
505  cat $LIBFGCM/phy$physique/scatterers.h
506  cd $LMDGCM
507fi
508
509
510########################################################################
511# Differentes dynamiques (3d, 2d, 1d)
512########################################################################
513
514dimension=`echo $dim | wc -w`
515echo dimension $dimension
516
517if (( $dimension == 3 ))
518then
519  cd $LIBFGCM/grid
520  \rm fxyprim.h
521  cp -p fxy_${grille}.h fxyprim.h
522#else
523#  echo "Probleme dans les dimensions de la dynamique !!"
524#  echo "Non reactive pour l'instant !!!"
525fi
526if (( $dimension == 1 ))
527then
528  echo pas de dynamique
529  dyn="DYN= L_DYN=-ldyn3d "
530fi
531
532######################################################################
533# Gestion du filtre qui n'existe qu'en 3d.
534######################################################################
535
536if (( `expr $dimc \> 2` == 1 ))
537then
538   filtre="FILTRE=$filtre"
539else
540   filtre="FILTRE= L_FILTRE= "
541fi
542echo MACRO FILTRE $filtre
543
544echo $dimc
545
546######################################################################
547# Creation du suffixe de la configuration
548######################################################################
549
550
551SUFF_NAME=_${dim_full}
552SUFF_NAME=${SUFF_NAME}_phy${physique}
553
554if [[ "$parallel" != "none" ]]
555then
556  SUFF_NAME=${SUFF_NAME}_para
557  DYN=dyn${dimc}d${paramem}
558  if [[ "$paramem" == "mem" ]]
559  then
560   SUFF_NAME=${SUFF_NAME}_${paramem}
561  fi
562else
563  SUFF_NAME=${SUFF_NAME}_seq
564  DYN=dyn${dimc}d
565fi
566
567if [[ $veget != "false" ]]
568then
569  SUFF_NAME=${SUFF_NAME}_orch
570fi
571
572if [[ $couple != "false" ]]
573then
574  SUFF_NAME=${SUFF_NAME}_couple
575fi
576
577if [[ $chimie == "INCA" ]]
578then
579  SUFF_NAME=${SUFF_NAME}_inca
580fi
581
582cd $LMDGCM
583
584
585########################################################################
586#  Avant de lancer le make, on recree le makefile si necessaire
587########################################################################
588########################################################################
589# c'est a dire dans 3 cas:
590# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
591#    derniere creation du makefile
592# 2. si le fichier contenant cette liste "liste_des_sources"
593#    n'existe pas.
594# 3. Si le makefile n'existe pas.
595########################################################################
596cd $LMDGCM
597find libf -name '*.[Fh]' -print > tmp77
598find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print > tmp90
599find libf -name '*.[Fh90]' -print >> tmp90
600######### CAS PARTICULIER CHIMIE TITAN
601if [[ "$physique" == "titan" ]]
602then 
603  find libf -name '*.[ch]' -print > tmpC
604fi
605#########
606
607if [[ ! ( -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 ]]
608then
609  echo "les fichiers suivants ont ete crees ou detruits"
610  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
611  diff liste_des_sources_f77 tmp77
612  diff liste_des_sources_f90 tmp90
613  \cp -f tmp77 liste_des_sources_f77
614  \cp -f tmp90 liste_des_sources_f90
615######### CAS PARTICULIER CHIMIE TITAN
616  if [[ "$physique" == "titan" ]]
617  then 
618  diff liste_des_sources_C tmpC
619  \cp -f tmpC liste_des_sources_C
620  fi
621#########
622  echo "on recree le makefile"
623  ./create_make_gcm > tmp
624  \mv -f tmp makefile
625  echo "Nouveau makefile cree"
626######### CAS PARTICULIER CHIMIE TITAN
627else if [[ "$physique" == "titan" ]]
628 then
629   if [[ ! ( -r liste_des_sources_C ) || ` diff tmpC liste_des_sources_C | wc -w ` -ne 0 ]]
630   then
631     diff liste_des_sources_C tmpC
632     \cp -f tmpC liste_des_sources_C
633     echo "on recree le makefile"
634     ./create_make_gcm > tmp
635     \mv -f tmp makefile
636     echo "Nouveau makefile cree"
637   fi
638 fi
639#########
640fi
641
642#################################################################
643# Preparation de l'execution de la commande make
644#################################################################
645
646# find code suffix and directory where code is located
647if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
648then
649  source_code=${code}.F
650  code_dir=dyn${dimc}d${FLAG_PARA}
651else
652  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
653  then
654    source_code=${code}.F90
655    code_dir=dyn${dimc}d${FLAG_PARA}
656  else
657    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
658    then
659      source_code=${code}.F
660      code_dir=phy${physique}
661    else
662      # last possibility:
663      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
664      then
665        source_code=${code}.F90
666        code_dir=phy${physique}
667      else
668        echo "Error: cannot find ${code}.F[90]"
669        echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
670        exit
671      fi
672    fi
673  fi
674fi
675
676# library directory name:
677nomlib=`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'`
678echo $nomlib
679
680if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
681then
682  mkdir ${LIBOGCM}/${nomlib}
683  # check we indeed managed to create the directory
684  if [[ ! $? ]]
685  then
686    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
687    exit
688  fi
689fi
690
691# where module files are created
692mod_loc_dir=$localdir
693
694if [[ "$physique" != "nophys" ]]
695then
696  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
697  phys="PHYS=$physique"
698else
699  # trick to avoid having a physics-related library in the makefile
700  phys="L_PHY= LIBPHY="
701fi
702if (( $dimension == 1 ))
703then
704 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
705else
706 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
707fi
708
709# ranlib utility (check it exists or else default to ls)
710if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
711then
712  ranlib="ranlib"
713else
714  ranlib="ls"
715fi
716
717# add CPP keys to COMPIL_FLAGS
718# (but first add -D before all CPP_KEY items)
719cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
720# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
721if [[ "${fcompiler:0:3}" == "xlf" ]]
722then
723cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
724fi
725COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
726
727#################################################################
728# Execution du make
729#################################################################
730echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
731OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
732OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
733OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
734OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
735OPTIMC="$optimc" \
736INCLUDE="$INCLUDE" \
737INCLUDEC="$includec" \
738$filtre \
739$dyn \
740LIBO=${LIBOGCM}/${nomlib} \
741$phys \
742DIM=$dimc \
743FLAG_PARA=$FLAG_PARA \
744L_ADJNT=$adjnt \
745L_COSP="$lcosp" \
746L_CHIMIE="$libchimie" \
747LOCAL_DIR="$localdir"  \
748F77="$fcompiler" \
749F90="$fcompiler" \
750CCC="$ccompiler" \
751OPLINK="$LIB" \
752LINK="$linker" \
753GCM="$LMDGCM" \
754MOD_LOC_DIR=$mod_loc_dir \
755MOD_SUFFIX="mod" \
756AR=$arcommand \
757DIRMAIN=$code_dir \
758SOURCE=$source_code \
759PROG=$code
760
761$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
762OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
763OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
764OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
765OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
766OPTIMC="$optimc" \
767INCLUDE="$INCLUDE" \
768INCLUDEC="$includec" \
769$filtre \
770$dyn \
771LIBO=${LIBOGCM}/${nomlib} \
772$phys \
773DIM=$dimc \
774FLAG_PARA=$FLAG_PARA \
775L_ADJNT="$adjnt" \
776L_COSP="$lcosp" \
777L_CHIMIE="$libchimie" \
778LOCAL_DIR="$localdir"  \
779F77="$fcompiler" \
780F90="$fcompiler" \
781CCC="$ccompiler" \
782OPLINK="$LIB" \
783LINK="$linker" \
784GCM="$LMDGCM" \
785MOD_LOC_DIR=$mod_loc_dir \
786MOD_SUFFIX="mod" \
787AR=$arcommand \
788DIRMAIN=$code_dir \
789SOURCE=$source_code \
790PROG=$code
791
792if [[ -r $LIBFGCM/grid/dimensions.h ]]
793then
794  # Cleanup: remove dimension.h file
795  \rm -f $LIBFGCM/grid/dimensions.h
796fi
Note: See TracBrowser for help on using the repository browser.