source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 200

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

MESOSCALE: correction makemeso (LES). ajout a README-svn. tests tempetes de poussiere avec JF.

  • 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         fi
177  # folder
178  mkdir ${conf_wrf} 2> /dev/null
179  if [[ "$?" == 0 ]]
180  then
181    echo new folder ... link sources
182    if [[ "${phys}" == "newphys_" ]]
183    then
184     \rm copy_model_tmp > /dev/null
185        if [[ "${scenario}" == "" ]]
186        then
187          sed s+"mars_lmd"+"mars_lmd_new"+g             copy_model > copy_model_tmp
188        else
189          echo SCENARIO ${scenario} DID YOU INCLUDE THE SPECIFIC folder ? ; read dummy
190          sed s+"mars_lmd"+"mars_lmd_new_${scenario}"+g copy_model > copy_model_tmp
191             if [[ "${config}" == "les" ]]
192             then
193              echo "NOT SUPPORTED, check options"
194              exit
195             fi
196        fi
197        if [[ "${config}" == "les" ]]
198        then
199         sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g copy_model_tmp > yeah
200         mv yeah copy_model_tmp
201        fi
202     chmod 755 copy_model_tmp
203     ./copy_model_tmp
204     \rm copy_model_tmp
205     mv WRFV2 ${conf_wrf}/
206     cd ${conf_wrf}/WRFV2
207        if [[ "${scenario}" == "" ]]
208        then
209          ln -sf mars_lmd_new             mars_lmd
210        else
211          ln -sf mars_lmd_new_${scenario} mars_lmd
212          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/Registry.EM mars_lmd_new_${scenario}/
213          cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/*.inc mars_lmd_new_${scenario}/
214          cd Registry ; ln -sf ../mars_lmd_new_${scenario}/Registry.EM . ; cd ..
215        fi
216     ln -sf meso_callkeys_newphys.h meso_callkeys.h
217     cd Registry ; Registry.bash ; cd ..
218    else
219     #./copy_model
220         if [[ "${config}" == "les" ]]
221         then
222           ### NB: With physics: LES folder // Without physics : LESnophys_ folder
223           ### ---- because differences in 'modif' folder ----
224           sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g copy_model > copy_model_tmp
225         else
226           cp copy_model copy_model_tmp
227         fi   
228     chmod 755 copy_model_tmp
229     ./copy_model_tmp
230     \rm copy_model_tmp
231     mv WRFV2 ${conf_wrf}/
232     cd ${conf_wrf}/WRFV2
233     cd Registry ; Registry.bash ; cd ..
234     fi
235          #### sparadrap consequent a l'utilisation de copy_model pour les liens
236          #### -- car alors il manque fftpack
237          if [[ "${config}" == "les" ]]
238          then
239            if [[ "${phys}" == "nophys_" ]]
240            then
241              ## voir ci-dessus pour le folder
242              cp ../../SRC/LES$phys/correcfft ./
243            else
244              cp ../../SRC/LES/correcfft ./
245            fi 
246            ./correcfft
247            \rm correcfft
248          fi
249  else
250    cd ${conf_wrf}/WRFV2
251    if [ ${fresh_start} -eq 1 ]
252    then
253      echo '*** FRESH START, I clean everything'
254      clean -a > /dev/null 2> /dev/null
255      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
256      answer='y' ## a voir... pas si sur
257    else
258            if [[ "${phys}" != "nophys_" ]]
259            then
260      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
261      case ${answer} in
262        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
263        *) answer='no' ;;
264      esac
265            fi
266    fi
267  fi
268  if [[ "${phys}" == "newphys_" ]]
269  then
270     echo "How many scatterers are you using : 1,2,..." ; read scat
271  else
272     scat=1 ## dummy stuff
273  fi
274
275  # summary
276  echo '**********************'
277  echo '*** Your folder is ...'
278  echo '**********************'
279  echo ${conf_wrf}
280  echo '**********************'
281  echo '****************************************'
282  echo so ...
283  echo your computer is ${machine} bits
284  echo ${compilo} is your compiler
285       if [[ "${compilo}" = "mpi" ]]
286       then
287         echo MPICH is in ${WHERE_MPI}
288       fi
289  echo you will use ${numproc} processors
290  echo you have ${lon} x points
291  echo '         '${lat} y points
292  echo '         '${level} z points
293  echo '         '${dom} domains
294  echo '         '${tra} tracers
295  if [[ "${phys}" == "newphys_" ]]
296  then
297    echo '         '${scat} scatterers
298  fi
299  echo '****************************************'
300  # save answer
301  \rm last 2> /dev/null
302  touch last
303  echo ${reply} >> last
304     if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
305     then
306     echo ${numproc} >> last
307     fi
308  echo ${lon} >> last
309  echo ${lat} >> last
310  echo ${level} >> last
311  echo ${dom} >> last
312  echo ${tra} >> last
313  echo ${answer} >> last
314  echo ${scat} >> last
315
316#------------
317# log files
318#------------
319  \rm log_compile 2> /dev/null
320  \rm log_error 2> /dev/null
321
322#-----------------
323# configure WRF
324#-----------------
325  mv configure.wrf configure.wrf.bak 2> /dev/null
326  ########################
327  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
328
329         #### in this case options are different because for LES, WRFV3 is used
330         if [[ "${config}" == "les" ]]
331         then
332         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
333         fi
334
335  case ${conf_wrf_forall} in
336
337     #######LES-specific (WRFV3-based) -- previously in 'makeles'
338     #######
339
340     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
341                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
342                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
343                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
344                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
345                       then
346            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
347            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
348            #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
349            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
350            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
351                       else
352            sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
353            sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
354                       fi
355                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
356                          ### pas forcement necessaire ici mais OK
357                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
358                       \rm conf > /dev/null ;;
359
360     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
361                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
362                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
363                       sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
364                       sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
365                       sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
366                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
367                       sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
368                       \rm conf > /dev/null ;;
369
370     #######
371     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
372
373#######TEST TEST
374                     # GFORTRAN, 64 bits, no nesting     
375     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
376                       echo 15 | configure > log_compile 2> log_error
377                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
378                       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 ;;
379#######TEST TEST
380                     # PGF90, 32 bits, no nesting
381     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
382                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
383                     # PGF90, 32 bits, nesting
384     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
385                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
386                     # PGF90, 64 bits, no nesting
387     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
388                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
389                     # PGF90, 64 bits, nesting
390     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
391                       echo 4 | configure > log_compile 2> log_error
392                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
393                     # G95, 32 bits, no nesting
394     g95_32_single)    echo 13 | configure > log_compile 2> log_error
395                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
396                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
397     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 ..
398                       echo 14 | configure > log_compile 2> log_error
399                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
400                       #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;;
401                     # IFORT, 64 bits, no nesting
402     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
403                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
404                         ## !!! NETCDF must be defined
405                         sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
406                         mv -f yeah configure.wrf ;;
407     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
408                       echo 9 | configure > log_compile 2> log_error
409                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
410                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
411                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
412                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
413                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
414                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
415                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
416                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
417                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
418                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
419                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
420                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
421                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
422                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
423                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
424                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
425                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
426                         ### necessary even if mpi-selector is used (no need in makegcm though)
427                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
428                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
429                         ## !!! NETCDF must be defined
430                         sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
431                         mv -f yeah configure.wrf
432                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
433                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
434                         mv -f yeah configure.wrf ;;
435                     # MPICH, 64 bits, no nesting / nesting
436     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
437                       echo 3 | configure > log_compile 2> log_error
438                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
439                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
440                                #| sed s+"fastsse"+"fast"+g > yeah
441                       mv -f yeah configure.wrf ;;
442                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
443                       ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
444                       ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
445                       #mv -f yeah configure.wrf ;;
446                     # MPICH, 64 bits, OK with periodic BC but no positive definite
447     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
448                       echo 2 | configure > log_compile 2> log_error
449                       sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf
450                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
451                       mv -f yeah configure.wrf ;;
452                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
453     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
454                       echo 3 | configure > log_compile 2> log_error
455                       sed -f mars.sed configure.wrf > yeah
456                       mv -f yeah configure.wrf ;;
457                     # ANYTHING ELSE
458     *)                echo NO PRESETS ...
459                       if [ ${donotallow} -eq 0 ] 
460                       then
461                         configure
462                       else
463                         # problem when an input file is used
464                         echo 'please cd to '$PWD' and type ./configure' 
465                         exit   
466                       fi ;;
467  esac
468  ########################
469
470
471  ### here a case structure would be great
472
473  if [[ "${phys}" == "newphys_" ]]
474  then
475     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
476     then
477       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
478     else
479       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
480     fi
481     mv -f yeah configure.wrf
482  fi
483
484        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment
485        then
486          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
487          mv -f yeah configure.wrf
488        fi
489
490  ################
491  if [[ "${phys}" == "nophys_" ]]
492  then
493     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
494     then
495       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
496       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
497     else
498       ### not tested yet but should be working 
499       echo CAUTION CAUTION CAUTION NOT FULLY TESTED
500       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
501       sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
502     fi
503  fi
504  ################
505
506  if [ ${debug} -ne 0 ]   # not working for xlf!
507  then
508    echo 'DEBUG DEBUG DEBUG DEBUG'
509    sed s+"#-g"+"-g"+g configure.wrf > yeah
510    mv -f yeah configure.wrf
511  fi
512
513
514##################################################
515# compile physics
516##################################################
517if [ ${donotcompilephys} -eq 0 ]
518then
519
520  cd mars_lmd/
521
522  # required size
523  #----------------
524  case ${numproc} in
525    1) physx=$(expr ${lon} - 1)
526       physy=$(expr ${lat} - 1)
527       physz=$(expr ${level} - 1) ;;
528    2) physx=$(expr ${lon} - 1)
529       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
530       physz=$(expr ${level} - 1) ;;
531    4) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
532       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
533       physz=$(expr ${level} - 1) ;;
534    6) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
535       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 3)
536       physz=$(expr ${level} - 1) ;;
537    8) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
538       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
539       physz=$(expr ${level} - 1) ;;
540    12) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 3)
541        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
542        physz=$(expr ${level} - 1) ;;
543    16) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
544        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
545        physz=$(expr ${level} - 1) ;;
546    20) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
547        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 5)
548        physz=$(expr ${level} - 1) ;;
549    24) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
550        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 6)
551        physz=$(expr ${level} - 1) ;;
552    32) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
553        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8)
554        physz=$(expr ${level} - 1) ;;
555    64) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8)
556        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8)
557        physz=$(expr ${level} - 1) ;;
558    128) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8)
559        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 16)
560        physz=$(expr ${level} - 1) ;;
561    *) echo not supported ; exit
562  esac
563
564  # change this if you change num_soil_layers in WRF
565  # -- default is 10
566  if [[ "${phys}" == "newphys_" ]]
567  then
568     soilsize=18 ## nouvelle physique
569  else
570     soilsize=10
571  fi
572
573  # GCM environment variables
574  #--------------------------
575  export LMDGCM=$PWD
576  export LIBOGCM=$PWD/libo
577
578  # generate the appropriate dimphys
579  #---------------------------------
580  cd libf/phymars
581  \rm dimphys.h 2> /dev/null
582  physize=$(expr ${physx} \* ${physy})
583  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
584  head -15 dimphys.h
585     ###
586     ### TEST new new phys
587     if [[ "${phys}" == "newphys_" ]]
588     then
589       touch callkeys.h.meso 
590         ln -sf meso_callkeys.h callkeys.h
591       #touch dustlift.F.meso
592       #  ln -sf meso_dustlift.F dustlift.F  ## attention avec "ancienne nouvelle physique"
593       touch readtesassim.F90.meso
594         ln -sf meso_readtesassim.F90 readtesassim.F90  ## attention idem
595       touch gr_fi_dyn.F.lien
596         ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger ## attention idem
597     ###############################
598     ###############################
599\rm scatterers.h
600cat << EOF > scatterers.h
601!-----------------------------------------------------------------------
602!   INCLUDE 'scatterers.h'
603!
604! Number of kind of tracer radiative properties
605! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
606! (ex: naerkind=1 if you use one dust mode without ice ...)
607! (ex: naerkind=2 if you use one dust mode and active ice ...)
608!-----------------------------------------------------------------------
609
610      integer, parameter :: naerkind=${scat}
611
612!-----------------------------------------------------------------------
613EOF
614     ###############################
615     ###############################
616     fi
617     ###
618     ###
619  cd ../..
620
621  # prepare for nesting
622  #---------------------
623  cd libf
624  duplicate${dom} 2> /dev/null
625  cd ..
626
627  # compile physics
628  #--------------------------
629  \rm libf/grid/dimensions.h 2> /dev/null
630  \rm -rf libo/* 2> /dev/null
631  echo 1. compiling LMD physics ...
632  echo compilation info in:
633  echo $PWD/libo/log_compile_phys
634
635  if [ ${debug} -ne 0 ]
636  then
637    echo 'DEBUG DEBUG DEBUG DEBUG'
638    nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
639  else
640    nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
641  fi
642  echo ... done
643        # clean the duplicate routines
644        cd libf
645        duplicate1 2> /dev/null
646        cd ..
647
648  # merge LMD executables in one lib
649  #--------------------------------------
650  cd libo
651  mkdir temp
652  #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp
653  cp -f LINUX*/*.a temp
654  cd temp
655  ar x libbibio.a
656  ar x libphymars.a
657  ar x libaeronomars.a
658  \rm *.a
659  ar r liblmd.a *
660  cp -f liblmd.a ..
661  cd ..
662  \rm -r temp
663  nm liblmd.a > liblmd_content
664  # finish merge
665  cd ..
666
667  # save a copy
668  #--------------
669  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}_${scat}
670  echo '****************************************'
671
672  # ok
673  #----
674  cd ..
675
676  # manage nest includes in module_lmd_driver.F
677  #----
678  cp call_meso_inifis$dom.inc call_meso_inifis.inc
679  cp call_meso_physiq$dom.inc call_meso_physiq.inc
680
681
682fi
683##################################################
684# END compile physics
685##################################################
686
687#------------------
688# compile WRF
689#------------------
690if [ ${justphys} -eq 0 ]
691then
692
693  echo 2. compiling WRF dynamical core ...
694
695  if [[ "${phys}" == "nophys_" ]]
696  then
697   echo 'NO LMD PHYSICS included'
698  else
699   if [[ ! ( -f "call_meso_physiq.inc" ) ]]
700   then
701    echo 'did you compile the physics ? no call_meso_physiq.inc !'
702    exit
703   fi
704  fi
705
706  # be sure to compile with the most recent physics
707  touch phys/module_lmd_driver.F
708
709  # talk to user
710  echo '>>> compiling ... this may be long ... <<<'
711  echo check progress in:
712  echo $PWD/log_compile
713  echo check possible errors in:
714  echo $PWD/log_error
715 
716  # compile ...
717  case ${config} in
718    '')         compile em_real > log_compile 2> log_error
719                    # save executables 
720                    cd main
721                      if [[ -f real.exe ]]
722                      then
723                        echo 'Looks good ! real.exe is here...'
724                      fi
725                      if [[ -f wrf.exe ]]
726                      then
727                        echo 'Looks good ! wrf.exe is here...'
728                      fi
729                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
730                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
731                    cd ..  ;;
732    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
733                    echo '>>> YOUR CONFIG IS : '${config}
734                    compile em_quarter_ss > log_compile 2> log_error
735                    # save executables 
736                    cd main
737                      if [[ -f ideal.exe ]]
738                      then
739                        echo 'Looks good ! ideal.exe is here...'
740                      fi
741                      if [[ -f wrf.exe ]]
742                      then
743                        echo 'Looks good ! wrf.exe is here...'
744                      fi
745                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
746                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
747                    cd ..  ;;
748    'les')          echo '>>> YOUR CONFIG IS : '${config}
749                    mkdir 'test/em_les' 2> /dev/null                   
750                    compile em_les > log_compile 2> log_error
751                    # save executables 
752                    cd main
753                      if [[ -f ideal.exe ]]
754                      then
755                        echo 'Looks good ! ideal.exe is here...'
756                      fi
757                      if [[ -f wrf.exe ]]
758                      then
759                        echo 'Looks good ! wrf.exe is here...'
760                      fi
761                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
762                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe
763                    cd ..  ;;
764    *)              echo not supported... please use ; echo ideal les ; exit ;;
765  esac
766  echo '*******last lines from log_error*********'
767  tail -n 20 log_error
768fi
769
770  # the end
771  echo '****************************************'
772  echo 'done.'
773  echo '****************************************'
774  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}
775  mv last ../../
776
777  # add here specific messages
778  if [[ "${dom}" != "1" ]]
779  then
780  nest=$(expr ${lon} + 4)
781  echo NB: in namelist.input, please set:
782  echo '
783  max_dom = '$dom'
784  s_we    = 1,1,
785  e_we    = '$lon','$nest',
786  s_sn    = 1,1,
787  e_sn    = '$lat','$nest',
788  s_vert  = 1,1,
789  e_vert  = '$level','$level','
790  fi
791
Note: See TracBrowser for help on using the repository browser.