Skip to content

Support for compiling on cygwin#911

Closed
DWesl wants to merge 6 commits intowrf-model:developfrom
DWesl:clean_cygwin_support
Closed

Support for compiling on cygwin#911
DWesl wants to merge 6 commits intowrf-model:developfrom
DWesl:clean_cygwin_support

Conversation

@DWesl
Copy link
Contributor

@DWesl DWesl commented May 16, 2019

TYPE: enhancement

KEYWORDS: cygwin, compiler, configure, library search path

SOURCE: DWesl (PSU)

DESCRIPTION OF CHANGES:

The build configury did not understand the cygwin platform. Since the platform is similar to Linux and BSD, it was relatively straightforward to add support.

I had to move some settings from the postamble to the preamble for the settings in configure.defaults to be honored. I also had to allow a larger stack in the registry for that program not to crash.

Some libraries appear to have different names on Cygwin and on Linux, in particular, I cannot find a libhdf5_fortran, but libhdf5_hl appears to work just fine. I have no idea if these are fully interchangeable on Linux.

I could not find code for libwavelet, so I removed that library from LIB_EXTERNAL

LIST OF MODIFIED FILES:
arch/Config.pl
arch/configure.defaults
arch/postamble
arch/preamble
configure
external/io_netcdf/makefile
tools/Makefile

TESTS CONDUCTED:
I succeeded in compiling and running the em_scm_xy case on Cygwin.

DWesl added 4 commits May 16, 2019 10:54
I have tested this on cygwin code with WRF v4.0.2 and a few other
changes to try to stop the registry code from crashing.  I will likely
submit those changes as a separate PR.
It was crashing when it tried to build this because it couldn't find
the code.  I couldn't either, so I told it to stop trying.
It was a copy of the CYGWIN_NT configuration, instead of using
"x86_64-w64-mingw32-gfortran" and friends as compilers.  There are
probably other problems, so I'm removing this instead of correcting
the compiler executables.
@DWesl DWesl requested a review from a team as a code owner May 16, 2019 21:03
# If the user asked for classic netcdf, acquiesce to the request.

if [ "`uname`" = "Linux" ] ; then
if [ "`uname`" = "Linux" -o "`uname -o`" = "Cygwin" ] ; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is uname -o correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uname gives result CYGWIN_NT-10.0. I could change that, but I'm not sure when the "10.0" part changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -o option trims the "10.0" and changes the string from "CYGWIN_NT" to "Cygwin"?

@davegill
Copy link
Contributor

davegill commented May 16, 2019

@DWesl @mgduda @MiCurry
Anything that changes the build system needs to be thoroughly vetted, so be patient. Lets iterate back and forth.

First, I checked, and this is using the develop branch as a base, and you are targeting the develop branch - both what we want with this type of PR.

I would like to see this PR re-done (only 7 files, so not too arduous). Keep this PR active for reference, but make a new one. The new PR will be assembled from very specific commits, in specific order. If you have troubles at any step, clean it up before the actual commit is made to your branch.

Before each of the specific commits, a full test build of the WRF code on a non-CYGWIN machine will be required (clean -a, configure, compile), and a heavier duty test case than SCM. Take a look at:
https://github.com/davegill/wrf-coop/blob/master/README.md#with-the-second-image-build-three-containers
We want you to run ARW, NMM, and Chemistry builds, and one test case for each. For each of these test cases, we need serial and MPI, and a comparison of the results demonstrating bit-for-bit identical results. You will swap in your github repository in the Dockerfile. At each step, the non-CYGWIN results are to be maintained. After the last commit, the CYGWIN results should also work (of course, unavailable from inside a docker container). A single GNU compiler will suffice (handled inside of the docker container).

Here are the commits. Again, with each of these proposed commits, conduct the 6 tests (serial and MPI for each of ARW, NMM, and Chem) and the comparisons (the serial vs MPI for each of the 3 builds). When everything is OK, put that commit on your branch.

  1. Change the preamble, postamble, and configure.defaults files
  2. Change configure (check syntax question)
  3. Change external/io_netcdf/makefile (check syntax question)
  4. Change tools/Makefile - explain in the PR comment what is peflags
  5. Change Config.pl

