source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1408

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

changed makemeso to compile NOPHYS case with the regular LES case. should allow subsequent removal of the LESnophys_ folder (after checking that everything was transferred)

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