source: trunk/LMDZ.COMMON/makelmdz @ 1098

Last change on this file since 1098 was 1076, checked in by slebonnois, 11 years ago

SL: still another correction to version 1056...

  • 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 )
301for inc in $archfileline ; do INCLUDE="$INCLUDE `echo $inc | grep '\-I'`" ; done
302
303if [[ "$physique" != "nophys" ]]
304then
305   CPP_KEY="$CPP_KEY CPP_PHYS"
306fi
307
308if [[ "$physique" == "lmd" ]]
309then
310   #Default planet type is Earth
311   CPP_KEY="$CPP_KEY CPP_EARTH"
312fi
313
314######### CAS PARTICULIER CHIMIE TITAN
315if [[ "$physique" == "titan" ]]
316then
317   INCLUDE="$INCLUDE"' -I$(LIBF)/chim'"$physique"
318   LIB="$LIB -l${LIBPREFIX}chim$physique"
319   opt_dep="$opt_dep chim$physique"
320# get C compiler name and optim from arch.fcm file
321   archfileline=$( grep -i '^%C_COMPILER' arch.fcm )
322   ccompiler=$( echo ${archfileline##%C_COMPILER} )
323   archfileline=$( grep -i '^%C_OPTIM' arch.fcm )
324   coptim=$( echo ${archfileline##%C_OPTIM} )
325   OPTIMC="${coptim}"
326   INCLUDEC='-I$(LIBF)/grid -I.'
327fi
328#########
329
330if [[ "$chimie" == "INCA" ]]
331then
332   CPP_KEY="$CPP_KEY INCA"
333   INCLUDE="$INCLUDE -I${INCA_INCDIR}"
334   LIB="$LIB -L${INCA_LIBDIR} -lchimie"
335   libchimie=" -L${INCA_LIBDIR} -lchimie"
336fi
337
338if [[ "$couple" != "false" ]]
339then
340   CPP_KEY="$CPP_KEY CPP_COUPLE"
341   INCLUDE="$INCLUDE -I${OASIS_INCDIR}"
342   LIB="$LIB -L${OASIS_LIBDIR} -lpsmile.${couple} -lmpp_io"
343fi
344
345if [[ "$parallel" == "none" ]]
346then
347  FLAG_PARA=''
348else
349  FLAG_PARA="$paramem"
350fi
351
352if [[ "$parallel" == "mpi" ]]
353then
354   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI"
355  # MPI additional compilation options
356  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
357  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
358  # MPI additional links
359  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
360  PARA_LD=$( echo ${archfileline##%MPI_LD} )
361elif [[ "$parallel" == "omp" ]]
362then
363   CPP_KEY="$CPP_KEY CPP_PARA CPP_OMP"
364  # OMP additional compilation options
365  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
366  PARA_FFLAGS=$( echo ${archfileline##%OMP_FFLAGS} )
367  # OMP additional links
368  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
369  PARA_LD=$( echo ${archfileline##%OMP_LD} )
370elif [[ "$parallel" == "mpi_omp" ]]
371then
372   CPP_KEY="$CPP_KEY CPP_PARA CPP_MPI CPP_OMP"
373  # MPI additional compilation options
374  archfileline=$( grep -i '^%MPI_FFLAGS' arch.fcm )
375  PARA_FFLAGS=$( echo ${archfileline##%MPI_FFLAGS} )
376  # OMP additional compilation options
377  archfileline=$( grep -i '^%OMP_FFLAGS' arch.fcm )
378  PARA_FFLAGS="${PARA_FFLAGS} "$( echo $archfileopt ${archfileline##%OMP_FFLAGS} )
379  # MPI additional links
380  archfileline=$( grep -i '^%MPI_LD' arch.fcm )
381  PARA_LD=$( echo ${archfileline##%MPI_LD} )
382  # OMP additional links
383  archfileline=$( grep -i '^%OMP_LD' arch.fcm )
384  PARA_LD="${PARA_LD} "$( echo $archfileopt ${archfileline##%OMP_LD} )
385fi
386
387if [[ ( "$parallel" == "omp" || "$parallel" == "mpi_omp" ) \
388   && "$compil_mod" == "debug" ]]
389then
390    echo "Usually, parallelization with OpenMP requires some optimization."
391    echo "We suggest switching to \"-dev\"."
392fi
393
394if [ "$veget" = "true" -o "$veget" = "orchidee1.9" -o "$veget" = "orchidee2.0" ]
395then
396
397   INCLUDE="${INCLUDE} -I${ORCH_INCDIR}"
398   CPP_KEY="$CPP_KEY CPP_VEGET"
399# temporary, for Orchidee versions 1.9.* (before openmp activation)
400   if [[ "$veget" == "orchidee1.9" ]] ; then
401      CPP_KEY="$CPP_KEY ORCHIDEE_NOOPENMP"
402   fi
403   if [[ "$veget" == "orchidee2.0" ]] ; then
404      orch_libs="sechiba parameters stomate parallel orglob orchidee"
405   else
406      orch_libs="sechiba parameters stomate parallel orglob"
407   fi
408   LIB="${LIB} -L${ORCH_LIBDIR}"
409   for lib in ${orch_libs} ; do
410      if [ -f ${ORCH_LIBDIR}/lib${LIBPREFIX}$lib.a ] ; then
411         LIB="${LIB} -l${LIBPREFIX}$lib "
412      fi
413   done
414elif [[ "$veget" != "false" ]] ; then
415   echo "Option -v $veget does not exist"
416   echo "Use ./makelmdz -h for more information"
417   exit 
418fi
419
420if [[ $io == ioipsl ]]
421then
422   CPP_KEY="$CPP_KEY CPP_IOIPSL"
423   INCLUDE="$INCLUDE -I${IOIPSL_INCDIR}"
424   LIB="$LIB -L${IOIPSL_LIBDIR} -l${LIBPREFIX}ioipsl"
425fi
426
427if [[ "$cosp" == "true" ]]
428then
429   CPP_KEY="$CPP_KEY CPP_COSP"
430   COSP_PATH="$LIBFGCM/cosp"
431#   LIB="${LIB} -l${LIBPREFIX}cosp"
432   opt_dep="$opt_dep cosp"
433   lcosp="-l${LIBPREFIX}cosp"
434   INCLUDE="$INCLUDE"' -I$(LIBF)/cosp'
435fi
436
437
438INCLUDE="$INCLUDE ${NETCDF_INCDIR}"
439LIB="$LIB ${NETCDF_LIBDIR}"
440
441########################################################################
442# calcul du nombre de dimensions
443########################################################################
444
445
446dim_full=$dim
447dim=`echo $dim | sed -e 's/[^0-9]/ /g'` 
448set $dim
449dimc=$#
450echo calcul de la dimension
451echo dim $dim
452echo dimc $dimc
453
454
455########################################################################
456# Gestion des dimensions du modele.
457# on cree ou remplace le fichier des dimensions
458########################################################################
459
460cd $LIBFGCM/grid
461if [[ -f dimensions.h ]]
462then
463  echo 'ATTENTION: vous etes sans doute en train de compiler le modele par ailleurs'
464  echo "Attendez que la premiere compilation soit terminee pour relancer la suivante."
465  echo "Si vous etes sur que vous ne compilez pas le modele par ailleurs,"
466  echo  vous pouvez continuer en repondant oui.
467  echo "Voulez-vous vraiment continuer?"
468  echo ""
469  echo "WARNING: you are probably already compiling the model somewhere else."
470  echo "Wait until the first compilation is finished before launching this one."
471  echo "If you are sure that you are not compiling elsewhere, just answer "
472  echo "yes (or 'oui') to the question below to proceed."
473  echo "Do you wish to continue?"
474  read reponse
475  if [[ $reponse == "oui" || $reponse == "yes" ]]
476  then
477    \rm -f $LIBFGCM/grid/dimensions.h
478  else
479    exit
480  fi
481fi
482
483
484cd $LIBFGCM/grid/dimension
485./makdim $dim
486cat $LIBFGCM/grid/dimensions.h
487cd $LMDGCM
488
489if [[ "$bands" != "" ]]
490then
491  # Generic model, recreate bands.h (IR & VIS bands for radiative transfer)
492  bands=$(echo $bands | sed -e 's/[^0-9]/ /g')
493  cd $LIBFGCM/phy$physique/bands
494  ./makbands $bands
495  cat $LIBFGCM/phy$physique/bands.h
496  cd $LMDGCM
497fi
498
499if [[ "$scatterers" != "" ]]
500then
501  # Generic model, recreate scatterers.h
502  cd $LIBFGCM/phy$physique/scatterers
503  ./make_scatterers $scatterers
504  cat $LIBFGCM/phy$physique/scatterers.h
505  cd $LMDGCM
506fi
507
508
509########################################################################
510# Differentes dynamiques (3d, 2d, 1d)
511########################################################################
512
513dimension=`echo $dim | wc -w`
514echo dimension $dimension
515
516if (( $dimension == 3 ))
517then
518  cd $LIBFGCM/grid
519  \rm fxyprim.h
520  cp -p fxy_${grille}.h fxyprim.h
521#else
522#  echo "Probleme dans les dimensions de la dynamique !!"
523#  echo "Non reactive pour l'instant !!!"
524fi
525if (( $dimension == 1 ))
526then
527  echo pas de dynamique
528  dyn="DYN= L_DYN=-ldyn3d "
529fi
530
531######################################################################
532# Gestion du filtre qui n'existe qu'en 3d.
533######################################################################
534
535if (( `expr $dimc \> 2` == 1 ))
536then
537   filtre="FILTRE=$filtre"
538else
539   filtre="FILTRE= L_FILTRE= "
540fi
541echo MACRO FILTRE $filtre
542
543echo $dimc
544
545######################################################################
546# Creation du suffixe de la configuration
547######################################################################
548
549
550SUFF_NAME=_${dim_full}
551SUFF_NAME=${SUFF_NAME}_phy${physique}
552
553if [[ "$parallel" != "none" ]]
554then
555  SUFF_NAME=${SUFF_NAME}_para
556  DYN=dyn${dimc}d${paramem}
557  if [[ "$paramem" == "mem" ]]
558  then
559   SUFF_NAME=${SUFF_NAME}_${paramem}
560  fi
561else
562  SUFF_NAME=${SUFF_NAME}_seq
563  DYN=dyn${dimc}d
564fi
565
566if [[ $veget != "false" ]]
567then
568  SUFF_NAME=${SUFF_NAME}_orch
569fi
570
571if [[ $couple != "false" ]]
572then
573  SUFF_NAME=${SUFF_NAME}_couple
574fi
575
576if [[ $chimie == "INCA" ]]
577then
578  SUFF_NAME=${SUFF_NAME}_inca
579fi
580
581cd $LMDGCM
582
583
584########################################################################
585#  Avant de lancer le make, on recree le makefile si necessaire
586########################################################################
587########################################################################
588# c'est a dire dans 3 cas:
589# 1. si la liste des fichiers .F et .h a ete modifiee depuis la
590#    derniere creation du makefile
591# 2. si le fichier contenant cette liste "liste_des_sources"
592#    n'existe pas.
593# 3. Si le makefile n'existe pas.
594########################################################################
595cd $LMDGCM
596find libf -name '*.[Fh]' -print | sort > tmp77
597find libf -name '*.[Fh]' -exec egrep -i " *use *ioipsl" {} \; -print | sort > tmp90
598find libf -name '*.[Fh90]' -print | sort >> tmp90
599######### CAS PARTICULIER CHIMIE TITAN
600if [[ "$physique" == "titan" ]]
601then 
602  find libf -name '*.[ch]' -print | sort > tmpC
603fi
604#########
605
606if [[ ! ( -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 ]]
607then
608  echo "les fichiers suivants ont ete crees ou detruits"
609  echo "ou les fichiers suivants sont passes ou ne sont plus en Fortran 90"
610  diff liste_des_sources_f77 tmp77
611  diff liste_des_sources_f90 tmp90
612  \cp -f tmp77 liste_des_sources_f77
613  \cp -f tmp90 liste_des_sources_f90
614######### CAS PARTICULIER CHIMIE TITAN
615  if [[ "$physique" == "titan" ]]
616  then 
617  diff liste_des_sources_C tmpC
618  \cp -f tmpC liste_des_sources_C
619  fi
620#########
621  echo "on recree le makefile"
622  ./create_make_gcm > tmp
623  \mv -f tmp makefile
624  echo "Nouveau makefile cree"
625######### CAS PARTICULIER CHIMIE TITAN
626else if [[ "$physique" == "titan" ]]
627 then
628   if [[ ! ( -r liste_des_sources_C ) || ` diff tmpC liste_des_sources_C | wc -w ` -ne 0 ]]
629   then
630     diff liste_des_sources_C tmpC
631     \cp -f tmpC liste_des_sources_C
632     echo "on recree le makefile"
633     ./create_make_gcm > tmp
634     \mv -f tmp makefile
635     echo "Nouveau makefile cree"
636   fi
637 fi
638#########
639fi
640
641#################################################################
642# Preparation de l'execution de la commande make
643#################################################################
644
645# find code suffix and directory where code is located
646if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F ]]
647then
648  source_code=${code}.F
649  code_dir=dyn${dimc}d${FLAG_PARA}
650else
651  if [[ -r $LMDGCM/libf/dyn${dimc}d${FLAG_PARA}/${code}.F90 ]]
652  then
653    source_code=${code}.F90
654    code_dir=dyn${dimc}d${FLAG_PARA}
655  else
656    if [[ -r $LMDGCM/libf/phy${physique}/${code}.F ]]
657    then
658      source_code=${code}.F
659      code_dir=phy${physique}
660    else
661      # last possibility:
662      if [[ -r $LMDGCM/libf/phy${physique}/${code}.F90 ]]
663      then
664        source_code=${code}.F90
665        code_dir=phy${physique}
666      else
667        echo "Error: cannot find ${code}.F[90]"
668        echo " neither in dyn${dimc}d${FLAG_PARA} nor in phy${physique}"
669        exit
670      fi
671    fi
672  fi
673fi
674
675# library directory name:
676nomlib=`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'`
677echo $nomlib
678
679if [[ ! -d "${LIBOGCM}/${nomlib}" ]]
680then
681  mkdir ${LIBOGCM}/${nomlib}
682  # check we indeed managed to create the directory
683  if [[ ! $? ]]
684  then
685    echo "Error: could not create directory ${LIBOGCM}/${nomlib}"
686    exit
687  fi
688fi
689
690# where module files are created
691mod_loc_dir=$localdir
692
693if [[ "$physique" != "nophys" ]]
694then
695  INCLUDE="$INCLUDE"' -I$(LIBF)/phy'"$physique"
696  phys="PHYS=$physique"
697else
698  # trick to avoid having a physics-related library in the makefile
699  phys="L_PHY= LIBPHY="
700fi
701if (( $dimension == 1 ))
702then
703 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn3d -I'${LIBOGCM}/${nomlib}
704else
705 INCLUDE="$INCLUDE"' -I$(LIBF)/dyn'${dimc}'d'$FLAG_PARA' -I'${LIBOGCM}/${nomlib}
706fi
707
708# ranlib utility (check it exists or else default to ls)
709if [[ `which ranlib > /dev/null 2>&1 ; echo $?` -eq 0 ]]
710then
711  ranlib="ranlib"
712else
713  ranlib="ls"
714fi
715
716# add CPP keys to COMPIL_FLAGS
717# (but first add -D before all CPP_KEY items)
718cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-D&/g'`
719# (but add a -WF,-D before all CPP_KEY items) => for xlf on Vargas
720if [[ "${fcompiler:0:3}" == "xlf" ]]
721then
722cpp_definitions=`echo $CPP_KEY | sed -e 's/[A-Za-z_=0-9]*/-WF,-D&/g'`
723fi
724COMPIL_FFLAGS="${COMPIL_FFLAGS} ${cpp_definitions}"
725
726#################################################################
727# Execution du make
728#################################################################
729echo $makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
730OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
731OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
732OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
733OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
734OPTIMC="$OPTIMC" \
735INCLUDE="$INCLUDE" \
736INCLUDEC="$includec" \
737$filtre \
738$dyn \
739LIBO=${LIBOGCM}/${nomlib} \
740$phys \
741DIM=$dimc \
742FLAG_PARA=$FLAG_PARA \
743L_ADJNT=$adjnt \
744L_COSP="$lcosp" \
745L_CHIMIE="$libchimie" \
746LOCAL_DIR="$localdir"  \
747F77="$fcompiler" \
748F90="$fcompiler" \
749CCC="$ccompiler" \
750OPLINK="$LIB" \
751LINK="$linker" \
752GCM="$LMDGCM" \
753MOD_LOC_DIR=$mod_loc_dir \
754MOD_SUFFIX="mod" \
755AR=$arcommand \
756DIRMAIN=$code_dir \
757SOURCE=$source_code \
758PROG=$code
759
760$makecommand RANLIB=$ranlib -f $LMDGCM/makefile \
761OPTION_DEP="$opt_dep" OPTION_LINK="$LIB ${PARA_LD}" \
762OPTIM90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
763OPTIMTRU90="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
764OPTIM="${COMPIL_FFLAGS} ${PARA_FFLAGS}" \
765OPTIMC="$OPTIMC" \
766INCLUDE="$INCLUDE" \
767INCLUDEC="$includec" \
768$filtre \
769$dyn \
770LIBO=${LIBOGCM}/${nomlib} \
771$phys \
772DIM=$dimc \
773FLAG_PARA=$FLAG_PARA \
774L_ADJNT="$adjnt" \
775L_COSP="$lcosp" \
776L_CHIMIE="$libchimie" \
777LOCAL_DIR="$localdir"  \
778F77="$fcompiler" \
779F90="$fcompiler" \
780CCC="$ccompiler" \
781OPLINK="$LIB" \
782LINK="$linker" \
783GCM="$LMDGCM" \
784MOD_LOC_DIR=$mod_loc_dir \
785MOD_SUFFIX="mod" \
786AR=$arcommand \
787DIRMAIN=$code_dir \
788SOURCE=$source_code \
789PROG=$code
790
791if [[ -r $LIBFGCM/grid/dimensions.h ]]
792then
793  # Cleanup: remove dimension.h file
794  \rm -f $LIBFGCM/grid/dimensions.h
795fi
Note: See TracBrowser for help on using the repository browser.