NCAR / DART

Data Assimilation Research Testbed
https://dart.ucar.edu/
Apache License 2.0
187 stars 140 forks source link

Buildtools for compiling dart as a library #702

Closed hkershaw-brown closed 1 month ago

hkershaw-brown commented 1 month ago

Description:

Buildtools for compiling dart as a library (libdart.a or libdart.so)

SiParCS 2024 Anh Pham and Suman Shekhar students used dart as a static library.
There are other people interested in having dart as a library, so this provides buildtools so they don't have to create Makefiles by hand.

This pull request has a developer test directory 'library' which has a shared lib build and a static lib build and a little test script to demo building and linking filter.

Not sure what level of docs to add, maybe just a section in DART build system for people who want to play with a library.

Fixes issue

no issue

Types of changes

Documentation changes needed?

Tests

DART/developer_tests/library/test_libraries.sh does a bitwise test for filter (regular build vs. static library vs shared library) edit: also did a paranoia check that -fPIC was bitwise for a regular build of filter.

Checklist for merging

Checklist for release

Testing Datasets

mjs2369 commented 1 month ago

@hkershaw-brown I'm getting some errors when running test_libraries.sh

/glade/derecho/scratch/masmith/DART/assimilation_code/modules/utilities/mpi_utilities_mod.f90(1862): error #6404: This name does not have a type, and must have an explicit type.   [SYSTEM]
    rc = system(trim(shell_name)//' '//trim(execute)//' '//char(0))
---------^
/glade/derecho/scratch/masmith/DART/assimilation_code/modules/utilities/mpi_utilities_mod.f90(2033): error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [MPI_UTILITIES_MOD]
 use mpi_utilities_mod, only : get_dart_mpi_comm
-----^

I'll keep looking into these, but I thought I'd let you know now to see if you might already know the causes.

hkershaw-brown commented 1 month ago

@mjs2369 are you running with a gfortran mkmf.template but the intel module on Derecho?

mjs2369 commented 1 month ago

@mjs2369 are you running with a gfortran mkmf.template but the intel module on Derecho?

Yep, duh. Though I did have to add the mpif08 argument to lines that run quickbuild (22, 36, and 44) in test_libraries.sh to get it compile with gfortran. But the script is still erroring out while trying to run filter for the first time on line 62 (the no lib build):

ar: creating libdart.a
a - algorithm_info_mod.o
a - bnrh_distribution_mod.o
a - netcdf_utilities_mod.o
a - schedule_mod.o
a - io_filenames_mod.o
.... (a bunch more files)
a - direct_netcdf_mod.o
a - distribution_params_mod.o
a - assert_mod.o
No host list provided

I haven't been able to figure out why this is happening yet

mjs2369 commented 1 month ago

Some last questions/comments other than the error are:

  1. I think minimal docs in the like you mentioned in the body of the PR sound like the way to go, but I think they might make more sense in Compiling DART instead of "DART Build System".

  2. We aren't supporting compiling DART as a library for Windows, right? The mkmf.template.gfortran is only for osx and linux, and I believe that Windows uses different file extensions for library files (static libraries are .lib in Windows instead of .a)

hkershaw-brown commented 1 month ago
ar: creating libdart.a
a - algorithm_info_mod.o
a - bnrh_distribution_mod.o
a - netcdf_utilities_mod.o
a - schedule_mod.o
a - io_filenames_mod.o
.... (a bunch more files)
a - direct_netcdf_mod.o
a - distribution_params_mod.o
a - assert_mod.o
No host list provided

I haven't been able to figure out why this is happening yet

Are you trying to run an mpi job on the Derecho login nodes?

hkershaw-brown commented 1 month ago

Some last questions/comments other than the error are:

  1. I think minimal docs in the like you mentioned in the body of the PR sound like the way to go, but I think they might make more sense in Compiling DART instead of "DART Build System".

So this isn't a feature for general use. It would be for people developing tools that use DART. I think the build system docs (developers section) is the place for it.

  1. We aren't supporting compiling DART as a library for Windows, right? The mkmf.template.gfortran is only for osx and linux, and I believe that Windows uses different file extensions for library files (static libraries are .lib in Windows instead of .a)

No we're not supporting DART as a library for windows. If people want to use DART on windows, then I'd recommend using WSL.

hkershaw-brown commented 1 month ago

@hkershaw-brown mpif90 mpif08