PartMC
2.2.1
|
The code is mainly Fortran 90, with a few parts still clearly showing their Fortran 77 heritage. A few Fortran 95 and Fortran 2003 features are used (mainly the COMMAND_ARGUMENT_COUNT
and GET_COMMAND_ARGUMENT
intrinsics). The code needs to be processed with cpp
or a compatible pre-processor.
Extensive use is made of Fortran 90 derived types and pointers for dynamic memory allocation of arrays inside derived types. Derived types are named my_type_t
and are generally defined in modules named pmc_my_type
within files named my_type.F95
. Each derived type has allocation and deallocation functions my_type_allocate()
and my_type_deallocate()
, where appropriate. Almost all subroutines and function in each my_type.F95
file have names of the form my_type_*
() and take an object of type my_type_t
(called my_type
) as the first argument on which to operate.
Module names are always the same as the name of the containing file, but prefixed with pmc_
. Thus the module pmc_condense
is contained in the file condense.F95
.
The memory allocation policy is that all functions must be called with an already allocated structure. That is, if a subroutine defines a variable of type my_type_t
, then it must call my_type_allocate()
or my_type_allocate_size()
on it before passing it to any other subroutines or functions. The defining subroutine is also responsible for calling my_type_deallocate()
on every variable it defines.
Similarly, any subroutine that declares a pointer variable must allocate it and any data it points to before passing it to other subroutines or functions. If no specific length is known for an array pointer then it should be allocated to zero size. Any subsequent subroutines are free to deallocate and reallocate if they need to change the size.
This means that every subroutine (except for allocate and deallocate routines) should contain matching allocate()/deallocate
() and my_type_allocate()/my_type_deallocate()
calls.