FV3 Bundle
fv3jedi_model_interface_mod.F90
Go to the documentation of this file.
1 ! (C) Copyright 2017-2018 UCAR
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 
7 
9 use config_mod
10 use datetime_mod
11 use duration_mod
12 use iso_c_binding
13 
19 
20 implicit none
21 private
22 
23 public :: fv3jedi_model_registry
24 
25 !> Linked list interface
26 #define LISTED_TYPE fv3jedi_model
27 #include "linkedList_i.f"
28 type(registry_t) :: fv3jedi_model_registry
29 
30 ! ------------------------------------------------------------------------------
31 
32 contains
33 
34 ! ------------------------------------------------------------------------------
35 
36 !> Linked list implementation
37 #include "linkedList_c.f"
38 
39 ! ------------------------------------------------------------------------------
40 
41 subroutine c_fv3jedi_model_create(c_conf, c_key_geom, c_key_self) bind (c,name='fv3jedi_model_create_f90')
42 
43 implicit none
44 integer(c_int), intent(inout) :: c_key_self !< Key to model data
45 integer(c_int), intent(in) :: c_key_geom !< Geometry
46 type(c_ptr), intent(in) :: c_conf !< pointer to object of class Config
47 
48 type(fv3jedi_model), pointer :: self
49 type(fv3jedi_geom), pointer :: geom
50 
51 call fv3jedi_geom_registry%get(c_key_geom, geom)
52 call fv3jedi_model_registry%init()
53 call fv3jedi_model_registry%add(c_key_self)
54 call fv3jedi_model_registry%get(c_key_self, self)
55 
56 call model_create(self, geom, c_conf)
57 
58 end subroutine c_fv3jedi_model_create
59 
60 ! ------------------------------------------------------------------------------
61 
62 subroutine c_fv3jedi_model_delete(c_key_self) bind (c,name='fv3jedi_model_delete_f90')
63 
64 implicit none
65 integer(c_int), intent(inout) :: c_key_self
66 type(fv3jedi_model), pointer :: self
67 
68 call fv3jedi_model_registry%get(c_key_self, self)
69 
70 call model_delete(self)
71 
72 call fv3jedi_model_registry%remove(c_key_self)
73 
74 end subroutine c_fv3jedi_model_delete
75 
76 ! ------------------------------------------------------------------------------
77 
78 subroutine c_fv3jedi_model_initialize(c_key_self, c_key_state) bind(c,name='fv3jedi_model_initialize_f90')
79 
80 implicit none
81 integer(c_int), intent(in) :: c_key_self !< Model
82 integer(c_int), intent(in) :: c_key_state !< Model state
83 
84 type(fv3jedi_model), pointer :: self
85 type(fv3jedi_state), pointer :: state
86 
87 call fv3jedi_state_registry%get(c_key_state,state)
88 call fv3jedi_model_registry%get(c_key_self, self)
89 
90 call model_initialize(self, state)
91 
92 end subroutine c_fv3jedi_model_initialize
93 
94 ! ------------------------------------------------------------------------------
95 
96 subroutine c_fv3jedi_model_step(c_key_self, c_key_state, c_dt) bind(c,name='fv3jedi_model_step_f90')
97 
98 implicit none
99 integer(c_int), intent(in) :: c_key_self !< Model
100 integer(c_int), intent(in) :: c_key_state !< Model state
101 type(c_ptr), intent(inout) :: c_dt !< DateTime
102 
103 type(fv3jedi_model), pointer :: self
104 type(fv3jedi_state), pointer :: state
105 
106 type(datetime) :: fdate
107 
108 call fv3jedi_model_registry%get(c_key_self, self)
109 call fv3jedi_state_registry%get(c_key_state,state)
110 
111 call c_f_datetime(c_dt, fdate)
112 
113 call model_step(self, state, fdate)
114 
115 end subroutine c_fv3jedi_model_step
116 
117 ! ------------------------------------------------------------------------------
118 
119 subroutine c_fv3jedi_model_finalize(c_key_self, c_key_state) bind(c,name='fv3jedi_model_finalize_f90')
121 implicit none
122 integer(c_int), intent(in) :: c_key_self !< Model
123 integer(c_int), intent(in) :: c_key_state !< Model state
124 
125 type(fv3jedi_model), pointer :: self
126 type(fv3jedi_state), pointer :: state
127 
128 call fv3jedi_state_registry%get(c_key_state,state)
129 call fv3jedi_model_registry%get(c_key_self, self)
130 
131 call model_finalize(self, state)
132 
133 end subroutine c_fv3jedi_model_finalize
134 
135 ! ------------------------------------------------------------------------------
136 
type(registry_t), public fv3jedi_geom_registry
Linked list interface - defines registry_t type.
subroutine, public model_initialize(self, state)
Fortran derived type to hold FV3JEDI state.
subroutine c_fv3jedi_model_create(c_conf, c_key_geom, c_key_self)
Linked list implementation.
subroutine c_fv3jedi_model_step(c_key_self, c_key_state, c_dt)
Fortran derived type to hold geometry data for the FV3JEDI model.
subroutine c_fv3jedi_model_initialize(c_key_self, c_key_state)
subroutine c_fv3jedi_model_delete(c_key_self)
Handle state for the FV3JEDI odel.
subroutine, public model_finalize(self, state)
subroutine, public model_create(self, geom, c_conf)
Fortran module handling geometry for the FV3 model.
subroutine, public model_step(self, state, vdate)
type(registry_t), public fv3jedi_state_registry
Linked list interface - defines registry_t type.
type(registry_t), public fv3jedi_model_registry
Linked list interface.
subroutine, public model_delete(self)
subroutine c_fv3jedi_model_finalize(c_key_self, c_key_state)
Fortran module handling geometry for the FV3 model.