sábado, 3 de diciembre de 2016

Compile WRF 3.8.1 in Ubuntu 16.04.1 LTS

WRF, the Weather Research and Forecasting Model, is a mesoscale numerical weather prediction system for meteorological applications across scales from tens of meters to thousands of kilometers.
I am following these instructions and adapting them to my system.
Install dependencies (note you need FORTRAN NetCDF)

sudo apt install csh gfortran m4 mpich libhdf5-mpich-dev libpng-dev libnetcdff-dev netcdf-bin ncl-ncarg

We now identify the path to the include filed and libraries

sudo updatedb
locate mpich/lib

In my system the two last commands give




Keep these in mind.

OK after downloading and extracting WRF I wanted to do out-of-source compilation (this keeps the source code clean form build symbols), but the Makefile is not well written so it doesn't support this.

Hence I do configure in the source folder


This gives me the list of option form which I chose GNU gfortran and the default no nesting option, because I will be running things like the em_hill2d_x example.

checking for perl5... no
checking for perl... found /usr/bin/perl (perl)
Will use NETCDF in dir: /usr
HDF5 not set in environment. Will configure WRF for use without.
PHDF5 not set in environment. Will configure WRF for use without.
Will use 'time' to report timing information
$JASPERLIB or $JASPERINC not found in environment, configuring to build without grib2 I/O...
Please select from among the following Linux x86_64 options:

  1. (serial)   2. (smpar)   3. (dmpar)   4. (dm+sm)   PGI (pgf90/gcc)
  5. (serial)   6. (smpar)   7. (dmpar)   8. (dm+sm)   PGI (pgf90/pgcc): SGI MPT
  9. (serial)  10. (smpar)  11. (dmpar)  12. (dm+sm)   PGI (pgf90/gcc): PGI accelerator
 13. (serial)  14. (smpar)  15. (dmpar)  16. (dm+sm)   INTEL (ifort/icc)
                                         17. (dm+sm)   INTEL (ifort/icc): Xeon Phi (MIC architecture)
 18. (serial)  19. (smpar)  20. (dmpar)  21. (dm+sm)   INTEL (ifort/icc): Xeon (SNB with AVX mods)
 22. (serial)  23. (smpar)  24. (dmpar)  25. (dm+sm)   INTEL (ifort/icc): SGI MPT
 26. (serial)  27. (smpar)  28. (dmpar)  29. (dm+sm)   INTEL (ifort/icc): IBM POE
 30. (serial)               31. (dmpar)                PATHSCALE (pathf90/pathcc)
 32. (serial)  33. (smpar)  34. (dmpar)  35. (dm+sm)   GNU (gfortran/gcc)
 36. (serial)  37. (smpar)  38. (dmpar)  39. (dm+sm)   IBM (xlf90_r/cc_r)
 40. (serial)  41. (smpar)  42. (dmpar)  43. (dm+sm)   PGI (ftn/gcc): Cray XC CLE
 44. (serial)  45. (smpar)  46. (dmpar)  47. (dm+sm)   CRAY CCE (ftn/cc): Cray XE and XC
 48. (serial)  49. (smpar)  50. (dmpar)  51. (dm+sm)   INTEL (ftn/icc): Cray XC
 52. (serial)  53. (smpar)  54. (dmpar)  55. (dm+sm)   PGI (pgf90/pgcc)
 56. (serial)  57. (smpar)  58. (dmpar)  59. (dm+sm)   PGI (pgf90/gcc): -f90=pgf90
 60. (serial)  61. (smpar)  62. (dmpar)  63. (dm+sm)   PGI (pgf90/pgcc): -f90=pgf90
 64. (serial)  65. (smpar)  66. (dmpar)  67. (dm+sm)   INTEL (ifort/icc): HSW/BDW
 68. (serial)  69. (smpar)  70. (dmpar)  71. (dm+sm)   INTEL (ifort/icc): KNL MIC

Enter selection [1-71] : 32
Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]: 

Configuration successful! 
testing for fseeko and fseeko64
fseeko64 is supported

# Settings for    Linux x86_64 ppc64le, gfortran compiler with gcc   (serial)

After this we need to fix the configure.wrf file to link against netcdf. This is done via the LIB_EXTERNAL variable:

    -L$(WRF_SRC_ROOT_DIR)/external/io_netcdf -lwrfio_nf -L/usr/lib -lnetcdff -lnetcdf

Now I can compile, I first tried compiling WRF (using 7 of my cores for compilation)

./compile -j 7 wrf

This took about 4 minutes. Then I compiled the em_hill2d_x example (Makefile agian is not correct so you can't use multiple cores here)

./compile em_hill2d_x

This took about 10 seconds to finish. I moved to the folder where the test is stored and run it:

cd tests/em_hill2d_x

To make plots of the results I had to modify this script (here my version): the NCARG_ROOT trick mentioned in the tutorial doesn't work (I explicitly used the folder where those scripts are in my system, use locate to find them in yours) and they should use loadscript instead of load. But I got it

No hay comentarios:

Publicar un comentario