Skip to content

Commit

Permalink
ww3_150826 commit Qing Li Aug updates
Browse files Browse the repository at this point in the history
  • Loading branch information
apcraig committed Aug 27, 2015
1 parent 5af8998 commit 0d50aa7
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 34 deletions.
16 changes: 14 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
================================================================================
ww3 ChangeLo
ww3 ChangeLog
================================================================================
Originator: mvertens
Originator: tcraig
Date: 26 Aug 2015
Model: cpl7
Version: ww3_150826
One-line summary: update from Qing Li from August 2015
M bld/ww3.buildnml
M src/source/w3cesmmd.f90
M src/source/w3initmd.f90
M src/source/w3wavemd.f90
M src/source/w3iorsmd.f90
M src/cpl_mct/wav_comp_mct.F90
================================================================================
Originator: tcraig
Date: 18 Aug 2015
Model: cpl7
Version: ww3_150818
Expand Down
10 changes: 6 additions & 4 deletions bld/ww3.buildnml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ chdir "${CASEROOT}";
my $RUNDIR = `./xmlquery RUNDIR -value`;
my $DIN_LOC_ROOT = `./xmlquery DIN_LOC_ROOT -value`;
my $CONTINUE_RUN = `./xmlquery CONTINUE_RUN -value`;
my $CASE = `./xmlquery CASE -value`;


if (-d "$RUNDIR") {
# QL, 150526, no copy of restart.ww3 if CONTINUE_RUN is TRUE, fixed some typos in the error message
# 150629, it seems that restart.ww3 is no longer needed for initial run
#if ($CONTINUE_RUN eq 'FALSE') {
# my $sysmod = "cp $DIN_LOC_ROOT/wav/ww3/restart.ww3.init.seed $RUNDIR/restart.ww3";
# system($sysmod) == 0 or die "ERROR ww3.buildnml: $sysmod failed: $?\n";
#}
# 150823, still need the initial condition
if ($CONTINUE_RUN eq 'FALSE') {
my $sysmod = "cp $DIN_LOC_ROOT/wav/ww3/restart.ww3.init.seed $RUNDIR/$CASE.ww3.r.0001-01-01-00000";
system($sysmod) == 0 or die "ERROR ww3.buildnml: $sysmod failed: $?\n";
}

my $sysmod = "cp $DIN_LOC_ROOT/wav/ww3/core2_G4_wns_30min_20000601_to_05.nc $RUNDIR/wind.ww3";
system($sysmod) == 0 or die "ERROR ww3.buildnml: $sysmod failed: $?\n";
Expand Down
63 changes: 44 additions & 19 deletions src/cpl_mct/wav_comp_mct.F90
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ MODULE WAV_COMP_MCT
!/
use w3iopomd
use w3timemd
use w3cesmmd, only : casename
use w3cesmmd, only : casename, rstwr

use esmf
use mct_mod
Expand All @@ -182,7 +182,8 @@ MODULE WAV_COMP_MCT
use shr_kind_mod , only : in=>shr_kind_in, r8=>shr_kind_r8, &
cs=>shr_kind_cs, cl=>shr_kind_cl
use seq_cdata_mod , only : seq_cdata, seq_cdata_setptrs
use seq_timemgr_mod , only : seq_timemgr_eclockgetdata
use seq_timemgr_mod , only : seq_timemgr_eclockgetdata, &
seq_timemgr_RestartAlarmIsOn
use seq_infodata_mod , only : seq_infodata_type, seq_infodata_getdata, seq_infodata_putdata, &
seq_infodata_start_type_start, seq_infodata_start_type_cont, &
seq_infodata_start_type_brnch
Expand Down Expand Up @@ -213,7 +214,7 @@ MODULE WAV_COMP_MCT
CONTAINS
!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )
SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w_w, w2x_w, NLFilename )

