source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 333

Last change on this file since 333 was 333, checked in by aslmd, 13 years ago

MESOSCALE: tests OK for changes in previous commit. corrected another instance of the infamous rad/deg bug! also fixed an issue with nesting, functions are not considered in physics duplication. results look good in a typical Hellas winter case [with old physics].

  • Property svn:executable set to *
File size: 32.0 KB
Line 
1#! /bin/bash
2
3
4##################################
5# makemeso allows you to compile #
6# WRF with modified LMD physics  #
7##################################
8
9##############################
10# Author: A. Spiga           #
11# New version : October 2008 #
12# Last update : January 2009 #
13#               November  09 #
14#               January   11 #
15##############################
16
17###############################
18#### Type makemeso -h for help
19###############################
20
21
22
23##############################################################################################
24##############################################################################################
25##############################################################################################
26##############################################################################################
27
28donotcompile=0
29donotallow=0
30config=''
31donotcompilephys=0
32justphys=0
33debug=0
34fresh_start=0
35phys=""
36scenario=""
37while getopts "drc:njhgpfs:x" options; do
38  case $options in
39   d ) donotcompile=1;;       ## just to check the compile folder
40   r ) donotallow=1;;         ## allow only known config (useful with 'makemeso < last')
41   c ) config="${OPTARG}";;   ## idealized cases
42   n ) donotcompilephys=1;;   ## do not recompile physics
43   j ) justphys=1;;           ## just compile LMD physics
44   g ) debug=1;;              ## debug mode
45   p ) phys="newphys_";;      ## with new physics
46   f ) fresh_start=1;;        ## a fresh start
47   s ) scenario="${OPTARG}";; ## a specific scenario, you need a corresponding "mars_lmd_..."
48   x ) donotcompile=1;phys="nophys_";donotcompilephys=1;; ## a case with no LMD physics included
49   h ) echo "
50# Use:   
51#
52# makemeso                   ## basic use (real-case configuration)
53#
54# makemeso -d                ## no compilation, just check the name of the compile folder
55#
56# makemeso -c ideal          ## idealized mode (convective cell, mountain wave, etc...)
57# makemeso -c les            ## large-eddy simulations mode based on WRFV3
58#
59# makemeso -n                ## do not recompile LMD physics (must have been compiled before)
60#
61# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
62# makemeso -r < last         ## basic use + skip questions + only known config
63# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
64#
65# makemeso -j                ## just compile the LMD physics
66#
67# makemeso -g                ## debug mode
68#
69# makemeso -h                ## display options
70#
71# makemeso -p                ## with new LMD physics
72#
73# makemeso -f                ## fresh start [clean -a]
74#
75# makemeso -s storm          ## a specific scenario, you need a corresponding mars_lmd_... (only for newphys)
76#
77# makemeso -x                ## a case with no LMD physics included
78" ; exit ;;
79  esac
80done   
81
82#--------------
83# talk w/ user
84#--------------
85  echo '****************************************'
86  echo ' LMD Mesoscale Model Compiler. Welcome.'
87  echo '****************************************'
88  if [[ "${phys}" == "newphys_" ]]
89  then
90    echo '***********with new physics*************'
91    echo '****************************************'
92  fi
93  # computer
94  uname -a | grep x86_64 > /dev/null
95  if [[ "$?" == 0 ]]
96  then
97    machine='64'
98  else
99    machine='32'
100  fi
101  # compiler
102  echo "Supported compiler options are "
103  echo "       <1> pgf90"
104  echo "       <2> g95"
105  echo "       <3> pgf90 + mpi"
106  echo "       <4> ifort"
107  echo "       <5> ifort + mpi"
108  echo "       <7> xlf + mpi (IBM AIX)"
109  echo "Your choice ?" ; read reply
110  case ${reply} in
111    1) compilo='pgf' ; numproc=1 ;;
112    2) compilo='g95' ; numproc=1 ;;
113    3) compilo='mpi'
114       if [[ "${WHERE_MPI}" = "" ]]
115       then
116         echo Please initialize the variable WHERE_MPI in your environnement
117         exit
118       fi
119       echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
120    4) compilo='ifort' ; numproc=1 ;;
121    5) compilo='mpifort' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
122    7) compilo='mpixlf' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
123### for tests
12499) compilo='gnu' ; numproc=1 ;;
125    *) echo not supported by this script ; exit ;;
126  esac
127  # dimensions
128  if [ ${donotcompile} -eq 0 ]
129  then   
130  echo Grid points in longitude ? ; read lon
131  echo Grid points in latitude ? ; read lat
132  echo Number of vertical levels ? ; read level
133  fi
134  echo Number of domains ? ; read dom
135
136###PB lecture dom si < last
137
138    case ${dom} in
139       1) single='_single' ;;
140       *) single='_nest' ;;
141    esac
142      if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
143      then
144           single=''
145      fi
146
147testflag=''
148####
149#testflag='_test'
150####
151
152    conf_wrf="${config}${scenario}${phys}${compilo}_${machine}${single}${testflag}"
153    \rm what_folder 2> /dev/null
154    echo ${conf_wrf} > what_folder
155         if [ ${donotcompile} -eq 1 ]
156         then
157            #\rm what_folder 2> /dev/null
158            #echo '**********************'
159            #echo '*** Your folder is ...'
160            #echo '**********************'
161            #echo ${conf_wrf} | tee what_folder
162            #cat what_folder
163            #echo ${conf_wrf} > what_folder
164            #echo ${reply} > what_compilo
165            #echo ${numproc} > what_numproc
166            if [[ "${phys}" != "nophys_" ]]
167            then
168              exit
169            fi
170         else
171            echo Number of tracers ? ; read tra
172            if [ ${tra} -eq 0 ]
173            then
174              tra=1     
175            fi
176            if [[ "${phys}" == "newphys_" ]]
177            then
178              echo "How many types of scatterer are you using ? 1 [dust] or 2 [dust + water ice]" ; read scat
179            else
180              scat=1 ## dummy stuff
181            fi
182         fi
183  # folder
184  mkdir ${conf_wrf} 2> /dev/null
185  if [[ "$?" == 0 ]]
186  then
187    echo new folder ... link sources
188    if [[ "${phys}" == "newphys_" ]]
189    then
190     \rm copy_model_tmp > /dev/null 2> /dev/null
191        if [[ "${scenario}" == "" ]]
192        then
193          sed s+"mars_lmd"+"mars_lmd_new"+g             SRC/SCRIPTS/copy_model > copy_model_tmp
194        else
195          echo SCENARIO ${scenario} DID YOU INCLUDE THE SPECIFIC folder ? ; read dummy
196          sed s+"mars_lmd"+"mars_lmd_new_${scenario}"+g SRC/SCRIPTS/copy_model > copy_model_tmp
197             if [[ "${config}" == "les" ]]
198             then
199              echo "NOT SUPPORTED, check options"
200              exit
201             fi
202        fi
203        if [[ "${config}" == "les" ]]
204        then
205         sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g copy_model_tmp > yeah
206         mv yeah copy_model_tmp
207        fi
208     chmod 755 copy_model_tmp
209     ./copy_model_tmp
210     \rm copy_model_tmp
211     mv zeWRFV2 ${conf_wrf}/WRFV2
212     cd ${conf_wrf}/WRFV2
213        if [[ "${scenario}" == "" ]]
214        then
215          ln -sf mars_lmd_new             mars_lmd
216        else
217          ln -sf mars_lmd_new_${scenario} mars_lmd
218          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/Registry.EM mars_lmd_new_${scenario}/
219          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/*.inc mars_lmd_new_${scenario}/
220          cd Registry ; ln -sf ../mars_lmd_new_${scenario}/Registry.EM . ; cd ..
221        fi
222     #ln -sf meso_callkeys_newphys.h meso_callkeys.h
223     cd Registry ; Registry.bash ; cd ..
224    else
225         if [[ "${config}" == "les" ]]
226         then
227           ### NB: With physics: LES folder // Without physics : LESnophys_ folder
228           ### ---- because differences in 'modif' folder ----
229           sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g SRC/SCRIPTS/copy_model > copy_model_tmp
230         else
231           cp SRC/SCRIPTS/copy_model copy_model_tmp
232         fi   
233     chmod 755 copy_model_tmp
234     ./copy_model_tmp
235     \rm copy_model_tmp
236     mv zeWRFV2 ${conf_wrf}/WRFV2
237     cd ${conf_wrf}/WRFV2
238     cd Registry ; Registry.bash ; cd ..
239     fi
240          #### sparadrap consequent a l'utilisation de copy_model pour les liens
241          #### -- car alors il manque fftpack
242          if [[ "${config}" == "les" ]]
243          then
244            if [[ "${phys}" == "nophys_" ]]
245            then
246              ## voir ci-dessus pour le folder
247              cp ../../SRC/LES$phys/correcfft ./
248            else
249              cp ../../SRC/LES/correcfft ./
250            fi 
251            ./correcfft
252            \rm correcfft
253          fi
254  else
255    cd ${conf_wrf}/WRFV2
256    if [ ${fresh_start} -eq 1 ]
257    then
258      echo '*** FRESH START, I clean everything'
259      ### clean the whole place 
260      clean -a > /dev/null 2> /dev/null
261      ### get a possibly modified registry !
262      if [[ "${scenario}" == "" ]]
263      then
264        cp ../../SRC/WRFV2/Registry/Registry.EM Registry/
265      fi
266      ### ensure the model will be recompiled from scratch with correct registry
267      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
268#     answer='y' ## a voir... pas si sur
269#    else
270#            if [[ "${phys}" != "nophys_" ]]
271#            then
272#      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
273#      case ${answer} in
274#        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
275#        *) answer='no' ;;
276#      esac
277#            fi
278    fi
279  fi
280
281  # summary
282  echo '**********************'
283  echo '*** Your folder is ...'
284  echo '**********************'
285  echo ${conf_wrf}
286  echo '**********************'
287  echo '****************************************'
288  echo so ...
289  echo your computer is ${machine} bits
290  echo ${compilo} is your compiler
291       if [[ "${compilo}" = "mpi" ]]
292       then
293         echo MPICH is in ${WHERE_MPI}
294       fi
295  echo you will use ${numproc} processors
296  echo you have ${lon} x points
297  echo '         '${lat} y points
298  echo '         '${level} z points
299  echo '         '${dom} domains
300  echo '         '${tra} tracers
301  if [[ "${phys}" == "newphys_" ]]
302  then
303    echo '         '${scat} scatterers
304  fi
305  echo '****************************************'
306  # save answer
307  \rm last 2> /dev/null
308  touch last
309  echo ${reply} >> last
310     if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
311     then
312     echo ${numproc} >> last
313     fi
314  echo ${lon} >> last
315  echo ${lat} >> last
316  echo ${level} >> last
317  echo ${dom} >> last
318  echo ${tra} >> last
319  echo ${scat} >> last
320  #echo ${answer} >> last
321
322#------------
323# log files
324#------------
325  \rm log_compile 2> /dev/null
326  \rm log_error 2> /dev/null
327
328#-----------------
329# configure WRF
330#-----------------
331  mv configure.wrf configure.wrf.bak 2> /dev/null
332  ########################
333  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
334
335         #### in this case options are different because for LES, WRFV3 is used
336         if [[ "${config}" == "les" ]]
337         then
338         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
339         fi
340
341  case ${conf_wrf_forall} in
342
343     #######LES-specific (WRFV3-based) -- previously in 'makeles'
344     #######
345
346     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
347                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
348                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
349                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
350                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
351                       then
352            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
353            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
354            #sed s+"mpicc -cc=$(SCC)"+"/usr/lib64/openmpi/1.4.2-gfortran/bin/mpicc -DMPI2_SUPPORT"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
355            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
356            sed s+"mpicc -cc=\$(SCC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpicc -DMPI2_SUPPORT"+g       configure.wrf > yeah ; mv -f yeah configure.wrf
357                       else
358            sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
359            sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
360                       fi
361                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
362                          ### pas forcement necessaire ici mais OK
363                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
364                       \rm conf > /dev/null ;;
365
366     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
367                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
368                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
369                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
370                       sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
371                       sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
372                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
373                       sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
374                       \rm conf > /dev/null ;;
375
376     #######
377     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
378
379#######TEST TEST
380                     # GFORTRAN, 64 bits, no nesting     
381     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
382                       echo 15 | configure > log_compile 2> log_error
383                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
384                       sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
385#######TEST TEST
386                     # PGF90, 32 bits, no nesting
387     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
388                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
389                     # PGF90, 32 bits, nesting
390     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
391                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
392                     # PGF90, 64 bits, no nesting
393     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
394                       #### the following line is necessary because readtesassim has a line "use netcdf" in it!
395                       #sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
396                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
397                     # PGF90, 64 bits, nesting
398     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
399                       echo 4 | configure > log_compile 2> log_error
400                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
401                     # G95, 32 bits, no nesting
402     g95_32_single)    echo 13 | configure > log_compile 2> log_error
403                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
404                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
405     g95_64_single)    cd arch ; sed s/"PC Linux i486 i586 i686, g95 compiler"/"PC Linux i486 i586 i686 x86_64, g95 compiler"/g configure.defaults > yeahyeahyeah ; rm configure.defaults ; mv yeahyeahyeah configure.defaults ; cd ..
406                       echo 14 | configure > log_compile 2> log_error
407                         ##### marche pas ....
408                         #sed s+"-fno-second-underscore"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
409                         #sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
410                         #sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
411                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
412                       #sed s+"=       g95"+"=       /home/physastro/aspiga/mysoft/g95/g95-install/bin/x86_64-unknown-linux-gnu-g95"+g configure.wrf > yeah ; mv -f yeah configure.wrf;;
413                     # IFORT, 64 bits, no nesting
414     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
415                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
416                         ## !!! NETCDF must be defined
417                         sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
418                         mv -f yeah configure.wrf ;;
419     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
420                       echo 9 | configure > log_compile 2> log_error
421                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
422                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
423                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
424                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
425                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
426                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
427                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
428                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
429                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
430                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
431                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
432                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
433                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
434                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
435                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
436                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
437                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
438                         ### necessary even if mpi-selector is used (no need in makegcm though)
439                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
440                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
441                         ## !!! NETCDF must be defined
442                         sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
443                         mv -f yeah configure.wrf
444                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
445                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
446                         mv -f yeah configure.wrf ;;
447                     # MPICH, 64 bits, no nesting / nesting
448     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
449                       echo 3 | configure > log_compile 2> log_error
450                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
451                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
452                       sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
453                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
454                                #| sed s+"fastsse"+"fast"+g > yeah
455                       mv -f yeah configure.wrf ;;
456                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
457                       ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
458                       ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
459                       #mv -f yeah configure.wrf ;;
460                     # MPICH, 64 bits, OK with periodic BC but no positive definite
461     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
462                       echo 2 | configure > log_compile 2> log_error
463                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
464                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
465                       mv -f yeah configure.wrf ;;
466                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
467     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
468                       echo 3 | configure > log_compile 2> log_error
469                       sed -f mars.sed configure.wrf > yeah
470                       mv -f yeah configure.wrf ;;
471                     # ANYTHING ELSE
472     *)                echo NO PRESETS ...
473                       if [ ${donotallow} -eq 0 ] 
474                       then
475                         configure
476                       else
477                         # problem when an input file is used
478                         echo 'please cd to '$PWD' and type ./configure' 
479                         exit   
480                       fi ;;
481  esac
482  ########################
483
484
485  ### here a case structure would be great
486
487  if [[ "${phys}" == "newphys_" ]]
488  then
489     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
490     then
491       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
492     else
493       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
494     fi
495     mv -f yeah configure.wrf
496  fi
497
498        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment
499        then
500          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
501          mv -f yeah configure.wrf
502        fi
503
504  ################
505  if [[ "${phys}" == "nophys_" ]]
506  then
507     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
508     then
509       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
510       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
511     else
512       ### not tested yet but should be working 
513       echo CAUTION CAUTION CAUTION NOT FULLY TESTED
514       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
515       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
516     fi
517  fi
518  ################
519
520  if [ ${debug} -ne 0 ]   # not working for xlf!
521  then
522    echo 'DEBUG DEBUG DEBUG DEBUG'
523    sed s+"#-g"+"-g"+g configure.wrf > yeah
524    mv -f yeah configure.wrf
525  fi
526
527
528##################################################
529# compile physics
530##################################################
531if [ ${donotcompilephys} -eq 0 ]
532then
533
534  cd mars_lmd/
535
536  # required size
537  #----------------
538  case ${numproc} in
539      1) divx=1 ; divy=1  ;;
540      2) divx=1 ; divy=2  ;;
541      4) divx=2 ; divy=2  ;;
542      6) divx=2 ; divy=3  ;;
543      8) divx=2 ; divy=4  ;;
544     12) divx=3 ; divy=4  ;;
545     16) divx=4 ; divy=4  ;;
546     20) divx=4 ; divy=5  ;;
547     24) divx=4 ; divy=6  ;;
548     32) divx=4 ; divy=8  ;;
549     64) divx=8 ; divy=8  ;;
550    128) divx=8 ; divy=16 ;;
551      *) echo not yet supported ; exit ;;
552  esac
553  physx=$(expr ${lon} - 1)
554  restex=$(expr ${physx} \% ${divx})   
555  physy=$(expr ${lat} - 1)
556  restey=$(expr ${physy} \% ${divy})
557  if [[ ${restex} != 0 || ${restey} != 0 ]]
558  then
559     echo nx-1 shall be divided by ${divx}
560     echo ny-1 shall be divided by ${divy}
561     exit
562  fi
563  physx=$(expr ${physx} \/ ${divx})
564  physy=$(expr ${physy} \/ ${divy})
565  physz=$(expr ${level} - 1)
566
567  # change this if you change num_soil_layers in WRF
568  # -- default is 10
569  if [[ "${phys}" == "newphys_" ]]
570  then
571     soilsize=18 ## nouvelle physique
572  else
573     soilsize=10
574  fi
575
576  # GCM environment variables
577  #--------------------------
578  export LMDGCM=$PWD
579  export LIBOGCM=$PWD/libo
580
581  # generate the appropriate dimphys
582  #---------------------------------
583  cd libf/phymars
584  \rm dimphys.h 2> /dev/null
585  if [[ "${phys}" == "newphys_" ]]
586  then
587    ln -sf meso_inc/meso_dimphys.h_ref .
588  fi
589  physize=$(expr ${physx} \* ${physy})
590  sed s/--xsize--/${physx}/g meso_dimphys.h_ref | sed s/--ysize--/${physy}/g | sed s/--physize--/${physize}/g | sed s/--zsize--/${physz}/g | sed s/--soilsize--/${soilsize}/g > dimphys.h
591  head -15 dimphys.h
592     ### TEST new new phys
593     if [[ "${phys}" == "newphys_" ]]
594     then
595       touch gr_fi_dyn.F.lien
596         ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
597     ###############################
598\rm scatterers.h
599cat << EOF > scatterers.h
600!-----------------------------------------------------------------------
601!   INCLUDE 'scatterers.h'
602!
603! Number of kind of tracer radiative properties
604! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
605! (ex: naerkind=1 if you use one dust mode without ice ...)
606! (ex: naerkind=2 if you use one dust mode and active ice ...)
607!-----------------------------------------------------------------------
608
609      integer, parameter :: naerkind=${scat}
610
611!-----------------------------------------------------------------------
612EOF
613     ###############################
614     ###############################
615     fi
616     ###
617     ###
618  cd ../..
619
620  # prepare for nesting
621  #---------------------
622  cd libf
623  duplicate${dom} 2> /dev/null
624  cd ..
625
626  # compile physics
627  #--------------------------
628  \rm libf/grid/dimensions.h 2> /dev/null
629  \rm -rf libo/* 2> /dev/null
630  echo 1. compiling LMD physics ...
631  echo compilation info in:
632  echo $PWD/libo/log_compile_phys
633
634  if [ ${debug} -ne 0 ]
635  then
636    echo 'DEBUG DEBUG DEBUG DEBUG'
637    nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
638  else
639    nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
640  fi
641  echo ... done
642        # clean the duplicate routines
643        cd libf
644        duplicate1 2> /dev/null
645        cd ..
646
647  # merge LMD executables in one lib
648  #--------------------------------------
649  cd libo
650  mkdir temp
651  #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp
652  cp -f LINUX*/*.a temp
653  cd temp
654  ar x libbibio.a
655  ar x libphymars.a
656  ar x libaeronomars.a
657  \rm *.a
658  ar r liblmd.a *
659  cp -f liblmd.a ..
660  cd ..
661  \rm -r temp
662  nm liblmd.a > liblmd_content
663  # finish merge
664  cd ..
665
666  # save a copy
667  #--------------
668  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}_${scat}
669  echo '****************************************'
670
671  # ok
672  #----
673  cd ..
674
675  # manage nest includes in module_lmd_driver.F
676  #----
677  cp call_meso_inifis$dom.inc call_meso_inifis.inc
678  cp call_meso_physiq$dom.inc call_meso_physiq.inc
679
680
681fi
682##################################################
683# END compile physics
684##################################################
685
686#------------------
687# compile WRF
688#------------------
689if [ ${justphys} -eq 0 ]
690then
691
692  echo 2. compiling WRF dynamical core ...
693
694  if [[ "${phys}" == "nophys_" ]]
695  then
696   echo 'NO LMD PHYSICS included'
697  else
698   if [[ ! ( -f "call_meso_physiq.inc" ) ]]
699   then
700    echo 'did you compile the physics ? no call_meso_physiq.inc !'
701    exit
702   fi
703  fi
704
705  # be sure to compile with the most recent physics
706  touch phys/module_lmd_driver.F
707
708  # talk to user
709  echo '>>> compiling ... this may be long ... <<<'
710  echo check progress in:
711  echo $PWD/log_compile
712  echo check possible errors in:
713  echo $PWD/log_error
714 
715  # compile ...
716  case ${config} in
717    '')         compile em_real > log_compile 2> log_error
718                    # save executables 
719                    cd main
720                      if [[ -f real.exe ]]
721                      then
722                        echo 'Looks good ! real.exe is here...'
723                      fi
724                      if [[ -f wrf.exe ]]
725                      then
726                        echo 'Looks good ! wrf.exe is here...'
727                      fi
728                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
729                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
730                    cd ..  ;;
731    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
732                    echo '>>> YOUR CONFIG IS : '${config}
733                    compile em_quarter_ss > log_compile 2> log_error
734                    # save executables 
735                    cd main
736                      if [[ -f ideal.exe ]]
737                      then
738                        echo 'Looks good ! ideal.exe is here...'
739                      fi
740                      if [[ -f wrf.exe ]]
741                      then
742                        echo 'Looks good ! wrf.exe is here...'
743                      fi
744                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
745                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
746                    cd ..  ;;
747    'les')          echo '>>> YOUR CONFIG IS : '${config}
748                    mkdir 'test/em_les' 2> /dev/null                   
749                    compile em_les > log_compile 2> log_error
750                    # save executables 
751                    cd main
752                      if [[ -f ideal.exe ]]
753                      then
754                        echo 'Looks good ! ideal.exe is here...'
755                      fi
756                      if [[ -f wrf.exe ]]
757                      then
758                        echo 'Looks good ! wrf.exe is here...'
759                      fi
760                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
761                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
762                    cd ..  ;;
763    *)              echo not supported... please use ; echo ideal les ; exit ;;
764  esac
765  echo '*******last lines from log_error*********'
766  tail -n 20 log_error
767fi
768
769  # the end
770  echo '****************************************'
771  echo 'done.'
772  echo '****************************************'
773  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}
774  mv last ../../
775
776  # add here specific messages
777  if [[ "${dom}" != "1" ]]
778  then
779  nest=$(expr ${lon} + 4)
780  echo NB: in namelist.input, please set:
781  echo '
782  max_dom = '$dom'
783  s_we    = 1,1,
784  e_we    = '$lon','$nest',
785  s_sn    = 1,1,
786  e_sn    = '$lat','$nest',
787  s_vert  = 1,1,
788  e_vert  = '$level','$level','
789  fi
790
Note: See TracBrowser for help on using the repository browser.