Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
IF(TRIM( sn_snd_ifrac%cldes ) == 'coupled') ssnd(jps_ficet)%laction = .TRUE.
SELECT CASE ( TRIM( sn_snd_thick%cldes ) )
CASE( 'none' ) ! nothing to do
CASE( 'ice and snow' )
ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
IF( TRIM( sn_snd_thick%clcat ) == 'yes' ) THEN
ssnd(jps_hice:jps_hsnw)%nct = nn_cats_cpl
ENDIF
CASE ( 'weighted ice and snow' )
ssnd(jps_hice:jps_hsnw)%laction = .TRUE.
IF( TRIM( sn_snd_thick%clcat ) == 'yes' ) ssnd(jps_hice:jps_hsnw)%nct = nn_cats_cpl
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_thick%cldes' )
END SELECT
! ! ------------------------- !
! ! Ice Meltponds !
! ! ------------------------- !
! Needed by Met Office
ssnd(jps_a_p)%clname = 'OPndFrc'
ssnd(jps_ht_p)%clname = 'OPndTck'
SELECT CASE ( TRIM( sn_snd_mpnd%cldes ) )
CASE ( 'none' )
ssnd(jps_a_p)%laction = .FALSE.
ssnd(jps_ht_p)%laction = .FALSE.
CASE ( 'ice only' )
ssnd(jps_a_p)%laction = .TRUE.
ssnd(jps_ht_p)%laction = .TRUE.
IF( TRIM( sn_snd_mpnd%clcat ) == 'yes' ) THEN
ssnd(jps_a_p)%nct = nn_cats_cpl
ssnd(jps_ht_p)%nct = nn_cats_cpl
ELSE
IF( nn_cats_cpl > 1 ) THEN
CALL ctl_stop( 'sbc_cpl_init: use weighted ice option for sn_snd_mpnd%cldes if not exchanging category fields' )
ENDIF
ENDIF
CASE ( 'weighted ice' )
ssnd(jps_a_p)%laction = .TRUE.
ssnd(jps_ht_p)%laction = .TRUE.
IF( TRIM( sn_snd_mpnd%clcat ) == 'yes' ) THEN
ssnd(jps_a_p)%nct = nn_cats_cpl
ssnd(jps_ht_p)%nct = nn_cats_cpl
ENDIF
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_mpnd%cldes; '//sn_snd_mpnd%cldes )
END SELECT
! ! ------------------------- !
! ! Surface current !
! ! ------------------------- !
! ocean currents ! ice velocities
ssnd(jps_ocx1)%clname = 'O_OCurx1' ; ssnd(jps_ivx1)%clname = 'O_IVelx1'
ssnd(jps_ocy1)%clname = 'O_OCury1' ; ssnd(jps_ivy1)%clname = 'O_IVely1'
ssnd(jps_ocz1)%clname = 'O_OCurz1' ; ssnd(jps_ivz1)%clname = 'O_IVelz1'
ssnd(jps_ocxw)%clname = 'O_OCurxw'
ssnd(jps_ocyw)%clname = 'O_OCuryw'
!
ssnd(jps_ocx1:jps_ivz1)%nsgn = -1. ! vectors: change of the sign at the north fold
IF( sn_snd_crt%clvgrd == 'U,V' ) THEN
ssnd(jps_ocx1)%clgrid = 'U' ; ssnd(jps_ocy1)%clgrid = 'V'
ELSE IF( sn_snd_crt%clvgrd /= 'T' ) THEN
CALL ctl_stop( 'sn_snd_crt%clvgrd must be equal to T' )
ENDIF
ssnd(jps_ocx1:jps_ivz1)%laction = .TRUE. ! default: all are send
IF( TRIM( sn_snd_crt%clvref ) == 'spherical' ) ssnd( (/jps_ocz1, jps_ivz1/) )%laction = .FALSE.
IF( TRIM( sn_snd_crt%clvor ) == 'eastward-northward' ) ssnd(jps_ocx1:jps_ivz1)%nsgn = 1.
SELECT CASE( TRIM( sn_snd_crt%cldes ) )
CASE( 'none' ) ; ssnd(jps_ocx1:jps_ivz1)%laction = .FALSE.
CASE( 'oce only' ) ; ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
CASE( 'weighted oce and ice' ) ! nothing to do
CASE( 'mixed oce-ice' ) ; ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_crt%cldes' )
END SELECT
ssnd(jps_ocxw:jps_ocyw)%nsgn = -1. ! vectors: change of the sign at the north fold
IF( sn_snd_crtw%clvgrd == 'U,V' ) THEN
ssnd(jps_ocxw)%clgrid = 'U' ; ssnd(jps_ocyw)%clgrid = 'V'
ELSE IF( sn_snd_crtw%clvgrd /= 'T' ) THEN
CALL ctl_stop( 'sn_snd_crtw%clvgrd must be equal to T' )
ENDIF
IF( TRIM( sn_snd_crtw%clvor ) == 'eastward-northward' ) ssnd(jps_ocxw:jps_ocyw)%nsgn = 1.
SELECT CASE( TRIM( sn_snd_crtw%cldes ) )
CASE( 'none' ) ; ssnd(jps_ocxw:jps_ocyw)%laction = .FALSE.
CASE( 'oce only' ) ; ssnd(jps_ocxw:jps_ocyw)%laction = .TRUE.
CASE( 'weighted oce and ice' ) ! nothing to do
CASE( 'mixed oce-ice' ) ; ssnd(jps_ivx1:jps_ivz1)%laction = .FALSE.
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_crtw%cldes' )
END SELECT
! ! ------------------------- !
! ! CO2 flux !
! ! ------------------------- !
ssnd(jps_co2)%clname = 'O_CO2FLX' ; IF( TRIM(sn_snd_co2%cldes) == 'coupled' ) ssnd(jps_co2 )%laction = .TRUE.
!
#if defined key_medusa
! ! ------------------------- !
! ! MEDUSA output fields !
! ! ------------------------- !
! Surface dimethyl sulphide from Medusa
ssnd(jps_bio_dms)%clname = 'OBioDMS'
IF( TRIM(sn_snd_bio_dms%cldes) == 'medusa' ) ssnd(jps_bio_dms )%laction = .TRUE.
! Surface CO2 flux from Medusa
ssnd(jps_bio_co2)%clname = 'OBioCO2'
IF( TRIM(sn_snd_bio_co2%cldes) == 'medusa' ) ssnd(jps_bio_co2 )%laction = .TRUE.
! Surface chlorophyll from Medusa
ssnd(jps_bio_chloro)%clname = 'OBioChlo'
IF( TRIM(sn_snd_bio_chloro%cldes) == 'medusa' ) ssnd(jps_bio_chloro )%laction = .TRUE.
#endif
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
! ! ------------------------- !
! ! Sea surface freezing temp !
! ! ------------------------- !
! needed by Met Office
ssnd(jps_sstfrz)%clname = 'O_SSTFrz' ; IF( TRIM(sn_snd_sstfrz%cldes) == 'coupled' ) ssnd(jps_sstfrz)%laction = .TRUE.
!
! ! ------------------------- !
! ! Ice conductivity !
! ! ------------------------- !
! needed by Met Office
! Note that ultimately we will move to passing an ocean effective conductivity as well so there
! will be some changes to the parts of the code which currently relate only to ice conductivity
ssnd(jps_ttilyr )%clname = 'O_TtiLyr'
SELECT CASE ( TRIM( sn_snd_ttilyr%cldes ) )
CASE ( 'none' )
ssnd(jps_ttilyr)%laction = .FALSE.
CASE ( 'ice only' )
ssnd(jps_ttilyr)%laction = .TRUE.
IF( TRIM( sn_snd_ttilyr%clcat ) == 'yes' ) THEN
ssnd(jps_ttilyr)%nct = nn_cats_cpl
ELSE
IF( nn_cats_cpl > 1 ) THEN
CALL ctl_stop( 'sbc_cpl_init: use weighted ice option for sn_snd_ttilyr%cldes if not exchanging category fields' )
ENDIF
ENDIF
CASE ( 'weighted ice' )
ssnd(jps_ttilyr)%laction = .TRUE.
IF( TRIM( sn_snd_ttilyr%clcat ) == 'yes' ) ssnd(jps_ttilyr)%nct = nn_cats_cpl
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_ttilyr%cldes;'//sn_snd_ttilyr%cldes )
END SELECT
ssnd(jps_kice )%clname = 'OIceKn'
SELECT CASE ( TRIM( sn_snd_cond%cldes ) )
CASE ( 'none' )
ssnd(jps_kice)%laction = .FALSE.
CASE ( 'ice only' )
ssnd(jps_kice)%laction = .TRUE.
IF( TRIM( sn_snd_cond%clcat ) == 'yes' ) THEN
ssnd(jps_kice)%nct = nn_cats_cpl
ELSE
IF( nn_cats_cpl > 1 ) THEN
CALL ctl_stop( 'sbc_cpl_init: use weighted ice option for sn_snd_cond%cldes if not exchanging category fields' )
ENDIF
ENDIF
CASE ( 'weighted ice' )
ssnd(jps_kice)%laction = .TRUE.
IF( TRIM( sn_snd_cond%clcat ) == 'yes' ) ssnd(jps_kice)%nct = nn_cats_cpl
CASE default ; CALL ctl_stop( 'sbc_cpl_init: wrong definition of sn_snd_cond%cldes;'//sn_snd_cond%cldes )
END SELECT
!
! ! ------------------------- !
! ! Sea surface height !
! ! ------------------------- !
ssnd(jps_wlev)%clname = 'O_Wlevel' ; IF( TRIM(sn_snd_wlev%cldes) == 'coupled' ) ssnd(jps_wlev)%laction = .TRUE.
! ! ------------------------------- !
! ! OCE-SAS coupling - snd by opa !
! ! ------------------------------- !
ssnd(jps_ssh )%clname = 'O_SSHght'
ssnd(jps_soce )%clname = 'O_SSSal'
ssnd(jps_e3t1st)%clname = 'O_E3T1st'
ssnd(jps_fraqsr)%clname = 'O_FraQsr'
!
IF( nn_components == jp_iam_oce ) THEN
ssnd(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
ssnd( (/jps_toce, jps_soce, jps_ssh, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
ssnd( jps_e3t1st )%laction = .NOT.ln_linssh
! vector definition: not used but cleaner...
ssnd(jps_ocx1)%clgrid = 'U' ! oce components given at U-point
ssnd(jps_ocy1)%clgrid = 'V' ! and V-point
sn_snd_crt%clvgrd = 'U,V'
sn_snd_crt%clvor = 'local grid'
sn_snd_crt%clvref = 'spherical'
!
IF(lwp) THEN ! control print
WRITE(numout,*)
WRITE(numout,*)' sent fields to SAS component '
WRITE(numout,*)' sea surface temperature (T before, Celsius) '
WRITE(numout,*)' sea surface salinity '
WRITE(numout,*)' surface currents U,V on local grid and spherical coordinates'
WRITE(numout,*)' sea surface height '
WRITE(numout,*)' thickness of first ocean T level '
WRITE(numout,*)' fraction of solar net radiation absorbed in the first ocean level'
WRITE(numout,*)
ENDIF
ENDIF
! ! ------------------------------- !
! ! OCE-SAS coupling - snd by sas !
! ! ------------------------------- !
ssnd(jps_sflx )%clname = 'I_SFLX'
ssnd(jps_fice2 )%clname = 'IIceFrc'
ssnd(jps_qsroce)%clname = 'I_QsrOce'
ssnd(jps_qnsoce)%clname = 'I_QnsOce'
ssnd(jps_oemp )%clname = 'IOEvaMPr'
ssnd(jps_otx1 )%clname = 'I_OTaux1'
ssnd(jps_oty1 )%clname = 'I_OTauy1'
ssnd(jps_rnf )%clname = 'I_Runoff'
ssnd(jps_taum )%clname = 'I_TauMod'
!
IF( nn_components == jp_iam_sas ) THEN
IF( .NOT. ln_cpl ) ssnd(:)%laction = .FALSE. ! force default definition in case of opa <-> sas coupling
ssnd( (/jps_qsroce, jps_qnsoce, jps_oemp, jps_fice2, jps_sflx, jps_otx1, jps_oty1, jps_taum/) )%laction = .TRUE.
!
! Change first letter to couple with atmosphere if already coupled with sea_ice
! this is nedeed as each variable name used in the namcouple must be unique:
! for example O_SSTSST sent by OCE to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
DO jn = 1, jpsnd
IF( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
END DO
!
IF(lwp) THEN ! control print
WRITE(numout,*)
IF( .NOT. ln_cpl ) THEN
WRITE(numout,*)' sent fields to OCE component '
ELSE
WRITE(numout,*)' Additional sent fields to OCE component : '
ENDIF
WRITE(numout,*)' ice cover '
WRITE(numout,*)' oce only EMP '
WRITE(numout,*)' salt flux '
WRITE(numout,*)' mixed oce-ice solar flux '
WRITE(numout,*)' mixed oce-ice non solar flux '
WRITE(numout,*)' wind stress U,V components'
WRITE(numout,*)' wind stress module'
ENDIF
ENDIF
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
! Initialise 1D river outflow scheme
nn_cpl_river = 1
IF ( TRIM( sn_rcv_rnf%cldes ) == 'coupled1d' ) CALL cpl_rnf_1d_init ! Coupled runoff using 1D array
! =================================================== !
! Allocate all parts of frcv used for received fields !
! =================================================== !
DO jn = 1, jprcv
IF ( srcv(jn)%laction ) THEN
SELECT CASE( srcv(jn)%dimensions )
!
CASE( 0 ) ! Scalar field
ALLOCATE( frcv(jn)%z3(1,1,1) )
CASE( 1 ) ! 1D field
ALLOCATE( frcv(jn)%z3(nn_cpl_river,1,1) )
CASE DEFAULT ! 2D (or pseudo 3D) field.
ALLOCATE( frcv(jn)%z3(jpi,jpj,srcv(jn)%nct) )
END SELECT
END IF
END DO
! Allocate taum part of frcv which is used even when not received as coupling field
IF ( .NOT. srcv(jpr_taum)%laction ) ALLOCATE( frcv(jpr_taum)%z3(jpi,jpj,srcv(jpr_taum)%nct) )
! Allocate w10m part of frcv which is used even when not received as coupling field
IF ( .NOT. srcv(jpr_w10m)%laction ) ALLOCATE( frcv(jpr_w10m)%z3(jpi,jpj,srcv(jpr_w10m)%nct) )
! Allocate jpr_otx1 part of frcv which is used even when not received as coupling field
IF ( .NOT. srcv(jpr_otx1)%laction ) ALLOCATE( frcv(jpr_otx1)%z3(jpi,jpj,srcv(jpr_otx1)%nct) )
IF ( .NOT. srcv(jpr_oty1)%laction ) ALLOCATE( frcv(jpr_oty1)%z3(jpi,jpj,srcv(jpr_oty1)%nct) )
! Allocate itx1 and ity1 as they are used in sbc_cpl_ice_tau even if srcv(jpr_itx1)%laction = .FALSE.
IF( k_ice /= 0 ) THEN
IF ( .NOT. srcv(jpr_itx1)%laction ) ALLOCATE( frcv(jpr_itx1)%z3(jpi,jpj,srcv(jpr_itx1)%nct) )
IF ( .NOT. srcv(jpr_ity1)%laction ) ALLOCATE( frcv(jpr_ity1)%z3(jpi,jpj,srcv(jpr_ity1)%nct) )
END IF
!
! ================================ !
! initialisation of the coupler !
! ================================ !
! There's no point initialising the coupler if we've accumulated any errors in
! coupling field definitions or settings.
IF (nstop > 0) CALL ctl_stop( 'STOP', 'sbc_cpl_init: Errors encountered in coupled field definitions' )
CALL cpl_define(jprcv, jpsnd, nn_cplmodel)
IF(ln_usecplmask) THEN
xcplmask(:,:,:) = 0.
CALL iom_open( 'cplmask', inum )
CALL iom_get( inum, jpdom_unknown, 'cplmask', xcplmask(1:jpi,1:jpj,1:nn_cplmodel), &
& kstart = (/ mig(1),mjg(1),1 /), kcount = (/ jpi,jpj,nn_cplmodel /) )
CALL iom_close( inum )
ELSE
xcplmask(:,:,:) = 1.
ENDIF
xcplmask(:,:,0) = 1. - SUM( xcplmask(:,:,1:nn_cplmodel), dim = 3 )
!
IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN
! Crude masks to separate the Antarctic and Greenland icesheets. Obviously something
! more complicated could be done if required.
greenland_icesheet_mask = 0.0
WHERE( gphit >= 0.0 ) greenland_icesheet_mask = 1.0
antarctica_icesheet_mask = 0.0
WHERE( gphit < 0.0 ) antarctica_icesheet_mask = 1.0
IF( .not. ln_rstart ) THEN
greenland_icesheet_mass = 0.0
greenland_icesheet_mass_rate_of_change = 0.0
greenland_icesheet_timelapsed = 0.0
antarctica_icesheet_mass = 0.0
antarctica_icesheet_mass_rate_of_change = 0.0
antarctica_icesheet_timelapsed = 0.0
ENDIF
ENDIF
!
IF (ln_timing) CALL timing_stop('sbc_cpl_init')
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
!
END SUBROUTINE sbc_cpl_init
SUBROUTINE sbc_cpl_rcv( kt, k_fsbc, k_ice, Kbb, Kmm )
!!----------------------------------------------------------------------
!! *** ROUTINE sbc_cpl_rcv ***
!!
!! ** Purpose : provide the stress over the ocean and, if no sea-ice,
!! provide the ocean heat and freshwater fluxes.
!!
!! ** Method : - Receive all the atmospheric fields (stored in frcv array). called at each time step.
!! OASIS controls if there is something do receive or not. nrcvinfo contains the info
!! to know if the field was really received or not
!!
!! --> If ocean stress was really received:
!!
!! - transform the received ocean stress vector from the received
!! referential and grid into an atmosphere-ocean stress in
!! the (i,j) ocean referencial and at the ocean velocity point.
!! The received stress are :
!! - defined by 3 components (if cartesian coordinate)
!! or by 2 components (if spherical)
!! - oriented along geographical coordinate (if eastward-northward)
!! or along the local grid coordinate (if local grid)
!! - given at U- and V-point, resp. if received on 2 grids
!! or at T-point if received on 1 grid
!! Therefore and if necessary, they are successively
!! processed in order to obtain them
!! first as 2 components on the sphere
!! second as 2 components oriented along the local grid
!! third as 2 components on the U,V grid
!!
!! -->
!!
!! - In 'ocean only' case, non solar and solar ocean heat fluxes
!! and total ocean freshwater fluxes
!!
!! ** Method : receive all fields from the atmosphere and transform
!! them into ocean surface boundary condition fields
!!
!! ** Action : update utau, vtau ocean stress at U,V grid
!! taum wind stress module at T-point
!! wndm wind speed module at T-point over free ocean or leads in presence of sea-ice
!! qns non solar heat fluxes including emp heat content (ocean only case)
!! and the latent heat flux of solid precip. melting
!! qsr solar ocean heat fluxes (ocean only case)
!! emp upward mass flux [evap. - precip. (- runoffs) (- calving)] (ocean only case)
!!----------------------------------------------------------------------
USE zdf_oce, ONLY : ln_zdfswm
!
INTEGER, INTENT(in) :: kt ! ocean model time step index
INTEGER, INTENT(in) :: k_fsbc ! frequency of sbc (-> ice model) computation
INTEGER, INTENT(in) :: k_ice ! ice management in the sbc (=0/1/2/3)
INTEGER, INTENT(in) :: Kbb, Kmm ! ocean model time level indices
!!
LOGICAL :: llnewtx, llnewtau ! update wind stress components and module??
INTEGER :: ji, jj, jn ! dummy loop indices
INTEGER :: isec ! number of seconds since nit000 (assuming rdt did not change since nit000)
INTEGER :: ikchoix
REAL(wp), DIMENSION(jpi,jpj) :: ztx2, zty2
REAL(wp) :: zcumulneg, zcumulpos ! temporary scalars
REAL(wp) :: zcoef ! temporary scalar
LOGICAL :: ll_wrtstp ! write diagnostics?
REAL(wp) :: zrhoa = 1.22 ! Air density kg/m3
REAL(wp) :: zcdrag = 1.5e-3 ! drag coefficient
REAL(wp) :: zgreenland_icesheet_mass_in, zantarctica_icesheet_mass_in
REAL(wp) :: zgreenland_icesheet_mass_b, zantarctica_icesheet_mass_b
REAL(wp) :: zmask_sum, zepsilon

Guillaume Samson
committed
REAL(wp) :: r1_grau ! = 1.e0 / (grav * rho0)
REAL(wp), DIMENSION(jpi,jpj) :: ztx, zty, zmsk, zemp, zqns, zqsr, zcloud_fra
!!----------------------------------------------------------------------
!
!
IF (ln_timing) CALL timing_start('sbc_cpl_rcv')
!
ll_wrtstp = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
!
IF( kt == nit000 ) THEN
! cannot be done in the init phase when we use agrif as cpl_freq requires that oasis_enddef is done
ncpl_qsr_freq = cpl_freq( 'O_QsrOce' ) + cpl_freq( 'O_QsrMix' ) + cpl_freq( 'I_QsrOce' ) + cpl_freq( 'I_QsrMix' )
IF( ln_dm2dc .AND. ncpl_qsr_freq /= 86400 ) &
& CALL ctl_stop( 'sbc_cpl_rcv: diurnal cycle reconstruction (ln_dm2dc) needs daily couping for solar radiation' )
IF ( ln_wave .AND. nn_components == 0 ) THEN
ncpl_qsr_freq = 1;
WRITE(numout,*) 'ncpl_qsr_freq is set to 1 when coupling NEMO with wave (without SAS) '
ENDIF
ENDIF
!
IF( ln_mixcpl ) zmsk(:,:) = 1. - xcplmask(:,:,0)
!
! ! ======================================================= !
! ! Receive all the atmos. fields (including ice information)
! ! ======================================================= !
isec = ( kt - nit000 ) * NINT( rn_Dt ) ! date of exchanges
DO jn = 1, jprcv ! received fields sent by the atmosphere
IF( srcv(jn)%laction ) THEN
IF ( srcv(jn)%dimensions <= 1 ) THEN
CALL cpl_rcv_1d( jn, isec, frcv(jn)%z3, SIZE(frcv(jn)%z3), nrcvinfo(jn) )
ELSE
CALL cpl_rcv( jn, isec, frcv(jn)%z3, xcplmask(:,:,1:nn_cplmodel), nrcvinfo(jn) )
END IF
END IF
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
END DO
! ! ========================= !
IF( srcv(jpr_otx1)%laction ) THEN ! ocean stress components !
! ! ========================= !
! define frcv(jpr_otx1)%z3(:,:,1) and frcv(jpr_oty1)%z3(:,:,1): stress at U/V point along model grid
! => need to be done only when we receive the field
IF( nrcvinfo(jpr_otx1) == OASIS_Rcv ) THEN
!
IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN ! 2 components on the sphere
! ! (cartesian to spherical -> 3 to 2 components)
!
CALL geo2oce( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), frcv(jpr_otz1)%z3(:,:,1), &
& srcv(jpr_otx1)%clgrid, ztx, zty )
frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 1st grid
frcv(jpr_oty1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 1st grid
!
IF( srcv(jpr_otx2)%laction ) THEN
CALL geo2oce( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), frcv(jpr_otz2)%z3(:,:,1), &
& srcv(jpr_otx2)%clgrid, ztx, zty )
frcv(jpr_otx2)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 2nd grid
frcv(jpr_oty2)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 2nd grid
ENDIF
!
ENDIF
!
IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN ! 2 components oriented along the local grid
! ! (geographical to local grid -> rotate the components)
IF( srcv(jpr_otx1)%clgrid == 'U' .AND. (.NOT. srcv(jpr_otx2)%laction) ) THEN
! Temporary code for HadGEM3 - will be removed eventually.
! Only applies when we have only taux on U grid and tauy on V grid
!RSRH these MUST be initialised because the halos are not explicitly set
! but they're passed to repcmo and used directly in calculations, so if
! they point at junk in memory then bad things will happen!
! (You can prove this by running with preset NaNs).
ztx(:,:)=0.0
zty(:,:)=0.0
DO_2D( 0, 0, 0, 0 )
ztx(ji,jj)=0.25*vmask(ji,jj,1) &
*(frcv(jpr_otx1)%z3(ji,jj,1)+frcv(jpr_otx1)%z3(ji-1,jj,1) &
+frcv(jpr_otx1)%z3(ji,jj+1,1)+frcv(jpr_otx1)%z3(ji-1,jj+1,1))
zty(ji,jj)=0.25*umask(ji,jj,1) &
*(frcv(jpr_oty1)%z3(ji,jj,1)+frcv(jpr_oty1)%z3(ji+1,jj,1) &
+frcv(jpr_oty1)%z3(ji,jj-1,1)+frcv(jpr_oty1)%z3(ji+1,jj-1,1))
END_2D
ikchoix = 1
CALL repcmo (frcv(jpr_otx1)%z3(:,:,1),zty,ztx,frcv(jpr_oty1)%z3(:,:,1),ztx2,zty2,ikchoix)
CALL lbc_lnk ('jpr_otx1', ztx2,'U', -1. )
CALL lbc_lnk ('jpr_oty1', zty2,'V', -1. )
frcv(jpr_otx1)%z3(:,:,1)=ztx2(:,:)
frcv(jpr_oty1)%z3(:,:,1)=zty2(:,:)
CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->i', ztx )
frcv(jpr_otx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st component on the 1st grid
IF( srcv(jpr_otx2)%laction ) THEN
CALL rot_rep( frcv(jpr_otx2)%z3(:,:,1), frcv(jpr_oty2)%z3(:,:,1), srcv(jpr_otx2)%clgrid, 'en->j', zty )
ELSE
CALL rot_rep( frcv(jpr_otx1)%z3(:,:,1), frcv(jpr_oty1)%z3(:,:,1), srcv(jpr_otx1)%clgrid, 'en->j', zty )
ENDIF
frcv(jpr_oty1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd component on the 2nd grid
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
ENDIF
ENDIF
!
IF( srcv(jpr_otx1)%clgrid == 'T' ) THEN
DO_2D( 0, 0, 0, 0 ) ! T ==> (U,V)
frcv(jpr_otx1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_otx1)%z3(ji+1,jj ,1) + frcv(jpr_otx1)%z3(ji,jj,1) )
frcv(jpr_oty1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_oty1)%z3(ji ,jj+1,1) + frcv(jpr_oty1)%z3(ji,jj,1) )
END_2D
CALL lbc_lnk( 'sbccpl', frcv(jpr_otx1)%z3(:,:,1), 'U', -1.0_wp, frcv(jpr_oty1)%z3(:,:,1), 'V', -1.0_wp )
ENDIF
llnewtx = .TRUE.
ELSE
llnewtx = .FALSE.
ENDIF
! ! ========================= !
ELSE ! No dynamical coupling !
! ! ========================= !
frcv(jpr_otx1)%z3(:,:,1) = 0.e0 ! here simply set to zero
frcv(jpr_oty1)%z3(:,:,1) = 0.e0 ! an external read in a file can be added instead
llnewtx = .TRUE.
!
ENDIF
! ! ========================= !
! ! wind stress module ! (taum)
! ! ========================= !
IF( .NOT. srcv(jpr_taum)%laction ) THEN ! compute wind stress module from its components if not received
! => need to be done only when otx1 was changed
IF( llnewtx ) THEN
DO_2D( 0, 0, 0, 0 )
zzx = frcv(jpr_otx1)%z3(ji-1,jj ,1) + frcv(jpr_otx1)%z3(ji,jj,1)
zzy = frcv(jpr_oty1)%z3(ji ,jj-1,1) + frcv(jpr_oty1)%z3(ji,jj,1)
frcv(jpr_taum)%z3(ji,jj,1) = 0.5 * SQRT( zzx * zzx + zzy * zzy )
END_2D
CALL lbc_lnk( 'sbccpl', frcv(jpr_taum)%z3(:,:,1), 'T', 1.0_wp )
llnewtau = .TRUE.
ELSE
llnewtau = .FALSE.
ENDIF
ELSE
llnewtau = nrcvinfo(jpr_taum) == OASIS_Rcv
! Stress module can be negative when received (interpolation problem)
IF( llnewtau ) THEN
frcv(jpr_taum)%z3(:,:,1) = MAX( 0._wp, frcv(jpr_taum)%z3(:,:,1) )
ENDIF
ENDIF
!
! ! ========================= !
! ! 10 m wind speed ! (wndm)
! ! ========================= !
IF( .NOT. srcv(jpr_w10m)%laction ) THEN ! compute wind spreed from wind stress module if not received
! => need to be done only when taumod was changed
IF( llnewtau ) THEN
zcoef = 1. / ( zrhoa * zcdrag )
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef )
END_2D
ENDIF
ENDIF
!!$ ! ! ========================= !
!!$ SELECT CASE( TRIM( sn_rcv_clouds%cldes ) ) ! cloud fraction !
!!$ ! ! ========================= !
!!$ cloud_fra(:,:) = frcv(jpr_clfra)*z3(:,:,1)
!!$ END SELECT
!!$
zcloud_fra(:,:) = pp_cldf ! should be real cloud fraction instead (as in the bulk) but needs to be read from atm.
IF( ln_mixcpl ) THEN
cloud_fra(:,:) = cloud_fra(:,:) * xcplmask(:,:,0) + zcloud_fra(:,:)* zmsk(:,:)
ELSE
cloud_fra(:,:) = zcloud_fra(:,:)
ENDIF
! ! ========================= !
! u(v)tau and taum will be modified by ice model
! -> need to be reset before each call of the ice/fsbc
IF( MOD( kt-1, k_fsbc ) == 0 ) THEN
!
IF( ln_mixcpl ) THEN
utau(:,:) = utau(:,:) * xcplmask(:,:,0) + frcv(jpr_otx1)%z3(:,:,1) * zmsk(:,:)
vtau(:,:) = vtau(:,:) * xcplmask(:,:,0) + frcv(jpr_oty1)%z3(:,:,1) * zmsk(:,:)
taum(:,:) = taum(:,:) * xcplmask(:,:,0) + frcv(jpr_taum)%z3(:,:,1) * zmsk(:,:)
wndm(:,:) = wndm(:,:) * xcplmask(:,:,0) + frcv(jpr_w10m)%z3(:,:,1) * zmsk(:,:)
ELSE
utau(:,:) = frcv(jpr_otx1)%z3(:,:,1)
vtau(:,:) = frcv(jpr_oty1)%z3(:,:,1)
taum(:,:) = frcv(jpr_taum)%z3(:,:,1)
wndm(:,:) = frcv(jpr_w10m)%z3(:,:,1)
ENDIF
CALL iom_put( "taum_oce", taum ) ! output wind stress module
!
ENDIF
#if defined key_medusa
IF (ln_medusa) THEN
IF( srcv(jpr_atm_pco2)%laction) PCO2a_in_cpl(:,:) = frcv(jpr_atm_pco2)%z3(:,:,1)
IF( srcv(jpr_atm_dust)%laction) Dust_in_cpl(:,:) = frcv(jpr_atm_dust)%z3(:,:,1)
ENDIF
#endif
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
! ! ================== !
! ! atmosph. CO2 (ppm) !
! ! ================== !
IF( srcv(jpr_co2)%laction ) atm_co2(:,:) = frcv(jpr_co2)%z3(:,:,1)
!
! ! ========================= !
! ! Mean Sea Level Pressure ! (taum)
! ! ========================= !
IF( srcv(jpr_mslp)%laction ) THEN ! UKMO SHELF effect of atmospheric pressure on SSH
IF( kt /= nit000 ) ssh_ibb(:,:) = ssh_ib(:,:) !* Swap of ssh_ib fields
r1_grau = 1.e0 / (grav * rho0) !* constant for optimization
ssh_ib(:,:) = - ( frcv(jpr_mslp)%z3(:,:,1) - rpref ) * r1_grau ! equivalent ssh (inverse barometer)
apr (:,:) = frcv(jpr_mslp)%z3(:,:,1) !atmospheric pressure
IF( kt == nit000 ) ssh_ibb(:,:) = ssh_ib(:,:) ! correct this later (read from restart if possible)
ENDIF
!
IF( ln_sdw ) THEN ! Stokes Drift correction activated
! ! ========================= !
! ! Stokes drift u !
! ! ========================= !
IF( srcv(jpr_sdrftx)%laction ) ut0sd(:,:) = frcv(jpr_sdrftx)%z3(:,:,1)
!
! ! ========================= !
! ! Stokes drift v !
! ! ========================= !
IF( srcv(jpr_sdrfty)%laction ) vt0sd(:,:) = frcv(jpr_sdrfty)%z3(:,:,1)
!
! ! ========================= !
! ! Wave mean period !
! ! ========================= !
IF( srcv(jpr_wper)%laction ) wmp(:,:) = frcv(jpr_wper)%z3(:,:,1)
!
! ! ========================= !
! ! Significant wave height !
! ! ========================= !
IF( srcv(jpr_hsig)%laction ) hsw(:,:) = frcv(jpr_hsig)%z3(:,:,1)
!
! ! ========================= !
! ! Vertical mixing Qiao !
! ! ========================= !
IF( srcv(jpr_wnum)%laction .AND. ln_zdfswm ) wnum(:,:) = frcv(jpr_wnum)%z3(:,:,1)
! Calculate the 3D Stokes drift both in coupled and not fully uncoupled mode
IF( srcv(jpr_sdrftx)%laction .OR. srcv(jpr_sdrfty)%laction .OR. &
srcv(jpr_wper)%laction .OR. srcv(jpr_hsig)%laction ) THEN
CALL sbc_stokes( Kmm )
ENDIF
ENDIF
! ! ========================= !
! ! Stress adsorbed by waves !
! ! ========================= !
IF( srcv(jpr_wstrf)%laction .AND. ln_tauoc ) tauoc_wave(:,:) = frcv(jpr_wstrf)%z3(:,:,1)
!
! ! ========================= !
! ! Wave drag coefficient !
! ! ========================= !
IF( srcv(jpr_wdrag)%laction .AND. ln_cdgw ) cdn_wave(:,:) = frcv(jpr_wdrag)%z3(:,:,1)
!
! ! ========================= !
! ! Chranock coefficient !
! ! ========================= !
IF( srcv(jpr_charn)%laction .AND. ln_charn ) charn(:,:) = frcv(jpr_charn)%z3(:,:,1)
!
! ! ========================= !
! ! net wave-supported stress !
! ! ========================= !
IF( srcv(jpr_tawx)%laction .AND. ln_taw ) tawx(:,:) = frcv(jpr_tawx)%z3(:,:,1)
IF( srcv(jpr_tawy)%laction .AND. ln_taw ) tawy(:,:) = frcv(jpr_tawy)%z3(:,:,1)
!
! ! ========================= !
! !wave to ocean momentum flux!
! ! ========================= !
IF( srcv(jpr_twox)%laction .AND. ln_taw ) twox(:,:) = frcv(jpr_twox)%z3(:,:,1)
IF( srcv(jpr_twoy)%laction .AND. ln_taw ) twoy(:,:) = frcv(jpr_twoy)%z3(:,:,1)
!
! ! ========================= !
! ! wave TKE flux at sfc !
! ! ========================= !
IF( srcv(jpr_phioc)%laction .AND. ln_phioc ) phioc(:,:) = frcv(jpr_phioc)%z3(:,:,1)
!
! ! ========================= !
! ! Bernoulli head !
! ! ========================= !
IF( srcv(jpr_bhd)%laction .AND. ln_bern_srfc ) bhd_wave(:,:) = frcv(jpr_bhd)%z3(:,:,1)
!
! ! ========================= !
! ! Stokes transport u dir !
! ! ========================= !
IF( srcv(jpr_tusd)%laction .AND. ln_breivikFV_2016 ) tusd(:,:) = frcv(jpr_tusd)%z3(:,:,1)
!
! ! ========================= !
! ! Stokes transport v dir !
! ! ========================= !
IF( srcv(jpr_tvsd)%laction .AND. ln_breivikFV_2016 ) tvsd(:,:) = frcv(jpr_tvsd)%z3(:,:,1)
!
! Fields received by SAS when OASIS coupling
! (arrays no more filled at sbcssm stage)
! ! ================== !
! ! SSS !
! ! ================== !
IF( srcv(jpr_soce)%laction ) THEN ! received by sas in case of opa <-> sas coupling
sss_m(:,:) = frcv(jpr_soce)%z3(:,:,1)
CALL iom_put( 'sss_m', sss_m )
ENDIF
!
! ! ================== !
! ! SST !
! ! ================== !
IF( srcv(jpr_toce)%laction ) THEN ! received by sas in case of opa <-> sas coupling
sst_m(:,:) = frcv(jpr_toce)%z3(:,:,1)
IF( srcv(jpr_soce)%laction .AND. l_useCT ) THEN ! make sure that sst_m is the potential temperature
sst_m(:,:) = eos_pt_from_ct( sst_m(:,:), sss_m(:,:) )
ENDIF
ENDIF
! ! ================== !
! ! SSH !
! ! ================== !
IF( srcv(jpr_ssh )%laction ) THEN ! received by sas in case of opa <-> sas coupling
ssh_m(:,:) = frcv(jpr_ssh )%z3(:,:,1)
CALL iom_put( 'ssh_m', ssh_m )
ENDIF
! ! ================== !
! ! surface currents !
! ! ================== !
IF( srcv(jpr_ocx1)%laction ) THEN ! received by sas in case of opa <-> sas coupling
ssu_m(:,:) = frcv(jpr_ocx1)%z3(:,:,1)
uu(:,:,1,Kbb) = ssu_m(:,:) ! will be used in icestp in the call of ice_forcing_tau
uu(:,:,1,Kmm) = ssu_m(:,:) ! will be used in sbc_cpl_snd if atmosphere coupling
CALL iom_put( 'ssu_m', ssu_m )
ENDIF
IF( srcv(jpr_ocy1)%laction ) THEN
ssv_m(:,:) = frcv(jpr_ocy1)%z3(:,:,1)
vv(:,:,1,Kbb) = ssv_m(:,:) ! will be used in icestp in the call of ice_forcing_tau
vv(:,:,1,Kmm) = ssv_m(:,:) ! will be used in sbc_cpl_snd if atmosphere coupling
CALL iom_put( 'ssv_m', ssv_m )
ENDIF
! ! ======================== !
! ! first T level thickness !
! ! ======================== !
IF( srcv(jpr_e3t1st )%laction ) THEN ! received by sas in case of opa <-> sas coupling
e3t_m(:,:) = frcv(jpr_e3t1st )%z3(:,:,1)
CALL iom_put( 'e3t_m', e3t_m(:,:) )
ENDIF
! ! ================================ !
! ! fraction of solar net radiation !
! ! ================================ !
IF( srcv(jpr_fraqsr)%laction ) THEN ! received by sas in case of opa <-> sas coupling
frq_m(:,:) = frcv(jpr_fraqsr)%z3(:,:,1)
CALL iom_put( 'frq_m', frq_m )
ENDIF
! ! ========================= !
IF( k_ice <= 1 .AND. MOD( kt-1, k_fsbc ) == 0 ) THEN ! heat & freshwater fluxes ! (Ocean only case)
! ! ========================= !
!
! ! total freshwater fluxes over the ocean (emp)
IF( srcv(jpr_oemp)%laction .OR. srcv(jpr_rain)%laction ) THEN
SELECT CASE( TRIM( sn_rcv_emp%cldes ) ) ! evaporation - precipitation
CASE( 'conservative' )
zemp(:,:) = frcv(jpr_tevp)%z3(:,:,1) - ( frcv(jpr_rain)%z3(:,:,1) + frcv(jpr_snow)%z3(:,:,1) )
CASE( 'oce only', 'oce and ice' )
zemp(:,:) = frcv(jpr_oemp)%z3(:,:,1)
CASE default
CALL ctl_stop( 'sbc_cpl_rcv: wrong definition of sn_rcv_emp%cldes' )
END SELECT
ELSE
zemp(:,:) = 0._wp
ENDIF
!
! ! runoffs and calving (added in emp)
IF( srcv(jpr_rnf)%laction ) rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
IF( srcv(jpr_cal)%laction ) zemp(:,:) = zemp(:,:) - frcv(jpr_cal)%z3(:,:,1)
IF( srcv(jpr_icb)%laction ) THEN
fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
rnf(:,:) = rnf(:,:) + fwficb(:,:) ! iceberg added to runfofs
ENDIF
!
! ice shelf fwf
IF( srcv(jpr_isf)%laction ) THEN
fwfisf_oasis(:,:) = frcv(jpr_isf)%z3(:,:,1) ! fresh water flux from the isf to the ocean ( > 0 = melting )
END IF
IF( ln_mixcpl ) THEN ; emp(:,:) = emp(:,:) * xcplmask(:,:,0) + zemp(:,:) * zmsk(:,:)
ELSE ; emp(:,:) = zemp(:,:)
ENDIF
!
! ! non solar heat flux over the ocean (qns)
IF( srcv(jpr_qnsoce)%laction ) THEN ; zqns(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
ELSE IF( srcv(jpr_qnsmix)%laction ) THEN ; zqns(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
ELSE ; zqns(:,:) = 0._wp
ENDIF
! update qns over the free ocean with:
IF( nn_components /= jp_iam_oce ) THEN
zqns(:,:) = zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp ! remove heat content due to mass flux (assumed to be at SST)
IF( srcv(jpr_snow )%laction ) THEN
zqns(:,:) = zqns(:,:) - frcv(jpr_snow)%z3(:,:,1) * rLfus ! energy for melting solid precipitation over the free ocean
ENDIF
ENDIF
!
IF( srcv(jpr_icb)%laction ) zqns(:,:) = zqns(:,:) - frcv(jpr_icb)%z3(:,:,1) * rLfus ! remove heat content associated to iceberg melting
!
IF( ln_mixcpl ) THEN
qns(:,:) = qns(:,:) * xcplmask(:,:,0) + zqns(:,:) * zmsk(:,:)
ELSE
qns(:,:) = zqns(:,:)
ENDIF
! ! solar flux over the ocean (qsr)
IF ( srcv(jpr_qsroce)%laction ) THEN ; zqsr(:,:) = frcv(jpr_qsroce)%z3(:,:,1)
ELSE IF( srcv(jpr_qsrmix)%laction ) then ; zqsr(:,:) = frcv(jpr_qsrmix)%z3(:,:,1)
ELSE ; zqsr(:,:) = 0._wp
ENDIF
IF( ln_dm2dc .AND. ln_cpl ) zqsr(:,:) = sbc_dcy( zqsr ) ! modify qsr to include the diurnal cycle
IF( ln_mixcpl ) THEN ; qsr(:,:) = qsr(:,:) * xcplmask(:,:,0) + zqsr(:,:) * zmsk(:,:)
ELSE ; qsr(:,:) = zqsr(:,:)
ENDIF
!
! salt flux over the ocean (received by opa in case of opa <-> sas coupling)
IF( srcv(jpr_sflx )%laction ) sfx(:,:) = frcv(jpr_sflx )%z3(:,:,1)
! Ice cover (received by opa in case of opa <-> sas coupling)
IF( srcv(jpr_fice )%laction ) fr_i(:,:) = frcv(jpr_fice )%z3(:,:,1)
!
ENDIF
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
zepsilon = rn_iceshelf_fluxes_tolerance
IF( srcv(jpr_grnm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN
! This is a zero dimensional, single value field.
zgreenland_icesheet_mass_in = frcv(jpr_grnm)%z3(1,1,1)
greenland_icesheet_timelapsed = greenland_icesheet_timelapsed + rdt
IF( ln_iceshelf_init_atmos .AND. kt == 1 ) THEN
! On the first timestep (of an NRUN) force the ocean to ignore the icesheet masses in the ocean restart
! and take them from the atmosphere to avoid problems with using inconsistent ocean and atmosphere restarts.
zgreenland_icesheet_mass_b = zgreenland_icesheet_mass_in
greenland_icesheet_mass = zgreenland_icesheet_mass_in
ENDIF
IF( ABS( zgreenland_icesheet_mass_in - greenland_icesheet_mass ) > zepsilon ) THEN
zgreenland_icesheet_mass_b = greenland_icesheet_mass
! Only update the mass if it has increased.
IF ( (zgreenland_icesheet_mass_in - greenland_icesheet_mass) > 0.0 ) THEN
greenland_icesheet_mass = zgreenland_icesheet_mass_in
ENDIF
IF( zgreenland_icesheet_mass_b /= 0.0 ) &
& greenland_icesheet_mass_rate_of_change = ( greenland_icesheet_mass - zgreenland_icesheet_mass_b ) / greenland_icesheet_timelapsed
greenland_icesheet_timelapsed = 0.0_wp
ENDIF
IF(lwp .AND. ll_wrtstp) THEN
WRITE(numout,*) 'Greenland icesheet mass (kg) read in is ', zgreenland_icesheet_mass_in
WRITE(numout,*) 'Greenland icesheet mass (kg) used is ', greenland_icesheet_mass
WRITE(numout,*) 'Greenland icesheet mass rate of change (kg/s) is ', greenland_icesheet_mass_rate_of_change
WRITE(numout,*) 'Greenland icesheet seconds lapsed since last change is ', greenland_icesheet_timelapsed
ENDIF
ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN
greenland_icesheet_mass_rate_of_change = rn_greenland_total_fw_flux
ENDIF
! ! land ice masses : Antarctica
IF( srcv(jpr_antm)%laction .AND. nn_coupled_iceshelf_fluxes == 1 ) THEN
! This is a zero dimensional, single value field.
zantarctica_icesheet_mass_in = frcv(jpr_antm)%z3(1,1,1)
antarctica_icesheet_timelapsed = antarctica_icesheet_timelapsed + rdt
IF( ln_iceshelf_init_atmos .AND. kt == 1 ) THEN
! On the first timestep (of an NRUN) force the ocean to ignore the icesheet masses in the ocean restart
! and take them from the atmosphere to avoid problems with using inconsistent ocean and atmosphere restarts.
zantarctica_icesheet_mass_b = zantarctica_icesheet_mass_in
antarctica_icesheet_mass = zantarctica_icesheet_mass_in
ENDIF
IF( ABS( zantarctica_icesheet_mass_in - antarctica_icesheet_mass ) > zepsilon ) THEN
zantarctica_icesheet_mass_b = antarctica_icesheet_mass
! Only update the mass if it has increased.
IF ( (zantarctica_icesheet_mass_in - antarctica_icesheet_mass) > 0.0 ) THEN
antarctica_icesheet_mass = zantarctica_icesheet_mass_in
END IF
IF( zantarctica_icesheet_mass_b /= 0.0 ) &
& antarctica_icesheet_mass_rate_of_change = ( antarctica_icesheet_mass - zantarctica_icesheet_mass_b ) / antarctica_icesheet_timelapsed
antarctica_icesheet_timelapsed = 0.0_wp
ENDIF
IF(lwp .AND. ll_wrtstp) THEN
WRITE(numout,*) 'Antarctica icesheet mass (kg) read in is ', zantarctica_icesheet_mass_in
WRITE(numout,*) 'Antarctica icesheet mass (kg) used is ', antarctica_icesheet_mass
WRITE(numout,*) 'Antarctica icesheet mass rate of change (kg/s) is ', antarctica_icesheet_mass_rate_of_change
WRITE(numout,*) 'Antarctica icesheet seconds lapsed since last change is ', antarctica_icesheet_timelapsed
ENDIF
ELSE IF ( nn_coupled_iceshelf_fluxes == 2 ) THEN
antarctica_icesheet_mass_rate_of_change = rn_antarctica_total_fw_flux
ENDIF
IF (ln_timing) CALL timing_stop('sbc_cpl_rcv')
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
END SUBROUTINE sbc_cpl_rcv
SUBROUTINE sbc_cpl_ice_tau( p_taui, p_tauj )
!!----------------------------------------------------------------------
!! *** ROUTINE sbc_cpl_ice_tau ***
!!
!! ** Purpose : provide the stress over sea-ice in coupled mode
!!
!! ** Method : transform the received stress from the atmosphere into
!! an atmosphere-ice stress in the (i,j) ocean referencial
!! and at the velocity point of the sea-ice model:
!! 'C'-grid : i- (j-) components given at U- (V-) point
!!
!! The received stress are :
!! - defined by 3 components (if cartesian coordinate)
!! or by 2 components (if spherical)
!! - oriented along geographical coordinate (if eastward-northward)
!! or along the local grid coordinate (if local grid)
!! - given at U- and V-point, resp. if received on 2 grids
!! or at a same point (T or I) if received on 1 grid
!! Therefore and if necessary, they are successively
!! processed in order to obtain them
!! first as 2 components on the sphere
!! second as 2 components oriented along the local grid
!! third as 2 components on the ice grid point
!!
!! Except in 'oce and ice' case, only one vector stress field
!! is received. It has already been processed in sbc_cpl_rcv
!! so that it is now defined as (i,j) components given at U-
!! and V-points, respectively.
!!
!! ** Action : return ptau_i, ptau_j, the stress over the ice
!!----------------------------------------------------------------------
REAL(wp), INTENT(inout), DIMENSION(:,:) :: p_taui ! i- & j-components of atmos-ice stress [N/m2]
REAL(wp), INTENT(inout), DIMENSION(:,:) :: p_tauj ! at I-point (B-grid) or U & V-point (C-grid)
!!
INTEGER :: ji, jj ! dummy loop indices
INTEGER :: itx ! index of taux over ice
REAL(wp) :: zztmp1, zztmp2
REAL(wp), DIMENSION(jpi,jpj) :: ztx, zty
!!----------------------------------------------------------------------
!
#if defined key_si3 || defined key_cice
!
IF( srcv(jpr_itx1)%laction ) THEN ; itx = jpr_itx1
ELSE ; itx = jpr_otx1
ENDIF
! do something only if we just received the stress from atmosphere
IF( nrcvinfo(itx) == OASIS_Rcv ) THEN
! ! ======================= !
IF( srcv(jpr_itx1)%laction ) THEN ! ice stress received !
! ! ======================= !
!
IF( TRIM( sn_rcv_tau%clvref ) == 'cartesian' ) THEN ! 2 components on the sphere
! ! (cartesian to spherical -> 3 to 2 components)
CALL geo2oce( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), frcv(jpr_itz1)%z3(:,:,1), &
& srcv(jpr_itx1)%clgrid, ztx, zty )
frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 1st grid
frcv(jpr_ity1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 1st grid
!
IF( srcv(jpr_itx2)%laction ) THEN
CALL geo2oce( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), frcv(jpr_itz2)%z3(:,:,1), &
& srcv(jpr_itx2)%clgrid, ztx, zty )
frcv(jpr_itx2)%z3(:,:,1) = ztx(:,:) ! overwrite 1st comp. on the 2nd grid
frcv(jpr_ity2)%z3(:,:,1) = zty(:,:) ! overwrite 2nd comp. on the 2nd grid
ENDIF
!
ENDIF
!
IF( TRIM( sn_rcv_tau%clvor ) == 'eastward-northward' ) THEN ! 2 components oriented along the local grid
! ! (geographical to local grid -> rotate the components)
CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->i', ztx )
IF( srcv(jpr_itx2)%laction ) THEN
CALL rot_rep( frcv(jpr_itx2)%z3(:,:,1), frcv(jpr_ity2)%z3(:,:,1), srcv(jpr_itx2)%clgrid, 'en->j', zty )
ELSE
CALL rot_rep( frcv(jpr_itx1)%z3(:,:,1), frcv(jpr_ity1)%z3(:,:,1), srcv(jpr_itx1)%clgrid, 'en->j', zty )
ENDIF
frcv(jpr_itx1)%z3(:,:,1) = ztx(:,:) ! overwrite 1st component on the 1st grid
frcv(jpr_ity1)%z3(:,:,1) = zty(:,:) ! overwrite 2nd component on the 1st grid
ENDIF
! ! ======================= !
ELSE ! use ocean stress !
! ! ======================= !
frcv(jpr_itx1)%z3(:,:,1) = frcv(jpr_otx1)%z3(:,:,1)
frcv(jpr_ity1)%z3(:,:,1) = frcv(jpr_oty1)%z3(:,:,1)
!
ENDIF
! ! ======================= !
! ! put on ice grid !
! ! ======================= !
!
! j+1 j -----V---F
! ice stress on ice velocity point ! |
! (C-grid ==>(U,V)) j | T U
! | |
! j j-1 -I-------|
! (for I) | |
! i-1 i i
! i i+1 (for I)
SELECT CASE ( srcv(jpr_itx1)%clgrid )
CASE( 'U' )
p_taui(:,:) = frcv(jpr_itx1)%z3(:,:,1) ! (U,V) ==> (U,V)
p_tauj(:,:) = frcv(jpr_ity1)%z3(:,:,1)
CASE( 'T' )
DO_2D( 0, 0, 0, 0 ) ! T ==> (U,V)
! take care of the land-sea mask to avoid "pollution" of coastal stress. p[uv]taui used in frazil and rheology
zztmp1 = 0.5_wp * ( 2. - umask(ji,jj,1) ) * MAX( tmask(ji,jj,1),tmask(ji+1,jj ,1) )
zztmp2 = 0.5_wp * ( 2. - vmask(ji,jj,1) ) * MAX( tmask(ji,jj,1),tmask(ji ,jj+1,1) )
p_taui(ji,jj) = zztmp1 * ( frcv(jpr_itx1)%z3(ji+1,jj ,1) + frcv(jpr_itx1)%z3(ji,jj,1) )
p_tauj(ji,jj) = zztmp2 * ( frcv(jpr_ity1)%z3(ji ,jj+1,1) + frcv(jpr_ity1)%z3(ji,jj,1) )
END_2D
CALL lbc_lnk( 'sbccpl', p_taui, 'U', -1._wp, p_tauj, 'V', -1._wp )