diff --git a/adoc/Makefile b/adoc/Makefile index c585393..47b147b 100644 --- a/adoc/Makefile +++ b/adoc/Makefile @@ -47,11 +47,11 @@ pdf: man $(MAN) -t $(MANDIR)/dmbackup.1 | $(PS2PDF) - $(PDFDIR)/dmbackup.pdf $(MAN) -t $(MANDIR)/dmbeat.1 | $(PS2PDF) - $(PDFDIR)/dmbeat.pdf $(MAN) -t $(MANDIR)/dmdb.1 | $(PS2PDF) - $(PDFDIR)/dmdb.pdf - $(MAN) -t $(MANDIR)/dmdbclu.1 | $(PS2PDF) - $(PDFDIR)/dmdbctl.pdf + $(MAN) -t $(MANDIR)/dmdbctl.1 | $(PS2PDF) - $(PDFDIR)/dmdbctl.pdf $(MAN) -t $(MANDIR)/dmexport.1 | $(PS2PDF) - $(PDFDIR)/dmexport.pdf $(MAN) -t $(MANDIR)/dmfeed.1 | $(PS2PDF) - $(PDFDIR)/dmfeed.pdf $(MAN) -t $(MANDIR)/dmfs.1 | $(PS2PDF) - $(PDFDIR)/dmfs.pdf - $(MAN) -t $(MANDIR)/dmplot.1 | $(PS2PDF) - $(PDFDIR)/dmplot.pdf + $(MAN) -t $(MANDIR)/dmplot.1 | $(PS2PDF) - $(PDFDIR)/dmplot.pdf $(MAN) -t $(MANDIR)/dmimport.1 | $(PS2PDF) - $(PDFDIR)/dmimport.pdf $(MAN) -t $(MANDIR)/dminfo.1 | $(PS2PDF) - $(PDFDIR)/dminfo.pdf $(MAN) -t $(MANDIR)/dminit.1 | $(PS2PDF) - $(PDFDIR)/dminit.pdf diff --git a/adoc/dmdbctl.adoc b/adoc/dmdbctl.adoc index 47c8f19..d56f9b0 100644 --- a/adoc/dmdbctl.adoc +++ b/adoc/dmdbctl.adoc @@ -23,8 +23,23 @@ _meta_] [--*node* _id_] [--*type* _sensor_] [--*sn* _sn_] [--*state* _n_] == DESCRIPTION The *dmdbctl* utility program performs create, read, update, or delete -operations on the observation databasae. Only nodes, sensors, and targets are -supported. Data attributes are passed through command-line arguments. +operations on the observation database: + +Create:: + Add nodes, sensors, and targets to the database. + +Read:: + Read nodes, sensors, and targets from database. Print the records to standard + output. + +Update:: + Update nodes, sensors, and targets in the database. + +Delete:: + Delete nodes, sensors, and targets from the database. + +Only nodes, sensors, and targets are supported. All data attributes are passed +through command-line arguments. == OPTIONS diff --git a/guide/guide.adoc b/guide/guide.adoc index ef1a00a..c33f77b 100644 --- a/guide/guide.adoc +++ b/guide/guide.adoc @@ -336,15 +336,15 @@ $ make OS=linux PREFIX=/usr LIBSQLITE3="-L/usr/local/lib -lsqlite3" ==== If Intel oneAPI is used instead of GCC, run: .... -$ make CC=icx FC=ifx CFLAGS="-mtune=native -O2 -fpic" \ - FFLAGS="-mtune=native -O2 -fpic" PPFLAGS= \ - LDFLAGS="-I./include -module ./include -L/usr/lib -L/opt/lib" \ - INCHDF5="-I/opt/include/hdf5/mod/shared" +$ make CC=icx FC=ifx PPFLAGS= \ + CFLAGS="-mtune=native -O2 -fpic" FFLAGS="-mtune=native -O2 -fpic" \ + LDFLAGS="-module ./include -I./include" \ + INCHDF5="-I/opt/include" \ + LIBHDF5="-Wl,-rpath,/opt/lib -L/opt/lib -lhdf5_fortran -lhdf5" .... -In this case, the HDF5 libraries are installed to `/opt/lib`, and the modules -files to `/opt/include/hdf5/mod/shared`. Change the paths to the actual -locations. +In this case, the HDF5 libraries are installed to `/opt/lib/`, and the HDF5 +modules files to `/opt/include/`. Change the paths to the actual locations. ==== ==== Fortran Package Manager [[linux-fpm]] diff --git a/man/dmdbctl.1 b/man/dmdbctl.1 index e96d86e..ddd558e 100644 --- a/man/dmdbctl.1 +++ b/man/dmdbctl.1 @@ -2,12 +2,12 @@ .\" Title: dmdbctl .\" Author: Philipp Engel .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2024-02-16 +.\" Date: 2024-03-02 .\" Manual: User Commands .\" Source: DMDBCTL .\" Language: English .\" -.TH "DMDBCTL" "1" "2024-02-16" "DMDBCTL" "User Commands" +.TH "DMDBCTL" "1" "2024-03-02" "DMDBCTL" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -42,8 +42,31 @@ dmdbctl \- command\-line interface to DMPACK observation databases .SH "DESCRIPTION" .sp The \fBdmdbctl\fP utility program performs create, read, update, or delete -operations on the observation databasae. Only nodes, sensors, and targets are -supported. Data attributes are passed through command\-line arguments. +operations on the observation database: +.sp +Create +.RS 4 +Add nodes, sensors, and targets to the database. +.RE +.sp +Read +.RS 4 +Read nodes, sensors, and targets from database. Print the records to standard +output. +.RE +.sp +Update +.RS 4 +Update nodes, sensors, and targets in the database. +.RE +.sp +Delete +.RS 4 +Delete nodes, sensors, and targets from the database. +.RE +.sp +Only nodes, sensors, and targets are supported. All data attributes are passed +through command\-line arguments. .SH "OPTIONS" .sp \fB\-\-altitude\fP, \fB\-Z\fP \fIz\fP diff --git a/src/dm_db.f90 b/src/dm_db.f90 index ddda68c..0c9b745 100644 --- a/src/dm_db.f90 +++ b/src/dm_db.f90 @@ -1965,6 +1965,7 @@ integer function dm_db_open(db, path, create, foreign_keys, read_only, threaded, if (threaded_) flag = ior(flag, SQLITE_OPEN_FULLMUTEX) ! Open database. + if (sqlite3_initialize() /= SQLITE_OK) return if (sqlite3_open_v2(trim(path), db%ptr, flag) /= SQLITE_OK) return ! Enable foreign keys constraint. diff --git a/src/dm_la.f90 b/src/dm_la.f90 index 90e890c..54165ae 100644 --- a/src/dm_la.f90 +++ b/src/dm_la.f90 @@ -425,7 +425,7 @@ end subroutine dm_la_dgelsd1 ! ****************************************************************** ! PRIVATE PROCEDURES. ! ****************************************************************** - logical function la_same(ca, cb) result(same) + pure elemental logical function la_same(ca, cb) result(same) !! LAPACK95 auxility routine thats tests if `ca` is the same letter as !! `cb` regardless of case. character, intent(in) :: ca diff --git a/test/dmtestdb.f90 b/test/dmtestdb.f90 index 4b96e7c..7efafb1 100644 --- a/test/dmtestdb.f90 +++ b/test/dmtestdb.f90 @@ -2,43 +2,9 @@ ! ! Author: Philipp Engel ! Licence: ISC -module dmtestdb_aux - use, intrinsic :: iso_c_binding - implicit none (type, external) - private - - public :: backup_handler - public :: log_handler -contains - subroutine backup_handler(remaining, page_count) - integer, intent(in) :: remaining - integer, intent(in) :: page_count - - print '("Progress: ", f5.1, " %")', 100.0 * (page_count - remaining) / page_count - end subroutine backup_handler - - subroutine log_handler(client_data, err_code, err_msg_ptr) bind(c) - !! Callback for SQLite error logs. - use :: sqlite3_util, only: c_f_str_ptr - type(c_ptr), intent(in), value :: client_data - integer(kind=c_int), intent(in), value :: err_code - type(c_ptr), intent(in), value :: err_msg_ptr - - character(len=:), allocatable :: err_msg - - if (.not. c_associated(err_msg_ptr)) return - call c_f_str_ptr(err_msg_ptr, err_msg) - if (.not. allocated(err_msg)) return - print '("Error ", i0, ": ", a)', err_code, err_msg - deallocate (err_msg) - end subroutine log_handler -end module dmtestdb_aux - program dmtestdb !! Tests database access using `dm_db` module. - use, intrinsic :: iso_c_binding use :: dmpack - use :: dmtestdb_aux implicit none (type, external) character(len=*), parameter :: DB_BEAT = 'testbeat.sqlite' character(len=*), parameter :: DB_LOG = 'testlog.sqlite' @@ -53,27 +19,30 @@ program dmtestdb type(test_type) :: tests(NTESTS) logical :: stats(NTESTS) - tests( 1) = test_type('dmtestdb.test01', test01) - tests( 2) = test_type('dmtestdb.test02', test02) - tests( 3) = test_type('dmtestdb.test03', test03) - tests( 4) = test_type('dmtestdb.test04', test04) - tests( 5) = test_type('dmtestdb.test05', test05) - tests( 6) = test_type('dmtestdb.test06', test06) - tests( 7) = test_type('dmtestdb.test07', test07) - tests( 8) = test_type('dmtestdb.test08', test08) - tests( 9) = test_type('dmtestdb.test09', test09) - tests(10) = test_type('dmtestdb.test10', test10) - tests(11) = test_type('dmtestdb.test11', test11) - tests(12) = test_type('dmtestdb.test12', test12) - tests(13) = test_type('dmtestdb.test13', test13) - tests(14) = test_type('dmtestdb.test14', test14) - tests(15) = test_type('dmtestdb.test15', test15) - tests(16) = test_type('dmtestdb.test16', test16) - tests(17) = test_type('dmtestdb.test17', test17) - tests(18) = test_type('dmtestdb.test18', test18) - tests(19) = test_type('dmtestdb.test19', test19) - call dm_init() + + tests = [ & + test_type('dmtestdb.test01', test01), & + test_type('dmtestdb.test02', test02), & + test_type('dmtestdb.test03', test03), & + test_type('dmtestdb.test04', test04), & + test_type('dmtestdb.test05', test05), & + test_type('dmtestdb.test06', test06), & + test_type('dmtestdb.test07', test07), & + test_type('dmtestdb.test08', test08), & + test_type('dmtestdb.test09', test09), & + test_type('dmtestdb.test10', test10), & + test_type('dmtestdb.test11', test11), & + test_type('dmtestdb.test12', test12), & + test_type('dmtestdb.test13', test13), & + test_type('dmtestdb.test14', test14), & + test_type('dmtestdb.test15', test15), & + test_type('dmtestdb.test16', test16), & + test_type('dmtestdb.test17', test17), & + test_type('dmtestdb.test18', test18), & + test_type('dmtestdb.test19', test19) & + ] + call dm_test_run(tests, stats, dm_env_has('NO_COLOR')) contains logical function test01() result(stat) @@ -1068,4 +1037,28 @@ logical function test19() result(stat) stat = TEST_PASSED end function test19 + + subroutine backup_handler(remaining, page_count) + integer, intent(in) :: remaining + integer, intent(in) :: page_count + + print '("Progress: ", f5.1, " %")', 100.0 * (page_count - remaining) / page_count + end subroutine backup_handler + + subroutine log_handler(client_data, err_code, err_msg_ptr) bind(c) + !! Callback for SQLite error logs. + use, intrinsic :: iso_c_binding + use :: sqlite3_util, only: c_f_str_ptr + type(c_ptr), intent(in), value :: client_data + integer(kind=c_int), intent(in), value :: err_code + type(c_ptr), intent(in), value :: err_msg_ptr + + character(len=:), allocatable :: err_msg + + if (.not. c_associated(err_msg_ptr)) return + call c_f_str_ptr(err_msg_ptr, err_msg) + if (.not. allocated(err_msg)) return + print '("Error ", i0, ": ", a)', err_code, err_msg + deallocate (err_msg) + end subroutine log_handler end program dmtestdb