Debian Codegraph @

src/atlas_f/mesh/atlas_MeshGenerator_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_MeshGenerator_module
12
13
14 use fckit_owned_object_module, only: fckit_owned_object
15
16 implicit none
17
18 private :: fckit_owned_object
19
20 public :: atlas_MeshGenerator
21
22 private
23
24 !-----------------------------!
25 ! atlas_MeshGenerator !
26 !-----------------------------!
27
28 !------------------------------------------------------------------------------
29 TYPE, extends(fckit_owned_object) :: atlas_MeshGenerator
30 contains
31 procedure, private :: atlas_MeshGenerator__generate
32 procedure, private :: atlas_MeshGenerator__generate_partitioner
33 generic :: generate => atlas_MeshGenerator__generate, atlas_MeshGenerator__generate_partitioner
34
35 #if FCKIT_FINAL_NOT_INHERITING
36 final :: atlas_MeshGenerator__final_auto
37 #endif
38
39 END TYPE atlas_MeshGenerator
40
41 interface atlas_MeshGenerator
42 module procedure atlas_MeshGenerator__cptr
43 module procedure atlas_MeshGenerator__config
44 module procedure atlas_MeshGenerator__type
45 end interface
46
47 !------------------------------------------------------------------------------
48
49
50 !========================================================
51 contains
52 !========================================================
53
54
55 function atlas_MeshGenerator__cptr(cptr) result(this)
56 use, intrinsic :: iso_c_binding, only: c_ptr
57 type(atlas_MeshGenerator) :: this
58 type(c_ptr), intent(in) :: cptr
59 call this%reset_c_ptr( cptr )
60 call this%return()
61 end function
62
63 function atlas_MeshGenerator__type(type) result(this)
64 use fckit_c_interop_module, only: c_str
65 use atlas_MeshGenerator_c_binding
66 type(atlas_MeshGenerator) :: this
67 character(len=*), intent(in) :: type
68 call this%reset_c_ptr( atlas__MeshGenerator__create_noconfig(c_str(type)) )
69 call this%return()
70 end function
71
72 function atlas_MeshGenerator__config(config) result(this)
73 use fckit_c_interop_module, only: c_str
74 use atlas_MeshGenerator_c_binding
75 use atlas_Config_module, only: atlas_Config
76 type(atlas_MeshGenerator) :: this
77 type(atlas_Config), intent(in), optional :: config
78 character(len=:), allocatable :: meshgenerator_type
79 if( present(config) ) then
80 if( .not. config%get("type",meshgenerator_type) ) then
81 meshgenerator_type='structured'
82 endif
83 call this%reset_c_ptr( atlas__MeshGenerator__create( &
84 c_str(meshgenerator_type),config%CPTR_PGIBUG_B) )
85 else
86 call this%reset_c_ptr( atlas__MeshGenerator__create_noconfig(c_str('structured')) )
87 endif
88 call this%return()
89 end function
90
91 function atlas_MeshGenerator__generate(this,grid,distribution) result(mesh)
92 use atlas_MeshGenerator_c_binding
93 use atlas_Grid_module, only: atlas_Grid
94 use atlas_GridDistribution_module, only: atlas_GridDistribution
95 use atlas_Mesh_module, only: atlas_Mesh
96 type(atlas_Mesh) :: mesh
97 class(atlas_MeshGenerator), intent(in) :: this
98 class(atlas_Grid), intent(in) :: grid
99 class(atlas_GridDistribution), intent(in), optional :: distribution
100 call mesh%reset_c_ptr() ! Somehow needed with PGI/16.7 and build-type "bit"
101 if( present(distribution) ) then
102 mesh = atlas_Mesh( atlas__MeshGenerator__generate__grid_griddist( &
103 this%CPTR_PGIBUG_A,grid%CPTR_PGIBUG_A,distribution%CPTR_PGIBUG_A) )
104 else
105 mesh = atlas_Mesh( atlas__MeshGenerator__generate__grid( &
106 this%CPTR_PGIBUG_A,grid%CPTR_PGIBUG_A) )
107 endif
108 call mesh%return()
109 end function
110
111 function atlas_MeshGenerator__generate_partitioner(this,grid,partitioner) result(mesh)
112 use atlas_MeshGenerator_c_binding
113 use atlas_Grid_module, only: atlas_Grid
114 use atlas_Partitioner_module, only: atlas_Partitioner
115 use atlas_Mesh_module, only: atlas_Mesh
116 type(atlas_Mesh) :: mesh
117 class(atlas_MeshGenerator), intent(in) :: this
118 class(atlas_Grid), intent(in) :: grid
119 class(atlas_Partitioner), intent(in) :: partitioner
120 call mesh%reset_c_ptr() ! Somehow needed with PGI/16.7 and build-type "bit"
121 mesh = atlas_Mesh( atlas__MeshGenerator__generate__grid_partitioner( &
122 this%CPTR_PGIBUG_A,grid%CPTR_PGIBUG_A,partitioner%CPTR_PGIBUG_A) )
123 call mesh%return()
124 end function
125
126
127 !-------------------------------------------------------------------------------
128
129 #if FCKIT_FINAL_NOT_INHERITING
130 ATLAS_FINAL subroutine atlas_MeshGenerator__final_auto(this)
131 type(atlas_MeshGenerator), intent(inout) :: this
132 #if FCKIT_FINAL_DEBUGGING
133 write(0,*) "atlas_MeshGenerator__final_auto"
134 #endif
135 #if FCKIT_FINAL_NOT_PROPAGATING
136 call this%final()
137 #endif
138 FCKIT_SUPPRESS_UNUSED( this )
139 end subroutine
140 #endif
141
142 ! ----------------------------------------------------------------------------------------
143
144 end module atlas_MeshGenerator_module