#!/bin/bash # # svn $Id: build.bash 102 2007-08-13 18:49:51Z arango $ #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # Copyright (c) 2002-2007 The ROMS/TOMS Group ::: # Licensed under a MIT/X style license ::: # See License_ROMS.txt ::: #::::::::::::::::::::::::::::::::::::::::::::::::::::: Hernan G. Arango ::: # ::: # ROMS/TOMS Compiling Script ::: # ::: # Script to compile an user application where the application-specific ::: # files are kept separate from the ROMS source code. ::: # ::: # Q: How/why does this script work? ::: # ::: # A: The ROMS makefile configures user-defined options with a set of ::: # flags such as ROMS_APPLICATION. Browse the makefile to see these. ::: # If an option in the makefile uses the syntax ?= in setting the ::: # default, this means that make will check whether an environment ::: # variable by that name is set in the shell that calls make. If so ::: # the environment variable value overrides the default (and the ::: # user need not maintain separate makefiles, or frequently edit ::: # the makefile, to run separate applications). ::: # ::: # Usage: ::: # ::: # ./build.bash [options] ::: # ::: # Options: ::: # ::: # -j [N] Compile in parallel using N CPUs ::: # omit argument for all available CPUs ::: # -noclean Do not clean already compiled objects ::: # ::: # Notice that sometimes the parallel compilation fail to find MPI ::: # include file "mpif.h". ::: # ::: #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: parallel=0 clean=0 while [ $# -gt 0 ] do case "$1" in -j ) shift parallel=1 test=`echo $1 | grep -P '^\d+$'` if [ "$test" != "" ]; then NCPUS="-j $1" shift else NCPUS="-j" fi ;; -clean ) shift clean=1 ;; * ) echo "" echo "$0 : Unknown option [ $1 ]" echo "" echo "Available Options:" echo "" echo "-j [N] Compile in parallel using N CPUs" echo " omit argument for all avaliable CPUs" echo "-noclean Do not clean already compiled objects" echo "" exit 1 ;; esac done # so mpif90 finds the correct compiler. #export MPICH_F90=ifort # Set the CPP option defining the particular application. This will # determine the name of the ".h" header file with the application # CPP definitions. export ROMS_APPLICATION=SWF_FUGATE # Set a local environmental variable to define the path to the directories # where all this project's files are kept. export MY_ROOT_DIR=/home/beach/guest/dafu8991 export MY_PROJECT_DIR=${MY_ROOT_DIR}/CALUS # The path to the user's local current ROMS source code. # # If using svn locally, this would be the user's Working Copy Path (WCPATH). # Note that one advantage of maintaining your source code locally with svn # is that when working simultaneously on multiple machines (e.g. a local # workstation, a local cluster and a remote supercomputer) you can checkout # the latest release and always get an up-to-date customized source on each # machine. This script is designed to more easily allow for differing paths # to the code and inputs on differing machines. export MY_ROMS_SRC=${MY_ROOT_DIR}/trunk # Set tunable CPP options. # # Sometimes it is desirable to activate one or more CPP options to run # different variants of the same application without modifying its header # file. If this is the case, specify each options here using the -D syntax. # Notice also that you need to use shell's quoting syntax to enclose the # definition. Both single or double quotes works. For example, to write # time-averaged fields set: # #export MY_CPP_FLAGS="-DAVERAGES" # export MY_CPP_FLAGS="-DNPZD_POWELL" # Other user defined environmental variables. See the ROMS makefile for # details on other options the user might want to set here. export USE_MPI=on export USE_MPIF90=on #export FORT=ifort export FORT=gfortran #export USE_OpenMP=on #export USE_DEBUG=on export USE_LARGE=on export USE_NETCDF4=on # The rest of this script sets the path to the users header file and # analytical source files, if any. See the templates in User/Functionals. export MY_HEADER_DIR=${MY_PROJECT_DIR}/INCLUDE # ckh: if set up project-specific analytical files (ana*.h) # then specify their location here export MY_ANALYTICAL_DIR=${MY_PROJECT_DIR}/FUNCTIONALS # Put the binary to execute in the following directory. export BINDIR=${MY_PROJECT_DIR} # Put the f90 files in a project specific Build directory to avoid conflict # with other projects. export SCRATCH_DIR=${MY_PROJECT_DIR}/Build # Go to the users source directory to compile. The options set above will # pick up the application-specific code from the appropriate place. cd ${MY_ROMS_SRC} # Remove build directory. if [ $clean -eq 1 ]; then make clean fi # Compile (the binary will go to BINDIR set above). if [ $parallel -eq 1 ]; then make $NCPUS else make fi