source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1228

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

MESOSCALE. cf. previous commit, same principle. now everything works.

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