Compilation of WRF 3.3 under Cygwin for Windows

Posted by • pb

After lot of hours spent on how to compile and get running WRF ARW model under Windows and utilizing all the available CPU cores (using SMPAR build), I have been sucessful and would like to share the know-how. WRF ARW "officially" supports Cygwin only using expensive PGI compilers, but the compilation seems to be very tricky. Here I will share info, how to compile WRF using open-source gfortran and gcc compilers.

Please note that DMPAR build seems not to be working due to segmentation fault and ulimit -s unlimited not supported by Cygwin.

How-to:
• Read & follow official Online tutorial considering steps below.
• Install Cygwin with these packages: autoconf, binutils, bison, byacc, flex, gcc, gcc4, gcc4-fortran, gcc-g++, gdb, make, makedepend, openssl-devel, vim, libcurl3, libgfortran3, libidn-devel, libxml2, sunrpc, zlib, libcurl-devel, libcurl4, openssh, bash, sh-utils. Not all are required, but at least theese I had installed.
• Before any untar fallback to cygwin1.dll v. 1.7.8 (1.7.9 is unable to create symlinks from tars and You will get permission denied exception because file will have 0 size)
• Select gfortran (gcc4-*) and libgomp version 4.5.0 that comes with cygwin installation (4.3.4 faulty libgomp, multithreading does not work. Version 4.7 has bug preventing compilation of SEED function in Fortran sources)
• Download & compile netcdf 3.6.3 (export CC=gcc FC=gfortran F90=gfortran CXX=g++). Please mind that precompiled binaries won't work and netcdf has to be recompiled whenever the compilator or its version changes for further compilation of WRF.
• Cygwin requires You to apply configure.fix.tar for WRF V3.3 before running configure script in WRFV3 directory.
• ./configure -os Linux and choose option 2. (gfortran with gcc SMPAR)
• Small modification to generated configure.wrf should be done (e.g. CPP should point to existing command). Please compare against my configure.wrf
• Build WRF nice -n 9 ./compile em_real 2>&1 | tee compile.log
• If You are lucky then in ./main/ subdirectory You should find 5 exe files including wrf.exe and real.exe. If not please check compile.log for errors and You are condemned to find problem.
• if You find in log internal compiler error please reduce optimizations for Fortran in configure.wrf: FCOPTIM = -O1 and recompile without clean. This will keep previous files compiled with O3 and problematic create with O0. If You will recompile all with O0 You would decrease performance of simulation to 50%!

Compilation of WPS 3.3 under Cygwin for Windows

Posted by • pb

Please make sure that You have been sucessfull with build of WRF before You proceed with WPS.
• Make sure that You are using cygwin1.dll v. 1.7.8 before untar.
• hack configure -> replace os=`uname` with os=Linux
• ./configure and choose 14. gfortran (with GRIB2)
• modify configure.wps: WRF_DIR should point to directory where WRF is compiled and correct *_LIBS references. Please see and compare against my configure.wps
• Compile and if You are lucky then geogrid.exe, ungrib.exe, metgrid.exe files should be created.