Error while compiling OBSGRID during model setup on Ubuntu 24.04

Hi everyone,


I'm currently setting up the OBSGRID model and encountered multiple errors during the compilation process. I would appreciate any help in resolving these issues.


System Information:


  • OS: [Ubuntu 24.04]
  • Compiler: gfortran [version]
  • NetCDF version: 4.7.4 (installed via Conda)
  • OBSGRID version:GitHub - wrf-model/OBSGRID: Repository for OBSGRID
  • Environment variables:

    export NETCDF=/home/air360/miniconda3
    export PATH=$NETCDF/bin:$PATH
    export LD_LIBRARY_PATH=$NETCDF/lib:$LD_LIBRARY_PATH
    export CPATH=$NETCDF/include:$CPATH
    export LIBRARY_PATH=$NETCDF/lib:$LIBRARY_PATH



Error Summary:


  1. Fatal error: Cannot open included file ‘netcdf.inc’
    pgsql
    CopyEdit
    main.f:29:0:
    29 | INCLUDE 'netcdf.inc'
    |
    Fatal Error: Cannot open included file ‘netcdf.inc’
    compilation terminated.
    • The file netcdf.inc is missing or not being found.
    • Checked: NetCDF is installed at /home/air360/miniconda3, and its include directory contains netcdf.h but not netcdf.inc.
  2. Fatal Error: Cannot open module file ‘observation.mod’
    lua
    CopyEdit
    driver.f:29:8:
    29 | USE observation
    | 1
    Fatal Error: Cannot open module file ‘observation.mod’ for reading at (1): No such file or directory
    • observation.mod is missing, which suggests that it either:
      • Failed to compile earlier
      • Was not generated properly due to errors in dependencies
  3. Linker errors: Missing .o files
    yaml
    CopyEdit
    /usr/bin/ld: cannot find driver.o: No such file or directory
    /usr/bin/ld: cannot find main.o: No such file or directory
    /usr/bin/ld: cannot find proc_final_analysis.o: No such file or directory
    collect2: error: ld returned 1 exit status
    • Many .o object files are missing, which suggests:
      • Errors in previous compilation steps
      • Dependencies not being built properly before linking



Steps I Have Tried:


  1. Checked NetCDF installation
    • Running nc-config --all shows NetCDF is installed and paths are set.
    • But netcdf.inc is missing from /home/air360/miniconda3/include/.
  2. Recompiling with modified preprocessor settings
    • Edited configure.oa to change:
      ini
      CopyEdit
      CPP = /usr/bin/cpp -C -P -traditional
      to:
      ini
      CopyEdit
      CPP = /usr/bin/cpp -C -P -traditional-cpp
  3. Reinstalling NetCDF-Fortran:
    bash
    CopyEdit
    conda install -c conda-forge netcdf-fortran
    But the error "Cannot open included file ‘netcdf.inc’" still appears.
  4. Cleaning and recompiling:
    bash
    CopyEdit
    make clean
    make
    • Compilation still fails at the same point.



Request for Help

  • Has anyone encountered a similar issue while compiling OBSGRID?
  • Do I need a specific NetCDF-Fortran version to include netcdf.inc?
  • Any advice on fixing observation.mod and ensuring dependencies compile properly?

Thank you for any suggestions!
 

Attachments

Hi,
When you install netCDF, are you installing both netcdf-c and netcdf-fortran, and making sure all the binaries, libraries, and include files are in the same directories? For e.g., having a directory called "netcdf" that includes the directories bin, lib, and include - where files from both builds reside?

Do you have the variable NETCDF set to the path with both netcdfs are built?
 
Back
Top