Skip to content

Commit

Permalink
ww3_diffraction: merge develop and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aronroland committed Nov 7, 2023
1 parent e5efc45 commit f6110f5
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 129 deletions.
13 changes: 8 additions & 5 deletions model/src/w3gdatmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1394,11 +1394,11 @@ MODULE W3GDATMD
#endif
!/
!/ Data aliasing for structure SCHM(S)
LOGICAL, POINTER :: FSN,FSPSI,FSFCT,FSNIMP,FSTOTALIMP,FSTOTALEXP
LOGICAL, POINTER :: FSREFRACTION, FSFREQSHIFT, FSSOURCE, FSBCCFL
LOGICAL, POINTER :: DO_CHANGE_WLV
REAL(8), POINTER :: SOLVERTHR_STP
REAL(8), POINTER :: CRIT_DEP_STP
LOGICAL, POINTER :: FSN,FSPSI,FSFCT,FSNIMP,FSTOTALIMP,FSTOTALEXP
LOGICAL, POINTER :: FSREFRACTION, FSFREQSHIFT, FSSOURCE, FSBCCFL
LOGICAL, POINTER :: DO_CHANGE_WLV
REAL(8), POINTER :: SOLVERTHR_STP
REAL(8), POINTER :: CRIT_DEP_STP
LOGICAL, POINTER :: B_JGS_TERMINATE_MAXITER
LOGICAL, POINTER :: B_JGS_TERMINATE_DIFFERENCE
LOGICAL, POINTER :: B_JGS_TERMINATE_NORM
Expand Down Expand Up @@ -2834,6 +2834,9 @@ SUBROUTINE W3SETG ( IMOD, NDSE, NDST )
B_JGS_USE_JACOBI => MPARS(IMOD)%SCHMS%B_JGS_USE_JACOBI
B_JGS_BLOCK_GAUSS_SEIDEL => MPARS(IMOD)%SCHMS%B_JGS_BLOCK_GAUSS_SEIDEL
B_JGS_MAXITER => MPARS(IMOD)%SCHMS%B_JGS_MAXITER
B_JGS_LIMITER_FUNC => MPARS(IMOD)%SCHMS%B_JGS_LIMITER_FUNC
B_JGS_LDIFR => MPARS(IMOD)%SCHMS%B_JGS_LDIFR
B_JGS_IDIFR => MPARS(IMOD)%SCHMS%B_JGS_IDIFR
B_JGS_PMIN => MPARS(IMOD)%SCHMS%B_JGS_PMIN
B_JGS_DIFF_THR => MPARS(IMOD)%SCHMS%B_JGS_DIFF_THR
B_JGS_NORM_THR => MPARS(IMOD)%SCHMS%B_JGS_NORM_THR
Expand Down
8 changes: 5 additions & 3 deletions model/src/w3gridmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ MODULE W3GRIDMD
INTEGER :: UNSTSCHEMES(6)
INTEGER :: UNSTSCHEME
INTEGER :: JGS_NLEVEL
LOGICAL :: JGS_LDIFR
INTEGER :: JGS_IDIFR
REAL*8 :: JGS_PMIN
REAL*8 :: JGS_DIFF_THR
REAL*8 :: JGS_NORM_THR
Expand Down Expand Up @@ -1097,8 +1099,8 @@ MODULE W3GRIDMD
JGS_NLEVEL, &
JGS_SOURCE_NONLINEAR, &
SETUP_APPLY_WLV, SOLVERTHR_SETUP, &
CRIT_DEP_SETUP, &
JGS_LDIFR, JGS_IDIFR
CRIT_DEP_SETUP, JGS_LDIFR, JGS_IDIFR

