source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 1724

Last change on this file since 1724 was 1724, checked in by mlefevre, 7 years ago

Add of Venus mesoscale structure + update of Venus LES

  • Property svn:executable set to *
File size: 40.3 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='real'
31donotcompilephys=0
32justphys=0
33debug=0
34fresh_start=0
35phys="mars_lmd"
36scenario=""
37from_scratch=0
38
39while getopts "drc:njhgp:fs:xe" options; do
40  case $options in
41   d ) donotcompile=1;;       ## just to check the compile folder
42   r ) donotallow=1;;         ## allow only known config (useful with 'makemeso < last')
43   c ) config="${OPTARG}";;   ## idealized cases
44   n ) donotcompilephys=1;;   ## do not recompile physics
45   j ) justphys=1;;           ## just compile LMD physics
46   g ) debug=1;;              ## debug mode
47   p ) phys="${OPTARG}";;     ## choose physics
48   f ) fresh_start=1;;        ## a fresh start
49   e ) from_scratch=1;;       ## a fresh start with a completely new folder
50   s ) scenario="${OPTARG}";; ## a specific scenario (with precompiling flags)
51   x ) donotcompile=1;phys="void_lmd_new";donotcompilephys=1;; ## a case with no LMD physics included
52   h ) echo "
53# Use:   
54#
55# makemeso                   ## basic use (real-case configuration)
56#
57# makemeso -d                ## no compilation, just check the name of the compile folder
58#
59# makemeso -c ideal          ## idealized mode (convective cell, mountain wave, etc...)
60# makemeso -c les            ## large-eddy simulations mode based on WRFV3
61#
62# makemeso -n                ## do not recompile LMD physics (must have been compiled before)
63#
64# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
65# makemeso -r < last         ## basic use + skip questions + only known config
66# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
67#
68# makemeso -j                ## just compile the LMD physics
69#
70# makemeso -g                ## debug mode
71#
72# makemeso -h                ## display options
73#
74# makemeso -p mars_lmd_new   ## choose physics
75#             venus_lmd_new
76#             generic_lmd_new
77#             titan_lmd_new
78#
79# makemeso -f                ## fresh start [clean -a]
80#
81# makemeso -e                ## a completely new recompile with erasing the WHOLE compiling folder
82#
83# makemeso -s DUSTSTORM      ## a specific scenario (with precompiling flags)
84#
85# makemeso -x                ## a case with no LMD physics included
86" ; exit ;;
87  esac
88done   
89
90#--------------
91# talk w/ user
92#--------------
93  echo '****************************************'
94  echo ' LMD Mesoscale Model Compiler. Welcome.'
95  echo '****************************************'
96  if [[ "${phys}" == *"new"* ]]
97  then
98    echo '*********** PHYSICS: ' ${phys}
99    echo '****************************************'
100  fi
101  # computer
102  uname -a | grep x86_64 > /dev/null
103  if [[ "$?" == 0 ]]
104  then
105    machine='64'
106  else
107    machine='32'
108  fi
109  # compiler
110  echo "Supported compiler options are "
111  echo "       <1> pgf90"
112  echo "       <2> g95"
113  echo "       <3> pgf90 + mpi"
114  echo "       <4> ifort"
115  echo "       <5> ifort + mpi"
116  echo "       <7> xlf + mpi (IBM AIX)"
117  echo "Your choice ?" ; read reply
118  case ${reply} in
119    1) compilo='pgf' ; numproc=1 ;;
120    2) compilo='g95' ; numproc=1 ;;
121    3) compilo='mpi'
122       if [[ "${WHERE_MPI}" = "" ]]
123       then
124         echo Please initialize the variable WHERE_MPI in your environnement
125         exit
126       fi ;;
127    4) compilo='ifort' ; numproc=1 ;;
128    5) compilo='mpifort' ;;
129    7) compilo='mpixlf' ;;
130    ### for tests
131   99) compilo='gnu' ; numproc=1 ;;
132    *) echo not supported by this script ; exit ;;
133  esac
134  # number of processors
135  if [[ "${phys}" == *"new"* ]]
136  then
137   numproc=999
138  else
139   case ${reply} in
140    3) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
141    5) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
142    7) echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;;
143   esac
144  fi
145
146  # dimensions
147  if [ ${donotcompile} -eq 0 ]
148  then   
149  # ngrid: now dynamically set in newphys 03/2014
150   if [[ "${phys}" == *"new"* ]]
151   then
152      lon=999
153      lat=999
154      level=999
155   else
156      echo Grid points in longitude ? ; read lon
157      echo Grid points in latitude ? ; read lat
158      echo Number of vertical levels ? ; read level
159   fi
160  fi
161  echo Number of domains ? ; read dom
162
163###PB lecture dom si < last
164
165    case ${dom} in
166       1) single='_single' ;;
167       *) single='_nest' ;;
168    esac
169      if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
170      then
171           single=''
172      fi
173
174testflag=''
175####
176#testflag='_test'
177####
178
179    conf_wrf="${phys}_${config}${scenario}_${compilo}_${machine}${single}${testflag}"
180
181    if [ ${debug} -eq 1 ]
182    then
183     conf_wrf="debug_${conf_wrf}"
184    fi
185
186    \rm what_folder 2> /dev/null
187    echo ${conf_wrf} > what_folder
188         if [ ${donotcompile} -eq 0 ]
189         then
190            ##\rm what_folder 2> /dev/null
191            ##echo '**********************'
192            ##echo '*** Your folder is ...'
193            ##echo '**********************'
194            ##echo ${conf_wrf} | tee what_folder
195            ##cat what_folder
196            ##echo ${conf_wrf} > what_folder
197            ##echo ${reply} > what_compilo
198            ##echo ${numproc} > what_numproc
199            #if [[ "${phys}" != "nophys_" ]]
200            #then
201            #  exit
202            #fi
203         #else
204            # tracers: now dynamically set in newphys 09/2013
205            if [[ "${phys}" == *"new"* ]]
206            then
207              tra=999
208            else
209              echo Number of tracers ? ; read tra
210              if [ ${tra} -eq 0 ]
211              then
212                tra=1   
213              fi
214            fi
215         fi
216  # 'from scratch' case
217  if [ ${from_scratch} -eq 1 ]
218  then
219      echo "***** I ERASE THE FOLDER "${conf_wrf}
220      \rm -rf ${conf_wrf}
221  fi
222  # folder
223
224  mkdir ${conf_wrf} 2> /dev/null
225  if [[ "$?" == 0 ]]
226  then
227    echo new folder ... link sources
228    ###############################################
229     echo ${phys}
230     ./SRC/SCRIPTS/copy_model -p ${phys} -c ${config}
231     mv zeWRFV2 ${conf_wrf}/WRFV2
232    ###############################################
233     if [[ "${phys}" == *"new"* ]]
234     then
235      cd ${conf_wrf}/WRFV2
236        if [[ "${config}" != "les" ]]
237        then
238           cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
239        else
240           cp -L ../../SRC/LES/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
241        fi
242      cd phys
243      ln -sf module_lmd_driver.F.new module_lmd_driver.F
244      cd ..
245
246     # remove files adapted to parallel GCM and useless for mesoscale
247     #cd mars_lmd
248     #cd libf/phymars
249     #\rm tabfi* soil_settings* phyetat0* phyredem* iostart* writediagfi* mkstat* writediagsoil* eofdump* wstats* inistats* mod_*
250     #\rm iniphysiq* init_phys_lmdz* comgeomphy* planetwide_mod*
251     #mv ../dyn3d/control_mod.F90 .
252     #cd ../..
253     #cd ..
254
255    else
256         if [[ "${config}" == "les" ]]
257         then
258           #### NB: With physics: LES folder // Without physics : LESnophys_ folder
259           #### ---- because differences in 'modif' folder ----
260           #sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g SRC/SCRIPTS/copy_model > copy_model_tmp
261           sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g SRC/SCRIPTS/copy_model > copy_model_tmp
262         else
263           cp SRC/SCRIPTS/copy_model copy_model_tmp
264         fi   
265     chmod 755 copy_model_tmp
266     ./copy_model_tmp
267     \rm copy_model_tmp
268     mv zeWRFV2 ${conf_wrf}/WRFV2
269     cd ${conf_wrf}/WRFV2
270     cd Registry ; ./Registry.bash ; cd ..
271     fi
272          #### sparadrap consequent a l'utilisation de copy_model pour les liens
273          #### -- car alors il manque fftpack
274          if [[ "${config}" == "les" ]]
275          then
276            cp ../../SRC/LES/correcfft ./
277            ./correcfft
278            \rm correcfft
279          fi
280  else
281    cd ${conf_wrf}/WRFV2
282    if [ ${fresh_start} -eq 1 ]
283    then
284      echo '*** FRESH START, I clean everything'
285      ### clean the whole place 
286      clean -a > /dev/null 2> /dev/null
287      ### get a possibly modified registry !
288      if [[ "${phys}" == *"new"* ]]
289      then
290          cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
291      else
292          cp ../../SRC/WRFV2/Registry/Registry.EM Registry/
293      fi
294      if [[ "${config}" == "les" ]]
295      then
296        cp ../../SRC/LES/WRFV2/Registry/Registry.EM Registry/
297      fi
298      ### ensure the model will be recompiled from scratch with correct registry
299      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
300#     answer='y' ## a voir... pas si sur
301#    else
302#            if [[ "${phys}" != "nophys_" ]]
303#            then
304#      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
305#      case ${answer} in
306#        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
307#        *) answer='no' ;;
308#      esac
309#            fi
310    fi
311  fi
312
313  # summary
314  echo '**********************'
315  echo '*** Your folder is ...'
316  echo '**********************'
317  echo ${conf_wrf}
318  echo '**********************'
319  echo '****************************************'
320  echo so ...
321  echo your computer is ${machine} bits
322  echo ${compilo} is your compiler
323       if [[ "${compilo}" = "mpi" ]]
324       then
325         echo MPICH is in ${WHERE_MPI}
326       fi
327  echo you have ${dom} domains
328  if [[ "${phys}" == *"new"* ]]
329  then
330   echo number of processors can be changed without recompiling
331   echo x points can be changed without recompiling
332   echo y points can be changed without recompiling
333   echo z points can be changed without recompiling
334   echo number of tracers can be changed without recompiling
335  else
336   echo you will use ${numproc} processors
337   echo you have ${lon} x points
338   echo '         '${lat} y points
339   echo '         '${level} z points
340   echo '         '${tra} tracers
341  fi
342  echo '****************************************'
343  # save answer
344  \rm last 2> /dev/null
345  touch last
346  echo ${reply} >> last
347  if [[ "${phys}" != *"new"* ]]
348  then
349    if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
350    then
351     echo ${numproc} >> last
352    fi
353    echo ${lon} >> last
354    echo ${lat} >> last
355    echo ${level} >> last
356  fi
357  echo ${dom} >> last
358  if [[ "${phys}" != **"new"* ]]
359  then
360   echo ${tra} >> last
361  fi
362
363#------------
364# log files
365#------------
366  \rm log_compile 2> /dev/null
367  \rm log_error 2> /dev/null
368
369#-----------------
370# configure WRF
371#-----------------
372  mv configure.wrf configure.wrf.bak 2> /dev/null
373  ########################
374  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
375
376         #### in this case options are different because for LES, WRFV3 is used
377         if [[ "${config}" == "les" ]]
378         then
379         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
380         fi
381
382  case ${conf_wrf_forall} in
383
384     #######LES-specific (WRFV3-based) -- previously in 'makeles'
385     #######
386
387     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
388                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
389                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
390                       sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
391                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
392                       then
393            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
394            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
395            #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
396            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
397            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
398                       else
399            #sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
400            #sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
401            #### OPENMPI
402            sed s+"mpif90 -f90=\$(SFC)"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
403            sed s+"mpicc -cc=\$(SCC)"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
404                       fi
405                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
406                          ### pas forcement necessaire ici mais OK
407                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
408                       \rm conf > /dev/null ;;
409
410     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
411                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
412                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
413                       if [[ "${phys}" != *"void"* ]]
414                       then
415                         sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
416                         #sed s+"O3"+"O3"+g configure.wrf > yeah ; mv -f yeah configure.wrf
417                       else
418                         sed s+"-lnetcdf"+"-lnetcdf $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
419                       fi
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+"-lnetcdf -lnetcdff"+"-lnetcdf -lnetcdff -L../mars_lmd/libo -llmd"+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 physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
441                       sed s+"-L../$phys/libo -llmd"+"-L../$phys/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 physics.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 physics.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../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
453                       sed -f physics.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 physics.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 physics.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 physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
467                         #sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
468                       sed -f physics.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../$phys/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 physics.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                       sed s+"-O1"+"-O1 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
489                       sed s+"-O2"+"-O2 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
490                       sed s+"-O3"+"-O3 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
491                       if [ ${debug} -ne 0 ]   # not working for xlf!
492                             then
493                             echo 'DEBUG DEBUG DEBUG DEBUG'
494                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
495                             mv -f yeah configure.wrf
496                       fi
497                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
498                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
499                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
500                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
501                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
502                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
503                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
504                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
505                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
506                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
507                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
508                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
509                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
510                         ### necessary even if mpi-selector is used (no need in makegcm though)
511                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
512                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
513                         ## !!! NETCDF must be defined
514                         if [[ "${phys}" != *"void"* ]]
515                           sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a $NETCDF/lib/libnetcdff.a"+g configure.wrf > yeah
516                         else
517                           sed s+"-lesmf_time"+"-lesmf_time $NETCDF/lib/libnetcdf.a $NETCDFF/lib/libnetcdff.a"+g configure.wrf > yeah
518                         fi
519                         mv -f yeah configure.wrf
520                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
521                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
522                         mv -f yeah configure.wrf ;;
523                     # MPICH, 64 bits, no nesting / nesting
524     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
525                       echo 3 | configure > log_compile 2> log_error
526                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
527                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
528                       sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
529                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
530                       #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
531                                #| sed s+"fastsse"+"fast"+g > yeah
532                       mv -f yeah configure.wrf ;;
533                       #    #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
534                       #    ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
535                       #    ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
536                       #sed s+"-fastsse"+"-O3 -tp=nehalem-64 -fastsse -Mscalarsse -Mvect=sse -Mipa=fast"+g configure.wrf > yeah
537                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
538                       #sed s+"-fastsse"+""+g configure.wrf > yeah
539                       #sed s+"-fastsse"+"-fast"+g configure.wrf > yeah
540                       #sed s+"-fastsse"+"-Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed"+g configure.wrf > yeah
541                       #mv -f yeah configure.wrf ;;
542                     # MPICH, 64 bits, OK with periodic BC but no positive definite
543     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
544                       echo 2 | configure > log_compile 2> log_error
545                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
546                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
547                       mv -f yeah configure.wrf ;;
548                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
549     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
550                       echo 3 | configure > log_compile 2> log_error
551                       sed -f physics.sed configure.wrf > yeah
552                       mv -f yeah configure.wrf ;;
553                     # ANYTHING ELSE
554     *)                echo NO PRESETS ...
555                       if [ ${donotallow} -eq 0 ] 
556                       then
557                         configure
558                       else
559                         # problem when an input file is used
560                         echo 'please cd to '$PWD' and type ./configure' 
561                         exit   
562                       fi ;;
563  esac
564  ########################
565
566
567  ### here a case structure would be great
568
569  if [[ "${phys}" == *"new"* ]]
570  then
571     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
572     then
573       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
574     else
575       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
576     fi
577     mv -f yeah configure.wrf
578  fi
579
580        ### SCENARIO SCENARIO SCENARIO
581        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment?
582        then
583          # precompiling flag in WRF part
584          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
585          mv -f yeah configure.wrf
586          # precompiling flag in LMD part
587          cd $phys
588          cp -Lrf makegcm_${compilo} yeah
589          \rm makegcm_${compilo}
590          sed s+"-DMESOSCALE"+"-D${scenario} -DMESOSCALE"+ yeah > makegcm_${compilo}
591          chmod 755 makegcm_${compilo}
592          \rm yeah
593          cd ..
594        fi
595
596  ################
597  #if [[ "${phys}" == "nophys_" ]]
598  #then
599  #   if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
600  #   then
601  #     sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
602  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
603  #   else
604  #     ### not tested yet but should be working 
605  #     echo CAUTION CAUTION CAUTION NOT FULLY TESTED
606  #     sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
607  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
608  #   fi
609  #fi
610  ################
611
612  if [[ "${phys}" == *"venus"* ]]
613  then
614    sed s+"LIB_BUNDLED     = "+"LIB_BUNDLED     =    /usr/lib64/liblapack.so  \ "+g configure.wrf > yeah ; mv -f yeah configure.wrf
615    #sed s+"RWORDSIZE       =       "+"RWORDSIZE       =       8 # "+g configure.wrf > yeah ; mv -f yeah configure.wrf
616    #sed s+"PROMOTION       =       -i4"+'PROMOTION       = -real-size "expr 8 \* $(RWORDSIZE)" -i4'+g configure.wrf > yeah ; mv -f yeah configure.wrf
617    #sed s+"PROMOTION       =       -i4"+"PROMOTION       =       -real_size 64 -i4"+g configure.wrf > yeah ; mv -f yeah configure.wrf
618    #sed s+"-DLWORDSIZE=4 "+"-DLWORDSIZE=8 "+g configure.wrf > yeah ; mv -f yeah configure.wrf
619    #sed s+"-DIWORDSIZE=4 "+"-DIWORDSIZE=8 "+g configure.wrf > yeah ; mv -f yeah configure.wrf
620    #sed s+"FCBASEOPTS      ="+"FCBASEOPTS      = -r8 "+g configure.wrf > yeah ; mv -f yeah configure.wrf
621    #sed s+"-fp-model precise "+"-fpconstant -fp-model precise "+g configure.wrf > yeah ; mv -f yeah configure.wrf
622  fi
623
624  if [ ${debug} -ne 0 ]   # not working for xlf!
625  then
626    echo 'DEBUG DEBUG DEBUG DEBUG'
627    sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
628    #sed s+"# -g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
629    #sed s+"# -g"+"-g"+g configure.wrf > yeah
630    mv -f yeah configure.wrf
631  fi
632
633  if [[ "${phys}" == *"prescribed"* ]]
634  then
635     donotcompilephys=1
636  fi   
637
638#exit
639##################################################
640# compile physics
641##################################################
642if [ ${donotcompilephys} -eq 0 ] #|| [[ "${phys}" != *"prescribed"* ]]
643then
644
645 cd $phys/
646
647 if [[ "${phys}" == *"new"* ]]
648 then
649  divx=1
650  divy=1
651 else
652  # required size
653  #----------------
654  case ${numproc} in
655      1) divx=1 ; divy=1  ;;
656      2) divx=1 ; divy=2  ;;
657      4) divx=2 ; divy=2  ;;
658      6) divx=2 ; divy=3  ;;
659      8) divx=2 ; divy=4  ;;
660     12) divx=3 ; divy=4  ;;
661     16) divx=4 ; divy=4  ;;
662     20) divx=4 ; divy=5  ;;
663     24) divx=4 ; divy=6  ;;
664     32) divx=4 ; divy=8  ;;
665     64) divx=8 ; divy=8  ;;
666    128) divx=8 ; divy=16 ;;
667      *) echo not yet supported ; exit ;;
668  esac
669 fi
670  physx=$(expr ${lon} - 1)
671  restex=$(expr ${physx} \% ${divx})   
672  physy=$(expr ${lat} - 1)
673  restey=$(expr ${physy} \% ${divy})
674  if [[ ${restex} != 0 || ${restey} != 0 ]]
675  then
676     echo nx-1 shall be divided by ${divx}
677     echo ny-1 shall be divided by ${divy}
678     exit
679  fi
680  physx=$(expr ${physx} \/ ${divx})
681  physy=$(expr ${physy} \/ ${divy})
682  physz=$(expr ${level} - 1)
683
684  # change this if you change num_soil_layers in WRF
685  # -- default is 10
686  if [[ "${phys}" == *"new"* ]]
687  then
688     soilsize=18 ## nouvelle physique. ne sert a rien ici. voir comsoil.
689  else
690     soilsize=10
691  fi
692
693  # GCM environment variables
694  #--------------------------
695  export LMDGCM=$PWD
696  export LIBOGCM=$PWD/libo
697
698  # generate the appropriate dimphys
699  #---------------------------------
700  if [[ "${phys}" == *"mars"* ]]
701  then
702    cd libf/phymars
703  elif [[ "${phys}" == *"venus"* ]]
704  then
705    cd libf/phyvenus
706  elif [[ "${phys}" == *"generic"* ]]
707  then
708    cd libf/phystd
709  elif [[ "${phys}" == *"titan"* ]]
710  then
711    cd libf/phytitan
712  fi
713  \rm dimphys.h 2> /dev/null
714  #if [[ "${phys}" == "newphys_" ]]
715  #then
716  #  ln -sf ../../meso_dimphys.h_ref . ## ne sert plus !!
717  #else
718  if [[ "${phys}" != "newphys_" ]]
719  then
720    physize=$(expr ${physx} \* ${physy})
721    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
722    head -15 dimphys.h
723  fi
724     ### TEST new new phys
725     #if [[ "${phys}" == "newphys_" ]]
726     #then
727     #  touch gr_fi_dyn.F.lien
728     #    ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
729     ###############################
730     ###############################
731     ###############################
732     #fi
733     ###
734     ###
735  cd ../..
736
737  # prepare for nesting
738  #---------------------
739  cd libf
740  duplicate${dom} 2> /dev/null
741  cd ..
742
743  # compile physics
744  #--------------------------
745  \rm libf/grid/dimensions.h 2> /dev/null
746  \rm -rf libo/* 2> /dev/null
747  echo 1. compiling LMD physics ...
748  echo compilation info in:
749  echo $PWD/libo/log_compile_phys
750 
751  if [ ${debug} -ne 0 ] 
752  then
753    if [[ "${phys}" == *"mars"* ]]
754    then
755      echo 'DEBUG DEBUG DEBUG DEBUG'
756      nohup makegcm_${compilo} debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
757    elif [[ "${phys}" == *"venus"* ]]
758    then
759      echo 'DEBUG DEBUG DEBUG DEBUG'
760      nohup ./makelmdz -debug -full -p venus -d 181 rcm1d -arch X64_MESU -cpp MESOSCALE | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
761    elif [[ "${phys}" == *"generic"* ]]
762    then
763      echo 'DEBUG DEBUG DEBUG DEBUG'
764      nohup ./makegcm_ifort -debug -t ${tra} -p std -b 36x32 -d 25 rcm1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
765      #nohup ./makegcm_ifort -t ${tra} -p std -b 36x32 -d 25 rcm1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
766    fi
767  else
768    if [[ "${phys}" == *"mars"* ]]
769    then
770      nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
771    elif [[ "${phys}" == *"venus"* ]]
772    then
773      nohup ./makelmdz -full -p venus -d 51 rcm1d -arch linux-ifort_meso -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on /u/ and /planeto/
774      nohup ./makelmdz -p venus -d 51 rcm1d -arch linux-ifort_meso -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
775      #nohup ./makelmdz -full -p venus -d 51 rcm1d -arch CICLADifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on CICLAD
776      #nohup ./makelmdz -p venus -d 51 rcm1d -arch CICLADifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
777      #nohup ./makelmdz -full -p venus -d 51 rcm1d -arch X64_MESU -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #on MESU
778      #nohup ./makelmdz -p venus -d 51 rcm1d -arch X64_MESU -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
779      #nohup makelmdz -full -p venus -d 51 rcm1d -arch X64_OCCIGEN -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #on OCCIGEN
780      #nohup makelmdz -p venus -d 51 rcm1d -arch X64_OCCIGEN -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
781    fi
782  fi
783  echo ... done
784        # clean the duplicate routines
785        cd libf
786        duplicate1 2> /dev/null
787        cd ..
788
789  # merge LMD executables in one lib
790  #--------------------------------------
791  cd libo
792  mkdir temp
793  if [[ ("${phys}" == *"venus"*) ]]
794  then
795    cp -f linux*/*.a temp/ # on /u/ and /planeto/
796    #cp -f /home/mlefevre/modipsl/lib/libioipsl.a temp/ #on CICLAD
797    #cp -f X64*/*.a temp #on MESU and OCCIGEN
798    cp -f ../ioipsl/libioipsl.a temp/
799  else
800    cp -f LINUX*/*.a temp/
801  fi
802  cd temp
803  if [[ "${phys}" == *"mars"* ]]
804   then   
805   ar x libbibio.a
806   ar x libphymars.a
807   ar x libaeronomars.a
808  elif [[ "${phys}" == *"venus"* ]]
809  then
810   ar x libphyvenus.a
811   ar x libmisc.a
812   ar x libphy_common.a
813   ar x libioipsl.a
814  fi
815  \rm *.a
816  ar r liblmd.a *
817  cp -f liblmd.a ..
818  cd ..
819  \rm -r temp
820  nm liblmd.a > liblmd_content
821  # finish merge
822  cd ..
823  echo ${phys}
824  if [[ "${phys}" == *"new"* ]]
825  then
826    if [[ "${phys}" == *"mars"* ]]
827    then
828      # include modules for interfacing
829      mv  *.mod ../inc/
830    elif  [[ ("${phys}" == *"venus"*)]]
831    then
832      mv  ./libo/linux*/*.mod ../inc/ # on /u/ and /planeto/
833      #mv  ./libo/CICLAD*/*.mod ../inc/ # on CICLAD
834      #mv  ./libo/X64*/*.mod ../inc/ # on MESU and OCCIGEN
835      cp -f ./ioipsl/*.mod ../inc/
836    fi
837  fi
838
839
840  # save a copy
841  #--------------
842  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}
843  echo '****************************************'
844
845  # ok
846  #----
847  cd ..
848
849  # manage nest includes in module_lmd_driver.F
850  #----
851  cp call_meso_inifis$dom.inc call_meso_inifis.inc
852  cp call_meso_physiq$dom.inc call_meso_physiq.inc
853
854
855fi
856##################################################
857# END compile physics
858##################################################
859
860#------------------
861# compile WRF
862#------------------
863if [ ${justphys} -eq 0 ]
864then
865
866  echo 2. compiling WRF dynamical core ...
867
868  #if [[ "${phys}" == "nophys_" ]]
869  #then
870  # echo 'NO LMD PHYSICS included'
871  #else
872  # if [[ ! ( -f "call_meso_physiq.inc" ) ]]
873  # then
874  #  echo 'did you compile the physics ? no call_meso_physiq.inc !'
875  #  exit
876  # fi
877  #fi
878
879  # be sure to compile with the most recent physics
880  touch phys/module_lmd_driver.F
881
882  # talk to user
883  echo '>>> compiling ... this may be long ... <<<'
884  echo check progress in:
885  echo $PWD/log_compile
886  echo check possible errors in:
887  echo $PWD/log_error
888 
889  # compile ...
890  echo '>>> YOUR CONFIG IS : '${config}
891  case ${config} in
892    'real')         ./compile em_real > log_compile 2> log_error
893                    # save executables 
894                    cd main
895                      if [[ -f real.exe ]]
896                      then
897                        echo 'Looks good ! real.exe is here...'
898                      fi
899                      if [[ -f wrf.exe ]]
900                      then
901                        echo 'Looks good ! wrf.exe is here...'
902                      fi
903                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
904                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
905                    cd ..  ;;
906    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
907                    #echo '>>> YOUR CONFIG IS : '${config}
908                    ./compile em_quarter_ss > log_compile 2> log_error
909                    # save executables 
910                    cd main
911                      if [[ -f ideal.exe ]]
912                      then
913                        echo 'Looks good ! ideal.exe is here...'
914                      fi
915                      if [[ -f wrf.exe ]]
916                      then
917                        echo 'Looks good ! wrf.exe is here...'
918                      fi
919                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
920                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
921                    cd ..  ;;
922    'les')          #echo '>>> YOUR CONFIG IS : '${config}
923                    mkdir 'test/em_les' 2> /dev/null                   
924                    ./compile em_les > log_compile 2> log_error
925                    # save executables 
926                    cd main
927                      if [[ -f ideal.exe ]]
928                      then
929                        echo 'Looks good ! ideal.exe is here...'
930                      fi
931                      if [[ -f wrf.exe ]]
932                      then
933                        echo 'Looks good ! wrf.exe is here...'
934                      fi
935                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
936                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
937                    cd ..  ;;
938    *)              echo not supported... please use ; echo ideal les ; exit ;;
939  esac
940  echo '*******last lines from log_error*********'
941  tail -n 20 log_error
942fi
943
944  # the end
945  echo '****************************************'
946  echo 'done.'
947  echo '****************************************'
948  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}
949  mv last ../../
950  svn info ../../ > ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.svn.info
951
952
953
954  # link latest compiled folder as LATEST
955  cd ../../
956  rm -rf LATEST
957  ln -sf ${conf_wrf} LATEST
958
959  # add here specific messages
960  if [[ "${dom}" != "1" ]]
961  then
962  nest=$(expr ${lon} + 4)
963  echo NB: in namelist.input, please set:
964  echo '
965  max_dom = '$dom'
966  s_we    = 1,1,
967  e_we    = '$lon','$nest',
968  s_sn    = 1,1,
969  e_sn    = '$lat','$nest',
970  s_vert  = 1,1,
971  e_vert  = '$level','$level','
972  fi
973
974
Note: See TracBrowser for help on using the repository browser.