|
| 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 |
0 commit comments