diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e3c6f7..b456a5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Check CMake version -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.12) include("${CMAKE_SOURCE_DIR}/cmake/Obs2Ioda_Functions.cmake") # Define the project @@ -15,9 +15,21 @@ install(DIRECTORY ${CMAKE_BINARY_DIR}/${OBS2IODA_MODULE_DIR}/ DESTINATION ${CMAK # Set the Fortran compiler and flags set(NCEP_BUFR_LIB CACHE STRING "" ) +# Set to ON to build tests. Default is OFF. If testing is enabled, +# pFUnit is required to be installed. +set(BUILD_TESTS CACHE BOOL OFF) +# Set the path to the pFUnit installation directory if BUILD_TESTS is ON +set(PFUNIT_DIR CACHE STRING "" ) # Find required packages find_package(NetCDF REQUIRED COMPONENTS Fortran C) add_subdirectory("${CMAKE_SOURCE_DIR}/obs2ioda-v2") +if (BUILD_TESTS) + enable_testing() + set(CMAKE_PREFIX_PATH ${PFUNIT_DIR}) + find_package(PFUNIT REQUIRED) + add_subdirectory("${CMAKE_SOURCE_DIR}/test") +endif() + diff --git a/README.md b/README.md index 3c1e3e1..374ba32 100644 --- a/README.md +++ b/README.md @@ -17,11 +17,11 @@ File types that obs2ioda can handle: * HS_H08_YYYYMMDD_HH00_BNN_FLDK_R20_S0210.DAT * OR_ABI-L1b-Rad nc files -## See [obs2ioda-v1/README.md](https://github.com/jamiebresch/obs2ioda/blob/main/obs2ioda-v1/README.md) for compilation and usage. +## See [obs2ioda-v1/README.md](https://github.com/NCAR/obs2ioda/blob/main/obs2ioda-v1/README.md) for compilation and usage. -## See [obs2ioda-v2/README.md](https://github.com/jamiebresch/obs2ioda/blob/main/obs2ioda-v2/README.md) for compilation and usage. +## See [obs2ioda-v2/README.md](https://github.com/NCAR/obs2ioda/blob/main/obs2ioda-v2/README.md) for compilation and usage. -## See [goes_abi/README.md](https://github.com/jamiebresch/obs2ioda/blob/main/goes_abi/README.md) for compilation and usage. +## See [goes_abi/README.md](https://github.com/NCAR/obs2ioda/blob/main/goes_abi/README.md) for compilation and usage. ## Observation data sources: * https://nomads.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/ diff --git a/obs2ioda-v2/README.md b/obs2ioda-v2/README.md index 5fc819c..259e815 100644 --- a/obs2ioda-v2/README.md +++ b/obs2ioda-v2/README.md @@ -3,46 +3,65 @@ obs2ioda-v2 utilizes CMake as its primary build system. Follow the steps below to build the project: ### Prerequisites -Please make sure the following libraries are installed: -- NetCDF -- NCEP BUFR library. (Instructions for installing the NCEP BUFR library are provided in a subsequent section) -If you have an environment preconfigured for `mpas-jedi`, simply source that environment prior to building `obs2ioda`. +Prior to building `obs2ioda`, ensure that you have installed the following libraries: + +- **CMake**: Required (version 3.20 or higher). +- **NetCDF**: Required. +- **NCEP BUFR Library**: Required. +- **pFUnit**: Optional (Needed for testing). + +For instructions on how to install `pFUnit` and the `NCEP BUFR` library , please refer to the respective sections: + +- [Installing NCEP BUFR Library](#installing-ncep-bufr-library) +- [Installing pFUnit](#installing-pfunit) + +If you have an environment preconfigured for `mpas-jedi` or `mpas-bundle`, simply source that environment prior to building `obs2ioda`. ### Build Instructions 1. First, clone the repository into your preferred directory (``): ```bash git clone https://github.com/NCAR/obs2ioda.git ``` -2. Create a new directory `build` and navigate into it: - ```bash - mkdir build && cd build - ``` -3. Locate the NCEP BUFR library by executing the following command in the `NCEP BUFR` library's build directory: +1. Create a new directory `` and navigate into it: ```bash - find . -name *libbufr* + mkdir && cd ``` -4. Next, run CMake to configure the build. Specify the `CMAKE_BUILD_TYPE` option to set the build type. Currently, the supported types are `Release`, `RelWithDebInfo`, and `Debug`. Don't forget to include the path to the NCEP BUFR library: +1. Set the variable OBS2IODA_CMAKE_ARGS to include the `obs2ioda` root directory and the absolute path of the `NCEP BUFR` library: + ```bash + OBS2IODA_CMAKE_ARGS=" -DNCEP_BUFR_LIB=" + ``` +1. If building in `Debug` mode, append the following to `OBS2IODA_CMAKE_ARGS`: + ```bash + OBS2IODA_CMAKE_ARGS="${OBS2IODA_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Debug" + ``` +1. If building unit tests, append the following to `OBS2IODA_CMAKE_ARGS`: + ```bash + OBS2IODA_CMAKE_ARGS="${OBS2IODA_CMAKE_ARGS} -DBUILD_TESTS=ON -DPFUNIT_DIR=" + ``` + where `` is the directory of the `pFUnit` installation. + +1. Next, run CMake to configure the build. ```bash - cmake -DNCEP_BUFR_LIB= -DCMAKE_BUILD_TYPE= + cmake 'echo ${OBS2IODA_CMAKE_ARGS}' ``` -5. Finally, build `obs2ioda` using `CMake`'s build tool. In this case, we use `GNU Make`, but other build tools supported by `CMake` can be used: +1. Finally, build `obs2ioda` using `CMake`'s build tool. In this case, we use `GNU Make`, but other build tools supported by `CMake` can be used: ```bash make ``` The `obs2ioda-v2` executable will reside in the `bin` directory within the build directory. --- -## Installing NCEP BUFR Library +### Installing NCEP BUFR Library To install the NCEP BUFR library, follow these steps: 1. Clone the NCEP BUFR repository into a directory of your choice (``): ```bash git clone https://github.com/NOAA-EMC/NCEPLIBS-bufr.git ``` -2. Create a new directory `build` and navigate into it: +2. Create a new directory `` and navigate into it: ```bash - mkdir build && cd build + mkdir && cd ``` 3. Run CMake to configure the build (Ensure NetCDF is installed): ```bash @@ -54,9 +73,34 @@ To install the NCEP BUFR library, follow these steps: ``` 5. To locate the NCEP BUFR library, run: ```bash - find . -name *libbufr* + bash -c "find . -name *libbufr*" ``` Remember to note down the library path (``) required for the build process of `obs2ioda-v2`. + +--- + +### Installing pFUnit + +To install `pFUnit` version 4.10.0, follow these steps: + +1. Clone the `pFUnit` repository into your desired directory (``): + ```bash + git clone https://github.com/Goddard-Fortran-Ecosystem/pFUnit.git -b v4.10.0 + ``` + +2. Navigate to the `pFUnit` directory: + ```bash + cd + ``` + Follow the instructions for building version 4.10.0 with `CMake`, provided on the [pFUnit GitHub page](https://github.com/Goddard-Fortran-Ecosystem/pFUnit?tab=readme-ov-file#building-and-installing-pfunit). + +**Note:** If you do not intend to use this installation of `pFUnit` for testing `MPI` or `OpenMP` libraries, pass the following options to `CMake` during the build process: + ```bash + -DUSE_MPI=OFF -DUSE_OPENMP=OFF + ``` + +--- + ## caveate NetCDF-Fortran interface does not allow reading/writing NF90_STRING, so ``station_id`` and ``variable_names`` are still written out as ``char station_id(nlocs, nstring)`` diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..93d71c6 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/fortran) \ No newline at end of file diff --git a/test/fortran/CMakeLists.txt b/test/fortran/CMakeLists.txt new file mode 100644 index 0000000..e69de29