File: populate.F90

package info (click to toggle)
odb-api 0.18.1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,452 kB
  • sloc: cpp: 115,083; ansic: 86,859; f90: 30,318; sql: 12,508; sh: 9,939; yacc: 3,680; python: 2,432; lex: 1,593; perl: 1,116; fortran: 341; csh: 214; makefile: 111; lisp: 17
file content (82 lines) | stat: -rw-r--r-- 2,381 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
PROGRAM populate
!*** populate.F90 ***

  
USE odb_module

implicit none

REAL(8), ALLOCATABLE :: x(:,:)
REAL(8) :: statid(3), to_real8
REAL(8) mdi ! Missing data indicator ("NULL")
INTEGER(4) :: myproc,nproc,npools,jp,h
INTEGER(4) :: nrows, ncols, rc
character(len=64) dbname, tblname

rc = ODB_init(myproc=myproc,nproc=nproc)

CALL getarg(1,dbname)    ! Database name

npools = 0 ! Gets true value from ODB_open()

h = ODB_open(dbname,'OLD',npools)

mdi = abs(ODB_getval(h, '$mdi'))

jp = 1 ! Here: Populate poolno#1 only for now

if (myproc == mod(jp-1,nproc)+1) then
  tblname = '@hdr' ! Note '@'-sign in front of
  rc = ODB_getsize(h,tblname,nrows,ncols,poolno=jp)
  nrows = 3 ! Three new rows for TABLE hdr
  ALLOCATE(x(nrows,0:ncols))

  statid(1) = transfer("07027   ", to_real8)
  statid(2) = transfer("07061   ", to_real8)
  statid(3) = transfer("07075   ", to_real8)

  !              seqno       date     time     statid  ...
  !                ...     lat       lon  body.offset  body.len
  x(1,1:ncols) = (/1d0,20010101d0,100000d0,statid(1), &
               &       49.18d0,  -0.45d0,      0d0,         2d0/)
  x(2,1:ncols) = (/2d0,20010101d0,130000d0,statid(2), &
               &       49.82d0,   3.20d0,      2d0,         2d0/)
  x(3,1:ncols) = (/3d0,20010101d0,130000d0,statid(3), &
               &       49.78d0,   4.63d0,      4d0,         1d0/)

  ! Note: the following APPENDs after the existing data
  rc = ODB_put(h,tblname,x,nrows,ncols,poolno=jp)

  DEALLOCATE(x)

  tblname = '@body' ! Note '@'-sign in front of

  rc = ODB_getsize(h,tblname,nrows,ncols,poolno=jp)

  nrows = 5 ! Five new rows for TABLE body

  ALLOCATE(x(nrows,0:ncols))
  ! entryno, varno,     press,  obsvalue,    depar, obs_error, bias
  x(1,1:ncols) = &
    (/1d0,   110d0,  657.05d0,98530.00d0, -85.86d0,   69.03d0, -mdi/)
  x(2,1:ncols) = &
    (/2d0,    39d0,98530.00d0,  282.70d0,   1.80d0,    1.95d0, -mdi/)
  x(3,1:ncols) = &
    (/1d0,   110d0,  990.47d0,98480.00d0,-221.59d0,   69.09d0, -mdi/)
  x(4,1:ncols) = &
    (/2d0,    39d0,98480.00d0,  279.80d0,   1.06d0,    1.95d0, -mdi/)
  x(5,1:ncols) = &
    (/1d0,   110d0, 1451.38d0,98250.00d0,-123.32d0,   69.36d0, -mdi/)
  ! Note: the following APPENDs after the existing data

  rc = ODB_put(h,tblname,x,nrows,ncols,poolno=jp)

  DEALLOCATE(x)

endif

rc = ODB_close(h,save=.TRUE.)

rc = ODB_end()

END PROGRAM populate