Changeset 5099 for LMDZ6/branches/Amaury_dev/libf/phylmd/cpl_mod.F90
- Timestamp:
- Jul 22, 2024, 9:29:09 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
LMDZ6/branches/Amaury_dev/libf/phylmd/cpl_mod.F90
r4640 r5099 1 ! 1 2 2 MODULE cpl_mod 3 ! 3 4 4 ! This module excahanges and transforms all fields that should be recieved or sent to 5 5 ! coupler. The transformation of the fields are done from the grid 1D-array in phylmd 6 6 ! to the regular 2D grid accepted by the coupler. Cumulation of the fields for each 7 7 ! timestep is done in here. 8 ! 8 9 9 ! Each type of surface that recevie fields from the coupler have a subroutine named 10 10 ! cpl_receive_XXX_fields and each surface that have fields to be sent to the coupler 11 11 ! have a subroutine named cpl_send_XXX_fields. 12 ! 12 13 13 !************************************************************************************* 14 14 … … 129 129 130 130 CONTAINS 131 ! 131 132 132 !************************************************************************************ 133 ! 133 134 134 SUBROUTINE cpl_init(dtime, rlon, rlat) 135 135 USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day … … 178 178 !************************************************************************************* 179 179 ! Calculate coupling period 180 ! 180 181 181 !************************************************************************************* 182 182 … … 191 191 !************************************************************************************* 192 192 ! Allocate variables 193 ! 193 194 194 !************************************************************************************* 195 195 error = 0 … … 324 324 !************************************************************************************* 325 325 ! Initialize the allocated varaibles 326 ! 326 327 327 !************************************************************************************* 328 328 DO ig = 1, klon … … 332 332 !************************************************************************************* 333 333 ! Initialize coupling 334 ! 334 335 335 !************************************************************************************* 336 336 idtime = INT(dtime) … … 341 341 !************************************************************************************* 342 342 ! initialize NetCDF output 343 ! 343 344 344 !************************************************************************************* 345 345 IF (is_sequential) THEN … … 390 390 !************************************************************************************* 391 391 ! compatibility test 392 ! 392 393 393 !************************************************************************************* 394 394 IF (carbon_cycle_cpl .AND. version_ocean=='opa8') THEN … … 398 398 399 399 END SUBROUTINE cpl_init 400 401 ! 402 !************************************************************************************* 403 ! 404 400 401 !************************************************************************************* 402 405 403 SUBROUTINE cpl_receive_frac(itime, dtime, pctsrf, is_modified) 406 404 ! This subroutine receives from coupler for both ocean and seaice … … 442 440 ! Start calculation 443 441 ! Get fields from coupler 444 ! 442 445 443 !************************************************************************************* 446 444 … … 510 508 ! Transform seaice fraction (read_sic : ocean-seaice mask) into global 511 509 ! fraction (pctsrf : ocean-seaice-land-landice mask) 512 ! 510 513 511 !************************************************************************************* 514 512 CALL cpl2gath(read_sic, read_sic1D, klon, unity) … … 530 528 END SUBROUTINE cpl_receive_frac 531 529 532 ! 533 !************************************************************************************* 534 ! 530 !************************************************************************************* 535 531 536 532 SUBROUTINE cpl_receive_ocean_fields(knon, knindex, tsurf_new, u0_new, & 537 533 v0_new, sss) 538 ! 534 539 535 ! This routine returns the field for the ocean that has been read from the coupler 540 536 ! (done earlier with cpl_receive_frac). The field is the temperature. 541 537 ! The temperature is transformed into 1D array with valid points from index 1 to knon. 542 ! 538 543 539 USE carbon_cycle_mod, ONLY : carbon_cycle_cpl, fco2_ocn_day 544 540 USE indice_sol_mod … … 568 564 !************************************************************************************* 569 565 ! Transform read_sst into compressed 1D variable tsurf_new 570 ! 566 571 567 !************************************************************************************* 572 568 CALL cpl2gath(read_sst, tsurf_new, knon, knindex) … … 579 575 ! Transform read_co2 into uncompressed 1D variable fco2_ocn_day added directly in 580 576 ! the module carbon_cycle_mod 581 ! 577 582 578 !************************************************************************************* 583 579 IF (carbon_cycle_cpl) THEN … … 591 587 ! The fields received from the coupler have to be weighted with the fraction of ocean 592 588 ! in relation to the total sea-ice+ocean 593 ! 589 594 590 !************************************************************************************* 595 591 DO i=1, knon … … 599 595 END SUBROUTINE cpl_receive_ocean_fields 600 596 601 ! 602 !************************************************************************************* 603 ! 597 !************************************************************************************* 604 598 605 599 SUBROUTINE cpl_receive_seaice_fields(knon, knindex, & 606 600 tsurf_new, alb_new, u0_new, v0_new) 607 ! 601 608 602 ! This routine returns the fields for the seaice that have been read from the coupler 609 603 ! (done earlier with cpl_receive_frac). These fields are the temperature and 610 604 ! albedo at sea ice surface and fraction of sea ice. 611 605 ! The fields are transformed into 1D arrays with valid points from index 1 to knon. 612 !613 606 614 607 ! Input arguments … … 631 624 !************************************************************************************* 632 625 ! Transform fields read from coupler from 2D into compressed 1D variables 633 ! 626 634 627 !************************************************************************************* 635 628 CALL cpl2gath(read_sit, tsurf_new, knon, knindex) … … 642 635 ! The fields received from the coupler have to be weighted with the sea-ice 643 636 ! concentration (in relation to the total sea-ice + ocean). 644 ! 637 645 638 !************************************************************************************* 646 639 DO i= 1, knon … … 651 644 END SUBROUTINE cpl_receive_seaice_fields 652 645 653 ! 654 !************************************************************************************* 655 ! 646 !************************************************************************************* 656 647 657 648 SUBROUTINE cpl_send_ocean_fields(itime, knon, knindex, & … … 715 706 ! Start calculation 716 707 ! The ocean points are saved with second array index=1 717 ! 708 718 709 !************************************************************************************* 719 710 cpl_index = 1 … … 721 712 !************************************************************************************* 722 713 ! Reset fields to zero in the beginning of a new coupling period 723 ! 714 724 715 !************************************************************************************* 725 716 IF (MOD(itime, nexca) == 1) THEN … … 751 742 !************************************************************************************* 752 743 ! Cumulate at each time-step 753 ! 744 754 745 !************************************************************************************* 755 746 DO ig = 1, knon … … 802 793 ! fields are transformed to the 2D grid. 803 794 ! No sending to the coupler (it is done from cpl_send_seaice_fields). 804 ! 795 805 796 !************************************************************************************* 806 797 IF (MOD(itime, nexca) == 0) THEN … … 915 906 END SUBROUTINE cpl_send_ocean_fields 916 907 917 ! 918 !************************************************************************************* 919 ! 908 !************************************************************************************* 920 909 921 910 SUBROUTINE cpl_send_seaice_fields(itime, dtime, knon, knindex, & … … 924 913 precip_rain, precip_snow, evap, tsurf, fder, albsol, taux, tauy,& 925 914 sens_prec_liq, sens_prec_sol, lat_prec_liq, lat_prec_sol) 926 ! 915 927 916 ! This subroutine cumulates some fields for each time-step during a coupling 928 917 ! period. At last time-step in a coupling period the fields are transformed to the 929 918 ! grid accepted by the coupler. All fields for all types of surfaces are sent to 930 919 ! the coupler. 931 ! 920 932 921 USE carbon_cycle_mod, ONLY : carbon_cycle_cpl 933 922 USE indice_sol_mod … … 962 951 ! Start calulation 963 952 ! The sea-ice points are saved with second array index=2 964 ! 953 965 954 !************************************************************************************* 966 955 cpl_index = 2 … … 968 957 !************************************************************************************* 969 958 ! Reset fields to zero in the beginning of a new coupling period 970 ! 959 971 960 !************************************************************************************* 972 961 IF (MOD(itime, nexca) == 1) THEN … … 988 977 !************************************************************************************* 989 978 ! Cumulate at each time-step 990 ! 979 991 980 !************************************************************************************* 992 981 DO ig = 1, knon … … 1022 1011 ! If the time-step corresponds to the end of coupling period the 1023 1012 ! fields are transformed to the 2D grid and all fields are sent to coupler. 1024 ! 1013 1025 1014 !************************************************************************************* 1026 1015 IF (MOD(itime, nexca) == 0) THEN … … 1119 1108 END SUBROUTINE cpl_send_seaice_fields 1120 1109 1121 ! 1122 !************************************************************************************* 1123 ! 1110 !************************************************************************************* 1124 1111 1125 1112 SUBROUTINE cpl_send_land_fields(itime, knon, knindex, rriv_in, rcoa_in) 1126 ! 1113 1127 1114 ! This subroutine cumulates some fields for each time-step during a coupling 1128 1115 ! period. At last time-step in a coupling period the fields are transformed to the 1129 1116 ! grid accepted by the coupler. No sending to the coupler will be done from here 1130 1117 ! (it is done in cpl_send_seaice_fields). 1131 ! 1118 1132 1119 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat 1133 1120 … … 1148 1135 ! Rearrange fields in 2D variables 1149 1136 ! First initialize to zero to avoid unvalid points causing problems 1150 ! 1137 1151 1138 !************************************************************************************* 1152 1139 !$OMP MASTER … … 1159 1146 !************************************************************************************* 1160 1147 ! Reset cumulated fields to zero in the beginning of a new coupling period 1161 ! 1148 1162 1149 !************************************************************************************* 1163 1150 IF (MOD(itime, nexca) == 1) THEN … … 1170 1157 !************************************************************************************* 1171 1158 ! Cumulate : Following fields should be cumulated at each time-step 1172 ! 1159 1173 1160 !************************************************************************************* 1174 1161 !$OMP MASTER … … 1179 1166 END SUBROUTINE cpl_send_land_fields 1180 1167 1181 ! 1182 !************************************************************************************* 1183 ! 1168 !************************************************************************************* 1184 1169 1185 1170 SUBROUTINE cpl_send_landice_fields(itime, knon, knindex, rlic_in, rlic_in_frac) … … 1187 1172 ! during a coupling period. This routine will not send to coupler. Sending 1188 1173 ! will be done in cpl_send_seaice_fields. 1189 !1190 1174 1191 1175 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat … … 1208 1192 ! Rearrange field in a 2D variable 1209 1193 ! First initialize to zero to avoid unvalid points causing problems 1210 ! 1194 1211 1195 !************************************************************************************* 1212 1196 !$OMP MASTER … … 1217 1201 !************************************************************************************* 1218 1202 ! Reset field to zero in the beginning of a new coupling period 1219 ! 1203 1220 1204 !************************************************************************************* 1221 1205 IF (MOD(itime, nexca) == 1) THEN … … 1227 1211 !************************************************************************************* 1228 1212 ! Cumulate : Melting ice should be cumulated at each time-step 1229 ! 1213 1230 1214 !************************************************************************************* 1231 1215 !$OMP MASTER … … 1235 1219 END SUBROUTINE cpl_send_landice_fields 1236 1220 1237 ! 1238 !************************************************************************************* 1239 ! 1221 !************************************************************************************* 1240 1222 1241 1223 SUBROUTINE cpl_send_all(itime, dtime, pctsrf, lafin, rlon, rlat) … … 1243 1225 ! This subroutine should be executed after calculations by the last surface(sea-ice), 1244 1226 ! all calculations at the different surfaces have to be done before. 1245 ! 1227 1246 1228 USE surface_data 1247 1229 USE carbon_cycle_mod, ONLY : carbon_cycle_cpl … … 1253 1235 1254 1236 ! Some includes 1255 ! 1237 1256 1238 ! Input arguments 1257 1239 !************************************************************************************* … … 1295 1277 ! All fields are stored in a table tab_flds(:,:,:) 1296 1278 ! First store the fields which are already on the right format 1297 ! 1279 1298 1280 !************************************************************************************* 1299 1281 !$OMP MASTER … … 1329 1311 !************************************************************************************* 1330 1312 ! Transform the fraction of sub-surfaces from 1D to 2D array 1331 ! 1313 1332 1314 !************************************************************************************* 1333 1315 pctsrf2D(:,:,:) = 0. … … 1342 1324 ! Calculate the average calving per latitude 1343 1325 ! Store calving in tab_flds(:,:,19) 1344 ! 1326 1345 1327 !************************************************************************************* 1346 1328 IF (is_omp_root) THEN … … 1403 1385 ! Calculate total flux for snow, rain and wind with weighted addition using the 1404 1386 ! fractions of ocean and seaice. 1405 ! 1387 1406 1388 !************************************************************************************* 1407 1389 ! fraction oce+seaice … … 1507 1489 !************************************************************************************* 1508 1490 ! NetCDF output of all fields just before sending to coupler. 1509 ! 1491 1510 1492 !************************************************************************************* 1511 1493 IF (is_sequential) THEN … … 1517 1499 !************************************************************************************* 1518 1500 ! Send the table of all fields 1519 ! 1501 1520 1502 !************************************************************************************* 1521 1503 time_sec=(itime-1)*dtime … … 1528 1510 !************************************************************************************* 1529 1511 ! Finish with some dellocate 1530 ! 1512 1531 1513 !************************************************************************************* 1532 1514 sum_error=0 … … 1555 1537 1556 1538 END SUBROUTINE cpl_send_all 1557 ! 1558 !************************************************************************************* 1559 ! 1539 1540 !************************************************************************************* 1541 1560 1542 SUBROUTINE cpl2gath(champ_in, champ_out, knon, knindex) 1561 1543 USE mod_phys_lmdz_para 1562 1544 ! Cette routine transforme un champs de la grille 2D recu du coupleur sur la grille 1563 1545 ! 'gathered' (la grille physiq comprime). 1564 ! 1565 ! 1546 1547 1566 1548 ! input: 1567 1549 ! champ_in champ sur la grille 2D 1568 1550 ! knon nombre de points dans le domaine a traiter 1569 1551 ! knindex index des points de la surface a traiter 1570 ! 1552 1571 1553 ! output: 1572 1554 ! champ_out champ sur la grille 'gatherd' 1573 ! 1555 1574 1556 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat 1575 1557 … … 1588 1570 1589 1571 !************************************************************************************* 1590 !1591 1592 1572 1593 1573 ! Transform from 2 dimensions (nbp_lon,jj_nb) to 1 dimension (klon) … … 1605 1585 1606 1586 END SUBROUTINE cpl2gath 1607 ! 1608 !************************************************************************************* 1609 ! 1587 1588 !************************************************************************************* 1589 1610 1590 SUBROUTINE gath2cpl(champ_in, champ_out, knon, knindex) 1611 1591 USE mod_phys_lmdz_para 1612 1592 ! Cette routine ecrit un champ 'gathered' sur la grille 2D pour le passer 1613 1593 ! au coupleur. 1614 ! 1594 1615 1595 ! input: 1616 1596 ! champ_in champ sur la grille gathere 1617 1597 ! knon nombre de points dans le domaine a traiter 1618 1598 ! knindex index des points de la surface a traiter 1619 ! 1599 1620 1600 ! output: 1621 1601 ! champ_out champ sur la grille 2D 1622 ! 1602 1623 1603 USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat 1624 1604 … … 1658 1638 1659 1639 END SUBROUTINE gath2cpl 1660 ! 1661 !************************************************************************************* 1662 ! 1640 1641 !************************************************************************************* 1642 1663 1643 END MODULE cpl_mod 1664 1644
Note: See TracChangeset
for help on using the changeset viewer.