How to compile the WRF model on ECMWF cca/ccb

#Prerequisites:
#- This has been tested with the GNU compiler suite version 4.9.3
#- You should have all the needed libraries and WRF sources in the $PERM directory. Namely:
#  * zlib-1.2.7.tar.gz          (This is a compression library necessary for compiling WPS (specifically ungrib) with GRIB2 capability)
#  * libpng-1.2.50.tar.gz       (This is a compression library necessary for compiling WPS (specifically ungrib) with GRIB2 capability)
#  * WRFV3.8.1.tar.gz           (WRF model)
#  * WPSV3.8.1.tar.gz           (WRF Preprocessing System)
#  * DTC_upp_v3.1.tar.gz        (Unified PostProcessing system)

#-------------------------------------------
# 1. Log in to cca (or ccb)
#-------------------------------------------

 ssh -Y cca  


#-------------------------------------------
# 2. GNU
#-------------------------------------------
# switch to GNU compilers

 prgenvswitchto gnu  

#-------------------------------------------
# 3. NETCDF
#-------------------------------------------
# Load NetCDF module

 module load netcdf4  
 export NETCDF=$NETCDF_DIR  
 export DIR=$PERM/build/netcdf4/4.3.2/GNU/49  
 mkdir -p $DIR  
 cd $DIR  
 cp -v $PERM/src/*.gz .  


#-------------------------------------------
# 4. zlib
#-------------------------------------------
# Configure and compile zlib

 export LDFLAGS=-L$DIR/grib2/lib  
 export CPPFLAGS=-I$DIR/grib2/include  
 tar xzvf zlib-1.2.7.tar.gz  
 cd zlib-1.2.7  
 ./configure --prefix=$DIR/grib2  
 make > out.make 2>&1  
 make install  
 cd ..   


#-------------------------------------------
# 5. libpng
#-------------------------------------------
# Configure and compile libpng

 tar xzvf libpng-1.2.50.tar.gz  
 cd libpng-1.2.50  
 ./configure --prefix=$DIR/grib2  
 make > out.make 2>&1  
 make install  
 cd ..   

#-------------------------------------------
# 6. WRF 3.8.1
#-------------------------------------------
# Configure and compile WRF

 gunzip WRFV3.8.1.tar.gz  
 tar -xf WRFV3.8.1.tar  
 cd WRFV3  
 ./clean -a  
 cd external/  
 make superclean  
 cd ..  
 ./configure   
 #then option 35. (dm+sm)  GNU (gfortran/gcc) 
 #Edit configure.wrf by changing the following variables value: 
 #SFC       =    ftn 
 #SCC       =    cc 
 #CCOMP      =    cc 
 #DM_FC      =    ftn 
 #DM_CC      =    cc 

  ./compile -j 4 em_real > compile.out 2>&1 && cd .. 
#It should fail on the first time (namely main/real.exe is not created)
#with the following error:
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#real_em.f90:32.7:

#   USE module_initialize_real, ONLY : wrfu_initialize, find_my_parent, find_my_
       1
#Fatal Error: Can't open module file 'module_initialize_real.mod' for reading at (1): No such file or
#directory
#nup_em.f90:90.7:

#   USE module_initialize_real, only : wrfu_initialize
#       1
#Fatal Error: Can't open module file 'module_initialize_real.mod' for reading at (1): No such file or
#directory
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#Then it should end successfully when running the
#command a second time (do not understand why but it works...)
  ./compile -j 4 em_real > compile.out 2>&1 && cd .. 

#-------------------------------------------
# 7. WPS 3.8.1
#-------------------------------------------
# Configure and compile WPS
 gunzip WPSV3.8.1.tar.gz  
 tar -xf WPSV3.8.1.tar  
 cd WPS  
 ./clean  
 export JASPERLIB=$JASPER_LIB_DIR  
 export JASPERINC=$JASPER_INCLUDE_DIR  
 echo  
 ./configure  

#then option 1 Linux x86_64, gfortran    (serial)
#Few edits in the configure.wps file
# 1. add "-lgomp" to the WRF_LIB variable (just append it after -lnetcdf)
# 2. Be sure to use the wrappers for the Fortran and C compilers, ie
#     SFC                 = ftn
#     SCC                 = cc
# (no changes for the DM_FC and DM_CC variables

 ./compile > compile.out 2>&1  
 cd ..  

#-------------------------------------------
# 8. UPP 3.1
#-------------------------------------------
# Configure and compile UPP
 tar -zxvf DTC_upp_v3.1.tar.gz  
 cd UPPV3.1  
 ./configure  

#then option 7.  Linux x86_64, gfortran compiler  (serial)

 ./compile > compile.out 2>&1  
 cd ..  

#Important! The unipost.exe is created, BUT it does not work...so write me if you were able to successfully compile and run unipost.exe

Commenti