source: trunk/MESOSCALE/LMD_MM_MARS/makemeso @ 2103

Last change on this file since 2103 was 2094, checked in by jleconte, 7 years ago

Changes in makemeso and config files to compile the generic LES with gfortran. Also added def files to run a simple generic LES simulaiton in SIMU/DEF/2019_leconte-test-les

  • Property svn:executable set to *
File size: 40.5 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###path to compiled version of ioipsl on your system for generic physics
22pathioipsl='/home/leconte/script/ioipsl/modipsl/lib'
23
24##############################################################################################
25##############################################################################################
26##############################################################################################
27##############################################################################################
28
29donotcompile=0
30donotallow=0
31config='real'
32donotcompilephys=0
33justphys=0
34debug=0
35fresh_start=0
36phys="mars_lmd"
37scenario=""
38from_scratch=0
39
40while getopts "drc:njhgp:fs:xe" options; do
41  case $options in
42   d ) donotcompile=1;;       ## just to check the compile folder
43   r ) donotallow=1;;         ## allow only known config (useful with 'makemeso < last')
44   c ) config="${OPTARG}";;   ## idealized cases
45   n ) donotcompilephys=1;;   ## do not recompile physics
46   j ) justphys=1;;           ## just compile LMD physics
47   g ) debug=1;;              ## debug mode
48   p ) phys="${OPTARG}";;     ## choose physics
49   f ) fresh_start=1;;        ## a fresh start
50   e ) from_scratch=1;;       ## a fresh start with a completely new folder
51   s ) scenario="${OPTARG}";; ## a specific scenario (with precompiling flags)
52   x ) donotcompile=1;phys="void_lmd_new";donotcompilephys=1;; ## a case with no LMD physics included
53   h ) echo "
54# Use:   
55#
56# makemeso                   ## basic use (real-case configuration)
57#
58# makemeso -d                ## no compilation, just check the name of the compile folder
59#
60# makemeso -c ideal          ## idealized mode (convective cell, mountain wave, etc...)
61# makemeso -c les            ## large-eddy simulations mode based on WRFV3
62#
63# makemeso -n                ## do not recompile LMD physics (must have been compiled before)
64#
65# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
66# makemeso -r < last         ## basic use + skip questions + only known config
67# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
68#
69# makemeso -j                ## just compile the LMD physics
70#
71# makemeso -g                ## debug mode
72#
73# makemeso -h                ## display options
74#
75# makemeso -p mars_lmd_new   ## choose physics
76#             venus_lmd_new
77#             generic_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 "       <8> gfortran"
118  echo "Your choice ?" ; read reply
119  case ${reply} in
120    1) compilo='pgf' ; numproc=1 ;;
121    2) compilo='g95' ; numproc=1 ;;
122    3) compilo='mpi'
123       if [[ "${WHERE_MPI}" = "" ]]
124       then
125         echo Please initialize the variable WHERE_MPI in your environnement
126         exit
127       fi ;;
128    4) compilo='ifort' ; numproc=1 ;;
129    5) compilo='mpifort' ;;
130    7) compilo='mpixlf' ;;
131    8) 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     else
247      cd ${conf_wrf}/WRFV2
248      cd Registry ; ./Registry.bash ; cd ..
249     fi
250          #### sparadrap consequent a l'utilisation de copy_model pour les liens
251          #### -- car alors il manque fftpack
252          if [[ "${config}" == "les" ]]
253          then
254            cp ../../SRC/LES/correcfft ./
255            ./correcfft
256            \rm correcfft
257          fi
258  else
259    cd ${conf_wrf}/WRFV2
260    if [ ${fresh_start} -eq 1 ]
261    then
262      echo '*** FRESH START, I clean everything'
263      ### clean the whole place 
264      clean -a > /dev/null 2> /dev/null
265      ### get a possibly modified registry !
266      if [[ "${phys}" == *"new"* ]]
267      then
268          cp ../../SRC/WRFV2/Registry/Registry.EM.newphys Registry/Registry.EM
269      else
270          cp ../../SRC/WRFV2/Registry/Registry.EM Registry/
271      fi
272      if [[ "${config}" == "les" ]]
273      then
274        cp ../../SRC/LES/WRFV2/Registry/Registry.EM Registry/
275      fi
276      ### ensure the model will be recompiled from scratch with correct registry
277      cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd ..
278#     answer='y' ## a voir... pas si sur
279#    else
280#            if [[ "${phys}" != "nophys_" ]]
281#            then
282#      echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
283#      case ${answer} in
284#        y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
285#        *) answer='no' ;;
286#      esac
287#            fi
288    fi
289  fi
290
291  # summary
292  echo '**********************'
293  echo '*** Your folder is ...'
294  echo '**********************'
295  echo ${conf_wrf}
296  echo '**********************'
297  echo '****************************************'
298  echo so ...
299  echo your computer is ${machine} bits
300  echo ${compilo} is your compiler
301       if [[ "${compilo}" = "mpi" ]]
302       then
303         echo MPICH is in ${WHERE_MPI}
304       fi
305  echo you have ${dom} domains
306  if [[ "${phys}" == *"new"* ]]
307  then
308   echo number of processors can be changed without recompiling
309   echo x points can be changed without recompiling
310   echo y points can be changed without recompiling
311   echo z points can be changed without recompiling
312   echo number of tracers can be changed without recompiling
313  else
314   echo you will use ${numproc} processors
315   echo you have ${lon} x points
316   echo '         '${lat} y points
317   echo '         '${level} z points
318   echo '         '${tra} tracers
319  fi
320  echo '****************************************'
321  # save answer
322  \rm last 2> /dev/null
323  touch last
324  echo ${reply} >> last
325  if [[ "${phys}" != *"new"* ]]
326  then
327    if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ]
328    then
329     echo ${numproc} >> last
330    fi
331    echo ${lon} >> last
332    echo ${lat} >> last
333    echo ${level} >> last
334  fi
335  echo ${dom} >> last
336  if [[ "${phys}" != **"new"* ]]
337  then
338   echo ${tra} >> last
339  fi
340
341#------------
342# log files
343#------------
344  \rm log_compile 2> /dev/null
345  \rm log_error 2> /dev/null
346
347#-----------------
348# configure WRF
349#-----------------
350  mv configure.wrf configure.wrf.bak 2> /dev/null
351  ########################
352  conf_wrf_forall="${compilo}_${machine}${single}${testflag}"
353
354         #### in this case options are different because for LES, WRFV3 is used
355         if [[ "${config}" == "les" ]]
356         then
357         conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}"
358         fi
359
360  case ${conf_wrf_forall} in
361
362     #######LES-specific (WRFV3-based) -- previously in 'makeles'
363     #######
364
365     lesmpi_64)        ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP]
366                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf
367                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
368                       sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
369                       if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]]
370                       then
371            echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS."
372            #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g                      configure.wrf > yeah ; mv -f yeah configure.wrf
373            #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
374            sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g                   configure.wrf > yeah ; mv -f yeah configure.wrf
375            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
376                       else
377            #sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
378            #sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
379            #### OPENMPI
380            sed s+"mpif90 -f90=\$(SFC)"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
381            sed s+"mpicc -cc=\$(SCC)"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
382                       fi
383                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
384                          ### pas forcement necessaire ici mais OK
385                          sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
386                       \rm conf > /dev/null ;;
387
388     lesmpifort_64)    ## MPI (dm) 64 bits IFORT
389                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf
390                       \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null
391                       if [[ "${phys}" != *"void"* ]]
392                       then
393                         sed s+"-lnetcdff"+"TOZTOZ"+g configure.wrf > yeah ; mv -f yeah configure.wrf
394                         # ... in case there is netcdff save it in TOZTOZ so that it is not impacted in the following sed
395                         sed s+"-lnetcdf"+"-lnetcdf -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
396                         sed s+"TOZTOZ"+"-lnetcdff"+g configure.wrf > yeah ; mv -f yeah configure.wrf
397                       else
398                         sed s+"-lnetcdf"+"-lnetcdf $NETCDF/lib/libnetcdf.a"+g   configure.wrf > yeah ; mv -f yeah configure.wrf
399                       fi
400                       sed s+"mpif90"+"$WHERE_MPI/mpif90"+g                 configure.wrf > yeah ; mv -f yeah configure.wrf
401                       sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g    configure.wrf > yeah ; mv -f yeah configure.wrf
402                       sed s+"-fastsse"+" "+g                               configure.wrf > yeah ; mv -f yeah configure.wrf
403                       sed s+"O3"+"O3 -mcmodel=large -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
404                       #sed s+"-lnetcdf -lnetcdff"+"-lnetcdf -lnetcdff -L../mars_lmd/libo -llmd"+g     configure.wrf > yeah ; mv -f yeah configure.wrf
405                       if [ ${debug} -ne 0 ]   # not working for xlf!
406                             then
407                             echo 'DEBUG DEBUG DEBUG DEBUG'
408                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
409                             mv -f yeah configure.wrf
410                       fi
411                       \rm conf > /dev/null ;;
412
413     lesgnu_64_single) echo Special option...
414                       \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 11 >> conf ; echo 0 >> conf
415                       configure  < conf > log_compile 2> log_error
416                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
417                       sed s+"-lnetcdff"+'-lnetcdff -I$(WRF_SRC_ROOT_DIR)/inc'+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
418     #######
419     #######LES-specific (WRFV3-based) -- previously in 'makeles'   
420
421                     # GFORTRAN, 64 bits, no nesting     
422     gnu_64_single)    cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd ..
423                       echo 15 | configure > log_compile 2> log_error
424                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf 
425                       sed s+"-L../$phys/libo -llmd"+"-lnetcdf -lnetcdff -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
426                     # PGF90, 32 bits, no nesting
427     pgf_32_single)    echo 1 | configure > log_compile 2> log_error
428                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
429                     # PGF90, 32 bits, nesting
430     pgf_32_nest)      echo 2 | configure > log_compile 2> log_error
431                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
432                     # PGF90, 64 bits, no nesting
433     pgf_64_single)    echo 1 | configure > log_compile 2> log_error
434                       #### the following line is necessary because readtesassim has a line "use netcdf" in it!
435                       #sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
436                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
437                     # PGF90, 64 bits, nesting
438     pgf_64_nest)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
439                       echo 4 | configure > log_compile 2> log_error
440                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
441                     # G95, 32 bits, no nesting
442     g95_32_single)    echo 13 | configure > log_compile 2> log_error
443                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
444                     # G95, 64 bits, no nesting  ### we modify configure.defaults to add x86_64 next to g95 in the header comment
445     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 ..
446                       echo 14 | configure > log_compile 2> log_error
447                         ##### marche pas ....
448                         #sed s+"-fno-second-underscore"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
449                         #sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
450                         #sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;;
451                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;;
452                       #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;;
453                     # IFORT, 64 bits, no nesting
454     ifort_64_single)  echo 5 | configure > log_compile 2> log_error
455                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
456                       if [ ${debug} -ne 0 ]   # not working for xlf!
457                             then
458                             echo 'DEBUG DEBUG DEBUG DEBUG'
459                             sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
460                             mv -f yeah configure.wrf
461                       fi
462                         ## !!! NETCDF must be defined
463                         sed s+"lio_grib_share"+"lio_grib_share -L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
464                         mv -f yeah configure.wrf ;;
465     mpifort_64)     # MPI+IFORT, 64 bits, no nesting / nesting
466                       echo 9 | ./configure > log_compile 2> log_error
467                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
468                       sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
469                       sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
470                       sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
471                       sed s+"-O1"+"-O1 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
472                       sed s+"-O2"+"-O2 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
473                       sed s+"-O3"+"-O3 -mcmodel=medium -shared-intel"+g configure.wrf > yeah ; mv -f yeah configure.wrf
474                       if [ ${debug} -ne 0 ]   # not working for xlf!
475                             then
476                             echo 'DEBUG DEBUG DEBUG DEBUG'
477                             sed s+"#-g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
478                             mv -f yeah configure.wrf
479                       fi
480                       sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf
481                                        #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf  ### pour compilation rapide
482                                        #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3
483                                        #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/
484                            #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault
485                            sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf
486                            sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
487                            sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
488                            sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
489                            sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf
490                            sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf
491                            sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf
492                            sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf
493                         ### necessary even if mpi-selector is used (no need in makegcm though)
494                         sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf
495                         sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf
496                         ## !!! NETCDF must be defined
497                         if [[ "${phys}" != *"void"* ]]
498                         then
499                           sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
500                         else
501                           sed s+"-lesmf_time"+"-lesmf_time $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah
502                         fi
503                         mv -f yeah configure.wrf
504                         #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver]
505                         sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah
506                         mv -f yeah configure.wrf ;;
507                     # MPICH, 64 bits, no nesting / nesting
508     mpi_64)           cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
509                       echo 3 | configure > log_compile 2> log_error
510                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
511                       ### the following line is necessary because readtesassim has a line "use netcdf" in it!
512                       sed s+"-L../$phys/libo -llmd"+"-L../$phys/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf
513                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
514                       #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
515                                #| sed s+"fastsse"+"fast"+g > yeah
516                       mv -f yeah configure.wrf ;;
517                       #    #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
518                       #    ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem
519                       #    ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem
520                       #sed s+"-fastsse"+"-O3 -tp=nehalem-64 -fastsse -Mscalarsse -Mvect=sse -Mipa=fast"+g configure.wrf > yeah
521                       #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah
522                       #sed s+"-fastsse"+""+g configure.wrf > yeah
523                       #sed s+"-fastsse"+"-fast"+g configure.wrf > yeah
524                       #sed s+"-fastsse"+"-Mvect=noaltcode -Msmartalloc -Mprefetch=distance:8 -Mfprelaxed"+g configure.wrf > yeah
525                       #mv -f yeah configure.wrf ;;
526                     # MPICH, 64 bits, OK with periodic BC but no positive definite
527     mpi_64_test)      cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
528                       echo 2 | configure > log_compile 2> log_error
529                       sed -f physics.sed configure.wrf > yeah ; mv -f yeah configure.wrf
530                       sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
531                       mv -f yeah configure.wrf ;;
532                     # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered
533     mpixlf_32)        cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
534                       echo 3 | configure > log_compile 2> log_error
535                       sed -f physics.sed configure.wrf > yeah
536                       mv -f yeah configure.wrf ;;
537                     # ANYTHING ELSE
538     *)                echo NO PRESETS ...
539                       if [ ${donotallow} -eq 0 ] 
540                       then
541                         configure
542                       else
543                         # problem when an input file is used
544                         echo 'please cd to '$PWD' and type ./configure' 
545                         exit   
546                       fi ;;
547  esac
548  ########################
549
550
551  ### here a case structure would be great
552
553  if [[ "${phys}" == *"new"* ]]
554  then
555     if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
556     then
557       sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNEWPHYS "+g configure.wrf > yeah
558     else
559       sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNEWPHYS "+g configure.wrf > yeah
560     fi
561     mv -f yeah configure.wrf
562  fi
563
564        ### SCENARIO SCENARIO SCENARIO
565        if [[ ! ("${scenario}" == "") ]]   ### not supported with LES for the moment?
566        then
567          # precompiling flag in WRF part
568          sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -D${scenario} "+g configure.wrf > yeah
569          mv -f yeah configure.wrf
570          # precompiling flag in LMD part
571          cd $phys
572          cp -Lrf makegcm_${compilo} yeah
573          \rm makegcm_${compilo}
574          sed s+"-DMESOSCALE"+"-D${scenario} -DMESOSCALE"+ yeah > makegcm_${compilo}
575          chmod 755 makegcm_${compilo}
576          \rm yeah
577          cd ..
578        fi
579
580  ################
581  #if [[ "${phys}" == "nophys_" ]]
582  #then
583  #   if [[ "${config}" == "les" ]]  ### LES is different because of WRFV3
584  #   then
585  #     sed s+"ARCH_LOCAL      =       "+"ARCH_LOCAL      =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
586  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
587  #   else
588  #     ### not tested yet but should be working 
589  #     echo CAUTION CAUTION CAUTION NOT FULLY TESTED
590  #     sed s+"ARCHFLAGS       =       "+"ARCHFLAGS       =       -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf
591  #     sed s+"-L../$phys/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf
592  #   fi
593  #fi
594  ################
595
596  if [[ "${phys}" == *"venus"* ]]
597  then
598    sed s+"LIB_BUNDLED     = "+"LIB_BUNDLED     =    /usr/lib64/liblapack.so  \ "+g configure.wrf > yeah ; mv -f yeah configure.wrf
599  fi
600
601  if [ ${debug} -ne 0 ]   # not working for xlf!
602  then
603    echo 'DEBUG DEBUG DEBUG DEBUG'
604    sed s+"# -g"+" -g -no-ftz -traceback -ftrapuv -fp-stack-check -check"+g configure.wrf > yeah
605    #sed s+"# -g"+"-g -Ktrap=fp -Mbounds"+g configure.wrf > yeah
606    #sed s+"# -g"+"-g"+g configure.wrf > yeah
607    mv -f yeah configure.wrf
608  fi
609
610  if [[ "${phys}" == *"prescribed"* ]]
611  then
612     donotcompilephys=1
613  fi
614
615  # some compiler and environment mess things up when using -C
616  sed s+"-C"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf   
617
618#exit
619##################################################
620# compile physics
621##################################################
622if [ ${donotcompilephys} -eq 0 ] #|| [[ "${phys}" != *"prescribed"* ]]
623then
624
625 cd $phys/
626
627 if [[ "${phys}" == *"new"* ]]
628 then
629  divx=1
630  divy=1
631 else
632  # required size
633  #----------------
634  case ${numproc} in
635      1) divx=1 ; divy=1  ;;
636      2) divx=1 ; divy=2  ;;
637      4) divx=2 ; divy=2  ;;
638      6) divx=2 ; divy=3  ;;
639      8) divx=2 ; divy=4  ;;
640     12) divx=3 ; divy=4  ;;
641     16) divx=4 ; divy=4  ;;
642     20) divx=4 ; divy=5  ;;
643     24) divx=4 ; divy=6  ;;
644     32) divx=4 ; divy=8  ;;
645     64) divx=8 ; divy=8  ;;
646    128) divx=8 ; divy=16 ;;
647      *) echo not yet supported ; exit ;;
648  esac
649 fi
650  physx=$(expr ${lon} - 1)
651  restex=$(expr ${physx} \% ${divx})   
652  physy=$(expr ${lat} - 1)
653  restey=$(expr ${physy} \% ${divy})
654  if [[ ${restex} != 0 || ${restey} != 0 ]]
655  then
656     echo nx-1 shall be divided by ${divx}
657     echo ny-1 shall be divided by ${divy}
658     exit
659  fi
660  physx=$(expr ${physx} \/ ${divx})
661  physy=$(expr ${physy} \/ ${divy})
662  physz=$(expr ${level} - 1)
663
664  # change this if you change num_soil_layers in WRF
665  # -- default is 10
666  if [[ "${phys}" == *"new"* ]]
667  then
668     soilsize=18 ## nouvelle physique. ne sert a rien ici. voir comsoil.
669  else
670     soilsize=10
671  fi
672
673  # GCM environment variables
674  #--------------------------
675  export LMDGCM=$PWD
676  export LIBOGCM=$PWD/libo
677
678  # generate the appropriate dimphys
679  #---------------------------------
680  if [[ "${phys}" == *"mars"* ]]
681  then
682    cd libf/phymars
683  elif [[ "${phys}" == *"venus"* ]]
684  then
685    cd libf/phyvenus
686  elif [[ "${phys}" == *"generic"* ]]
687  then
688    cd libf/phystd
689  fi
690  \rm dimphys.h 2> /dev/null
691#  if [[ "${phys}" == "newphys_" ]]
692#  then
693#    ln -sf ../../meso_dimphys.h_ref . ## ne sert plus !!
694#  else
695  if [[ "${phys}" == "mars_lmd" ]]
696  then
697    physize=$(expr ${physx} \* ${physy})
698    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
699    head -15 dimphys.h
700  fi
701     #### TEST new new phys
702     #if [[ "${phys}" == "newphys_" ]]
703     #then
704     #  touch gr_fi_dyn.F.lien
705     #    ln -sf ../dyn3d/gr_fi_dyn.F .  ## dommage, a corriger
706     ################################
707     ################################
708     ################################
709     #fi
710     ####
711     ####
712  cd ../..
713
714  # prepare for nesting
715  #---------------------
716  cd libf
717  duplicate${dom} 2> /dev/null
718  cd ..
719
720  # compile physics
721  #--------------------------
722  \rm libf/grid/dimensions.h 2> /dev/null
723  \rm -rf libo/* 2> /dev/null
724  echo 1. compiling LMD physics ...
725  echo compilation info in:
726  echo $PWD/libo/log_compile_phys
727  echo $PWD/libo/log_compile_phys2
728
729  if [ ${debug} -ne 0 ] 
730  then
731    if [[ "${phys}" == *"mars"* ]]
732    then
733      echo 'DEBUG DEBUG DEBUG DEBUG'
734      nohup makegcm_${compilo} -debug -full -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
735    elif [[ "${phys}" == *"venus"* ]]
736    then
737      echo 'DEBUG DEBUG DEBUG DEBUG'
738      nohup ./makelmdz -debug -full -p venus -d 51 rcm1d -arch linux-ifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys # on /u/ and /planeto/
739      nohup ./makelmdz --debug p venus -d 51 rcm1d -arch linux-ifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
740    elif [[ "${phys}" == *"generic"* ]]
741    then
742      echo 'DEBUG DEBUG DEBUG DEBUG'
743      nohup ./makelmdz -debug -t ${tra} -p std -b 36x32 -s 1 -d 25 rcm1d -arch X64_MESU -cpp MESOSCALE | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #Proxb
744    fi
745  else
746    if [[ "${phys}" == *"mars"* ]]
747    then
748      nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
749    elif [[ "${phys}" == *"venus"* ]]
750    then
751      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/
752      nohup ./makelmdz -p venus -d 51 rcm1d -arch linux-ifort_meso -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
753      #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
754      #nohup ./makelmdz -p venus -d 51 rcm1d -arch CICLADifort -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
755      #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
756      #nohup ./makelmdz -p venus -d 51 rcm1d -arch X64_MESU -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
757      #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
758      #nohup makelmdz -p venus -d 51 rcm1d -arch X64_OCCIGEN -cpp MESOSCALE  | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
759    elif [[ "${phys}" == *"generic"* ]]
760    then
761      nohup ./makelmdz -t 1 -p std -b 38x36 -full -s 1 -d 25 rcm1d -arch mascaret_gfortran_para -cpp MESOSCALE | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys #Proxb
762      nohup ./makelmdz -t 1 -p std -b 38x36 -s 1 -d 25 rcm1d -arch mascaret_gfortran_para -cpp MESOSCALE | tee libo/log_compile_phys2 | grep 'warnings' >> libo/log_compile_phys2 #Proxb
763    fi
764  fi
765  echo ... done
766        # clean the duplicate routines
767        cd libf
768        duplicate1 2> /dev/null
769        cd ..
770
771  # merge LMD executables in one lib
772  #--------------------------------------
773  cd libo
774  mkdir temp
775  if [[ "${phys}" == *"mars"* ]]
776  then
777    cp -f LINUX*/*.a temp
778  else #VENUS and GENERIC
779#    cp -f linux*/*.a temp/ # on /u/ and /planeto/
780    cp -f */*.a temp/ # on /u/ and /planeto/
781    #cp -f /home/mlefevre/modipsl/lib/libioipsl.a temp/ #on CICLAD
782    #cp -f X64*/*.a temp #on MESU and OCCIGEN
783    cp -f $pathioipsl/libioipsl.a temp/
784  fi
785  cd temp
786  if [[ "${phys}" == *"mars"* ]]
787   then   
788   ar x libbibio.a
789   ar x libphymars.a
790   ar x libaeronomars.a
791  elif [[ "${phys}" == *"venus"* ]]
792   then
793   ar x libphyvenus.a
794   ar x libmisc.a
795   ar x libphy_common.a
796   ar x libioipsl.a
797  elif [[ "${phys}" == *"generic"* ]]
798   then
799   ar x libphystd.a
800   ar x libmisc.a
801   ar x libphy_common.a
802   ar x libioipsl.a
803  fi
804  \rm *.a
805  ar r liblmd.a *
806  cp -f liblmd.a ..
807  cd ..
808  \rm -r temp
809  nm liblmd.a > liblmd_content
810  # finish merge
811  cd ..
812  if [[ "${phys}" == *"new"* ]]
813  then
814    if [[ "${phys}" == *"mars"* ]]
815    then
816      # include modules for interfacing
817      mv  *.mod ../inc/
818    else
819#      mv  ./libo/linux*/*.mod ../inc/ # on /u/ and /planeto/
820      mv  ./libo/*/*.mod ../inc/ # on /u/ and /planeto/
821      #mv  ./libo/CICLAD*/*.mod ../inc/ # on CICLAD
822      #mv  ./libo/X64*/*.mod ../inc/ # on MESU and OCCIGEN
823      cp -f $pathioipsl/*.mod ../inc/
824    fi
825  fi
826
827
828  # save a copy
829  #--------------
830  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}
831  echo '****************************************'
832
833  # ok
834  #----
835  cd ..
836
837  # manage nest includes in module_lmd_driver.F
838  #----
839  cp call_meso_inifis$dom.inc call_meso_inifis.inc
840  cp call_meso_physiq$dom.inc call_meso_physiq.inc
841
842
843fi
844##################################################
845# END compile physics
846##################################################
847
848#------------------
849# compile WRF
850#------------------
851if [ ${justphys} -eq 0 ]
852then
853
854  echo 2. compiling WRF dynamical core ...
855
856  #if [[ "${phys}" == "nophys_" ]]
857  #then
858  # echo 'NO LMD PHYSICS included'
859  #else
860  # if [[ ! ( -f "call_meso_physiq.inc" ) ]]
861  # then
862  #  echo 'did you compile the physics ? no call_meso_physiq.inc !'
863  #  exit
864  # fi
865  #fi
866
867  # be sure to compile with the most recent physics
868  touch phys/module_lmd_driver.F
869
870  # talk to user
871  echo '>>> compiling ... this may be long ... <<<'
872  echo check progress in:
873  echo $PWD/log_compile
874  echo check possible errors in:
875  echo $PWD/log_error
876 
877  # compile ...
878  echo '>>> YOUR CONFIG IS : '${config}
879  case ${config} in
880    'real')         ./compile em_real > log_compile 2> log_error
881                    # save executables 
882                    cd main
883                      if [[ -f real.exe ]]
884                      then
885                        echo 'Looks good ! real.exe is here...'
886                      fi
887                      if [[ -f wrf.exe ]]
888                      then
889                        echo 'Looks good ! wrf.exe is here...'
890                      fi
891                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
892                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
893                    cd ..  ;;
894    'ideal')        #mkdir 'test/em_quarter_ss' 2> /dev/null
895                    #echo '>>> YOUR CONFIG IS : '${config}
896                    ./compile em_quarter_ss > log_compile 2> log_error
897                    # save executables 
898                    cd main
899                      if [[ -f ideal.exe ]]
900                      then
901                        echo 'Looks good ! ideal.exe is here...'
902                      fi
903                      if [[ -f wrf.exe ]]
904                      then
905                        echo 'Looks good ! wrf.exe is here...'
906                      fi
907                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
908                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
909                    cd ..  ;;
910    'les')          #echo '>>> YOUR CONFIG IS : '${config}
911                    mkdir 'test/em_les' 2> /dev/null                   
912                    ./compile em_les ###> log_compile 2> log_error
913                    # save executables 
914                    cd main
915                      if [[ -f ideal.exe ]]
916                      then
917                        echo 'Looks good ! ideal.exe is here...'
918                      fi
919                      if [[ -f wrf.exe ]]
920                      then
921                        echo 'Looks good ! wrf.exe is here...'
922                      fi
923                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
924                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
925                    cd ..  ;;
926    *)              echo not supported... please use ; echo ideal les ; exit ;;
927  esac
928  echo '*******last lines from log_error*********'
929  tail -n 20 log_error
930fi
931
932  # the end
933  echo '****************************************'
934  echo 'done.'
935  echo '****************************************'
936  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}
937  mv last ../../
938  svn info ../../ > ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.svn.info
939
940  # link latest compiled folder as LATEST
941  cd ../../
942  rm -rf LATEST
943  ln -sf ${conf_wrf} LATEST
944
945  # link latest compiled exec
946  cd LATEST
947  case ${config} in
948    'real')         ln -sf real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe real.exe ;;
949    'ideal')        ln -sf ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe ideal.exe ;;
950    'les')          ln -sf ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe ideal.exe ;;
951  esac
952  ln -sf wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe wrf.exe
953  cd ..
954
955  # add here specific messages
956  if [[ "${dom}" != "1" ]]
957  then
958  nest=$(expr ${lon} + 4)
959  echo NB: in namelist.input, please set:
960  echo '
961  max_dom = '$dom'
962  s_we    = 1,1,
963  e_we    = '$lon','$nest',
964  s_sn    = 1,1,
965  e_sn    = '$lat','$nest',
966  s_vert  = 1,1,
967  e_vert  = '$level','$level','
968  fi
969
970
Note: See TracBrowser for help on using the repository browser.