NOTE: These instructions are out-of-date. TODO update
Adding an aerosol representation to the camp-chem module can be done in the following steps:
Step 1. Create a new aerosol representation module
The module should be placed in the /src/aero_reps
folder and extend the abstract camp_aero_rep_data::aero_rep_data_t
type, overriding all deferred functions, and providing a constructor that returns a pointer to a newly allocated instance of the new type:
module camp_aero_rep_foo
use ...
implicit none
private
public :: aero_rep_foo_t
type, extends(aero_rep_data_t) :: aero_rep_foo_t
contains
... (all deferred functions) ...
end type :: aero_rep_foo_t
interface aero_rep_foo_t
procedure :: constructor
end interface aero_rep_foo_t
function constructor() result (new_obj)
type(aero_rep_foo_t), pointer :: new_obj
allocate(new_obj)
end function constructor
...
end module camp_aero_rep_foo
Step 2. Create a new aerosol representation state module
The module should also be placed in the /src/aero_reps
folder and should extend the abstract camp_aero_rep_state::aero_rep_state_t
type, overriding all deferred functions, and providing a constructor that returns a pointer to a newly allocated instance of the new type:
module camp_aero_rep_foo_state
use ...
implicit none
private
public :: aero_rep_foo_state_t
type, extends(aero_rep_state_t) :: aero_rep_foo_state_t
contains
... (all deferred functions) ...
end type :: aero_rep_foo_state_t
interface aero_rep_foo_state_t
procedure :: constructor
end interface aero_rep_foo_state_t
function constructor() result (new_obj)
type(aero_rep_foo_state_t), pointer :: new_obj
allocate(new_obj)
end function constructor
...
end module camp_aero_rep_foo_state
Step 3. Add the aerosol representation to the camp_aero_rep_factory
module
...
...
use camp_aero_rep_foo
...
...
integer(kind=i_kind), parameter :: AERO_REP_FOO = 32
...
function create(this, type_name)
result (new_obj)
...
select case (type_name)
...
case ()
new_obj => aero_rep_foo_t()
...
...
subroutine bin_pack(this, aero_rep, buffer, pos)
...
select type (aero_rep)
...
type is (aero_rep_foo_t)
aero_rep_type = aero_rep_foo
...
...
function bin_unpack(this, buffer, pos)
result (aero_rep)
...
select case (aero_rep_type)
...
case (aero_rep_foo)
aero_rep => aero_rep_foo_t()
...
...
end module camp_aero_rep_factory
The aero_rep_factory_t type and associated subroutines.
class(aero_rep_data_t) function, pointer create(this, type_name)
Create a new aerosol representation by type name.
class(aero_rep_data_t) function, pointer bin_unpack(this, buffer, pos, comm)
Unpack the given value to the buffer, advancing position.
subroutine bin_pack(this, aero_rep, buffer, pos, comm)
Pack the given value to the buffer, advancing position.
Step 4. Add the new module to the CMakeList file in the root directory.
...
# partmc library
...
set(AEROSOL_REPS_SRC
...
src/aero_reps/aero_rep_foo.F90
src/aero_reps/aero_rep_foo_state.F90
)
...
Step 5. Add unit tests for the new aero_rep_foo_t
and aero_rep_foo_state_t
types
Unit testing should be based on the actual functions of the new module, but in general 80% code coverage is recommended. Some examples can be found in the /src/test
folder
Usage
The new aerosol representation is now ready to use. To include it in a camp_camp_core::camp_core_t
instance, add an aerosol representation object to a new or existing camp-chem configuration file with a type corresponding to the newly created type, along with any required parameters:
{ : [
{
: ,
...
},
...
]}