Skip to content

Commit 2b794da

Browse files
Merge pull request #4 from alperaltuntas/dev/ncar
Added coupler indices module
2 parents fa86163 + fbd405b commit 2b794da

2 files changed

Lines changed: 234 additions & 2 deletions

File tree

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
module coupler_indices
2+
3+
use seq_flds_mod, only : seq_flds_x2o_fields, seq_flds_o2x_fields
4+
use seq_flds_mod, only : seq_flds_i2o_per_cat, ice_ncat
5+
use mct_mod
6+
7+
implicit none
8+
9+
private
10+
11+
public coupler_indices_init
12+
13+
type, public :: cpl_indices
14+
15+
! ocn -> drv
16+
17+
integer :: o2x_So_t
18+
integer :: o2x_So_u
19+
integer :: o2x_So_v
20+
integer :: o2x_So_s
21+
integer :: o2x_So_dhdx
22+
integer :: o2x_So_dhdy
23+
! QL, 150526, to wav, boundary layer depth
24+
integer :: o2x_So_bldepth
25+
integer :: o2x_Fioo_q
26+
integer :: o2x_Faoo_fco2_ocn
27+
integer :: o2x_Faoo_fdms_ocn
28+
29+
! drv -> ocn
30+
31+
integer :: x2o_Si_ifrac ! fractional ice wrt ocean
32+
integer :: x2o_So_duu10n ! 10m wind speed squared (m^2/s^2)
33+
integer :: x2o_Sa_pslv ! sea-level pressure (Pa)
34+
integer :: x2o_Sa_co2prog ! bottom atm level prognostic CO2
35+
integer :: x2o_Sa_co2diag ! bottom atm level diagnostic CO2
36+
! QL, 150526, from wav
37+
integer :: x2o_Sw_lamult ! wave model langmuir multiplier
38+
integer :: x2o_Sw_ustokes ! surface Stokes drift, x-component
39+
integer :: x2o_Sw_vstokes ! surface Stokes drift, y-component
40+
integer :: x2o_Foxx_taux ! zonal wind stress (taux) (W/m2 )
41+
integer :: x2o_Foxx_tauy ! meridonal wind stress (tauy) (W/m2 )
42+
integer :: x2o_Foxx_swnet ! net short-wave heat flux (W/m2 )
43+
integer :: x2o_Foxx_sen ! sensible heat flux (W/m2 )
44+
integer :: x2o_Foxx_lat
45+
integer :: x2o_Foxx_lwup ! longwave radiation (up) (W/m2 )
46+
integer :: x2o_Faxa_lwdn ! longwave radiation (down) (W/m2 )
47+
integer :: x2o_Fioi_melth ! heat flux from snow & ice melt (W/m2 )
48+
integer :: x2o_Fioi_meltw ! snow melt flux (kg/m2/s)
49+
integer :: x2o_Fioi_bcpho ! flux: Black Carbon hydrophobic release from sea ice component
50+
integer :: x2o_Fioi_bcphi ! flux: Black Carbon hydrophilic release from sea ice component
51+
integer :: x2o_Fioi_flxdst ! flux: dust release from sea ice component
52+
integer :: x2o_Fioi_salt ! salt (kg(salt)/m2/s)
53+
integer :: x2o_Foxx_evap ! evaporation flux (kg/m2/s)
54+
integer :: x2o_Faxa_prec
55+
integer :: x2o_Faxa_snow ! water flux due to snow (kg/m2/s)
56+
integer :: x2o_Faxa_rain ! water flux due to rain (kg/m2/s)
57+
integer :: x2o_Faxa_bcphidry ! flux: Black Carbon hydrophilic dry deposition
58+
integer :: x2o_Faxa_bcphodry ! flux: Black Carbon hydrophobic dry deposition
59+
integer :: x2o_Faxa_bcphiwet ! flux: Black Carbon hydrophilic wet deposition
60+
integer :: x2o_Faxa_ocphidry ! flux: Organic Carbon hydrophilic dry deposition
61+
integer :: x2o_Faxa_ocphodry ! flux: Organic Carbon hydrophobic dry deposition
62+
integer :: x2o_Faxa_ocphiwet ! flux: Organic Carbon hydrophilic dry deposition
63+
integer :: x2o_Faxa_dstwet1 ! flux: Size 1 dust -- wet deposition
64+
integer :: x2o_Faxa_dstwet2 ! flux: Size 2 dust -- wet deposition
65+
integer :: x2o_Faxa_dstwet3 ! flux: Size 3 dust -- wet deposition
66+
integer :: x2o_Faxa_dstwet4 ! flux: Size 4 dust -- wet deposition
67+
integer :: x2o_Faxa_dstdry1 ! flux: Size 1 dust -- dry deposition
68+
integer :: x2o_Faxa_dstdry2 ! flux: Size 2 dust -- dry deposition
69+
integer :: x2o_Faxa_dstdry3 ! flux: Size 3 dust -- dry deposition
70+
integer :: x2o_Faxa_dstdry4 ! flux: Size 4 dust -- dry deposition
71+
integer :: x2o_Foxx_rofl ! river runoff flux (kg/m2/s)
72+
integer :: x2o_Foxx_rofi ! ice runoff flux (kg/m2/s)
73+
74+
! optional per thickness category fields
75+
76+
integer, dimension(:), allocatable :: x2o_frac_col ! fraction of ocean cell, per column
77+
integer, dimension(:), allocatable :: x2o_fracr_col ! fraction of ocean cell used in radiation computations, per column
78+
integer, dimension(:), allocatable :: x2o_qsw_fracr_col ! qsw * fracr, per column
79+
80+
end type cpl_indices
81+
82+
! Module data for storing
83+
type(cpl_indices), public :: ind
84+
85+
contains
86+
87+
subroutine coupler_indices_init( )
88+
89+
type(mct_aVect) :: o2x ! temporary
90+
type(mct_aVect) :: x2o ! temporary
91+
92+
integer :: ncat ! thickness category index
93+
character(len=2) :: cncat ! character version of ncat
94+
integer :: ncol ! column index
95+
integer :: mcog_ncols
96+
integer :: lmcog_flds_sent
97+
98+
! Determine attribute vector indices
99+
100+
! create temporary attribute vectors
101+
call mct_aVect_init(x2o, rList=seq_flds_x2o_fields, lsize=1)
102+
call mct_aVect_init(o2x, rList=seq_flds_o2x_fields, lsize=1)
103+
104+
ind%o2x_So_t = mct_avect_indexra(o2x,'So_t')
105+
ind%o2x_So_u = mct_avect_indexra(o2x,'So_u')
106+
ind%o2x_So_v = mct_avect_indexra(o2x,'So_v')
107+
ind%o2x_So_s = mct_avect_indexra(o2x,'So_s')
108+
ind%o2x_So_dhdx = mct_avect_indexra(o2x,'So_dhdx')
109+
ind%o2x_So_dhdy = mct_avect_indexra(o2x,'So_dhdy')
110+
! QL, 150526, to wav, boundary layer depth
111+
ind%o2x_So_bldepth = mct_avect_indexra(o2x,'So_bldepth')
112+
ind%o2x_Fioo_q = mct_avect_indexra(o2x,'Fioo_q')
113+
ind%o2x_Faoo_fco2_ocn = mct_avect_indexra(o2x,'Faoo_fco2_ocn',perrWith='quiet')
114+
ind%o2x_Faoo_fdms_ocn = mct_avect_indexra(o2x,'Faoo_fdms_ocn',perrWith='quiet')
115+
ind%x2o_Si_ifrac = mct_avect_indexra(x2o,'Si_ifrac')
116+
ind%x2o_Sa_pslv = mct_avect_indexra(x2o,'Sa_pslv')
117+
ind%x2o_So_duu10n = mct_avect_indexra(x2o,'So_duu10n')
118+
! QL, 150526, from wav
119+
ind%x2o_Sw_lamult = mct_avect_indexra(x2o,'Sw_lamult')
120+
ind%x2o_Sw_ustokes = mct_avect_indexra(x2o,'Sw_ustokes')
121+
ind%x2o_Sw_vstokes = mct_avect_indexra(x2o,'Sw_vstokes')
122+
123+
ind%x2o_Foxx_tauy = mct_avect_indexra(x2o,'Foxx_tauy')
124+
ind%x2o_Foxx_taux = mct_avect_indexra(x2o,'Foxx_taux')
125+
ind%x2o_Foxx_swnet = mct_avect_indexra(x2o,'Foxx_swnet')
126+
ind%x2o_Foxx_lat = mct_avect_indexra(x2o,'Foxx_lat')
127+
ind%x2o_Foxx_sen = mct_avect_indexra(x2o,'Foxx_sen')
128+
ind%x2o_Foxx_lwup = mct_avect_indexra(x2o,'Foxx_lwup')
129+
ind%x2o_Faxa_lwdn = mct_avect_indexra(x2o,'Faxa_lwdn')
130+
ind%x2o_Fioi_melth = mct_avect_indexra(x2o,'Fioi_melth')
131+
ind%x2o_Fioi_meltw = mct_avect_indexra(x2o,'Fioi_meltw')
132+
ind%x2o_Fioi_salt = mct_avect_indexra(x2o,'Fioi_salt')
133+
ind%x2o_Fioi_bcpho = mct_avect_indexra(x2o,'Fioi_bcpho')
134+
ind%x2o_Fioi_bcphi = mct_avect_indexra(x2o,'Fioi_bcphi')
135+
ind%x2o_Fioi_flxdst = mct_avect_indexra(x2o,'Fioi_flxdst')
136+
ind%x2o_Faxa_prec = mct_avect_indexra(x2o,'Faxa_prec')
137+
ind%x2o_Faxa_snow = mct_avect_indexra(x2o,'Faxa_snow')
138+
ind%x2o_Faxa_rain = mct_avect_indexra(x2o,'Faxa_rain')
139+
ind%x2o_Foxx_evap = mct_avect_indexra(x2o,'Foxx_evap')
140+
ind%x2o_Foxx_rofl = mct_avect_indexra(x2o,'Foxx_rofl')
141+
ind%x2o_Foxx_rofi = mct_avect_indexra(x2o,'Foxx_rofi')
142+
ind%x2o_Faxa_bcphidry = mct_avect_indexra(x2o,'Faxa_bcphidry')
143+
ind%x2o_Faxa_bcphodry = mct_avect_indexra(x2o,'Faxa_bcphodry')
144+
ind%x2o_Faxa_bcphiwet = mct_avect_indexra(x2o,'Faxa_bcphiwet')
145+
ind%x2o_Faxa_ocphidry = mct_avect_indexra(x2o,'Faxa_ocphidry')
146+
ind%x2o_Faxa_ocphodry = mct_avect_indexra(x2o,'Faxa_ocphodry')
147+
ind%x2o_Faxa_ocphiwet = mct_avect_indexra(x2o,'Faxa_ocphiwet')
148+
ind%x2o_Faxa_dstdry1 = mct_avect_indexra(x2o,'Faxa_dstdry1')
149+
ind%x2o_Faxa_dstdry2 = mct_avect_indexra(x2o,'Faxa_dstdry2')
150+
ind%x2o_Faxa_dstdry3 = mct_avect_indexra(x2o,'Faxa_dstdry3')
151+
ind%x2o_Faxa_dstdry4 = mct_avect_indexra(x2o,'Faxa_dstdry4')
152+
ind%x2o_Faxa_dstwet1 = mct_avect_indexra(x2o,'Faxa_dstwet1')
153+
ind%x2o_Faxa_dstwet2 = mct_avect_indexra(x2o,'Faxa_dstwet2')
154+
ind%x2o_Faxa_dstwet3 = mct_avect_indexra(x2o,'Faxa_dstwet3')
155+
ind%x2o_Faxa_dstwet4 = mct_avect_indexra(x2o,'Faxa_dstwet4')
156+
ind%x2o_Sa_co2prog = mct_avect_indexra(x2o,'Sa_co2prog',perrWith='quiet')
157+
ind%x2o_Sa_co2diag = mct_avect_indexra(x2o,'Sa_co2diag',perrWith='quiet')
158+
159+
! optional per thickness category fields
160+
161+
! convert cpl indices to mcog column indices
162+
! this implementation only handles columns due to ice thickness categories
163+
164+
lmcog_flds_sent = seq_flds_i2o_per_cat
165+
166+
if (seq_flds_i2o_per_cat) then
167+
mcog_ncols = ice_ncat+1
168+
allocate(ind%x2o_frac_col(mcog_ncols))
169+
allocate(ind%x2o_fracr_col(mcog_ncols))
170+
allocate(ind%x2o_qsw_fracr_col(mcog_ncols))
171+
172+
ncol = 1
173+
ind%x2o_frac_col(ncol) = mct_avect_indexra(x2o,'Sf_afrac')
174+
ind%x2o_fracr_col(ncol) = mct_avect_indexra(x2o,'Sf_afracr')
175+
ind%x2o_qsw_fracr_col(ncol) = mct_avect_indexra(x2o,'Foxx_swnet_afracr')
176+
177+
do ncat = 1, ice_ncat
178+
write(cncat,'(i2.2)') ncat
179+
ncol = ncat+1
180+
ind%x2o_frac_col(ncol) = mct_avect_indexra(x2o,'Si_ifrac_'//cncat)
181+
ind%x2o_fracr_col(ncol) = ind%x2o_frac_col(ncol)
182+
ind%x2o_qsw_fracr_col(ncol) = mct_avect_indexra(x2o,'PFioi_swpen_ifrac_'//cncat)
183+
enddo
184+
else
185+
mcog_ncols = 1
186+
endif
187+
188+
call mct_aVect_clean(x2o)
189+
call mct_aVect_clean(o2x)
190+
191+
192+
end subroutine coupler_indices_init
193+
194+
end module coupler_indices

config_src/mct_driver/ocn_comp_mct.F90

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ module ocn_comp_mct
1414
use esmf
1515
use seq_cdata_mod
1616
use mct_mod
17-
17+
use seq_infodata_mod, only: seq_infodata_type, &
18+
seq_infodata_GetData, &
19+
seq_infodata_start_type_start, &
20+
seq_infodata_start_type_cont, &
21+
seq_infodata_start_type_brnch
22+
1823
! From MOM6
1924
use ocean_model_mod, only: ocean_state_type, ocean_public_type
2025
use ocean_model_mod, only: ocean_model_init
2126
use MOM_time_manager, only: time_type, set_date, set_calendar_type, NOLEAP
2227
use MOM_domains, only: MOM_infra_init, num_pes, root_pe, pe_here
28+
use coupler_indices, only: coupler_indices_init
2329

2430
!
2531
! !PUBLIC MEMBER FUNCTIONS:
@@ -43,6 +49,9 @@ module ocn_comp_mct
4349
type(ocean_state_type), pointer :: ocn_state => NULL() ! Private state of ocean
4450
type(ocean_public_type), pointer :: ocn_surface => NULL() ! Public surface state of ocean
4551

52+
type(seq_infodata_type), pointer :: &
53+
infodata
54+
4655
!=======================================================================
4756

4857
contains
@@ -78,13 +87,18 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
7887
type(ESMF_time) :: current_time
7988
integer :: year, month, day, hour, minute, seconds, rc
8089
character(len=128) :: errMsg
90+
character(len=384) :: runid
91+
character(len=384) :: runtype
92+
character(len=32) :: starttype ! infodata start type
8193
integer :: mpicom
8294
integer :: npes, pe0
8395
integer :: i
8496

85-
mpicom = cdata_o%mpicom
8697

98+
! Initialize MOM6
99+
mpicom = cdata_o%mpicom
87100
call MOM_infra_init(mpicom)
101+
88102
call ESMF_ClockGet(EClock, currTime=current_time, rc=rc)
89103
call ESMF_TimeGet(current_time, yy=year, mm=month, dd=day, h=hour, m=minute, s=seconds, rc=rc)
90104
! we need to confirm this:
@@ -101,8 +115,32 @@ subroutine ocn_init_mct( EClock, cdata_o, x2o_o, o2x_o, NLFilename )
101115
allocate(ocn_surface%pelist(npes))
102116
ocn_surface%pelist(:) = (/(i,i=pe0,pe0+npes)/)
103117

118+
! initialize the model run
104119
call ocean_model_init(ocn_surface, ocn_state, time_init, time_in)
105120

121+
! set infodata, a cdata pointer
122+
call seq_cdata_setptrs(cdata_o, infodata=infodata)
123+
124+
! initialize coupler indices
125+
call coupler_indices_init()
126+
127+
! get runid and starttype:
128+
call seq_infodata_GetData( infodata, case_name=runid )
129+
call seq_infodata_GetData( infodata, start_type=starttype)
130+
131+
132+
if ( trim(starttype) == trim(seq_infodata_start_type_start)) then
133+
runtype = "initial"
134+
else if (trim(starttype) == trim(seq_infodata_start_type_cont) ) then
135+
runtype = "continue"
136+
else if (trim(starttype) == trim(seq_infodata_start_type_brnch)) then
137+
runtype = "branch"
138+
else
139+
write(*,*) 'ocn_comp_mct ERROR: unknown starttype'
140+
call exit(0)
141+
end if
142+
143+
106144
!-----------------------------------------------------------------------
107145
!EOC
108146

0 commit comments

Comments
 (0)