We will likely need the mods in step 3 to also be put into other I/O libs, or we need a build time check that says "we can't use xxxxx" with CYGWIN.

It seems that step 5 may require an additional IF test to determine if we are using Linux of CYGWIN, if there are troubles with the hdf5 library.

Before starting on these tasks, let's get all of the software engineers to sign off on this initial proposed set of steps.

@DWesl
Copy link
Contributor Author

DWesl commented May 17, 2019 via email

@davegill
Copy link
Contributor

@DWesl
Nope, I agree that we want Cygwin

@DWesl
Copy link
Contributor Author

DWesl commented May 17, 2019 via email

@davegill
Copy link
Contributor

@DWesl
The test cases are small. They run in about 1 minute on my laptop.


LIB_EXTERNAL = \
../external/io_netcdf/libwrfio_nf.a CONFIGURE_NETCDF_PATH/lib/libnetcdf.lib \
../external/wavelet/libWavelet.a ../external/wavelet/lib_wavelet.a
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any way to generate an external/wavelet/libWavelet.a, so I removed that link here and did not add it for the Cygwin link line. If that archive was moved somewhere rather than removed, I should change these to point to the new location.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wavelet library looks to be part of the data assimilation. It is located in var/external.

@DWesl
Copy link
Contributor Author

DWesl commented Jun 2, 2019 via email

/usr/bin/peflags.exe is where it is on cygwin, and that's the only
place we need it, so make sure we're using that one.
@DWesl DWesl mentioned this pull request Oct 27, 2019
@DWesl
Copy link
Contributor Author

DWesl commented Nov 7, 2019

I reorganized the commits as requested; the result is #1003.

@DWesl DWesl closed this Nov 7, 2019
davegill pushed a commit that referenced this pull request Feb 7, 2020
TYPE: enhancement

KEYWORDS: compilation, cygwin, new platform, build system

SOURCE: Daniel Wesloh (The Pennsylvania State University Department of Meteorology and Atmospheric Science)

DESCRIPTION OF CHANGES: 

The WRF compilation script did not support compiling on Cygwin.  
#911 added support for that compilation, and generated feedback to
ensure those changes did not break compilation on other platforms.
This PR incorporates those suggestions and the changes required by them.

I moved the `LIB_BUNDLED` and `LIB_EXTERNAL` default definitions from the `configure.wrf` postamble to the preamble so I could override them in `configure.defaults` on non-Windows platforms.  This required copying the processing of the postamble in `arch/Config.pl` to where it processed the preamble so that the variables used in the definitions of `LIB_BUNDLED` and `LIB_EXTERNAL` would still be substituded.

One additional change was necessary: the system version of libjasper on cygwin is recent enough that `struct jas_image_t` has no `inmem_` member, so that the reference to `inmem_` must be commented out for Grib2 support to work.  I did not include that change here as that is related to the version of the Jasper library on all platforms, not just cygwin.

Dependency versions for current test:
```bash
$ cygcheck -c cygwin gcc-core gcc-fortran libnetcdf-devel libnetcdf-fortran-devel openmpi libjasper-devel perl tcsh libhdf5-devel libopenmpi-devel openmpi $(cygcheck -cd | awk $'/libnetcdf[0-9]/ {print $1;}\n/libhdf5_[0-9]/ {print $1;}\n/libopenmpiusef08_[0-9]/ {print $1;}\n/libgomp[0-9]/ {print $1;}\n/libgfortran[0-9]/ {print $1;}\n/libjasper[0-9]/ {print $1;}\n/libnetcdf-fortran_[0-9]/ {print $1;}')
Cygwin Package Information
Package                 Version        Status
cygwin                  3.1.2-1        OK
gcc-core                9.2.0-1        OK
gcc-fortran             9.2.0-1        OK
libgfortran3            6.4.0-5        OK
libgfortran4            7.4.0-1        OK
libgfortran5            9.2.0-1        OK
libgomp1                9.2.0-1        OK
libhdf5-devel           1.10.6-1       OK
libhdf5_10              1.8.20-1       OK
libhdf5_101             1.10.2-1       OK
libhdf5_103             1.10.6-1       OK
libjasper-devel         2.0.14-1       OK
libjasper1              1.900.22-1     OK
libjasper4              2.0.14-1       OK
libnetcdf-devel         4.7.3-1        OK
libnetcdf-fortran-devel 4.5.2-1.1      OK
libnetcdf-fortran_6     4.4.4-3        OK
libnetcdf-fortran_7     4.5.2-1.1      OK
libnetcdf11             4.4.1.1-1      OK
libnetcdf13             4.6.1-2        OK
libnetcdf15             4.7.3-1        OK
libopenmpi-devel        3.1.5-1        OK
libopenmpiusef08_11     1.10.7-1       OK
libopenmpiusef08_40     3.1.5-1        OK
openmpi                 3.1.5-1        OK
perl                    5.26.3-2       OK
tcsh                    6.22.01-1      OK
```

