Skip to content

Using CDF Distiller

andybeet edited this page Nov 15, 2023 · 4 revisions

CDF Distiller is a c++ utility (created by CSIRO) that creates a snapshot of the models end state and creates a new initial conditions (nc) file from this point in time. The model can then be run from this endpoint without having to run the model in its entirety.

To utilize CDF Distiller you will need to download the source code from CSIRO and add some additional lines of code to you Dockerfile. The resulting image will have dual functionality.

  1. Run Atlantis
  2. Run CDF Distiller

Dockerfile

The Dockerfile for model version 6669+ will look like this:

FROM ubuntu:18.04

ENV TZ=America/New_York
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -yq build-essential autoconf libnetcdf-dev libxml2-dev     libproj-dev subversion valgrind dos2unix nano r-base

COPY .svn /app/.svn
COPY atlantis /app/atlantis
COPY CDFDistiller /CDFDistiller

# Compile atlantis code
RUN cd /app/atlantis && aclocal && autoheader && autoconf && automake -a && ./configure --enable-rassesslink && make && make install

# Compile CDF Distiller code
ENV PKG_CONFIG_PATH=/app/model
RUN cd /CDFDistiller && aclocal && autoheader && autoconf && automake -a && ./configure && make && make install

WORKDIR /app/model

ENTRYPOINT ["sh"]

CMD ["RunAtlantis.sh"]

The atlantis code and the cdfDistiller code should be in folders on the same level. Your Dockerfile should be one level up. The structure should look like this:

  --root
   |-- atlantis
   |   |__ altantis files
   |-- .svn
   |   |__ svn files
   |-- CDFDistiller
   |
   |__Dockerfile

Build

Build your image as described in Getting Started

Run

You will need to copy output.nc in to the folder containing the .prm files and create a sample run_distiller.prm file that looks like this:

# Run parameters
  verbose      0 	# Detailed logged output, 1 = 2x messages, 3/4 = slightly more, 5 = every routine

title      NEUS v1.5 with fishing
flagdump   0           # flag indicating whether use max dump in file (0) or user specified dump (1)
start_dump 10          # dump to use of flagdump = 1

dt         24 hour     # 24 hour time step
flagtimerest 1   # flag indicating whether to use t from original file (0) or set to value in tstop (1)

tstop      20805 day   # Stop time after the given period (18260)18260  , 4000   2191 7320 9120 3660 7320 (01-01-1964 to 12-31-2017 is 19724 d)

flagflipdz 1           # flag to flip dz if necessary (0 of old output.nc file, 1 for newer output.nc files)

wc_dz_tol  0.2        # Tolerance for water column dz values. The model only allows this much fractional
                  # change before dz is reset to nominal value

Then on the command line:

podman run  --rm --mount "type=bind,src=pathToInputFiles/,dst=/app/model" imageName distiller.sh

where distiller.sh:

#!/bin/bash
find /app/model -type f | xargs dos2unix
find /CDFDistiller -type f | xargs dos2unix


CDFDistiller -i model_output.nc -o newinput.nc -r run_distiller.prm