From fad98794d6d3c33cffba45baa8cac41d47cdc79e Mon Sep 17 00:00:00 2001 From: Gervasio Perez Date: Fri, 14 Jul 2023 12:41:00 +0000 Subject: [PATCH] WRF+WPS 4.4 v1 --- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ wps.nix | 41 +++++++++++++++++++++++++++++++++++++++++ wrf.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 137 insertions(+) create mode 100644 README.md create mode 100644 wps.nix create mode 100644 wrf.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce71ab1 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# COMPILACIÒN DE WRF + +Este instructivo permite compilar WRF v4.4 con HDF5. + +## Activar entorno NIX + +``` +$ enable_nix +``` + +## Clonar este repositorio y bajar/compilar fuentes de WRF + +``` +$ git clone https://git.csc.gob.ar/tupac/wrf-nix.git +$ cd wrf-nix +$ nix-shell wrf.nix +# [esperar a que se active el entorno Nix] +# unpackPhase: función de Nix que baja y descomprime el fuente de WRF +# Necesario por unica vez +$ unpackPhase +$ cd WRF +$ ./configure +# Seleccionar opciones 34 y 1 +$ ./compile -j 4 wrf +$ ./compile -j 4 em_real +$ exit +``` + +## Compilar WPS + +A continuación podemos compilar WPS (desde la carpeta base del repo): + +``` +$ nix-shell wps.nix +$ [esperar a que se active el entorno Nix] +# unpackPhase: función de Nix que baja y descomprime el fuente de WPS +# Necesario por unica vez +$ unpackPhase +$ cd WPS-4.4 +$ ./configure +# Seleccionar opcion 3, linux paralelo +$ ./compile +$ exit +``` + diff --git a/wps.nix b/wps.nix new file mode 100644 index 0000000..891957d --- /dev/null +++ b/wps.nix @@ -0,0 +1,41 @@ +#{ lib, stdenv, fetchurl, gfortran, mpi, jasper, netcdf, netcdf-fortran, zlib, removeReferencesTo}: + +with import {}; + +let netcdf-full = pkgs.buildEnv { + name = "netcdf+c+fortran"; + paths = [ + netcdf + netcdffortran + ]; + }; +in + +stdenv.mkDerivation { + pname = "WPS"; + version = "4.4"; + + src = fetchurl { + url = "https://github.com/wrf-model/WPS/archive/refs/tags/v4.4.tar.gz"; + sha256 = "sha256-/pyNippKu/gAsw5suzeGBMYEDkU29VlLji2uQ+lC4rM="; + }; + + nativeBuildInputs = [ m4 removeReferencesTo ]; + buildInputs = [ mpi netcdf-full gfortran zlib jasper openmpi libpng gomp ]; + dontAddPrefix=true; + env.NETCDF=netcdf-full; + env.JASPERLIB=jasper + "/lib"; + env.JASPERINC=jasper + "/include"; + env.WRF_DIR = "../WRF"; + env.NIX_LDFLAGS = "-lnetcdff"; + configurePhase= '' + bash -c "echo 35 | ./configure" + ''; + + buildPhase= '' + bash -c "./compile wrf" + ''; + + installPhase= '' + ''; +} diff --git a/wrf.nix b/wrf.nix new file mode 100644 index 0000000..c290320 --- /dev/null +++ b/wrf.nix @@ -0,0 +1,51 @@ +#{ lib, stdenv, fetchurl, gfortran, mpi, jasper, netcdf, netcdffortran, zlib, removeReferencesTo}: + +with import {}; + +let netcdf-full = pkgs.buildEnv { + name = "netcdf+c+fortran"; + paths = [ + netcdf + netcdffortran + ]; +}; +in + +gcc9Stdenv.mkDerivation { + pname = "WRF"; + version = "4.4.2"; + + src = fetchurl { + url = "https://github.com/wrf-model/WRF/releases/download/v4.4.2/v4.4.2.tar.gz"; + sha256 = "sha256-SIuZLo6ZRjfFjjxp6GmtBaz+eUGcAfvvat4fYk5Q3Do="; + }; + + nativeBuildInputs = [ m4 removeReferencesTo ]; + buildInputs = [ mpi + netcdf-full + gfortran + zlib + jasper + openmpi + libpng + gomp + hdf5-mpi + hdf5-fortran]; + dontAddPrefix=true; + env.HDF5=hdf5-mpi; + env.NETCDF=netcdf-full; + env.JASPERLIB=jasper + "/lib"; + env.JASPERINC=jasper + "/include"; + NIX_CFLAGS_COMPILE = "-Wno-format-security"; + env.NIX_LDFLAGS = "-lnetcdff"; + configurePhase= '' + bash -c "echo 34 | ./configure" + ''; + + buildPhase= '' + bash -c "./compile wrf" + ''; + + installPhase= '' + ''; +}