Compiling WRF on 64bit, target system: 32bit

Hello,

I am trying to compile the WRF model with PGI 7.1-6 on a 64bit Debian Etch Linux box. My target system should be a 32bit machine, also running Debian Etch. The latest NetCDF version seemed to compile fine with setting “-tp px” in some environment variables, but failed in some tests during “make check”. However, I don’t get WRF to compile at all.

Without getting in too much detail right now (I have only tried once and this failed, will try again in the next few days and keep you updated about that): has someone already successfully completed a similar task, perhaps even using OpenMP? I suppose with the right configuration, it should be possible to cross-compile WRF.

Best regards,
Jonas

PS, @mkcolg: looking forward to your WRF model description, thank you for that!

Hi Jonas,

I’m just starting work on the WRF t&t page so will look into how to configure it to cross compile. I know it compiles fine in 32-bits, but I’m not sure what in it’s build scripts needs to be changed. (We compile it daily with a variety of flags, but in our QA harness not the WRF build harness). While you can use the “-tp” switch to have the compiler target a 32-bit architecture, you’ll most likely need to change some of the WRF’s define flags as well. I don’t have access to a debian system, but hopefully the work I do on SuSE applies to Debian as well.

On a side note, “-tp px” targets a generic i386 system. This is good for portability, but bad for performance since you wont be able to take advantage of most processor advances. Take look at the output of “pgf90 -help -tp” and see if you can find an architecture that more closely matches your target system. For example “-tp piv” targets a Pentium 4 and would enable vectorization (with the “-fastsse” flag).

  • Mat

Hi Jonas,

Here’s what I did to get WRF to cross compile:

  1. Compile NetCDF in 32-bits (using “-tp piv”) and set the environment variable “NETCDF” to my NetCDF install directory.
  2. Untar WRFV3.0.1.1.TAR.gz and cd into WRFV3.
  3. Set the environment variable “WRF_OS” to “Linux” and “WRF_MARCH” o “x86”.
  4. Run “./configure” and select an option for Linux i486 and PGI. I choose serial (#11).
  5. Add “-tp piv” to the FCBASEOPTS and “-m32” to CFLAGS_LOCAL.
  6. Add “-m32” to compile line in the “.c.o” and “wgrib” rules in “external/io_grib1/WGRIB/Makefile”.
  7. ./compile em_real

You may need to change this a bit if you’re compiling for MPI (like where the 32-bit MPI libraries are located), but this is the basic idea.

Let me know how it goes,
Mat

Hi Mat,

thank you for your quick answer! I successfully cross-compiled WRF with the options you provided. The only difference is that I used “-tp p7” as my target platform is Xeon-based.

However, when trying to execute the generated binaries on my target machine, I get the following errors:

user@server:~/WRF/WRFV3/main$ ./wrf.exe 
./wrf.exe: error while loading shared libraries: libpgc.so: cannot open shared object file: No such file or directory

I then tried to use the portability packages. I get errors when using both the 32bit version and the 64bit version of these packages:

user@server:~/WRF/WRFV3/main$ export LD_LIBRARY_PATH=/var/pgi-libraries-64
user@server:~/WRF/WRFV3/main$ ./wrf.exe 
./wrf.exe: error while loading shared libraries: libpgc.so: cannot open shared object file: No such file or directory
user@server:~/WRF/WRFV3/main$ export LD_LIBRARY_PATH=/var/pgi-libraries-32
user@server:~/WRF/WRFV3/main$ ./wrf.exe 
./wrf.exe: symbol lookup error: ./wrf.exe: undefined symbol: __pgi_ctrl_init

Where do I get the missing libraries? Or do I have an error in the compilation steps?

Thank you for your help!

Regards,
Jonas

Hi Jonas,

The missing symbol was added to our 7.1 runtime in order to support the trace back feature. Though for some reason, the portability package posted on www.pgroup.com is from the 7.0 release so is missing this symbol. I’ve sent out an email to our webmaster.

In the meantime, you can copy the PGI 7.1 32-bit C runtime library from your 64-bit system to your 32-bit system (by default this is located in /opt/pgi/linux86/7.1-6/lib/libpgc.so) or you can relink wrf.exe with the “-Bstatic_pgi” flag to remove the dependency on libpgc.so altogether. Unless you have an older glib version (< 2.3.2) on the 32-bit system, then either method should be fine.

To relink wrf, add “-Bstatic_pgi” to FCBASEOPTS in configure.wrf and rerun “compile em_real”.

Hope this helps,
Mat

Hi Mat,

thank you for your help! Using the 64bit version of libgpc.so worked fine.

To run WRF, I also needed to compile the preprocessing system WPS and the postprocessing system ARWpost. I could successfully cross-compile those two packages with editing the configure-scripts and adding “-tp p7”. Let’s hope that everything still works when I try those builds in “real-life”.

Thank you (again) for your help!

Regards,
Jonas