!/ ------------------------------------------------------------------- /
!/ Parameter list
Expand All @@ -222,7 +223,7 @@ SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )
implicit none
TYPE(ESMF_CLOCK), INTENT(INOUT) :: ECLOCK
TYPE(SEQ_CDATA) , INTENT(INOUT) :: CDATA
TYPE(MCT_AVECT) , INTENT(INOUT) :: X2W, W2X
TYPE(MCT_AVECT) , INTENT(INOUT) :: X2W_W, W2X_W
CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: NLFILENAME ! NAMELIST FILENAME

!/ ------------------------------------------------------------------- /
Expand Down Expand Up @@ -258,6 +259,7 @@ SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )
timen(2), odat(30), nh(4), iprt(6)
integer :: i,j,npts
integer :: ierr
integer :: jsea,isea
real :: a(nhmax,4)
real, allocatable :: x(:), y(:)
logical :: flgrd(nogrd), prtfrm, flt
Expand Down Expand Up @@ -415,15 +417,11 @@ SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )

! TIME0 = from ESMF clock
! NOTE - are not setting TIMEN here
! QL, 150629, TIMEN is set here to calculate the restart time
! interval, hardwired to write restart file at the end of run

if ( iaproc .eq. napout ) write (ndso,930)
call shr_sys_flush(stdout)

! QL, 150525, initial run or restart run
! TODO, currently restart files are written at the end of run
! need to suppot REST_OPTION and REST_N
if ( runtype .eq. "initial") then
call seq_timemgr_EClockGetData(EClock, &
start_ymd=start_ymd, start_tod=start_tod)
Expand Down Expand Up @@ -488,21 +486,25 @@ SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )
do j=1, 6
odat(5*(j-1)+3) = 0
end do
! QL, 150629, calculating restart output interval
time_int = dsec21(time0, timen)

! QL, 160823, initialize flag for restart
rstwr = .false.


!DEBUG
! Hardwire gridded output for now
! first output time stamp is now read from file
! QL, 150525, 1-5 for history files, 16-20 for restart files
! 150629, restart output interval is set to the total time of run
! 150823, restart is taken over by rstwr
odat(1) = time(1) ! YYYYMMDD for first output
odat(2) = time(2) ! HHMMSS for first output
odat(3) = 21600 ! output interval in sec ! changed by Adrean
odat(4) = 99990101 ! YYYYMMDD for last output
odat(5) = 0 ! HHMMSS for last output
odat(16) = time(1) ! YYYYMMDD for first output
odat(17) = time(2) ! HHMMSS for first output
odat(18) = time_int ! output interval in sec
odat(18) = 86400 ! output interval in sec
odat(19) = 99990101 ! YYYYMMDD for last output
odat(20) = 0 ! HHMMSS for last output
!DEBUG
Expand Down Expand Up @@ -612,14 +614,37 @@ SUBROUTINE WAV_INIT_MCT( EClock, cdata, x2w, w2x, NLFilename )

! initialize mct attribute vectors

call mct_avect_init(w2x, rlist=seq_flds_w2x_fields, lsize=lsize)
call mct_avect_zero(w2x)
call mct_avect_init(w2x_w, rlist=seq_flds_w2x_fields, lsize=lsize)
call mct_avect_zero(w2x_w)

call mct_avect_init(x2w, rlist=seq_flds_x2w_fields, lsize=lsize)
call mct_avect_zero(x2w)
call mct_avect_init(x2w_w, rlist=seq_flds_x2w_fields, lsize=lsize)
call mct_avect_zero(x2w_w)

! add call to gptl timer

