source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1212

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

LMDZ.MARS + MESOSCALE

A quite major commit, at least for MESOSCALE.
In a word: any ngrid deserves to be free.

  • no need to recompile when changing number of horizontal grid points or number of processors
  • latest version of LMDZ.MARS physics can be used
  • WARNING! Nesting is still yet to be fixed (since r1027)

Also some small bug fixes to LMDZ.MARS.

Changes in LMDZ.MARS


--> fixed a potential bug in thermal plume model because zlmax was computed both in thermcell_main_mars and calltherm_interface... so made it an OUT argument of calltherm_interface. also: changed the name to limz. and added precompiling flags to avoid the use of planetwide in MESOSCALE. in MESOSCALE we just go high enough (nlayer-5) and do not care about computational cost (although we certainly gain from not using MAXVAL).
--> moved allocations upward in inifis. does not change anything for GCM, but make MESOSCALE modifications simpler, and overall make inifis better organized: first allocations, then reading callphys.def file.
--> added precompiling flags around lines that are both useless for MESOSCALE (notably I/O) and recently adapted to parallel computations in the GCM
--> tidied up what is MESOSCALE vs. GCM in surfini

Changes in MESOSCALE


--> changed makemeso to allow dynamically set nx ny nprocs
--> changed makemeso to remove links to Fortran code adapted to parallel GCM and useless for mesoscale
--> changed ngridmx to ngrid in inifis includes

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