Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fb_global_unstr #335

Merged
merged 28 commits into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
98c5702
Added boundary checks to the SMC grid input files for ww3_grid,
UKMO-lsampson Jun 8, 2020
71b9ba9
Fb 360 calendar (#8)
ukmo-juan-castillo Jul 16, 2020
6c42d17
RTD support for ww3_boun[dc] (#10)
ukmo-ccbunney Jul 28, 2020
5c361aa
Fb coupling time (#9)
ukmo-juan-castillo Jul 30, 2020
cc34122
Merge remote-tracking branch 'upstream/staging' into develop
Aug 7, 2020
33a7af3
bug fix for ukmet development
Aug 7, 2020
68c3c96
Merge remote-tracking branch 'upstream/develop' into develop
Oct 19, 2020
663d983
Merge remote-tracking branch 'upstream/develop' into develop
Oct 26, 2020
d4887f5
Merge remote-tracking branch 'upstream/develop' into develop
Jan 11, 2021
6295b14
Periodicity fix for global unstructured grids
May 21, 2020
dc0cea9
Merge remote-tracking branch 'upstream/develop' into develop
Mar 4, 2021
083a910
modify the model/ftn/w3triamd.ftn and model/ftn/wmscrpmd.ftn and chan…
Mar 6, 2021
8917422
Merge remote-tracking branch 'upstream/develop' into global_unstr_PR_…
Mar 6, 2021
febddae
bug fix for ww3_grid make without SCRIP switch
Mar 7, 2021
6bc0e5f
Fix for corner node periodicity in wmscrpmd.ftn
sbrus89 Mar 9, 2021
4ee6dc9
Merge remote-tracking branch 'upstream/global_unstr_PR_develop_rebase…
Mar 17, 2021
558e7bf
PDLIB/yowpdlibmain.ftn: fix to handle global meshes
menta78 Mar 17, 2021
7a7d90a
Merge pull request #1 from menta78/FB_Global_Unstr
aliabdolali Mar 17, 2021
77d513b
bug fix for SCRIPNC switch
Mar 18, 2021
0ca3076
update info for ww3_tp2.21 for domain decomposition and PDLIB option
Mar 18, 2021
ef2da97
fix for mww3_04 link with SCRIP and SCRIPNC switch
Mar 18, 2021
2ff1b57
add inputs to tar file, update model/bin/ww3_from_ftp.sh and remove i…
Mar 18, 2021
a487bdb
reduce the duration of ww3_tp2.21 for the sake of regtest time
Mar 18, 2021
69ca74a
small editorial fixes
Mar 18, 2021
e443b62
fixes for SCRIPNC switch
Mar 19, 2021
4177081
change date for ww3_ounf and ww3_ounp for ww3_tp2.21
Mar 19, 2021
3a51cdf
Merge remote-tracking branch 'upstream/develop' into FB_Global_Unstr
Mar 19, 2021
af86335
edit w3_make
Mar 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion model/bin/make_makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,17 @@
prop=
source="w3parall w3triamd $stx $nlx $btx $is $uostmd"
IO='w3iogrmd'
aux="constants w3servmd w3arrymd w3dispmd w3gsrumd w3timemd w3nmlgridmd $pdlibyow $memcode" ;;
aux="constants w3servmd w3arrymd w3dispmd w3gsrumd w3timemd w3nmlgridmd $pdlibyow $memcode"
if [ "$scrip" = 'SCRIP' ]
JessicaMeixner-NOAA marked this conversation as resolved.
Show resolved Hide resolved
then
aux="$aux scrip_constants scrip_grids scrip_iounitsmod"
aux="$aux scrip_remap_vars scrip_timers scrip_errormod scrip_interface"
aux="$aux scrip_kindsmod scrip_remap_conservative wmscrpmd"
fi
if [ "$scripnc" = 'SCRIPNC' ]
then
aux="$aux scrip_netcdfmod scrip_remap_write scrip_remap_read"
fi ;;
ww3_strt) IDstring='Initial conditions program'
core=
data="$memcode w3gdatmd w3wdatmd w3adatmd w3idatmd w3odatmd"
Expand Down
5 changes: 3 additions & 2 deletions model/bin/w3_make
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@

# GRID STRT BOUND OUTF OUTP TRCK GRIB GINT GX* UPRSTR LIBWW3
# reg_programs = non-NetCDF programs
reg_programs="ww3_grid"
reg_programs="$reg_programs ww3_strt"
reg_programs="ww3_strt"
reg_programs="$reg_programs ww3_bound"
reg_programs="$reg_programs ww3_outf"
reg_programs="$reg_programs ww3_outp"
Expand Down Expand Up @@ -171,6 +170,7 @@
# MULTI MULTI_ESMF SBS1
if [ -n "`grep SCRIPNC $switch_file`" ] || [ -n "`grep OASIS $switch_file`" ] || [ -n "`grep PDLIB $switch_file`" ]
then
cdf_programs="$cdf_programs ww3_grid"
JessicaMeixner-NOAA marked this conversation as resolved.
Show resolved Hide resolved
cdf_programs="$cdf_programs ww3_multi"
cdf_programs="$cdf_programs ww3_sbs1"
cdf_programs="$cdf_programs libww3"
Expand All @@ -179,6 +179,7 @@
cdf_programs="$cdf_programs ww3_multi_esmf"
fi
else
reg_programs="$reg_programs ww3_grid"
reg_programs="$reg_programs ww3_multi"
reg_programs="$reg_programs ww3_sbs1"
reg_programs="$reg_programs libww3"
Expand Down
4 changes: 2 additions & 2 deletions model/bin/ww3_from_ftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
curr_dir=`pwd`

# Set WW3 code version
ww3ver=v7.07
ww3ver=v7.12.1

#Get top level directory of ww3 from user:
echo -e "\n\n This script will download data from the ftp for WAVEWATCH III "
Expand Down Expand Up @@ -51,7 +51,7 @@ cp -r data_regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM regtests/ww
cp -r data_regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM6
cp -r data_regtests/ww3_tp2.14/input/toy/*.nc regtests/ww3_tp2.14/input/toy/
cp -r data_regtests/ww3_tp2.17/input/* regtests/ww3_tp2.17/input/

cp -r data_regtests/ww3_tp2.21/input/* regtests/ww3_tp2.21/input/

#Do you want to clean up (aka delete tar file, delete the data_regtests directory)
echo -e "\n\n Do you want to delete the tar file ww3_from_ftp.${ww3ver}.tar.gz [y|n]: "
Expand Down
42 changes: 42 additions & 0 deletions model/ftn/PDLIB/yowpdlibmain.ftn
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ module yowpdlibMain
implicit none
integer I1, I2, I3, stat, IE, NI(3)
real(rkind) :: DXP1, DXP2, DXP3, DYP1, DYP2, DYP3, DBLTMP, TRIA03
logical :: CROSSES_DATELINE

allocate(PDLIB_SI(npa), PDLIB_CCON(npa), PDLIB_IEN(6,ne), PDLIB_TRIA(ne), stat=stat)
if(stat/=0) call parallel_abort('SI allocation failure')
Expand All @@ -1163,6 +1164,12 @@ module yowpdlibMain
DYP2=y(I3) - y(I2)
DXP3=x(I1) - x(I3)
DYP3=y(I1) - y(I3)
CALL ELEMENT_CROSSES_DATELINE(DXP1, DXP2, DXP3, CROSSES_DATELINE)
IF (CROSSES_DATELINE) THEN
CALL CORRECT_DX_GT180(DXP1)
CALL CORRECT_DX_GT180(DXP2)
CALL CORRECT_DX_GT180(DXP3)
ENDIF

PDLIB_IEN(1,IE) = - DYP2
PDLIB_IEN(2,IE) = DXP2
Expand All @@ -1185,6 +1192,41 @@ module yowpdlibMain
end subroutine
!**********************************************************************
!* *
!**********************************************************************
subroutine ELEMENT_CROSSES_DATELINE(RX1, RX2, RX3, CROSSES_DATELINE)
! Purpose: understanding if an element crosses the dateline.
! An element crossing the dateline has, e.g. a node with lon < 180
! and another 2 with lon > -180
IMPLICIT NONE
REAL(rkind), INTENT(IN) :: RX1, RX2, RX3
LOGICAL, INTENT(OUT) :: CROSSES_DATELINE
INTEGER :: R1GT180, R2GT180, R3GT180
R1GT180 = MERGE(1, 0, ABS(RX1).GT.180)
R2GT180 = MERGE(1, 0, ABS(RX2).GT.180)
R3GT180 = MERGE(1, 0, ABS(RX3).GT.180)
! if R1GT180+R2GT180+R3GT180 .eq. 0 the element does not cross the dateline
! if R1GT180+R2GT180+R3GT180 .eq. 1 the element contains the pole
! if R1GT180+R2GT180+R3GT180 .eq. 2 the element crosses the dateline
CROSSES_DATELINE = R1GT180+R2GT180+R3GT180 .EQ. 2
end subroutine
!**********************************************************************
!* *
!**********************************************************************
subroutine CORRECT_DX_GT180(DXP)
! Purpose: the absolute zonal distance between 2 points is always <= 180
! This subroutine corrects the zonal distance to satifsy
! this requirement
IMPLICIT NONE
REAL(rkind), INTENT(INOUT) :: DXP
IF (DXP .le. -180) THEN
DXP=DXP + 360
END IF
IF (DXP .ge. 180) THEN
DXP=DXP - 360
END IF
end subroutine
!**********************************************************************
!* *
!**********************************************************************
subroutine ComputeIA_JA_POSI_NNZ
use yowElementpool, only: ne, ne_global, INE, ielg
Expand Down
4 changes: 4 additions & 0 deletions model/ftn/SCRIP/scrip_grids.f
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ module scrip_grids
& special_polar_cell1, ! cell with only 1 corner at pole
& special_polar_cell2 !

integer (SCRIP_i4), dimension(:), allocatable, target,save ::
& grid1_imask, ! flag which cells participate
& grid2_imask ! flag which cells participate

real (SCRIP_r8), dimension(:), allocatable, target, save ::
& grid1_center_lat, ! lat/lon coordinates for
& grid1_center_lon, ! each grid center in radians
Expand Down
4 changes: 2 additions & 2 deletions model/ftn/w3iopomd.ftn
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
INTEGER :: IX1, IY1, IXS, IYS
!/S INTEGER, SAVE :: IENT = 0
!/O7a INTEGER :: IX0, IXN, IY0, IYN, NNX, &
!/O7a KX, KY, JX, IIX
!/O7a KX, KY, JX, IIX, IX2, IY2, IS1
INTEGER :: IX(4), IY(4) ! Indices of points used in interp.
REAL :: RD(4) ! Interpolation coefficient
!/O7a REAL :: RD1, RD2, RDTOT, ZBOX(4), DEPTH
Expand Down Expand Up @@ -392,7 +392,7 @@
!/O7a RD(4)*ZBOX(4) ) / RDTOT
!/O7a WRITE (SCREEN,943) DEPTH
!
!/O7a *** implementation of O7a option with curvilinear grids is incomplete ***
!/O7a ! *** implementation of O7a option with curvilinear grids is incomplete ***
!
!/O7a IF ( RD1 .LT. 0.05 ) IX2 = IX1
!/O7a IF ( RD1 .GT. 0.95 ) IX1 = IX2
Expand Down
135 changes: 118 additions & 17 deletions model/ftn/w3triamd.ftn
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ CONTAINS
!
! 1. purpose: defines open boundary points based on depth
! 2. Method : a boundary node has more node around it than triangles
!
!
!
! 3. Parameters :
Expand Down Expand Up @@ -739,6 +738,8 @@ CONTAINS
REAL :: TL1, TL2, TL3, TMPTRIGP
INTEGER :: I1, I2, I3
INTEGER :: K
REAL*8 :: PT(3,2)

!/S INTEGER :: IENT = 0
!/ ------------------------------------------------------------------- /
!/S CALL STRACE (IENT, 'SPATIAL_GRID')
Expand All @@ -748,13 +749,16 @@ CONTAINS
I1 = TRIGP(K,1)
I2 = TRIGP(K,2)
I3 = TRIGP(K,3)

CALL FIX_PERIODCITY(I1,I2,I3,XYB,PT)
!
! cross product of edge-vector (orientated anticlockwise)
!
TRIA(K) = REAL( (XYB(I2,2)-XYB(I1,2)) & ! (Y2-Y1)
*(XYB(I1,1)-XYB(I3,1)) & ! *(X1-X3)
+(XYB(I3,2)-XYB(I1,2)) & ! (Y3-Y1)*(X2-X1)
*(XYB(I2,1)-XYB(I1,1)) )*0.5

TRIA(K) = REAL( (PT(2,2)-PT(1,2)) & ! (Y2-Y1)
*(PT(1,1)-PT(3,1)) & ! *(X1-X3)
+(PT(3,2)-PT(1,2)) & ! (Y3-Y1)*(X2-X1)
*(PT(2,1)-PT(1,1)) )*0.5
!
! test on negative triangle area, which means that the orientiation is not as assumed to be anticw.
! therefore we swap the nodes !!!
Expand Down Expand Up @@ -832,6 +836,7 @@ CONTAINS
REAL*8 :: N1(2), N2(2), N3(2)
REAL*8 :: TMP(3)
REAL*8 :: TMPINV(3)
REAL*8 :: PT(3,2)
!/S INTEGER :: IENT = 0
!/ ------------------------------------------------------------------- /
!/S CALL STRACE (IENT, 'NVECTRI')
Expand All @@ -845,12 +850,14 @@ CONTAINS
I2 = TRIGP(IE,2)
I3 = TRIGP(IE,3)

P1(1) = XYB(I1,1)
P1(2) = XYB(I1,2)
P2(1) = XYB(I2,1)
P2(2) = XYB(I2,2)
P3(1) = XYB(I3,1)
P3(2) = XYB(I3,2)
CALL FIX_PERIODCITY(I1,I2,I3,XYB,PT)

P1(1) = PT(1,1)
P1(2) = PT(1,2)
P2(1) = PT(2,1)
P2(2) = PT(2,2)
P3(1) = PT(3,1)
P3(2) = PT(3,2)
!
! I1 -> I2, I2 -> I3, I3 -> I1 (anticlockwise orientation is preserved)
!
Expand Down Expand Up @@ -1418,6 +1425,7 @@ END SUBROUTINE
DOUBLE PRECISION :: x1, x2, x3
DOUBLE PRECISION :: y1, y2, y3
DOUBLE PRECISION :: s1, s2, s3, sg1, sg2, sg3
REAL*8 :: PT(3,2)
INTEGER :: ITRI
INTEGER :: I1, I2, I3
INTEGER :: nbFound
Expand All @@ -1433,15 +1441,17 @@ END SUBROUTINE
I1=GRIDS(IMOD)%TRIGP(ITRI,1)
I2=GRIDS(IMOD)%TRIGP(ITRI,2)
I3=GRIDS(IMOD)%TRIGP(ITRI,3)

CALL FIX_PERIODCITY(I1,I2,I3,GRIDS(IMOD)%XYB,PT)
! coordinates of the first vertex A
x1=GRIDS(IMOD)%XYB(I1,1)
y1=GRIDS(IMOD)%XYB(I1,2)
x1 = PT(1,1)
y1 = PT(1,2)
! coordinates of the 2nd vertex B
x2=GRIDS(IMOD)%XYB(I2,1)
y2=GRIDS(IMOD)%XYB(I2,2)
x2 = PT(2,1)
y2 = PT(2,2)
!coordinates of the 3rd vertex C
x3=GRIDS(IMOD)%XYB(I3,1)
y3=GRIDS(IMOD)%XYB(I3,2)
x3 = PT(3,1)
y3 = PT(3,2)
!with M = (XTIN,YTIN) the target point ...
!vector product of AB and AC
sg3=(y3-y1)*(x2-x1)-(x3-x1)*(y2-y1)
Expand Down Expand Up @@ -2729,4 +2739,95 @@ END SUBROUTINE
RETURN
END SUBROUTINE SETUGIOBP
!/ ------------------------------------------------------------------- /

SUBROUTINE FIX_PERIODCITY(I1,I2,I3,XYB,PT)
!/
!/ +-----------------------------------+
!/ | WAVEWATCH III NOAA/NCEP |
!/ | Steven Brus |
!/ | Ali Abdolali |
!/ | FORTRAN 90 |
!/ | Last update : 21-May-2020 |
!/ +-----------------------------------+
!/
!/ 21-May-2020 : Origination. ( version 6.07 )
!/
!/
! 1. Purpose :
!
! Adjust element longitude coordinates for elements straddling the
! dateline with distance of ~360 degrees
!
! 2. Method :
!
! Detect if element has nodes on both sides of dateline and adjust
! coordinates so that all nodes have the same sign
!
! 3. Parameters :
!
! Parameter list
! ----------------------------------------------------------------
IMPLICIT NONE
INTEGER, INTENT(IN) :: I1, I2, I3
DOUBLE PRECISION, INTENT(IN) :: XYB(:,:)
REAL*8, INTENT(OUT) :: PT(3,2)
! ----------------------------------------------------------------
!
! Local variables.
! ----------------------------------------------------------------
INTEGER :: I
INTEGER :: R1GT180, R2GT180, R3GT180
! ----------------------------------------------------------------
!
! 4. Subroutines used :
!

! 5. Called by :
!
! Name Type Module Description
! ----------------------------------------------------------------
! SPATIAL_GRID Subr. W3TRIAM Triangle area calculation
! NVECTRI Subr. W3TRIAM Edge length, angle, normal calcuation
! IS_IN_UNGRID Subr. W3TRIAM Point in element calculation
! ----------------------------------------------------------------
!
! 6. Error messages :
!
! None.
!
! 7. Remarks :
!
! 8. Structure :
!
! 9. Switches :
!
! 10. Source code :
!/ ------------------------------------------------------------------- /

PT(1,1) = XYB(I1,1)
PT(1,2) = XYB(I1,2)
PT(2,1) = XYB(I2,1)
PT(2,2) = XYB(I2,2)
PT(3,1) = XYB(I3,1)
PT(3,2) = XYB(I3,2)


R1GT180 = MERGE(1, 0, ABS(PT(3,1)-PT(2,1)).GT.180)
R2GT180 = MERGE(1, 0, ABS(PT(1,1)-PT(3,1)).GT.180)
R3GT180 = MERGE(1, 0, ABS(PT(2,1)-PT(1,1)).GT.180)
! if R1GT180+R2GT180+R3GT180 .eq. 0 the element does not cross the dateline
! if R1GT180+R2GT180+R3GT180 .eq. 1 the element contains the pole
! if R1GT180+R2GT180+R3GT180 .eq. 2 the element crosses the dateline


IF ( R1GT180 + R2GT180 == 2 ) THEN
PT(3,1)=PT(3,1)-SIGN(360.0,(PT(3,1)-PT(2,1)))
ELSE IF ( R2GT180 + R3GT180 == 2 ) THEN
PT(1,1)=PT(1,1)-SIGN(360.0,(PT(1,1)-PT(2,1)))
ELSE IF ( R1GT180 + R3GT180 == 2 ) THEN
PT(2,1)=PT(2,1)-SIGN(360.0,(PT(2,1)-PT(3,1)))
ENDIF

RETURN
END SUBROUTINE FIX_PERIODCITY
END MODULE W3TRIAMD
Loading