Windows MSYS2 - gher-uliege/Documentation GitHub Wiki

  • Install MSYS2 from http://www.msys2.org/
  • Once MSYS2 is installed, it will open a shell. Update repositories with:
pacman -Syu

To search of a package called e.g. gfortran use:

pacman -Ss gfortran

Install compilers

pacman -S mingw64/mingw-w64-x86_64-gcc-fortran mingw64/mingw-w64-x86_64-gcc

Install some libraries. NetCDF and HDF5 depend on szip but this dependency seems to be not explicit.

pacman -S git
pacman -S mingw64/mingw-w64-x86_64-netcdf
pacman -S mingw64/mingw-w64-x86_64-szip
pacman -S mingw64/mingw-w64-x86_64-lapack mingw64/mingw-w64-x86_64-blas
pacman -S mingw64/mingw-w64-x86_64-arpack
pacman -S msys/tar
pacman -S msys/colordiff

In a directory without a space (otherwise installation will fail)

wget ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-fortran-4.4.4.tar.gz
tar -zxvf netcdf-fortran-4.4.4.tar.gz 
cd netcdf-fortran-4.4.4
./configure

DINEOF

Get the code:

git clone https://github.com/aida-alvera/DINEOF.git
cd DINEOF/

Compile:

make OS=mingw SSTATIC=on LIBS="-L/usr/lib -llapack -larpack -lopenblas -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz -lszip"
$ ldd dineof.exe
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7ffaecac0000)
        KERNEL32.DLL => /c/WINDOWS/system32/KERNEL32.DLL (0x7ffaec340000)
        KERNELBASE.dll => /c/WINDOWS/system32/KERNELBASE.dll (0x7ffae9530000)
        msvcrt.dll => /c/WINDOWS/system32/msvcrt.dll (0x7ffaeb540000)
        USER32.dll => /c/WINDOWS/system32/USER32.dll (0x7ffaec0b0000)
        GDI32.dll => /c/WINDOWS/system32/GDI32.dll (0x7ffaebc50000)

Dynamic compilation fails

Probably a bug of netcdf-fortran on Windows https://github.com/Unidata/netcdf-c/issues/554:

C:/msys64/usr/lib/libnetcdff.a(nf_nc4.o): In function `nf_create_par_':
C:\msys64\home\Alexander Barth\netcdf-fortran-4.4.4\fortran/nf_nc4.f90:61: undefined reference to `nc_create_par_fortran'
C:/msys64/usr/lib/libnetcdff.a(nf_nc4.o): In function `nf_open_par_':
C:\msys64\home\Alexander Barth\netcdf-fortran-4.4.4\fortran/nf_nc4.f90:94: undefined reference to `nc_open_par_fortran'
C:/msys64/usr/lib/libnetcdff.a(nf_nc4.o): In function `nf_var_par_access_':
C:\msys64\home\Alexander Barth\netcdf-fortran-4.4.4\fortran/nf_nc4.f90:121: undefined reference to `nc_var_par_access'
collect2.exe: error: ld returned 1 exit status
make: *** [Makefile:78: dineof] Error 1