| 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_Redistribution_module |
| 12 |
|
| 13 |
use, intrinsic :: iso_c_binding, only : c_ptr |
| 14 |
use atlas_config_module, only : atlas_Config |
| 15 |
use atlas_functionspace_module, only : atlas_FunctionSpace |
| 16 |
use fckit_owned_object_module, only: fckit_owned_object |
| 17 |
|
| 18 |
implicit none |
| 19 |
|
| 20 |
public :: atlas_Redistribution |
| 21 |
|
| 22 |
private |
| 23 |
|
| 24 |
!------------------------------------------------------------------------------ |
| 25 |
TYPE, extends(fckit_owned_object) :: atlas_Redistribution |
| 26 |
|
| 27 |
! Purpose : |
| 28 |
! ------- |
| 29 |
! *atlas_Redistribution* : Object passed from atlas to inspect redistribution |
| 30 |
|
| 31 |
! Methods : |
| 32 |
! ------- |
| 33 |
|
| 34 |
! Author : |
| 35 |
! ------ |
| 36 |
! October-2023 Slavko Brdar *ECMWF* |
| 37 |
! August-2015 Willem Deconinck *ECMWF* |
| 38 |
|
| 39 |
!------------------------------------------------------------------------------ |
| 40 |
contains |
| 41 |
|
| 42 |
procedure, public :: execute => atlas_Redistribution__execute |
| 43 |
procedure, public :: source => atlas_Redistribution__source |
| 44 |
procedure, public :: target => atlas_Redistribution__target |
| 45 |
|
| 46 |
#if FCKIT_FINAL_NOT_INHERITING |
| 47 |
final :: atlas_Redistribution__final_auto |
| 48 |
#endif |
| 49 |
END TYPE atlas_Redistribution |
| 50 |
|
| 51 |
!------------------------------------------------------------------------------ |
| 52 |
|
| 53 |
interface atlas_Redistribution |
| 54 |
module procedure ctor_cptr |
| 55 |
module procedure ctor_create |
| 56 |
end interface |
| 57 |
|
| 58 |
private :: c_ptr |
| 59 |
private :: fckit_owned_object |
| 60 |
|
| 61 |
!======================================================== |
| 62 |
contains |
| 63 |
!======================================================== |
| 64 |
! ----------------------------------------------------------------------------- |
| 65 |
! Redistribution routines |
| 66 |
|
| 67 |
function empty_config() result(config) |
| 68 |
type(atlas_Config) :: config |
| 69 |
config = atlas_Config() |
| 70 |
call config%return() |
| 71 |
end function |
| 72 |
|
| 73 |
function ctor_cptr( cptr ) result(this) |
| 74 |
use atlas_redistribution_c_binding |
| 75 |
type(atlas_Redistribution) :: this |
| 76 |
type(c_ptr), intent(in) :: cptr |
| 77 |
call this%reset_c_ptr( cptr ) |
| 78 |
call this%return() |
| 79 |
end function |
| 80 |
|
| 81 |
function ctor_create(fspace1, fspace2, redist_name) result(this) |
| 82 |
use atlas_redistribution_c_binding |
| 83 |
class(atlas_FunctionSpace), intent(in) :: fspace1, fspace2 |
| 84 |
character(len=*), intent(in), optional :: redist_name |
| 85 |
type(atlas_Redistribution) :: this |
| 86 |
type(atlas_Config) :: config |
| 87 |
config = empty_config() |
| 88 |
if (present(redist_name)) call config%set("type", redist_name) |
| 89 |
call this%reset_c_ptr( atlas__Redistribution__new__config(fspace1%CPTR_PGIBUG_A, fspace2%CPTR_PGIBUG_A, config%CPTR_PGIBUG_B) ) |
| 90 |
call config%final() |
| 91 |
call this%return() |
| 92 |
end function |
| 93 |
|
| 94 |
subroutine atlas_Redistribution__execute(this, field_1, field_2) |
| 95 |
use atlas_redistribution_c_binding |
| 96 |
use atlas_Field_module |
| 97 |
class(atlas_Redistribution), intent(in) :: this |
| 98 |
class(atlas_Field), intent(in) :: field_1 |
| 99 |
class(atlas_Field), intent(inout) :: field_2 |
| 100 |
call atlas__Redistribution__execute(this%CPTR_PGIBUG_A, field_1%CPTR_PGIBUG_A, field_2%CPTR_PGIBUG_A) |
| 101 |
end subroutine |
| 102 |
|
| 103 |
function atlas_Redistribution__source(this) result(fspace) |
| 104 |
use atlas_redistribution_c_binding |
| 105 |
class(atlas_Redistribution), intent(in) :: this |
| 106 |
type(atlas_FunctionSpace) :: fspace |
| 107 |
call fspace%reset_c_ptr(atlas__Redistribution__source(this%CPTR_PGIBUG_A)) |
| 108 |
call fspace%return() |
| 109 |
end function |
| 110 |
|
| 111 |
function atlas_Redistribution__target(this) result(fspace) |
| 112 |
use atlas_redistribution_c_binding |
| 113 |
class(atlas_Redistribution), intent(in) :: this |
| 114 |
type(atlas_FunctionSpace) :: fspace |
| 115 |
call fspace%reset_c_ptr(atlas__Redistribution__target(this%CPTR_PGIBUG_A)) |
| 116 |
call fspace%return() |
| 117 |
end function |
| 118 |
|
| 119 |
! ---------------------------------------------------------------------------------------- |
| 120 |
|
| 121 |
#if FCKIT_FINAL_NOT_INHERITING |
| 122 |
ATLAS_FINAL subroutine atlas_Redistribution__final_auto(this) |
| 123 |
type(atlas_Redistribution), intent(inout) :: this |
| 124 |
#if FCKIT_FINAL_DEBUGGING |
| 125 |
write(0,*) "atlas_Redistribution__final_auto" |
| 126 |
#endif |
| 127 |
#if FCKIT_FINAL_NOT_PROPAGATING |
| 128 |
call this%final() |
| 129 |
#endif |
| 130 |
FCKIT_SUPPRESS_UNUSED( this ) |
| 131 |
end subroutine |
| 132 |
#endif |
| 133 |
|
| 134 |
! ---------------------------------------------------------------------------------------- |
| 135 |
|
| 136 |
end module atlas_Redistribution_module |