ISSUE: 
Replaces #911 

LIST OF MODIFIED FILES: 
M       README
M       arch/Config.pl
M       arch/configure.defaults
M       arch/postamble
M       arch/preamble
M       configure
M       doc/README.cygwin.md
M       external/io_netcdf/makefile
M       tools/Makefile

TESTS CONDUCTED: 

I used the script at 
https://github.com/davegill/wrf-coop/blob/master/build.csh
to build and run WRF-ARW, WRF-NMM, and WRF-Chem on Windows Subsystem for Linux (debian) and on Cygwin.
The build script does not consistently work, but running the indicated commands manually usually works fine.

A regression test on LInux is successful, but an intermediate branch was required to circumvent
a broken develop branch (from which this is based).
```
WRF NUMBER OF TILES =   1
 No land surface physics option is used: sf_surface_physics =            0
Timing for main: time 0001-01-01_00:00:04 on domain   2:    1.12292 elapsed seconds
Timing for main: time 0001-01-01_00:00:08 on domain   2:    0.91971 elapsed seconds
Timing for main: time 0001-01-01_00:00:12 on domain   2:    0.91965 elapsed seconds
Timing for main: time 0001-01-01_00:00:12 on domain   1:    6.95076 elapsed seconds
Timing for main: time 0001-01-01_00:00:16 on domain   2:    0.92157 elapsed seconds
Timing for main: time 0001-01-01_00:00:20 on domain   2:    0.92541 elapsed seconds
Timing for main: time 0001-01-01_00:00:24 on domain   2:    0.92848 elapsed seconds
Timing for main: time 0001-01-01_00:00:24 on domain   1:    3.92829 elapsed seconds
Timing for main: time 0001-01-01_00:00:28 on domain   2:    0.93069 elapsed seconds
Timing for main: time 0001-01-01_00:00:32 on domain   2:    0.93314 elapsed seconds
Timing for main: time 0001-01-01_00:00:36 on domain   2:    0.93447 elapsed seconds
Timing for main: time 0001-01-01_00:00:36 on domain   1:    3.95087 elapsed seconds
Timing for main: time 0001-01-01_00:00:40 on domain   2:    0.94396 elapsed seconds
Timing for main: time 0001-01-01_00:00:44 on domain   2:    0.93751 elapsed seconds
Timing for main: time 0001-01-01_00:00:48 on domain   2:    0.93741 elapsed seconds
Timing for main: time 0001-01-01_00:00:48 on domain   1:    3.97565 elapsed seconds
Timing for main: time 0001-01-01_00:00:52 on domain   2:    0.93471 elapsed seconds
Timing for main: time 0001-01-01_00:00:56 on domain   2:    0.93481 elapsed seconds
Timing for main: time 0001-01-01_00:01:00 on domain   2:    0.93528 elapsed seconds
Timing for Writing wrfout_d02_0001-01-01_00:01:00 for domain        2:    0.03285 elapsed seconds
Timing for main: time 0001-01-01_00:01:00 on domain   1:    3.99505 elapsed seconds
Timing for Writing wrfout_d01_0001-01-01_00:01:00 for domain        1:    0.03183 elapsed seconds
d01 0001-01-01_00:01:00 wrf: SUCCESS COMPLETE WRF
```

RELEASE NOTE: Introduce a Windows-based WRF build and run via the free Unix-like CYGWIN environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants