From 9d045ae4eb811bf3881d1dd87716235e029ff2cf Mon Sep 17 00:00:00 2001 From: Seth Underwood Date: Thu, 3 Nov 2016 15:34:34 -0400 Subject: [PATCH] diag_manifest deallocate arrays when done Added a routine to deallocate the field arrays once finished. Fixes #21 --- diag_manager/diag_manifest.F90 | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/diag_manager/diag_manifest.F90 b/diag_manager/diag_manifest.F90 index fed267f174..2cb9a608ac 100644 --- a/diag_manager/diag_manifest.F90 +++ b/diag_manager/diag_manifest.F90 @@ -155,10 +155,29 @@ SUBROUTINE write_diag_manifest(file) END IF END IF END IF -!$OMP END MASTER +!$OMP END MASTER + ! Free up memory used + CALL destroy_manifest_fields_type(static_fields) + CALL destroy_manifest_fields_type(temporal_fields) END SUBROUTINE write_diag_manifest ! PRIVATE routines + !> \brief De-allocate arrays used in the manifest_fields_type + SUBROUTINE destroy_manifest_fields_type(manifest_fields) + TYPE(manifest_fields_type), INTENT(inout) :: manifest_fields + + ! Set all num_?d to 0 + manifest_fields%num_1d = 0 + manifest_fields%num_2d = 0 + manifest_fields%num_3d = 0 + manifest_fields%num_4d = 0 + ! De-allocate the arrays + IF ( ALLOCATED(manifest_fields%fields_1d) ) DEALLOCATE(manifest_fields%fields_1d) + IF ( ALLOCATED(manifest_fields%fields_2d) ) DEALLOCATE(manifest_fields%fields_2d) + IF ( ALLOCATED(manifest_fields%fields_3d) ) DEALLOCATE(manifest_fields%fields_3d) + IF ( ALLOCATED(manifest_fields%fields_4d) ) DEALLOCATE(manifest_fields%fields_4d) + END SUBROUTINE destroy_manifest_fields_type + !> \brief Allow ASSIGNMENT(=) operator to work on TYPE(manifest_field_type) !! !! Simply assign the type on the rhs to the type on the lhs of the `=`.