Error in compiling hysplit v5: chmgea.f

Post any questions or comments regarding the LINUX version of HYSPLIT. This includes the model execution, GUIs, results, or graphics. Be sure to mention the version of LINUX you are using.
Post Reply
Christopher
Posts: 7
Joined: June 15th, 2021, 9:13 am
Registered HYSPLIT User: Yes

Error in compiling hysplit v5: chmgea.f

Post by Christopher »

I'm trying to compile hysplit as part of a docker container and am getting the same error for v5.0.1 and v5.1.0.

It starts with:

Code: Select all

gfortran -c -O2 -fconvert=big-endian -frecord-marker=4 -ffree-form chmgea.f
chmgea.f:109:20:

  109 |       DATA NPLOT/4HSAVE/
      |                    1
Warning: Legacy Extension: Hollerith constant at (1)
...

continues with a bunch more similar warnings, then ends with

...

Code: Select all

Warning: Extension: Conversion from HOLLERITH to INTEGER(4) at (1)
chmgea.f:1624:61:

 1624 |  IW1(1,8),Y(1,4),Y(1,5),IER)
      |                                                             1
Error: Type mismatch in argument 'p' at (1); passed REAL(8) to INTEGER(4)
chmgea.f:1943:73:

 1943 |       IW1(1,8))
      |                                                                         1
Error: Type mismatch in argument 'jawork' at (1); passed REAL(8) to INTEGER(4)
make[1]: *** [Makefile:275: chmgea.o] Error 1
make[1]: Leaving directory '/hysplit/hysplit.v5.0.2/library/hysplit'
The dockerfile I'm using is

Code: Select all

FROM python:3-alpine

USER root

#WORKDIR /code

# install necessary programs/libraries
ARG REQUIRE="sudo bash build-base gcc g++ valgrind musl-dev linux-headers subversion gdal gdal-dev tcl tk imagemagick gfortran netcdf make unzip git cmake wget openjpeg perl libffi-dev libffi"

RUN apk update && apk upgrade && apk add --no-cache ${REQUIRE}

# MPICH
# Build Options:
# See installation guide of target MPICH version
# Ex: http://www.mpich.org/static/downloads/3.2/mpich-3.2-installguide.pdf
# These options are passed to the steps below
# version 3.4+ fail with a make error
ARG MPICH_VERSION="3.2"
ARG MPICH_CONFIGURE_OPTIONS="FFLAGS=-fallow-argument-mismatch --enable-fast=all,O3 --enable-shared"
ARG MPICH_MAKE_OPTIONS="-j4"

# Download, build, and install MPICH
RUN mkdir /tmp/mpich-src
WORKDIR /tmp/mpich-src
RUN wget http://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz \
      && tar xfz mpich-${MPICH_VERSION}.tar.gz

WORKDIR /tmp/mpich-src/mpich-${MPICH_VERSION}
RUN ./configure ${MPICH_CONFIGURE_OPTIONS}
RUN make ${MPICH_MAKE_OPTIONS}
RUN make install
RUN rm -rf /tmp/mpich-src

ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"

# grib2
ARG GRIB2_VERSION="3.0.2"
ENV CC gcc
ENV FC gfortran

RUN mkdir /grib2
WORKDIR /grib2

RUN wget https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v${GRIB2_VERSION} \
        && tar xfz wgrib2.tgz.v${GRIB2_VERSION} \
        && cd grib2/ \
        && make
RUN cp /grib2/grib2/wgrib2/wgrib2 /usr/bin



# eccodes
ARG ECCODES_VERSION="2.22.1"

RUN mkdir /eccodes
WORKDIR /eccodes
RUN wget https://confluence.ecmwf.int/download/attachments/45757960/eccodes-${ECCODES_VERSION}-Source.tar.gz
RUN tar xfz eccodes-${ECCODES_VERSION}-Source.tar.gz \
        && mkdir build \
        && cd build \
        && mkdir /usr/src/eccodes \
        && cmake -DCMAKE_INSTALL_PREFIX=/usr/src/eccodes -DENABLE_JPG=ON ../eccodes-${ECCODES_VERSION}-Source
