From 0841c7b32a7270cc0b639bb9139b1080df773ee4 Mon Sep 17 00:00:00 2001 From: davis-matthew Date: Sat, 17 Oct 2026 19:03:47 -0400 Subject: [PATCH] Optimization of Counting Loop w/ Closed-form Formula --- modules/MM_Interface/mm_solv_constr.F | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/MM_Interface/mm_solv_constr.F b/modules/MM_Interface/mm_solv_constr.F index 71d1be0..77cfef8 100644 --- a/modules/MM_Interface/mm_solv_constr.F +++ b/modules/MM_Interface/mm_solv_constr.F @@ -61,12 +61,12 @@ SUBROUTINE mm_solv_const(str,dt,taup,velp,tau0) if(first)then first=.false. - NCONST=0 - do ia=1,NRAM - do ja=ia+1,min(ia+4,NRAM) - NCONST=NCONST+1 - enddo - enddo +C pairs (ia,ja) with ia < ja <= min(ia+4,NRAM) + if(NRAM.ge.4)then + NCONST=4*NRAM-10 + else + NCONST=NRAM*(NRAM-1)/2 + endif allocate(ABl(NCONST),STAT=ierr) if(ierr/=0) call stopgm(procedureN,'allocation problem', & __LINE__,'__file__')