Changeset 3605 for LMDZ6/branches/Ocean_skin/libf/phylmd/cpl_mod.F90
- Timestamp:
- Nov 21, 2019, 4:43:45 PM (5 years ago)
- Location:
- LMDZ6/branches/Ocean_skin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Ocean_skin
-
LMDZ6/branches/Ocean_skin/libf/phylmd/cpl_mod.F90
r3102 r3605 97 97 !$OMP THREADPRIVATE(cpl_atm_co22D) 98 98 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 99 111 CONTAINS 100 112 ! … … 105 117 USE surface_data 106 118 USE indice_sol_mod 107 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat 119 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat, grid1dTo2d_glo, klon_glo, grid_type, unstructured, regular_lonlat 108 120 USE time_phylmdz_mod, ONLY: annee_ref, day_ini, itau_phy, itaufin_phy 109 121 USE print_control_mod, ONLY: lunout 122 USE geometry_mod, ONLY : longitude_deg, latitude_deg, ind_cell_glo, cell_area 123 USE ioipsl_getin_p_mod, ONLY: getin_p 110 124 111 125 ! Input arguments … … 127 141 CHARACTER(len = 80) :: abort_message 128 142 CHARACTER(len=80) :: clintocplnam, clfromcplnam 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 148 149 !*************************************** 150 ! Use old calving or not (default new calving method) 151 ! New calving method should be used with DYNAMICO and when using new coupling 152 ! weights. 153 cpl_old_calving=.FALSE. 154 CALL getin_p("cpl_old_calving",cpl_old_calving) 155 129 156 130 157 !************************************************************************************* … … 204 231 205 232 ! Allocate variable in carbon_cycle_mod 206 ALLOCATE(fco2_ocn_day(klon), stat = error)233 IF (.NOT.ALLOCATED(fco2_ocn_day)) ALLOCATE(fco2_ocn_day(klon), stat = error) 207 234 sum_error = sum_error + error 208 END IF 209 235 ENDIF 236 237 ! calving initialization 238 ALLOCATE(area_calving(nbp_lon, jj_nb, nb_zone_calving), stat = error) 239 sum_error = sum_error + error 240 ALLOCATE(cell_area2D(nbp_lon, jj_nb), stat = error) 241 sum_error = sum_error + error 242 243 244 CALL gather_omp(longitude_deg,rlon_mpi) 245 CALL gather_omp(latitude_deg,rlat_mpi) 246 CALL gather_omp(ind_cell_glo,ind_cell_glo_mpi) 247 CALL gather_omp(cell_area,cell_area_mpi) 248 249 IF (is_omp_master) THEN 250 CALL Grid1DTo2D_mpi(rlon_mpi,lon2D) 251 CALL Grid1DTo2D_mpi(rlat_mpi,lat2D) 252 CALL Grid1DTo2D_mpi(cell_area_mpi,cell_area2D) 253 mask_calving(:,:,:) = 0 254 WHERE ( lat2D >= 40) mask_calving(:,:,1) = 1 255 WHERE ( lat2D < 40 .AND. lat2D > -50) mask_calving(:,:,2) = 1 256 WHERE ( lat2D <= -50) mask_calving(:,:,3) = 1 257 258 259 DO i=1,nb_zone_calving 260 area_calving(:,:,i)=mask_calving(:,:,i)*cell_area2D(:,:) 261 pos=1 262 IF (i>1) pos = 1 + ((nbp_lon*nbp_lat-1)*(i-1))/(nb_zone_calving-1) 263 264 ind_calving(i)=0 265 IF (grid_type==unstructured) THEN 266 267 DO ig=1,klon_mpi 268 IF (ind_cell_glo_mpi(ig)==pos) ind_calving(i)=ig 269 ENDDO 270 271 ELSE IF (grid_type==regular_lonlat) THEN 272 IF ((ij_begin<=pos .AND. ij_end>=pos) .OR. (ij_begin<=pos .AND. is_south_pole_dyn )) THEN 273 ind_calving(i)=pos-(jj_begin-1)*nbp_lon 274 ENDIF 275 ENDIF 276 277 ENDDO 278 ENDIF 279 280 210 281 IF (sum_error /= 0) THEN 211 282 abort_message='Pb allocation variables couplees' … … 236 307 idayref = day_ini 237 308 CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian) 238 CALL gr _fi_ecrit(1,klon,nbp_lon,nbp_lat,rlon,zx_lon)309 CALL grid1dTo2d_glo(rlon,zx_lon) 239 310 DO i = 1, nbp_lon 240 311 zx_lon(i,1) = rlon(i+1) 241 312 zx_lon(i,nbp_lat) = rlon(i+1) 242 313 ENDDO 243 CALL gr _fi_ecrit(1,klon,nbp_lon,nbp_lat,rlat,zx_lat)314 CALL grid1dTo2d_glo(rlat,zx_lat) 244 315 clintocplnam="cpl_atm_tauflx" 245 316 CALL histbeg(clintocplnam,nbp_lon,zx_lon(:,1),nbp_lat,zx_lat(1,:),& … … 259 330 "-",nbp_lon,nbp_lat,nhoridct,1,1,1,-99,32,"inst",dtime,dtime) 260 331 ENDIF 261 END 332 ENDDO 262 333 CALL histend(nidct) 263 334 CALL histsync(nidct) … … 272 343 "-",nbp_lon,nbp_lat,nhoridcs,1,1,1,-99,32,"inst",dtime,dtime) 273 344 ENDIF 274 END 345 ENDDO 275 346 CALL histend(nidcs) 276 347 CALL histsync(nidcs) … … 286 357 abort_message='carbon_cycle_cpl does not work with opa8' 287 358 CALL abort_physic(modname,abort_message,1) 288 END 359 ENDIF 289 360 290 361 END SUBROUTINE cpl_init … … 356 427 CALL histwrite(nidcs,inforecv(i)%name,itau_w,tab_read_flds(:,:,i),nbp_lon*(nbp_lat),ndexcs) 357 428 ENDIF 358 END 429 ENDDO 359 430 ENDIF 360 431 … … 415 486 ENDDO 416 487 417 END 488 ENDIF ! if time to receive 418 489 419 490 END SUBROUTINE cpl_receive_frac … … 466 537 DO i=1,klon 467 538 index(i)=i 468 END 539 ENDDO 469 540 CALL cpl2gath(read_co2, fco2_ocn_day, klon, index) 470 END 541 ENDIF 471 542 472 543 !************************************************************************************* … … 477 548 DO i=1, knon 478 549 tsurf_new(i) = tsurf_new(i)/(1. - sic_new(i)) 479 END 550 ENDDO 480 551 481 552 END SUBROUTINE cpl_receive_ocean_fields … … 529 600 tsurf_new(i) = tsurf_new(i) / sic_new(i) 530 601 alb_new(i) = alb_new(i) / sic_new(i) 531 END 602 ENDDO 532 603 533 604 END SUBROUTINE cpl_receive_seaice_fields … … 637 708 cpl_atm_co2(ig,cpl_index) = cpl_atm_co2(ig,cpl_index) + & 638 709 co2_send(knindex(ig))/ REAL(nexca) 639 END IF 710 !!---OB: this is correct but why knindex ?? 711 ENDIF 640 712 ENDDO 641 713 … … 682 754 ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error) 683 755 sum_error = sum_error + error 684 END 756 ENDIF 685 757 686 758 IF (sum_error /= 0) THEN … … 886 958 ALLOCATE(cpl_atm_co22D(nbp_lon,jj_nb), stat=error) 887 959 sum_error = sum_error + error 888 END 960 ENDIF 889 961 890 962 IF (sum_error /= 0) THEN … … 917 989 DO ig = 1, knon 918 990 cpl_fder_tmp(knindex(ig))=cpl_fder(ig,cpl_index) 919 END 991 ENDDO 920 992 CALL gath2cpl(cpl_fder_tmp(:), cpl_fder2D(:,:,cpl_index), & 921 993 klon, unity) … … 1085 1157 ! Local variables 1086 1158 !************************************************************************************* 1087 INTEGER :: error, sum_error, j1159 INTEGER :: error, sum_error, i,j,k 1088 1160 INTEGER :: itau_w 1089 1161 INTEGER :: time_sec … … 1102 1174 ! Table with all fields to send to coupler 1103 1175 REAL, DIMENSION(nbp_lon, jj_nb, maxsend) :: tab_flds 1104 REAL, DIMENSION(klon_mpi) :: rlon_mpi, rlat_mpi 1105 1176 REAL, DIMENSION(klon_mpi) :: rlon_mpi, rlat_mpi 1177 REAL :: calving(nb_zone_calving) 1178 REAL :: calving_glo(nb_zone_calving) 1179 1106 1180 #ifdef CPP_MPI 1107 1181 INCLUDE 'mpif.h' … … 1130 1204 1131 1205 IF (version_ocean=='nemo') THEN 1132 tab_flds(:,:,ids_liqrun) = cpl_rriv2D(:,:) + cpl_rcoa2D(:,:)1206 tab_flds(:,:,ids_liqrun) = (cpl_rriv2D(:,:) + cpl_rcoa2D(:,:)) 1133 1207 IF (carbon_cycle_cpl) tab_flds(:,:,ids_atmco2)=cpl_atm_co22D(:,:) 1134 1208 ELSE IF (version_ocean=='opa8') THEN … … 1139 1213 tab_flds(:,:,ids_runcoa) = cpl_rcoa2D(:,:) 1140 1214 tab_flds(:,:,ids_rivflu) = cpl_rriv2D(:,:) 1141 END 1215 ENDIF 1142 1216 1143 1217 !************************************************************************************* … … 1158 1232 IF (is_omp_root) THEN 1159 1233 1160 DO j = 1, jj_nb 1161 tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:nbp_lon,j), & 1162 pctsrf2D(1:nbp_lon,j,is_lic)) / REAL(nbp_lon) 1163 ENDDO 1164 1165 1166 IF (is_parallel) THEN 1167 IF (.NOT. is_north_pole_dyn) THEN 1234 IF (cpl_old_calving) THEN ! use old calving 1235 1236 DO j = 1, jj_nb 1237 tmp_calv(:,j) = DOT_PRODUCT (cpl_rlic2D(1:nbp_lon,j), & 1238 pctsrf2D(1:nbp_lon,j,is_lic)) / REAL(nbp_lon) 1239 ENDDO 1240 1241 1242 IF (is_parallel) THEN 1243 IF (.NOT. is_north_pole_dyn) THEN 1168 1244 #ifdef CPP_MPI 1169 CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error)1170 CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error)1245 CALL MPI_RECV(Up,1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,status,error) 1246 CALL MPI_SEND(tmp_calv(1,1),1,MPI_REAL_LMDZ,mpi_rank-1,1234,COMM_LMDZ_PHY,error) 1171 1247 #endif 1172 ENDIF1248 ENDIF 1173 1249 1174 IF (.NOT. is_south_pole_dyn) THEN1250 IF (.NOT. is_south_pole_dyn) THEN 1175 1251 #ifdef CPP_MPI 1176 CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error)1177 CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error)1252 CALL MPI_SEND(tmp_calv(1,jj_nb),1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,error) 1253 CALL MPI_RECV(down,1,MPI_REAL_LMDZ,mpi_rank+1,1234,COMM_LMDZ_PHY,status,error) 1178 1254 #endif 1179 ENDIF1255 ENDIF 1180 1256 1181 IF (.NOT. is_north_pole_dyn .AND. ii_begin /=1) THEN 1182 Up=Up+tmp_calv(nbp_lon,1) 1183 tmp_calv(:,1)=Up 1184 ENDIF 1257 IF (.NOT. is_north_pole_dyn .AND. ii_begin /=1) THEN 1258 Up=Up+tmp_calv(nbp_lon,1) 1259 tmp_calv(:,1)=Up 1260 ENDIF 1261 1262 IF (.NOT. is_south_pole_dyn .AND. ii_end /= nbp_lon) THEN 1263 Down=Down+tmp_calv(1,jj_nb) 1264 tmp_calv(:,jj_nb)=Down 1265 ENDIF 1266 ENDIF 1267 tab_flds(:,:,ids_calvin) = tmp_calv(:,:) 1268 1269 ELSE 1270 ! cpl_old_calving=FALSE 1271 ! To be used with new method for calculation of coupling weights 1272 DO k=1,nb_zone_calving 1273 calving(k)=0 1274 DO j = 1, jj_nb 1275 calving(k)= calving(k)+DOT_PRODUCT(cpl_rlic2D(:,j)*area_calving(:,j,k),pctsrf2D(:,j,is_lic)) 1276 ENDDO 1277 ENDDO 1185 1278 1186 IF (.NOT. is_south_pole_dyn .AND. ii_end /= nbp_lon) THEN 1187 Down=Down+tmp_calv(1,jj_nb) 1188 tmp_calv(:,jj_nb)=Down 1189 ENDIF 1279 #ifdef CPP_MPI 1280 CALL MPI_ALLREDUCE(calving, calving_glo, nb_zone_calving, MPI_REAL_LMDZ, MPI_SUM, COMM_LMDZ_PHY, error) 1281 #endif 1282 1283 tab_flds(:,:,ids_calvin) = 0 1284 DO k=1,nb_zone_calving 1285 IF (ind_calving(k)>0 ) THEN 1286 j=(ind_calving(k)-1)/nbp_lon + 1 1287 i=MOD(ind_calving(k)-1,nbp_lon)+1 1288 tab_flds(i,j,ids_calvin) = calving_glo(k) 1289 ENDIF 1290 ENDDO 1291 1190 1292 ENDIF 1191 1293 1192 tab_flds(:,:,ids_calvin) = tmp_calv(:,:)1193 1194 1294 !************************************************************************************* 1195 1295 ! Calculate total flux for snow, rain and wind with weighted addition using the … … 1252 1352 cpl_tauy2D(:,:,2) * pctsrf2D(:,:,is_sic) / deno(:,:) 1253 1353 ENDWHERE 1254 END 1354 ENDIF 1255 1355 1256 1356 ENDIF ! is_omp_root … … 1336 1436 DEALLOCATE(cpl_atm_co22D, stat=error ) 1337 1437 sum_error = sum_error + error 1338 END 1438 ENDIF 1339 1439 1340 1440 IF (sum_error /= 0) THEN
Note: See TracChangeset
for help on using the changeset viewer.