From 5d905fa470d6f0541dc27cfc0eca913e9bcb192d Mon Sep 17 00:00:00 2001 From: dougiesquire Date: Wed, 25 Feb 2026 09:10:19 +1100 Subject: [PATCH] Check that self%perturbation is allocated before trying to apply perturbations This prevents 'invalid memory reference.' errors when using GCC --- libforcing/src/forcing_field.F90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libforcing/src/forcing_field.F90 b/libforcing/src/forcing_field.F90 index 1a36a14..7c2c857 100644 --- a/libforcing/src/forcing_field.F90 +++ b/libforcing/src/forcing_field.F90 @@ -131,7 +131,7 @@ subroutine forcing_field_apply_perturbations(self, forcing_date, experiment_date integer :: num_separable_perturbations logical :: found - if (size(self%perturbations) == 0) then + if (.not. allocated(self%perturbations) .or. size(self%perturbations) == 0) then return endif