fvcom_tools  1.7.0
 All Data Structures Files Functions Variables
module_nwp_base.f90
Go to the documentation of this file.
1 
4 
15 
16  use kinds, only: r_kind, r_single, rmissing
17 
18  implicit none
19 
20  public :: nwpbase
21  public :: nwplocation
22 
23  private
24 
25 ! Define a nwp observation type.
26 
28  real(r_single) :: lon
29  real(r_single) :: lat
30  end type nwplocation
31 
32 ! Define a nwp observation type to contain actual data.
33 
34  type, extends(nwplocation) :: nwpbase
35 ! HOW DOES THIS POINTER THING WORK?
36  type(nwpbase), pointer :: next => NULL()
37  real(r_single) :: time
38  integer :: numvar
39 ! real(r_single), allocatable :: obs(:) !< observation value (# numvar).
40  real(r_kind), allocatable :: obs(:)
41  logical :: ifquality
42  integer, allocatable :: quality(:)
43  contains
44  procedure :: list => list_obsbase
45  procedure :: alloc => alloc_obsbase
46  procedure :: destroy => destroy_obsbase
47  end type nwpbase
48 
49  contains
50 
56  subroutine list_obsbase(this)
57  class(nwpbase) :: this
58 
59  integer :: i, numvar
60 
61 ! Write out the lon, lat, and time of the ob
62 
63  write(6,'(a,3f10.3)') 'LIGHTNING OB: longitude, latitude, time =', &
64  this%lon, this%lat, this%time
65 
66 ! Loop through all variables and print out obs and quality
67 
68  numvar = this%numvar
69  if (numvar >= 1) then
70 ! MULTI-DIMENSIONAL EXAMPLE IN module_obs_base.f90
71  write(6,'(a4,10F12.2)') 'obs=', (this%obs(i),i=1,numvar)
72  if(this%ifquality) &
73  write(6,'(a4,10I12)') 'qul=', (this%quality(i),i=1,numvar)
74  else
75  write(6,*) 'No obs for this location'
76  endif
77 
78  end subroutine list_obsbase
79 
88  subroutine alloc_obsbase(this,numvar,ifquality)
89 
90 
91  class(nwpbase) :: this
92 
93  integer, intent(in) :: numvar
94 
95  logical, intent(in), optional :: ifquality
96 
97  if (numvar >= 1) then
98  this%numvar = numvar
99 
100  if(allocated(this%obs)) deallocate(this%obs)
101  allocate(this%obs(numvar))
102 
103  this%ifquality=.false.
104  if(present(ifquality)) this%ifquality = ifquality
105  if(this%ifquality) allocate(this%quality(numvar))
106 
107  else
108  write(6,*) 'alloc_obsbase Error: dimension must be larger than 0:', numvar
109  stop 1234
110  endif
111 
112  end subroutine alloc_obsbase
113 
119  subroutine destroy_obsbase(this)
120 
121  class(nwpbase) :: this
122 
123  this%numvar = 0
124  this%time = 0
125 
126  if(allocated(this%obs)) deallocate(this%obs)
127 
128  this%ifquality=.false.
129  if(allocated(this%quality)) deallocate(this%quality)
130 
131  this%next => null()
132 
133  end subroutine destroy_obsbase
134 
135 end module module_nwp_base
procedure destroy=> destroy_obsbase
Release memory.
Module to hold specification kinds for variable declaration.
Definition: kinds.f90:11
This module defines nwp observation data structure and the method to read and write observations from...
subroutine destroy_obsbase(this)
This subroutine releases memory associated with nwp observations.
procedure list=> list_obsbase
List contents of obs.
subroutine list_obsbase(this)
This subroutine lists the contents of a base nwp observation.
subroutine alloc_obsbase(this, numvar, ifquality)
This subroutine allocates memory for base nwp observation variables.
procedure alloc=> alloc_obsbase
Allocate memory for observations.