diff --git a/README b/README index c3375981b9..21c2bccde4 100644 --- a/README +++ b/README @@ -40,6 +40,7 @@ doc/README.irr_diag doc/README.rsl_output doc/README.windturbine doc/README_test_cases +doc/README.cygwin.md - Beginning with version 4.0, for more information on the releases, visit the WRF GitHub Release Page: diff --git a/arch/Config.pl b/arch/Config.pl index 7d8173860a..b6f45dbe97 100644 --- a/arch/Config.pl +++ b/arch/Config.pl @@ -42,7 +42,7 @@ $sw_usenetcdf = "" ; $sw_time = "" ; # name of a timer to time fortran compiles, e.g. timex or time $sw_ifort_r8 = 0 ; -$sw_hdf5 = "-lhdf5 -lhdf5_hl"; +$sw_hdf5 = "-lhdf5_hl -lhdf5"; $sw_zlib = "-lz"; $sw_dep_lib_path = ""; $sw_gpfs_path = ""; @@ -604,8 +604,7 @@ $_ .= " \$\(NETCDF4_IO_OPTS\)\n" ; } if (/^LIB.*=/) - { $_ =~ s/\r|\n//g ; - $_ .=" \$\(NETCDF4_DEP_LIB\)\n" ; + { $_ =~ s/(\\?)[\r\n]/ \$\(NETCDF4_DEP_LIB\)\1\n/g ; } } } @@ -756,6 +755,9 @@ # apply substitutions to the preamble... while ( ) { + if ( $sw_os ne "CYGWIN_NT" ) { + $_ =~ s/#NOWIN// ; + } # ESMF substitutions in preamble if ( $sw_esmflib_path && $sw_esmfinc_path ) { @@ -797,6 +799,76 @@ $_ =~ s/CONFIGURE_DEP_LIB_PATH/$sw_dep_lib_path/g ; + $_ =~ s/CONFIGURE_COMMS_LIB/$sw_comms_lib/g ; + if ( $sw_os ne "CYGWIN_NT" ) { + $_ =~ s/#NOWIN// ; + } + if ( $sw_netcdf_path ) + { $_ =~ s/CONFIGURE_WRFIO_NF/wrfio_nf/g ; + $_ =~ s:CONFIGURE_NETCDF_FLAG:-DNETCDF: ; + if ( $ENV{NETCDF_LDFLAGS} ) { + $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a $ENV{NETCDF_LDFLAGS} : ; + } elsif ( $sw_os eq "Interix" ) { + $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf/libwrfio_nf.a -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ; + } else { + $_ =~ s:CONFIGURE_NETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_netcdf -lwrfio_nf -L$sw_netcdf_path/lib $sw_usenetcdff $sw_usenetcdf : ; + } + } + else + { $_ =~ s/CONFIGURE_WRFIO_NF//g ; + $_ =~ s:CONFIGURE_NETCDF_FLAG::g ; + $_ =~ s:CONFIGURE_NETCDF_LIB_PATH::g ; + } + + if ( $sw_pnetcdf_path ) + { $_ =~ s/CONFIGURE_WRFIO_PNF/wrfio_pnf/g ; + $_ =~ s:CONFIGURE_PNETCDF_FLAG:-DPNETCDF: ; + if ( $sw_os eq "Interix" ) { + $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf/libwrfio_pnf.a -L$sw_pnetcdf_path/lib -lpnetcdf: ; + } else { + $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_pnetcdf -lwrfio_pnf -L$sw_pnetcdf_path/lib -lpnetcdf: ; + } + } + else + { $_ =~ s/CONFIGURE_WRFIO_PNF//g ; + $_ =~ s:CONFIGURE_PNETCDF_FLAG::g ; + $_ =~ s:CONFIGURE_PNETCDF_LIB_PATH::g ; + } + + if ( $sw_hdf5_path ) + { $_ =~ s:CONFIGURE_HDF5_LIB_PATH:-L$sw_hdf5_path/lib -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -lm -lz: ; + $_ =~ s:CONFIGURE_HDF5_FLAG:-DHDF5: ; + } + else + { $_ =~ s:CONFIGURE_HDF5_LIB_PATH::g ; + $_ =~ s:CONFIGURE_HDF5_FLAG::g ; + } + + if ( $sw_phdf5_path ) + + { $_ =~ s/CONFIGURE_WRFIO_PHDF5/wrfio_phdf5/g ; + $_ =~ s:CONFIGURE_PHDF5_FLAG:-DPHDF5: ; + $_ =~ s:CONFIGURE_PHDF5_LIB_PATH:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_phdf5 -lwrfio_phdf5 -L$sw_phdf5_path/lib -lhdf5_fortran -lhdf5 -lm -lz -L$sw_phdf5_path/lib -lsz: ; + } + else + { $_ =~ s/CONFIGURE_WRFIO_PHDF5//g ; + $_ =~ s:CONFIGURE_PHDF5_FLAG::g ; + $_ =~ s:CONFIGURE_PHDF5_LIB_PATH::g ; + } + + if ( $sw_jasperlib_path && $sw_jasperinc_path ) + { $_ =~ s/CONFIGURE_WRFIO_GRIB2/wrfio_grib2/g ; + $_ =~ s:CONFIGURE_GRIB2_FLAG:-DGRIB2:g ; + $_ =~ s:CONFIGURE_GRIB2_INC:-I$sw_jasperinc_path:g ; + $_ =~ s:CONFIGURE_GRIB2_LIB:-L\$\(WRF_SRC_ROOT_DIR\)/external/io_grib2 -lio_grib2 -L$sw_jasperlib_path -ljasper:g ; + } + else + { $_ =~ s/CONFIGURE_WRFIO_GRIB2//g ; + $_ =~ s:CONFIGURE_GRIB2_FLAG::g ; + $_ =~ s:CONFIGURE_GRIB2_INC::g ; + $_ =~ s:CONFIGURE_GRIB2_LIB::g ; + } + if ( $sw_gpfs_path ne "" ) { if (/^GPFS.*=/) { $_ =~ s/\r|\n//g; diff --git a/arch/configure.defaults b/arch/configure.defaults index 45e1079dd4..57b4873a7c 100644 --- a/arch/configure.defaults +++ b/arch/configure.defaults @@ -1556,7 +1556,7 @@ CC_TOOLS = $(SCC) ########################################################### #ARCH CYGWIN_NT i686, PGI compiler on Windows # serial smpar dmpar dm+sm # -DESCRIPTION = PGI ($SFC/$SCC): Windows +DESCRIPTION = PGI ($SFC/$SCC): Windows POSIX native DMPARALLEL = # 1 OMPCPP = # -D_OPENMP OMP = # -mp -Minfo=mp @@ -1916,6 +1916,64 @@ RANLIB = ranlib RLFLAGS = CC_TOOLS = $(SCC) +########################################################### +#ARCH CYGWIN_NT i686 x86_64 Cygwin, gfortran compiler with gcc #serial smpar dmpar dm+sm +# +DESCRIPTION = GNU ($SFC/$SCC) +DMPARALLEL = # 1 +OMPCPP = # -D_OPENMP +OMP = # -fopenmp +OMPCC = # -fopenmp +SFC = gfortran +SCC = gcc +CCOMP = gcc +DM_FC = mpif90 +DM_CC = mpicc +FC = CONFIGURE_FC +CC = CONFIGURE_CC +LD = $(FC) +RWORDSIZE = CONFIGURE_RWORDSIZE +PROMOTION = #-fdefault-real-8 +ARCH_LOCAL = -DNONSTANDARD_SYSTEM_SUBR -DWRF_USE_CLM +CFLAGS_LOCAL = -w -O3 -c +LDFLAGS_LOCAL = +CPLUSPLUSLIB = +ESMF_LDFLAG = $(CPLUSPLUSLIB) +FCOPTIM = -O2 -ftree-vectorize -funroll-loops +FCREDUCEDOPT = $(FCOPTIM) +FCNOOPT = -O0 +FCDEBUG = # -g $(FCNOOPT) # -ggdb -fbacktrace +FORMAT_FIXED = -ffixed-form +FORMAT_FREE = -ffree-form -ffree-line-length-none +FCSUFFIX = +BYTESWAPIO = -fconvert=big-endian -frecord-marker=4 +FCBASEOPTS_NO_G = -w $(FORMAT_FREE) $(BYTESWAPIO) +FCBASEOPTS = $(FCBASEOPTS_NO_G) $(FCDEBUG) +MODULE_SRCH_FLAG = +TRADFLAG = -traditional +CPP = /lib/cpp -P +AR = ar +ARFLAGS = ru +M4 = m4 -G +RANLIB = ranlib +RLFLAGS = +CC_TOOLS = $(SCC) + +LIB_EXTERNAL = \ + $(WRF_SRC_ROOT_DIR)/external/io_netcdf/libwrfio_nf.a CONFIGURE_NETCDF_PATH/lib/libnetcdf.dll.a \ + -L CONFIGURE_NETCDF_PATH -lnetcdff -lnetcdf -lnetcdf -ltirpc -lhdf5_hl -lhdf5 -lm -lz \ + CONFIGURE_GRIB2_LIB +ESMF_IO_LIB = $(WRF_SRC_ROOT_DIR)/external/esmf_time_f90/libesmf_time.a +LIB_BUNDLED = \ + $(WRF_SRC_ROOT_DIR)/external/fftpack/fftpack5/libfftpack.a \ + $(WRF_SRC_ROOT_DIR)/external/io_grib1/libio_grib1.a \ + $(WRF_SRC_ROOT_DIR)/external/io_grib_share/libio_grib_share.a \ + $(WRF_SRC_ROOT_DIR)/external/io_int/libwrfio_int.a \ + $(ESMF_IO_LIB) \ + CONFIGURE_COMMS_LIB \ + $(WRF_SRC_ROOT_DIR)/frame/module_internal_header_util.o \ + $(WRF_SRC_ROOT_DIR)/frame/pack_utils.o + #insert new stanza here ########################################################### diff --git a/arch/postamble b/arch/postamble index fb31cbdc0a..a63454aca3 100644 --- a/arch/postamble +++ b/arch/postamble @@ -55,19 +55,6 @@ INCLUDE_MODULES = $(MODULE_SRCH_FLAG) \ REGISTRY = Registry CC_TOOLS_CFLAGS = CONFIGURE_NMM_CORE -#NOWIN LIB_BUNDLED = \ -#NOWIN $(WRF_SRC_ROOT_DIR)/external/fftpack/fftpack5/libfftpack.a \ -#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_grib1/libio_grib1.a \ -#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_grib_share/libio_grib_share.a \ -#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_int/libwrfio_int.a \ -#NOWIN $(ESMF_IO_LIB) \ -#NOWIN CONFIGURE_COMMS_LIB \ -#NOWIN $(WRF_SRC_ROOT_DIR)/frame/module_internal_header_util.o \ -#NOWIN $(WRF_SRC_ROOT_DIR)/frame/pack_utils.o - -#NOWIN LIB_EXTERNAL = \ -#NOWIN CONFIGURE_NETCDF_LIB_PATH CONFIGURE_PNETCDF_LIB_PATH CONFIGURE_GRIB2_LIB CONFIGURE_ATMOCN_LIB CONFIGURE_HDF5_LIB_PATH - LIB = $(LIB_BUNDLED) $(LIB_EXTERNAL) $(LIB_LOCAL) $(LIB_WRF_HYDRO) LDFLAGS = $(OMP) $(FCFLAGS) $(LDFLAGS_LOCAL) CONFIGURE_LDFLAGS ENVCOMPDEFS = CONFIGURE_COMPILEFLAGS diff --git a/arch/preamble b/arch/preamble index 45354bffa9..38a0773c74 100644 --- a/arch/preamble +++ b/arch/preamble @@ -105,6 +105,19 @@ NETCDF4_DEP_LIB = $(DEP_LIB_PATH) $(HDF5) $(ZLIB) $(GPFS) $(CURL) LIBWRFLIB = libwrflib.a +#NOWIN LIB_BUNDLED = \ +#NOWIN $(WRF_SRC_ROOT_DIR)/external/fftpack/fftpack5/libfftpack.a \ +#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_grib1/libio_grib1.a \ +#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_grib_share/libio_grib_share.a \ +#NOWIN $(WRF_SRC_ROOT_DIR)/external/io_int/libwrfio_int.a \ +#NOWIN $(ESMF_IO_LIB) \ +#NOWIN CONFIGURE_COMMS_LIB \ +#NOWIN $(WRF_SRC_ROOT_DIR)/frame/module_internal_header_util.o \ +#NOWIN $(WRF_SRC_ROOT_DIR)/frame/pack_utils.o + +#NOWIN LIB_EXTERNAL = \ +#NOWIN CONFIGURE_NETCDF_LIB_PATH CONFIGURE_PNETCDF_LIB_PATH CONFIGURE_GRIB2_LIB CONFIGURE_ATMOCN_LIB CONFIGURE_HDF5_LIB_PATH + #### Architecture specific settings #### diff --git a/configure b/configure index 6279f876b3..d3d127811a 100755 --- a/configure +++ b/configure @@ -180,12 +180,12 @@ USENETCDF="" if [ -n "$NETCDF" ] ; then echo "Will use NETCDF in dir: $NETCDF" # Oh UNIDATA, why make it so hard ... - if [ -f "$NETCDF/lib/libnetcdff.a" -o -f "$NETCDF/lib/libnetcdff.so" ] ; then + if [ -f "$NETCDF/lib/libnetcdff.a" -o -f "$NETCDF/lib/libnetcdff.so" -o -f "$NETCDF/lib/libnetcdff.dll.a" ] ; then USENETCDFF="-lnetcdff" else USENETCDFF=" " fi - if [ -f "$NETCDF/lib/libnetcdf.a" -o -f "$NETCDF/lib/libnetcdf.so" ] ; then + if [ -f "$NETCDF/lib/libnetcdf.a" -o -f "$NETCDF/lib/libnetcdf.so" -o -f "$NETCDF/lib/libnetcdf.dll.a" ] ; then USENETCDF="-lnetcdf" else USENETCDF=" " @@ -204,7 +204,7 @@ fi # If the user asked for classic netcdf, acquiesce to the request. -if [ "`uname`" = "Linux" ] ; then +if [ "`uname`" = "Linux" -o "`uname -o`" = "Cygwin" ] ; then ans="`whereis nf-config`" elif [ "`uname`" = "Darwin" ] ; then ans="`which nf-config`" diff --git a/doc/README.cygwin.md b/doc/README.cygwin.md new file mode 100644 index 0000000000..1d8599e951 --- /dev/null +++ b/doc/README.cygwin.md @@ -0,0 +1,79 @@ +# Installing WRF on Cygwin + +1. Download https://cygwin.com/setup-x86_64.exe +2. (Optional) Download https://cygwin.com/setup-x86_64.exe.sig and verify the signature +3. Run `setup-x86_64.exe` + - Select `Install from Internet` + - Pick an installation root (installing directly into `C:\` is not + recommended) + - Pick a directory for a download cache + - If installing Cygwin on multiple computers, these files can + be re-used, skipping the download step on those computers + - `Direct Connection` is nice if it works, but `System Proxy Settings` + may fill in useful data from your OS. + - Select a mirror near you + - Change package view to `Full` + - Select for install at least: + - gcc-core (OpenMP for smpar) + - gcc-fortran + - libnetcdf-fortran-devel + - openmpi (MPI for dmpar) + - libopenmpi-devel (MPI for dmpar) + - libjasper-devel (GRIB) + - perl + - tcsh + - Select install + - Accept the packages pulled in as dependencies + - Wait for download, install, and postinstall steps. This will + take about an hour the first time through + - Decide whether you want shortcuts from the Desktop or Start Menu +4. Open mintty + - If you didn't install shortcuts, you can run the `Cygwin.bat` + file in the root of the Cygwin install tree +5. Follow usual instructions for installing WRF + - Download and unpack source + - `./clean -a` + - Export variables so WRF can find everything: + - `export NETCDF=/usr/ NETCDF4=1 HDF5=/usr` + - (Optional) `export JASPER=/usr JASPERLIB=/usr/lib JASPERINC=/usr/include` + - (Optional) `export WRFIO_NCD_NO_LARGE_FILE_SUPPORT=0 NETCDF_classic=0` + - `./configure`, follow directions + - `./compile`, follow directions + - ... + + +If the compiler reports problems due to `mpi.mod` or `netcdf.mod` +being compiled with a different version of gfortran, subscribe to the +[cygwin mailing list](https://cygwin.com/lists.html) and send a +message there to remind the maintainer that `openmpi` or +`netcdf-fortran` was built with an old version of `gfortran` and to +ask them nicely to update it. + +If the (volunteer) maintainer does not have time, or you want to build +this yourself, re-run `setup-x86_64.exe` and check the `Source?` box +next to `openmpi` or `libnetcdf-fortran-devel`, install `cygport` and +finish the install. Unpack the archives in `/usr/src` (`tar xaf ...` +should do the trick), and `cd` into the new directory. There will be +a `.cygport` file with the build script. Edit this to add a `.1` +after the current release field. Save this file, then run +`cygport ${package}.cygport download prep compile test install package` +If there are errors, try to fix them, then re-run +`cygport ${package}.cygport compile test install package` +Once it compiles, you can follow the directions in +https://cygwin.com/package-server.html#overlay +to set up a local package server and install from that, or you can run +```bash +cd / +for name in /usr/src/${package}-${version}*/${package}-${version}*/dist/**.tar.xz; +do + tar xaf ${name} +done +``` +then re-run setup to make sure everything still works. +The first method plays much nicer with other tools. + +If you feel nice, you can tell the maintainer whether the package +compiled, whether the tests passed and what you needed to do to make +it do that. The contents of +`/usr/src/${package}-${version}*/${package}-${version}*/patch` might +help with that. diff --git a/external/io_netcdf/makefile b/external/io_netcdf/makefile index 05c7967c38..fa638d455f 100644 --- a/external/io_netcdf/makefile +++ b/external/io_netcdf/makefile @@ -50,7 +50,7 @@ diffwrf: diffwrf.F90 $(FC) -c $(FFLAGS) diffwrf.f @if [ \( -f ../../frame/wrf_debug.o \) -a \( -f ../../frame/module_wrf_error.o \) -a \( -f $(ESMF_MOD_DEPENDENCE) \) -a \( -f ../../frame/clog.o \) ] ; then \ echo "diffwrf io_netcdf is being built now. " ; \ - if [ \( -f $(NETCDFPATH)/lib/libnetcdff.a -o -f $(NETCDFPATH)/lib/libnetcdff.so \) ] ; then \ + if [ \( -f $(NETCDFPATH)/lib/libnetcdff.a -o -f $(NETCDFPATH)/lib/libnetcdff.so -o -f $(NETCDFPATH)/lib/libnetcdff.dll.a \) ] ; then \ $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) ../../frame/wrf_debug.o ../../frame/module_wrf_error.o ../../frame/clog.o $(ESMF_IO_LIB_EXT) $(LIBFFS) ;\ else \ $(FC) $(FFLAGS) $(LDFLAGS) -o diffwrf diffwrf.o $(OBJSL) ../../frame/wrf_debug.o ../../frame/module_wrf_error.o ../../frame/clog.o $(ESMF_IO_LIB_EXT) $(LIBS) ;\ diff --git a/tools/Makefile b/tools/Makefile index d2db2161f7..a2c0acf50b 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,6 +12,7 @@ OBJ = registry.o my_strtok.o reg_parse.o data.o type.o misc.o \ registry : $(OBJ) standard.exe $(CC_TOOLS) -o registry $(DEBUG) $(LDFLAGS) $(OBJ) + if [ -x /usr/bin/peflags.exe ] ; then /usr/bin/peflags.exe --stack-reserve=33554432 registry; fi standard.exe : standard.o $(CC_TOOLS) -o standard.exe $(DEBUG) $(LDFLAGS) standard.o