source: trunk/LMDZ.COMMON/makelmdz @ 1243

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

Common dynamics: Updates and modifications to enable running Mars physics with

LMDZ.COMMON dynamics:

  • For compilation: adapted makelmdz, create_make_gcm and makelmdz_fcm, bld.cfg to compile aeronomy routines in "aerono$physique" if it exists, and added "-P -traditional" preprocessing flags in "arch-linux-ifort*"
  • Added function "cbrt.F" (cubic root) in 'bibio'
  • Adapted the reading/writing of dynamics (re)start.nc files for Mars. The main issue is that different information (on time, reference and current) is stored and used differently, hence a few if (planet_type =="mars") here and there. Moreover in the martian case there is the possibility to store fields over multiple times. Some Mars-specific variables (ecritphy,ecritstart,timestart) added in control_mod.F and (hour_ini) in temps.h

EM

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