Debian Codegraph @

src/atlas_f/output/atlas_output_module.F90

raw
1 ! (C) Copyright 2013 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 #include "atlas/atlas_f.h"
10
11 module atlas_output_module
12
13 use fckit_owned_object_module, only : fckit_owned_object
14 use atlas_Config_module, only : atlas_Config
15 use atlas_FunctionSpace_module, only: atlas_FunctionSpace
16 use atlas_FieldSet_module, only: atlas_FieldSet
17 use atlas_Field_module, only: atlas_Field
18 use atlas_Mesh_module, only: atlas_Mesh
19 use, intrinsic :: iso_c_binding, only : c_ptr
20
21 implicit none
22
23 public :: atlas_Output
24 public :: atlas_output_Gmsh
25
26 private
27
28 !------------------------------------------------------------------------------
29 TYPE, extends(fckit_owned_object) :: atlas_Output
30
31 ! Purpose :
32 ! -------
33
34 ! Methods :
35 ! -------
36
37 ! Author :
38 ! ------
39 ! October-2015 Willem Deconinck *ECMWF*
40
41 !------------------------------------------------------------------------------
42 contains
43 procedure, private :: write_mesh
44 procedure, private :: write_field_fs
45 procedure, private :: write_field
46 procedure, private :: write_fieldset_fs
47 procedure, private :: write_fieldset
48 generic, public :: write => &
49 & write_mesh, &
50 & write_field_fs, &
51 & write_fieldset_fs, &
52 & write_field, &
53 & write_fieldset
54
55 #if FCKIT_FINAL_NOT_INHERITING
56 final :: atlas_Output__final_auto
57 #endif
58
59 END TYPE atlas_Output
60
61 interface atlas_Output
62 module procedure atlas_Output__cptr
63 end interface
64
65 interface atlas_output_Gmsh
66 module procedure atlas_output_Gmsh__pathname_mode
67 end interface
68
69 !------------------------------------------------------------------------------
70
71 private :: fckit_owned_object
72 private :: atlas_Config
73 private :: atlas_FunctionSpace
74 private :: atlas_FieldSet
75 private :: atlas_Field
76 private :: atlas_Mesh
77 private :: c_ptr
78
79 ! =============================================================================
80 CONTAINS
81 ! =============================================================================
82
83 function atlas_Output__cptr(cptr) result(this)
84 type(atlas_Output) :: this
85 type(c_ptr), intent(in) :: cptr
86 call this%reset_c_ptr( cptr )
87 call this%return()
88 end function
89
90 function atlas_output_Gmsh__pathname_mode(file,mode,coordinates,levels,gather,ghost) result(this)
91 use fckit_c_interop_module, only : c_str
92 use atlas_output_gmsh_c_binding
93 type(atlas_Output) :: this
94 character(len=*), intent(in) :: file
95 character(len=1), intent(in), optional :: mode
96 character(len=*), intent(in), optional :: coordinates
97 integer, intent(in), optional :: levels(:)
98 logical, intent(in), optional :: gather
99 logical, intent(in), optional :: ghost
100 character(len=1) :: opt_mode
101 type(atlas_Config) :: opt_config
102 opt_config = atlas_Config()
103 opt_mode = "w"
104 if( present(mode) ) opt_mode = mode
105 if( present(coordinates) ) call opt_config%set("coordinates",coordinates)
106 if( present(levels) ) call opt_config%set("levels",levels)
107 if( present(gather) ) call opt_config%set("gather",gather)
108 if( present(ghost) ) call opt_config%set("ghost",ghost)
109 call this%reset_c_ptr( atlas__output__Gmsh__create_pathname_mode_config(c_str(file),c_str(opt_mode),&
110 opt_config%CPTR_PGIBUG_B) )
111 call this%return()
112 call opt_config%final()
113 end function
114
115 subroutine write_mesh(this,mesh,config)
116 use atlas_output_c_binding
117 class(atlas_Output), intent(in) :: this
118 type(atlas_Mesh), intent(in) :: mesh
119 type(atlas_Config), intent(in), optional :: config
120 type(atlas_Config) :: opt_config
121 if( present(config) ) then
122 call atlas__output__write_mesh(this%CPTR_PGIBUG_A,mesh%CPTR_PGIBUG_A,config%CPTR_PGIBUG_B)
123 else
124 opt_config = atlas_Config()
125 call atlas__output__write_mesh(this%CPTR_PGIBUG_A,mesh%CPTR_PGIBUG_A,opt_config%CPTR_PGIBUG_B)
126 call opt_config%final()
127 endif
128 end subroutine
129
130 subroutine write_field_fs(this,field,functionspace,config)
131 use atlas_output_c_binding
132 class(atlas_Output), intent(in) :: this
133 type(atlas_Field), intent(in) :: field
134 class(atlas_FunctionSpace), intent(in) :: functionspace
135 type(atlas_Config), intent(in), optional :: config
136 type(atlas_Config) :: opt_config
137 if( present(config) ) then
138 call atlas__output__write_field_fs(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,functionspace%CPTR_PGIBUG_A, &
139 config%CPTR_PGIBUG_B)
140 else
141 opt_config = atlas_Config()
142 call atlas__output__write_field_fs(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A,functionspace%CPTR_PGIBUG_A, &
143 opt_config%CPTR_PGIBUG_B)
144 call opt_config%final()
145 endif
146 end subroutine
147
148 subroutine write_fieldset_fs(this,fieldset,functionspace,config)
149 use atlas_output_c_binding
150 class(atlas_Output), intent(in) :: this
151 type(atlas_FieldSet), intent(in) :: fieldset
152 class(atlas_FunctionSpace), intent(in) :: functionspace
153 type(atlas_Config), intent(in), optional :: config
154 type(atlas_Config) :: opt_config
155 if( present(config) ) then
156 call atlas__output__write_fieldset_fs(this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A,functionspace%CPTR_PGIBUG_A, &
157 config%CPTR_PGIBUG_B)
158 else
159 opt_config = atlas_Config()
160 call atlas__output__write_fieldset_fs(this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A,functionspace%CPTR_PGIBUG_A, &
161 opt_config%CPTR_PGIBUG_B)
162 call opt_config%final()
163 endif
164 end subroutine
165
166
167 subroutine write_field(this,field,config)
168 use atlas_output_c_binding
169 class(atlas_Output), intent(in) :: this
170 type(atlas_Field), intent(in) :: field
171 type(atlas_Config), intent(in), optional :: config
172 type(atlas_Config) :: opt_config
173 if( present(config) ) then
174 call atlas__output__write_field(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A, &
175 config%CPTR_PGIBUG_B)
176 else
177 opt_config = atlas_Config()
178 call atlas__output__write_field(this%CPTR_PGIBUG_A,field%CPTR_PGIBUG_A, &
179 opt_config%CPTR_PGIBUG_B)
180 call opt_config%final()
181 endif
182 end subroutine
183
184
185 subroutine write_fieldset(this,fieldset,config)
186 use atlas_output_c_binding
187 class(atlas_Output), intent(in) :: this
188 type(atlas_FieldSet), intent(in) :: fieldset
189 type(atlas_Config), intent(in), optional :: config
190 type(atlas_Config) :: opt_config
191 if( present(config) ) then
192 call atlas__output__write_fieldset(this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A, &
193 config%CPTR_PGIBUG_B)
194 else
195 opt_config = atlas_Config()
196 call atlas__output__write_fieldset(this%CPTR_PGIBUG_A,fieldset%CPTR_PGIBUG_A, &
197 opt_config%CPTR_PGIBUG_B)
198 call opt_config%final()
199 endif
200 end subroutine
201
202 !-------------------------------------------------------------------------------
203
204 #if FCKIT_FINAL_NOT_INHERITING
205 ATLAS_FINAL subroutine atlas_Output__final_auto(this)
206 type(atlas_Output), intent(inout) :: this
207 #if FCKIT_FINAL_DEBUGGING
208 write(0,*) "atlas_Output__final_auto"
209 #endif
210 #if FCKIT_FINAL_NOT_PROPAGATING
211 call this%final()
212 #endif
213 FCKIT_SUPPRESS_UNUSED( this )
214 end subroutine
215 #endif
216
217 end module atlas_output_module