! QL, 150823, send initial state to driver
! same with that in wav_run_mct, maybe could be put into a
! subroutine wav_export
! copy enhancement factor, uStokes, vStokes to coupler
do jsea=1, nseal
isea = iaproc + (jsea-1)*naproc
if (LASLPJ(ISEA) .ne. 1.e30 .and. LASLPJ(ISEA) .gt. 1.e-4) then
! VR12-MA & VR12-EN
w2x_w%rattr(index_w2x_Sw_lamult,jsea) = ABS(COS(ALPHAL(ISEA))) * &
SQRT(1+(1.5*LASLPJ(ISEA))**-2+(5.4*LASLPJ(ISEA))**-4)
! VR12-AL
!w2x_w%rattr(index_w2x_Sw_lamult,jsea) = &
! SQRT(1+(3.1*LANGMT(ISEA))**-2+(5.4*LANGMT(ISEA))**-4)
w2x_w%rattr(index_w2x_Sw_ustokes,jsea) = USSX(ISEA)
w2x_w%rattr(index_w2x_Sw_vstokes,jsea) = USSY(ISEA)
else
w2x_w%rattr(index_w2x_Sw_lamult,jsea) = 1.
w2x_w%rattr(index_w2x_Sw_ustokes,jsea) = 0.
w2x_w%rattr(index_w2x_Sw_vstokes,jsea) = 0.
endif
!w2x_w%rattr(index_w2x_Sw_hstokes,jsea) = ??
enddo

! end redirection of share output to wav log

call shr_sys_flush(stdout)
Expand Down Expand Up @@ -712,6 +737,9 @@ SUBROUTINE WAV_RUN_MCT(EClock, cdata_w, x2w_w, w2x_w)
write(stdout,*)'time0= ',time0
write(stdout,*)'timen= ',timen

! QL, 150823, set flag for writing restart file
rstwr = seq_timemgr_RestartAlarmIsOn(EClock)

!--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! 7. Model with input
! 7.a Determine next time interval and input fields
Expand Down Expand Up @@ -863,10 +891,7 @@ SUBROUTINE WAV_RUN_MCT(EClock, cdata_w, x2w_w, w2x_w)
! QL, 150612, copy enhancement factor, uStokes, vStokes to coupler
do jsea=1, nseal
isea = iaproc + (jsea-1)*naproc
IX = MAPSF(ISEA,1)
IY = MAPSF(ISEA,2)
if (LASLPJ(ISEA) .ne. 1.e30) then
! TODO calculating enhancement factor here
if (LASLPJ(ISEA) .ne. 1.e30 .and. LASLPJ(ISEA) .gt. 1.e-4) then
! VR12-MA & VR12-EN
w2x_w%rattr(index_w2x_Sw_lamult,jsea) = ABS(COS(ALPHAL(ISEA))) * &
SQRT(1+(1.5*LASLPJ(ISEA))**-2+(5.4*LASLPJ(ISEA))**-4)
Expand Down
2 changes: 2 additions & 0 deletions src/source/w3cesmmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ MODULE W3CESMMD
!/
private
character(len=256),public :: casename
! QL, 150823, flag for restart
logical,public :: rstwr ! true => write restart at end of day

