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

Tested changes for efficient SMC grid coupling #16

Merged
merged 4 commits into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions model/bin/ww3_from_ftp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ cp -r data_regtests/ww3_tp2.12/input_be/* regtests/ww3_tp2.12/input_be/
cp -r data_regtests/ww3_tp2.12/input_le/* regtests/ww3_tp2.12/input_le/
cp -r data_regtests/ww3_tp2.14/input/r-ww3.nc.OAS*CM regtests/ww3_tp2.14/input/
cp -r data_regtests/ww3_tp2.14/input/r-ww3.nc.OASACM regtests/ww3_tp2.14/input/r-ww3.nc.OASACM2
cp -r data_regtests/ww3_tp2.14/input/rmp_* regtests/ww3_tp2.14/input/
if [ ! -d regtests/ww3_tp2.14/input/oasis3-mct/doc ]
then
mkdir regtests/ww3_tp2.14/input/oasis3-mct/doc
Expand All @@ -47,6 +48,7 @@ cp -r data_regtests/ww3_tp2.14/input/toy/r-toy.nc.OASACM regtests/ww3_tp2.14/inp
cp -r data_regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM2
cp -r data_regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM4
cp -r data_regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM regtests/ww3_tp2.14/input/toy/toy_coupled_field.nc.OASACM5
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/

Expand Down
218 changes: 138 additions & 80 deletions model/ftn/w3oacpmd.ftn
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
USE W3GDATMD, ONLY: NX, NY, FLAGLL, XGRD, YGRD, MAPSTA, &
& HPFAC, HQFAC, GTYPE, &
& UNGTYPE, RLGTYPE, CLGTYPE
!/SMC USE W3GDATMD, ONLY: NSEA, X0, Y0, MRFct, SX, SY, IJKCel
!/MPI INCLUDE "mpif.h"
!
!/ ------------------------------------------------------------------- /
Expand All @@ -214,15 +215,13 @@
REAL, ALLOCATABLE :: LON(:,:),LAT(:,:),AREA(:,:), &
CORLON(:,:,:),CORLAT(:,:,:)
REAL :: FACTOR
LOGICAL :: RGLGRD = .TRUE.
!/SMC REAL :: DLON, DLAT
!/ ------------------------------------------------------------------- /
!
IF (LD_MASTER) THEN
!
IF (FLAGLL) THEN
FACTOR = 1.
ELSE
FACTOR = 1. / (RADIUS * DERA)
END IF
!/SMC RGLGRD = .FALSE.
!
! 0. Create grids file
! --------------------------------
Expand All @@ -231,61 +230,100 @@
! 1. Get the lat/lon/corners,areas and masks
! -------------------------------------------
IF (GTYPE .EQ. RLGTYPE .OR. GTYPE .EQ. CLGTYPE) THEN
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NNODES = NX*NY
NXW=1
NXE=NX
NYS=1
NYN=NY
!
! lat/lon
ALLOCATE ( LON(NNODES,1), LAT(NNODES,1) )
I = 0
DO IY = NYS, NYN
!
IF (RGLGRD) THEN
IF (FLAGLL) THEN
FACTOR = 1.
ELSE
FACTOR = 1. / (RADIUS * DERA)
END IF
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NNODES = NX*NY
NXW=1
NXE=NX
NYS=1
NYN=NY
!
! lat/lon
ALLOCATE ( LON(NNODES,1), LAT(NNODES,1) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
LON(I,1)=XGRD(IY,IX)*FACTOR
LAT(I,1)=YGRD(IY,IX)*FACTOR
I = I+1
LON(I,1)=XGRD(IY,IX)*FACTOR
LAT(I,1)=YGRD(IY,IX)*FACTOR
END DO
END DO
!
! areas, corners
ALLOCATE ( AREA(NNODES,1), CORLON(NNODES,1,4), CORLAT(NNODES,1,4) )
I = 0
DO IY = NYS, NYN
END DO
!
! areas, corners
ALLOCATE ( AREA(NNODES,1), CORLON(NNODES,1,4), CORLAT(NNODES,1,4) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
CORLON(I,1,1)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,2)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,3)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,4)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,1)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,2)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,3)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,4)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
AREA(I,1)=HPFAC(IY,IX)*HQFAC(IY,IX)
I = I+1
CORLON(I,1,1)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,2)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,3)=LON(I,1)-HPFAC(IY,IX)/2.*FACTOR
CORLON(I,1,4)=LON(I,1)+HPFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,1)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,2)=LAT(I,1)+HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,3)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
CORLAT(I,1,4)=LAT(I,1)-HQFAC(IY,IX)/2.*FACTOR
AREA(I,1)=HPFAC(IY,IX)*HQFAC(IY,IX)
END DO
END DO
!
! Model grid mask
ALLOCATE ( MASK(NNODES,1) )
I = 0
DO IY = NYS, NYN
END DO
!
! Model grid mask
ALLOCATE ( MASK(NNODES,1) )
I = 0
DO IY = NYS, NYN
DO IX = NXW, NXE
I = I+1
! Get the mask : 0 - sea / 1 - open boundary cells (the land is already excluded)
IF ((MAPSTA(IY,IX) .EQ. 1)) THEN
MASK(I,1) = 0
ELSE
MASK(I,1) = 1
END IF
I = I+1
! Get the mask : 0 - sea / 1 - open boundary cells (the land is already excluded)
IF ((MAPSTA(IY,IX) .EQ. 1)) THEN
MASK(I,1) = 0
ELSE
MASK(I,1) = 1
END IF
END DO
END DO
END DO
!/SMC ELSE
!/SMC !
!/SMC ! 1.2. SMC grids
!/SMC ! ----------------------------------
!/SMC NNODES = NSEA
!/SMC !
!/SMC ! Calculate the smallest grid cell increments depending on the number of SMC levels
!/SMC DLON = SX / MRFct
!/SMC DLAT = SY / MRFct
!/SMC !
!/SMC ALLOCATE ( LON(NNODES,1), LAT(NNODES,1) )
!/SMC ALLOCATE ( AREA(NNODES,1), CORLON(NNODES,1,4), CORLAT(NNODES,1,4) )
!/SMC ALLOCATE ( MASK(NNODES,1) )
!/SMC DO I=1, NNODES
!/SMC ! lat/lon
!/SMC LON(I,1) = X0 + (IJKCel(1,I) + IJKCel(3,I)*0.5)*DLON
!/SMC LAT(I,1) = Y0 + (IJKCel(2,I) + IJKCel(4,I)*0.5)*DLAT
!/SMC ! corners
!/SMC CORLON(I,1,1) = X0 + IJKCel(1,I)*DLON
!/SMC CORLON(I,1,2) = X0 + (IJKCel(1,I) + IJKCel(3,I))*DLON
!/SMC CORLON(I,1,3) = CORLON(I,1,2)
!/SMC CORLON(I,1,4) = CORLON(I,1,1)
!/SMC CORLAT(I,1,1) = Y0 + IJKCel(2,I)*DLAT
!/SMC CORLAT(I,1,2)=CORLAT(I,1,1)
!/SMC CORLAT(I,1,3) = Y0 + (IJKCel(2,I) + IJKCel(4,I))*DLAT
!/SMC CORLAT(I,1,4)=CORLAT(I,1,3)
!/SMC ! areas
!/SMC AREA(I,1) = 0.25 * IJKCEL(3,I)*DLON * IJKCEL(4,I)*DLAT
!/SMC ! Model grid mask
!/SMC MASK(I,1) = 1
!/SMC ENDDO
ENDIF
ELSE
!
! 1.2. Unstructured grids
! 1.3. Unstructured grids
! ----------------------------------
WRITE(*,*) 'TO BE IMPLEMENT FOR UNSTRUCTURED GRIDS'
STOP
Expand Down Expand Up @@ -389,42 +427,62 @@
INTEGER :: ISEA, JSEA, IX, IY
INTEGER :: NHXW, NHXE, NHYS, NHYN ! size of the halo at the western, eastern, southern, northern boundaries
LOGICAL :: LL_MPI_FILE ! to check if there an mpi.txt file for domain decompasition
LOGICAL :: RGLGRD = .TRUE.
!/
!/ ------------------------------------------------------------------- /
!/ Executable part
!/
!/SMC RGLGRD = .FALSE.
!
IF (GTYPE .EQ. RLGTYPE .OR. GTYPE .EQ. CLGTYPE) THEN
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NHXW = 1 ; NHXE = NX ; NHYS = 1 ; NHYN = NY
NHXW = NHXW - 1
NHXE = NX - NHXE
NHYS = NHYS - 1
NHYN = NY - NHYN
!
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(ISEA,JSEA)

IX = MAPSF(ISEA,1)
IY = MAPSF(ISEA,2)
ILA_PARAL(JSEA*2+1) = (IY - NHYN -1)*(NX - NHXE - NHXW) + (IX - NHXW - 1)
ILA_PARAL(JSEA*2+2) = 1
END DO
!
IF (RGLGRD) THEN
!
! 1.1. regular and curvilinear grids
! ----------------------------------
NHXW = 1 ; NHXE = NX ; NHYS = 1 ; NHYN = NY
NHXW = NHXW - 1
NHXE = NX - NHXE
NHYS = NHYS - 1
NHYN = NY - NHYN
!
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(ISEA,JSEA)

IX = MAPSF(ISEA,1)
IY = MAPSF(ISEA,2)
ILA_PARAL(JSEA*2+1) = (IY - NHYN -1)*(NX - NHXE - NHXW) + (IX - NHXW - 1)
ILA_PARAL(JSEA*2+2) = 1
END DO
!/SMC ELSE
!/SMC !
!/SMC ! 1.2. SMC grids
!/SMC ! ----------------------------------
!/SMC ALLOCATE(ILA_PARAL(2+NSEAL))
!/SMC !
!/SMC ! * Define the partition : OASIS POINTS partition
!/SMC ILA_PARAL(1) = 4
!/SMC !
!/SMC ! * total number of segments of the global domain
!/SMC ILA_PARAL(2) = NSEAL
!/SMC !
!/SMC DO JSEA=1, NSEAL
!/SMC ILA_PARAL(JSEA+2) = IAPROC + (JSEA-1)*NAPROC
!/SMC ENDDO
ENDIF
!
ELSE
!
! 1.2. Unstructured grids
! 1.3. Unstructured grids
! ----------------------------------
WRITE(*,*) 'TO BE VERIFY FOR UNSTRUCTURED GRIDS'
WRITE(*,*) 'TO BE VERIFIED FOR UNSTRUCTURED GRIDS'
STOP
!
DO JSEA=1,NSEAL
Expand Down
4 changes: 4 additions & 0 deletions regtests/bin/matrix.base
Original file line number Diff line number Diff line change
Expand Up @@ -2045,6 +2045,10 @@
echo "$rtst -r ww3_grid -s OASACM5 -w work_OASACM5 -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
echo "$rtst -r ww3_shel -s OASACM5 -w work_OASACM5 -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
echo "$rtst -r ww3_ounf -s OASACM5 -w work_OASACM5 -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
echo "mv ww3_tp2.14/input/ww3_ounf.inp ww3_tp2.14/input/ww3_ounf.inp.bak" >> matrix.body
echo "cp ww3_tp2.14/input/ww3_ounf.inp-OASACM6 ww3_tp2.14/input/ww3_ounf.inp" >> matrix.body
echo "$rtst -g OASACM6 -s OASACM6 -w work_OASACM6 -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
echo "mv ww3_tp2.14/input/ww3_ounf.inp.bak ww3_tp2.14/input/ww3_ounf.inp" >> matrix.body
echo "$rtst -s OASOCM -w work_OASOCM -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
echo "$rtst -s OASICM -w work_OASICM -C OASIS -f -p $mpi -n $np -o netcdf $ww3 ww3_tp2.14" >> matrix.body
fi
Expand Down
10 changes: 9 additions & 1 deletion regtests/ww3_tp2.14/info
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
# !/COU !/OASIS !/OASACM5 #
# selecting coupling atmospheric model with the coupler OASIS3-mct #
# reading restart generated by a coupled run (continuation run) #
# !/COU !/OASIS !/OASACM6 #
# selecting coupling atmospheric model with the coupler OASIS3-mct #
# coupling with SMC grid, coupling at T+0 #
# !/COU !/OASIS !/OASOCM #
# selecting coupling ocean model with the coupler OASIS3-mct #
# !/COU !/OASIS !/OASICM #
Expand Down Expand Up @@ -114,9 +117,14 @@
# -p mpirun -n 4 -o netcdf ../model ww3_tp2.14 #
# ./bin/run_test -r ww3_ounf -s OASACM5 -w work_OASACM5 -C OASIS -f #
# -p mpirun -n 4 -o netcdf ../model ww3_tp2.14 #
# mv ww3_tp2.14/input/ww3_ounf.inp ww3_tp2.14/input/ww3_ounf.inp.bak #
# cp ww3_tp2.14/input/ww3_ounf.inp-OASACM6 ww3_tp2.14/input/ww3_ounf.inp #
# ./bin/run_test -g OASACM6 -s OASACM6 -w work_OASACM6 -C OASIS -f #
# -p mpirun -n 4 -o netcdf ../model ww3_tp2.14 #
# mv ww3_tp2.14/input/ww3_ounf.inp.bak ww3_tp2.14/input/ww3_ounf.inp #
# #
# M. Accensi, Feb 2015 #
# Ifremer Institute #
# Last Mod : Sept 2020 #
# Last Mod : Oct 2020 #
# #
#############################################################################
Loading