[782] | 1 | ! |
---|
| 2 | MODULE cpl_mod |
---|
| 3 | ! |
---|
| 4 | ! This module excahanges and transforms all fields that should be recieved or sent to |
---|
| 5 | ! coupler. The transformation of the fields are done from the grid 1D-array in phylmd |
---|
| 6 | ! to the regular 2D grid accepted by the coupler. Cumulation of the fields for each |
---|
| 7 | ! timestep is done in here. |
---|
| 8 | ! |
---|
| 9 | ! Each type of surface that recevie fields from the coupler have a subroutine named |
---|
| 10 | ! cpl_receive_XXX_fields and each surface that have fields to be sent to the coupler |
---|
| 11 | ! have a subroutine named cpl_send_XXX_fields. |
---|
| 12 | ! |
---|
| 13 | !************************************************************************************* |
---|
| 14 | |
---|
| 15 | ! Use statements |
---|
| 16 | !************************************************************************************* |
---|
[836] | 17 | USE dimphy, ONLY : klon |
---|
[782] | 18 | USE mod_phys_lmdz_para |
---|
| 19 | USE ioipsl |
---|
| 20 | USE iophy |
---|
| 21 | |
---|
| 22 | ! The module oasis is always used. Without the cpp key CPP_COUPLE only the parameters |
---|
| 23 | ! in the module are compiled and not the subroutines. |
---|
| 24 | USE oasis |
---|
| 25 | USE write_field_phy |
---|
[2344] | 26 | USE time_phylmdz_mod, ONLY: day_step_phy |
---|
[782] | 27 | |
---|
| 28 | ! Global attributes |
---|
| 29 | !************************************************************************************* |
---|
| 30 | IMPLICIT NONE |
---|
| 31 | PRIVATE |
---|
| 32 | |
---|
[996] | 33 | ! All subroutine are public except cpl_send_all |
---|
| 34 | PUBLIC :: cpl_init, cpl_receive_frac, cpl_receive_ocean_fields, cpl_receive_seaice_fields, & |
---|
[782] | 35 | cpl_send_ocean_fields, cpl_send_seaice_fields, cpl_send_land_fields, & |
---|
| 36 | cpl_send_landice_fields, gath2cpl |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | ! Declaration of module variables |
---|
| 40 | !************************************************************************************* |
---|
| 41 | ! variable for coupling period |
---|
[1279] | 42 | INTEGER, SAVE :: nexca |
---|
[782] | 43 | !$OMP THREADPRIVATE(nexca) |
---|
| 44 | |
---|
| 45 | ! variables for cumulating fields during a coupling periode : |
---|
| 46 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_sols, cpl_nsol, cpl_rain |
---|
| 47 | !$OMP THREADPRIVATE(cpl_sols,cpl_nsol,cpl_rain) |
---|
| 48 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_snow, cpl_evap, cpl_tsol |
---|
| 49 | !$OMP THREADPRIVATE(cpl_snow,cpl_evap,cpl_tsol) |
---|
[1279] | 50 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_fder, cpl_albe, cpl_taux, cpl_tauy |
---|
| 51 | !$OMP THREADPRIVATE(cpl_fder,cpl_albe,cpl_taux,cpl_tauy) |
---|
[782] | 52 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_windsp |
---|
| 53 | !$OMP THREADPRIVATE(cpl_windsp) |
---|
[2872] | 54 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_sens_rain, cpl_sens_snow |
---|
| 55 | !$OMP THREADPRIVATE(cpl_sens_rain, cpl_sens_snow) |
---|
[1279] | 56 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_taumod |
---|
| 57 | !$OMP THREADPRIVATE(cpl_taumod) |
---|
| 58 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_atm_co2 |
---|
| 59 | !$OMP THREADPRIVATE(cpl_atm_co2) |
---|
[782] | 60 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_rriv2D, cpl_rcoa2D, cpl_rlic2D |
---|
| 61 | !$OMP THREADPRIVATE(cpl_rriv2D,cpl_rcoa2D,cpl_rlic2D) |
---|
| 62 | |
---|
| 63 | ! variables read from coupler : |
---|
| 64 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_sst ! sea surface temperature |
---|
| 65 | !$OMP THREADPRIVATE(read_sst) |
---|
| 66 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_sit ! sea ice temperature |
---|
| 67 | !$OMP THREADPRIVATE(read_sit) |
---|
| 68 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_sic ! sea ice fraction |
---|
| 69 | !$OMP THREADPRIVATE(read_sic) |
---|
| 70 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_alb_sic ! albedo at sea ice |
---|
| 71 | !$OMP THREADPRIVATE(read_alb_sic) |
---|
[1067] | 72 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_u0, read_v0 ! ocean surface current |
---|
| 73 | !$OMP THREADPRIVATE(read_u0,read_v0) |
---|
[1279] | 74 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: read_co2 ! ocean co2 flux |
---|
| 75 | !$OMP THREADPRIVATE(read_co2) |
---|
[782] | 76 | INTEGER, ALLOCATABLE, DIMENSION(:), SAVE :: unity |
---|
| 77 | !$OMP THREADPRIVATE(unity) |
---|
| 78 | INTEGER, SAVE :: nidct, nidcs |
---|
| 79 | !$OMP THREADPRIVATE(nidct,nidcs) |
---|
| 80 | |
---|
| 81 | ! variables to be sent to the coupler |
---|
| 82 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_sols2D, cpl_nsol2D, cpl_rain2D |
---|
| 83 | !$OMP THREADPRIVATE(cpl_sols2D, cpl_nsol2D, cpl_rain2D) |
---|
| 84 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_snow2D, cpl_evap2D, cpl_tsol2D |
---|
| 85 | !$OMP THREADPRIVATE(cpl_snow2D, cpl_evap2D, cpl_tsol2D) |
---|
| 86 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_fder2D, cpl_albe2D |
---|
| 87 | !$OMP THREADPRIVATE(cpl_fder2D, cpl_albe2D) |
---|
| 88 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_taux2D, cpl_tauy2D |
---|
| 89 | !$OMP THREADPRIVATE(cpl_taux2D, cpl_tauy2D) |
---|
[1279] | 90 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_taumod2D |
---|
| 91 | !$OMP THREADPRIVATE(cpl_taumod2D) |
---|
[782] | 92 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_windsp2D |
---|
| 93 | !$OMP THREADPRIVATE(cpl_windsp2D) |
---|
[2872] | 94 | REAL, ALLOCATABLE, DIMENSION(:,:,:), SAVE :: cpl_sens_rain2D, cpl_sens_snow2D |
---|
| 95 | !$OMP THREADPRIVATE(cpl_sens_rain2D, cpl_sens_snow2D) |
---|
[1279] | 96 | REAL, ALLOCATABLE, DIMENSION(:,:), SAVE :: cpl_atm_co22D |
---|
| 97 | !$OMP THREADPRIVATE(cpl_atm_co22D) |
---|
[1001] | 98 | |
---|
[3465] | 99 | !!!!!!!!!! variable for calving |
---|
| 100 | INTEGER, PARAMETER :: nb_zone_calving = 3 |
---|
| 101 | REAL,ALLOCATABLE, DIMENSION(:,:,:),SAVE :: area_calving |
---|
| 102 | !$OMP THREADPRIVATE(area_calving) |
---|
| 103 | REAL,ALLOCATABLE, DIMENSION(:,:),SAVE :: cell_area2D |
---|
| 104 | !$OMP THREADPRIVATE(cell_area2D) |
---|
| 105 | INTEGER, SAVE :: ind_calving(nb_zone_calving) |
---|
| 106 | !$OMP THREADPRIVATE(ind_calving) |
---|
| 107 | |
---|
| 108 | LOGICAL,SAVE :: cpl_old_calving |
---|
| 109 | !$OMP THREADPRIVATE(cpl_old_calving) |
---|
| 110 | |
---|
[782] | 111 | CONTAINS |
---|
| 112 | ! |
---|
| 113 | !************************************************************************************ |
---|
| 114 | ! |
---|
| 115 | SUBROUTINE cpl_init(dtime, rlon, rlat) |
---|
[1279] | 116 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day |
---|
[1454] | 117 | USE surface_data |
---|
[1785] | 118 | USE indice_sol_mod |
---|
[3465] | 119 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid1dTo2d_glo, klon_glo, grid_type, unstructured, regular_lonlat |
---|
[2344] | 120 | USE time_phylmdz_mod, ONLY: annee_ref, day_ini, itau_phy, itaufin_phy |
---|
[2311] | 121 | USE print_control_mod, ONLY: lunout |
---|
[3465] | 122 | USE geometry_mod, ONLY : longitude_deg, latitude_deg, ind_cell_glo, cell_area |
---|
| 123 | USE ioipsl_getin_p_mod, ONLY: getin_p |
---|
[782] | 124 | |
---|
| 125 | ! Input arguments |
---|
| 126 | !************************************************************************************* |
---|
| 127 | REAL, INTENT(IN) :: dtime |
---|
| 128 | REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat |
---|
| 129 | |
---|
| 130 | ! Local variables |
---|
| 131 | !************************************************************************************* |
---|
| 132 | INTEGER :: error, sum_error, ig, i |
---|
| 133 | INTEGER :: jf, nhoridct |
---|
| 134 | INTEGER :: nhoridcs |
---|
| 135 | INTEGER :: idtime |
---|
| 136 | INTEGER :: idayref |
---|
| 137 | INTEGER :: npas ! only for OASIS2 |
---|
| 138 | REAL :: zjulian |
---|
[2344] | 139 | REAL, DIMENSION(nbp_lon,nbp_lat) :: zx_lon, zx_lat |
---|
[782] | 140 | CHARACTER(len = 20) :: modname = 'cpl_init' |
---|
| 141 | CHARACTER(len = 80) :: abort_message |
---|
| 142 | CHARACTER(len=80) :: clintocplnam, clfromcplnam |
---|
[3465] | 143 | REAL, DIMENSION(klon_mpi) :: rlon_mpi, rlat_mpi, cell_area_mpi |
---|
| 144 | INTEGER, DIMENSION(klon_mpi) :: ind_cell_glo_mpi |
---|
| 145 | REAL, DIMENSION(nbp_lon,jj_nb) :: lon2D, lat2D |
---|
| 146 | INTEGER :: mask_calving(nbp_lon,jj_nb,nb_zone_calving) |
---|
| 147 | REAL :: pos |
---|
[782] | 148 | |
---|
[3465] | 149 | !*************************************** |
---|
| 150 | ! Use old calving or not (default no) |
---|
| 151 | cpl_old_calving=.FALSE. |
---|
| 152 | CALL getin_p("cpl_old_calving",cpl_old_calving) |
---|
| 153 | |
---|
| 154 | |
---|
[782] | 155 | !************************************************************************************* |
---|
| 156 | ! Calculate coupling period |
---|
| 157 | ! |
---|
| 158 | !************************************************************************************* |
---|
| 159 | |
---|
[2344] | 160 | npas = itaufin_phy |
---|
[2075] | 161 | ! nexca = 86400 / dtime |
---|
| 162 | nexca = t_coupl / dtime |
---|
[782] | 163 | WRITE(lunout,*)' ##### Ocean couple #####' |
---|
| 164 | WRITE(lunout,*)' Valeurs des pas de temps' |
---|
| 165 | WRITE(lunout,*)' npas = ', npas |
---|
| 166 | WRITE(lunout,*)' nexca = ', nexca |
---|
| 167 | |
---|
| 168 | !************************************************************************************* |
---|
| 169 | ! Allocate variables |
---|
| 170 | ! |
---|
| 171 | !************************************************************************************* |
---|
| 172 | error = 0 |
---|
| 173 | sum_error = 0 |
---|
| 174 | |
---|
| 175 | ALLOCATE(unity(klon), stat = error) |
---|
| 176 | sum_error = sum_error + error |
---|
| 177 | ALLOCATE(cpl_sols(klon,2), stat = error) |
---|
| 178 | sum_error = sum_error + error |
---|
| 179 | ALLOCATE(cpl_nsol(klon,2), stat = error) |
---|
| 180 | sum_error = sum_error + error |
---|
| 181 | ALLOCATE(cpl_rain(klon,2), stat = error) |
---|
| 182 | sum_error = sum_error + error |
---|
| 183 | ALLOCATE(cpl_snow(klon,2), stat = error) |
---|
| 184 | sum_error = sum_error + error |
---|
| 185 | ALLOCATE(cpl_evap(klon,2), stat = error) |
---|
| 186 | sum_error = sum_error + error |
---|
| 187 | ALLOCATE(cpl_tsol(klon,2), stat = error) |
---|
| 188 | sum_error = sum_error + error |
---|
| 189 | ALLOCATE(cpl_fder(klon,2), stat = error) |
---|
| 190 | sum_error = sum_error + error |
---|
| 191 | ALLOCATE(cpl_albe(klon,2), stat = error) |
---|
| 192 | sum_error = sum_error + error |
---|
| 193 | ALLOCATE(cpl_taux(klon,2), stat = error) |
---|
| 194 | sum_error = sum_error + error |
---|
[1279] | 195 | ALLOCATE(cpl_tauy(klon,2), stat = error) |
---|
| 196 | sum_error = sum_error + error |
---|
[782] | 197 | ALLOCATE(cpl_windsp(klon,2), stat = error) |
---|
| 198 | sum_error = sum_error + error |
---|
[2545] | 199 | ALLOCATE(cpl_taumod(klon,2), stat = error) |
---|
[782] | 200 | sum_error = sum_error + error |
---|
[2872] | 201 | ALLOCATE(cpl_sens_rain(klon,2), stat = error) |
---|
| 202 | sum_error = sum_error + error |
---|
| 203 | ALLOCATE(cpl_sens_snow(klon,2), stat = error) |
---|
| 204 | sum_error = sum_error + error |
---|
[2344] | 205 | ALLOCATE(cpl_rriv2D(nbp_lon,jj_nb), stat=error) |
---|
[782] | 206 | sum_error = sum_error + error |
---|
[2344] | 207 | ALLOCATE(cpl_rcoa2D(nbp_lon,jj_nb), stat=error) |
---|
[782] | 208 | sum_error = sum_error + error |
---|
[2344] | 209 | ALLOCATE(cpl_rlic2D(nbp_lon,jj_nb), stat=error) |
---|
[782] | 210 | sum_error = sum_error + error |
---|
[2344] | 211 | ALLOCATE(read_sst(nbp_lon, jj_nb), stat = error) |
---|
[782] | 212 | sum_error = sum_error + error |
---|
[2344] | 213 | ALLOCATE(read_sic(nbp_lon, jj_nb), stat = error) |
---|
[782] | 214 | sum_error = sum_error + error |
---|
[2344] | 215 | ALLOCATE(read_sit(nbp_lon, jj_nb), stat = error) |
---|
[782] | 216 | sum_error = sum_error + error |
---|
[2344] | 217 | ALLOCATE(read_alb_sic(nbp_lon, jj_nb), stat = error) |
---|
[782] | 218 | sum_error = sum_error + error |
---|
[2344] | 219 | ALLOCATE(read_u0(nbp_lon, jj_nb), stat = error) |
---|
[1067] | 220 | sum_error = sum_error + error |
---|
[2344] | 221 | ALLOCATE(read_v0(nbp_lon, jj_nb), stat = error) |
---|
[1067] | 222 | sum_error = sum_error + error |
---|
| 223 | |
---|
[1279] | 224 | IF (carbon_cycle_cpl) THEN |
---|
[2344] | 225 | ALLOCATE(read_co2(nbp_lon, jj_nb), stat = error) |
---|
[1279] | 226 | sum_error = sum_error + error |
---|
| 227 | ALLOCATE(cpl_atm_co2(klon,2), stat = error) |
---|
| 228 | sum_error = sum_error + error |
---|
| 229 | |
---|
| 230 | ! Allocate variable in carbon_cycle_mod |
---|
[3448] | 231 | IF (.NOT.ALLOCATED(fco2_ocn_day)) ALLOCATE(fco2_ocn_day(klon), stat = error) |
---|
[1279] | 232 | sum_error = sum_error + error |
---|
[3448] | 233 | ENDIF |
---|
[1279] | 234 | |
---|
[3465] | 235 | ! calving initialization |
---|
| 236 | ALLOCATE(area_calving(nbp_lon, jj_nb, nb_zone_calving), stat = error) |
---|
| 237 | sum_error = sum_error + error |
---|
| 238 | ALLOCATE(cell_area2D(nbp_lon, jj_nb), stat = error) |
---|
| 239 | sum_error = sum_error + error |
---|
| 240 | |
---|
| 241 | |
---|
| 242 | CALL gather_omp(longitude_deg,rlon_mpi) |
---|
| 243 | CALL gather_omp(latitude_deg,rlat_mpi) |
---|
| 244 | CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi) |
---|
| 245 | CALL gather_omp(cell_area,cell_area_mpi) |
---|
| 246 | |
---|
| 247 | IF (is_omp_master) THEN |
---|
| 248 | CALL Grid1DTo2D_mpi(rlon_mpi,lon2D) |
---|
| 249 | CALL Grid1DTo2D_mpi(rlat_mpi,lat2D) |
---|
| 250 | CALL Grid1DTo2D_mpi(cell_area_mpi,cell_area2D) |
---|
| 251 | mask_calving(:,:,:) = 0 |
---|
| 252 | WHERE ( lat2D >= 40) mask_calving(:,:,1) = 1 |
---|
| 253 | WHERE ( lat2D < 40 .AND. lat2D > -50) mask_calving(:,:,2) = 1 |
---|
| 254 | WHERE ( lat2D <= -50) mask_calving(:,:,3) = 1 |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | DO i=1,nb_zone_calving |
---|
| 258 | area_calving(:,:,i)=mask_calving(:,:,i)*cell_area2D(:,:) |
---|
| 259 | pos=1 |
---|
| 260 | IF (i>1) pos = 1 + ((nbp_lon*nbp_lat-1)*(i-1))/(nb_zone_calving-1) |
---|
| 261 | |
---|
| 262 | ind_calving(i)=0 |
---|
| 263 | IF (grid_type==unstructured) THEN |
---|
| 264 | |
---|
| 265 | DO ig=1,klon_mpi |
---|
| 266 | IF (ind_cell_glo_mpi(ig)==pos) ind_calving(i)=ig |
---|
| 267 | ENDDO |
---|
| 268 | |
---|
| 269 | ELSE IF (grid_type==regular_lonlat) THEN |
---|
| 270 | IF ((ij_begin<=pos .AND. ij_end>=pos) .OR. (ij_begin<=pos .AND. is_south_pole_dyn )) THEN |
---|
| 271 | ind_calving(i)=pos-(jj_begin-1)*nbp_lon |
---|
| 272 | ENDIF |
---|
| 273 | ENDIF |
---|
| 274 | |
---|
| 275 | ENDDO |
---|
| 276 | ENDIF |
---|
| 277 | |
---|
| 278 | |
---|
[782] | 279 | IF (sum_error /= 0) THEN |
---|
| 280 | abort_message='Pb allocation variables couplees' |
---|
[2311] | 281 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 282 | ENDIF |
---|
| 283 | !************************************************************************************* |
---|
| 284 | ! Initialize the allocated varaibles |
---|
| 285 | ! |
---|
| 286 | !************************************************************************************* |
---|
| 287 | DO ig = 1, klon |
---|
| 288 | unity(ig) = ig |
---|
| 289 | ENDDO |
---|
| 290 | |
---|
| 291 | !************************************************************************************* |
---|
| 292 | ! Initialize coupling |
---|
| 293 | ! |
---|
| 294 | !************************************************************************************* |
---|
| 295 | idtime = INT(dtime) |
---|
| 296 | #ifdef CPP_COUPLE |
---|
| 297 | CALL inicma |
---|
| 298 | #endif |
---|
| 299 | |
---|
| 300 | !************************************************************************************* |
---|
| 301 | ! initialize NetCDF output |
---|
| 302 | ! |
---|
| 303 | !************************************************************************************* |
---|
| 304 | IF (is_sequential) THEN |
---|
| 305 | idayref = day_ini |
---|
| 306 | CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian) |
---|
[3435] | 307 | CALL grid1dTo2d_glo(rlon,zx_lon) |
---|
[2344] | 308 | DO i = 1, nbp_lon |
---|
[782] | 309 | zx_lon(i,1) = rlon(i+1) |
---|
[2344] | 310 | zx_lon(i,nbp_lat) = rlon(i+1) |
---|
[782] | 311 | ENDDO |
---|
[3435] | 312 | CALL grid1dTo2d_glo(rlat,zx_lat) |
---|
[782] | 313 | clintocplnam="cpl_atm_tauflx" |
---|
[2344] | 314 | CALL histbeg(clintocplnam,nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:),& |
---|
| 315 | 1,nbp_lon,1,nbp_lat, itau_phy,zjulian,dtime,nhoridct,nidct) |
---|
[782] | 316 | ! no vertical axis |
---|
| 317 | CALL histdef(nidct, 'tauxe','tauxe', & |
---|
[2344] | 318 | "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime) |
---|
[782] | 319 | CALL histdef(nidct, 'tauyn','tauyn', & |
---|
[2344] | 320 | "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime) |
---|
[782] | 321 | CALL histdef(nidct, 'tmp_lon','tmp_lon', & |
---|
[2344] | 322 | "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime) |
---|
[782] | 323 | CALL histdef(nidct, 'tmp_lat','tmp_lat', & |
---|
[2344] | 324 | "-",nbp_lon,nbp_lat, nhoridct, 1, 1, 1, -99, 32, "inst", dtime,dtime) |
---|
[1279] | 325 | DO jf=1,maxsend |
---|
| 326 | IF (infosend(i)%action) THEN |
---|
| 327 | CALL histdef(nidct, infosend(i)%name ,infosend(i)%name , & |
---|
[2344] | 328 | "-",nbp_lon,nbp_lat,nhoridct,1,1,1,-99,32,"inst",dtime,dtime) |
---|
[1279] | 329 | ENDIF |
---|
[3448] | 330 | ENDDO |
---|
[782] | 331 | CALL histend(nidct) |
---|
| 332 | CALL histsync(nidct) |
---|
| 333 | |
---|
| 334 | clfromcplnam="cpl_atm_sst" |
---|
[2344] | 335 | CALL histbeg(clfromcplnam,nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:),1,nbp_lon,1,nbp_lat, & |
---|
[782] | 336 | 0,zjulian,dtime,nhoridcs,nidcs) |
---|
| 337 | ! no vertical axis |
---|
[1279] | 338 | DO jf=1,maxrecv |
---|
| 339 | IF (inforecv(i)%action) THEN |
---|
| 340 | CALL histdef(nidcs,inforecv(i)%name ,inforecv(i)%name , & |
---|
[2344] | 341 | "-",nbp_lon,nbp_lat,nhoridcs,1,1,1,-99,32,"inst",dtime,dtime) |
---|
[1279] | 342 | ENDIF |
---|
[3448] | 343 | ENDDO |
---|
[782] | 344 | CALL histend(nidcs) |
---|
| 345 | CALL histsync(nidcs) |
---|
| 346 | |
---|
| 347 | ENDIF ! is_sequential |
---|
| 348 | |
---|
[1454] | 349 | |
---|
| 350 | !************************************************************************************* |
---|
| 351 | ! compatibility test |
---|
| 352 | ! |
---|
| 353 | !************************************************************************************* |
---|
| 354 | IF (carbon_cycle_cpl .AND. version_ocean=='opa8') THEN |
---|
| 355 | abort_message='carbon_cycle_cpl does not work with opa8' |
---|
[2311] | 356 | CALL abort_physic(modname,abort_message,1) |
---|
[3448] | 357 | ENDIF |
---|
[1454] | 358 | |
---|
[782] | 359 | END SUBROUTINE cpl_init |
---|
| 360 | |
---|
| 361 | ! |
---|
| 362 | !************************************************************************************* |
---|
| 363 | ! |
---|
[996] | 364 | |
---|
| 365 | SUBROUTINE cpl_receive_frac(itime, dtime, pctsrf, is_modified) |
---|
| 366 | ! This subroutine receives from coupler for both ocean and seaice |
---|
[782] | 367 | ! 4 fields : read_sst, read_sic, read_sit and read_alb_sic. |
---|
[996] | 368 | ! The new sea-ice-land-landice fraction is returned. The others fields |
---|
| 369 | ! are stored in this module. |
---|
| 370 | USE surface_data |
---|
[2399] | 371 | USE geometry_mod, ONLY : longitude_deg, latitude_deg |
---|
[1279] | 372 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl |
---|
[1785] | 373 | USE indice_sol_mod |
---|
[2344] | 374 | USE time_phylmdz_mod, ONLY: start_time, itau_phy |
---|
| 375 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[1785] | 376 | |
---|
[793] | 377 | INCLUDE "YOMCST.h" |
---|
[782] | 378 | |
---|
[996] | 379 | ! Arguments |
---|
[782] | 380 | !************************************************************************************ |
---|
[996] | 381 | INTEGER, INTENT(IN) :: itime |
---|
| 382 | REAL, INTENT(IN) :: dtime |
---|
| 383 | REAL, DIMENSION(klon,nbsrf), INTENT(INOUT) :: pctsrf |
---|
| 384 | LOGICAL, INTENT(OUT) :: is_modified |
---|
[782] | 385 | |
---|
| 386 | ! Local variables |
---|
| 387 | !************************************************************************************ |
---|
[996] | 388 | INTEGER :: j, i, time_sec |
---|
[782] | 389 | INTEGER :: itau_w |
---|
[2344] | 390 | INTEGER, DIMENSION(nbp_lon*nbp_lat) :: ndexcs |
---|
[996] | 391 | CHARACTER(len = 20) :: modname = 'cpl_receive_frac' |
---|
[782] | 392 | CHARACTER(len = 80) :: abort_message |
---|
| 393 | REAL, DIMENSION(klon) :: read_sic1D |
---|
[2344] | 394 | REAL, DIMENSION(nbp_lon,jj_nb,maxrecv) :: tab_read_flds |
---|
[996] | 395 | REAL, DIMENSION(klon,nbsrf) :: pctsrf_old |
---|
[1067] | 396 | REAL, DIMENSION(klon_mpi) :: rlon_mpi, rlat_mpi |
---|
[2344] | 397 | REAL, DIMENSION(nbp_lon,jj_nb) :: tmp_lon, tmp_lat |
---|
| 398 | REAL, DIMENSION(nbp_lon,jj_nb) :: tmp_r0 |
---|
[782] | 399 | |
---|
| 400 | !************************************************************************************* |
---|
| 401 | ! Start calculation |
---|
| 402 | ! Get fields from coupler |
---|
| 403 | ! |
---|
| 404 | !************************************************************************************* |
---|
| 405 | |
---|
[996] | 406 | is_modified=.FALSE. |
---|
| 407 | |
---|
[1279] | 408 | ! Check if right moment to receive from coupler |
---|
[996] | 409 | IF (MOD(itime, nexca) == 1) THEN |
---|
| 410 | is_modified=.TRUE. |
---|
| 411 | |
---|
| 412 | time_sec=(itime-1)*dtime |
---|
[782] | 413 | #ifdef CPP_COUPLE |
---|
[987] | 414 | !$OMP MASTER |
---|
[1010] | 415 | CALL fromcpl(time_sec, tab_read_flds) |
---|
[987] | 416 | !$OMP END MASTER |
---|
[782] | 417 | #endif |
---|
| 418 | |
---|
| 419 | ! NetCDF output of received fields |
---|
[996] | 420 | IF (is_sequential) THEN |
---|
| 421 | ndexcs(:) = 0 |
---|
[2344] | 422 | itau_w = itau_phy + itime + start_time * day_step_phy |
---|
[1279] | 423 | DO i = 1, maxrecv |
---|
| 424 | IF (inforecv(i)%action) THEN |
---|
[2344] | 425 | CALL histwrite(nidcs,inforecv(i)%name,itau_w,tab_read_flds(:,:,i),nbp_lon*(nbp_lat),ndexcs) |
---|
[1279] | 426 | ENDIF |
---|
[3448] | 427 | ENDDO |
---|
[996] | 428 | ENDIF |
---|
[782] | 429 | |
---|
[1001] | 430 | |
---|
[996] | 431 | ! Save each field in a 2D array. |
---|
[987] | 432 | !$OMP MASTER |
---|
[1279] | 433 | read_sst(:,:) = tab_read_flds(:,:,idr_sisutw) ! Sea surface temperature |
---|
| 434 | read_sic(:,:) = tab_read_flds(:,:,idr_icecov) ! Sea ice concentration |
---|
| 435 | read_alb_sic(:,:) = tab_read_flds(:,:,idr_icealw) ! Albedo at sea ice |
---|
| 436 | read_sit(:,:) = tab_read_flds(:,:,idr_icetem) ! Sea ice temperature |
---|
[996] | 437 | !$OMP END MASTER |
---|
[987] | 438 | |
---|
[1067] | 439 | IF (cpl_current) THEN |
---|
| 440 | |
---|
| 441 | ! Transform the longitudes and latitudes on 2D arrays |
---|
[2399] | 442 | CALL gather_omp(longitude_deg,rlon_mpi) |
---|
| 443 | CALL gather_omp(latitude_deg,rlat_mpi) |
---|
[1067] | 444 | !$OMP MASTER |
---|
| 445 | CALL Grid1DTo2D_mpi(rlon_mpi,tmp_lon) |
---|
| 446 | CALL Grid1DTo2D_mpi(rlat_mpi,tmp_lat) |
---|
| 447 | |
---|
| 448 | ! Transform the currents from cartesian to spheric coordinates |
---|
| 449 | ! tmp_r0 should be zero |
---|
[2344] | 450 | CALL geo2atm(nbp_lon, jj_nb, tab_read_flds(:,:,idr_curenx), & |
---|
[1279] | 451 | tab_read_flds(:,:,idr_cureny), tab_read_flds(:,:,idr_curenz), & |
---|
[1067] | 452 | tmp_lon, tmp_lat, & |
---|
| 453 | read_u0(:,:), read_v0(:,:), tmp_r0(:,:)) |
---|
| 454 | !$OMP END MASTER |
---|
[1146] | 455 | |
---|
[1279] | 456 | ELSE |
---|
[1067] | 457 | read_u0(:,:) = 0. |
---|
| 458 | read_v0(:,:) = 0. |
---|
[1279] | 459 | ENDIF |
---|
| 460 | |
---|
| 461 | IF (carbon_cycle_cpl) THEN |
---|
| 462 | !$OMP MASTER |
---|
| 463 | read_co2(:,:) = tab_read_flds(:,:,idr_oceco2) ! CO2 flux |
---|
| 464 | !$OMP END MASTER |
---|
[1067] | 465 | ENDIF |
---|
| 466 | |
---|
[782] | 467 | !************************************************************************************* |
---|
[996] | 468 | ! Transform seaice fraction (read_sic : ocean-seaice mask) into global |
---|
| 469 | ! fraction (pctsrf : ocean-seaice-land-landice mask) |
---|
[782] | 470 | ! |
---|
| 471 | !************************************************************************************* |
---|
[996] | 472 | CALL cpl2gath(read_sic, read_sic1D, klon, unity) |
---|
| 473 | |
---|
| 474 | pctsrf_old(:,:) = pctsrf(:,:) |
---|
| 475 | DO i = 1, klon |
---|
| 476 | ! treatment only of points with ocean and/or seaice |
---|
[1279] | 477 | ! old land-ocean mask can not be changed |
---|
[996] | 478 | IF (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic) > 0.) THEN |
---|
| 479 | pctsrf(i,is_sic) = (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic)) & |
---|
| 480 | * read_sic1D(i) |
---|
| 481 | pctsrf(i,is_oce) = (pctsrf_old(i,is_oce) + pctsrf_old(i,is_sic)) & |
---|
| 482 | - pctsrf(i,is_sic) |
---|
[782] | 483 | ENDIF |
---|
| 484 | ENDDO |
---|
[987] | 485 | |
---|
[3448] | 486 | ENDIF ! if time to receive |
---|
[782] | 487 | |
---|
[996] | 488 | END SUBROUTINE cpl_receive_frac |
---|
[782] | 489 | |
---|
| 490 | ! |
---|
| 491 | !************************************************************************************* |
---|
| 492 | ! |
---|
[996] | 493 | |
---|
[1067] | 494 | SUBROUTINE cpl_receive_ocean_fields(knon, knindex, tsurf_new, u0_new, v0_new) |
---|
[782] | 495 | ! |
---|
[996] | 496 | ! This routine returns the field for the ocean that has been read from the coupler |
---|
| 497 | ! (done earlier with cpl_receive_frac). The field is the temperature. |
---|
| 498 | ! The temperature is transformed into 1D array with valid points from index 1 to knon. |
---|
[782] | 499 | ! |
---|
[1279] | 500 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day |
---|
[1785] | 501 | USE indice_sol_mod |
---|
[782] | 502 | |
---|
| 503 | ! Input arguments |
---|
| 504 | !************************************************************************************* |
---|
| 505 | INTEGER, INTENT(IN) :: knon |
---|
| 506 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 507 | |
---|
| 508 | ! Output arguments |
---|
| 509 | !************************************************************************************* |
---|
| 510 | REAL, DIMENSION(klon), INTENT(OUT) :: tsurf_new |
---|
[1067] | 511 | REAL, DIMENSION(klon), INTENT(OUT) :: u0_new |
---|
| 512 | REAL, DIMENSION(klon), INTENT(OUT) :: v0_new |
---|
[782] | 513 | |
---|
[996] | 514 | ! Local variables |
---|
[782] | 515 | !************************************************************************************* |
---|
[1279] | 516 | INTEGER :: i |
---|
| 517 | INTEGER, DIMENSION(klon) :: index |
---|
| 518 | REAL, DIMENSION(klon) :: sic_new |
---|
[782] | 519 | |
---|
| 520 | !************************************************************************************* |
---|
| 521 | ! Transform read_sst into compressed 1D variable tsurf_new |
---|
| 522 | ! |
---|
| 523 | !************************************************************************************* |
---|
| 524 | CALL cpl2gath(read_sst, tsurf_new, knon, knindex) |
---|
[996] | 525 | CALL cpl2gath(read_sic, sic_new, knon, knindex) |
---|
[1067] | 526 | CALL cpl2gath(read_u0, u0_new, knon, knindex) |
---|
| 527 | CALL cpl2gath(read_v0, v0_new, knon, knindex) |
---|
[782] | 528 | |
---|
[996] | 529 | !************************************************************************************* |
---|
[1279] | 530 | ! Transform read_co2 into uncompressed 1D variable fco2_ocn_day added directly in |
---|
| 531 | ! the module carbon_cycle_mod |
---|
| 532 | ! |
---|
| 533 | !************************************************************************************* |
---|
| 534 | IF (carbon_cycle_cpl) THEN |
---|
| 535 | DO i=1,klon |
---|
| 536 | index(i)=i |
---|
[3448] | 537 | ENDDO |
---|
[1279] | 538 | CALL cpl2gath(read_co2, fco2_ocn_day, klon, index) |
---|
[3448] | 539 | ENDIF |
---|
[1279] | 540 | |
---|
| 541 | !************************************************************************************* |
---|
[996] | 542 | ! The fields received from the coupler have to be weighted with the fraction of ocean |
---|
| 543 | ! in relation to the total sea-ice+ocean |
---|
| 544 | ! |
---|
| 545 | !************************************************************************************* |
---|
| 546 | DO i=1, knon |
---|
| 547 | tsurf_new(i) = tsurf_new(i)/(1. - sic_new(i)) |
---|
[3448] | 548 | ENDDO |
---|
[782] | 549 | |
---|
| 550 | END SUBROUTINE cpl_receive_ocean_fields |
---|
[996] | 551 | |
---|
[782] | 552 | ! |
---|
| 553 | !************************************************************************************* |
---|
| 554 | ! |
---|
[996] | 555 | |
---|
[782] | 556 | SUBROUTINE cpl_receive_seaice_fields(knon, knindex, & |
---|
[1146] | 557 | tsurf_new, alb_new, u0_new, v0_new) |
---|
[782] | 558 | ! |
---|
| 559 | ! This routine returns the fields for the seaice that have been read from the coupler |
---|
[996] | 560 | ! (done earlier with cpl_receive_frac). These fields are the temperature and |
---|
[782] | 561 | ! albedo at sea ice surface and fraction of sea ice. |
---|
[996] | 562 | ! The fields are transformed into 1D arrays with valid points from index 1 to knon. |
---|
[782] | 563 | ! |
---|
| 564 | |
---|
| 565 | ! Input arguments |
---|
| 566 | !************************************************************************************* |
---|
| 567 | INTEGER, INTENT(IN) :: knon |
---|
| 568 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 569 | |
---|
| 570 | ! Output arguments |
---|
| 571 | !************************************************************************************* |
---|
| 572 | REAL, DIMENSION(klon), INTENT(OUT) :: tsurf_new |
---|
| 573 | REAL, DIMENSION(klon), INTENT(OUT) :: alb_new |
---|
[1146] | 574 | REAL, DIMENSION(klon), INTENT(OUT) :: u0_new |
---|
| 575 | REAL, DIMENSION(klon), INTENT(OUT) :: v0_new |
---|
[782] | 576 | |
---|
[996] | 577 | ! Local variables |
---|
| 578 | !************************************************************************************* |
---|
| 579 | INTEGER :: i |
---|
| 580 | REAL, DIMENSION(klon) :: sic_new |
---|
[782] | 581 | |
---|
| 582 | !************************************************************************************* |
---|
| 583 | ! Transform fields read from coupler from 2D into compressed 1D variables |
---|
| 584 | ! |
---|
| 585 | !************************************************************************************* |
---|
| 586 | CALL cpl2gath(read_sit, tsurf_new, knon, knindex) |
---|
| 587 | CALL cpl2gath(read_alb_sic, alb_new, knon, knindex) |
---|
[996] | 588 | CALL cpl2gath(read_sic, sic_new, knon, knindex) |
---|
[1146] | 589 | CALL cpl2gath(read_u0, u0_new, knon, knindex) |
---|
| 590 | CALL cpl2gath(read_v0, v0_new, knon, knindex) |
---|
[782] | 591 | |
---|
[996] | 592 | !************************************************************************************* |
---|
| 593 | ! The fields received from the coupler have to be weighted with the sea-ice |
---|
| 594 | ! concentration (in relation to the total sea-ice + ocean). |
---|
| 595 | ! |
---|
| 596 | !************************************************************************************* |
---|
| 597 | DO i= 1, knon |
---|
| 598 | tsurf_new(i) = tsurf_new(i) / sic_new(i) |
---|
| 599 | alb_new(i) = alb_new(i) / sic_new(i) |
---|
[3448] | 600 | ENDDO |
---|
[996] | 601 | |
---|
[782] | 602 | END SUBROUTINE cpl_receive_seaice_fields |
---|
| 603 | |
---|
| 604 | ! |
---|
| 605 | !************************************************************************************* |
---|
| 606 | ! |
---|
| 607 | |
---|
| 608 | SUBROUTINE cpl_send_ocean_fields(itime, knon, knindex, & |
---|
| 609 | swdown, lwdown, fluxlat, fluxsens, & |
---|
[2872] | 610 | precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy, windsp,& |
---|
| 611 | sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol) |
---|
[782] | 612 | ! |
---|
| 613 | ! This subroutine cumulates some fields for each time-step during a coupling |
---|
| 614 | ! period. At last time-step in a coupling period the fields are transformed to the |
---|
| 615 | ! grid accepted by the coupler. No sending to the coupler will be done from here |
---|
| 616 | ! (it is done in cpl_send_seaice_fields). |
---|
| 617 | ! |
---|
[1279] | 618 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, co2_send |
---|
[1785] | 619 | USE indice_sol_mod |
---|
[2344] | 620 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[782] | 621 | |
---|
| 622 | ! Input arguments |
---|
| 623 | !************************************************************************************* |
---|
| 624 | INTEGER, INTENT(IN) :: itime |
---|
| 625 | INTEGER, INTENT(IN) :: knon |
---|
| 626 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 627 | REAL, DIMENSION(klon), INTENT(IN) :: swdown, lwdown |
---|
| 628 | REAL, DIMENSION(klon), INTENT(IN) :: fluxlat, fluxsens |
---|
| 629 | REAL, DIMENSION(klon), INTENT(IN) :: precip_rain, precip_snow |
---|
| 630 | REAL, DIMENSION(klon), INTENT(IN) :: evap, tsurf, fder, albsol |
---|
| 631 | REAL, DIMENSION(klon), INTENT(IN) :: taux, tauy, windsp |
---|
[2872] | 632 | REAL, DIMENSION(klon), INTENT(IN) :: sens_prec_liq, sens_prec_sol |
---|
| 633 | REAL, DIMENSION(klon), INTENT(IN) :: lat_prec_liq, lat_prec_sol |
---|
[782] | 634 | |
---|
| 635 | ! Local variables |
---|
| 636 | !************************************************************************************* |
---|
| 637 | INTEGER :: cpl_index, ig |
---|
| 638 | INTEGER :: error, sum_error |
---|
| 639 | CHARACTER(len = 25) :: modname = 'cpl_send_ocean_fields' |
---|
| 640 | CHARACTER(len = 80) :: abort_message |
---|
| 641 | |
---|
| 642 | !************************************************************************************* |
---|
| 643 | ! Start calculation |
---|
| 644 | ! The ocean points are saved with second array index=1 |
---|
| 645 | ! |
---|
| 646 | !************************************************************************************* |
---|
| 647 | cpl_index = 1 |
---|
| 648 | |
---|
| 649 | !************************************************************************************* |
---|
| 650 | ! Reset fields to zero in the beginning of a new coupling period |
---|
| 651 | ! |
---|
| 652 | !************************************************************************************* |
---|
| 653 | IF (MOD(itime, nexca) == 1) THEN |
---|
[996] | 654 | cpl_sols(1:knon,cpl_index) = 0.0 |
---|
| 655 | cpl_nsol(1:knon,cpl_index) = 0.0 |
---|
| 656 | cpl_rain(1:knon,cpl_index) = 0.0 |
---|
| 657 | cpl_snow(1:knon,cpl_index) = 0.0 |
---|
| 658 | cpl_evap(1:knon,cpl_index) = 0.0 |
---|
| 659 | cpl_tsol(1:knon,cpl_index) = 0.0 |
---|
| 660 | cpl_fder(1:knon,cpl_index) = 0.0 |
---|
| 661 | cpl_albe(1:knon,cpl_index) = 0.0 |
---|
| 662 | cpl_taux(1:knon,cpl_index) = 0.0 |
---|
| 663 | cpl_tauy(1:knon,cpl_index) = 0.0 |
---|
| 664 | cpl_windsp(1:knon,cpl_index) = 0.0 |
---|
[2872] | 665 | cpl_sens_rain(1:knon,cpl_index) = 0.0 |
---|
| 666 | cpl_sens_snow(1:knon,cpl_index) = 0.0 |
---|
[1279] | 667 | cpl_taumod(1:knon,cpl_index) = 0.0 |
---|
| 668 | IF (carbon_cycle_cpl) cpl_atm_co2(1:knon,cpl_index) = 0.0 |
---|
[782] | 669 | ENDIF |
---|
| 670 | |
---|
| 671 | !************************************************************************************* |
---|
| 672 | ! Cumulate at each time-step |
---|
| 673 | ! |
---|
| 674 | !************************************************************************************* |
---|
| 675 | DO ig = 1, knon |
---|
| 676 | cpl_sols(ig,cpl_index) = cpl_sols(ig,cpl_index) + & |
---|
[1403] | 677 | swdown(ig) / REAL(nexca) |
---|
[782] | 678 | cpl_nsol(ig,cpl_index) = cpl_nsol(ig,cpl_index) + & |
---|
[1403] | 679 | (lwdown(ig) + fluxlat(ig) +fluxsens(ig)) / REAL(nexca) |
---|
[782] | 680 | cpl_rain(ig,cpl_index) = cpl_rain(ig,cpl_index) + & |
---|
[1403] | 681 | precip_rain(ig) / REAL(nexca) |
---|
[782] | 682 | cpl_snow(ig,cpl_index) = cpl_snow(ig,cpl_index) + & |
---|
[1403] | 683 | precip_snow(ig) / REAL(nexca) |
---|
[782] | 684 | cpl_evap(ig,cpl_index) = cpl_evap(ig,cpl_index) + & |
---|
[1403] | 685 | evap(ig) / REAL(nexca) |
---|
[782] | 686 | cpl_tsol(ig,cpl_index) = cpl_tsol(ig,cpl_index) + & |
---|
[1403] | 687 | tsurf(ig) / REAL(nexca) |
---|
[782] | 688 | cpl_fder(ig,cpl_index) = cpl_fder(ig,cpl_index) + & |
---|
[1403] | 689 | fder(ig) / REAL(nexca) |
---|
[782] | 690 | cpl_albe(ig,cpl_index) = cpl_albe(ig,cpl_index) + & |
---|
[1403] | 691 | albsol(ig) / REAL(nexca) |
---|
[782] | 692 | cpl_taux(ig,cpl_index) = cpl_taux(ig,cpl_index) + & |
---|
[1403] | 693 | taux(ig) / REAL(nexca) |
---|
[782] | 694 | cpl_tauy(ig,cpl_index) = cpl_tauy(ig,cpl_index) + & |
---|
[1403] | 695 | tauy(ig) / REAL(nexca) |
---|
[782] | 696 | cpl_windsp(ig,cpl_index) = cpl_windsp(ig,cpl_index) + & |
---|
[1403] | 697 | windsp(ig) / REAL(nexca) |
---|
[2872] | 698 | cpl_sens_rain(ig,cpl_index) = cpl_sens_rain(ig,cpl_index) + & |
---|
| 699 | sens_prec_liq(ig) / REAL(nexca) |
---|
| 700 | cpl_sens_snow(ig,cpl_index) = cpl_sens_snow(ig,cpl_index) + & |
---|
| 701 | sens_prec_sol(ig) / REAL(nexca) |
---|
[1279] | 702 | cpl_taumod(ig,cpl_index) = cpl_taumod(ig,cpl_index) + & |
---|
[1403] | 703 | SQRT ( taux(ig)*taux(ig)+tauy(ig)*tauy(ig) ) / REAL (nexca) |
---|
[782] | 704 | |
---|
[1279] | 705 | IF (carbon_cycle_cpl) THEN |
---|
| 706 | cpl_atm_co2(ig,cpl_index) = cpl_atm_co2(ig,cpl_index) + & |
---|
[1403] | 707 | co2_send(knindex(ig))/ REAL(nexca) |
---|
[3448] | 708 | !!---OB: this is correct but why knindex ?? |
---|
| 709 | ENDIF |
---|
[1279] | 710 | ENDDO |
---|
| 711 | |
---|
[782] | 712 | !************************************************************************************* |
---|
| 713 | ! If the time-step corresponds to the end of coupling period the |
---|
| 714 | ! fields are transformed to the 2D grid. |
---|
| 715 | ! No sending to the coupler (it is done from cpl_send_seaice_fields). |
---|
| 716 | ! |
---|
| 717 | !************************************************************************************* |
---|
| 718 | IF (MOD(itime, nexca) == 0) THEN |
---|
| 719 | |
---|
| 720 | IF (.NOT. ALLOCATED(cpl_sols2D)) THEN |
---|
| 721 | sum_error = 0 |
---|
[2344] | 722 | ALLOCATE(cpl_sols2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 723 | sum_error = sum_error + error |
---|
[2344] | 724 | ALLOCATE(cpl_nsol2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 725 | sum_error = sum_error + error |
---|
[2344] | 726 | ALLOCATE(cpl_rain2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 727 | sum_error = sum_error + error |
---|
[2344] | 728 | ALLOCATE(cpl_snow2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 729 | sum_error = sum_error + error |
---|
[2344] | 730 | ALLOCATE(cpl_evap2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 731 | sum_error = sum_error + error |
---|
[2344] | 732 | ALLOCATE(cpl_tsol2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 733 | sum_error = sum_error + error |
---|
[2344] | 734 | ALLOCATE(cpl_fder2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 735 | sum_error = sum_error + error |
---|
[2344] | 736 | ALLOCATE(cpl_albe2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 737 | sum_error = sum_error + error |
---|
[2344] | 738 | ALLOCATE(cpl_taux2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 739 | sum_error = sum_error + error |
---|
[2344] | 740 | ALLOCATE(cpl_tauy2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 741 | sum_error = sum_error + error |
---|
[2344] | 742 | ALLOCATE(cpl_windsp2D(nbp_lon,jj_nb), stat=error) |
---|
[782] | 743 | sum_error = sum_error + error |
---|
[2872] | 744 | ALLOCATE(cpl_sens_rain2D(nbp_lon,jj_nb,2), stat=error) |
---|
| 745 | sum_error = sum_error + error |
---|
| 746 | ALLOCATE(cpl_sens_snow2D(nbp_lon,jj_nb,2), stat=error) |
---|
| 747 | sum_error = sum_error + error |
---|
[2344] | 748 | ALLOCATE(cpl_taumod2D(nbp_lon,jj_nb,2), stat=error) |
---|
[1279] | 749 | sum_error = sum_error + error |
---|
[782] | 750 | |
---|
[1279] | 751 | IF (carbon_cycle_cpl) THEN |
---|
[2344] | 752 | ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error) |
---|
[1279] | 753 | sum_error = sum_error + error |
---|
[3448] | 754 | ENDIF |
---|
[1279] | 755 | |
---|
[782] | 756 | IF (sum_error /= 0) THEN |
---|
| 757 | abort_message='Pb allocation variables couplees pour l''ecriture' |
---|
[2311] | 758 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 759 | ENDIF |
---|
| 760 | ENDIF |
---|
| 761 | |
---|
| 762 | |
---|
[1146] | 763 | CALL gath2cpl(cpl_sols(:,cpl_index), cpl_sols2D(:,:,cpl_index), & |
---|
[782] | 764 | knon, knindex) |
---|
| 765 | |
---|
[1146] | 766 | CALL gath2cpl(cpl_nsol(:,cpl_index), cpl_nsol2D(:,:,cpl_index), & |
---|
[782] | 767 | knon, knindex) |
---|
| 768 | |
---|
[1146] | 769 | CALL gath2cpl(cpl_rain(:,cpl_index), cpl_rain2D(:,:,cpl_index), & |
---|
[782] | 770 | knon, knindex) |
---|
| 771 | |
---|
[1146] | 772 | CALL gath2cpl(cpl_snow(:,cpl_index), cpl_snow2D(:,:,cpl_index), & |
---|
[782] | 773 | knon, knindex) |
---|
| 774 | |
---|
[1146] | 775 | CALL gath2cpl(cpl_evap(:,cpl_index), cpl_evap2D(:,:,cpl_index), & |
---|
[782] | 776 | knon, knindex) |
---|
| 777 | |
---|
| 778 | ! cpl_tsol2D(:,:,:) not used! |
---|
[1146] | 779 | CALL gath2cpl(cpl_tsol(:,cpl_index), cpl_tsol2D(:,:, cpl_index), & |
---|
[782] | 780 | knon, knindex) |
---|
| 781 | |
---|
| 782 | ! cpl_fder2D(:,:,1) not used, only cpl_fder(:,:,2)! |
---|
[1146] | 783 | CALL gath2cpl(cpl_fder(:,cpl_index), cpl_fder2D(:,:,cpl_index), & |
---|
[782] | 784 | knon, knindex) |
---|
| 785 | |
---|
| 786 | ! cpl_albe2D(:,:,:) not used! |
---|
[1146] | 787 | CALL gath2cpl(cpl_albe(:,cpl_index), cpl_albe2D(:,:,cpl_index), & |
---|
[782] | 788 | knon, knindex) |
---|
| 789 | |
---|
[1146] | 790 | CALL gath2cpl(cpl_taux(:,cpl_index), cpl_taux2D(:,:,cpl_index), & |
---|
[782] | 791 | knon, knindex) |
---|
| 792 | |
---|
[1146] | 793 | CALL gath2cpl(cpl_tauy(:,cpl_index), cpl_tauy2D(:,:,cpl_index), & |
---|
[782] | 794 | knon, knindex) |
---|
| 795 | |
---|
[1146] | 796 | CALL gath2cpl(cpl_windsp(:,cpl_index), cpl_windsp2D(:,:), & |
---|
[782] | 797 | knon, knindex) |
---|
| 798 | |
---|
[2872] | 799 | CALL gath2cpl(cpl_sens_rain(:,cpl_index), cpl_sens_rain2D(:,:,cpl_index), & |
---|
| 800 | knon, knindex) |
---|
| 801 | |
---|
| 802 | CALL gath2cpl(cpl_sens_snow(:,cpl_index), cpl_sens_snow2D(:,:,cpl_index), & |
---|
| 803 | knon, knindex) |
---|
| 804 | |
---|
[1279] | 805 | CALL gath2cpl(cpl_taumod(:,cpl_index), cpl_taumod2D(:,:,cpl_index), & |
---|
| 806 | knon, knindex) |
---|
[782] | 807 | |
---|
[1279] | 808 | IF (carbon_cycle_cpl) & |
---|
| 809 | CALL gath2cpl(cpl_atm_co2(:,cpl_index), cpl_atm_co22D(:,:), knon, knindex) |
---|
| 810 | ENDIF |
---|
| 811 | |
---|
[782] | 812 | END SUBROUTINE cpl_send_ocean_fields |
---|
| 813 | |
---|
| 814 | ! |
---|
| 815 | !************************************************************************************* |
---|
| 816 | ! |
---|
| 817 | |
---|
| 818 | SUBROUTINE cpl_send_seaice_fields(itime, dtime, knon, knindex, & |
---|
| 819 | pctsrf, lafin, rlon, rlat, & |
---|
| 820 | swdown, lwdown, fluxlat, fluxsens, & |
---|
[2872] | 821 | precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy,& |
---|
| 822 | sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol) |
---|
[782] | 823 | ! |
---|
| 824 | ! This subroutine cumulates some fields for each time-step during a coupling |
---|
| 825 | ! period. At last time-step in a coupling period the fields are transformed to the |
---|
| 826 | ! grid accepted by the coupler. All fields for all types of surfaces are sent to |
---|
| 827 | ! the coupler. |
---|
| 828 | ! |
---|
[1279] | 829 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl |
---|
[1785] | 830 | USE indice_sol_mod |
---|
[2344] | 831 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[782] | 832 | |
---|
| 833 | ! Input arguments |
---|
| 834 | !************************************************************************************* |
---|
| 835 | INTEGER, INTENT(IN) :: itime |
---|
| 836 | INTEGER, INTENT(IN) :: knon |
---|
| 837 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 838 | REAL, INTENT(IN) :: dtime |
---|
| 839 | REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat |
---|
| 840 | REAL, DIMENSION(klon), INTENT(IN) :: swdown, lwdown |
---|
| 841 | REAL, DIMENSION(klon), INTENT(IN) :: fluxlat, fluxsens |
---|
| 842 | REAL, DIMENSION(klon), INTENT(IN) :: precip_rain, precip_snow |
---|
| 843 | REAL, DIMENSION(klon), INTENT(IN) :: evap, tsurf, fder |
---|
| 844 | REAL, DIMENSION(klon), INTENT(IN) :: albsol, taux, tauy |
---|
| 845 | REAL, DIMENSION(klon,nbsrf), INTENT(IN) :: pctsrf |
---|
[2872] | 846 | REAL, DIMENSION(klon), INTENT(IN) :: sens_prec_liq, sens_prec_sol |
---|
| 847 | REAL, DIMENSION(klon), INTENT(IN) :: lat_prec_liq, lat_prec_sol |
---|
[782] | 848 | LOGICAL, INTENT(IN) :: lafin |
---|
| 849 | |
---|
| 850 | ! Local variables |
---|
| 851 | !************************************************************************************* |
---|
| 852 | INTEGER :: cpl_index, ig |
---|
| 853 | INTEGER :: error, sum_error |
---|
| 854 | CHARACTER(len = 25) :: modname = 'cpl_send_seaice_fields' |
---|
| 855 | CHARACTER(len = 80) :: abort_message |
---|
[1146] | 856 | REAL, DIMENSION(klon) :: cpl_fder_tmp |
---|
[782] | 857 | |
---|
| 858 | !************************************************************************************* |
---|
| 859 | ! Start calulation |
---|
| 860 | ! The sea-ice points are saved with second array index=2 |
---|
| 861 | ! |
---|
| 862 | !************************************************************************************* |
---|
| 863 | cpl_index = 2 |
---|
| 864 | |
---|
| 865 | !************************************************************************************* |
---|
| 866 | ! Reset fields to zero in the beginning of a new coupling period |
---|
| 867 | ! |
---|
| 868 | !************************************************************************************* |
---|
| 869 | IF (MOD(itime, nexca) == 1) THEN |
---|
[996] | 870 | cpl_sols(1:knon,cpl_index) = 0.0 |
---|
| 871 | cpl_nsol(1:knon,cpl_index) = 0.0 |
---|
| 872 | cpl_rain(1:knon,cpl_index) = 0.0 |
---|
| 873 | cpl_snow(1:knon,cpl_index) = 0.0 |
---|
| 874 | cpl_evap(1:knon,cpl_index) = 0.0 |
---|
| 875 | cpl_tsol(1:knon,cpl_index) = 0.0 |
---|
| 876 | cpl_fder(1:knon,cpl_index) = 0.0 |
---|
| 877 | cpl_albe(1:knon,cpl_index) = 0.0 |
---|
| 878 | cpl_taux(1:knon,cpl_index) = 0.0 |
---|
| 879 | cpl_tauy(1:knon,cpl_index) = 0.0 |
---|
[2872] | 880 | cpl_sens_rain(1:knon,cpl_index) = 0.0 |
---|
| 881 | cpl_sens_snow(1:knon,cpl_index) = 0.0 |
---|
[1279] | 882 | cpl_taumod(1:knon,cpl_index) = 0.0 |
---|
[782] | 883 | ENDIF |
---|
| 884 | |
---|
| 885 | !************************************************************************************* |
---|
| 886 | ! Cumulate at each time-step |
---|
| 887 | ! |
---|
| 888 | !************************************************************************************* |
---|
| 889 | DO ig = 1, knon |
---|
| 890 | cpl_sols(ig,cpl_index) = cpl_sols(ig,cpl_index) + & |
---|
[1403] | 891 | swdown(ig) / REAL(nexca) |
---|
[782] | 892 | cpl_nsol(ig,cpl_index) = cpl_nsol(ig,cpl_index) + & |
---|
[1403] | 893 | (lwdown(ig) + fluxlat(ig) +fluxsens(ig)) / REAL(nexca) |
---|
[782] | 894 | cpl_rain(ig,cpl_index) = cpl_rain(ig,cpl_index) + & |
---|
[1403] | 895 | precip_rain(ig) / REAL(nexca) |
---|
[782] | 896 | cpl_snow(ig,cpl_index) = cpl_snow(ig,cpl_index) + & |
---|
[1403] | 897 | precip_snow(ig) / REAL(nexca) |
---|
[782] | 898 | cpl_evap(ig,cpl_index) = cpl_evap(ig,cpl_index) + & |
---|
[1403] | 899 | evap(ig) / REAL(nexca) |
---|
[782] | 900 | cpl_tsol(ig,cpl_index) = cpl_tsol(ig,cpl_index) + & |
---|
[1403] | 901 | tsurf(ig) / REAL(nexca) |
---|
[782] | 902 | cpl_fder(ig,cpl_index) = cpl_fder(ig,cpl_index) + & |
---|
[1403] | 903 | fder(ig) / REAL(nexca) |
---|
[782] | 904 | cpl_albe(ig,cpl_index) = cpl_albe(ig,cpl_index) + & |
---|
[1403] | 905 | albsol(ig) / REAL(nexca) |
---|
[782] | 906 | cpl_taux(ig,cpl_index) = cpl_taux(ig,cpl_index) + & |
---|
[1403] | 907 | taux(ig) / REAL(nexca) |
---|
[782] | 908 | cpl_tauy(ig,cpl_index) = cpl_tauy(ig,cpl_index) + & |
---|
[1403] | 909 | tauy(ig) / REAL(nexca) |
---|
[2872] | 910 | cpl_sens_rain(ig,cpl_index) = cpl_sens_rain(ig,cpl_index) + & |
---|
| 911 | sens_prec_liq(ig) / REAL(nexca) |
---|
| 912 | cpl_sens_snow(ig,cpl_index) = cpl_sens_snow(ig,cpl_index) + & |
---|
| 913 | sens_prec_sol(ig) / REAL(nexca) |
---|
[1279] | 914 | cpl_taumod(ig,cpl_index) = cpl_taumod(ig,cpl_index) + & |
---|
[1403] | 915 | SQRT ( taux(ig)*taux(ig)+tauy(ig)*tauy(ig) ) / REAL(nexca) |
---|
[782] | 916 | ENDDO |
---|
| 917 | |
---|
| 918 | !************************************************************************************* |
---|
| 919 | ! If the time-step corresponds to the end of coupling period the |
---|
| 920 | ! fields are transformed to the 2D grid and all fields are sent to coupler. |
---|
| 921 | ! |
---|
| 922 | !************************************************************************************* |
---|
| 923 | IF (MOD(itime, nexca) == 0) THEN |
---|
| 924 | IF (.NOT. ALLOCATED(cpl_sols2D)) THEN |
---|
| 925 | sum_error = 0 |
---|
[2344] | 926 | ALLOCATE(cpl_sols2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 927 | sum_error = sum_error + error |
---|
[2344] | 928 | ALLOCATE(cpl_nsol2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 929 | sum_error = sum_error + error |
---|
[2344] | 930 | ALLOCATE(cpl_rain2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 931 | sum_error = sum_error + error |
---|
[2344] | 932 | ALLOCATE(cpl_snow2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 933 | sum_error = sum_error + error |
---|
[2344] | 934 | ALLOCATE(cpl_evap2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 935 | sum_error = sum_error + error |
---|
[2344] | 936 | ALLOCATE(cpl_tsol2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 937 | sum_error = sum_error + error |
---|
[2344] | 938 | ALLOCATE(cpl_fder2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 939 | sum_error = sum_error + error |
---|
[2344] | 940 | ALLOCATE(cpl_albe2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 941 | sum_error = sum_error + error |
---|
[2344] | 942 | ALLOCATE(cpl_taux2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 943 | sum_error = sum_error + error |
---|
[2344] | 944 | ALLOCATE(cpl_tauy2D(nbp_lon,jj_nb,2), stat=error) |
---|
[782] | 945 | sum_error = sum_error + error |
---|
[2344] | 946 | ALLOCATE(cpl_windsp2D(nbp_lon,jj_nb), stat=error) |
---|
[782] | 947 | sum_error = sum_error + error |
---|
[2872] | 948 | ALLOCATE(cpl_sens_rain2D(nbp_lon,jj_nb,2), stat=error) |
---|
| 949 | sum_error = sum_error + error |
---|
| 950 | ALLOCATE(cpl_sens_snow2D(nbp_lon,jj_nb,2), stat=error) |
---|
| 951 | sum_error = sum_error + error |
---|
[2344] | 952 | ALLOCATE(cpl_taumod2D(nbp_lon,jj_nb,2), stat=error) |
---|
[1279] | 953 | sum_error = sum_error + error |
---|
| 954 | |
---|
| 955 | IF (carbon_cycle_cpl) THEN |
---|
[2344] | 956 | ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error) |
---|
[1279] | 957 | sum_error = sum_error + error |
---|
[3448] | 958 | ENDIF |
---|
[1279] | 959 | |
---|
[782] | 960 | IF (sum_error /= 0) THEN |
---|
| 961 | abort_message='Pb allocation variables couplees pour l''ecriture' |
---|
[2311] | 962 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 963 | ENDIF |
---|
| 964 | ENDIF |
---|
| 965 | |
---|
[1146] | 966 | CALL gath2cpl(cpl_sols(:,cpl_index), cpl_sols2D(:,:,cpl_index), & |
---|
[782] | 967 | knon, knindex) |
---|
| 968 | |
---|
[1146] | 969 | CALL gath2cpl(cpl_nsol(:,cpl_index), cpl_nsol2D(:,:,cpl_index), & |
---|
[782] | 970 | knon, knindex) |
---|
| 971 | |
---|
[1146] | 972 | CALL gath2cpl(cpl_rain(:,cpl_index), cpl_rain2D(:,:,cpl_index), & |
---|
[782] | 973 | knon, knindex) |
---|
| 974 | |
---|
[1146] | 975 | CALL gath2cpl(cpl_snow(:,cpl_index), cpl_snow2D(:,:,cpl_index), & |
---|
[782] | 976 | knon, knindex) |
---|
| 977 | |
---|
[1146] | 978 | CALL gath2cpl(cpl_evap(:,cpl_index), cpl_evap2D(:,:,cpl_index), & |
---|
[782] | 979 | knon, knindex) |
---|
| 980 | |
---|
| 981 | ! cpl_tsol2D(:,:,:) not used! |
---|
[1146] | 982 | CALL gath2cpl(cpl_tsol(:,cpl_index), cpl_tsol2D(:,:, cpl_index), & |
---|
[782] | 983 | knon, knindex) |
---|
| 984 | |
---|
[1146] | 985 | ! Set default value and decompress before gath2cpl |
---|
| 986 | cpl_fder_tmp(:) = -20. |
---|
| 987 | DO ig = 1, knon |
---|
| 988 | cpl_fder_tmp(knindex(ig))=cpl_fder(ig,cpl_index) |
---|
[3448] | 989 | ENDDO |
---|
[1146] | 990 | CALL gath2cpl(cpl_fder_tmp(:), cpl_fder2D(:,:,cpl_index), & |
---|
| 991 | klon, unity) |
---|
[782] | 992 | |
---|
| 993 | ! cpl_albe2D(:,:,:) not used! |
---|
[1146] | 994 | CALL gath2cpl(cpl_albe(:,cpl_index), cpl_albe2D(:,:,cpl_index), & |
---|
[782] | 995 | knon, knindex) |
---|
| 996 | |
---|
[1146] | 997 | CALL gath2cpl(cpl_taux(:,cpl_index), cpl_taux2D(:,:,cpl_index), & |
---|
[782] | 998 | knon, knindex) |
---|
| 999 | |
---|
[1146] | 1000 | CALL gath2cpl(cpl_tauy(:,cpl_index), cpl_tauy2D(:,:,cpl_index), & |
---|
[782] | 1001 | knon, knindex) |
---|
| 1002 | |
---|
[2872] | 1003 | CALL gath2cpl(cpl_sens_rain(:,cpl_index), cpl_sens_rain2D(:,:,cpl_index), & |
---|
| 1004 | knon, knindex) |
---|
| 1005 | |
---|
| 1006 | CALL gath2cpl(cpl_sens_snow(:,cpl_index), cpl_sens_snow2D(:,:,cpl_index), & |
---|
| 1007 | knon, knindex) |
---|
| 1008 | |
---|
[1279] | 1009 | CALL gath2cpl(cpl_taumod(:,cpl_index), cpl_taumod2D(:,:,cpl_index), & |
---|
| 1010 | knon, knindex) |
---|
| 1011 | |
---|
[782] | 1012 | ! Send all fields |
---|
| 1013 | CALL cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat) |
---|
| 1014 | ENDIF |
---|
| 1015 | |
---|
| 1016 | END SUBROUTINE cpl_send_seaice_fields |
---|
| 1017 | |
---|
| 1018 | ! |
---|
| 1019 | !************************************************************************************* |
---|
| 1020 | ! |
---|
| 1021 | |
---|
| 1022 | SUBROUTINE cpl_send_land_fields(itime, knon, knindex, rriv_in, rcoa_in) |
---|
| 1023 | ! |
---|
| 1024 | ! This subroutine cumulates some fields for each time-step during a coupling |
---|
| 1025 | ! period. At last time-step in a coupling period the fields are transformed to the |
---|
| 1026 | ! grid accepted by the coupler. No sending to the coupler will be done from here |
---|
| 1027 | ! (it is done in cpl_send_seaice_fields). |
---|
| 1028 | ! |
---|
[2344] | 1029 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[782] | 1030 | |
---|
| 1031 | ! Input arguments |
---|
| 1032 | !************************************************************************************* |
---|
| 1033 | INTEGER, INTENT(IN) :: itime |
---|
| 1034 | INTEGER, INTENT(IN) :: knon |
---|
| 1035 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 1036 | REAL, DIMENSION(klon), INTENT(IN) :: rriv_in |
---|
| 1037 | REAL, DIMENSION(klon), INTENT(IN) :: rcoa_in |
---|
| 1038 | |
---|
| 1039 | ! Local variables |
---|
| 1040 | !************************************************************************************* |
---|
[2344] | 1041 | REAL, DIMENSION(nbp_lon,jj_nb) :: rriv2D |
---|
| 1042 | REAL, DIMENSION(nbp_lon,jj_nb) :: rcoa2D |
---|
[782] | 1043 | |
---|
| 1044 | !************************************************************************************* |
---|
| 1045 | ! Rearrange fields in 2D variables |
---|
| 1046 | ! First initialize to zero to avoid unvalid points causing problems |
---|
| 1047 | ! |
---|
| 1048 | !************************************************************************************* |
---|
[987] | 1049 | !$OMP MASTER |
---|
[782] | 1050 | rriv2D(:,:) = 0.0 |
---|
| 1051 | rcoa2D(:,:) = 0.0 |
---|
[987] | 1052 | !$OMP END MASTER |
---|
[782] | 1053 | CALL gath2cpl(rriv_in, rriv2D, knon, knindex) |
---|
| 1054 | CALL gath2cpl(rcoa_in, rcoa2D, knon, knindex) |
---|
| 1055 | |
---|
| 1056 | !************************************************************************************* |
---|
| 1057 | ! Reset cumulated fields to zero in the beginning of a new coupling period |
---|
| 1058 | ! |
---|
| 1059 | !************************************************************************************* |
---|
| 1060 | IF (MOD(itime, nexca) == 1) THEN |
---|
[987] | 1061 | !$OMP MASTER |
---|
[782] | 1062 | cpl_rriv2D(:,:) = 0.0 |
---|
| 1063 | cpl_rcoa2D(:,:) = 0.0 |
---|
[987] | 1064 | !$OMP END MASTER |
---|
[782] | 1065 | ENDIF |
---|
| 1066 | |
---|
| 1067 | !************************************************************************************* |
---|
| 1068 | ! Cumulate : Following fields should be cumulated at each time-step |
---|
| 1069 | ! |
---|
| 1070 | !************************************************************************************* |
---|
[987] | 1071 | !$OMP MASTER |
---|
[1403] | 1072 | cpl_rriv2D(:,:) = cpl_rriv2D(:,:) + rriv2D(:,:) / REAL(nexca) |
---|
| 1073 | cpl_rcoa2D(:,:) = cpl_rcoa2D(:,:) + rcoa2D(:,:) / REAL(nexca) |
---|
[987] | 1074 | !$OMP END MASTER |
---|
[782] | 1075 | |
---|
| 1076 | END SUBROUTINE cpl_send_land_fields |
---|
| 1077 | |
---|
| 1078 | ! |
---|
| 1079 | !************************************************************************************* |
---|
| 1080 | ! |
---|
| 1081 | |
---|
| 1082 | SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in) |
---|
| 1083 | ! This subroutine cumulates the field for melting ice for each time-step |
---|
| 1084 | ! during a coupling period. This routine will not send to coupler. Sending |
---|
| 1085 | ! will be done in cpl_send_seaice_fields. |
---|
| 1086 | ! |
---|
[1279] | 1087 | |
---|
[2344] | 1088 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[996] | 1089 | |
---|
[782] | 1090 | ! Input varibales |
---|
| 1091 | !************************************************************************************* |
---|
| 1092 | INTEGER, INTENT(IN) :: itime |
---|
| 1093 | INTEGER, INTENT(IN) :: knon |
---|
| 1094 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 1095 | REAL, DIMENSION(klon), INTENT(IN) :: rlic_in |
---|
| 1096 | |
---|
| 1097 | ! Local varibales |
---|
| 1098 | !************************************************************************************* |
---|
[2344] | 1099 | REAL, DIMENSION(nbp_lon,jj_nb) :: rlic2D |
---|
[782] | 1100 | |
---|
| 1101 | !************************************************************************************* |
---|
| 1102 | ! Rearrange field in a 2D variable |
---|
| 1103 | ! First initialize to zero to avoid unvalid points causing problems |
---|
| 1104 | ! |
---|
| 1105 | !************************************************************************************* |
---|
[987] | 1106 | !$OMP MASTER |
---|
[782] | 1107 | rlic2D(:,:) = 0.0 |
---|
[987] | 1108 | !$OMP END MASTER |
---|
[782] | 1109 | CALL gath2cpl(rlic_in, rlic2D, knon, knindex) |
---|
| 1110 | |
---|
| 1111 | !************************************************************************************* |
---|
| 1112 | ! Reset field to zero in the beginning of a new coupling period |
---|
| 1113 | ! |
---|
| 1114 | !************************************************************************************* |
---|
| 1115 | IF (MOD(itime, nexca) == 1) THEN |
---|
[987] | 1116 | !$OMP MASTER |
---|
[782] | 1117 | cpl_rlic2D(:,:) = 0.0 |
---|
[987] | 1118 | !$OMP END MASTER |
---|
[782] | 1119 | ENDIF |
---|
| 1120 | |
---|
| 1121 | !************************************************************************************* |
---|
| 1122 | ! Cumulate : Melting ice should be cumulated at each time-step |
---|
| 1123 | ! |
---|
| 1124 | !************************************************************************************* |
---|
[987] | 1125 | !$OMP MASTER |
---|
[1403] | 1126 | cpl_rlic2D(:,:) = cpl_rlic2D(:,:) + rlic2D(:,:) / REAL(nexca) |
---|
[987] | 1127 | !$OMP END MASTER |
---|
[782] | 1128 | |
---|
| 1129 | END SUBROUTINE cpl_send_landice_fields |
---|
| 1130 | |
---|
| 1131 | ! |
---|
| 1132 | !************************************************************************************* |
---|
| 1133 | ! |
---|
| 1134 | |
---|
| 1135 | SUBROUTINE cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat) |
---|
| 1136 | ! This routine will send fields for all different surfaces to the coupler. |
---|
| 1137 | ! This subroutine should be executed after calculations by the last surface(sea-ice), |
---|
| 1138 | ! all calculations at the different surfaces have to be done before. |
---|
| 1139 | ! |
---|
[996] | 1140 | USE surface_data |
---|
[1279] | 1141 | USE carbon_cycle_mod, ONLY : carbon_cycle_cpl |
---|
[1785] | 1142 | USE indice_sol_mod |
---|
[2344] | 1143 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
| 1144 | USE time_phylmdz_mod, ONLY: start_time, itau_phy |
---|
[782] | 1145 | ! Some includes |
---|
[2344] | 1146 | ! |
---|
[782] | 1147 | ! Input arguments |
---|
| 1148 | !************************************************************************************* |
---|
| 1149 | INTEGER, INTENT(IN) :: itime |
---|
| 1150 | REAL, INTENT(IN) :: dtime |
---|
| 1151 | REAL, DIMENSION(klon), INTENT(IN) :: rlon, rlat |
---|
| 1152 | REAL, DIMENSION(klon,nbsrf), INTENT(IN) :: pctsrf |
---|
| 1153 | LOGICAL, INTENT(IN) :: lafin |
---|
| 1154 | |
---|
| 1155 | ! Local variables |
---|
| 1156 | !************************************************************************************* |
---|
[3465] | 1157 | INTEGER :: error, sum_error, i,j,k |
---|
[782] | 1158 | INTEGER :: itau_w |
---|
[996] | 1159 | INTEGER :: time_sec |
---|
[2344] | 1160 | INTEGER, DIMENSION(nbp_lon*(nbp_lat)) :: ndexct |
---|
[782] | 1161 | REAL :: Up, Down |
---|
[2344] | 1162 | REAL, DIMENSION(nbp_lon, jj_nb) :: tmp_lon, tmp_lat |
---|
| 1163 | REAL, DIMENSION(nbp_lon, jj_nb, 4) :: pctsrf2D |
---|
| 1164 | REAL, DIMENSION(nbp_lon, jj_nb) :: deno |
---|
[782] | 1165 | CHARACTER(len = 20) :: modname = 'cpl_send_all' |
---|
| 1166 | CHARACTER(len = 80) :: abort_message |
---|
| 1167 | |
---|
| 1168 | ! Variables with fields to coupler |
---|
[2344] | 1169 | REAL, DIMENSION(nbp_lon, jj_nb) :: tmp_taux |
---|
| 1170 | REAL, DIMENSION(nbp_lon, jj_nb) :: tmp_tauy |
---|
| 1171 | REAL, DIMENSION(nbp_lon, jj_nb) :: tmp_calv |
---|
[782] | 1172 | ! Table with all fields to send to coupler |
---|
[2344] | 1173 | REAL, DIMENSION(nbp_lon, jj_nb, maxsend) :: tab_flds |
---|
[3465] | 1174 | REAL, DIMENSION(klon_mpi) :: rlon_mpi, rlat_mpi |
---|
| 1175 | REAL :: calving(nb_zone_calving) |
---|
| 1176 | REAL :: calving_glo(nb_zone_calving) |
---|
| 1177 | |
---|
[1001] | 1178 | #ifdef CPP_MPI |
---|
[782] | 1179 | INCLUDE 'mpif.h' |
---|
| 1180 | INTEGER, DIMENSION(MPI_STATUS_SIZE) :: status |
---|
| 1181 | #endif |
---|
| 1182 | |
---|
| 1183 | ! End definitions |
---|
| 1184 | !************************************************************************************* |
---|
| 1185 | |
---|
| 1186 | |
---|
| 1187 | |
---|
| 1188 | !************************************************************************************* |
---|
| 1189 | ! All fields are stored in a table tab_flds(:,:,:) |
---|
[1146] | 1190 | ! First store the fields which are already on the right format |
---|
[782] | 1191 | ! |
---|
| 1192 | !************************************************************************************* |
---|
[987] | 1193 | !$OMP MASTER |
---|
[1279] | 1194 | tab_flds(:,:,ids_windsp) = cpl_windsp2D(:,:) |
---|
| 1195 | tab_flds(:,:,ids_shfice) = cpl_sols2D(:,:,2) |
---|
| 1196 | tab_flds(:,:,ids_nsfice) = cpl_nsol2D(:,:,2) |
---|
| 1197 | tab_flds(:,:,ids_dflxdt) = cpl_fder2D(:,:,2) |
---|
[2872] | 1198 | tab_flds(:,:,ids_qraioc) = cpl_sens_rain2D(:,:,1) |
---|
| 1199 | tab_flds(:,:,ids_qsnooc) = cpl_sens_snow2D(:,:,1) |
---|
| 1200 | tab_flds(:,:,ids_qraiic) = cpl_sens_rain2D(:,:,2) |
---|
| 1201 | tab_flds(:,:,ids_qsnoic) = cpl_sens_snow2D(:,:,2) |
---|
[1146] | 1202 | |
---|
[996] | 1203 | IF (version_ocean=='nemo') THEN |
---|
[3465] | 1204 | tab_flds(:,:,ids_liqrun) = (cpl_rriv2D(:,:) + cpl_rcoa2D(:,:)) |
---|
[1279] | 1205 | IF (carbon_cycle_cpl) tab_flds(:,:,ids_atmco2)=cpl_atm_co22D(:,:) |
---|
[996] | 1206 | ELSE IF (version_ocean=='opa8') THEN |
---|
[1279] | 1207 | tab_flds(:,:,ids_shfoce) = cpl_sols2D(:,:,1) |
---|
| 1208 | tab_flds(:,:,ids_nsfoce) = cpl_nsol2D(:,:,1) |
---|
| 1209 | tab_flds(:,:,ids_icevap) = cpl_evap2D(:,:,2) |
---|
| 1210 | tab_flds(:,:,ids_ocevap) = cpl_evap2D(:,:,1) |
---|
| 1211 | tab_flds(:,:,ids_runcoa) = cpl_rcoa2D(:,:) |
---|
| 1212 | tab_flds(:,:,ids_rivflu) = cpl_rriv2D(:,:) |
---|
[3448] | 1213 | ENDIF |
---|
[1146] | 1214 | |
---|
[782] | 1215 | !************************************************************************************* |
---|
| 1216 | ! Transform the fraction of sub-surfaces from 1D to 2D array |
---|
| 1217 | ! |
---|
| 1218 | !************************************************************************************* |
---|
| 1219 | pctsrf2D(:,:,:) = 0. |
---|
[987] | 1220 | !$OMP END MASTER |
---|
[782] | 1221 | CALL gath2cpl(pctsrf(:,is_oce), pctsrf2D(:,:,is_oce), klon, unity) |
---|
| 1222 | CALL gath2cpl(pctsrf(:,is_sic), pctsrf2D(:,:,is_sic), klon, unity) |
---|
| 1223 | CALL gath2cpl(pctsrf(:,is_lic), pctsrf2D(:,:,is_lic), klon, unity) |
---|
| 1224 | |
---|
| 1225 | !************************************************************************************* |
---|
| 1226 | ! Calculate the average calving per latitude |
---|
| 1227 | ! Store calving in tab_flds(:,:,19) |
---|
| 1228 | ! |
---|
| 1229 | !************************************************************************************* |
---|
[987] | 1230 | IF (is_omp_root) THEN |
---|
| 1231 | |
---|
[3465] | 1232 | IF (cpl_old_calving) THEN ! use old calving |
---|
| 1233 | |
---|
[1001] | 1234 | DO j = 1, jj_nb |
---|
[2344] | 1235 | tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:nbp_lon,j), & |
---|
| 1236 | pctsrf2D(1:nbp_lon,j,is_lic)) / REAL(nbp_lon) |
---|
[1001] | 1237 | ENDDO |
---|
[782] | 1238 | |
---|
[1001] | 1239 | |
---|
| 1240 | IF (is_parallel) THEN |
---|
[2429] | 1241 | IF (.NOT. is_north_pole_dyn) THEN |
---|
[1001] | 1242 | #ifdef CPP_MPI |
---|
[987] | 1243 | CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error) |
---|
| 1244 | CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error) |
---|
[782] | 1245 | #endif |
---|
[987] | 1246 | ENDIF |
---|
[1001] | 1247 | |
---|
[2429] | 1248 | IF (.NOT. is_south_pole_dyn) THEN |
---|
[1001] | 1249 | #ifdef CPP_MPI |
---|
[987] | 1250 | CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error) |
---|
| 1251 | CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error) |
---|
[782] | 1252 | #endif |
---|
[987] | 1253 | ENDIF |
---|
[996] | 1254 | |
---|
[2429] | 1255 | IF (.NOT. is_north_pole_dyn .AND. ii_begin /=1) THEN |
---|
[2344] | 1256 | Up=Up+tmp_calv(nbp_lon,1) |
---|
[987] | 1257 | tmp_calv(:,1)=Up |
---|
| 1258 | ENDIF |
---|
[996] | 1259 | |
---|
[2429] | 1260 | IF (.NOT. is_south_pole_dyn .AND. ii_end /= nbp_lon) THEN |
---|
[987] | 1261 | Down=Down+tmp_calv(1,jj_nb) |
---|
| 1262 | tmp_calv(:,jj_nb)=Down |
---|
| 1263 | ENDIF |
---|
| 1264 | ENDIF |
---|
[1279] | 1265 | tab_flds(:,:,ids_calvin) = tmp_calv(:,:) |
---|
[782] | 1266 | |
---|
[3465] | 1267 | ENDIF |
---|
| 1268 | |
---|
| 1269 | DO k=1,nb_zone_calving |
---|
| 1270 | calving(k)=0 |
---|
| 1271 | DO j = 1, jj_nb |
---|
| 1272 | calving(k)= calving(k)+DOT_PRODUCT(cpl_rlic2D(:,j)*area_calving(:,j,k),pctsrf2D(:,j,is_lic)) |
---|
| 1273 | ENDDO |
---|
| 1274 | ENDDO |
---|
| 1275 | |
---|
[3467] | 1276 | #ifdef CPP_MPI |
---|
[3465] | 1277 | CALL MPI_ALLREDUCE(calving, calving_glo, nb_zone_calving, MPI_REAL_LMDZ, MPI_SUM, COMM_LMDZ_PHY, error) |
---|
[3467] | 1278 | #endif |
---|
[3465] | 1279 | |
---|
| 1280 | tab_flds(:,:,ids_calvin) = 0 |
---|
| 1281 | DO k=1,nb_zone_calving |
---|
| 1282 | IF (ind_calving(k)>0 ) THEN |
---|
| 1283 | j=(ind_calving(k)-1)/nbp_lon + 1 |
---|
| 1284 | i=MOD(ind_calving(k)-1,nbp_lon)+1 |
---|
| 1285 | tab_flds(i,j,ids_calvin) = calving_glo(k) |
---|
| 1286 | ENDIF |
---|
| 1287 | ENDDO |
---|
| 1288 | |
---|
[782] | 1289 | !************************************************************************************* |
---|
| 1290 | ! Calculate total flux for snow, rain and wind with weighted addition using the |
---|
| 1291 | ! fractions of ocean and seaice. |
---|
| 1292 | ! |
---|
| 1293 | !************************************************************************************* |
---|
[996] | 1294 | ! fraction oce+seaice |
---|
| 1295 | deno = pctsrf2D(:,:,is_oce) + pctsrf2D(:,:,is_sic) |
---|
[836] | 1296 | |
---|
[996] | 1297 | IF (version_ocean=='nemo') THEN |
---|
[1279] | 1298 | tab_flds(:,:,ids_shftot) = 0.0 |
---|
| 1299 | tab_flds(:,:,ids_nsftot) = 0.0 |
---|
| 1300 | tab_flds(:,:,ids_totrai) = 0.0 |
---|
| 1301 | tab_flds(:,:,ids_totsno) = 0.0 |
---|
| 1302 | tab_flds(:,:,ids_toteva) = 0.0 |
---|
| 1303 | tab_flds(:,:,ids_taumod) = 0.0 |
---|
[1146] | 1304 | |
---|
[996] | 1305 | tmp_taux(:,:) = 0.0 |
---|
| 1306 | tmp_tauy(:,:) = 0.0 |
---|
| 1307 | ! For all valid grid cells containing some fraction of ocean or sea-ice |
---|
| 1308 | WHERE ( deno(:,:) /= 0 ) |
---|
| 1309 | tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
| 1310 | cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
| 1311 | tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
| 1312 | cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1313 | |
---|
| 1314 | tab_flds(:,:,ids_shftot) = cpl_sols2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[1146] | 1315 | cpl_sols2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1316 | tab_flds(:,:,ids_nsftot) = cpl_nsol2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[1146] | 1317 | cpl_nsol2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1318 | tab_flds(:,:,ids_totrai) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[1146] | 1319 | cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1320 | tab_flds(:,:,ids_totsno) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[1146] | 1321 | cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1322 | tab_flds(:,:,ids_toteva) = cpl_evap2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[1146] | 1323 | cpl_evap2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1324 | tab_flds(:,:,ids_taumod) = cpl_taumod2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
| 1325 | cpl_taumod2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
| 1326 | |
---|
[1146] | 1327 | ENDWHERE |
---|
| 1328 | |
---|
[1279] | 1329 | tab_flds(:,:,ids_icevap) = cpl_evap2D(:,:,2) |
---|
[996] | 1330 | |
---|
| 1331 | ELSE IF (version_ocean=='opa8') THEN |
---|
[1146] | 1332 | ! Store fields for rain and snow in tab_flds(:,:,15) and tab_flds(:,:,16) |
---|
[1279] | 1333 | tab_flds(:,:,ids_totrai) = 0.0 |
---|
| 1334 | tab_flds(:,:,ids_totsno) = 0.0 |
---|
[996] | 1335 | tmp_taux(:,:) = 0.0 |
---|
| 1336 | tmp_tauy(:,:) = 0.0 |
---|
| 1337 | ! For all valid grid cells containing some fraction of ocean or sea-ice |
---|
| 1338 | WHERE ( deno(:,:) /= 0 ) |
---|
[1279] | 1339 | tab_flds(:,:,ids_totrai) = cpl_rain2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[996] | 1340 | cpl_rain2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
[1279] | 1341 | tab_flds(:,:,ids_totsno) = cpl_snow2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
[996] | 1342 | cpl_snow2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
| 1343 | |
---|
| 1344 | tmp_taux = cpl_taux2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
| 1345 | cpl_taux2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
| 1346 | tmp_tauy = cpl_tauy2D(:,:,1) * pctsrf2D(:,:,is_oce) / deno(:,:) + & |
---|
| 1347 | cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) |
---|
| 1348 | ENDWHERE |
---|
[3448] | 1349 | ENDIF |
---|
[987] | 1350 | |
---|
[996] | 1351 | ENDIF ! is_omp_root |
---|
| 1352 | |
---|
[782] | 1353 | !************************************************************************************* |
---|
| 1354 | ! Transform the wind components from local atmospheric 2D coordinates to geocentric |
---|
| 1355 | ! 3D coordinates. |
---|
| 1356 | ! Store the resulting wind components in tab_flds(:,:,1:6) |
---|
| 1357 | !************************************************************************************* |
---|
| 1358 | |
---|
| 1359 | ! Transform the longitudes and latitudes on 2D arrays |
---|
[1001] | 1360 | |
---|
[987] | 1361 | CALL gather_omp(rlon,rlon_mpi) |
---|
| 1362 | CALL gather_omp(rlat,rlat_mpi) |
---|
| 1363 | !$OMP MASTER |
---|
| 1364 | CALL Grid1DTo2D_mpi(rlon_mpi,tmp_lon) |
---|
| 1365 | CALL Grid1DTo2D_mpi(rlat_mpi,tmp_lat) |
---|
| 1366 | !$OMP END MASTER |
---|
| 1367 | |
---|
[782] | 1368 | IF (is_sequential) THEN |
---|
[2429] | 1369 | IF (is_north_pole_dyn) tmp_lon(:,1) = tmp_lon(:,2) |
---|
| 1370 | IF (is_south_pole_dyn) tmp_lon(:,nbp_lat) = tmp_lon(:,nbp_lat-1) |
---|
[782] | 1371 | ENDIF |
---|
| 1372 | |
---|
| 1373 | ! NetCDF output of the wind before transformation of coordinate system |
---|
| 1374 | IF (is_sequential) THEN |
---|
| 1375 | ndexct(:) = 0 |
---|
[2344] | 1376 | itau_w = itau_phy + itime + start_time * day_step_phy |
---|
| 1377 | CALL histwrite(nidct,'tauxe',itau_w,tmp_taux,nbp_lon*(nbp_lat),ndexct) |
---|
| 1378 | CALL histwrite(nidct,'tauyn',itau_w,tmp_tauy,nbp_lon*(nbp_lat),ndexct) |
---|
| 1379 | CALL histwrite(nidct,'tmp_lon',itau_w,tmp_lon,nbp_lon*(nbp_lat),ndexct) |
---|
| 1380 | CALL histwrite(nidct,'tmp_lat',itau_w,tmp_lat,nbp_lon*(nbp_lat),ndexct) |
---|
[782] | 1381 | ENDIF |
---|
| 1382 | |
---|
[1067] | 1383 | ! Transform the wind from spherical atmospheric 2D coordinates to geocentric |
---|
| 1384 | ! cartesian 3D coordinates |
---|
[987] | 1385 | !$OMP MASTER |
---|
[2344] | 1386 | CALL atm2geo (nbp_lon, jj_nb, tmp_taux, tmp_tauy, tmp_lon, tmp_lat, & |
---|
[1279] | 1387 | tab_flds(:,:,ids_tauxxu), tab_flds(:,:,ids_tauyyu), tab_flds(:,:,ids_tauzzu) ) |
---|
[782] | 1388 | |
---|
[1279] | 1389 | tab_flds(:,:,ids_tauxxv) = tab_flds(:,:,ids_tauxxu) |
---|
| 1390 | tab_flds(:,:,ids_tauyyv) = tab_flds(:,:,ids_tauyyu) |
---|
| 1391 | tab_flds(:,:,ids_tauzzv) = tab_flds(:,:,ids_tauzzu) |
---|
[987] | 1392 | !$OMP END MASTER |
---|
[782] | 1393 | |
---|
| 1394 | !************************************************************************************* |
---|
| 1395 | ! NetCDF output of all fields just before sending to coupler. |
---|
| 1396 | ! |
---|
| 1397 | !************************************************************************************* |
---|
| 1398 | IF (is_sequential) THEN |
---|
[1279] | 1399 | DO j=1,maxsend |
---|
| 1400 | IF (infosend(j)%action) CALL histwrite(nidct,infosend(j)%name, itau_w, & |
---|
[2344] | 1401 | tab_flds(:,:,j),nbp_lon*(nbp_lat),ndexct) |
---|
[1279] | 1402 | ENDDO |
---|
[782] | 1403 | ENDIF |
---|
| 1404 | !************************************************************************************* |
---|
| 1405 | ! Send the table of all fields |
---|
| 1406 | ! |
---|
| 1407 | !************************************************************************************* |
---|
[996] | 1408 | time_sec=(itime-1)*dtime |
---|
[782] | 1409 | #ifdef CPP_COUPLE |
---|
[987] | 1410 | !$OMP MASTER |
---|
[1010] | 1411 | CALL intocpl(time_sec, lafin, tab_flds(:,:,:)) |
---|
[987] | 1412 | !$OMP END MASTER |
---|
[782] | 1413 | #endif |
---|
| 1414 | |
---|
| 1415 | !************************************************************************************* |
---|
| 1416 | ! Finish with some dellocate |
---|
| 1417 | ! |
---|
| 1418 | !************************************************************************************* |
---|
| 1419 | sum_error=0 |
---|
| 1420 | DEALLOCATE(cpl_sols2D, cpl_nsol2D, cpl_rain2D, cpl_snow2D, stat=error ) |
---|
| 1421 | sum_error = sum_error + error |
---|
| 1422 | DEALLOCATE(cpl_evap2D, cpl_tsol2D, cpl_fder2D, cpl_albe2D, stat=error ) |
---|
| 1423 | sum_error = sum_error + error |
---|
[1279] | 1424 | DEALLOCATE(cpl_taux2D, cpl_tauy2D, cpl_windsp2D, cpl_taumod2D, stat=error ) |
---|
[782] | 1425 | sum_error = sum_error + error |
---|
[2872] | 1426 | DEALLOCATE(cpl_sens_rain2D, cpl_sens_snow2D, stat=error) |
---|
| 1427 | sum_error = sum_error + error |
---|
| 1428 | |
---|
[1279] | 1429 | |
---|
| 1430 | IF (carbon_cycle_cpl) THEN |
---|
| 1431 | DEALLOCATE(cpl_atm_co22D, stat=error ) |
---|
| 1432 | sum_error = sum_error + error |
---|
[3448] | 1433 | ENDIF |
---|
[1279] | 1434 | |
---|
[782] | 1435 | IF (sum_error /= 0) THEN |
---|
| 1436 | abort_message='Pb in deallocation of cpl_xxxx2D coupling variables' |
---|
[2311] | 1437 | CALL abort_physic(modname,abort_message,1) |
---|
[782] | 1438 | ENDIF |
---|
| 1439 | |
---|
| 1440 | END SUBROUTINE cpl_send_all |
---|
| 1441 | ! |
---|
| 1442 | !************************************************************************************* |
---|
| 1443 | ! |
---|
| 1444 | SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex) |
---|
[1001] | 1445 | USE mod_phys_lmdz_para |
---|
[1279] | 1446 | ! Cette routine transforme un champs de la grille 2D recu du coupleur sur la grille |
---|
| 1447 | ! 'gathered' (la grille physiq comprime). |
---|
[782] | 1448 | ! |
---|
| 1449 | ! |
---|
| 1450 | ! input: |
---|
[1279] | 1451 | ! champ_in champ sur la grille 2D |
---|
[782] | 1452 | ! knon nombre de points dans le domaine a traiter |
---|
| 1453 | ! knindex index des points de la surface a traiter |
---|
| 1454 | ! |
---|
| 1455 | ! output: |
---|
[1279] | 1456 | ! champ_out champ sur la grille 'gatherd' |
---|
[782] | 1457 | ! |
---|
[2344] | 1458 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[782] | 1459 | |
---|
| 1460 | ! Input |
---|
| 1461 | INTEGER, INTENT(IN) :: knon |
---|
[2344] | 1462 | REAL, DIMENSION(nbp_lon,jj_nb), INTENT(IN) :: champ_in |
---|
[782] | 1463 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 1464 | |
---|
| 1465 | ! Output |
---|
[987] | 1466 | REAL, DIMENSION(klon_mpi), INTENT(OUT) :: champ_out |
---|
[782] | 1467 | |
---|
| 1468 | ! Local |
---|
| 1469 | INTEGER :: i, ig |
---|
[987] | 1470 | REAL, DIMENSION(klon_mpi) :: temp_mpi |
---|
| 1471 | REAL, DIMENSION(klon) :: temp_omp |
---|
[782] | 1472 | |
---|
| 1473 | !************************************************************************************* |
---|
| 1474 | ! |
---|
[1001] | 1475 | |
---|
| 1476 | |
---|
[2344] | 1477 | ! Transform from 2 dimensions (nbp_lon,jj_nb) to 1 dimension (klon) |
---|
[987] | 1478 | !$OMP MASTER |
---|
| 1479 | CALL Grid2Dto1D_mpi(champ_in,temp_mpi) |
---|
| 1480 | !$OMP END MASTER |
---|
[782] | 1481 | |
---|
[987] | 1482 | CALL scatter_omp(temp_mpi,temp_omp) |
---|
| 1483 | |
---|
[782] | 1484 | ! Compress from klon to knon |
---|
| 1485 | DO i = 1, knon |
---|
| 1486 | ig = knindex(i) |
---|
[987] | 1487 | champ_out(i) = temp_omp(ig) |
---|
[782] | 1488 | ENDDO |
---|
[1001] | 1489 | |
---|
[782] | 1490 | END SUBROUTINE cpl2gath |
---|
| 1491 | ! |
---|
| 1492 | !************************************************************************************* |
---|
| 1493 | ! |
---|
| 1494 | SUBROUTINE gath2cpl(champ_in, champ_out, knon, knindex) |
---|
[987] | 1495 | USE mod_phys_lmdz_para |
---|
[782] | 1496 | ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer |
---|
| 1497 | ! au coupleur. |
---|
| 1498 | ! |
---|
| 1499 | ! input: |
---|
| 1500 | ! champ_in champ sur la grille gathere |
---|
| 1501 | ! knon nombre de points dans le domaine a traiter |
---|
| 1502 | ! knindex index des points de la surface a traiter |
---|
| 1503 | ! |
---|
| 1504 | ! output: |
---|
| 1505 | ! champ_out champ sur la grille 2D |
---|
| 1506 | ! |
---|
[2344] | 1507 | USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat |
---|
[782] | 1508 | |
---|
| 1509 | ! Input arguments |
---|
| 1510 | !************************************************************************************* |
---|
| 1511 | INTEGER, INTENT(IN) :: knon |
---|
| 1512 | REAL, DIMENSION(klon), INTENT(IN) :: champ_in |
---|
| 1513 | INTEGER, DIMENSION(klon), INTENT(IN) :: knindex |
---|
| 1514 | |
---|
| 1515 | ! Output arguments |
---|
| 1516 | !************************************************************************************* |
---|
[2344] | 1517 | REAL, DIMENSION(nbp_lon,jj_nb), INTENT(OUT) :: champ_out |
---|
[782] | 1518 | |
---|
| 1519 | ! Local variables |
---|
| 1520 | !************************************************************************************* |
---|
| 1521 | INTEGER :: i, ig |
---|
[987] | 1522 | REAL, DIMENSION(klon) :: temp_omp |
---|
| 1523 | REAL, DIMENSION(klon_mpi) :: temp_mpi |
---|
[782] | 1524 | !************************************************************************************* |
---|
| 1525 | |
---|
| 1526 | ! Decompress from knon to klon |
---|
[987] | 1527 | temp_omp = 0. |
---|
[782] | 1528 | DO i = 1, knon |
---|
| 1529 | ig = knindex(i) |
---|
[987] | 1530 | temp_omp(ig) = champ_in(i) |
---|
[782] | 1531 | ENDDO |
---|
| 1532 | |
---|
[2344] | 1533 | ! Transform from 1 dimension (klon) to 2 dimensions (nbp_lon,jj_nb) |
---|
[987] | 1534 | CALL gather_omp(temp_omp,temp_mpi) |
---|
| 1535 | |
---|
| 1536 | !$OMP MASTER |
---|
| 1537 | CALL Grid1Dto2D_mpi(temp_mpi,champ_out) |
---|
[782] | 1538 | |
---|
[2429] | 1539 | IF (is_north_pole_dyn) champ_out(:,1)=temp_mpi(1) |
---|
| 1540 | IF (is_south_pole_dyn) champ_out(:,jj_nb)=temp_mpi(klon) |
---|
[987] | 1541 | !$OMP END MASTER |
---|
[782] | 1542 | |
---|
| 1543 | END SUBROUTINE gath2cpl |
---|
| 1544 | ! |
---|
| 1545 | !************************************************************************************* |
---|
| 1546 | ! |
---|
| 1547 | END MODULE cpl_mod |
---|
| 1548 | |
---|