-
Notifications
You must be signed in to change notification settings - Fork 7
BuildAndTest
Prev: Contents
Socrates is written in Fortran 2018 with shell scripts in bash and utilities written in python 3. The code can be used with text CDL input/output but it is recommended to use netCDF. All dependencies are generally available via the package manager of any linux distribution:
- Fortran 2018 compiler: gfortran or ifort are recommended
- Shell: bash
- NetCDF (optional but recommended)
- python 3 (optional)
Checkout the latest trunk code into the 'socrates' directory:
git clone git@github.com:MetOffice/socrates
Enter this directory and familiarise yourself with the directory structure with reference to the README.md file:
cd socrates
less README.md
Socrates is compiled using the build_code script in the top level directory. For users within the Met Office this script should work out-of-the-box. For other users, the local configuration needs to be set in the file make/Mk_cmd. For example, for a linux distribution with gfortran and netCDF installed via a package manager, the default make/Mk_cmd file may work:
FORTCOMP = gfortran -O -c
LINK = gfortran -O
LIBLINK = ar rvu
INCCDF_PATH = /usr/local/include
LIBCDF_PATH = /usr/local/lib
LIBCDF_NAME = netcdff
OMPARG = -fopenmp
FLAGS_ODEPACK = -w -std=legacy -fallow-argument-mismatch
LIBSUFFIX = a
.SUFFIXES: $(SUFFIXES) .f90
FORTCOMP and LINK should give the name of the local Fortran compiler with compilation and linking options respectively. INCCDF_PATH should give the location of the netCDF include and module files (netcdf.h, netcdf.mod) and LIBCDF_PATH the location of the Fortran netCDF library file. The name of the Fortran netCDF library file is then specified by LIBCDF_NAME and LIBSUFFIX. For example, if the Fotran netCDF library file is called libnetcdff.a (with 2 f's) then these options should be as given above. The paths given to the netCDF files should be for a version of netCDF which has been compiled with the same compiler specified in FORTCOMP and LINK.
Once this is set up the build_code script can be run to compile the whole suite:
./build_code
Alternatively, individual programs can be built be specifying their names as an option to the script, e.g.:
./build_code l_run_cdf
The build_code script will set up a file called "set_rad_env" in the top level directory. This file sets the PATH to all the executables in the suite (and the man pages) and needs to be sourced before running the code:
. ./set_rad_env
''Note: this needs to be done from each login window before running the code.''
The examples/ directory contains a number of different configurations for running programs in the suite. Two scripts in this directory: quick_tests and slow_tests will run each of the examples and compare the output to "known good output" (KGO). To run the tests:
cd examples
./quick_tests
If all is well, each test should report "OK" and at the end "All passed".
The KGOs are results from runs made in the Met Office using the ifort and gfortran compilers. If different compilers are used then the results are expected to differ in the less significant digits, so the tests will return "Some tests failed" and state the output files that differ. These can be checked manually to see if the differences are significant. External users can provide their own KGOs and Mk_cmd files so that the build and tests work out-of-the box for future versions of the code.