source: codes/icosagcm/branches/SATURN_DYNAMICO/LMDZ.COMMON/makelmdz @ 334

Last change on this file since 334 was 220, checked in by ymipsl, 10 years ago

Creating temporary dynamico/lmdz/saturn branche

YM

  • 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
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 IO]                   : 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 à 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 == xios ]]
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"
432fi
433
434if [[ "$cosp" == "true" ]]
435then
436   CPP_KEY="$CPP_KEY CPP_COSP"
437   COSP_PATH="$LIBFGCM/cosp"
438#   LIB="${LIB} -l${LIBPREFIX}cosp"
439   opt_dep="$opt_dep cosp"
440   lcosp="-l${LIBPREFIX}cosp"
441   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
442fi
443
444if [[ "$sisvat" == "true" ]]
445then
446   CPP_KEY="$CPP_KEY CPP_SISVAT"
447fi
448
449if [[ "$rrtm" == "true" ]]
450then
451   CPP_KEY="$CPP_KEY CPP_RRTM"
452fi
453
454
455INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
456LIB="$LIB ${NETCDF_LIBDIR}"
457
458########################################################################
459# calcul du nombre de dimensions
460########################################################################
461
462
463dim_full=$dim
464dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
465set $dim
466dimc=$#
467echo calcul de la dimension
468echo dim $dim
469echo dimc $dimc
470
471
472########################################################################
473# Gestion des dimensions du modele.
474# on cree ou remplace le fichier des dimensions
475########################################################################
476
477cd $LIBFGCM/grid
478if [[ -f dimensions.h ]]
479then
480  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
481  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
482  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
483  echo  vous pouvez continuer en repondant oui.
484  echo "Voulez-vous vraiment continuer?"
485  echo ""
486  echo "WARNING: you are probably already compiling the model somewhere else."
487  echo "Wait until the first compilation is finished before launching this one."
488  echo "If you are sure that you are not compiling elsewhere, just answer "
489  echo "yes (or 'oui') to the question below to proceed."
490  echo "Do you wish to continue?"
491  read reponse
492  if [[ $reponse == "oui" || $reponse == "yes" ]]
493  then
494    \rm -f $LIBFGCM/grid/dimensions.h
495  else
496    exit
497  fi
498fi
499
500
501cd $LIBFGCM/grid/dimension
502./makdim $dim
503cat $LIBFGCM/grid/dimensions.h
504cd $LMDGCM
505
506if [[ "$bands" != "" ]]
507then
508  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
509  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
510  cd $LIBFGCM/phy$physique/bands
511  ./makbands $bands
512  cat $LIBFGCM/phy$physique/bands.h
513  cd $LMDGCM
514fi
515
516if [[ "$scatterers" != "" ]]
517then
518  # Generic model, recreate scatterers.h
519  cd $LIBFGCM/phy$physique/scatterers
520  ./make_scatterers $scatterers
521  cat $LIBFGCM/phy$physique/scatterers.h
522  cd $LMDGCM
523fi
524
525
526########################################################################
527# Differentes dynamiques (3d, 2d, 1d)
528########################################################################
529
530dimension=`echo $dim | wc -w`
531echo dimension $dimension
532
533if (( $dimension == 3 )) ; then
534  cd $LIBFGCM/grid
535  \rm fxyprim.h
536  cp -p fxy_${grille}.h fxyprim.h
537  filtre="FILTRE=$filtre"
538  INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d${FLAG_PARA} -I$(LIBF)/dyn3d_common '
539elif (( $dimension == 2 )) ; then
540   filtre="FILTRE= L_FILTRE= "
541   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn2d'
542elif (( $dimension == 1 )) ; then
543   echo pas de dynamique
544   CPP_KEY="$CPP_KEY CPP_1D"
545   filtre="L_DYN= DYN= FILTRE= L_FILTRE= DIRMAIN=phy$physique "
546   INCLUDE="$INCLUDE "'-I$(LIBF)/dyn3d -I$(LIBF)/dyn3d_common ' # Pas tres propre
547else
548   echo Dimension dimc=$dimc pas prevu ; exit
549fi
550
551cd $LMDGCM
552
553#cleanup for a full recompilation, if requested
554if [[ $full == "full" ]]
555then
556# remove makefile and $libo/*
557  cd $LMDGCM
558  \rm -f makefile
559  \rm -rf $LIBOGCM/*
560fi
561
562########################################################################
563#  Avant de lancer le make, on recree le makefile si necessaire
564########################################################################
565########################################################################
566# c'est a dire dans 3 cas:
567# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
568#    derniere creation du makefile
569# 2. si le fichier contenant cette liste "liste_des_sources"
570#    n'existe pas.
571# 3. Si le makefile n'existe pas.
572########################################################################
573cd $LMDGCM
574find libf -name '*.[Fh]' -print | sort > tmp77
575find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print | sort > tmp90
576find libf -name '*.F90' -print | sort >> tmp90
577######### CAS PARTICULIER CHIMIE TITAN
578if [[ "$physique" == "titan" ]]
579then
580  find libf -name '*.[ch]' -print | sort > tmpC
581fi
582#########
583
584if [[ ! ( -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 ]]
585then
586  echo "les fichiers suivants ont ete crees ou detruits"
587  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
588  diff liste_des_sources_f77 tmp77
589  diff liste_des_sources_f90 tmp90
590  \cp -f tmp77 liste_des_sources_f77
591  \cp -f tmp90 liste_des_sources_f90
592######### CAS PARTICULIER CHIMIE TITAN
593  if [[ "$physique" == "titan" ]]
594  then
595  diff liste_des_sources_C tmpC
596  \cp -f tmpC liste_des_sources_C
597  fi
598#########
599  echo "on recree le makefile"
600  ./create_make_gcm > tmp
601  \mv -f tmp makefile
602  echo "Nouveau makefile cree"
603######### CAS PARTICULIER CHIMIE TITAN
604else if [[ "$physique" == "titan" ]]
605 then
606   if [[ ! ( -r liste_des_sources_C ) || ` diff tmpC liste_des_sources_C | wc -w ` -ne 0 ]]
607   then
608     diff liste_des_sources_C tmpC
609     \cp -f tmpC liste_des_sources_C
610     echo "on recree le makefile"
611     ./create_make_gcm > tmp
612     \mv -f tmp makefile
613     echo "Nouveau makefile cree"
614   fi
615 fi
616#########
617fi
618
619#################################################################
620# Preparation de l'execution de la commande make
621#################################################################
622
623# find code suffix and directory where code is located
624if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
625then
626  source_code=${code}.F
627  code_dir=dyn${dimc}d${FLAG_PARA}
628else
629  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
630  then
631    source_code=${code}.F90
632    code_dir=dyn${dimc}d${FLAG_PARA}
633  else
634    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
635    then
636      source_code=${code}.F
637      code_dir=phy${physique}
638    else
639      # last possibility:
640      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
641      then
642        source_code=${code}.F90
643        code_dir=phy${physique}
644      else
645        echo "Error: cannot find ${code}.F[90]"
646        echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
647        exit
648      fi
649    fi
650  fi
651fi
652
653# library directory name:
654nomlib=`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'`
655echo $nomlib
656
657if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
658then
659  mkdir ${LIBOGCM}/${nomlib}
660  # check we indeed managed to create the directory
661  if [[ ! $? ]]
662  then
663    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
664    exit
665  fi
666fi
667
668# where module files are created
669mod_loc_dir=$localdir
670
671if [[ "$physique" != "nophys" ]]
672then
673  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
674  phys="PHYS=$physique"
675else
676  # trick to avoid having a physics-related library in the makefile
677  phys="L_PHY= LIBPHY="
678fi
679if (( $dimension == 1 ))
680then
681 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
682else
683 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
684fi
685
686# ranlib utility (check it exists or else default to ls)
687if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
688then
689  ranlib="ranlib"
690else
691  ranlib="ls"
692fi
693
694# add CPP keys to COMPIL_FLAGS
695# (but first add -D before all CPP_KEY items)
696cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
697# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
698if [[ "${fcompiler:0:3}" == "xlf" ]]
699then
700cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
701fi
702COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
703
704#################################################################
705# Execution du make
706#################################################################
707echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
708OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
709OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
710OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
711OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
712OPTIMC="$OPTIMC" \
713INCLUDE="$INCLUDE" \
714INCLUDEC="$includec" \
715$filtre \
716LIBO=${LIBOGCM}/${nomlib} \
717$phys \
718DIM=$dimc \
719FLAG_PARA=$FLAG_PARA \
720L_ADJNT=$adjnt \
721L_COSP="$lcosp" \
722L_AERONOMARS="$laeronomars" \
723L_CHIMIE="$libchimie" \
724LOCAL_DIR="$localdir"  \
725F77="$fcompiler" \
726F90="$fcompiler" \
727CCC="$ccompiler" \
728OPLINK="$LIB" \
729LINK="$linker" \
730GCM="$LMDGCM" \
731MOD_LOC_DIR=$mod_loc_dir \
732MOD_SUFFIX="mod" \
733AR=$arcommand \
734DIRMAIN=$code_dir \
735SOURCE=$source_code \
736PROG=$code
737
738$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
739OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
740OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
741OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
742OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
743OPTIMC="$OPTIMC" \
744INCLUDE="$INCLUDE" \
745INCLUDEC="$includec" \
746$filtre \
747LIBO=${LIBOGCM}/${nomlib} \
748$phys \
749DIM=$dimc \
750FLAG_PARA=$FLAG_PARA \
751L_ADJNT="$adjnt" \
752L_COSP="$lcosp" \
753L_AERONOMARS="$laeronomars" \
754L_CHIMIE="$libchimie" \
755LOCAL_DIR="$localdir"  \
756F77="$fcompiler" \
757F90="$fcompiler" \
758CCC="$ccompiler" \
759OPLINK="$LIB" \
760LINK="$linker" \
761GCM="$LMDGCM" \
762MOD_LOC_DIR=$mod_loc_dir \
763MOD_SUFFIX="mod" \
764AR=$arcommand \
765DIRMAIN=$code_dir \
766SOURCE=$source_code \
767PROG=$code
768
769if [[ -r $LIBFGCM/grid/dimensions.h ]]
770then
771  # Cleanup: remove dimension.h file
772  \rm -f $LIBFGCM/grid/dimensions.h
773fi
Note: See TracBrowser for help on using the repository browser.