Skip to content

Commit

Permalink
minimize allocated forcing fields when using cmeps
Browse files Browse the repository at this point in the history
* minimally allocate fields used in w3updtmd when
using cmeps
* use fields provided by cmeps w/o fake time-interpolation
  • Loading branch information
DeniseWorthen committed Nov 6, 2024
1 parent 06c2099 commit 908c105
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 346 deletions.
42 changes: 24 additions & 18 deletions model/src/w3adatmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ SUBROUTINE W3DIMA ( IMOD, NDSE, NDST, D_ONLY )
#ifdef W3_S
USE W3SERVMD, ONLY: STRACE
#endif
use w3odatmd, only : use_cmeps
!
!/
!/ ------------------------------------------------------------------- /
Expand All @@ -949,11 +950,12 @@ SUBROUTINE W3DIMA ( IMOD, NDSE, NDST, D_ONLY )
!/ Local parameters
!/
INTEGER :: JGRID, NXXX, NSEAL_tmp
integer :: memunit
integer :: allocsize
#ifdef W3_S
INTEGER, SAVE :: IENT = 0
CALL STRACE (IENT, 'W3DIMA')
#endif
integer :: memunit
!
! -------------------------------------------------------------------- /
! 1. Test input and module status
Expand Down Expand Up @@ -1332,40 +1334,44 @@ SUBROUTINE W3DIMA ( IMOD, NDSE, NDST, D_ONLY )
ALLOCATE (WADATS(IMOD)%IC3CG(0:NK+1,0:300), STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
#endif

if (use_cmeps) then
allocsize = 1
else
allocsize = nsea
end if
!
IF ( FLCUR ) THEN
ALLOCATE ( WADATS(IMOD)%CA0(NSEA) , &
WADATS(IMOD)%CAI(NSEA) , &
WADATS(IMOD)%CD0(NSEA) , &
WADATS(IMOD)%CDI(NSEA) , &
ALLOCATE ( WADATS(IMOD)%CA0(allocsize) , &
WADATS(IMOD)%CAI(allocsize) , &
WADATS(IMOD)%CD0(allocsize) , &
WADATS(IMOD)%CDI(allocsize) , &
STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
!
IF ( FLWIND ) THEN
ALLOCATE ( WADATS(IMOD)%UA0(NSEA) , &
WADATS(IMOD)%UAI(NSEA) , &
WADATS(IMOD)%UD0(NSEA) , &
WADATS(IMOD)%UDI(NSEA) , &
WADATS(IMOD)%AS0(NSEA) , &
WADATS(IMOD)%ASI(NSEA) , &
ALLOCATE ( WADATS(IMOD)%UA0(allocsize) , &
WADATS(IMOD)%UAI(allocsize) , &
WADATS(IMOD)%UD0(allocsize) , &
WADATS(IMOD)%UDI(allocsize) , &
WADATS(IMOD)%AS0(allocsize) , &
WADATS(IMOD)%ASI(allocsize) , &
STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
!
IF ( FLTAUA ) THEN
ALLOCATE ( WADATS(IMOD)%MA0(NSEA) , &
WADATS(IMOD)%MAI(NSEA) , &
WADATS(IMOD)%MD0(NSEA) , &
WADATS(IMOD)%MDI(NSEA) , &
ALLOCATE ( WADATS(IMOD)%MA0(allocsize) , &
WADATS(IMOD)%MAI(allocsize) , &
WADATS(IMOD)%MD0(allocsize) , &
WADATS(IMOD)%MDI(allocsize) , &
STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
!
IF ( FLRHOA ) THEN
ALLOCATE ( WADATS(IMOD)%RA0(NSEA) , &
WADATS(IMOD)%RAI(NSEA) , &
ALLOCATE ( WADATS(IMOD)%RA0(allocsize) , &
WADATS(IMOD)%RAI(allocsize) , &
STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
Expand Down
71 changes: 40 additions & 31 deletions model/src/w3idatmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
#ifdef W3_S
USE W3SERVMD, ONLY: STRACE
#endif
use w3odatmd, only : use_cmeps
!
IMPLICIT NONE
!/
Expand All @@ -521,6 +522,7 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
!/
INTEGER :: JGRID
LOGICAL :: FLAGSTIDE(4)=.FALSE.
integer :: allocsizex, allocsizey
#ifdef W3_S
INTEGER, SAVE :: IENT = 0
CALL STRACE (IENT, 'W3DIMI')
Expand Down Expand Up @@ -631,19 +633,26 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
!
if (use_cmeps) then
allocsizex = 1
allocsizey = 1
else
allocsizex = nx
allocsizey = ny
end if
IF ( FLCUR ) THEN
#ifdef W3_SMC
IF( FSWND ) THEN
ALLOCATE ( INPUTS(IMOD)%CX0(NSEA,1) , &
INPUTS(IMOD)%CY0(NSEA,1) , &
INPUTS(IMOD)%CXN(NSEA,1) , &
ALLOCATE ( INPUTS(IMOD)%CX0(NSEA,1) , &
INPUTS(IMOD)%CY0(NSEA,1) , &
INPUTS(IMOD)%CXN(NSEA,1) , &
INPUTS(IMOD)%CYN(NSEA,1) , STAT=ISTAT )
ELSE
#endif
ALLOCATE ( INPUTS(IMOD)%CX0(NX,NY) , &
INPUTS(IMOD)%CY0(NX,NY) , &
INPUTS(IMOD)%CXN(NX,NY) , &
INPUTS(IMOD)%CYN(NX,NY) , STAT=ISTAT )
ALLOCATE ( INPUTS(IMOD)%CX0(NX,NY) , &
INPUTS(IMOD)%CY0(NX,NY) , &
INPUTS(IMOD)%CXN(ALLOCSIZEX,ALLOCSIZEY) , &
INPUTS(IMOD)%CYN(ALLOCSIZEX,ALLOCSIZEY) , STAT=ISTAT )
#ifdef W3_SMC
ENDIF
#endif
Expand All @@ -657,7 +666,7 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
END IF
!
IF ( FLCURTIDE ) THEN
ALLOCATE ( INPUTS(IMOD)%CXTIDE(NX,NY,NTIDE,2), &
ALLOCATE ( INPUTS(IMOD)%CXTIDE(NX,NY,NTIDE,2), &
INPUTS(IMOD)%CYTIDE(NX,NY,NTIDE,2), STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
END IF
Expand All @@ -666,7 +675,7 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )

#ifdef W3_WRST
IF(.NOT.(INPUTS(IMOD)%WRSTIINIT)) THEN
ALLOCATE ( INPUTS(IMOD)%WXNwrst(NX,NY) , &
ALLOCATE ( INPUTS(IMOD)%WXNwrst(NX,NY) , &
INPUTS(IMOD)%WYNwrst(NX,NY) , STAT=ISTAT )
INPUTS(IMOD)%WRSTIINIT=.TRUE.
ENDIF
Expand All @@ -675,20 +684,20 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
IF ( FLWIND ) THEN
#ifdef W3_SMC
IF( FSWND ) THEN
ALLOCATE ( INPUTS(IMOD)%WX0(NSEA,1) , &
INPUTS(IMOD)%WY0(NSEA,1) , &
INPUTS(IMOD)%DT0(NSEA,1) , &
INPUTS(IMOD)%WXN(NSEA,1) , &
INPUTS(IMOD)%WYN(NSEA,1) , &
ALLOCATE ( INPUTS(IMOD)%WX0(NSEA,1) , &
INPUTS(IMOD)%WY0(NSEA,1) , &
INPUTS(IMOD)%DT0(NSEA,1) , &
INPUTS(IMOD)%WXN(NSEA,1) , &
INPUTS(IMOD)%WYN(NSEA,1) , &
INPUTS(IMOD)%DTN(NSEA,1) , STAT=ISTAT )
ELSE
#endif
ALLOCATE ( INPUTS(IMOD)%WX0(NX,NY) , &
INPUTS(IMOD)%WY0(NX,NY) , &
INPUTS(IMOD)%DT0(NX,NY) , &
INPUTS(IMOD)%WXN(NX,NY) , &
INPUTS(IMOD)%WYN(NX,NY) , &
INPUTS(IMOD)%DTN(NX,NY) , STAT=ISTAT )
ALLOCATE ( INPUTS(IMOD)%WX0(NX,NY) , &
INPUTS(IMOD)%WY0(NX,NY) , &
INPUTS(IMOD)%DT0(NX,NY) , &
INPUTS(IMOD)%WXN(ALLOCSIZEX,ALLOCSIZEY) , &
INPUTS(IMOD)%WYN(ALLOCSIZEX,ALLOCSIZEY) , &
INPUTS(IMOD)%DTN(ALLOCSIZEX,ALLOCSIZEY) , STAT=ISTAT )
#ifdef W3_SMC
ENDIF
#endif
Expand All @@ -698,7 +707,7 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
END IF
!
IF ( FLICE ) THEN
ALLOCATE ( INPUTS(IMOD)%ICEI(NX,NY), &
ALLOCATE ( INPUTS(IMOD)%ICEI(NX,NY), &
INPUTS(IMOD)%BERGI(NX,NY), STAT=ISTAT )
CHECK_ALLOC_STATUS ( ISTAT )
INPUTS(IMOD)%BERGI = 0.
Expand All @@ -707,16 +716,16 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
IF ( FLTAUA ) THEN
#ifdef W3_SMC
IF( FSWND ) THEN
ALLOCATE ( INPUTS(IMOD)%UX0(NSEA,1) , &
INPUTS(IMOD)%UY0(NSEA,1) , &
INPUTS(IMOD)%UXN(NSEA,1) , &
ALLOCATE ( INPUTS(IMOD)%UX0(NSEA,1) , &
INPUTS(IMOD)%UY0(NSEA,1) , &
INPUTS(IMOD)%UXN(NSEA,1) , &
INPUTS(IMOD)%UYN(NSEA,1) , STAT=ISTAT )
ELSE
#endif
ALLOCATE ( INPUTS(IMOD)%UX0(NX,NY) , &
INPUTS(IMOD)%UY0(NX,NY) , &
INPUTS(IMOD)%UXN(NX,NY) , &
INPUTS(IMOD)%UYN(NX,NY) , STAT=ISTAT )
ALLOCATE ( INPUTS(IMOD)%UX0(NX,NY) , &
INPUTS(IMOD)%UY0(NX,NY) , &
INPUTS(IMOD)%UXN(ALLOCSIZEX,ALLOCSIZEY) , &
INPUTS(IMOD)%UYN(ALLOCSIZEX,ALLOCSIZEY) , STAT=ISTAT )
#ifdef W3_SMC
ENDIF
#endif
Expand All @@ -726,12 +735,12 @@ SUBROUTINE W3DIMI ( IMOD, NDSE, NDST, FLAGSTIDEIN )
IF ( FLRHOA ) THEN
#ifdef W3_SMC
IF( FSWND ) THEN
ALLOCATE ( INPUTS(IMOD)%RH0(NSEA,1) , &
ALLOCATE ( INPUTS(IMOD)%RH0(NSEA,1) , &
INPUTS(IMOD)%RHN(NSEA,1) , STAT=ISTAT )
ELSE
#endif
ALLOCATE ( INPUTS(IMOD)%RH0(NX,NY) , &
INPUTS(IMOD)%RHN(NX,NY) , STAT=ISTAT )
ALLOCATE ( INPUTS(IMOD)%RH0(NX,NY) , &
INPUTS(IMOD)%RHN(ALLOCSIZEX,ALLOCSIZEY) , STAT=ISTAT )
#ifdef W3_SMC
ENDIF
#endif
Expand Down
1 change: 1 addition & 0 deletions model/src/w3odatmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ MODULE W3ODATMD
character(len=36) :: time_origin = '' !< @public the time_origin used for netCDF output
character(len=36) :: calendar_name = '' !< @public the calendar used for netCDF output
integer(kind=8) :: elapsed_secs = 0 !< @public the time in seconds from the time_origin
logical :: use_cmeps = .false. !< @public a logical flag to indicate cmeps is providing the forcing
!/
CONTAINS
!/ ------------------------------------------------------------------- /
Expand Down
Loading

0 comments on commit 908c105

Please sign in to comment.