Skip to content

Commit

Permalink
Deprecate serial_build and parallel_build scripts
Browse files Browse the repository at this point in the history
This change simplifies the CABLE offline build system by deprecating the
`serial_build` and `parallel_build` build scripts and moving their
functionality into the Makefile.

Fixes #189
  • Loading branch information
SeanBryan51 committed Dec 15, 2023
1 parent 958ec04 commit 4dcd54e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 67 deletions.
11 changes: 4 additions & 7 deletions documentation/docs/user_guide/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ graph TD
A(Clone CABLE with git):::UserAction -->|Serial?| B(Run `offline/build3.sh`):::UserAction;
B --> D[load modules, set compiler flags, create .tmp/ directory];
D -->|Serial?| E[Run `serial_cable`];
D -->|Serial?| E[Run `make`];
E --> G[executable `cable`]:::Output;
A -->|Parallel?| C(Run `offline/build3.sh mpi`):::UserAction;
C --> D;
D -->|Parallel?| F[Run `parallel_cable`];
D -->|Parallel?| F[Run `make mpi`];
F --> H[executable `cable_mpi`]:::Output;
click A "http://cable.readthedocs.io/en/latest/user_guide/installation/#getting-the-cable-source-code"
click B "http://cable.readthedocs.io/en/latest/user_guide/installation/#launching-the-build"
Expand Down Expand Up @@ -101,12 +101,9 @@ The build script:
1. loads modules for the Fortran compiler and the netCDF library
2. sets the compiler flags
3. creates a hidden temporary directory (`.tmp/`) in which it then compiles CABLE.
4. executes `make` in the hidden temporary directory

A [Makefile][makefile] compiles the CABLE code that is common to both serial and parallel CABLE. This includes all the files under the `science/`, `util/`, and `params/` directories.

A serial compilation then calls `serial_cable` to compile the serial driver and link everything together to produce the executable, `cable`.

A parallel compilation then calls `parallel_cable` to compile the required MPI driver(s) and link everything together to produce the executable, `cable-mpi`.
The [Makefile][makefile] compiles the serial executable by default (via `make`) and compiles the MPI executable via the `mpi` target (via `make mpi`).

The hidden `.tmp/` directory is really only needed for technical reasons and you should never need to go
into the `.tmp/` directory. However, if for some reason you want the **.o** object files created by the compiler, they persist in this directory. Alternatively, it is sometimes useful to verify that the files you want to compile are actually making it into this directory. This is particularly relevant if you are adding new files to CABLE.
Expand Down
27 changes: 24 additions & 3 deletions src/offline/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
# ==============================================================================
##########################################################################

.PHONY: serial mpi common

# these are all the files we are compiling
LSRC = \
cable_maths_constants_mod.F90 \
Expand Down Expand Up @@ -149,7 +151,8 @@ casa_sumcflux.F90


# this is the executable we are building
PROG = cable
PROG_SERIAL = cable
PROG_MPI = cable-mpi

# from the compiled object files
OBJS = ${LSRC:.F90=.o}
Expand All @@ -165,7 +168,25 @@ CINC = -I$(NCMOD)
$(FC) $(CFLAGS) $(CINC) -c $<

# default target by convention is ``all''
all :
all: serial

serial: supr = -warn nostderrors -diag-disable 10145
serial: FOBJS = $(shell ls *.o)
serial: cable_driver.F90 common
rm -f cable_driver.o
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) $(LD) -o $(PROG_SERIAL) cable_driver.F90 $(FOBJS) $(CINC)

mpi: supr = -warn nostderrors -diag-disable 10145
mpi: FOBJS = $(shell ls *.o)
mpi: cable_mpidrv.F90 cable_mpicommon.F90 pop_mpi.F90 cable_mpiworker.F90 cable_mpimaster.F90 common
rm -f cable-mpi
rm -f cable_mpi*.o
rm -f pop_mpi.o
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) -c cable_mpicommon.F90 $(FOBJS) $(CINC)
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) -c pop_mpi.F90 cable_mpicommon.o $(FOBJS) $(CINC)
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) -c cable_mpiworker.F90 cable_mpicommon.o pop_mpi.o $(FOBJS) $(CINC)
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) -c cable_mpimaster.F90 cable_mpicommon.o cable_mpiworker.o pop_mpi.o $(FOBJS) $(CINC)
$(FC) $(supr) $(CFLAGS) $(LDFLAGS) -o $(PROG_MPI) cable_mpidrv.F90 cable_mpicommon.o cable_mpimaster.o cable_mpiworker.o pop_mpi.o $(FOBJS) $(CINC) $(LD)

# dependencies, compilation rules for ALL files needed for "all" (LSRC)
#================================================================
Expand Down Expand Up @@ -351,7 +372,7 @@ landuse3.o: landuse3.F90 cable_define_types.o casa_dimension.o landuse_constant.
landuse_inout.o: landuse_inout.F90 cable_define_types.o landuse_constant.o landuse3.o cable_common.o cable_iovars.o cable_abort.o

# these are all the files we are compiling
all : grid_constants_cbl.o \
common : grid_constants_cbl.o \
cable_maths_constants_mod.o \
cable_phys_constants_mod.o \
cable_other_constants_mod.o \
Expand Down
7 changes: 2 additions & 5 deletions src/offline/build3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ build_build()
/bin/cp -p $UTI/*90 ./.tmp
/bin/cp -p $PAR/*90 ./.tmp

/bin/cp -p serial_cable ./.tmp
/bin/cp -p parallel_cable ./.tmp
/bin/cp -p Makefile ./.tmp

cd .tmp/
Expand All @@ -122,11 +120,10 @@ echo ''
echo 'Building drivers for either serial or MPI application'
echo ''

make -f Makefile #this makes elements of CABLE that are common to all apps
if [[ $1 = 'mpi' ]]; then
./parallel_cable "$FC" "$CFLAGS" "$LDFLAGS" "$LD" "$NCMOD"
make mpi
else
./serial_cable "$FC" "$CFLAGS" "$LDFLAGS" "$LD" "$NCMOD"
make
fi

}
Expand Down
29 changes: 0 additions & 29 deletions src/offline/parallel_cable

This file was deleted.

23 changes: 0 additions & 23 deletions src/offline/serial_cable

This file was deleted.

0 comments on commit 4dcd54e

Please sign in to comment.