source: trunk/LMDZ.COMMON/makelmdz @ 1000

Last change on this file since 1000 was 979, checked in by emillour, 12 years ago

Common dynamics:
Updates in the dynamics (seq and ) to keep up with updates
in LMDZ5 (up to LMDZ5 trunk, rev 1760):

  • General stuff (essentially to keep up with Earth model):
  • Updated makelmdz_fcm and makelmdz (more control on dimension.h, added option -mem, although it is not usefull for now)
  • Updated build_gcm with more control over fcm
  • Updated create_make_gcm (enable looking for code in subdirectories)
  • bibio:
  • updates (just renaming the files actually...) new_unit.F90 => new_unit_m.F90, pchsp_95.F90 => pchsp_95_m.F90 and pchfe_95.F90 => pchfe_95_m.F90
  • filtrez:
  • mod_fft.F90: use more baseline CPP directives for preprocessor compatibility
  • mod_filtre_fft_loc.F90: added this new file
  • filtreg_mod.f90: added calls to init_..._loc
  • filtreg.F: fixed calls to DGEMM into SGEMM (preprocessing does the switch)
  • dyn3d:
  • removed obsolete files: etat0_netcdf.F90 limit_netcdf.F90

pres2lev.F90

  • added new file : pres2lev_mod.F90 (module containing "old" pres2lev)
  • gcm.F: changed args to call to inidissip (added arg "vert_prof_dissip")
  • inidissip.F90: added arg "vert_prof_dissip" and the "earth model" discterizations (flagged with "planet_type=="earth")
  • comdissnew.h: added 'vert_prof_dissip' to the common block
  • guide_mod.F90: added the "use pres2lev_mod"
  • conf_gcm.F: cosmetics, and evaluation of vert_prof_dissip, (and also of dissip_* factors, for Earth model)
  • comconst.h : added dissip_factz,dissip_zref variables (for Earth mode dissip)
  • dyn3dpar:
  • removed obsolete files: etat0_netcdf.F90 limit_netcdf.F90

pres2lev.F90 mod_const_para.F90

  • added new files: pres2lev_mod.F90 (module containing "old" pres2lev)

mod_const_mpi

  • abort_gcm : better control of abort in parallel mode
  • gcm.F: changed args to call to inidissip (added arg "vert_prof_dissip")
  • inidissip.F90: added arg "vert_prof_dissip" and the "earth model" discterizations (flagged with "planet_type=="earth")
  • comdissnew.h: added 'vert_prof_dissip' to the common block
  • filtreg_p.F : bug correction (array bounds)
  • guide_p_mod.F90 : added the "use pres2lev_mod"
  • conf_gcm.F : cosmetics (and evaluation of vert_prof_dissip , and

also of dissip_* factors, for Earth model)
plus check if "adjust" is indeed not used in OpenMP

  • comconst.h : add dissip_factz,dissip_zref variables (for Earth mode dissip)

EM

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