!/
!/ End of module CESMMD ---------------------------------------------- /
Expand Down
16 changes: 8 additions & 8 deletions src/source/w3initmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,14 @@ SUBROUTINE W3INIT ( IMOD, FEXT, MDS, MTRACE, ODAT, &
!
! 3.b Compare MAPSTA from grid and restart
!
DO IX=1, NX
DO IY=1, NY
IF ( ABS(MAPSTA(IY,IX)).EQ.2 .OR. &
ABS(MAPTST(IY,IX)).EQ.2 ) THEN
MAPSTA(IY,IX) = SIGN ( MAPTST(IY,IX) , MAPSTA(IY,IX) )
END IF
END DO
END DO
! DO IX=1, NX
! DO IY=1, NY
! IF ( ABS(MAPSTA(IY,IX)).EQ.2 .OR. &
! ABS(MAPTST(IY,IX)).EQ.2 ) THEN
! MAPSTA(IY,IX) = SIGN ( MAPTST(IY,IX) , MAPSTA(IY,IX) )
! END IF
! END DO
! END DO
!
! 3.c Initialization from wind fields
!
Expand Down
95 changes: 95 additions & 0 deletions src/source/w3iorsmd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ SUBROUTINE W3IORS ( INXOUT, NDSR, DUMFPI, INTYPE, IMOD )
USE W3SERVMD, ONLY: EXTCDE
! QL, 150629, casename for restart file
USE W3CESMMD, ONLY : CASENAME
! QL, 150823, save in restart file
USE W3ADATMD, ONLY : LASLPJ, ALPHAL, USSX, USSY, DW, &
MAPX2, MAPY2, MAPAXY
!
IMPLICIT NONE
!
Expand Down Expand Up @@ -572,6 +575,52 @@ SUBROUTINE W3IORS ( INXOUT, NDSR, DUMFPI, INTYPE, IMOD )
(FPIS(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
! QL, 150823, save more variables
!DO IX=1, NX
! NREC = NREC + 1
! WRITE (NDSR,REC=NREC) &
! (MAPX2(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IX=1, NX
! NREC = NREC + 1
! WRITE (NDSR,REC=NREC) &
! (MAPY2(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IX=1, NX
! NREC = NREC + 1
! WRITE (NDSR,REC=NREC) &
! (MAPAXY(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IPART=1,NPART
! NREC = NREC + 1
! WRITE (NDSR,REC=NREC) &
! (DW(ISEA),ISEA=1+(IPART-1)*NSIZE, &
! MIN(NSEA,IPART*NSIZE))
! END DO
DO IPART=1,NPART
NREC = NREC + 1
WRITE (NDSR,REC=NREC) &
(LASLPJ(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
WRITE (NDSR,REC=NREC) &
(ALPHAL(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
WRITE (NDSR,REC=NREC) &
(USSX(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
WRITE (NDSR,REC=NREC) &
(USSY(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
END IF
END IF
ELSE
Expand Down Expand Up @@ -623,6 +672,52 @@ SUBROUTINE W3IORS ( INXOUT, NDSR, DUMFPI, INTYPE, IMOD )
(FPIS(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
! QL, 150823, read more variables
!DO IX=1, NX
! NREC = NREC + 1
! READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
! (MAPX2(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IX=1, NX
! NREC = NREC + 1
! READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
! (MAPY2(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IX=1, NX
! NREC = NREC + 1
! READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
! (MAPAXY(ISEA),ISEA=1+(IX-1)*NY,IX*NY)
! END DO
!DO IPART=1,NPART
! NREC = NREC + 1
! READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
! (DW(ISEA),ISEA=1+(IPART-1)*NSIZE, &
! MIN(NSEA,IPART*NSIZE))
! END DO
DO IPART=1,NPART
NREC = NREC + 1
READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
(LASLPJ(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
(ALPHAL(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
(USSX(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
DO IPART=1,NPART
NREC = NREC + 1
READ (NDSR,REC=NREC,ERR=802,IOSTAT=IERR) &
(USSY(ISEA),ISEA=1+(IPART-1)*NSIZE, &
MIN(NSEA,IPART*NSIZE))
END DO
ELSE
TLEV(1) = -1
TLEV(2) = 0
Expand Down
6 changes: 5 additions & 1 deletion src/source/w3wavemd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ SUBROUTINE W3WAVE ( IMOD, TEND, STAMP, NO_OUT )
!/
USE W3SERVMD
USE W3TIMEMD

! QL, 150823, flag for restart
use w3cesmmd, only : rstwr
use shr_sys_mod, only : shr_sys_flush
!
IMPLICIT NONE
Expand Down Expand Up @@ -932,7 +935,8 @@ SUBROUTINE W3WAVE ( IMOD, TEND, STAMP, NO_OUT )
END IF
ELSE IF ( J .EQ. 3 ) THEN
CALL W3IOTR ( NDS(11), NDS(12), VA, IMOD )
ELSE IF ( J .EQ. 4 ) THEN
! QL, 150823, add restart flag
ELSE IF ( J .EQ. 4 .AND. RSTWR) THEN
CALL W3IORS ('HOT', NDS(6), XXX, ITEST, IMOD )
ELSE IF ( J .EQ. 5 ) THEN
IF ( IAPROC .EQ. NAPBPT ) THEN
Expand Down

0 comments on commit 0d50aa7

Please sign in to comment.