Skip to content

Commit 9ea1d89

Browse files
pass diag fields (HS, T01, T0M1, THM) to cpl (#38)
1 parent 32b667d commit 9ea1d89

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

model/src/wav_comp_nuopc.F90

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,10 @@ subroutine DataInitialize(gcomp, rc)
920920
real(r8), pointer :: sw_lasl(:)
921921
real(r8), pointer :: sw_ustokes(:)
922922
real(r8), pointer :: sw_vstokes(:)
923+
real(r8), pointer :: Sw_Hs(:)
924+
real(r8), pointer :: Sw_t01(:)
925+
real(r8), pointer :: Sw_t0m1(:)
926+
real(r8), pointer :: Sw_thm(:)
923927
real(r8), pointer :: wave_elevation_spectrum(:,:)
924928
character(len=*),parameter :: subname = '(wav_comp_nuopc:DataInitialize)'
925929
! -------------------------------------------------------------------
@@ -967,6 +971,26 @@ subroutine DataInitialize(gcomp, rc)
967971
if (ChkErr(rc,__LINE__,u_FILE_u)) return
968972
wave_elevation_spectrum(:,:) = 0.
969973
endif
974+
if (state_fldchk(exportState, 'Sw_Hs')) then
975+
call state_getfldptr(exportState, 'Sw_Hs', Sw_Hs, rc=rc)
976+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
977+
Sw_Hs (:) = 0.
978+
endif
979+
if (state_fldchk(exportState, 'Sw_t01')) then
980+
call state_getfldptr(exportState, 'Sw_t01', Sw_t01, rc=rc)
981+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
982+
Sw_t01 (:) = 0.
983+
endif
984+
if (state_fldchk(exportState, 'Sw_t0m1')) then
985+
call state_getfldptr(exportState, 'Sw_t0m1', Sw_t0m1, rc=rc)
986+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
987+
Sw_t0m1 (:) = 0.
988+
endif
989+
if (state_fldchk(exportState, 'Sw_thm')) then
990+
call state_getfldptr(exportState, 'Sw_thm', Sw_thm, rc=rc)
991+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
992+
Sw_thm (:) = 0.
993+
endif
970994

971995
if (.not. unstr_mesh) then
972996
! Set global grid size scalars in export state

model/src/wav_import_export.F90

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ subroutine advertise_fields(importState, ExportState, flds_scalar_name, rc)
148148
end if
149149
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_pstokes_x', ungridded_lbound=1, ungridded_ubound=3)
150150
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_pstokes_y', ungridded_lbound=1, ungridded_ubound=3)
151+
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_Hs')
152+
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_t01')
153+
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_t0m1')
154+
call fldlist_add(fldsFrWav_num, fldsFrWav, 'Sw_thm')
151155

152156
! AA TODO: In the above fldlist_add calls, we are passing hardcoded ungridded_ubound values (3) because, USSPF(2)
153157
! is not initialized yet. It is set during w3init which gets called at a later phase (realize). A permanent solution
@@ -589,7 +593,7 @@ subroutine export_fields (gcomp, rc)
589593
use w3iogomd , only : CALC_U3STOKES
590594
#ifdef W3_CESMCOUPLED
591595
use w3wdatmd , only : ASF, UST
592-
use w3adatmd , only : USSHX, USSHY, UD, HS
596+
use w3adatmd , only : USSHX, USSHY, UD, HS, T01, T0M1, THM
593597
use w3idatmd , only : HSL
594598
#else
595599
use wmmdatmd , only : mdse, mdst, wmsetm
@@ -622,6 +626,10 @@ subroutine export_fields (gcomp, rc)
622626
!real(r8), pointer :: sw_lasl(:)
623627
real(r8), pointer :: sw_ustokes(:)
624628
real(r8), pointer :: sw_vstokes(:)
629+
real(r8), pointer :: sw_hs(:)
630+
real(r8), pointer :: sw_t01(:)
631+
real(r8), pointer :: sw_t0m1(:)
632+
real(r8), pointer :: sw_thm(:)
625633

626634
! d2 is location, d1 is frequency - nwav_elev_spectrum frequencies will be used
627635
real(r8), pointer :: wave_elevation_spectrum(:,:)
@@ -741,6 +749,71 @@ subroutine export_fields (gcomp, rc)
741749
call CalcRoughl(z0rlen)
742750
endif
743751

752+
if (state_fldchk(exportState, 'Sw_Hs')) then
753+
call state_getfldptr(exportState, 'Sw_Hs', Sw_Hs, rc=rc)
754+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
755+
Sw_Hs(:) = fillvalue
756+
do jsea=1, nseal_cpl
757+
call init_get_isea(isea, jsea)
758+
ix = mapsf(isea,1)
759+
iy = mapsf(isea,2)
760+
if (mapsta(iy,ix) == 1) then
761+
Sw_Hs(jsea) = HS(jsea)
762+
else
763+
Sw_Hs(jsea) = 0.
764+
endif
765+
enddo
766+
end if
767+
768+
if (state_fldchk(exportState, 'Sw_t01')) then
769+
call state_getfldptr(exportState, 'Sw_t01', sw_t01, rc=rc)
770+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
771+
sw_t01(:) = fillvalue
772+
do jsea=1, nseal_cpl
773+
call init_get_isea(isea, jsea)
774+
ix = mapsf(isea,1)
775+
iy = mapsf(isea,2)
776+
if (mapsta(iy,ix) == 1) then
777+
sw_t01(jsea) = t01(jsea)
778+
else
779+
sw_t01(jsea) = 0.
780+
endif
781+
enddo
782+
end if
783+
784+
if (state_fldchk(exportState, 'Sw_t0m1')) then
785+
call state_getfldptr(exportState, 'Sw_t0m1', sw_t0m1, rc=rc)
786+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
787+
sw_t0m1(:) = fillvalue
788+
do jsea=1, nseal_cpl
789+
call init_get_isea(isea, jsea)
790+
ix = mapsf(isea,1)
791+
iy = mapsf(isea,2)
792+
if (mapsta(iy,ix) == 1) then
793+
sw_t0m1(jsea) = t0m1(jsea)
794+
else
795+
sw_t0m1(jsea) = 0.
796+
endif
797+
enddo
798+
end if
799+
800+
if (state_fldchk(exportState, 'Sw_thm')) then
801+
call state_getfldptr(exportState, 'Sw_thm', sw_thm, rc=rc)
802+
if (ChkErr(rc,__LINE__,u_FILE_u)) return
803+
sw_thm(:) = fillvalue
804+
do jsea=1, nseal_cpl
805+
call init_get_isea(isea, jsea)
806+
ix = mapsf(isea,1)
807+
iy = mapsf(isea,2)
808+
if (mapsta(iy,ix) == 1) then
809+
sw_thm(jsea) = thm(jsea)
810+
else
811+
sw_thm(jsea) = 0.
812+
endif
813+
enddo
814+
end if
815+
816+
744817
if ( state_fldchk(exportState, 'wbcuru') .and. &
745818
state_fldchk(exportState, 'wbcurv') .and. &
746819
state_fldchk(exportState, 'wbcurp')) then

0 commit comments

Comments
 (0)