Developing - StormSurgeLive/asgs GitHub Wiki

Pull Requests

General Guidelines

  1. please make sure trailing white spaces are removed (git diff shows these as big red blocks)

  2. make sure all PRs are up to date with the latest master; it will reduce the complication of the PRs

  3. When a commit or pull request resolves an issue, be sure to add a line like "resolves #N" (where N is an issue number) when that gets merged to master, it automatically closes the issue

  4. In order to avoid checkout conflicts on case-insensitive platforms, as well as to avoid confusion in general, make sure that new files that are committed to the repository have names that differ from other files by more than just capitalization.

ASGS Brew

Adding Packages

When adding packages to ASGS Brew the pull request "Added nco v4.9.8 to list of supported programs. #427" provides a concise example of the changes required to implement a new package. Here are the code changes, first to asgs-brew.pl:

        {
            key         => q{nco},
            name        => q{Step for installing the NCO Toolkit},
            description => q{Install The netCDF Operators (NCO) Toolkit}, 
            pwd         => q{./},
            command     => qq{bash ./cloud/general/init-nco.sh $asgs_install_path gfortran 4},
            clean       => qq{bash ./cloud/general/init-nco.sh $asgs_install_path clean},
            skip_if     => sub {
                local $?;
                system(qq{$asgs_install_path/bin/ncwa --version > /dev/null 2>&1});

                # look for zero exit code on success
                my $exit_code = ( $? >> 8 );
                return ( defined $exit_code and $exit_code == 0 ) ? 1 : 0;
            },
            precondition_check  => sub { 1 },
            postcondition_check => sub {
                local $?;
                system(qq{$asgs_install_path/bin/ncwa --version > /dev/null 2>&1});

                # look for zero exit code on success
                my $exit_code = ( $? >> 8 );
                return ( defined $exit_code and $exit_code == 0 ) ? 1 : 0;
            },
        },

And here is the new script init-nco.sh:

#!/usr/bin/env bash

OPT=${1-$ASGS_INSTALL_PATH}
COMPILER=$2
JOBS=${3-1}
TMP=/tmp/$USER-asgs

if [ "$COMPILER" == "clean" ]; then 
  echo cleaning nco
  cd $OPT/include
  rm -rvf libnco_c++.hh nco_dmn.hh nco_hgh.hh nco_var.hh nco_att.hh nco_fl.hh nco_utl.hh
  cd $OPT/lib
  rm -rvf libnco.so libnco.la libnco.a libnco-4.9.8.so libnco_c++.so libnco_c++.la libnco_c++.a libnco_c++-4.9.8.so 
  cd $OPT/bin
  rm -rvf ncwa ncrename ncremap ncrcat ncra ncpdq ncks ncflint nces ncecat ncea ncdiff ncclimo ncbo ncatted
  cd $OPT/share/man/man1
  rm -rvf ncap2.1 ncatted.1 ncbo.1 ncclimo.1 nces.1 ncecat.1 ncflint.1 ncks.1 nco.1 ncra.1 ncremap.1 ncrename.1 ncpdq.1 ncrcat.1 ncwa.1
  cd $TMP
  exit
fi

NCO_VERSION=4.9.8
NCO_DIR=nco-${NCO_VERSION}
NCO_TGZ=${NCO_VERSION}.tar.gz
cd $TMP

if [ ! -e ${NCO_TGZ} ]; then
  wget https://github.com/nco/nco/archive/refs/tags/${NCO_TGZ}
fi

rm -rf ./$NCO_DIR 2> /dev/null

tar zxvf ./$NCO_TGZ

cd $NCO_DIR
./configure --prefix=$OPT
make -j $JOBS
make install

# no errors, so clean up
if [ "$?" == 0 ]; then
  echo cleaning build scripts and downloads
  cd $TMP
  rm -rfv units* 
fi