NAMELIST /MISC/ CICE0, CICEN, LICE, XSEED, FLAGTR, XP, XR, &
XFILT, PMOVE, IHM, HSPM, WSM, WSC, FLC, FMICHE, &
RWNDC, FACBERG, NOSW, GSHIFT, WCOR1, WCOR2, &
Expand Down Expand Up @@ -2441,7 +2443,7 @@ SUBROUTINE W3GRID()
JGS_NORM_THR = 1.E-20
JGS_NLEVEL = 0
JGS_SOURCE_NONLINEAR = .FALSE.
JGS_LDIFR = .FALSE.
JGS_LDIFR = .FALSE.
JGS_IDIFR = 1
! read data from the unstructured devoted namelist
CALL READNL ( NDSS, 'UNST', STATUS )
Expand Down
2 changes: 1 addition & 1 deletion model/src/w3initmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ SUBROUTINE W3INIT ( IMOD, IsMulti, FEXT, MDS, MTRACE, ODAT, FLGRD, FLGR2, FLGD,
#endif
REAL :: DTTST, DEPTH, FRACOS
REAL :: FACTOR
REAL :: WLVeff
REAL :: WLVeff, CTMP
#ifdef W3_T
REAL, ALLOCATABLE :: XOUT(:,:)
#endif
Expand Down
2 changes: 1 addition & 1 deletion model/src/w3iorsmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ SUBROUTINE W3IORS ( INXOUT, NDSR, DUMFPI, IMOD, FLRSTRT )
! Include remainder values (switch to record format) ---- *
JSEA = NSEAL_MIN + 1
IF ( JSEA.EQ.NSEAL ) THEN
ISEA = IAPROC + (JSEA - 1) * NAPROC
CALL INIT_GET_ISEA(ISEA, JSEA)
NREC = ISEA + 2
RPOS = 1_8 + LRECL*(NREC-1_8)
READ (NDSR, POS=RPOS, ERR=802, IOSTAT=IERR) &
Expand Down
110 changes: 22 additions & 88 deletions model/src/w3oacpmd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ MODULE W3OACPMD
!
USE MOD_OASIS ! OASIS3-MCT module
!
USE W3ODATMD, ONLY: NAPROC, IAPROC, UNDEF
USE MPI, ONLY : MPI_SUM, MPI_INT
USE W3PARALL, ONLY : INIT_GET_ISEA
#ifdef W3_PDLIB
USE YOWNODEPOOL, ONLY: NPA, NP, IPLG
#endif

IMPLICIT NONE
PRIVATE
!
Expand Down Expand Up @@ -338,7 +331,7 @@ SUBROUTINE CPL_OASIS_GRID(LD_MASTER,ID_LCOMM)
!
! 1.3. Unstructured grids
! ----------------------------------
WRITE(*,*) 'TO BE IMPLEMENT FOR UNSTRUCTURED GRIDS CPL_OASIS_GRID'
WRITE(*,*) 'TO BE IMPLEMENT FOR UNSTRUCTURED GRIDS'
STOP
END IF
!
Expand Down Expand Up @@ -374,19 +367,15 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
!/ | A. Thevenin |
!/ | V. Garnier |
!/ | M. Accensi |
!/ ! A. Roland |
!/ ! H. Michaud |
!/ | FORTRAN 90 |
!/ | Last update : 22-Feb-2023 |
!/ | Last update : 08-Jun-2018 |
!/ +-----------------------------------+
!/
!/ Jul-2013 : Origination. ( version 4.18 )
!/ April-2016 : Add coupling for unstructured grids ( version 5.07 )
!/ (R. Baraille & J. Pianezze)
!/ April-2016 : Add comments (J. Pianezze) ( version 5.07 )
!/ 08-Jun-2018 : use INIT_GET_ISEA ( version 6.04 )
!/ 22-Feb-2023 : Extend to domain decomposition ( version 7.xx )
!/ 01-Mar-2023 : More work ...
!/
! 1. Purpose :
!
Expand Down Expand Up @@ -427,11 +416,7 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
USE W3GDATMD, ONLY: NSEAL,NSEA, NX, NY, MAPSTA, MAPSF, GTYPE, &
& UNGTYPE, RLGTYPE, CLGTYPE, SMCTYPE
USE W3ODATMD, ONLY: NAPROC, IAPROC
#ifdef W3_PDLIB
USE W3PARALL, ONLY : INIT_GET_ISEA
USE YOWNODEPOOL, ONLY: NPA, NP, IPLG
#endif
IMPLICIT NONE
USE W3PARALL, ONLY : INIT_GET_ISEA
!
!/ ------------------------------------------------------------------- /
!/ Parameter list
Expand All @@ -442,7 +427,7 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
!/ ------------------------------------------------------------------- /
!/ Local parameters
!/
INTEGER :: IB_I,I,IPART,IERR_MPI
INTEGER :: IB_I,I
INTEGER :: IL_PART_ID ! PartitionID
INTEGER, ALLOCATABLE, DIMENSION(:) :: ILA_PARAL ! Description of the local partition in the global index space
INTEGER, DIMENSION(4) :: ILA_SHAPE ! Vector giving the min & max index for each dim of the fields
Expand Down Expand Up @@ -503,81 +488,31 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
!
! 1.3. Unstructured grids
! ----------------------------------
#ifdef W3_PDLIB
IPART = 4 ! USING POINT PARTITION FOR UNSTRUCTURED DD
IF (IPART == 3) THEN
! * allocate : OASIS ORANGE partition
ALLOCATE(ILA_PARAL(2+NP*2))
! * Define the partition : OASIS ORANGE partition
ILA_PARAL(1) = 3
! * total number of segments of the global domain
ILA_PARAL(2) = NP
DO JSEA = 1, NP
CALL INIT_GET_ISEA(ILA_PARAL(JSEA*2+1),JSEA)
ILA_PARAL(JSEA*2+2) = 1
END DO
ELSE IF (IPART == 4) THEN
! * allocate : OASIS POINT partition
ALLOCATE(ILA_PARAL(2+NP))
! * Define the partition : OASIS POINTS partition
ILA_PARAL(1) = 4
! * total number of segments of the global domain
ILA_PARAL(2) = NP
DO JSEA = 1, NP
CALL INIT_GET_ISEA(ILA_PARAL(JSEA+2),JSEA)
ENDDO
ENDIF
#else
IPART = 4
IF (IPART == 3) THEN
! * allocate : OASIS ORANGE partition
ALLOCATE(ILA_PARAL(2+NSEAL*2))
! * Define the partition : OASIS ORANGE partition
ILA_PARAL(1) = 3
! * total number of segments of the global domain
ILA_PARAL(2) = NSEAL
DO JSEA = 1, NSEAL
CALL INIT_GET_ISEA(ILA_PARAL(JSEA*2+1),JSEA)
ILA_PARAL(JSEA*2+2) = 1
END DO
ELSE IF (IPART == 4) THEN
! * allocate : OASIS POINT partition
ALLOCATE(ILA_PARAL(2+NSEAL))
! * Define the partition : OASIS POINTS partition
ILA_PARAL(1) = 4
! * total number of segments of the global domain
ILA_PARAL(2) = NSEAL
DO JSEA = 1, NSEAL
CALL INIT_GET_ISEA(ILA_PARAL(JSEA+2),JSEA)
ENDDO
ENDIF
#endif
WRITE(*,*) 'TO BE VERIFIED FOR UNSTRUCTURED GRIDS'
STOP
!
DO JSEA=1,NSEAL
ILA_PARAL(JSEA*2+1) = (IAPROC-1) + (JSEA-1)*NAPROC
ILA_PARAL(JSEA*2+2) = 1
END DO
!
ENDIF

!
! 2. Partition definition
! ----------------------------------
CALL OASIS_DEF_PARTITION(IL_PART_ID, ILA_PARAL,IL_ERR,NSEA)
CALL OASIS_DEF_PARTITION(IL_PART_ID, ILA_PARAL,IL_ERR,NNODES)
IF(IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_partition')
ENDIF


!
! 3. Coupling fields declaration
! ----------------------------------
#ifdef W3_PDLIB
ILA_SHAPE(:) = (/1, NP, 1, 1 /)
#else
ILA_SHAPE(:) = (/1, NSEAL, 1, 1 /)
#endif
!
ILA_VAR_NODIMS(1) = 2 ! rank of fields array
ILA_VAR_NODIMS(2) = 1 ! always 1 with OASIS3-MCT 2.0
!
CALL GET_LIST_EXCH_FIELD(NDSO, RCV_FLD, SND_FLD, IL_NB_RCV, IL_NB_SND, RCV_STR, SND_STR)

!
! 3.1 Send coupling fields
! ----------------------------------
Expand All @@ -595,8 +530,6 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_var')
ENDIF
ENDDO


!
! 3.2 Received coupling fields
! ----------------------------------
Expand All @@ -614,14 +547,11 @@ SUBROUTINE CPL_OASIS_DEFINE(NDSO,RCV_STR,SND_STR)
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_def_var')
ENDIF
ENDDO


!
! 4. End of definition phase
! ----------------------------------
CALL OASIS_ENDDEF(IL_ERR)


IF (IL_ERR /= 0) THEN
CALL OASIS_ABORT(IL_COMPID, 'CPL_OASIS_DEFINE', 'Problem during oasis_enddef')
ENDIF
Expand Down Expand Up @@ -746,9 +676,6 @@ SUBROUTINE CPL_OASIS_RCV(ID_NB, ID_TIME, RDA_FIELD, LD_ACTION)
!/ ------------------------------------------------------------------- /
!/ Parameter list
!/
USE W3ODATMD, ONLY: NAPROC, IAPROC, UNDEF
USE W3GDATMD, ONLY: NSEAL, NSEA, NX
IMPLICIT NONE
INTEGER, INTENT(IN) :: ID_NB ! Number of the field to be received
INTEGER, INTENT(IN) :: ID_TIME ! Ocean time-step in seconds
REAL(KIND=8), DIMENSION(:,:), INTENT(OUT) :: RDA_FIELD ! Coupling field array to be received
Expand All @@ -758,18 +685,15 @@ SUBROUTINE CPL_OASIS_RCV(ID_NB, ID_TIME, RDA_FIELD, LD_ACTION)
!/ Local parameters
!/
INTEGER :: IL_INFO ! OASIS3-MCT info argument
INTEGER :: IERR_MPI, NPSUM
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/

CALL OASIS_GET ( RCV_fld(ID_NB)%IL_FIELD_ID &
& , ID_TIME &
& , RDA_FIELD &
& , IL_INFO &
& )

!
LD_ACTION = IL_INFO == OASIS_RECVD .OR. IL_INFO == OASIS_FROMREST .OR. &
& IL_INFO == OASIS_RECVOUT .OR. IL_INFO == OASIS_FROMRESTOUT
Expand Down Expand Up @@ -918,6 +842,14 @@ SUBROUTINE GET_LIST_EXCH_FIELD(NDSO, RCV, SND, ID_NB_RCV, ID_NB_SND, RCV_STR, SN
ID_NB_RCV=ID_NB_RCV+1
RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDH'
!
! wet-drying at u-location
ID_NB_RCV=ID_NB_RCV+1
RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDU'
!
! wet-drying at v-location
ID_NB_RCV=ID_NB_RCV+1
RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OWDV'
!
CASE('SSH')
! ssh : sea surface height (m)
ID_NB_RCV=ID_NB_RCV+1
Expand All @@ -933,6 +865,7 @@ SUBROUTINE GET_LIST_EXCH_FIELD(NDSO, RCV, SND, ID_NB_RCV, ID_NB_SND, RCV_STR, SN
RCV(ID_NB_RCV)%CL_FIELD_NAME='WW3_OSSV'
#endif
!

!
! ATMOSPHERE MODEL VARIABLES
!
Expand Down Expand Up @@ -1211,3 +1144,4 @@ END SUBROUTINE GET_LIST_EXCH_FIELD
!/
END MODULE W3OACPMD
!/
!/ ------------------------------------------------------------------- /
21 changes: 9 additions & 12 deletions model/src/w3parall.F90
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ MODULE W3PARALL
REAL*8, PARAMETER :: KDMAX = 200.d0


REAL*8, ALLOCATABLE :: DIFRX(:), DIFRY(:), DIFRM(:) !AR: todo, allocate!
REAL*8, ALLOCATABLE :: DIFRX(:), DIFRY(:), DIFRM(:)
CONTAINS
!/ ------------------------------------------------------------------- /
!>
Expand Down Expand Up @@ -542,7 +542,7 @@ SUBROUTINE PROP_REFRACTION_PR3(IP, ISEA, DTG, CAD, DoLimiter)
FACTH = 1.0 / DTH
!
FDG = FACTH * eCTHG0
DEPTH = MAX ( DMIN , DW(ISEA) ) ! This results in bathemtry modification and it used all over the code!
DEPTH = MAX ( DMIN , DW(ISEA) )
DO IK=0, NK+1
IF ( DEPTH*WN(IK,ISEA) .LT. 5. ) THEN
DSDD(IK) = MAX ( 0. , CG(IK,ISEA)*WN(IK,ISEA)-0.5*SIG(IK) ) / DEPTH
Expand All @@ -566,7 +566,7 @@ SUBROUTINE PROP_REFRACTION_PR3(IP, ISEA, DTG, CAD, DoLimiter)
VCFLT(ISP) = ES2(ISP)*DCYX + ESC(ISP)*DCXXYY - EC2(ISP)*DCXY
END DO
ELSE
VCFLT = 0
VCFLT=0
END IF
!
#ifdef W3_REFRX
Expand All @@ -592,9 +592,8 @@ SUBROUTINE PROP_REFRACTION_PR3(IP, ISEA, DTG, CAD, DoLimiter)
VCFLT(ISP)=VELNOFILT
END IF
END DO

DO ISP = 1, NSPEC
CAD(ISP) = DBLE(VCFLT(ISP))
DO ISP=1,NSPEC
CAD(ISP)=DBLE(VCFLT(ISP))
END DO

IF (B_JGS_LDIFR) THEN
Expand Down Expand Up @@ -700,7 +699,6 @@ SUBROUTINE PROP_FREQ_SHIFT(IP, ISEA, CAS, DMM, DTG)
CALL STRACE (IENT, 'PROP_FREQ_SHIFT')
#endif
!

IF (LPDLIB) THEN
eDCXDX = DCXDX(1,IP)
eDCXDY = DCXDY(1,IP)
Expand All @@ -718,14 +716,13 @@ SUBROUTINE PROP_FREQ_SHIFT(IP, ISEA, CAS, DMM, DTG)
eDDDX=DDDX(IY,IX)
eDDDY=DDDY(IY,IX)
ENDIF

eCX = CX(ISEA)
eCY = CY(ISEA)
eCX=CX(ISEA)
eCY=CY(ISEA)
DCXX = - eDCXDX
DCXYYX = - ( eDCXDY + eDCYDX )
DCYY = - eDCYDY
FKD = ( eCX*eDDDX + eCY*eDDDY )
FACK = DTG
FACK = DTG
DO ITH=1, NTH
FKC(ITH) = EC2(ITH)*DCXX + ESC(ITH)*DCXYYX + ES2(ITH)*DCYY
END DO
Expand Down Expand Up @@ -899,7 +896,7 @@ SUBROUTINE PROP_FREQ_SHIFT_M2(IP, ISEA, CWNB_M2, DWNI_M2, DTG)
!
DEPTH = MAX ( DMIN , DW(ISEA) )
DO IK=0, NK+1
IF ( DEPTH*WN(IK,ISEA) .LT. 5. ) THEN
IF ( DEPTH*WN(IK,ISEA) .LT. 5. ) THEN
IF (B_JGS_LDIFR) THEN
DSDD(IK) = MAX ( 0. , DIFRM(IP)*CG(IK,ISEA)*WN(IK,ISEA)-0.5*SIG(IK) ) / DEPTH
ELSE
Expand Down
2 changes: 1 addition & 1 deletion model/src/w3profsmd_pdlib.F90
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ MODULE PDLIB_W3PROFSMD
REAL*8, ALLOCATABLE :: FLALL1(:,:,:), KELEM1(:,:,:)
REAL*8, ALLOCATABLE :: FLALL2(:,:,:), KELEM2(:,:,:)
REAL*8, ALLOCATABLE :: FLALL3(:,:,:), KELEM3(:,:,:)
REAL*8, ALLOCATABLE :: DIFRX(:), DIFRY(:), DIFRM(:) !AR: todo, allocate!
REAL*8, ALLOCATABLE :: DIFRX(:), DIFRY(:), DIFRM(:)
REAL*8, ALLOCATABLE :: NM(:,:,:), DTSI(:)
INTEGER, ALLOCATABLE :: ITER(:)
INTEGER, ALLOCATABLE :: IS0_pdlib(:)
Expand Down
Loading

0 comments on commit f6110f5

Please sign in to comment.