WORKDIR /eccodes/build
RUN make
#RUN ctest
RUN make install
RUN cp -r /usr/src/eccodes/bin/* /usr/bin

ENV ECCODES_DIR /usr/src/eccodes
ENV ECCODES_DEFINITION_PATH /usr/src/eccodes/share/eccodes/definitions

RUN pip3 install eccodes
RUN python3 -m eccodes selfcheck

# hysplit
ENV HYSPLIT_VERSION="5.0.2"
ARG HYSPLIT_PASSWORD=

RUN mkdir /hysplit
WORKDIR /hysplit
RUN svn --username guest --password ${HYSPLIT_PASSWORD} export https://svn.arl.noaa.gov:8443/svn/hysplit/tags/hysplit.v${HYSPLIT_VERSION}
RUN cd hysplit.v${HYSPLIT_VERSION}
WORKDIR hysplit.v${HYSPLIT_VERSION}
RUN cp Makefile.inc.gfortran Makefile.inc
#RUN make

CMD ["tail", "-f", "/dev/null"]
Any idea on where to look for the problem and/or solution?
Last edited by Christopher on August 26th, 2021, 1:00 pm, edited 1 time in total.
Christopher
Posts: 7
Joined: June 15th, 2021, 9:13 am
Registered HYSPLIT User: Yes

Re: Error in compiling hysplit v5: chmgea.f

Post by Christopher »

The fortran errors were fixed by adding -std=legacy to the FFLAGS in Makefile.inc

Though now I'm getting C errors:

Code: Select all

make[2]: Leaving directory '/hysplit/hysplit.v5.1.0/gisprog/arlshapes/contour'
gcc -g -O2 -o shapeHysplitOut shapeHysplitOut.c -I arcview2 -I arcview1 -I contour -I shapeutil -L.  -lshapext -lshp -lcontour -lshaputil -lm
/usr/lib/gcc/x86_64-alpine-linux-musl/10.3.1/../../../../x86_64-alpine-linux-musl/bin/ld: ./libcontour.a(shapeContour.o):/hysplit/hysplit.v5.1.0/gisprog/arlshapes/contour/shapeContour.c:29: multiple definition
of `doSplit'; /tmp/ccjIKaMD.o:/hysplit/hysplit.v5.1.0/gisprog/arlshapes/shapeHysplitOut.c:20: first defined here
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:60: shapeHysplitOut] Error 1
make[1]: Leaving directory '/hysplit/hysplit.v5.1.0/gisprog/arlshapes'
Adding -fcommon to the Makefile.inc CFLAGS didn't translate down to the arlshapes Makefile. Turns out that in controlled by ./configure, so after editing the arlshapes/configure file to add -fcommon to CFLAGS, it compiles.

Now I'm down to an error of not finding netcdf.inc.

I would suggest making the above FFLAGS and CFLAGS changes in the main branch so that hysplit will compile on the latest gcc/gfortran. Or the code could be cleaned up so that you don't need flags to allow for depreciated coding practices, but flags are easier.
Christopher
Posts: 7
Joined: June 15th, 2021, 9:13 am
Registered HYSPLIT User: Yes

Re: Error in compiling hysplit v5: chmgea.f

Post by Christopher »

OK, finally got a clean compile into a docker container

The Dockerfile is below if anyone wants to use it as a base for their project.

I'm starting with python:3-alpine because most of my scripts that use hysplit are in Python and alpine is a pretty common base for docker containers. Though to get netcdf to easily install, I had to move the alpine repositories to "edge".

There are three sed commands to add the necessary flags to have the compiler not complain about some of the crustier codes:

# add fortran flag
sed -i 's/^\(FFLAGS=.*\)/\1 -std=legacy /g' Makefile.inc

# add C flag
sed -i 's/^\(CFLAGS=.*\)/\1 -fcommon /g' Makefile.inc
sed -i 's/\(\.\/configure\)/\1 CFLAGS=\"\$(CFLAGS)\" /g' Makefile

These changes probably should be made to the HYSPLIT codebase.

While I can see why the HYSPLIT team might not want a prebuilt docker container on DockerHub, you might want to consider adding a Dockerfile similar to the one below to the linux distribution source tree so users can easily build their own container.

Code: Select all

FROM python:3-alpine

USER root

#WORKDIR /code

# change to alpine edge repository in order to get netcdf-fortran to install right
RUN rm /etc/apk/repositories
RUN touch /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories


# install necessary programs/libraries
ARG REQUIRE="sudo bash build-base gcc g++ valgrind musl-dev linux-headers subversion gdal gdal-dev tcl tk imagemagick gfortran netcdf make unzip git cmake wget openjpeg perl libffi-dev libffi netcdf netcdf-fortran netcdf-fortran-dev"

RUN apk update && apk upgrade && apk add --no-cache ${REQUIRE}

# MPICH
# Build Options:
# See installation guide of target MPICH version
# Ex: http://www.mpich.org/static/downloads/3.2/mpich-3.2-installguide.pdf
# These options are passed to the steps below
# version 3.4+ fail with a make error
ARG MPICH_VERSION="3.2"
ARG MPICH_CONFIGURE_OPTIONS="FFLAGS=-fallow-argument-mismatch --enable-fast=all,O3 --enable-shared"
ARG MPICH_MAKE_OPTIONS="-j4"

# Download, build, and install MPICH
RUN mkdir /tmp/mpich-src
WORKDIR /tmp/mpich-src
RUN wget http://www.mpich.org/static/downloads/${MPICH_VERSION}/mpich-${MPICH_VERSION}.tar.gz \
      && tar xfz mpich-${MPICH_VERSION}.tar.gz

WORKDIR /tmp/mpich-src/mpich-${MPICH_VERSION}
RUN ./configure ${MPICH_CONFIGURE_OPTIONS}
RUN make ${MPICH_MAKE_OPTIONS}
RUN make install
RUN rm -rf /tmp/mpich-src

ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"


#### TEST MPICH INSTALLATION ####
#RUN mkdir /tmp/mpich-test
#WORKDIR /tmp/mpich-test
#COPY mpich-test .
#RUN sh test.sh
#RUN rm -rf /tmp/mpich-test


#### CLEAN UP ####
WORKDIR /
#RUN rm -rf /tmp/*



# grib2
ARG GRIB2_VERSION="3.0.2"
ENV CC gcc
ENV FC gfortran

RUN mkdir /grib2
WORKDIR /grib2

RUN wget https://www.ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v${GRIB2_VERSION} \
        && tar xfz wgrib2.tgz.v${GRIB2_VERSION} \
        && cd grib2/ \
        && make
RUN cp /grib2/grib2/wgrib2/wgrib2 /usr/bin



# eccodes
ARG ECCODES_VERSION="2.22.1"

RUN mkdir /eccodes
WORKDIR /eccodes
RUN wget https://confluence.ecmwf.int/download/attachments/45757960/eccodes-${ECCODES_VERSION}-Source.tar.gz
RUN tar xfz eccodes-${ECCODES_VERSION}-Source.tar.gz \
        && mkdir build \
        && cd build \
        && mkdir /usr/src/eccodes \
        && cmake -DCMAKE_INSTALL_PREFIX=/usr/src/eccodes -DENABLE_JPG=ON ../eccodes-${ECCODES_VERSION}-Source
WORKDIR /eccodes/build
RUN make
#RUN ctest
RUN make install
RUN cp -r /usr/src/eccodes/bin/* /usr/bin

ENV ECCODES_DIR /usr/src/eccodes
ENV ECCODES_DEFINITION_PATH /usr/src/eccodes/share/eccodes/definitions

RUN pip3 install eccodes
RUN python3 -m eccodes selfcheck



# hysplit
ENV HYSPLIT_VERSION="5.1.0"
ARG HYSPLIT_PASSWORD=

RUN mkdir /hysplit
WORKDIR /hysplit
RUN svn --username guest --password ${HYSPLIT_PASSWORD} export https://svn.arl.noaa.gov:8443/svn/hysplit/tags/hysplit.v${HYSPLIT_VERSION}
RUN cd hysplit.v${HYSPLIT_VERSION}
WORKDIR hysplit.v${HYSPLIT_VERSION}
RUN cp Makefile.inc.gfortran Makefile.inc

# add fortran flag
RUN sed -i 's/^\(FFLAGS=.*\)/\1 -std=legacy /g' Makefile.inc

# add C flag
RUN sed -i 's/^\(CFLAGS=.*\)/\1 -fcommon /g' Makefile.inc
RUN sed -i 's/\(\.\/configure\)/\1 CFLAGS=\"\$(CFLAGS)\" /g'  Makefile

RUN make
#RUN make install
#RUN rm -fr source_bulids/


CMD ["tail", "-f", "/dev/null"]

sonny.zinn
Posts: 354
Joined: May 8th, 2019, 1:31 pm
Registered HYSPLIT User: Yes

Re: Error in compiling hysplit v5: chmgea.f

Post by sonny.zinn »

Thank you for informing us of the compilation issues and for sharing the docker image builder. You have done good work there. We will add the compilation issues to our to-do list.
Post Reply

Return to “HYSPLIT for LINUX”