source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1038

Last change on this file since 1038 was 1038, checked in by aslmd, 11 years ago

MESOSCALE
LMDZ.MARS

--> Performed the necessary modifications for dynamic tracers

to work with the mesoscale model (new physics).

--> Added precompiling flag MESOSCALE around pressure modifications

done in revision 883. This makes the mesoscale model become crazy.

--> Added an option -e in makemeso to erase a configuration and start over.

NOTE
--> not sure recent versions (rev>1000) are compliant with nesting compilation.
--> use mesoscale model + new physics with caution. still not stabilized.

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