FV3 Bundle
qg_vars_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2009-2016 ECMWF.
2 !
3 ! This software is licensed under the terms of the Apache Licence Version 2.0
4 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 ! In applying this licence, ECMWF does not waive the privileges and immunities
6 ! granted to it by virtue of its status as an intergovernmental organisation nor
7 ! does it submit to any jurisdiction.
8 
9 !> Fortran module to handle variables for the QG model
10 
12 
13 use iso_c_binding
14 use config_mod
15 
16 implicit none
17 private
18 public :: qg_vars, qg_vars_create
19 
20 ! ------------------------------------------------------------------------------
21 !> Fortran derived type to represent QG model variables
22 
23 type :: qg_vars
24  integer :: nv
25  character(len=1), allocatable :: fldnames(:) !< Variable identifiers
26  logical :: lbc
27 end type qg_vars
28 
29 #define LISTED_TYPE qg_vars
30 
31 !> Linked list interface - defines registry_t type
32 #include "oops/util/linkedList_i.f"
33 
34 !> Global registry
35 type(registry_t) :: qg_vars_registry
36 
37 ! ------------------------------------------------------------------------------
38 contains
39 ! ------------------------------------------------------------------------------
40 !> Linked list implementation
41 #include "oops/util/linkedList_c.f"
42 
43 ! ------------------------------------------------------------------------------
44 
45 subroutine qg_vars_create(self, kvars)
46 implicit none
47 type(qg_vars), intent(inout) :: self
48 integer(c_int), dimension(*), intent(in) :: kvars
49 integer :: ii, jj
50 
51 if (kvars(1)<1 .or. kvars(1)>5) call abor1_ftn ("qg_vars_create: error variables")
52 if (kvars(kvars(1)+2)/=999) call abor1_ftn ("qg_vars_create: error check")
53 
54 self%lbc = .false.
55 self%nv = 0
56 
57 do jj=1,kvars(1)
58  ii=jj+1
59  if (kvars(ii)<1 .or. kvars(ii)>5) call abor1_ftn ("qg_vars_create: unknown index")
60  if (kvars(ii)==5) then
61  self%lbc = .true.
62  else
63  self%nv=self%nv+1
64  endif
65 enddo
66 
67 allocate(self%fldnames(self%nv))
68 
69 ii = 0
70 do jj=1,kvars(1)
71  if (kvars(jj+1)/=5) ii=ii+1
72  if (kvars(jj+1)==1) self%fldnames(ii)="x"
73  if (kvars(jj+1)==2) self%fldnames(ii)="q"
74  if (kvars(jj+1)==3) self%fldnames(ii)="u"
75  if (kvars(jj+1)==4) self%fldnames(ii)="v"
76 enddo
77 
78 end subroutine qg_vars_create
79 
80 ! ------------------------------------------------------------------------------
81 
82 end module qg_vars_mod
Fortran derived type to represent QG model variables.
Definition: qg_vars_mod.F90:23
subroutine, public qg_vars_create(self, kvars)
Linked list implementation.
Definition: qg_vars_mod.F90:46
Fortran module to handle variables for the QG model.
Definition: qg_vars_mod.F90:11
type(registry_t) qg_vars_registry
Linked list interface - defines registry_t type.
Definition: qg_vars_mod.F90:35